public function testPlaceRelation() { $place = new Place(); $image = new Image(); $this->assertCount(0, $place->getImages()); $this->assertNull($image->getPlace()); $image->setPlace($place); $this->assertSame($place, $image->getPlace()); $this->assertSame($image, $place->getImages()[0]); }
public function testImageOnDiskIsDeletedWhenRecordInDbIsDeleted() { $image = new Image('test image'); $image->setFilename('test image.jpg'); $this->getEntityManager()->persist($image); $this->getEntityManager()->flush(); touch($image->getPath()); touch($image->getSmallPath()); $this->assertTrue(file_exists($image->getPath()), 'test file must exist, because we just touch()ed it'); $this->assertTrue(file_exists($image->getSmallPath()), 'thumb file must exist, because we just touch()ed it'); $this->getEntityManager()->remove($image); $this->getEntityManager()->flush(); $this->assertFalse(file_exists($image->getPath()), 'test file must have been deleted when record was deleted'); $this->assertFalse(file_exists($image->getSmallPath()), 'thumb file must have been deleted when record was deleted'); }