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

Drupal example source code file (views_handler_filter_equality.test)

This example Drupal source code file (views_handler_filter_equality.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

array, field, function, id, name, operator, php, resultset, return, ringo, table, value, view, views_test

The views_handler_filter_equality.test Drupal example source code

<?php
// $Id: views_handler_filter_equality.test,v 1.1.2.1 2010/12/26 22:41:40 dereine Exp $

class viewsHandlerFilterEqualityTest extends ViewsSqlTest {
  public static function getInfo() {
    return array(
      'name' => 'Filter: Equality',
      'description' => 'Test the core views_handler_filter_equality handler.',
      'group' => 'Views Handlers',
    );
  }

  function setUp() {
    parent::setUp();
    $this->column_map = array(
      'views_test_name' => 'name',
    );
  }

  function viewsData() {
    $data = parent::viewsData();
    $data['views_test']['name']['filter']['handler'] = 'views_handler_filter_equality';

    return $data;
  }

  function testEqual() {
    $view = $this->getBasicView();

    // Change the filtering
    $view->display['default']->handler->override_option('filters', array(
      'name' => array(
        'id' => 'name',
        'table' => 'views_test',
        'field' => 'name',
        'relationship' => 'none',
        'operator' => '=',
        'value' => array('value' => 'Ringo'),
      ),
    ));

    $this->executeView($view);
    $resultset = array(
      array(
        'name' => 'Ringo',
      ),
    );
    $this->assertIdenticalResultset($view, $resultset, $this->column_map);
  }

  function testNotEqual() {
    $view = $this->getBasicView();

    // Change the filtering
    $view->display['default']->handler->override_option('filters', array(
      'name' => array(
        'id' => 'name',
        'table' => 'views_test',
        'field' => 'name',
        'relationship' => 'none',
        'operator' => '!=',
        'value' => array('value' => 'Ringo'),
      ),
    ));

    $this->executeView($view);
    $resultset = array(
      array(
        'name' => 'John',
      ),
      array(
        'name' => 'George',
      ),
      array(
        'name' => 'Paul',
      ),
      array(
        'name' => 'Meredith',
      ),
    );
    $this->assertIdenticalResultset($view, $resultset, $this->column_map);
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_handler_filter_equality.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.