1 views_plugin_style.test | ViewsPluginStyleTestCase::testCustomRowClasses() |
Tests custom css classes.
File
- core/
modules/ views/ tests/ styles/ views_plugin_style.test, line 231 - 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, 'Make 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, 'Make sure that a token in custom CSS class is replaced.');
$count++;
}
}