@@ -308,6 +308,36 @@ public function testReplaceFile()
308
308
->string ($ entity ->getUserPhotoFilename ())->isEqualTo ($ this ->workspace .'/dest/replacement_{-imgformat-}.png ' )
309
309
->boolean (file_exists ($ this ->workspace .'/image.png ' ))->isFalse ()
310
310
311
+ ->assert ('BaseEntityWithImageManager::replaceFile for specific format ' )
312
+ ->given (
313
+ touch ($ this ->workspace .'/my-photo_original.png ' ),
314
+ touch ($ this ->workspace .'/my-photo_format1Definition.png ' ),
315
+ touch ($ this ->workspace .'/my-photo_format2Definition.png ' ),
316
+ $ entity = $ this ->createMockEntity (array (
317
+ 'userPhoto ' => $ this ->createMockFileType (__DIR__ .'/../../data/image.png ' ),
318
+ 'userPhotoFilename ' => 'my-photo_{-imgformat-}.png ' ,
319
+ ),
320
+ $ entityManager = $ this ->createMockEntityManager ())
321
+ )
322
+ ->if (
323
+ $ testedClass = $ this ->createTestedClassInstance (array (
324
+ 'bundle.web ' => $ this ->workspace .'/ ' ,
325
+ 'bundle.root ' => $ this ->workspace .'/ ' ,
326
+ 'userPhoto ' => '/{-origin-}_{-imgformat-}.{-ext-} ' ,
327
+ ), $ entityManager )
328
+ )
329
+ ->when ($ fileProperties = $ testedClass ->replaceFile ($ entity , 'userPhoto ' , __DIR__ .'/../../data/image.png ' , null , Manager \BaseEntityWithImageManager::OPERATION_COPY , ['format1Definition ' ]))
330
+ ->then
331
+ ->array ($ fileProperties )
332
+ ->hasKeys (array ('extension ' , 'original ' , 'size ' , 'mime ' ))
333
+ ->string ['extension ' ]->isEqualTo ('png ' )
334
+ ->string ['original ' ]->isEqualTo ('image.png ' )
335
+ ->integer ['size ' ]->isGreaterThan (0 )
336
+ ->string ($ entity ->getUserPhotoFilename ())->isEqualTo ('/image_{-imgformat-}.png ' )
337
+ ->boolean (file_exists ($ this ->workspace .'/image_original.png ' ))->isTrue ()
338
+ ->boolean (file_exists ($ this ->workspace .'/image_format1Definition.png ' ))->isTrue ()
339
+ ->boolean (file_exists ($ this ->workspace .'/image_format2Definition.png ' ))->isTrue ()
340
+
311
341
->assert ('BaseEntityWithImageManager::replaceFile with invalid file ' )
312
342
->if (
313
343
$ testedClass = $ this ->createTestedClassInstance (array (
0 commit comments