You are here

function SpacesOGTestOverrides::testOverrides in Spaces 7

Same name and namespace in other branches
  1. 6.3 spaces_og/tests/spaces_og.test \SpacesOGTestOverrides::testOverrides()
  2. 7.3 spaces_og/tests/spaces_og.test \SpacesOGTestOverrides::testOverrides()

Test override space configuration.

File

spaces_og/tests/spaces_og.test, line 258

Class

SpacesOGTestOverrides

Code

function testOverrides() {

  // Go to override tab and verify settings.
  $this
    ->drupalGet('group-a/node/1/features/overrides');
  $this
    ->assertPattern('/spaces_preset_og(.*?)og_public/');
  $this
    ->assertPattern('/spaces_og_selective(.*?)0(.*?)inherited/');
  $this
    ->assertPattern('/spaces_og_register(.*?)1(.*?)inherited/');
  $this
    ->assertPattern('/spaces_og_directory(.*?)1(.*?)inherited/');
  $this
    ->assertPattern('/spaces_og_private(.*?)0(.*?)inherited/');
  $this
    ->assertNoText('features_test_setting');

  // Save feature setting (amounts to an actual change) and verify the change
  // on the overrides page.
  $this
    ->drupalPost('group-a/node/1/features/features_test', array(), 'Save for Group A');
  $this
    ->assertText('The configuration options have been saved for Group A.');
  $this
    ->drupalGet('group-a/node/1/features/overrides');
  $this
    ->assertRaw('features_test_setting');
  $this
    ->assertEqual('0', unserialize(db_query('SELECT value FROM {spaces_overrides} WHERE object_id = :object_id AND id = :id', array(
    ':object_id' => "features_test_setting",
    ':id' => 1,
  ))
    ->fetchField()));

  // Change feature setting, verify again.
  $this
    ->drupalPost('group-a/node/1/features/features_test', array(
    'features_test_setting' => 1,
  ), 'Save for Group A');
  $this
    ->drupalGet('group-a/node/1/features/overrides');
  $this
    ->assertRaw('features_test_setting');
  $this
    ->assertEqual('1', unserialize(db_query('SELECT value FROM {spaces_overrides} WHERE object_id = :object_id AND id = :id', array(
    ':object_id' => "features_test_setting",
    ':id' => 1,
  ))
    ->fetchField()));

  // Go to admin/build/spaces page and verify that there are no overridden
  // presets. Then save the modified features_test_setting setting to preset
  // and check for this change on admin page.
  $this
    ->drupalGet('admin/structure/spaces');
  $this
    ->assertNoText('Overridden');
  $this
    ->drupalGet('admin/structure/spaces/og_public');
  $this
    ->assertNoText('features_test_setting');
  $edit = array(
    'variable[features_test_setting]' => 1,
  );
  $this
    ->drupalPost('group-a/node/1/features/overrides', $edit, 'Save to preset');
  $this
    ->assertText('Saved preset Public group.');
  $preset = unserialize(db_query('SELECT value FROM {spaces_presets} WHERE name = :name AND space_type = :space_type', array(
    ':name' => "og_public",
    ':space_type' => "og",
  ))
    ->fetchField());
  $this
    ->assertEqual('1', $preset['variable']['features_test_setting']);
  $this
    ->drupalGet('admin/structure/spaces');
  $this
    ->assertText('Overridden');
  $this
    ->drupalGet('admin/structure/spaces/list/og_public/edit');
  $this
    ->assertPattern('/features_test_setting(.*?)1/');
}