views_plugin_style_unformatted.test 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsPluginStyleUnformattedTestCase.
  5. */
  6. /**
  7. * Tests the default/unformatted row style.
  8. */
  9. class ViewsPluginStyleUnformattedTestCase extends ViewsPluginStyleTestBase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Style: unformatted',
  13. 'description' => 'Test unformatted style functionality.',
  14. 'group' => 'Views Plugins',
  15. );
  16. }
  17. /**
  18. * Take sure that the default css classes works as expected.
  19. */
  20. function testDefaultRowClasses() {
  21. $view = $this->getBasicView();
  22. $rendered_output = $view->preview();
  23. $this->storeViewPreview($rendered_output);
  24. $rows = $this->elements->body->div->div->div;
  25. $count = 0;
  26. $count_result = count($view->result);
  27. foreach ($rows as $row) {
  28. $count++;
  29. $attributes = $row->attributes();
  30. $class = (string) $attributes['class'][0];
  31. // Take sure that each row has a row css class.
  32. $this->assertTrue(strpos($class, "views-row-$count") !== FALSE, 'Take sure that each row has a row css class.');
  33. // Take sure that the odd/even classes are set right.
  34. $odd_even = $count % 2 == 0 ? 'even' : 'odd';
  35. $this->assertTrue(strpos($class, "views-row-$odd_even") !== FALSE, 'Take sure that the odd/even classes are set right.');
  36. if ($count == 1) {
  37. $this->assertTrue(strpos($class, "views-row-first") !== FALSE, 'Take sure that the first class is set right.');
  38. }
  39. else if ($count == $count_result) {
  40. $this->assertTrue(strpos($class, "views-row-last") !== FALSE, 'Take sure that the last class is set right.');
  41. }
  42. $this->assertTrue(strpos($class, 'views-row') !== FALSE, 'Take sure that the views row class is set right.');
  43. }
  44. }
  45. }