public function PagerElementTest::testPagerElement in Entity Browser 8
Same name and namespace in other branches
- 8.2 tests/src/FunctionalJavascript/PagerElementTest.php \Drupal\Tests\entity_browser\FunctionalJavascript\PagerElementTest::testPagerElement()
Test entity browser pager form element.
File
- tests/
src/ FunctionalJavascript/ PagerElementTest.php, line 80
Class
- PagerElementTest
- Tests entity browser pager form element.
Namespace
Drupal\Tests\entity_browser\FunctionalJavascriptCode
public function testPagerElement() {
$this
->drupalGet('/entity-browser/iframe/pager');
// Go through pager next and previous buttons and assert pages.
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 1.');
$this
->assertSession()
->buttonExists('‹ Previous')
->hasAttribute('disabled');
$this
->assertSession()
->pageTextContains('Page 1');
$this
->assertSession()
->buttonExists('Next ›');
$this
->getSession()
->getPage()
->pressButton('Next ›');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 2.');
$this
->assertSession()
->pageTextContains('Page 2');
$this
->getSession()
->getPage()
->pressButton('Next ›');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 3.');
$this
->assertSession()
->pageTextContains('Page 3');
$this
->getSession()
->getPage()
->pressButton('Next ›');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 4.');
$this
->assertSession()
->pageTextContains('Page 4');
$this
->assertSession()
->buttonExists('Next ›')
->hasAttribute('disabled');
// Go back.
$this
->getSession()
->getPage()
->pressButton('‹ Previous');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 3.');
$this
->assertSession()
->pageTextContains('Page 3');
$this
->getSession()
->getPage()
->pressButton('‹ Previous');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 2.');
$this
->assertSession()
->pageTextContains('Page 2');
$this
->getSession()
->getPage()
->pressButton('‹ Previous');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 1.');
$this
->assertSession()
->pageTextContains('Page 1');
$this
->assertSession()
->buttonExists('‹ Previous')
->hasAttribute('disabled');
// Test reset button.
$this
->getSession()
->getPage()
->pressButton('Last page');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 4.');
$this
->assertSession()
->pageTextContains('Page 4');
$this
->getSession()
->getPage()
->pressButton('First page');
$this
->assertSession()
->pageTextContains('Current page reported by the element is: 1.');
$this
->assertSession()
->pageTextContains('Page 1');
}