From a582d109009f7814035abb5fdccf5facc44d5903 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Mon, 23 Oct 2023 11:31:44 -0700 Subject: [PATCH] Check for array key --- .../codeception/acceptance/Paragraphs/ListsCest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/codeception/acceptance/Paragraphs/ListsCest.php b/tests/codeception/acceptance/Paragraphs/ListsCest.php index 446d96e2c..c6f2326e3 100644 --- a/tests/codeception/acceptance/Paragraphs/ListsCest.php +++ b/tests/codeception/acceptance/Paragraphs/ListsCest.php @@ -117,6 +117,8 @@ public function testSharedTags(AcceptanceTester $I) { $I->amOnPage('/jsonapi/views/stanford_shared_tags/card_grid?page[limit]=50&views-argument[]=' . preg_replace('/[^a-z0-9-]/', '-', strtolower($shared_tag->label()))); $json_data = json_decode($I->grabPageSource(), TRUE, 512, JSON_THROW_ON_ERROR); + $I->assertArrayHasKey('data', $json_data); + $json_ids = []; foreach ($json_data['data'] as $item) { $json_ids[] = $item['id']; @@ -154,6 +156,8 @@ public function testListParagraphNews(AcceptanceTester $I) { $I->amOnPage('/jsonapi/views/stanford_news/block_1?page[limit]=99'); $json_data = json_decode($I->grabPageSource(), TRUE, 512, JSON_THROW_ON_ERROR); + $I->assertArrayHasKey('data', $json_data); + $json_titles = []; foreach ($json_data['data'] as $item) { $json_titles[] = $item['attributes']['title']; @@ -190,8 +194,11 @@ public function testListParagraphNewsFiltersNoFilter(AcceptanceTester $I) { $I->amOnPage($node->toUrl()->toString()); $I->canSee($news->label()); - $I->amOnPage('/jsonapi/views/stanford_news/block_1?page[limit]=99&views-argument[]=' . Drupal::service('pathauto.alias_cleaner')->cleanString($topic_term->label())); + $I->amOnPage('/jsonapi/views/stanford_news/block_1?page[limit]=99&views-argument[]=' . Drupal::service('pathauto.alias_cleaner') + ->cleanString($topic_term->label())); $json_data = json_decode($I->grabPageSource(), TRUE, 512, JSON_THROW_ON_ERROR); + $I->assertArrayHasKey('data', $json_data); + $json_titles = []; foreach ($json_data['data'] as $item) { $json_titles[] = $item['attributes']['title']; @@ -201,6 +208,7 @@ public function testListParagraphNewsFiltersNoFilter(AcceptanceTester $I) { $topic_term = $this->createTaxonomyTerm($I, 'stanford_news_topics'); $I->amOnPage('/jsonapi/views/stanford_news/block_1?page[limit]=99&views-argument[]=' . $topic_term->label()); $json_data = json_decode($I->grabPageSource(), TRUE, 512, JSON_THROW_ON_ERROR); + $I->assertArrayHasKey('data', $json_data); $I->assertEmpty($json_data['data']); } @@ -495,6 +503,8 @@ public function testListParagraphEvents(AcceptanceTester $I) { $I->amOnPage('/jsonapi/views/stanford_events/list_page?page[limit]=99'); $json_data = json_decode($I->grabPageSource(), TRUE, 512, JSON_THROW_ON_ERROR); + $I->assertArrayHasKey('data', $json_data); + $json_titles = []; foreach ($json_data['data'] as $item) { $json_titles[] = $item['attributes']['title'];