@@ -454,6 +454,42 @@ public function testUploadFileWithoutExtension(): void
454454 $ this ->assertPathEquals ($ filePath , $ file ->getFilePath ());
455455 }
456456
457+ public function testCanUploadTwoEntities (): void
458+ {
459+ // create two entities: File and Image
460+ $ file = new File ();
461+ $ fileInfo = $ this ->generateUploadedFile ($ this ->testFile , $ this ->testFilename );
462+ $ this ->listener ->addEntityFileInfo ($ file , $ fileInfo );
463+
464+ $ image = new Image ();
465+ $ image ->setTitle ('test image ' );
466+ $ imageInfo = $ this ->generateUploadedFile ($ this ->testFile2 , $ this ->testFilename2 );
467+ $ this ->listener ->addEntityFileInfo ($ image , $ imageInfo );
468+
469+ $ this ->em ->persist ($ file );
470+ $ this ->em ->persist ($ image );
471+ $ this ->em ->flush ();
472+
473+ // update uploaded files on both entities
474+ $ this ->listener ->addEntityFileInfo (
475+ $ file ,
476+ $ this ->generateUploadedFile ($ this ->testFile3 , $ this ->testFilename3 )
477+ );
478+ $ this ->listener ->addEntityFileInfo (
479+ $ image ,
480+ $ this ->generateUploadedFile ($ this ->testFileWithoutExt , $ this ->testFilenameWithoutExt )
481+ );
482+
483+ $ this ->em ->persist ($ file );
484+ $ this ->em ->persist ($ image );
485+ $ this ->em ->flush ();
486+ $ this ->em ->refresh ($ file );
487+ $ this ->em ->refresh ($ image );
488+
489+ static ::assertFileExists ($ file ->getFilePath ());
490+ static ::assertFileExists ($ image ->getFilePath ());
491+ }
492+
457493 public function testFileAlreadyExistsException (): void
458494 {
459495 $ this ->expectException (UploadableFileAlreadyExistsException::class);
0 commit comments