Пример #1
0
 /**
  * @param string $url
  * @param string $expectedContentType
  */
 public function assertContentTypeFile($url, $expectedContentType)
 {
     $actualContentType = FileUtil::getFileContentType($this->getAbsoluteUri($url));
     $this->assertEquals($expectedContentType, $actualContentType);
 }
 /**
  * Test delete image for image
  */
 public function testDeleteImageFileImage()
 {
     $uploaderHelper = $this->getContainer()->get('vich_uploader.templating.helper.uploader_helper');
     /** @var Image $image */
     $objects = $this->loadFixturesAndAuthenticate(['@AppBundle/DataFixtures/ORM/Test/Image/CrudData.yml']);
     $image = $objects['image-1'];
     $this->assertTrue((bool) $image->getImage());
     $imageUrl = $this->getAbsoluteUri($uploaderHelper->asset($image, 'imageFile'));
     $this->assertTrue(FileUtil::isFile($imageUrl));
     $this->sendDeleteRestRequest('/api/images/' . $image->getId() . '/file/image');
     // Test in DB
     $doctrine = $this->getContainer()->get('doctrine');
     $doctrine->getManager()->clear(Image::class);
     $image = $this->getRepository(Image::class)->find($image->getId());
     $this->assertFalse((bool) $image->getImage());
     $this->assertFalse(FileUtil::isFile($imageUrl));
 }