@@ -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,35 @@ 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 (
66
+ \Magento \Framework \Filesystem::class,
67
+ [],
68
+ [],
69
+ '' ,
70
+ false
71
+ );
72
+ $ this ->scopeConfigMock = $ this ->getMock (
73
+ \Magento \Framework \App \Config \ScopeConfigInterface::class,
74
+ [],
75
+ [],
76
+ '' ,
77
+ false
78
+ );
79
+ $ this ->rootDirectoryMock = $ this ->getMock (
80
+ \Magento \Framework \Filesystem \Directory \ReadInterface::class,
81
+ [],
82
+ [],
83
+ '' ,
84
+ false );
85
+ $ this ->compiledDirectoryMock = $ this ->getMock (
86
+ \Magento \Framework \Filesystem \Directory \ReadInterface::class,
87
+ [],
88
+ [],
89
+ '' ,
90
+ false
91
+ );
69
92
70
- $ this ->_fileSystemMock ->expects ($ this ->any ())
93
+ $ this ->fileSystemMock ->expects ($ this ->any ())
71
94
->method ('getDirectoryRead ' )
72
95
->will ($ this ->returnValueMap (
73
96
[
@@ -80,7 +103,13 @@ protected function setUp()
80
103
->method ('getAbsolutePath ' )
81
104
->will ($ this ->returnValue ('/magento/var/compiled ' ));
82
105
83
- $ this ->componentRegistrar = $ this ->getMock ('Magento\Framework\Component\ComponentRegistrar ' , [], [], '' , false );
106
+ $ this ->componentRegistrar = $ this ->getMock (
107
+ \Magento \Framework \Component \ComponentRegistrar::class,
108
+ [],
109
+ [],
110
+ '' ,
111
+ false
112
+ );
84
113
$ this ->componentRegistrar ->expects ($ this ->any ())
85
114
->method ('getPaths ' )
86
115
->will (
@@ -91,10 +120,18 @@ protected function setUp()
91
120
]
92
121
)
93
122
);
94
- $ this ->_validator = new \Magento \Framework \View \Element \Template \File \Validator (
95
- $ this ->_fileSystemMock ,
96
- $ this ->_scopeConfigMock ,
97
- $ this ->componentRegistrar
123
+
124
+ $ fileDriverMock = $ this ->getMock (\Magento \Framework \Filesystem \Driver \File::class);
125
+ $ fileDriverMock ->expects ($ this ->any ())
126
+ ->method ('getRealPath ' )
127
+ ->willReturnArgument (0 );
128
+
129
+ $ this ->validator = new \Magento \Framework \View \Element \Template \File \Validator (
130
+ $ this ->fileSystemMock ,
131
+ $ this ->scopeConfigMock ,
132
+ $ this ->componentRegistrar ,
133
+ null ,
134
+ $ fileDriverMock
98
135
);
99
136
}
100
137
@@ -103,23 +140,22 @@ protected function setUp()
103
140
*
104
141
* @param string $file
105
142
* @param bool $expectedResult
106
- *
107
- * @dataProvider testIsValidDataProvider
108
- *
109
143
* @return void
144
+ *
145
+ * @dataProvider isValidDataProvider
110
146
*/
111
147
public function testIsValid ($ file , $ expectedResult )
112
148
{
113
149
$ this ->rootDirectoryMock ->expects ($ this ->any ())->method ('isFile ' )->will ($ this ->returnValue (true ));
114
- $ this ->assertEquals ($ expectedResult , $ this ->_validator ->isValid ($ file ));
150
+ $ this ->assertEquals ($ expectedResult , $ this ->validator ->isValid ($ file ));
115
151
}
116
152
117
153
/**
118
154
* Data provider for testIsValid
119
155
*
120
- * @return []
156
+ * @return array
121
157
*/
122
- public function testIsValidDataProvider ()
158
+ public function isValidDataProvider ()
123
159
{
124
160
return [
125
161
'empty ' => ['' , false ],
0 commit comments