views_handler_area_text.test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsHandlerAreaTextTest.
  5. */
  6. /**
  7. * Tests the text area handler.
  8. *
  9. * @see views_handler_area_text
  10. */
  11. class ViewsHandlerAreaTextTest extends ViewsSqlTest {
  12. public static function getInfo() {
  13. return array(
  14. 'name' => 'Area: Text',
  15. 'description' => 'Test the core views_handler_area_text handler.',
  16. 'group' => 'Views Handlers',
  17. );
  18. }
  19. public function testAreaText() {
  20. $view = $this->getBasicView();
  21. // add a text header
  22. $string = $this->randomName();
  23. $view->display['default']->handler->override_option('header', array(
  24. 'area' => array(
  25. 'id' => 'area',
  26. 'table' => 'views',
  27. 'field' => 'area',
  28. 'content' => $string,
  29. ),
  30. ));
  31. // Execute the view.
  32. $this->executeView($view);
  33. $view->display_handler->handlers['header']['area']->options['format'] = $this->randomString();
  34. $this->assertEqual(NULL, $view->display_handler->handlers['header']['area']->render(), 'Non existant format should return nothing');
  35. $view->display_handler->handlers['header']['area']->options['format'] = filter_default_format();
  36. $this->assertEqual(check_markup($string), $view->display_handler->handlers['header']['area']->render(), 'Existant format should return something');
  37. // Empty results, and it shouldn't be displayed .
  38. $this->assertEqual('', $view->display_handler->handlers['header']['area']->render(TRUE), 'No result should lead to no header');
  39. // Empty results, and it should be displayed.
  40. $view->display_handler->handlers['header']['area']->options['empty'] = TRUE;
  41. $this->assertEqual(check_markup($string), $view->display_handler->handlers['header']['area']->render(TRUE), 'No result, but empty enabled lead to a full header');
  42. }
  43. }