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 @@
*/
class ConfigEntityNormalizeTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('config_test');
protected function setUp() {
......
......@@ -30,6 +30,42 @@ class ConfigExportImportUITest extends WebTestBase {
*/
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.
*
......@@ -62,7 +98,7 @@ public function testExportImport() {
$this->assertEqual($this->config('system.site')->get('slogan'), $this->newSlogan);
// Create a content type.
$this->content_type = $this->drupalCreateContentType();
$this->contentType = $this->drupalCreateContentType();
// Create a field.
$this->fieldName = Unicode::strtolower($this->randomMachineName());
......@@ -74,18 +110,18 @@ public function testExportImport() {
$this->fieldStorage->save();
entity_create('field_config', array(
'field_storage' => $this->fieldStorage,
'bundle' => $this->content_type->type,
'bundle' => $this->contentType->type,
))->save();
entity_get_form_display('node', $this->content_type->type, 'default')
entity_get_form_display('node', $this->contentType->type, 'default')
->setComponent($this->fieldName, array(
'type' => 'text_textfield',
))
->save();
entity_get_display('node', $this->content_type->type, 'full')
entity_get_display('node', $this->contentType->type, 'full')
->setComponent($this->fieldName)
->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');
// Export the configuration.
......@@ -110,7 +146,7 @@ public function testExportImport() {
$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');
// Import the configuration.
......
......@@ -20,6 +20,13 @@ class ConfigImportAllTest extends ModuleTestBase {
use SchemaCheckTestTrait;
/**
* A user with the 'synchronize configuration' permission.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
/**
* The profile to install as a basis for testing.
*
......@@ -32,8 +39,8 @@ class ConfigImportAllTest extends ModuleTestBase {
protected function setUp() {
parent::setUp();
$this->web_user = $this->drupalCreateUser(array('synchronize configuration'));
$this->drupalLogin($this->web_user);
$this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
$this->drupalLogin($this->webUser);
}
/**
......
......@@ -18,15 +18,25 @@
*/
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');
/**
* A user with the 'synchronize configuration' permission.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
protected function setUp() {
parent::setUp();
$this->web_user = $this->drupalCreateUser(array('synchronize configuration'));
$this->drupalLogin($this->web_user);
$this->webUser = $this->drupalCreateUser(array('synchronize configuration'));
$this->drupalLogin($this->webUser);
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
}
......
......@@ -16,13 +16,25 @@
*/
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');
protected function setUp() {
parent::setUp();
$this->web_user = $this->drupalCreateUser(array('import configuration'));
$this->drupalLogin($this->web_user);
$this->webUser = $this->drupalCreateUser(array('import configuration'));
$this->drupalLogin($this->webUser);
}
/**
......
......@@ -17,6 +17,9 @@
*/
class ConfigInstallTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
......
......@@ -18,6 +18,10 @@
* @group config
*/
class ConfigInstallWebTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
......
......@@ -24,6 +24,9 @@ class ConfigLanguageOverrideTest extends KernelTestBase {
*/
public static $modules = array('user', 'language', 'config_test', 'system', 'field');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(array('config_test'));
......
......@@ -18,8 +18,16 @@
*/
class ConfigLanguageOverrideWebTest extends WebTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('language', 'system');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
}
......
......@@ -16,6 +16,11 @@
*/
class ConfigModuleOverridesTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('system', 'config', 'config_override_test');
public function testSimpleModuleOverrides() {
......
......@@ -18,6 +18,11 @@
*/
class ConfigOverridesPriorityTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('system', 'config', 'config_override_test', 'language');
public function testOverridePriorities() {
......
......@@ -27,6 +27,9 @@ class ConfigSchemaTest extends KernelTestBase {
*/
public static $modules = array('system', 'language', 'locale', 'field', 'image', 'config_schema_test');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(array('system', 'image', 'config_schema_test'));
......
......@@ -24,6 +24,9 @@ class ConfigSnapshotTest extends KernelTestBase {
*/
public static $modules = array('config_test', 'system');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Update the config snapshot. This allows the parent::setUp() to write
......
......@@ -32,12 +32,12 @@ class CachedStorageTest extends ConfigStorageTestBase {
*
* @var \Drupal\Core\Config\FileStorage
*/
protected $filestorage;
protected $fileStorage;
protected function setUp() {
parent::setUp();
$this->filestorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
$this->storage = new CachedStorage($this->filestorage, \Drupal::service('cache.config'));
$this->fileStorage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]);
$this->storage = new CachedStorage($this->fileStorage, \Drupal::service('cache.config'));
$this->cache = \Drupal::service('cache_factory')->get('config');
// ::listAll() verifications require other configuration data to exist.
$this->storage->write('system.performance', array());
......@@ -56,14 +56,14 @@ public function testInvalidStorage() {
protected function read($name) {
$data = $this->cache->get($name);
// 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}
*/
protected function insert($name, $data) {
$this->filestorage->write($name, $data);
$this->fileStorage->write($name, $data);
$this->cache->set($name, $data);
}
......@@ -71,7 +71,7 @@ protected function insert($name, $data) {
* {@inheritdoc}
*/
protected function update($name, $data) {
$this->filestorage->write($name, $data);
$this->fileStorage->write($name, $data);
$this->cache->set($name, $data);
}
......@@ -80,7 +80,7 @@ protected function update($name, $data) {
*/
protected function delete($name) {
$this->cache->delete($name);
unlink($this->filestorage->getFilePath($name));
unlink($this->fileStorage->getFilePath($name));
}
/**
......
......@@ -15,21 +15,21 @@
* All configuration storages are expected to behave identically in
* terms of reading, writing, listing, deleting, as well as error handling.
*
* Therefore, storage tests use a uncommon test case class structure;
* the base class defines the test method(s) to execute, which are identical for
* all storages. The storage specific test case classes
* supply the necessary helper methods to interact with the raw/native storage
* Therefore, storage tests use an uncommon test case class structure;
* the base class defines the test method(s) to execute, which are identical
* for all storages. The storage specific test case classes supply the
* necessary helper methods to interact with the raw/native storage
* directly.
*/
abstract class ConfigStorageTestBase extends KernelTestBase {
/**
* @var \Drupal\Core\Config\StorageInterface;
* @var \Drupal\Core\Config\StorageInterface
*/
protected $storage;
/**
* @var \Drupal\Core\Config\StorageInterface;
* @var \Drupal\Core\Config\StorageInterface
*/
protected $invalidStorage;
......
......@@ -15,6 +15,10 @@
* @group config
*/
class DatabaseStorageTest extends ConfigStorageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
......
......@@ -16,6 +16,10 @@
* @group config
*/
class FileStorageTest extends ConfigStorageTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$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