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 b8ffd43 commit 79a81e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/codeception/acceptance/Content/PersonCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function testD8Core2613Terms(AcceptanceTester $I) {
'parent' => ['target_id' => $term1->id()],
], 'taxonomy_term');

$I->runDrush('cache:rebuild');
$I->amOnPage($term3->toUrl()->toString());
$I->canSeeLink($term1->label());
$I->canSeeLink($term2->label());
Expand Down
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 79a81e8

Please sign in to comment.