You are here

protected function UcAddressesViewsTestCase::createArgumentValidatorView2 in Ubercart Addresses 6.2

Creates a View for Argument validator test for Views 2.

Return value

object The created View.

1 call to UcAddressesViewsTestCase::createArgumentValidatorView2()
UcAddressesViewsTestCase::testArgumentValidatorPlugins in tests/uc_addresses.views.test
Tests if the argument validator plugins work as expected.

File

tests/uc_addresses.views.test, line 793
Test cases for Views integration.

Class

UcAddressesViewsTestCase
Test cases for Views integration.

Code

protected function createArgumentValidatorView2() {
  views_include('view');
  $view = new view();
  $view->vid = 'new';
  $view->name = 'uc_addresses_argument_validator';
  $view->description = 'Used to test if display access restrictions work as expected.';
  $view->tag = 'default';
  $view->base_table = 'uc_addresses';
  $view->core = 6;
  $view->api_version = '2';
  $view->disabled = FALSE;

  /* Edit this to true to make a default view disabled initially */
  $handler = $view
    ->new_display('default', 'Master', 'default');
  $handler
    ->override_option('fields', array(
    'aid' => array(
      'id' => 'aid',
      'table' => 'uc_addresses',
      'field' => 'aid',
    ),
    'address_name' => array(
      'id' => 'address_name',
      'table' => 'uc_addresses',
      'field' => 'address_name',
    ),
  ));
  $handler
    ->override_option('access', array(
    'type' => 'none',
  ));
  $handler
    ->override_option('cache', array(
    'type' => 'none',
  ));
  $handler
    ->override_option('items_per_page', 0);
  $handler = $view
    ->new_display('page', 'uc_addresses_view_access', 'uc_addresses_view_access');
  $handler
    ->override_option('arguments', array(
    'uid' => array(
      'id' => 'uid',
      'table' => 'uc_addresses',
      'field' => 'uid',
      'default_action' => 'not found',
      'style_plugin' => 'default_summary',
      'default_argument_type' => 'fixed',
      'default_argument_skip_url' => 0,
      'validate_type' => 'uc_addresses_user_address_access',
      'validate_fail' => 'not found',
      'validate_uc_addresses_user_argument_type' => 'uid',
      'validate_uc_addresses_user_restrict_roles' => FALSE,
      'validate_uc_addresses_user_roles' => array(),
      'validate_uc_addresses_user_access_type' => 'view',
      'break_phrase' => 0,
      'not' => 0,
    ),
    'aid' => array(
      'id' => 'aid',
      'table' => 'uc_addresses',
      'field' => 'aid',
      'style_plugin' => 'default_summary',
      'default_argument_type' => 'fixed',
      'default_argument_skip_url' => 0,
      'validate_type' => 'uc_addresses_address_access',
      'validate_fail' => 'not found',
      'validate_uc_addresses_address_access_type' => 'view',
      'break_phrase' => 0,
      'not' => 0,
    ),
  ));
  $handler
    ->override_option('path', 'user/%/uc_addresses_argument_validator_view');
  $handler
    ->override_option('menu', array(
    'type' => 'tab',
    'title' => 'AddressBookView',
    'description' => '',
    'weight' => '0',
    'name' => 'navigation',
  ));
  $handler
    ->override_option('tab_options', array(
    'type' => 'none',
    'title' => '',
    'description' => '',
    'weight' => 0,
    'name' => 'navigation',
  ));
  $handler = $view
    ->new_display('page', 'uc_addresses_edit_access', 'uc_addresses_edit_access');
  $handler
    ->override_option('arguments', array(
    'uid' => array(
      'id' => 'uid',
      'table' => 'uc_addresses',
      'field' => 'uid',
      'default_action' => 'not found',
      'style_plugin' => 'default_summary',
      'default_argument_type' => 'fixed',
      'default_argument_skip_url' => 0,
      'validate_type' => 'uc_addresses_user_address_access',
      'validate_fail' => 'not found',
      'validate_uc_addresses_user_argument_type' => 'uid',
      'validate_uc_addresses_user_restrict_roles' => FALSE,
      'validate_uc_addresses_user_roles' => array(),
      'validate_uc_addresses_user_access_type' => 'edit',
      'break_phrase' => 0,
      'not' => 0,
    ),
    'aid' => array(
      'id' => 'aid',
      'table' => 'uc_addresses',
      'field' => 'aid',
      'style_plugin' => 'default_summary',
      'default_argument_type' => 'fixed',
      'default_argument_skip_url' => 0,
      'validate_type' => 'uc_addresses_address_access',
      'validate_fail' => 'not found',
      'validate_uc_addresses_address_access_type' => 'edit',
      'break_phrase' => 0,
      'not' => 0,
    ),
  ));
  $handler
    ->override_option('path', 'user/%/uc_addresses_argument_validator_edit');
  $handler
    ->override_option('menu', array(
    'type' => 'tab',
    'title' => 'AddressBookEdit',
    'description' => '',
    'weight' => '0',
    'name' => 'navigation',
  ));
  $handler
    ->override_option('tab_options', array(
    'type' => 'none',
    'title' => '',
    'description' => '',
    'weight' => 0,
    'name' => 'navigation',
  ));
  $handler = $view
    ->new_display('page', 'uc_addresses_delete_access', 'uc_addresses_delete_access');
  $handler
    ->override_option('arguments', array(
    'uid' => array(
      'id' => 'uid',
      'table' => 'uc_addresses',
      'field' => 'uid',
      'default_action' => 'not found',
      'style_plugin' => 'default_summary',
      'default_argument_type' => 'fixed',
      'default_argument_skip_url' => 0,
      'validate_type' => 'uc_addresses_user_address_access',
      'validate_fail' => 'not found',
      'validate_uc_addresses_user_argument_type' => 'uid',
      'validate_uc_addresses_user_restrict_roles' => FALSE,
      'validate_uc_addresses_user_roles' => array(),
      'validate_uc_addresses_user_access_type' => 'delete',
      'break_phrase' => 0,
      'not' => 0,
    ),
    'aid' => array(
      'id' => 'aid',
      'table' => 'uc_addresses',
      'field' => 'aid',
      'style_plugin' => 'default_summary',
      'default_argument_type' => 'fixed',
      'default_argument_skip_url' => 0,
      'validate_type' => 'uc_addresses_address_access',
      'validate_fail' => 'not found',
      'validate_uc_addresses_address_access_type' => 'delete',
      'break_phrase' => 0,
      'not' => 0,
    ),
  ));
  $handler
    ->override_option('path', 'user/%/uc_addresses_argument_validator_delete');
  $handler
    ->override_option('menu', array(
    'type' => 'tab',
    'title' => 'AddressBookDelete',
    'description' => '',
    'weight' => '0',
    'name' => 'navigation',
  ));
  $handler
    ->override_option('tab_options', array(
    'type' => 'none',
    'title' => '',
    'description' => '',
    'weight' => 0,
    'name' => 'navigation',
  ));

  // Save View.
  $this
    ->UcAddressesSaveView($view);
  return $view;
}