Commit f9c1ff23 authored by alexpott's avatar alexpott

Issue #2314123 by sun: Fixed various tests.

parent 1d1ff757
...@@ -32,6 +32,8 @@ class BlockConfigSchemaTest extends KernelTestBase { ...@@ -32,6 +32,8 @@ class BlockConfigSchemaTest extends KernelTestBase {
'forum', 'forum',
'node', 'node',
'statistics', 'statistics',
// BlockManager->getModuleName() calls system_get_info().
'system',
'taxonomy', 'taxonomy',
); );
......
...@@ -22,7 +22,7 @@ class CKEditorPluginManagerTest extends DrupalUnitTestBase { ...@@ -22,7 +22,7 @@ class CKEditorPluginManagerTest extends DrupalUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('system', 'editor', 'ckeditor'); public static $modules = array('system', 'user', 'filter', 'editor', 'ckeditor');
/** /**
* The manager for "CKEditor plugin" plugins. * The manager for "CKEditor plugin" plugins.
...@@ -36,7 +36,6 @@ function setUp() { ...@@ -36,7 +36,6 @@ function setUp() {
// Install the Filter module. // Install the Filter module.
$this->installSchema('system', 'url_alias'); $this->installSchema('system', 'url_alias');
$this->enableModules(array('user', 'filter'));
// Create text format, associate CKEditor. // Create text format, associate CKEditor.
$filtered_html_format = entity_create('filter_format', array( $filtered_html_format = entity_create('filter_format', array(
......
...@@ -23,7 +23,7 @@ class CKEditorTest extends DrupalUnitTestBase { ...@@ -23,7 +23,7 @@ class CKEditorTest extends DrupalUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('system', 'editor', 'ckeditor', 'filter_test'); public static $modules = array('system', 'user', 'filter', 'editor', 'ckeditor', 'filter_test');
/** /**
* An instance of the "CKEditor" text editor plugin. * An instance of the "CKEditor" text editor plugin.
...@@ -44,7 +44,6 @@ function setUp() { ...@@ -44,7 +44,6 @@ function setUp() {
// Install the Filter module. // Install the Filter module.
$this->installSchema('system', 'url_alias'); $this->installSchema('system', 'url_alias');
$this->enableModules(array('user', 'filter'));
// Create text format, associate CKEditor. // Create text format, associate CKEditor.
$filtered_html_format = entity_create('filter_format', array( $filtered_html_format = entity_create('filter_format', array(
......
...@@ -24,7 +24,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityUnitTestBase { ...@@ -24,7 +24,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('entity_test', 'comment', 'menu_link'); public static $modules = array('entity_test', 'comment');
/** /**
* {@inheritdoc} * {@inheritdoc}
......
...@@ -29,6 +29,8 @@ class CommentStringIdEntitiesTest extends KernelTestBase { ...@@ -29,6 +29,8 @@ class CommentStringIdEntitiesTest extends KernelTestBase {
'field_ui', 'field_ui',
'entity', 'entity',
'entity_test', 'entity_test',
// EMAIL_MAX_LENGTH constant.
'system',
'text', 'text',
); );
......
...@@ -71,6 +71,9 @@ public function testStorageMethods() { ...@@ -71,6 +71,9 @@ public function testStorageMethods() {
// Ensure that the configuration entity can be loaded by UUID. // Ensure that the configuration entity can be loaded by UUID.
$entity_loaded_by_uuid = entity_load_by_uuid($entity_type->id(), $entity->uuid()); $entity_loaded_by_uuid = entity_load_by_uuid($entity_type->id(), $entity->uuid());
if (!$entity_loaded_by_uuid) {
$this->fail(sprintf("Failed to load '%s' entity ID '%s' by UUID '%s'.", $entity_type->id(), $entity->id(), $entity->uuid()));
}
// Compare UUIDs as the objects are not identical since // Compare UUIDs as the objects are not identical since
// $entity->enforceIsNew is FALSE and $entity_loaded_by_uuid->enforceIsNew // $entity->enforceIsNew is FALSE and $entity_loaded_by_uuid->enforceIsNew
// is NULL. // is NULL.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use Drupal\Core\Config\CachedStorage; use Drupal\Core\Config\CachedStorage;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/** /**
* Tests CachedStorage operations. * Tests CachedStorage operations.
...@@ -89,7 +90,7 @@ public function containerBuild(ContainerBuilder $container) { ...@@ -89,7 +90,7 @@ public function containerBuild(ContainerBuilder $container) {
parent::containerBuild($container); parent::containerBuild($container);
// Use the regular database cache backend to aid testing. // Use the regular database cache backend to aid testing.
$container->register('cache_factory', 'Drupal\Core\Cache\DatabaseBackendFactory') $container->register('cache_factory', 'Drupal\Core\Cache\DatabaseBackendFactory')
->addArgument(Database::getConnection()); ->addArgument(new Reference('database'));
} }
} }
...@@ -28,6 +28,11 @@ abstract class ConfigStorageTestBase extends DrupalUnitTestBase { ...@@ -28,6 +28,11 @@ abstract class ConfigStorageTestBase extends DrupalUnitTestBase {
*/ */
protected $storage; protected $storage;
/**
* @var \Drupal\Core\Config\StorageInterface;
*/
protected $invalidStorage;
/** /**
* Tests storage CRUD operations. * Tests storage CRUD operations.
* *
......
...@@ -46,7 +46,7 @@ protected function delete($name) { ...@@ -46,7 +46,7 @@ protected function delete($name) {
/** /**
* Tests the FileStorage::listAll method with a relative and absolute path. * Tests the FileStorage::listAll method with a relative and absolute path.
*/ */
protected function testlistAll() { public function testlistAll() {
$expected_files = array( $expected_files = array(
'core.extension', 'core.extension',
'system.performance', 'system.performance',
......
...@@ -32,7 +32,7 @@ class ViewsIntegrationTest extends ViewUnitTestBase { ...@@ -32,7 +32,7 @@ class ViewsIntegrationTest extends ViewUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('dblog_test_views'); public static $modules = array('dblog', 'dblog_test_views');
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -40,7 +40,6 @@ class ViewsIntegrationTest extends ViewUnitTestBase { ...@@ -40,7 +40,6 @@ class ViewsIntegrationTest extends ViewUnitTestBase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->enableModules(array('system', 'dblog'));
$this->installSchema('dblog', array('watchdog')); $this->installSchema('dblog', array('watchdog'));
ViewTestData::createTestViews(get_class($this), array('dblog_test_views')); ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
......
...@@ -22,7 +22,7 @@ class EditorManagerTest extends DrupalUnitTestBase { ...@@ -22,7 +22,7 @@ class EditorManagerTest extends DrupalUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('system', 'editor'); public static $modules = array('system', 'user', 'filter', 'editor');
/** /**
* The manager for text editor plugins. * The manager for text editor plugins.
...@@ -36,7 +36,6 @@ public function setUp() { ...@@ -36,7 +36,6 @@ public function setUp() {
// Install the Filter module. // Install the Filter module.
$this->installSchema('system', 'url_alias'); $this->installSchema('system', 'url_alias');
$this->enableModules(array('user', 'filter'));
// Add text formats. // Add text formats.
$filtered_html_format = entity_create('filter_format', array( $filtered_html_format = entity_create('filter_format', array(
......
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
*/ */
class QuickEditIntegrationTest extends QuickEditTestBase { class QuickEditIntegrationTest extends QuickEditTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('editor', 'editor_test');
/** /**
* The manager for editor plug-ins. * The manager for editor plug-ins.
* *
...@@ -65,9 +70,6 @@ public function setUp() { ...@@ -65,9 +70,6 @@ public function setUp() {
// Install the Filter module. // Install the Filter module.
$this->installSchema('system', 'url_alias'); $this->installSchema('system', 'url_alias');
// Enable the Text Editor and Text Editor Test module.
$this->enableModules(array('editor', 'editor_test'));
// Create a field. // Create a field.
$this->field_name = 'field_textarea'; $this->field_name = 'field_textarea';
$this->createFieldWithInstance( $this->createFieldWithInstance(
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*/ */
class EntityDisplayTest extends DrupalUnitTestBase { class EntityDisplayTest extends DrupalUnitTestBase {
public static $modules = array('entity', 'field', 'entity_test', 'user', 'text', 'entity_test'); public static $modules = array('entity', 'field', 'entity_test', 'user', 'text', 'field_test', 'node', 'system');
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
...@@ -137,8 +137,6 @@ public function testExtraFieldComponent() { ...@@ -137,8 +137,6 @@ public function testExtraFieldComponent() {
* Tests the behavior of a field component within an entity display object. * Tests the behavior of a field component within an entity display object.
*/ */
public function testFieldComponent() { public function testFieldComponent() {
$this->enableModules(array('field_test'));
$field_name = 'test_field'; $field_name = 'test_field';
// Create a field storage and an instance. // Create a field storage and an instance.
$field_storage = entity_create('field_storage_config', array( $field_storage = entity_create('field_storage_config', array(
...@@ -264,7 +262,6 @@ public function testBaseFieldComponent() { ...@@ -264,7 +262,6 @@ public function testBaseFieldComponent() {
* Tests renaming and deleting a bundle. * Tests renaming and deleting a bundle.
*/ */
public function testRenameDeleteBundle() { public function testRenameDeleteBundle() {
$this->enableModules(array('field_test', 'node', 'system', 'text'));
$this->installEntitySchema('node'); $this->installEntitySchema('node');
// Create a node bundle, display and form display object. // Create a node bundle, display and form display object.
...@@ -314,8 +311,6 @@ public function testRenameDeleteBundle() { ...@@ -314,8 +311,6 @@ public function testRenameDeleteBundle() {
* Tests deleting field instance. * Tests deleting field instance.
*/ */
public function testDeleteFieldInstance() { public function testDeleteFieldInstance() {
$this->enableModules(array('field_test'));
$field_name = 'test_field'; $field_name = 'test_field';
// Create a field storage and an instance. // Create a field storage and an instance.
$field_storage = entity_create('field_storage_config', array( $field_storage = entity_create('field_storage_config', array(
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*/ */
class EntityFormDisplayTest extends DrupalUnitTestBase { class EntityFormDisplayTest extends DrupalUnitTestBase {
public static $modules = array('entity', 'field', 'entity_test', 'user', 'text'); public static $modules = array('entity', 'field', 'entity_test', 'field_test', 'user', 'text');
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
...@@ -47,8 +47,6 @@ public function testEntityGetFromDisplay() { ...@@ -47,8 +47,6 @@ public function testEntityGetFromDisplay() {
* Tests the behavior of a field component within an EntityFormDisplay object. * Tests the behavior of a field component within an EntityFormDisplay object.
*/ */
public function testFieldComponent() { public function testFieldComponent() {
$this->enableModules(array('field_test'));
// Create a field storage and an instance. // Create a field storage and an instance.
$field_name = 'test_field'; $field_name = 'test_field';
$field_storage = entity_create('field_storage_config', array( $field_storage = entity_create('field_storage_config', array(
...@@ -177,8 +175,6 @@ public function testBaseFieldComponent() { ...@@ -177,8 +175,6 @@ public function testBaseFieldComponent() {
* Tests deleting field instance. * Tests deleting field instance.
*/ */
public function testDeleteFieldInstance() { public function testDeleteFieldInstance() {
$this->enableModules(array('field_sql_storage', 'field_test'));
$field_name = 'test_field'; $field_name = 'test_field';
// Create a field storage and an instance. // Create a field storage and an instance.
$field_storage = entity_create('field_storage_config', array( $field_storage = entity_create('field_storage_config', array(
......
...@@ -18,13 +18,6 @@ ...@@ -18,13 +18,6 @@
*/ */
class EmailItemTest extends FieldUnitTestBase { class EmailItemTest extends FieldUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('email');
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -22,7 +22,7 @@ class FieldImportDeleteUninstallTest extends FieldUnitTestBase { ...@@ -22,7 +22,7 @@ class FieldImportDeleteUninstallTest extends FieldUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('telephone', 'menu_link'); public static $modules = array('telephone');
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -13,6 +13,17 @@ ...@@ -13,6 +13,17 @@
* @group file * @group file
*/ */
class ValidatorTest extends FileManagedUnitTestBase { class ValidatorTest extends FileManagedUnitTestBase {
/**
* @var \Drupal\file\Entity\File
*/
protected $image;
/**
* @var \Drupal\file\Entity\File
*/
protected $non_image;
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -33,7 +33,7 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase { ...@@ -33,7 +33,7 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('entity', 'entity_test', 'entity_reference', 'field', 'hal', 'language', 'rest', 'serialization', 'system', 'text', 'user', 'filter', 'menu_link'); public static $modules = array('entity', 'entity_test', 'entity_reference', 'field', 'hal', 'language', 'rest', 'serialization', 'system', 'text', 'user', 'filter');
/** /**
* The mock serializer. * The mock serializer.
......
...@@ -21,7 +21,7 @@ class NodeLastChangedTest extends DrupalUnitTestBase { ...@@ -21,7 +21,7 @@ class NodeLastChangedTest extends DrupalUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('entity', 'user', 'node', 'field', 'text', 'filter'); public static $modules = array('entity', 'user', 'node', 'field', 'system', 'text', 'filter');
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
*/ */
class MetadataGeneratorTest extends QuickEditTestBase { class MetadataGeneratorTest extends QuickEditTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('quickedit_test');
/** /**
* The manager for editor plugins. * The manager for editor plugins.
* *
...@@ -124,8 +129,6 @@ public function testSimpleEntityType() { ...@@ -124,8 +129,6 @@ public function testSimpleEntityType() {
public function testEditorWithCustomMetadata() { public function testEditorWithCustomMetadata() {
$this->installSchema('system', 'url_alias'); $this->installSchema('system', 'url_alias');
// Enable edit_test module so that the WYSIWYG editor becomes available.
$this->enableModules(array('quickedit_test'));
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor'); $this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter')); $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
......
...@@ -23,6 +23,21 @@ class CrudTest extends DrupalUnitTestBase { ...@@ -23,6 +23,21 @@ class CrudTest extends DrupalUnitTestBase {
*/ */
public static $modules = array('entity_test', 'rdf', 'system'); public static $modules = array('entity_test', 'rdf', 'system');
/**
* @var string
*/
protected $prefix;
/**
* @var string
*/
protected $entity_type;
/**
* @var string
*/
protected $bundle;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->prefix = 'rdf.mapping'; $this->prefix = 'rdf.mapping';
......
...@@ -23,7 +23,7 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase { ...@@ -23,7 +23,7 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static $modules = array('email', 'text'); public static $modules = array('text');
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -38,9 +38,9 @@ public function setUp() { ...@@ -38,9 +38,9 @@ public function setUp() {
))->save(); ))->save();
// Set up test values. // Set up test values.
$this->test_value = $this->randomMachineName(); $this->testValue = $this->randomMachineName();
$this->entity = entity_create('entity_test'); $this->entity = entity_create('entity_test');
$this->entity->{$this->fieldName}->value = $this->test_value; $this->entity->{$this->fieldName}->value = $this->testValue;
$this->entity->save(); $this->entity->save();
$this->uri = $this->getAbsoluteUri($this->entity); $this->uri = $this->getAbsoluteUri($this->entity);
...@@ -51,7 +51,7 @@ public function setUp() { ...@@ -51,7 +51,7 @@ public function setUp() {
*/ */
public function testDefaultFormatter() { public function testDefaultFormatter() {
// Expected value is the output of the datatype callback, not the raw value. // Expected value is the output of the datatype callback, not the raw value.
$this->assertFormatterRdfa(array('type'=>'text_default'), 'http://schema.org/interactionCount', array('value' => 'foo' . $this->test_value)); $this->assertFormatterRdfa(array('type'=>'text_default'), 'http://schema.org/interactionCount', array('value' => 'foo' . $this->testValue));
} }
} }
......
...@@ -50,7 +50,12 @@ abstract class FieldRdfaTestBase extends FieldUnitTestBase { ...@@ -50,7 +50,12 @@ abstract class FieldRdfaTestBase extends FieldUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('rdf', 'menu_link'); public static $modules = array('rdf');
/**
* @var string
*/
protected $testValue;
/** /**
* {@inheritdoc} * {@inheritdoc}
......
...@@ -24,7 +24,7 @@ class SystemMenuBlockTest extends DrupalUnitTestBase { ...@@ -24,7 +24,7 @@ class SystemMenuBlockTest extends DrupalUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('system', 'menu_link', 'block'); public static $modules = array('system', 'block');
/** /**
* Tests calculation of a system menu block's configuration dependencies. * Tests calculation of a system menu block's configuration dependencies.
......