@@ -47,6 +47,7 @@ public function testGetCmsBlock()
47
47
{
48
48
cmsBlocks(identifiers: "enabled_block") {
49
49
items {
50
+ block_id
50
51
identifier
51
52
title
52
53
content
@@ -59,6 +60,43 @@ public function testGetCmsBlock()
59
60
self ::assertArrayHasKey ('cmsBlocks ' , $ response );
60
61
self ::assertArrayHasKey ('items ' , $ response ['cmsBlocks ' ]);
61
62
63
+ self ::assertEquals ($ cmsBlockData ['block_id ' ], $ response ['cmsBlocks ' ]['items ' ][0 ]['block_id ' ]);
64
+ self ::assertEquals ($ cmsBlockData ['identifier ' ], $ response ['cmsBlocks ' ]['items ' ][0 ]['identifier ' ]);
65
+ self ::assertEquals ($ cmsBlockData ['title ' ], $ response ['cmsBlocks ' ]['items ' ][0 ]['title ' ]);
66
+ self ::assertEquals ($ renderedContent , $ response ['cmsBlocks ' ]['items ' ][0 ]['content ' ]);
67
+ }
68
+
69
+ /**
70
+ * Verify the fields of CMS Block selected by block_id
71
+ *
72
+ * @magentoApiDataFixture Magento/Cms/_files/blocks.php
73
+ */
74
+ public function testGetCmsBlockByBlockId ()
75
+ {
76
+ $ cmsBlock = $ this ->blockRepository ->getById ('enabled_block ' );
77
+ $ cmsBlockData = $ cmsBlock ->getData ();
78
+ $ blockId = $ cmsBlockData ['block_id ' ];
79
+ $ renderedContent = $ this ->filterEmulate ->setUseSessionInUrl (false )->filter ($ cmsBlock ->getContent ());
80
+
81
+ $ query =
82
+ <<<QUERY
83
+ {
84
+ cmsBlocks(identifiers: " $ blockId") {
85
+ items {
86
+ block_id
87
+ identifier
88
+ title
89
+ content
90
+ }
91
+ }
92
+ }
93
+ QUERY ;
94
+ $ response = $ this ->graphQlQuery ($ query );
95
+
96
+ self ::assertArrayHasKey ('cmsBlocks ' , $ response );
97
+ self ::assertArrayHasKey ('items ' , $ response ['cmsBlocks ' ]);
98
+
99
+ self ::assertEquals ($ blockId , $ response ['cmsBlocks ' ]['items ' ][0 ]['block_id ' ]);
62
100
self ::assertEquals ($ cmsBlockData ['identifier ' ], $ response ['cmsBlocks ' ]['items ' ][0 ]['identifier ' ]);
63
101
self ::assertEquals ($ cmsBlockData ['title ' ], $ response ['cmsBlocks ' ]['items ' ][0 ]['title ' ]);
64
102
self ::assertEquals ($ renderedContent , $ response ['cmsBlocks ' ]['items ' ][0 ]['content ' ]);
0 commit comments