6 declare(strict_types=1);
21 private $objectManager;
33 public function testGetCmsBlocksByIdentifiers()
36 $storeManager = $this->objectManager->get(StoreManagerInterface::class);
38 $cmsBlock = $this->objectManager->get(GetBlockByIdentifier::class)->execute(
"fixture_block",
$storeId);
39 $cmsBlockData = $cmsBlock->getData();
41 $widgetFilter = $this->objectManager->get(FilterEmulate::class);
42 $renderedContent = $widgetFilter->setUseSessionInUrl(
false)->filter($cmsBlock->getContent());
46 cmsBlocks(identifiers:
"fixture_block") {
57 $this->assertArrayHasKey(
'cmsBlocks',
$response);
58 $this->assertArrayHasKey(
'items',
$response[
'cmsBlocks']);
59 $this->assertArrayHasKey(
'content',
$response[
'cmsBlocks'][
'items'][0]);
60 $this->assertEquals($cmsBlockData[
'identifier'],
$response[
'cmsBlocks'][
'items'][0][
'identifier']);
61 $this->assertEquals($cmsBlockData[
'title'],
$response[
'cmsBlocks'][
'items'][0][
'title']);
62 $this->assertEquals($renderedContent,
$response[
'cmsBlocks'][
'items'][0][
'content']);
70 public function testGetDisabledCmsBlockByIdentifiers()
73 $storeManager = $this->objectManager->get(StoreManagerInterface::class);
75 $cmsBlockId = $this->objectManager->get(GetBlockByIdentifier::class)
78 $this->objectManager->get(Block::class)->load($cmsBlockId)->setIsActive(0)->save();
82 cmsBlocks(identifiers:
"fixture_block") {
92 $this->expectException(\Exception::class);
93 $this->expectExceptionMessage(
'No such entity.');
105 cmsBlocks(identifiers: []) {
115 $this->expectException(\Exception::class);
116 $this->expectExceptionMessage(
'"identifiers" of CMS blocks should be specified');
128 cmsBlocks(identifiers:
"0") {
138 $this->expectException(\Exception::class);
139 $this->expectExceptionMessage(
'The CMS block with the "0" ID doesn\'t exist.');
testGetCmsBlockByNonExistentIdentifier()
testGetCmsBlockBypassingIdentifiers()
graphQlQuery(string $query, array $variables=[], string $operationName='', array $headers=[])
static getObjectManager()