function ViewsPluginStyleTestCase::testCustomRowClasses

3.x views_plugin_style.test ViewsPluginStyleTestCase::testCustomRowClasses()

Tests custom css classes.

File

tests/styles/views_plugin_style.test, line 238
Definition of ViewsPluginStyleTestCase.

Class

ViewsPluginStyleTestCase
Tests some general style plugin related functionality.

Code

function testCustomRowClasses() {
  $view = $this->getBasicView();

  // Setup some random css class.
  $view->init_display();
  $view->init_style();
  $random_name = $this->randomName();
  $view->style_plugin->options['row_class'] = $random_name . " test-token-[name]";

  $rendered_output = $view->preview();
  $this->storeViewPreview($rendered_output);

  $rows = $this->elements->body->div->div->div;
  $count = 0;
  foreach ($rows as $row) {
    $attributes = $row->attributes();
    $class = (string) $attributes['class'][0];
    $this->assertTrue(strpos($class, $random_name) !== FALSE, 'Take sure that a custom css class is added to the output.');

    // Check token replacement.
    $name = $view->field['name']->get_value($view->result[$count]);
    $this->assertTrue(strpos($class, "test-token-$name") !== FALSE, 'Take sure that a token in custom css class is replaced.');

    $count++;
  }
}