1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2024 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
namespace Magento \Theme \Test \Unit \Plugin ;
7
7
10
10
use Magento \Framework \Message \ManagerInterface ;
11
11
use Magento \Framework \View \DesignLoader ;
12
12
use Magento \Theme \Plugin \LoadDesignPlugin ;
13
+ use PHPUnit \Framework \MockObject \Exception ;
13
14
use PHPUnit \Framework \MockObject \MockObject ;
14
15
use PHPUnit \Framework \TestCase ;
15
16
16
17
class LoadDesignPluginTest extends TestCase
17
18
{
18
- public function testBeforeExecute ()
19
+ /**
20
+ * @return void
21
+ * @throws Exception
22
+ */
23
+ public function testBeforeExecute (): void
19
24
{
20
25
/** @var MockObject|ActionInterface $actionMock */
21
26
$ actionMock = $ this ->createMock (Action::class);
@@ -31,4 +36,32 @@ public function testBeforeExecute()
31
36
$ designLoaderMock ->expects ($ this ->once ())->method ('load ' );
32
37
$ plugin ->beforeExecute ($ actionMock );
33
38
}
39
+
40
+ /**
41
+ * @return void
42
+ * @throws Exception
43
+ */
44
+ public function testBeforeExecuteNotThrowException (): void
45
+ {
46
+ /** @var MockObject|ActionInterface $actionMock */
47
+ $ actionMock = $ this ->createMock (Action::class);
48
+
49
+ /** @var MockObject|DesignLoader $designLoaderMock */
50
+ $ designLoaderMock = $ this ->createMock (DesignLoader::class);
51
+
52
+ /** @var MockObject|ManagerInterface $messageManagerMock */
53
+ $ messageManagerMock = $ this ->createMock (ManagerInterface::class);
54
+
55
+ $ plugin = new LoadDesignPlugin ($ designLoaderMock , $ messageManagerMock );
56
+
57
+ $ exceptionMessage = 'test message ' ;
58
+ $ designLoaderMock ->expects ($ this ->once ())
59
+ ->method ('load ' )
60
+ ->willThrowException (new \InvalidArgumentException ($ exceptionMessage ));
61
+ $ messageManagerMock ->expects ($ this ->once ())
62
+ ->method ('addErrorMessage ' )
63
+ ->with ($ exceptionMessage );
64
+
65
+ $ plugin ->beforeExecute ($ actionMock );
66
+ }
34
67
}
0 commit comments