/** * @expectedException Exception * @expectedExceptionMessage No album configured for the passed media object and no size passed! */ public function testGenerationWithoutAlbum() { $media = new \Shopware\Models\Media\Media(); $imagePath = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'sw_icon.png'; $file = new \Symfony\Component\HttpFoundation\File\File($imagePath); $media->setFile($file); $media->setPath(str_replace(Shopware()->DocPath(), '', $imagePath)); $manager = Shopware()->Container()->get('thumbnail_manager'); $manager->createMediaThumbnail($media); $thumbnailDir = Shopware()->DocPath('media_' . strtolower($media->getType()) . '_thumbnail'); $path = $thumbnailDir . $media->getName(); $this->assertFileExists($path . '_140x140.jpg'); }
/** * @expectedException Exception * @expectedExceptionMessage No album configured for the passed media object and no size passed! */ public function testGenerationWithoutAlbum() { $media = new \Shopware\Models\Media\Media(); $sourcePath = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'sw_icon.png'; $imagePath = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'sw_icon_copy.png'; copy($sourcePath, $imagePath); $file = new \Symfony\Component\HttpFoundation\File\File($imagePath); $media->setFile($file); $media->setPath(str_replace(Shopware()->DocPath(), '', $imagePath)); unlink($file->getRealPath()); $manager = Shopware()->Container()->get('thumbnail_manager'); $manager->createMediaThumbnail($media); }