Skip to content

Commit

Permalink
Check for array key
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Oct 23, 2023
1 parent ed13dd9 commit a582d10
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/codeception/acceptance/Paragraphs/ListsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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'];
Expand All @@ -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']);
}

Expand Down Expand Up @@ -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'];
Expand Down

0 comments on commit a582d10

Please sign in to comment.