You are here

function StyleUnformattedTest::testDefaultRowClasses in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/StyleUnformattedTest.php \Drupal\views\Tests\Plugin\StyleUnformattedTest::testDefaultRowClasses()

Make sure that the default css classes works as expected.

File

core/modules/views/src/Tests/Plugin/StyleUnformattedTest.php, line 29
Contains \Drupal\views\Tests\Plugin\StyleUnformattedTest.

Class

StyleUnformattedTest
Tests unformatted style functionality.

Namespace

Drupal\views\Tests\Plugin

Code

function testDefaultRowClasses() {
  $view = Views::getView('test_view');
  $view
    ->setDisplay();
  $output = $view
    ->preview();
  $this
    ->storeViewPreview(\Drupal::service('renderer')
    ->renderRoot($output));
  $rows = $this->elements->body->div->div;
  $count = 0;
  $count_result = count($view->result);
  foreach ($rows as $row) {
    $count++;
    $attributes = $row
      ->attributes();
    $class = (string) $attributes['class'][0];
    $this
      ->assertTrue(strpos($class, 'views-row') !== FALSE, 'Make sure that the views row class is set right.');
  }
  $this
    ->assertIdentical($count, $count_result);
}