99
1010use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
1111use Magento \Framework \Api \Data \ImageContentInterface ;
12- use Magento \Framework \App \Filesystem \DirectoryList ;
13- use Magento \Framework \Filesystem ;
14- use Magento \Framework \Filesystem \Directory \WriteInterface ;
1512use Magento \Store \Test \Fixture \Store as StoreFixture ;
1613use Magento \TestFramework \Fixture \DataFixture ;
1714use Magento \TestFramework \Fixture \DataFixtureStorage ;
2522use Magento \Framework \ObjectManagerInterface ;
2623
2724/**
28- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
25+ * Class ProductAttributeMediaGalleryManagementInterfaceTest
2926 */
3027class ProductAttributeMediaGalleryManagementInterfaceTest extends WebapiAbstract
3128{
@@ -71,11 +68,6 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends WebapiAbstract
7168 */
7269 private $ fixtures ;
7370
74- /**
75- * @var WriteInterface
76- */
77- private $ mediaDirectory ;
78-
7971 /**
8072 * @inheritDoc
8173 */
@@ -120,8 +112,6 @@ protected function setUp(): void
120112
121113 $ this ->testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files ' . DIRECTORY_SEPARATOR . 'test_image.jpg ' ;
122114 $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
123- $ this ->mediaDirectory = $ this ->objectManager ->get (Filesystem::class)
124- ->getDirectoryWrite (DirectoryList::MEDIA );
125115 }
126116
127117 /**
@@ -906,7 +896,7 @@ public function testContentAttributeInGet(): void
906896 }
907897
908898 /**
909- * Test update() method when existing image gets overwritten
899+ * Test update() method when existing image gets overwritten and name is not changed
910900 *
911901 * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php
912902 */
@@ -916,7 +906,6 @@ public function testUpdateExistingImage()
916906 /** @var \Magento\Catalog\Api\Data\ProductInterface $product */
917907 $ product = $ productRepository ->get ('simple ' );
918908 $ imageId = (int )$ product ->getMediaGalleryImages ()->getFirstItem ()->getValueId ();
919- $ originalImagePath = $ product ->getMediaGalleryImages ()->getFirstItem ()->getFile ();
920909 $ requestData = [
921910 'sku ' => 'simple ' ,
922911 'entry ' => [
@@ -929,7 +918,7 @@ public function testUpdateExistingImage()
929918 'content ' => [
930919 'base64_encoded_data ' => base64_encode (file_get_contents ($ this ->testImagePath )),
931920 'type ' => 'image/jpeg ' ,
932- 'name ' => 'test_image .jpg ' ,
921+ 'name ' => 'magento_image .jpg ' ,
933922 ]
934923 ]
935924 ];
@@ -938,10 +927,8 @@ public function testUpdateExistingImage()
938927 . '/ ' . $ this ->getTargetGalleryEntryId ();
939928
940929 $ this ->assertTrue ($ this ->_webApiCall ($ this ->updateServiceInfo , $ requestData , null , 'all ' ));
941- $ updatedImage = $ this ->assertMediaGalleryData ($ imageId , '/t/e/test_image .jpg ' , 'Updated Image Text ' );
930+ $ updatedImage = $ this ->assertMediaGalleryData ($ imageId , '/m/a/magento_image .jpg ' , 'Updated Image Text ' );
942931 $ this ->assertEquals (10 , $ updatedImage ['position_default ' ]);
943932 $ this ->assertEquals (1 , $ updatedImage ['disabled_default ' ]);
944- $ this ->assertStringStartsWith ('/t/e/test_image.jpg ' , $ updatedImage ['file ' ]);
945- $ this ->assertFalse ($ this ->mediaDirectory ->isExist ($ originalImagePath ));
946933 }
947934}
0 commit comments