Compare the expected nids with the view result
This commit is contained in:
parent
88a0399f39
commit
744556a681
|
@ -47,11 +47,13 @@ class PageListTest extends BrowserTestBase {
|
||||||
$result = views_get_view_result('pages');
|
$result = views_get_view_result('pages');
|
||||||
|
|
||||||
// $result contains an array of Drupal\views\ResultRow objects. We can use
|
// $result contains an array of Drupal\views\ResultRow objects. We can use
|
||||||
// a Collection here to pluck the nid from each node and return them as an
|
// array_column to get the nid from each node and return them as an array.
|
||||||
// array.
|
$nids = array_column($result, 'nid');
|
||||||
$nids = collect($result)->pluck('nid')->all();
|
|
||||||
|
|
||||||
// Then I should only see the published pages.
|
// Only node 1 matches the criteria of being a published page, so only that
|
||||||
|
// node ID should be being returned from the view. assertEquals() can be
|
||||||
|
// used to compare the expected result to what is being returned.
|
||||||
|
$this->assertEquals([1], $nids);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue