24
24
use Magento \GraphQlResolverCache \Model \Resolver \Result \CacheKey \Calculator \ProviderInterface ;
25
25
use Magento \GraphQlResolverCache \Model \Resolver \Result \Type as GraphQlResolverCache ;
26
26
use Magento \TestFramework \Fixture \DataFixture ;
27
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
27
28
use Magento \TestFramework \Helper \Bootstrap ;
28
29
use Magento \TestFramework \TestCase \GraphQl \ResolverCacheAbstract ;
29
30
@@ -48,21 +49,28 @@ class MediaGalleryTest extends ResolverCacheAbstract
48
49
*/
49
50
private $ graphQlResolverCache ;
50
51
52
+ /**
53
+ * @var DataFixtureStorageManager
54
+ */
55
+ private $ fixtures ;
56
+
51
57
protected function setUp (): void
52
58
{
53
59
$ this ->objectManager = Bootstrap::getObjectManager ();
54
60
$ this ->graphQlResolverCache = $ this ->objectManager ->get (GraphQlResolverCache::class);
55
61
$ this ->productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
62
+ $ this ->fixtures = DataFixtureStorageManager::getStorage ();
56
63
57
64
parent ::setUp ();
58
65
}
59
66
60
67
#[
61
- DataFixture(ProductFixture::class, ['sku ' => ' product1 ' , ' media_gallery_entries ' => [[]]], as: 'product ' ),
68
+ DataFixture(ProductFixture::class, ['media_gallery_entries ' => [[]]], as: 'product ' ),
62
69
]
63
70
public function testSavingProductInAdminWithoutChangesDoesNotInvalidateResolverCache ()
64
71
{
65
- $ product = $ this ->productRepository ->get ('product1 ' );
72
+ /** @var ProductInterface $product */
73
+ $ product = $ this ->fixtures ->get ('product ' );
66
74
67
75
// Assert Media Gallery Resolver cache record does not exist before querying the product's media gallery
68
76
$ this ->assertMediaGalleryResolverCacheRecordDoesNotExist ($ product );
@@ -112,6 +120,14 @@ public function testSavingProductInAdminWithoutChangesDoesNotInvalidateResolverC
112
120
$ image = array_filter ($ image , function ($ key ) {
113
121
return strpos ($ key , 'video ' ) === false ;
114
122
}, ARRAY_FILTER_USE_KEY );
123
+
124
+ // client UI converts null values to empty string due to behavior of HTML encoding;
125
+ // match this behavior before posting to the controller
126
+ foreach ($ image as &$ value ) {
127
+ if ($ value === null ) {
128
+ $ value = '' ;
129
+ }
130
+ }
115
131
}
116
132
117
133
unset($ productData ['entity_id ' ]);
0 commit comments