Commit cc14b667 authored by webchick's avatar webchick

Issue #2381753 by tadityar, tibbsa, Mile23, cilefen: Clean-up Config module...

Issue #2381753 by tadityar, tibbsa, Mile23, cilefen: Clean-up Config module test members - ensure property definition and use of camelCase naming convention
parent 75f9fed6
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
*/ */
class ConfigEntityNormalizeTest extends KernelTestBase { class ConfigEntityNormalizeTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('config_test'); public static $modules = array('config_test');
protected function setUp() { protected function setUp() {
......
...@@ -30,6 +30,42 @@ class ConfigExportImportUITest extends WebTestBase { ...@@ -30,6 +30,42 @@ class ConfigExportImportUITest extends WebTestBase {
*/ */
protected $tarball; protected $tarball;
/**
* Holds the original 'site slogan' before testing.
*
* @var string
*/
protected $originalSlogan;
/**
* Holds a randomly generated new 'site slogan' for testing.
*
* @var string
*/
protected $newSlogan;
/**
* Holds a content type.
*
* @var \Drupal\node\NodeInterface
*/
protected $contentType;
/**
* Holds the randomly-generated name of a field.
*
* @var string
*/
protected $fieldName;
/**
* Holds the field storage entity for $fieldName.
*
* @var \Drupal\field\FieldStorageConfigInterface
*/
protected $fieldStorage;
/** /**
* Modules to enable. * Modules to enable.
* *
...@@ -62,7 +98,7 @@ public function testExportImport() { ...@@ -62,7 +98,7 @@ public function testExportImport() {
$this->assertEqual($this->config('system.site')->get('slogan'), $this->newSlogan); $this->assertEqual($this->config('system.site')->get('slogan'), $this->newSlogan);
// Create a content type. // Create a content type.
$this->content_type = $this->drupalCreateContentType(); $this->contentType = $this->drupalCreateContentType();
// Create a field. // Create a field.
$this->fieldName = Unicode::strtolower($this->randomMachineName()); $this->fieldName = Unicode::strtolower($this->randomMachineName());
...@@ -74,18 +110,18 @@ public function testExportImport() { ...@@ -74,18 +110,18 @@ public function testExportImport() {
$this->fieldStorage->save(); $this->fieldStorage->save();
entity_create('field_config', array( entity_create('field_config', array(
'field_storage' => $this->fieldStorage, 'field_storage' => $this->fieldStorage,
'bundle' => $this->content_type->type, 'bundle' => $this->contentType->type,
))->save(); ))->save();
entity_get_form_display('node', $this->content_type->type, 'default') entity_get_form_display('node', $this->contentType->type, 'default')
->setComponent($this->fieldName, array( ->setComponent($this->fieldName, array(
'type' => 'text_textfield', 'type' => 'text_textfield',
)) ))
->save(); ->save();
entity_get_display('node', $this->content_type->type, 'full') entity_get_display('node', $this->contentType->type, 'full')
->setComponent($this->fieldName) ->setComponent($this->fieldName)
->save(); ->save();
$this->drupalGet('node/add/' . $this->content_type->type); $this->drupalGet('node/add/' . $this->contentType->type);
$this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed'); $this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed');
// Export the configuration. // Export the configuration.
...@@ -110,7 +146,7 @@ public function testExportImport() { ...@@ -110,7 +146,7 @@ public function testExportImport() {
$field_storage->delete(); $field_storage->delete();
} }
} }
$this->drupalGet('node/add/' . $this->content_type->type); $this->drupalGet('node/add/' . $this->contentType->type);
$this->assertNoFieldByName("{$this->fieldName}[0][value]", '', 'Widget is not displayed'); $this->assertNoFieldByName("{$this->fieldName}[0][value]", '', 'Widget is not displayed');
// Import the configuration. // Import the configuration.
......
...@@ -20,6 +20,13 @@ class ConfigImportAllTest extends ModuleTestBase { ...@@ -20,6 +20,13 @@ class ConfigImportAllTest extends ModuleTestBase {
use SchemaCheckTestTrait; use SchemaCheckTestTrait;
/**
* A user with the 'synchronize configuration' permission.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
/** /**
* The profile to install as a basis for testing. * The profile to install as a basis for testing.
* *
...@@ -32,8 +39,8 @@ class ConfigImportAllTest extends ModuleTestBase { ...@@ -32,8 +39,8 @@ class ConfigImportAllTest extends ModuleTestBase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->web_user = $this->drupalCreateUser(array('synchronize configuration')); $this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
$this->drupalLogin($this->web_user); $this->drupalLogin($this->webUser);
} }
/** /**
......
...@@ -18,15 +18,25 @@ ...@@ -18,15 +18,25 @@
*/ */
class ConfigImportUITest extends WebTestBase { class ConfigImportUITest extends WebTestBase {
// Enable the Options and Text modules to ensure dependencies are handled /**
// correctly. * Modules to install.
*
* @var array
*/
public static $modules = array('config', 'config_test', 'config_import_test', 'text', 'options'); public static $modules = array('config', 'config_test', 'config_import_test', 'text', 'options');
/**
* A user with the 'synchronize configuration' permission.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->web_user = $this->drupalCreateUser(array('synchronize configuration')); $this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
$this->drupalLogin($this->web_user); $this->drupalLogin($this->webUser);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging')); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
} }
......
...@@ -16,13 +16,25 @@ ...@@ -16,13 +16,25 @@
*/ */
class ConfigImportUploadTest extends WebTestBase { class ConfigImportUploadTest extends WebTestBase {
/**
* A user with the 'import configuration' permission.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('config'); public static $modules = array('config');
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->web_user = $this->drupalCreateUser(array('import configuration')); $this->webUser = $this->drupalCreateUser(array('import configuration'));
$this->drupalLogin($this->web_user); $this->drupalLogin($this->webUser);
} }
/** /**
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
*/ */
class ConfigInstallTest extends KernelTestBase { class ConfigInstallTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
* @group config * @group config
*/ */
class ConfigInstallWebTest extends WebTestBase { class ConfigInstallWebTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -24,6 +24,9 @@ class ConfigLanguageOverrideTest extends KernelTestBase { ...@@ -24,6 +24,9 @@ class ConfigLanguageOverrideTest extends KernelTestBase {
*/ */
public static $modules = array('user', 'language', 'config_test', 'system', 'field'); public static $modules = array('user', 'language', 'config_test', 'system', 'field');
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->installConfig(array('config_test')); $this->installConfig(array('config_test'));
......
...@@ -18,8 +18,16 @@ ...@@ -18,8 +18,16 @@
*/ */
class ConfigLanguageOverrideWebTest extends WebTestBase { class ConfigLanguageOverrideWebTest extends WebTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('language', 'system'); public static $modules = array('language', 'system');
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
} }
......
...@@ -16,6 +16,11 @@ ...@@ -16,6 +16,11 @@
*/ */
class ConfigModuleOverridesTest extends KernelTestBase { class ConfigModuleOverridesTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('system', 'config', 'config_override_test'); public static $modules = array('system', 'config', 'config_override_test');
public function testSimpleModuleOverrides() { public function testSimpleModuleOverrides() {
......
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
*/ */
class ConfigOverridesPriorityTest extends KernelTestBase { class ConfigOverridesPriorityTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('system', 'config', 'config_override_test', 'language'); public static $modules = array('system', 'config', 'config_override_test', 'language');
public function testOverridePriorities() { public function testOverridePriorities() {
......
...@@ -27,6 +27,9 @@ class ConfigSchemaTest extends KernelTestBase { ...@@ -27,6 +27,9 @@ class ConfigSchemaTest extends KernelTestBase {
*/ */
public static $modules = array('system', 'language', 'locale', 'field', 'image', 'config_schema_test'); public static $modules = array('system', 'language', 'locale', 'field', 'image', 'config_schema_test');
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->installConfig(array('system', 'image', 'config_schema_test')); $this->installConfig(array('system', 'image', 'config_schema_test'));
......
...@@ -24,6 +24,9 @@ class ConfigSnapshotTest extends KernelTestBase { ...@@ -24,6 +24,9 @@ class ConfigSnapshotTest extends KernelTestBase {
*/ */
public static $modules = array('config_test', 'system'); public static $modules = array('config_test', 'system');
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
// Update the config snapshot. This allows the parent::setUp() to write // Update the config snapshot. This allows the parent::setUp() to write
......
...@@ -32,12 +32,12 @@ class CachedStorageTest extends ConfigStorageTestBase { ...@@ -32,12 +32,12 @@ class CachedStorageTest extends ConfigStorageTestBase {
* *
* @var \Drupal\Core\Config\FileStorage * @var \Drupal\Core\Config\FileStorage
*/ */
protected $filestorage; protected $fileStorage;
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->filestorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]); $this->fileStorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
$this->storage = new CachedStorage($this->filestorage, \Drupal::service('cache.config')); $this->storage = new CachedStorage($this->fileStorage, \Drupal::service('cache.config'));
$this->cache = \Drupal::service('cache_factory')->get('config'); $this->cache = \Drupal::service('cache_factory')->get('config');
// ::listAll() verifications require other configuration data to exist. // ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', array()); $this->storage->write('system.performance', array());
...@@ -56,14 +56,14 @@ public function testInvalidStorage() { ...@@ -56,14 +56,14 @@ public function testInvalidStorage() {
protected function read($name) { protected function read($name) {
$data = $this->cache->get($name); $data = $this->cache->get($name);
// Cache misses fall through to the underlying storage. // Cache misses fall through to the underlying storage.
return $data ? $data->data : $this->filestorage->read($name); return $data ? $data->data : $this->fileStorage->read($name);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function insert($name, $data) { protected function insert($name, $data) {
$this->filestorage->write($name, $data); $this->fileStorage->write($name, $data);
$this->cache->set($name, $data); $this->cache->set($name, $data);
} }
...@@ -71,7 +71,7 @@ protected function insert($name, $data) { ...@@ -71,7 +71,7 @@ protected function insert($name, $data) {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function update($name, $data) { protected function update($name, $data) {
$this->filestorage->write($name, $data); $this->fileStorage->write($name, $data);
$this->cache->set($name, $data); $this->cache->set($name, $data);
} }
...@@ -80,7 +80,7 @@ protected function update($name, $data) { ...@@ -80,7 +80,7 @@ protected function update($name, $data) {
*/ */
protected function delete($name) { protected function delete($name) {
$this->cache->delete($name); $this->cache->delete($name);
unlink($this->filestorage->getFilePath($name)); unlink($this->fileStorage->getFilePath($name));
} }
/** /**
......
...@@ -15,21 +15,21 @@ ...@@ -15,21 +15,21 @@
* All configuration storages are expected to behave identically in * All configuration storages are expected to behave identically in
* terms of reading, writing, listing, deleting, as well as error handling. * terms of reading, writing, listing, deleting, as well as error handling.
* *
* Therefore, storage tests use a uncommon test case class structure; * Therefore, storage tests use an uncommon test case class structure;
* the base class defines the test method(s) to execute, which are identical for * the base class defines the test method(s) to execute, which are identical
* all storages. The storage specific test case classes * for all storages. The storage specific test case classes supply the
* supply the necessary helper methods to interact with the raw/native storage * necessary helper methods to interact with the raw/native storage
* directly. * directly.
*/ */
abstract class ConfigStorageTestBase extends KernelTestBase { abstract class ConfigStorageTestBase extends KernelTestBase {
/** /**
* @var \Drupal\Core\Config\StorageInterface; * @var \Drupal\Core\Config\StorageInterface
*/ */
protected $storage; protected $storage;
/** /**
* @var \Drupal\Core\Config\StorageInterface; * @var \Drupal\Core\Config\StorageInterface
*/ */
protected $invalidStorage; protected $invalidStorage;
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
* @group config * @group config
*/ */
class DatabaseStorageTest extends ConfigStorageTestBase { class DatabaseStorageTest extends ConfigStorageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
* @group config * @group config
*/ */
class FileStorageTest extends ConfigStorageTestBase { class FileStorageTest extends ConfigStorageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->storage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]); $this->storage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment