@@ -105,17 +105,17 @@ protected function setUp()
105105 null ,
106106 $ this ->directoryResolver ,
107107 ])
108- ->setMethods (['_setUploadFile ' , 'save ' , 'getTmpDir ' ])
108+ ->setMethods (['_setUploadFile ' , 'save ' , 'getTmpDir ' , ' checkAllowedExtension ' ])
109109 ->getMock ();
110110 }
111111
112112 /**
113113 * @dataProvider moveFileUrlDataProvider
114114 */
115- public function testMoveFileUrl ($ fileUrl , $ expectedHost , $ expectedFileName )
115+ public function testMoveFileUrl ($ fileUrl , $ expectedHost , $ expectedFileName, $ checkAllowedExtension )
116116 {
117117 $ destDir = 'var/dest/dir ' ;
118- $ expectedRelativeFilePath = $ this -> uploader -> getTmpDir () . ' / ' . $ expectedFileName ;
118+ $ expectedRelativeFilePath = $ expectedFileName ;
119119 $ this ->directoryMock ->expects ($ this ->once ())->method ('isWritable ' )->with ($ destDir )->willReturn (true );
120120 $ this ->directoryMock ->expects ($ this ->any ())->method ('getRelativePath ' )->with ($ expectedRelativeFilePath );
121121 $ this ->directoryMock ->expects ($ this ->once ())->method ('getAbsolutePath ' )->with ($ destDir )
@@ -140,6 +140,9 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName)
140140 $ this ->uploader ->expects ($ this ->once ())->method ('_setUploadFile ' )->will ($ this ->returnSelf ());
141141 $ this ->uploader ->expects ($ this ->once ())->method ('save ' )->with ($ destDir . '/ ' . $ expectedFileName )
142142 ->willReturn (['name ' => $ expectedFileName , 'path ' => 'absPath ' ]);
143+ $ this ->uploader ->expects ($ this ->exactly ($ checkAllowedExtension ))
144+ ->method ('checkAllowedExtension ' )
145+ ->willReturn (true );
143146
144147 $ this ->uploader ->setDestDir ($ destDir );
145148 $ result = $ this ->uploader ->move ($ fileUrl );
@@ -151,7 +154,7 @@ public function testMoveFileName()
151154 {
152155 $ destDir = 'var/dest/dir ' ;
153156 $ fileName = 'test_uploader_file ' ;
154- $ expectedRelativeFilePath = $ this -> uploader -> getTmpDir () . ' / ' . $ fileName ;
157+ $ expectedRelativeFilePath = $ fileName ;
155158 $ this ->directoryMock ->expects ($ this ->once ())->method ('isWritable ' )->with ($ destDir )->willReturn (true );
156159 $ this ->directoryMock ->expects ($ this ->any ())->method ('getRelativePath ' )->with ($ expectedRelativeFilePath );
157160 $ this ->directoryMock ->expects ($ this ->once ())->method ('getAbsolutePath ' )->with ($ destDir )
@@ -176,11 +179,13 @@ public function moveFileUrlDataProvider()
176179 '$fileUrl ' => 'http://test_uploader_file ' ,
177180 '$expectedHost ' => 'test_uploader_file ' ,
178181 '$expectedFileName ' => 'httptest_uploader_file ' ,
182+ '$checkAllowedExtension ' => 0 ,
179183 ],
180184 [
181185 '$fileUrl ' => 'https://!:^&`;file ' ,
182186 '$expectedHost ' => '!:^&`;file ' ,
183187 '$expectedFileName ' => 'httpsfile ' ,
188+ '$checkAllowedExtension ' => 0 ,
184189 ],
185190 ];
186191 }
0 commit comments