You are here

function SpacesOGTestFeatures::testFeatures in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 spaces_og/tests/spaces_og.test \SpacesOGTestFeatures::testFeatures()
  2. 7 spaces_og/tests/spaces_og.test \SpacesOGTestFeatures::testFeatures()

Test Feature enable/disable.

File

spaces_og/tests/spaces_og.test, line 354

Class

SpacesOGTestFeatures

Code

function testFeatures() {

  // Verify that feature is off site-wide and off for group. node/add/features-test
  // should not be available.
  $this
    ->drupalGet('features');
  $elems = $this
    ->xpath('//select[@name="spaces_features[features_test]"]/option[@selected="selected"]');
  $this
    ->assert('Disabled' == (string) $elems[0]);
  $this
    ->drupalGet('node/add');
  $this
    ->assertNoText('Features test');
  $this
    ->drupalGet('node/add/features-test');
  $this
    ->assertResponse(403);
  $this
    ->drupalGet('group-a/node/1/features');
  $elems = $this
    ->xpath('//select[@name="spaces_features[features_test]"]/option[@selected="selected"]');
  $this
    ->assert('Disabled' == (string) $elems[0]);
  $this
    ->drupalGet('group-a/node/add');
  $this
    ->assertNoText('Features test');
  $this
    ->drupalGet('group-a/node/add/features-test');
  $this
    ->assertResponse(403);

  // Enable features_test feature for site wide space, post a node.
  // features_test feature should still not be available in group.
  // @todo: this *should* not work as this post is an in-group content type.
  // 'group-a/features' will redirect us to 'features'.
  $this
    ->drupalPost('group-a/features', array(
    'spaces_features[features_test]' => '1',
  ), 'Save configuration');
  $this
    ->assertText('The configuration options have been saved.');
  $this
    ->drupalGet('node/add');
  $this
    ->assertText('Testing: Features');
  $this
    ->drupalPost('node/add/features-test', array(
    'title' => 'Post outside of Group',
  ), 'Save');
  $this
    ->assertText('Testing: Features Post outside of Group has been created.');

  // Turn off site wide features_test feature.
  $this
    ->drupalPost('features', array(
    'spaces_features[features_test]' => '0',
  ), 'Save configuration');
  $this
    ->drupalGet('group-a/node/1/features');
  $elems = $this
    ->xpath('//select[@name="spaces_features[features_test]"]/option[@selected="selected"]');
  $this
    ->assert('Disabled' == (string) $elems[0]);
  $this
    ->drupalGet('node/add/features-test');
  $this
    ->assertResponse(403);

  // Turn on features_test feature for group and post a features_test post.
  $this
    ->drupalPost('group-a/node/1/features', array(
    'spaces_features[features_test]' => '1',
  ), 'Save for Group A');
  $elems = $this
    ->xpath('//select[@name="spaces_features[features_test]"]/option[@selected="selected"]');
  $this
    ->assert('Enabled' == (string) $elems[0]);
  $this
    ->drupalGet('group-a/node/add');
  $this
    ->assertText('Testing: Features');
  $this
    ->drupalPost('group-a/node/add/features-test', array(
    'title' => 'Post in Group space',
  ), 'Save');
  $this
    ->assertText('Testing: Features Post in Group space has been created.');
  $this
    ->drupalGet('node/add/features-test');
  $this
    ->assertResponse(403);
}