public function CallbackViewsTest::testDefaultViewContent in Search Autocomplete 8
Same name and namespace in other branches
- 2.x src/Tests/Views/CallbackViewsTest.php \Drupal\search_autocomplete\Tests\Views\CallbackViewsTest::testDefaultViewContent()
Default view content checks.
File
- src/
Tests/ Views/ CallbackViewsTest.php, line 81
Class
- CallbackViewsTest
- Test callback view configurations.
Namespace
Drupal\search_autocomplete\Tests\ViewsCode
public function testDefaultViewContent() {
// Retrieve node default view.
$actual_json = $this
->drupalGet("callback/nodes");
$expected = [];
$this
->assertIdentical($actual_json, json_encode($expected), 'The expected JSON output was found.');
// Create some published nodes of type article and page.
$this
->createNodes(5, "article", $expected);
$this
->createNodes(5, "page", $expected);
// Log out user.
$this
->drupalLogout();
// Get the view page as anonymous user.
$actual_json = $this
->drupalGet("callback/nodes");
// Check the view result using serializer service.
$expected_string = json_encode($expected);
$this
->assertIdentical($actual_json, $expected_string);
// Re-test as anonymous user.
$actual_json = $this
->drupalGet("callback/nodes");
$this
->assertIdentical($actual_json, $expected_string);
}