You are here

function ModuleGrantsBasicTestCase::testQueryAlter in Module Grants 7

File

./module_grants.test, line 603

Class

ModuleGrantsBasicTestCase

Code

function testQueryAlter() {
  $body[LANGUAGE_NONE][0]['value'] = 'All';
  $node = $this
    ->drupalCreateNode(array(
    'title' => "Test node dog blue three",
    'type' => 'article',
    'body' => $body,
  ));
  variable_set('module_grants_lenient', true);
  $this
    ->assertNodeQueryAlter(array(), 0);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
  ), 0);
  $this
    ->assertNodeQueryAlter(array(
    'cat',
  ), 0);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
    'blue',
  ), 0);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
    'red',
  ), 0);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
    'blue',
    'three',
  ), 1);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
    'blue',
    'two',
  ), 0);
  variable_set('module_grants_lenient', false);
  $this
    ->assertNodeQueryAlter(array(), 0);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
  ), 0);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
    'blue',
  ), 0);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
    'blue',
    'three',
  ), 1);
  $this
    ->assertNodeQueryAlter(array(
    'dog',
    'blue',
    'two',
  ), 0);
  variable_set('module_grants_lenient', true);
  $this
    ->assertEntityQueryAlter(array(), 0);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
  ), 0);
  $this
    ->assertEntityQueryAlter(array(
    'cat',
  ), 0);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
    'blue',
  ), 0);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
    'red',
  ), 0);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
    'blue',
    'three',
  ), 1);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
    'blue',
    'two',
  ), 0);
  variable_set('module_grants_lenient', false);
  $this
    ->assertEntityQueryAlter(array(), 0);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
  ), 0);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
    'blue',
  ), 0);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
    'blue',
    'three',
  ), 1);
  $this
    ->assertEntityQueryAlter(array(
    'dog',
    'blue',
    'two',
  ), 0);
}