You are here

public function AccessWebTestCase::createListScheme in Access Control Kit 7

Creates a list-based scheme with generic realms.

Parameters

string $type: The list type: 'integer', 'float', or 'text'.

Return value

object An access scheme.

3 calls to AccessWebTestCase::createListScheme()
AccessGrantFunctionTest::testGrantCRUD in ./access.test
Test basic create, read, update, and delete functions.
AccessPluginTest::testHanderInfo in ./access.test
Check that handlers are defined correctly.
AccessPluginTest::testSchemeInfo in ./access.test
Check that scheme types are defined correctly.

File

./access.test, line 57
Tests for the access control kit module.

Class

AccessWebTestCase
Provides common helper methods for access control kit module tests.

Code

public function createListScheme($type) {
  switch ($type) {
    case 'integer':
      $realms = array(
        1 => '1 day',
        7 => '1 week',
        31 => '1 month',
      );
      break;
    case 'float':
      $realms = array(
        '0' => '0',
        '.25' => '1/4',
        '.75' => '3/4',
        '1' => '1',
      );
      break;
    case 'text':
      $realms = array(
        'IL' => 'Illinois',
        'IA' => 'Iowa',
        'IN' => 'Indiana',
      );
      break;
    default:
      $realms = array();
  }
  field_create_field(array(
    'field_name' => 'field_' . $type,
    'type' => 'list_' . $type,
    'settings' => array(
      'allowed_values' => $realms,
    ),
  ));
  $scheme = $this
    ->createScheme('list_' . $type, array(
    'field_name' => 'field_' . $type,
  ));
  return access_scheme_load($scheme->sid);
}