Projet

Général

Profil

Paste
Télécharger (2,05 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / tests / handlers / views_handler_argument_null.test @ 4003efde

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of ViewsHandlerArgumentNullTest.
6
 */
7

    
8
/**
9
 * Tests the core views_handler_argument_null handler.
10
 */
11
class ViewsHandlerArgumentNullTest extends ViewsSqlTest {
12
  public static function getInfo() {
13
    return array(
14
      'name' => 'Argument: Null',
15
      'description' => 'Test the core views_handler_argument_null handler.',
16
      'group' => 'Views Handlers',
17
    );
18
  }
19

    
20
  function viewsData() {
21
    $data = parent::viewsData();
22
    $data['views_test']['id']['argument']['handler'] = 'views_handler_argument_null';
23

    
24
    return $data;
25
  }
26

    
27
  public function testAreaText() {
28
    // Test validation.
29
    $view = $this->getBasicView();
30

    
31
    // Add a null argument.
32
    $string = $this->randomString();
33
    $view->display['default']->handler->override_option('arguments', array(
34
      'null' => array(
35
        'id' => 'null',
36
        'table' => 'views',
37
        'field' => 'null',
38
      ),
39
    ));
40

    
41
    $this->executeView($view);
42

    
43
    // Make sure that the argument is not validated yet.
44
    unset($view->argument['null']->argument_validated);
45
    $this->assertTrue($view->argument['null']->validate_arg(26));
46
    // test must_not_be option.
47
    unset($view->argument['null']->argument_validated);
48
    $view->argument['null']->options['must_not_be'] = TRUE;
49
    $this->assertFalse($view->argument['null']->validate_arg(26), 'must_not_be returns FALSE, if there is an argument');
50
    unset($view->argument['null']->argument_validated);
51
    $this->assertTrue($view->argument['null']->validate_arg(NULL), 'must_not_be returns TRUE, if there is no argument');
52

    
53
    // Test execution.
54
    $view = $this->getBasicView();
55

    
56
    // Add a argument, which has null as handler.
57
    $string = $this->randomString();
58
    $view->display['default']->handler->override_option('arguments', array(
59
      'id' => array(
60
        'id' => 'id',
61
        'table' => 'views_test',
62
        'field' => 'id',
63
      ),
64
    ));
65

    
66
    $this->executeView($view, array(26));
67

    
68
    // The argument should be ignored, so every result should return.
69
    $this->assertEqual(5, count($view->result));
70
  }
71

    
72
}