function ViewsPluginStyleTestCase::testCustomRowClasses
Tests custom css classes.
File
-
tests/
styles/ views_plugin_style.test, line 250
Class
- ViewsPluginStyleTestCase
- Tests some general style plugin related functionality.
Code
public function testCustomRowClasses() {
$view = $this->getBasicView();
// Setup some random css class.
$view->init_display();
$view->init_style();
$random_name = drupal_html_class($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, 'Make sure that a custom css class is added to the output.');
// Check token replacement.
$name = drupal_clean_css_identifier($view->field['name']
->get_value($view->result[$count]));
$this->assertTrue(strpos($class, "test-token-{$name}") !== FALSE, 'Make sure that a token in custom css class is replaced.');
$count++;
}
}