You are here

protected function UcAddressesViewsTestCase::createDisplayAccessView in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 tests/uc_addresses.views.test \UcAddressesViewsTestCase::createDisplayAccessView()

Creates a View for Display access test.

Return value

object The created View.

1 call to UcAddressesViewsTestCase::createDisplayAccessView()
UcAddressesViewsTestCase::testDisplayAccessPlugin in tests/uc_addresses.views.test
Tests if the display access plugin works as expected.

File

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

Class

UcAddressesViewsTestCase
Test cases for Views integration.

Code

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

  /* Edit this to true to make a default view disabled initially */

  /* Display: Master */
  $handler = $view
    ->new_display('default', 'Master', 'default');
  $handler->display->display_options['items_per_page'] = 0;
  $handler->display->display_options['access']['type'] = 'none';
  $handler->display->display_options['cache']['type'] = 'none';
  $handler->display->display_options['query']['type'] = 'views_query';
  $handler->display->display_options['exposed_form']['type'] = 'basic';
  $handler->display->display_options['pager']['type'] = 'none';
  $handler->display->display_options['style_plugin'] = 'default';
  $handler->display->display_options['row_plugin'] = 'fields';

  // For Views 6.x-2.x to show all items.
  $handler
    ->override_option('items_per_page', 0);

  /* Field: Ubercart Addresses: Address ID */
  $handler->display->display_options['fields']['aid']['id'] = 'aid';
  $handler->display->display_options['fields']['aid']['table'] = 'uc_addresses';
  $handler->display->display_options['fields']['aid']['field'] = 'aid';

  /* Field: Ubercart Addresses: Address name */
  $handler->display->display_options['fields']['address_name']['id'] = 'address_name';
  $handler->display->display_options['fields']['address_name']['table'] = 'uc_addresses';
  $handler->display->display_options['fields']['address_name']['field'] = 'address_name';

  /* Argument: Ubercart Addresses: User ID */
  $handler->display->display_options['arguments']['uid']['id'] = 'uid';
  $handler->display->display_options['arguments']['uid']['table'] = 'uc_addresses';
  $handler->display->display_options['arguments']['uid']['field'] = 'uid';
  $handler->display->display_options['arguments']['uid']['default_action'] = 'not found';
  $handler->display->display_options['arguments']['uid']['style_plugin'] = 'default_summary';
  $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'fixed';
  $handler->display->display_options['arguments']['uid']['default_argument_skip_url'] = 0;
  $handler->display->display_options['arguments']['uid']['validate_type'] = 'none';
  $handler->display->display_options['arguments']['uid']['break_phrase'] = 0;
  $handler->display->display_options['arguments']['uid']['not'] = 0;

  /* Argument: Ubercart Addresses: Address ID */
  $handler->display->display_options['arguments']['aid']['id'] = 'aid';
  $handler->display->display_options['arguments']['aid']['table'] = 'uc_addresses';
  $handler->display->display_options['arguments']['aid']['field'] = 'aid';
  $handler->display->display_options['arguments']['aid']['style_plugin'] = 'default_summary';
  $handler->display->display_options['arguments']['aid']['default_argument_type'] = 'fixed';
  $handler->display->display_options['arguments']['aid']['default_argument_skip_url'] = 0;
  $handler->display->display_options['arguments']['aid']['validate_type'] = 'none';
  $handler->display->display_options['arguments']['aid']['break_phrase'] = 0;
  $handler->display->display_options['arguments']['aid']['not'] = 0;

  /* Display: uc_addresses_view_access */
  $handler = $view
    ->new_display('page', 'uc_addresses_view_access', 'uc_addresses_view_access');
  $handler->display->display_options['defaults']['access'] = FALSE;
  $handler->display->display_options['access']['type'] = 'uc_addresses_views_access';
  $handler->display->display_options['access']['uid_argument'] = 'uid';
  $handler->display->display_options['access']['aid_argument'] = 'aid';
  $handler->display->display_options['access']['access_type'] = 'view';
  $handler->display->display_options['path'] = 'user/%/uc_addresses_display_access_view';
  $handler->display->display_options['menu']['type'] = 'tab';
  $handler->display->display_options['menu']['title'] = 'AddressBookView';
  $handler->display->display_options['menu']['weight'] = '0';

  /* Display: uc_addresses_edit_access */
  $handler = $view
    ->new_display('page', 'uc_addresses_edit_access', 'uc_addresses_edit_access');
  $handler->display->display_options['defaults']['access'] = FALSE;
  $handler->display->display_options['access']['type'] = 'uc_addresses_views_access';
  $handler->display->display_options['access']['uid_argument'] = 'uid';
  $handler->display->display_options['access']['aid_argument'] = 'aid';
  $handler->display->display_options['access']['access_type'] = 'edit';
  $handler->display->display_options['path'] = 'user/%/uc_addresses_display_access_edit';
  $handler->display->display_options['menu']['type'] = 'tab';
  $handler->display->display_options['menu']['title'] = 'AddressBookEdit';
  $handler->display->display_options['menu']['weight'] = '0';

  /* Display: uc_addresses_delete_access */
  $handler = $view
    ->new_display('page', 'uc_addresses_delete_access', 'uc_addresses_delete_access');
  $handler->display->display_options['defaults']['access'] = FALSE;
  $handler->display->display_options['access']['type'] = 'uc_addresses_views_access';
  $handler->display->display_options['access']['uid_argument'] = 'uid';
  $handler->display->display_options['access']['aid_argument'] = 'aid';
  $handler->display->display_options['access']['access_type'] = 'delete';
  $handler->display->display_options['path'] = 'user/%/uc_addresses_display_access_delete';
  $handler->display->display_options['menu']['type'] = 'tab';
  $handler->display->display_options['menu']['title'] = 'AddressBookDelete';
  $handler->display->display_options['menu']['weight'] = '0';

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