26
26
use Magento \GraphQlResolverCache \Model \Resolver \Result \CacheKey \Calculator \ProviderInterface ;
27
27
use Magento \GraphQlResolverCache \Model \Resolver \Result \Type as GraphQlResolverCache ;
28
28
use Magento \ImportExport \Model \Import ;
29
+ use Magento \Integration \Api \IntegrationServiceInterface ;
29
30
use Magento \Integration \Model \Integration ;
30
31
use Magento \Framework \Filesystem ;
31
32
use Magento \TestFramework \Fixture \DataFixture ;
@@ -53,6 +54,16 @@ class MediaGalleryTest extends ResolverCacheAbstract
53
54
*/
54
55
private $ graphQlResolverCache ;
55
56
57
+ /**
58
+ * @var IntegrationServiceInterface
59
+ */
60
+ private $ integrationService ;
61
+
62
+ /**
63
+ * @var Integration
64
+ */
65
+ private $ integration ;
66
+
56
67
/**
57
68
* @var DirectoryWriteInterface
58
69
*/
@@ -68,6 +79,7 @@ protected function setUp(): void
68
79
$ this ->objectManager = Bootstrap::getObjectManager ();
69
80
$ this ->graphQlResolverCache = $ this ->objectManager ->get (GraphQlResolverCache::class);
70
81
$ this ->productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
82
+ $ this ->integrationService = $ this ->objectManager ->get (IntegrationServiceInterface::class);
71
83
$ filesystem = $ this ->objectManager ->get (Filesystem::class);
72
84
$ this ->mediaDirectory = $ filesystem ->getDirectoryWrite (DirectoryList::MEDIA );
73
85
@@ -449,7 +461,7 @@ public function testCacheIsInvalidatedWhenUpdatingMediaGalleryEntriesOnAProductV
449
461
{
450
462
// first, create an integration so that cache is not cleared in
451
463
// Magento\TestFramework\Authentication\OauthHelper::_createIntegration before making the API call
452
- $ integration = $ this ->createNewOauthIntegration ();
464
+ $ integration = $ this ->getOauthIntegration ();
453
465
454
466
$ product = $ this ->productRepository ->get ('product1 ' );
455
467
@@ -476,7 +488,7 @@ public function testCacheIsInvalidatedWhenUpdatingMediaGalleryEntriesOnAProductV
476
488
];
477
489
478
490
// move test image into media directory
479
- $ destinationDir = $ this ->mediaDirectory ->getAbsolutePath () . '/ import/images ' ;
491
+ $ destinationDir = $ this ->mediaDirectory ->getAbsolutePath () . 'import/images ' ;
480
492
481
493
$ this ->mediaDirectory ->create ($ destinationDir );
482
494
@@ -528,7 +540,7 @@ public function testCacheIsNotInvalidatedWhenUpdatingProductSpecificAttributeVia
528
540
{
529
541
// first, create an integration so that cache is not cleared in
530
542
// Magento\TestFramework\Authentication\OauthHelper::_createIntegration before making the API call
531
- $ integration = $ this ->createNewOauthIntegration ();
543
+ $ integration = $ this ->getOauthIntegration ();
532
544
533
545
$ product = $ this ->productRepository ->get ('product1 ' );
534
546
@@ -589,19 +601,19 @@ public function testCacheIsNotInvalidatedWhenUpdatingProductSpecificAttributeVia
589
601
* @return Integration
590
602
* @throws \Magento\Framework\Exception\IntegrationException
591
603
*/
592
- private function createNewOauthIntegration (): Integration
604
+ private function getOauthIntegration (): Integration
593
605
{
594
- /** @var $integrationService \Magento\Integration\Api\IntegrationServiceInterface */
595
- $ integrationService = $ this -> objectManager -> get (\ Magento \ Integration \ Api \IntegrationServiceInterface::class);
596
-
597
- $ params = [
598
- ' all_resources ' => true ,
599
- ' integration_id ' => 1 ,
600
- ' status ' => Integration:: STATUS_ACTIVE ,
601
- ' name ' => ' Integration ' . microtime ()
602
- ];
606
+ if (! isset ( $ this -> integration )) {
607
+ $ params = [
608
+ ' all_resources ' => true ,
609
+ ' status ' => Integration:: STATUS_ACTIVE ,
610
+ ' name ' => ' Integration ' . microtime ()
611
+ ];
612
+
613
+ $ this -> integration = $ this -> integrationService -> create ( $ params );
614
+ }
603
615
604
- return $ integrationService -> create ( $ params ) ;
616
+ return $ this -> integration ;
605
617
}
606
618
607
619
/**
0 commit comments