summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style.test48
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test8
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test73
3 files changed, 129 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++;
+ }
+ }
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
index 03495c3..9a53bfc 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
@@ -1,5 +1,13 @@
<?php
+/**
+ * @file
+ * Definition of viewsPluginStyleJumpMenuTest.
+ */
+
+/**
+ * Tests jump menu style functionality.
+ */
class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
public static function getInfo() {
return array(
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test
new file mode 100644
index 0000000..20b7b4d
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_unformatted.test
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * @file
+ * Definition of ViewsPluginStyleUnformattedTestCase.
+ */
+
+/**
+ * Tests the default/unformatted row style.
+ */
+class ViewsPluginStyleUnformattedTestCase extends ViewsSqlTest {
+
+ /**
+ * Stores all created nodes.
+ *
+ * @var array
+ */
+ var $nodes;
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Style: unformatted',
+ 'description' => 'Test unformatted style functionality.',
+ 'group' => 'Views Plugins',
+ );
+ }
+
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * Take sure that the default css classes works as expected.
+ */
+ function testDefaultRowClasses() {
+ $view = $this->getBasicView();
+ $rendered_output = $view->preview();
+ $this->storeViewPreview($rendered_output);
+
+ $rows = $this->elements->body->div->div->div;
+ $count = 0;
+ $count_result = count($view->result);
+ foreach ($rows as $row) {
+ $count++;
+ $attributes = $row->attributes();
+ $class = (string) $attributes['class'][0];
+ // Take sure that each row has a row css class.
+ $this->assertTrue(strpos($class, "views-row-$count") !== FALSE, 'Take sure that each row has a row css class.');
+ // Take sure that the odd/even classes are set right.
+ $odd_even = $count % 2 == 0 ? 'even' : 'odd';
+ $this->assertTrue(strpos($class, "views-row-$odd_even") !== FALSE, 'Take sure that the odd/even classes are set right.');
+
+ if ($count == 1) {
+ $this->assertTrue(strpos($class, "views-row-first") !== FALSE, 'Take sure that the first class is set right.');
+ }
+ else if ($count == $count_result) {
+ $this->assertTrue(strpos($class, "views-row-last") !== FALSE, 'Take sure that the last class is set right.');
+
+ }
+ $this->assertTrue(strpos($class, 'views-row') !== FALSE, 'Take sure that the views row class is set right.');
+ }
+ }
+
+}