9
9
10
10
use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
11
11
use Magento \Framework \Api \Data \ImageContentInterface ;
12
- use Magento \Framework \App \Filesystem \DirectoryList ;
13
- use Magento \Framework \Filesystem ;
14
- use Magento \Framework \Filesystem \Directory \WriteInterface ;
15
12
use Magento \Store \Test \Fixture \Store as StoreFixture ;
16
13
use Magento \TestFramework \Fixture \DataFixture ;
17
14
use Magento \TestFramework \Fixture \DataFixtureStorage ;
25
22
use Magento \Framework \ObjectManagerInterface ;
26
23
27
24
/**
28
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
25
+ * Class ProductAttributeMediaGalleryManagementInterfaceTest
29
26
*/
30
27
class ProductAttributeMediaGalleryManagementInterfaceTest extends WebapiAbstract
31
28
{
@@ -71,11 +68,6 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends WebapiAbstract
71
68
*/
72
69
private $ fixtures ;
73
70
74
- /**
75
- * @var WriteInterface
76
- */
77
- private $ mediaDirectory ;
78
-
79
71
/**
80
72
* @inheritDoc
81
73
*/
@@ -120,8 +112,6 @@ protected function setUp(): void
120
112
121
113
$ this ->testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files ' . DIRECTORY_SEPARATOR . 'test_image.jpg ' ;
122
114
$ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
123
- $ this ->mediaDirectory = $ this ->objectManager ->get (Filesystem::class)
124
- ->getDirectoryWrite (DirectoryList::MEDIA );
125
115
}
126
116
127
117
/**
@@ -906,7 +896,7 @@ public function testContentAttributeInGet(): void
906
896
}
907
897
908
898
/**
909
- * Test update() method when existing image gets overwritten
899
+ * Test update() method when existing image gets overwritten and name is not changed
910
900
*
911
901
* @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php
912
902
*/
@@ -916,7 +906,6 @@ public function testUpdateExistingImage()
916
906
/** @var \Magento\Catalog\Api\Data\ProductInterface $product */
917
907
$ product = $ productRepository ->get ('simple ' );
918
908
$ imageId = (int )$ product ->getMediaGalleryImages ()->getFirstItem ()->getValueId ();
919
- $ originalImagePath = $ product ->getMediaGalleryImages ()->getFirstItem ()->getFile ();
920
909
$ requestData = [
921
910
'sku ' => 'simple ' ,
922
911
'entry ' => [
@@ -929,7 +918,7 @@ public function testUpdateExistingImage()
929
918
'content ' => [
930
919
'base64_encoded_data ' => base64_encode (file_get_contents ($ this ->testImagePath )),
931
920
'type ' => 'image/jpeg ' ,
932
- 'name ' => 'test_image .jpg ' ,
921
+ 'name ' => 'magento_image .jpg ' ,
933
922
]
934
923
]
935
924
];
@@ -938,10 +927,8 @@ public function testUpdateExistingImage()
938
927
. '/ ' . $ this ->getTargetGalleryEntryId ();
939
928
940
929
$ 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 ' );
942
931
$ this ->assertEquals (10 , $ updatedImage ['position_default ' ]);
943
932
$ this ->assertEquals (1 , $ updatedImage ['disabled_default ' ]);
944
- $ this ->assertStringStartsWith ('/t/e/test_image.jpg ' , $ updatedImage ['file ' ]);
945
- $ this ->assertFalse ($ this ->mediaDirectory ->isExist ($ originalImagePath ));
946
933
}
947
934
}
0 commit comments