summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test48
1 files changed, 48 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test
index 875fcf1..87f5b7d 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test
@@ -2,6 +2,10 @@
/**
* @file
+ * Definition of ViewsPluginStyleTestCase.
+ */
+
+/**
* Tests some general style plugin related functionality.
*/
class ViewsPluginStyleTestCase extends ViewsSqlTest {
@@ -227,4 +231,48 @@ class ViewsPluginStyleTestCase extends ViewsSqlTest {
$this->assertEqual($sets_new_value, $expected, t('The style plugins should proper group the results with grouping by the value.'));
}
}
+
+
+ /**
+ * Stores a view output in the elements.
+ */
+ function storeViewPreview($output) {
+ $htmlDom = new DOMDocument();
+ @$htmlDom->loadHTML($output);
+ if ($htmlDom) {
+ // It's much easier to work with simplexml than DOM, luckily enough
+ // we can just simply import our DOM tree.
+ $this->elements = simplexml_import_dom($htmlDom);
+ }
+ }
+
+ /**
+ * Tests custom css classes.
+ */
+ 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++;
+ }
+ }
}