@@ -45,11 +45,10 @@ protected function uploadClass()
4545
4646 protected function mockUploadedFile ($ name , $ fileSize = 10 , $ isValidImage = true , $ height = 10 , $ width = 10 )
4747 {
48- $ mock = $ this ->getMock (
49- UploadedImage::class,
50- ['getSize ' , 'isValidImage ' , 'getHeight ' , 'getWidth ' ],
51- ['somepath/ ' . $ name , UPLOAD_ERR_OK ]
52- );
48+ $ mock = $ this ->getMockBuilder (UploadedImage::class)
49+ ->setMethods (['getSize ' , 'isValidImage ' , 'getHeight ' , 'getWidth ' ])
50+ ->setConstructorArgs (['somepath/ ' . $ name , UPLOAD_ERR_OK ])
51+ ->getMock ();
5352
5453 $ mock ->method ('getSize ' )->willReturn ($ fileSize );
5554 $ mock ->method ('getHeight ' )->willReturn ($ height );
@@ -62,13 +61,13 @@ protected function mockUploadedFile($name, $fileSize = 10, $isValidImage = true,
6261 public function testInvalidImage ()
6362 {
6463 $ this ->testValidation (
65- ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = $ this ->mockUploadedFile ('new ' , 1024 , false )],
66- [new Message (UploadedImageValidator::MESSAGE , ['field ' => 'File ' , 'input ' => $ file ])]
64+ ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = $ this ->mockUploadedFile ('new ' , 1024 , false )],
65+ [new Message (UploadedImageValidator::MESSAGE , ['field ' => 'File ' , 'input ' => $ file ])]
6766 );
6867
6968 $ this ->testValidation (
70- ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = parent ::mockUploadedFile ('new ' , 1024 )],
71- [new Message (TypeValidator::MESSAGE , ['field ' => 'File ' , 'input ' => $ file , 'type ' => IUploadedImage::class . '|null ' ])]
69+ ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = parent ::mockUploadedFile ('new ' , 1024 )],
70+ [new Message (TypeValidator::MESSAGE , ['field ' => 'File ' , 'input ' => $ file , 'type ' => IUploadedImage::class . '|null ' ])]
7271 );
7372 }
7473
@@ -77,13 +76,13 @@ public function testMaxHeight()
7776 $ this ->loadFieldType ((new ImageUploadType ())->with (ImageUploadType::ATTR_MAX_HEIGHT , 100 ));
7877
7978 $ this ->testProcess (
80- ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = $ this ->mockUploadedFile ('new ' , 1024 , true , 100 )],
81- $ file
79+ ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = $ this ->mockUploadedFile ('new ' , 1024 , true , 100 )],
80+ $ file
8281 );
8382
8483 $ this ->testValidation (
85- ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = $ this ->mockUploadedFile ('new ' , 1024 , true , 101 )],
86- [new Message (ImageDimensionsValidator::MESSAGE_MAX_HEIGHT , ['field ' => 'File ' , 'input ' => $ file , 'max_height ' => 100 ])]
84+ ['action ' => UploadAction::STORE_NEW , 'file ' => $ file = $ this ->mockUploadedFile ('new ' , 1024 , true , 101 )],
85+ [new Message (ImageDimensionsValidator::MESSAGE_MAX_HEIGHT , ['field ' => 'File ' , 'input ' => $ file , 'max_height ' => 100 ])]
8786 );
8887 }
8988}
0 commit comments