Example #1
0
 public function testUploadName()
 {
     $data = $this->getSimpleTestData();
     $source = __DIR__ . '/fixtures/test-bild.jpg';
     $dest = __DIR__ . '/fixtures/test-bild-used.jpg';
     //copy image to execute test case multiple times.
     unlink($dest);
     copy($source, $dest);
     $data['file'] = $dest;
     $path = Shopware()->DocPath('media_image') . '/test-bild-used.jpg';
     unlink($path);
     $media = $this->resource->create($data);
     $this->assertFileExists($path);
     //check if the thumbnails are generated
     $path = Shopware()->DocPath('media_image_thumbnail') . '/test-bild-used_140x140.jpg';
     $this->assertFileExists($path);
 }
Example #2
0
 public function testUploadNameWithOver50Characters()
 {
     $data = $this->getSimpleTestData();
     $source = __DIR__ . '/fixtures/test-bild.jpg';
     $dest = __DIR__ . '/fixtures/test-bild-with-more-than-50-characaters-more-more-more-more-used.jpg';
     //copy image to execute test case multiple times.
     unlink($dest);
     copy($source, $dest);
     $data['file'] = $dest;
     $media = $this->resource->create($data);
     $pathPicture = Shopware()->DocPath('media_image') . $media->getFileName();
     $mediaService = Shopware()->Container()->get('shopware_media.media_service');
     $this->assertTrue($mediaService->has($pathPicture));
     //check if the thumbnails are generated
     $path = Shopware()->DocPath('media_image_thumbnail') . $media->getName() . '_140x140.jpg';
     $this->assertTrue($mediaService->has($path));
     $mediaService->delete(Shopware()->DocPath('media_image') . $media->getFileName());
     $mediaService->delete($path);
 }