Skip to content

Commit

Permalink
magento/graphql-ce#387: Test coverage of getting IDs of CMS page/bloc…
Browse files Browse the repository at this point in the history
…ks by GraphQL API
  • Loading branch information
atwixfirster committed Apr 24, 2019
1 parent 81984dc commit f4a4a34
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function getData(string $blockIdentifier): array
$renderedContent = $this->widgetFilter->filter($block->getContent());

$blockData = [
BlockInterface::BLOCK_ID => $block->getId(),
BlockInterface::IDENTIFIER => $block->getIdentifier(),
BlockInterface::TITLE => $block->getTitle(),
BlockInterface::CONTENT => $renderedContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ private function convertPageData(PageInterface $page)

$pageData = [
'url_key' => $page->getIdentifier(),
PageInterface::PAGE_ID => $page->getId(),
PageInterface::IDENTIFIER => $page->getIdentifier(),
PageInterface::TITLE => $page->getTitle(),
PageInterface::CONTENT => $renderedContent,
Expand Down
4 changes: 1 addition & 3 deletions app/code/Magento/CmsGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type StoreConfig @doc(description: "The type contains information about a store

type Query {
cmsPage (
id: Int @doc(description: "Id of the CMS page")
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")
identifier: String @doc(description: "Identifier of the CMS page")
): CmsPage @resolver(class: "Magento\\CmsGraphQl\\Model\\Resolver\\Page") @doc(description: "The CMS page query returns information about a CMS page")
cmsBlocks (
Expand All @@ -21,7 +21,6 @@ type Query {
}

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

type CmsBlock @doc(description: "CMS block defines all CMS block information") {
block_id: Int @doc(description: "Entity ID of CMS block")
identifier: String @doc(description: "CMS block identifier")
title: String @doc(description: "CMS block title")
content: String @doc(description: "CMS block content")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function testGetCmsBlock()
{
cmsBlocks(identifiers: "enabled_block") {
items {
block_id
identifier
title
content
Expand All @@ -60,7 +59,6 @@ public function testGetCmsBlock()
self::assertArrayHasKey('cmsBlocks', $response);
self::assertArrayHasKey('items', $response['cmsBlocks']);

self::assertEquals($cmsBlockData['block_id'], $response['cmsBlocks']['items'][0]['block_id']);
self::assertEquals($cmsBlockData['identifier'], $response['cmsBlocks']['items'][0]['identifier']);
self::assertEquals($cmsBlockData['title'], $response['cmsBlocks']['items'][0]['title']);
self::assertEquals($renderedContent, $response['cmsBlocks']['items'][0]['content']);
Expand All @@ -83,7 +81,6 @@ public function testGetCmsBlockByBlockId()
{
cmsBlocks(identifiers: "$blockId") {
items {
block_id
identifier
title
content
Expand All @@ -95,8 +92,6 @@ public function testGetCmsBlockByBlockId()

self::assertArrayHasKey('cmsBlocks', $response);
self::assertArrayHasKey('items', $response['cmsBlocks']);

self::assertEquals($blockId, $response['cmsBlocks']['items'][0]['block_id']);
self::assertEquals($cmsBlockData['identifier'], $response['cmsBlocks']['items'][0]['identifier']);
self::assertEquals($cmsBlockData['title'], $response['cmsBlocks']['items'][0]['title']);
self::assertEquals($renderedContent, $response['cmsBlocks']['items'][0]['content']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,18 @@ public function testGetCmsPageById()
public function testGetCmsPageByIdentifier()
{
$cmsPageIdentifier = 'page100';
$storeId = 0;

$cmsPage = ObjectManager::getInstance()->get(GetPageByIdentifier::class)->execute($cmsPageIdentifier, $storeId);
$pageId = $cmsPage->getPageId();

$query =
<<<QUERY
{
cmsPage(identifier: "$cmsPageIdentifier") {
page_id
identifier
}
}
QUERY;

$response = $this->graphQlQuery($query);
$this->assertEquals($pageId, $response['cmsPage']['page_id']);
$this->assertEquals($cmsPageIdentifier, $response['cmsPage']['identifier']);
}

/**
Expand Down

0 comments on commit f4a4a34

Please sign in to comment.