5
5
*/
6
6
namespace Magento \Framework \View ;
7
7
8
- use \Magento \Framework \App \State ;
8
+ use Magento \Framework \App \State ;
9
+ use Magento \Framework \Exception \LocalizedException ;
10
+ use Magento \Framework \View \Layout \Element ;
11
+ use Magento \TestFramework \Helper \Bootstrap ;
12
+ use PHPUnit \Framework \TestCase ;
9
13
10
- class LayoutTestWithExceptions extends \PHPUnit \Framework \TestCase
14
+ /**
15
+ * Class to test Layout model functionality with exceptions
16
+ */
17
+ class LayoutTestWithExceptions extends TestCase
11
18
{
12
19
/**
13
- * @var \Magento\Framework\View\ Layout
20
+ * @var Layout
14
21
*/
15
22
protected $ layout ;
16
23
@@ -19,10 +26,10 @@ class LayoutTestWithExceptions extends \PHPUnit\Framework\TestCase
19
26
*/
20
27
protected function setUp (): void
21
28
{
22
- $ objectManager = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ();
23
- $ layoutFactory = $ objectManager ->get (\ Magento \ Framework \ View \ LayoutFactory::class);
29
+ $ objectManager = Bootstrap::getObjectManager ();
30
+ $ layoutFactory = $ objectManager ->get (LayoutFactory::class);
24
31
$ this ->layout = $ layoutFactory ->create ();
25
- $ layoutElement = new \ Magento \ Framework \ View \ Layout \ Element (
32
+ $ layoutElement = new Element (
26
33
__DIR__ . '/_files/layout_with_exceptions/layout.xml ' ,
27
34
0 ,
28
35
true
@@ -33,21 +40,24 @@ protected function setUp(): void
33
40
}
34
41
35
42
/**
43
+ * Test to Create structure of elements from the loaded XML configuration with exception
36
44
*/
37
45
public function testProcessWithExceptionsDeveloperMode ()
38
46
{
39
- $ this ->expectException (\ Magento \ Framework \ Exception \ LocalizedException::class);
47
+ $ this ->expectException (LocalizedException::class);
40
48
$ this ->expectExceptionMessage ('Construction problem. ' );
41
49
42
50
$ this ->layout ->generateElements ();
43
51
}
44
52
45
53
/**
54
+ * Test to Get all blocks marked for output with exceptions
55
+ *
46
56
* @magentoAppIsolation enabled
47
57
*/
48
58
public function testProcessWithExceptions ()
49
59
{
50
- \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ()->get (\ Magento \ Framework \ App \ State::class)
60
+ Bootstrap::getObjectManager ()->get (State::class)
51
61
->setMode (State::MODE_DEFAULT );
52
62
53
63
$ this ->layout ->generateElements ();
0 commit comments