Same name and namespace in other branches
- 2.0.x tests/src/FunctionalJavascript/EntityReferenceAjaxFormatterTest.php \Drupal\Tests\entity_reference_ajax_formatter\FunctionalJavascript\EntityReferenceAjaxFormatterTest::testFormatter()
Tests the behavior of the 'entity_reference_ajax_entity_view' formatter.
Fichier
-
tests/
src/ FunctionalJavascript/ EntityReferenceAjaxFormatterTest.php, line 107
Classe
- EntityReferenceAjaxFormatterTest
- Test the Entity Reference Ajax Formatter.
Namespace
Drupal\Tests\entity_reference_ajax_formatter\FunctionalJavascriptCode
public function testFormatter() {
$this->drupalGet("node/{$this->node->id()}");
$session = $this->assertSession();
$session->pageTextContains('Node #1');
$session->pageTextNotContains('Node #2');
$session->pageTextNotContains('Load More');
// Test random sort.
$this->display
->setComponent('field_ref', [
'type' => 'entity_reference_ajax_entity_view',
'settings' => [
'number' => 3,
'sort' => 1,
'load_more' => TRUE,
'max' => 8,
],
])
->save();
$this->drupalGet("node/{$this->node->id()}");
$page = $this->getSession()
->getPage();
$this->assertSame(count($page->findAll('css', 'article.node')), 4);
$session->pageTextMatches('/Node #(\\d\\d|[^123])/');
$session->pageTextContains('Load More');
$page->clickLink('Load More');
$session->assertWaitOnAjaxRequest();
$this->assertSame(count($page->findAll('css', 'article.node')), 7);
$session->pageTextContains('Load More');
$page->clickLink('Load More');
$session->assertWaitOnAjaxRequest();
$text = $page->getText();
$this->assertSame(count($page->findAll('css', 'article.node')), 9);
$session->pageTextNotContains('Load More');
}