Skip to content

Commit f4a4a34

Browse files
committed
magento/graphql-ce#387: Test coverage of getting IDs of CMS page/blocks by GraphQL API
1 parent 81984dc commit f4a4a34

File tree

5 files changed

+3
-16
lines changed

5 files changed

+3
-16
lines changed

app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function getData(string $blockIdentifier): array
5959
$renderedContent = $this->widgetFilter->filter($block->getContent());
6060

6161
$blockData = [
62-
BlockInterface::BLOCK_ID => $block->getId(),
6362
BlockInterface::IDENTIFIER => $block->getIdentifier(),
6463
BlockInterface::TITLE => $block->getTitle(),
6564
BlockInterface::CONTENT => $renderedContent,

app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/PageDataProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ private function convertPageData(PageInterface $page)
9696

9797
$pageData = [
9898
'url_key' => $page->getIdentifier(),
99-
PageInterface::PAGE_ID => $page->getId(),
10099
PageInterface::IDENTIFIER => $page->getIdentifier(),
101100
PageInterface::TITLE => $page->getTitle(),
102101
PageInterface::CONTENT => $renderedContent,

app/code/Magento/CmsGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type StoreConfig @doc(description: "The type contains information about a store
1212

1313
type Query {
1414
cmsPage (
15-
id: Int @doc(description: "Id of the CMS page")
15+
id: Int @doc(description: "Id of the CMS page") @deprecated(reason: "Use `identifier`") @doc(description: "The CMS page query returns information about a CMS page")
1616
identifier: String @doc(description: "Identifier of the CMS page")
1717
): CmsPage @resolver(class: "Magento\\CmsGraphQl\\Model\\Resolver\\Page") @doc(description: "The CMS page query returns information about a CMS page")
1818
cmsBlocks (
@@ -21,7 +21,6 @@ type Query {
2121
}
2222

2323
type CmsPage @doc(description: "CMS page defines all CMS page information") {
24-
page_id: Int @doc(description: "Entity ID of CMS page")
2524
identifier: String @doc(description: "Identifier of the CMS page")
2625
url_key: String @doc(description: "URL key of CMS page")
2726
title: String @doc(description: "CMS page title")
@@ -38,7 +37,6 @@ type CmsBlocks @doc(description: "CMS blocks information") {
3837
}
3938

4039
type CmsBlock @doc(description: "CMS block defines all CMS block information") {
41-
block_id: Int @doc(description: "Entity ID of CMS block")
4240
identifier: String @doc(description: "CMS block identifier")
4341
title: String @doc(description: "CMS block title")
4442
content: String @doc(description: "CMS block content")

dev/tests/api-functional/testsuite/Magento/GraphQl/Cms/CmsBlockTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public function testGetCmsBlock()
4747
{
4848
cmsBlocks(identifiers: "enabled_block") {
4949
items {
50-
block_id
5150
identifier
5251
title
5352
content
@@ -60,7 +59,6 @@ public function testGetCmsBlock()
6059
self::assertArrayHasKey('cmsBlocks', $response);
6160
self::assertArrayHasKey('items', $response['cmsBlocks']);
6261

63-
self::assertEquals($cmsBlockData['block_id'], $response['cmsBlocks']['items'][0]['block_id']);
6462
self::assertEquals($cmsBlockData['identifier'], $response['cmsBlocks']['items'][0]['identifier']);
6563
self::assertEquals($cmsBlockData['title'], $response['cmsBlocks']['items'][0]['title']);
6664
self::assertEquals($renderedContent, $response['cmsBlocks']['items'][0]['content']);
@@ -83,7 +81,6 @@ public function testGetCmsBlockByBlockId()
8381
{
8482
cmsBlocks(identifiers: "$blockId") {
8583
items {
86-
block_id
8784
identifier
8885
title
8986
content
@@ -95,8 +92,6 @@ public function testGetCmsBlockByBlockId()
9592

9693
self::assertArrayHasKey('cmsBlocks', $response);
9794
self::assertArrayHasKey('items', $response['cmsBlocks']);
98-
99-
self::assertEquals($blockId, $response['cmsBlocks']['items'][0]['block_id']);
10095
self::assertEquals($cmsBlockData['identifier'], $response['cmsBlocks']['items'][0]['identifier']);
10196
self::assertEquals($cmsBlockData['title'], $response['cmsBlocks']['items'][0]['title']);
10297
self::assertEquals($renderedContent, $response['cmsBlocks']['items'][0]['content']);

dev/tests/api-functional/testsuite/Magento/GraphQl/Cms/CmsPageTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,18 @@ public function testGetCmsPageById()
5858
public function testGetCmsPageByIdentifier()
5959
{
6060
$cmsPageIdentifier = 'page100';
61-
$storeId = 0;
62-
63-
$cmsPage = ObjectManager::getInstance()->get(GetPageByIdentifier::class)->execute($cmsPageIdentifier, $storeId);
64-
$pageId = $cmsPage->getPageId();
6561

6662
$query =
6763
<<<QUERY
6864
{
6965
cmsPage(identifier: "$cmsPageIdentifier") {
70-
page_id
66+
identifier
7167
}
7268
}
7369
QUERY;
7470

7571
$response = $this->graphQlQuery($query);
76-
$this->assertEquals($pageId, $response['cmsPage']['page_id']);
72+
$this->assertEquals($cmsPageIdentifier, $response['cmsPage']['identifier']);
7773
}
7874

7975
/**

0 commit comments

Comments
 (0)