@@ -105,17 +105,17 @@ protected function setUp()
105
105
null ,
106
106
$ this ->directoryResolver ,
107
107
])
108
- ->setMethods (['_setUploadFile ' , 'save ' , 'getTmpDir ' ])
108
+ ->setMethods (['_setUploadFile ' , 'save ' , 'getTmpDir ' , ' checkAllowedExtension ' ])
109
109
->getMock ();
110
110
}
111
111
112
112
/**
113
113
* @dataProvider moveFileUrlDataProvider
114
114
*/
115
- public function testMoveFileUrl ($ fileUrl , $ expectedHost , $ expectedFileName )
115
+ public function testMoveFileUrl ($ fileUrl , $ expectedHost , $ expectedFileName, $ checkAllowedExtension )
116
116
{
117
117
$ destDir = 'var/dest/dir ' ;
118
- $ expectedRelativeFilePath = $ this -> uploader -> getTmpDir () . ' / ' . $ expectedFileName ;
118
+ $ expectedRelativeFilePath = $ expectedFileName ;
119
119
$ this ->directoryMock ->expects ($ this ->once ())->method ('isWritable ' )->with ($ destDir )->willReturn (true );
120
120
$ this ->directoryMock ->expects ($ this ->any ())->method ('getRelativePath ' )->with ($ expectedRelativeFilePath );
121
121
$ this ->directoryMock ->expects ($ this ->once ())->method ('getAbsolutePath ' )->with ($ destDir )
@@ -140,6 +140,9 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName)
140
140
$ this ->uploader ->expects ($ this ->once ())->method ('_setUploadFile ' )->will ($ this ->returnSelf ());
141
141
$ this ->uploader ->expects ($ this ->once ())->method ('save ' )->with ($ destDir . '/ ' . $ expectedFileName )
142
142
->willReturn (['name ' => $ expectedFileName , 'path ' => 'absPath ' ]);
143
+ $ this ->uploader ->expects ($ this ->exactly ($ checkAllowedExtension ))
144
+ ->method ('checkAllowedExtension ' )
145
+ ->willReturn (true );
143
146
144
147
$ this ->uploader ->setDestDir ($ destDir );
145
148
$ result = $ this ->uploader ->move ($ fileUrl );
@@ -151,7 +154,7 @@ public function testMoveFileName()
151
154
{
152
155
$ destDir = 'var/dest/dir ' ;
153
156
$ fileName = 'test_uploader_file ' ;
154
- $ expectedRelativeFilePath = $ this -> uploader -> getTmpDir () . ' / ' . $ fileName ;
157
+ $ expectedRelativeFilePath = $ fileName ;
155
158
$ this ->directoryMock ->expects ($ this ->once ())->method ('isWritable ' )->with ($ destDir )->willReturn (true );
156
159
$ this ->directoryMock ->expects ($ this ->any ())->method ('getRelativePath ' )->with ($ expectedRelativeFilePath );
157
160
$ this ->directoryMock ->expects ($ this ->once ())->method ('getAbsolutePath ' )->with ($ destDir )
@@ -176,11 +179,13 @@ public function moveFileUrlDataProvider()
176
179
'$fileUrl ' => 'http://test_uploader_file ' ,
177
180
'$expectedHost ' => 'test_uploader_file ' ,
178
181
'$expectedFileName ' => 'httptest_uploader_file ' ,
182
+ '$checkAllowedExtension ' => 0
179
183
],
180
184
[
181
185
'$fileUrl ' => 'https://!:^&`;file ' ,
182
186
'$expectedHost ' => '!:^&`;file ' ,
183
187
'$expectedFileName ' => 'httpsfile ' ,
188
+ '$checkAllowedExtension ' => 0
184
189
],
185
190
];
186
191
}
0 commit comments