You are here

protected function TourUITest::listTest in Tour UI 8

Tests the listing of a tour.

1 call to TourUITest::listTest()
TourUITest::testUi in tests/src/Functional/TourUITest.php
Tests the listing and editing of a tour.

File

tests/src/Functional/TourUITest.php, line 54

Class

TourUITest
Tests the Tour UI.

Namespace

Drupal\Tests\tour_ui\Functional

Code

protected function listTest() {

  // Assert that two test tours are shown.
  $this
    ->drupalGet('admin/config/user-interface/tour');
  $elements = $this
    ->xpath('//table/tbody/tr');
  $this
    ->assertEquals(5, count($elements));

  // The first column contains the id.
  // jQuery('table > tbody > tr:first > td:first').text() === tour-test
  // jQuery('table > tbody > tr:first').hasClass('tour-test')
  // jQuery('table > tbody > tr.tip-edit > td:first').text()
  $elements = $this
    ->xpath('//table/tbody/tr[contains(@class, :class)]/td[1]', [
    ':class' => 'tour-test',
  ]);
  $this
    ->assertIdentical($elements[0]
    ->getText(), 'tour-test');

  // The second column contains the title.
  $elements = $this
    ->xpath('//table/tbody/tr[contains(@class, :class)]/td[2]', [
    ':class' => 'tour-test',
  ]);
  $this
    ->assertIdentical($elements[0]
    ->getText(), t('Tour test english')
    ->render());

  // The third column contains the routes.
  // Running "jQuery('table > tbody > tr.tour-test > td:nth(2)').html()"
  // results in "> <div class="tour-routes">tour_test.1<br>tour_test.3</div>".
  // FIX ME: trying to solve this failed. See #3009733 for further information.
  // $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td/div[contains(@class, :class-routes)]', [':class' => 'tour-test-1', ':class-routes' => 'tour-routes']);
  // $routes = strpos($elements[0]->getText(), 'tour_test.1') !== FALSE;
  // $this->assertTrue($routes, 'Route contains "tour_test.1".');
  // The fourth column contains the number of tips.
  $elements = $this
    ->xpath('//table/tbody/tr[contains(@class, :class)]/td[4]', [
    ':class' => 'tour-test',
  ]);
  $this
    ->assertIdentical($elements[0]
    ->getText(), '1', 'Core tour_test/config/tour-test-2 has 1 tip');
  $this
    ->assertIdentical($elements[1]
    ->getText(), '3', 'Core tour_test/config/tour-test-1 has 3 tips');
}