You are here

function SpacesOGTestOverrides::testOverrides in Spaces 6.3

Same name and namespace in other branches
  1. 7.3 spaces_og/tests/spaces_og.test \SpacesOGTestOverrides::testOverrides()
  2. 7 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_result(db_query('SELECT value FROM {spaces_overrides} WHERE object_id = "features_test_setting" AND id = 1'))));

  // 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_result(db_query('SELECT value FROM {spaces_overrides} WHERE object_id = "features_test_setting" AND id = 1'))));

  // 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/build/spaces');
  $this
    ->assertNoText('Overridden');
  $this
    ->drupalGet('admin/build/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_result(db_query('SELECT value FROM {spaces_presets} WHERE name = "og_public" AND space_type = "og"')));
  $this
    ->assertEqual('1', $preset['variable']['features_test_setting']);
  $this
    ->drupalGet('admin/build/spaces');
  $this
    ->assertText('Overridden');
  $this
    ->drupalGet('admin/build/spaces/list/og_public/edit');
  $this
    ->assertPattern('/features_test_setting(.*?)1/');
}