public function testGetPath() { $image = new Image(); $image->setFilename('photo.jpg'); $this->assertSame('photo.jpg', $image->getFilename()); $appPath = realpath('.'); $expected = $appPath . '/htdocs/data/images/photo.jpg'; $this->assertSame($expected, $image->getPath()); $expected = $appPath . '/htdocs/data/images/small/photo.jpg'; $this->assertSame($expected, $image->getSmallPath()); }
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'); }