-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8185 from magento-arcticfoxes/B2B-2530-cache
B2B-2530: Unskip GraphQL cache tests skipped due to DEVOPS-4924 or cr…
- Loading branch information
Showing
11 changed files
with
860 additions
and
354 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/code/Magento/CmsGraphQl/Model/Resolver/Block/ResolverCacheIdentity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CmsGraphQl\Model\Resolver\Block; | ||
|
||
use Magento\Cms\Api\Data\BlockInterface; | ||
use Magento\Cms\Model\Block; | ||
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface; | ||
|
||
class ResolverCacheIdentity implements IdentityInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $cacheTag = Block::CACHE_TAG; | ||
|
||
/** | ||
* Get block identities from resolved data | ||
* | ||
* @param array $resolvedData | ||
* @return string[] | ||
*/ | ||
public function getIdentities(array $resolvedData): array | ||
{ | ||
$ids = []; | ||
$items = $resolvedData['items'] ?? []; | ||
foreach ($items as $item) { | ||
if (is_array($item) && !empty($item[BlockInterface::BLOCK_ID])) { | ||
$ids[] = sprintf('%s_%s', $this->cacheTag, $item[BlockInterface::BLOCK_ID]); | ||
$ids[] = sprintf('%s_%s', $this->cacheTag, $item[BlockInterface::IDENTIFIER]); | ||
} | ||
} | ||
|
||
return $ids; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...api-functional/framework/Magento/TestFramework/TestCase/GraphQl/ResolverCacheAbstract.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\TestFramework\TestCase\GraphQl; | ||
|
||
use Magento\Framework\App\Cache\StateInterface as CacheStateInterface; | ||
use Magento\GraphQlCache\Model\Cache\Query\Resolver\Result\Type as GraphQlResolverCache; | ||
use Magento\TestFramework\TestCase\GraphQlAbstract; | ||
|
||
class ResolverCacheAbstract extends GraphQlAbstract | ||
{ | ||
/** | ||
* @var GraphQlResolverCache | ||
*/ | ||
private $graphQlResolverCache; | ||
|
||
/** | ||
* @var CacheStateInterface | ||
*/ | ||
private $cacheState; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private $originalCacheStateEnabledStatus; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
$this->cacheState = $objectManager->get(CacheStateInterface::class); | ||
$this->originalCacheStateEnabledStatus = $this->cacheState->isEnabled(GraphQlResolverCache::TYPE_IDENTIFIER); | ||
$this->cacheState->setEnabled(GraphQlResolverCache::TYPE_IDENTIFIER, true); | ||
$this->graphQlResolverCache = $objectManager->get(GraphQlResolverCache::class); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function tearDown(): void | ||
{ | ||
// clean graphql resolver cache and reset to original enablement status | ||
$this->graphQlResolverCache->clean(); | ||
$this->cacheState->setEnabled( | ||
GraphQlResolverCache::TYPE_IDENTIFIER, | ||
$this->originalCacheStateEnabledStatus | ||
); | ||
|
||
parent::tearDown(); | ||
} | ||
} |
Oops, something went wrong.