You are here

public function EntityQueueTest::testEntityQueueButtons in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/EntityQueueTest.php \Drupal\Tests\entity_browser\FunctionalJavascript\EntityQueueTest::testEntityQueueButtons()

Tests entityqueue buttons.

File

tests/src/FunctionalJavascript/EntityQueueTest.php, line 57

Class

EntityQueueTest
Tests entity browser used to manipulate EntitySubqueue.

Namespace

Drupal\Tests\entity_browser\FunctionalJavascript

Code

public function testEntityQueueButtons() {
  $this
    ->drupalLogin($this->adminUser);
  $article1 = $this
    ->createNode([
    'type' => 'article',
    'title' => 'Article 1',
  ]);
  $article2 = $this
    ->createNode([
    'type' => 'article',
    'title' => 'Article 2',
  ]);
  $article3 = $this
    ->createNode([
    'type' => 'article',
    'title' => 'Article 3',
  ]);
  $subqueue = EntitySubqueue::load('nodes');
  $subqueue->items
    ->setValue([
    $article1,
    $article2,
    $article3,
  ]);
  $subqueue
    ->save();
  $this
    ->drupalGet('/admin/structure/entityqueue/nodes/nodes');
  $correct_order = [
    1 => 'Article 1',
    2 => 'Article 2',
    3 => 'Article 3',
  ];
  foreach ($correct_order as $key => $value) {
    $this
      ->assertSession()
      ->elementContains('xpath', "(//div[contains(@class, 'item-container')])[" . $key . "]", $value);
  }
  $this
    ->assertSession()
    ->buttonExists('Reverse')
    ->press();
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $correct_order = [
    1 => 'Article 3',
    2 => 'Article 2',
    3 => 'Article 1',
  ];
  foreach ($correct_order as $key => $value) {
    $this
      ->assertSession()
      ->elementContains('xpath', "(//div[contains(@class, 'item-container')])[" . $key . "]", $value);
  }
  $this
    ->assertSession()
    ->buttonExists('Clear')
    ->press();
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->elementNotExists('xpath', "//div[contains(@class, 'item-container')]");
}