@@ -20,21 +20,21 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
20
20
*
21
21
* @var \Magento\Framework\View\Element\Template\File\Validator
22
22
*/
23
- private $ _validator ;
23
+ private $ validator ;
24
24
25
25
/**
26
26
* Mock for view file system
27
27
*
28
28
* @var \Magento\Framework\FileSystem|\PHPUnit_Framework_MockObject_MockObject
29
29
*/
30
- private $ _fileSystemMock ;
30
+ private $ fileSystemMock ;
31
31
32
32
/**
33
33
* Mock for scope config
34
34
*
35
35
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
36
36
*/
37
- private $ _scopeConfigMock ;
37
+ private $ scopeConfigMock ;
38
38
39
39
/**
40
40
* Mock for root directory reader
@@ -62,12 +62,30 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
62
62
*/
63
63
protected function setUp ()
64
64
{
65
- $ this ->_fileSystemMock = $ this ->getMock ('\Magento\Framework\Filesystem ' , [], [], '' , false );
66
- $ this ->_scopeConfigMock = $ this ->getMock ('\Magento\Framework\App\Config\ScopeConfigInterface ' );
67
- $ this ->rootDirectoryMock = $ this ->getMock ('\Magento\Framework\Filesystem\Directory\ReadInterface ' );
68
- $ this ->compiledDirectoryMock = $ this ->getMock ('\Magento\Framework\Filesystem\Directory\ReadInterface ' );
65
+ $ this ->fileSystemMock = $ this ->getMock (\Magento \Framework \Filesystem::class, [], [], '' , false );
66
+ $ this ->scopeConfigMock = $ this ->getMock (
67
+ \Magento \Framework \App \Config \ScopeConfigInterface::class,
68
+ [],
69
+ [],
70
+ '' ,
71
+ false
72
+ );
73
+ $ this ->rootDirectoryMock = $ this ->getMock (
74
+ \Magento \Framework \Filesystem \Directory \ReadInterface::class,
75
+ [],
76
+ [],
77
+ '' ,
78
+ false
79
+ );
80
+ $ this ->compiledDirectoryMock = $ this ->getMock (
81
+ \Magento \Framework \Filesystem \Directory \ReadInterface::class,
82
+ [],
83
+ [],
84
+ '' ,
85
+ false
86
+ );
69
87
70
- $ this ->_fileSystemMock ->expects ($ this ->any ())
88
+ $ this ->fileSystemMock ->expects ($ this ->any ())
71
89
->method ('getDirectoryRead ' )
72
90
->will ($ this ->returnValueMap (
73
91
[
@@ -80,7 +98,13 @@ protected function setUp()
80
98
->method ('getAbsolutePath ' )
81
99
->will ($ this ->returnValue ('/magento/var/compiled ' ));
82
100
83
- $ this ->componentRegistrar = $ this ->getMock ('Magento\Framework\Component\ComponentRegistrar ' , [], [], '' , false );
101
+ $ this ->componentRegistrar = $ this ->getMock (
102
+ \Magento \Framework \Component \ComponentRegistrar::class,
103
+ [],
104
+ [],
105
+ '' ,
106
+ false
107
+ );
84
108
$ this ->componentRegistrar ->expects ($ this ->any ())
85
109
->method ('getPaths ' )
86
110
->will (
@@ -91,10 +115,18 @@ protected function setUp()
91
115
]
92
116
)
93
117
);
94
- $ this ->_validator = new \Magento \Framework \View \Element \Template \File \Validator (
95
- $ this ->_fileSystemMock ,
96
- $ this ->_scopeConfigMock ,
97
- $ this ->componentRegistrar
118
+
119
+ $ fileDriverMock = $ this ->getMock (\Magento \Framework \Filesystem \Driver \File::class);
120
+ $ fileDriverMock ->expects ($ this ->any ())
121
+ ->method ('getRealPath ' )
122
+ ->willReturnArgument (0 );
123
+
124
+ $ this ->validator = new \Magento \Framework \View \Element \Template \File \Validator (
125
+ $ this ->fileSystemMock ,
126
+ $ this ->scopeConfigMock ,
127
+ $ this ->componentRegistrar ,
128
+ null ,
129
+ $ fileDriverMock
98
130
);
99
131
}
100
132
@@ -103,23 +135,22 @@ protected function setUp()
103
135
*
104
136
* @param string $file
105
137
* @param bool $expectedResult
106
- *
107
- * @dataProvider testIsValidDataProvider
108
- *
109
138
* @return void
139
+ *
140
+ * @dataProvider isValidDataProvider
110
141
*/
111
142
public function testIsValid ($ file , $ expectedResult )
112
143
{
113
144
$ this ->rootDirectoryMock ->expects ($ this ->any ())->method ('isFile ' )->will ($ this ->returnValue (true ));
114
- $ this ->assertEquals ($ expectedResult , $ this ->_validator ->isValid ($ file ));
145
+ $ this ->assertEquals ($ expectedResult , $ this ->validator ->isValid ($ file ));
115
146
}
116
147
117
148
/**
118
149
* Data provider for testIsValid
119
150
*
120
- * @return []
151
+ * @return array
121
152
*/
122
- public function testIsValidDataProvider ()
153
+ public function isValidDataProvider ()
123
154
{
124
155
return [
125
156
'empty ' => ['' , false ],
0 commit comments