home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (views_handler_argument_null.test)

This example Drupal source code file (views_handler_argument_null.test) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

argument, array, function, id, is, null, php, return, returns, there, true, unset, view, views_handler_argument_null

The views_handler_argument_null.test Drupal example source code

<?php
// $Id: views_handler_argument_null.test,v 1.1.2.1 2010/11/07 11:32:25 dereine Exp $

class ViewsHandlerArgumentNullTest extends ViewsSqlTest {
  public static function getInfo() {
    return array(
      'name' => 'Argument: Null',
      'description' => 'Test the core views_handler_argument_null handler.',
      'group' => 'Views Handlers',
    );
  }

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

    return $data;
  }

  public function testAreaText() {
    // Test validation
    $view = $this->getBasicView();

    // Add a null argument.
    $string = $this->randomString();
    $view->display['default']->handler->override_option('arguments', array(
      'null' => array(
        'id' => 'null',
        'table' => 'views',
        'field' => 'null',
      ),
    ));

    $this->executeView($view);

    // Take sure that the argument is not validated yet.
    unset($view->argument['null']->argument_validated);
    $this->assertTrue($view->argument['null']->validate_arg(26));
    // test must_not_be option.
    unset($view->argument['null']->argument_validated);
    $view->argument['null']->options['must_not_be'] = TRUE;
    $this->assertFalse($view->argument['null']->validate_arg(26), 'must_not_be returns FALSE, if there is an argument');
    unset($view->argument['null']->argument_validated);
    $this->assertTrue($view->argument['null']->validate_arg(NULL), 'must_not_be returns TRUE, if there is no argument');

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

    // Add a argument, which has null as handler.
    $string = $this->randomString();
    $view->display['default']->handler->override_option('arguments', array(
      'id' => array(
        'id' => 'id',
        'table' => 'views_test',
        'field' => 'id',
      ),
    ));

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

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

}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_handler_argument_null.test source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.