You are here

public function ConfigurationActiveStoreOverriddenTest::testOverridden in Configuration Management 7

Tests that configurations get marked as overriden.

File

tests/configuration.test, line 243
Tests for Configuration Management

Class

ConfigurationActiveStoreOverriddenTest

Code

public function testOverridden() {
  $this
    ->trackConfigurations();

  // Test content types overrides.
  $edit = array();

  // Change the name of the content type.
  $edit['name'] = $this->type->type . ' Other name';
  $this
    ->drupalPost('admin/structure/types/manage/' . $this->type->type, $edit, t('Save content type'));
  $this
    ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden for content types'));
  $status = configuration_get_status('node', $this->type->type);
  $this
    ->assertEqual($status, CONFIGURATION_ACTIVESTORE_OVERRIDDEN);

  // Test content types back to default.
  $edit = array();

  // Back to the original name.
  $edit['name'] = $this->type->type;
  $this
    ->drupalPost('admin/structure/types/manage/' . $this->type->type, $edit, t('Save content type'));
  $this
    ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore overriden for content types'));
  $status = configuration_get_status('node', $this->type->type);
  $this
    ->assertEqual($status, CONFIGURATION_IN_SYNC);

  // Testing overridding a field.
  $edit = array();
  $edit["instance[widget][settings][rows]"] = 2;
  $this
    ->drupalPost('admin/structure/types/manage/' . $this->type->type . '/fields/body', $edit, t('Save settings'));
  $this
    ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden for Fields'));
  $status = configuration_get_status('field', 'node-' . $this->type->type . '-body');
  $this
    ->assertEqual($status, CONFIGURATION_ACTIVESTORE_OVERRIDDEN);

  // Testing putting the field back to default.
  $edit = array();
  $edit["instance[widget][settings][rows]"] = 20;
  $this
    ->drupalPost('admin/structure/types/manage/' . $this->type->type . '/fields/body', $edit, t('Save settings'));
  $this
    ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore in sync for Fields'));
  $status = configuration_get_status('field', 'node-' . $this->type->type . '-body');
  $this
    ->assertEqual($status, CONFIGURATION_IN_SYNC);

  // Testing overriding filters.
  $edit = array();
  $edit["filters[filter_url][settings][filter_url_length]"] = 20;
  $this
    ->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
  $this
    ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden for Filters'));
  $status = configuration_get_status('filter', 'filtered_html');
  $this
    ->assertEqual($status, CONFIGURATION_ACTIVESTORE_OVERRIDDEN);

  // Testing filters back to default.
  $edit = array();
  $edit["filters[filter_url][settings][filter_url_length]"] = 72;
  $this
    ->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
  $this
    ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore in sync for Filters'));
  $status = configuration_get_status('filter', 'filtered_html');
  $this
    ->assertEqual($status, CONFIGURATION_IN_SYNC);

  // Testing overriding filters.
  $edit = array();
  $edit["filters[filter_url][settings][filter_url_length]"] = 20;
  $this
    ->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
  $this
    ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden for Filters'));
  $status = configuration_get_status('filter', 'filtered_html');
  $this
    ->assertEqual($status, CONFIGURATION_ACTIVESTORE_OVERRIDDEN);

  // Testing filters back to default.
  $edit = array();
  $edit["filters[filter_url][settings][filter_url_length]"] = 72;
  $this
    ->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
  $this
    ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore in sync for Filters'));
  $status = configuration_get_status('filter', 'filtered_html');
  $this
    ->assertEqual($status, CONFIGURATION_IN_SYNC);

  // Testing overriden user permissions.
  $edit = array();
  $edit['2[access configuration management]'] = TRUE;
  $this
    ->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
  $this
    ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden for User Permissions'));
  $status = configuration_get_status('user_permission', 'access configuration management');
  $this
    ->assertEqual($status, CONFIGURATION_ACTIVESTORE_OVERRIDDEN);

  // Testing user permissions back to default.
  $edit = array();
  $edit['2[access configuration management]'] = FALSE;
  $this
    ->drupalPost('admin/people/permissions', $edit, t('Save permissions'));
  $this
    ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore in sync for User Permissions'));
  $status = configuration_get_status('user_permission', 'access configuration management');
  $this
    ->assertEqual($status, CONFIGURATION_IN_SYNC);

  // Testing overriden image styles.
  $edit = array();

  // First unlock the image style.
  $this
    ->drupalPost('admin/config/media/image-styles/edit/large', $edit, t('Override defaults'));
  $edit = array();
  $edit['data[width]'] = '400';
  $this
    ->drupalPost('admin/config/media/image-styles/edit/large/effects/1', $edit, t('Update effect'));
  $this
    ->assertRaw($this->configuration_needs_saving_text, t('Activestore overriden for Image Styles'));
  $status = configuration_get_status('image', 'large');
  $this
    ->assertEqual($status, CONFIGURATION_ACTIVESTORE_OVERRIDDEN);

  // Testing image styles back to default.
  $edit = array();
  $this
    ->drupalPost('admin/config/media/image-styles/revert/large', $edit, t('Revert'));
  $this
    ->assertNoRaw($this->configuration_needs_saving_text, t('Activestore in sync for Image Styles'));
  $status = configuration_get_status('image', 'large');
  $this
    ->assertEqual($status, CONFIGURATION_IN_SYNC);
}