views_handler_argument_null.test 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsHandlerArgumentNullTest.
  5. */
  6. /**
  7. * Tests the core views_handler_argument_null handler.
  8. */
  9. class ViewsHandlerArgumentNullTest extends ViewsSqlTest {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Argument: Null',
  13. 'description' => 'Test the core views_handler_argument_null handler.',
  14. 'group' => 'Views Handlers',
  15. );
  16. }
  17. function viewsData() {
  18. $data = parent::viewsData();
  19. $data['views_test']['id']['argument']['handler'] = 'views_handler_argument_null';
  20. return $data;
  21. }
  22. public function testAreaText() {
  23. // Test validation
  24. $view = $this->getBasicView();
  25. // Add a null argument.
  26. $string = $this->randomString();
  27. $view->display['default']->handler->override_option('arguments', array(
  28. 'null' => array(
  29. 'id' => 'null',
  30. 'table' => 'views',
  31. 'field' => 'null',
  32. ),
  33. ));
  34. $this->executeView($view);
  35. // Make sure that the argument is not validated yet.
  36. unset($view->argument['null']->argument_validated);
  37. $this->assertTrue($view->argument['null']->validate_arg(26));
  38. // test must_not_be option.
  39. unset($view->argument['null']->argument_validated);
  40. $view->argument['null']->options['must_not_be'] = TRUE;
  41. $this->assertFalse($view->argument['null']->validate_arg(26), 'must_not_be returns FALSE, if there is an argument');
  42. unset($view->argument['null']->argument_validated);
  43. $this->assertTrue($view->argument['null']->validate_arg(NULL), 'must_not_be returns TRUE, if there is no argument');
  44. // Test execution.
  45. $view = $this->getBasicView();
  46. // Add a argument, which has null as handler.
  47. $string = $this->randomString();
  48. $view->display['default']->handler->override_option('arguments', array(
  49. 'id' => array(
  50. 'id' => 'id',
  51. 'table' => 'views_test',
  52. 'field' => 'id',
  53. ),
  54. ));
  55. $this->executeView($view, array(26));
  56. // The argument should be ignored, so every result should return.
  57. $this->assertEqual(5, count($view->result));
  58. }
  59. }