Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
|
@ -153,7 +153,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
'bundle' => 'test_bundle',
|
||||
'field_type' => 'test_field',
|
||||
), $this->entityTypeId);
|
||||
$dependencies = $field->calculateDependencies();
|
||||
$dependencies = $field->calculateDependencies()->getDependencies();
|
||||
$this->assertContains('field.storage.test_entity_type.test_field', $dependencies['config']);
|
||||
$this->assertContains('test.test_entity_type.id', $dependencies['config']);
|
||||
$this->assertEquals(['test_module', 'test_module2', 'test_module3'], $dependencies['module']);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
namespace Drupal\Tests\field\Unit;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Field\FieldItemBase;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldTypePluginManagerInterface;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
|
|
@ -39,16 +42,25 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase {
|
|||
*/
|
||||
protected $uuid;
|
||||
|
||||
/**
|
||||
* The field type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Field\FieldTypePluginManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $fieldTypeManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
|
||||
$this->fieldTypeManager = $this->getMock(FieldTypePluginManagerInterface::class);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('entity.manager', $this->entityManager);
|
||||
$container->set('uuid', $this->uuid);
|
||||
$container->set('plugin.manager.field.field_type', $this->fieldTypeManager);
|
||||
\Drupal::setContainer($container);
|
||||
}
|
||||
|
||||
|
|
@ -73,29 +85,50 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase {
|
|||
// ConfigEntityBase::addDependency() to get the provider of the field config
|
||||
// entity type and once in FieldStorageConfig::calculateDependencies() to
|
||||
// get the provider of the entity type that field is attached to.
|
||||
$this->entityManager->expects($this->at(0))
|
||||
$this->entityManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with('field_storage_config')
|
||||
->will($this->returnValue($fieldStorageConfigentityType));
|
||||
$this->entityManager->expects($this->at(1))
|
||||
->method('getDefinition')
|
||||
->with($attached_entity_type_id)
|
||||
->will($this->returnValue($attached_entity_type));
|
||||
$this->entityManager->expects($this->at(2))
|
||||
->method('getDefinition')
|
||||
->with('field_storage_config')
|
||||
->will($this->returnValue($fieldStorageConfigentityType));
|
||||
->willReturnMap([
|
||||
['field_storage_config', TRUE, $fieldStorageConfigentityType],
|
||||
[$attached_entity_type_id, TRUE, $attached_entity_type],
|
||||
]);
|
||||
|
||||
$field_storage = new FieldStorageConfig(array(
|
||||
$this->fieldTypeManager->expects($this->atLeastOnce())
|
||||
->method('getDefinition')
|
||||
->with('test_field_type', FALSE)
|
||||
->willReturn([
|
||||
'class' => TestFieldType::class,
|
||||
]);
|
||||
|
||||
$field_storage = new FieldStorageConfig([
|
||||
'entity_type' => $attached_entity_type_id,
|
||||
'field_name' => 'test_field',
|
||||
'type' => 'test_field_type',
|
||||
'module' => 'test_module',
|
||||
));
|
||||
]);
|
||||
|
||||
$dependencies = $field_storage->calculateDependencies();
|
||||
$this->assertContains('test_module', $dependencies['module']);
|
||||
$this->assertContains('entity_provider_module', $dependencies['module']);
|
||||
$dependencies = $field_storage->calculateDependencies()->getDependencies();
|
||||
$this->assertEquals(['entity_provider_module', 'entity_test', 'test_module'], $dependencies['module']);
|
||||
$this->assertEquals(['stark'], $dependencies['theme']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A test class to test field storage dependencies.
|
||||
*
|
||||
* @see \Drupal\Core\Field\FieldItemInterface::calculateStorageDependencies()
|
||||
*/
|
||||
class TestFieldType {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function calculateStorageDependencies(FieldStorageDefinitionInterface $field_definition) {
|
||||
$dependencies = [];
|
||||
$dependencies['module'] = ['entity_test'];
|
||||
$dependencies['theme'] = ['stark'];
|
||||
|
||||
return $dependencies;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\Tests\field\Unit;
|
||||
|
||||
use Drupal\simpletest\AssertHelperTrait;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -15,6 +16,8 @@ use Drupal\Tests\UnitTestCase;
|
|||
*/
|
||||
class FieldUninstallValidatorTest extends UnitTestCase {
|
||||
|
||||
use AssertHelperTrait;
|
||||
|
||||
/**
|
||||
* @var \Drupal\field\FieldUninstallValidator|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
|
|
@ -43,7 +46,7 @@ class FieldUninstallValidatorTest extends UnitTestCase {
|
|||
$module = $this->randomMachineName();
|
||||
$expected = [];
|
||||
$reasons = $this->fieldUninstallValidator->validate($module);
|
||||
$this->assertSame($expected, $reasons);
|
||||
$this->assertSame($expected, $this->castSafeStrings($reasons));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +66,7 @@ class FieldUninstallValidatorTest extends UnitTestCase {
|
|||
$module = $this->randomMachineName();
|
||||
$expected = ['Fields pending deletion'];
|
||||
$reasons = $this->fieldUninstallValidator->validate($module);
|
||||
$this->assertSame($expected, $reasons);
|
||||
$this->assertSame($expected, $this->castSafeStrings($reasons));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -83,7 +86,7 @@ class FieldUninstallValidatorTest extends UnitTestCase {
|
|||
$module = $this->randomMachineName();
|
||||
$expected = ['Fields type(s) in use'];
|
||||
$reasons = $this->fieldUninstallValidator->validate($module);
|
||||
$this->assertSame($expected, $reasons);
|
||||
$this->assertSame($expected, $this->castSafeStrings($reasons));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d6\FieldInstancePerViewModeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\field\Plugin\migrate\source\d6\FieldInstancePerFormDisplay;
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests d6_field_instance_per_form_display source plugin.
|
||||
*
|
||||
* @group field
|
||||
*/
|
||||
class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = FieldInstancePerFormDisplay::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'view_mode_test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_field_instance_per_form_display',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'display_settings' => array(),
|
||||
'widget_settings' => array(),
|
||||
'type_name' => 'story',
|
||||
'widget_active' => TRUE,
|
||||
'field_name' => 'field_test_filefield',
|
||||
'type' => 'filefield',
|
||||
'module' => 'filefield',
|
||||
'weight' => '8',
|
||||
'widget_type' => 'filefield_widget',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$empty_array = serialize([]);
|
||||
|
||||
$this->databaseContents['content_node_field'] = array(
|
||||
array(
|
||||
'field_name' => 'field_test_filefield',
|
||||
'type' => 'filefield',
|
||||
'global_settings' => $empty_array,
|
||||
'required' => '0',
|
||||
'multiple' => '0',
|
||||
'db_storage' => '1',
|
||||
'module' => 'filefield',
|
||||
'db_columns' => $empty_array,
|
||||
'active' => '1',
|
||||
'locked' => '0',
|
||||
)
|
||||
);
|
||||
$this->databaseContents['content_node_field_instance'] = array(
|
||||
array(
|
||||
'field_name' => 'field_test_filefield',
|
||||
'type_name' => 'story',
|
||||
'weight' => '8',
|
||||
'label' => 'File Field',
|
||||
'widget_type' => 'filefield_widget',
|
||||
'widget_settings' => $empty_array,
|
||||
'display_settings' => $empty_array,
|
||||
'description' => 'An example image field.',
|
||||
'widget_module' => 'filefield',
|
||||
'widget_active' => '1',
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,13 +16,9 @@ use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
|||
*/
|
||||
class FieldInstancePerViewModeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'view_mode_test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_field_instance_per_view_mode',
|
||||
|
|
@ -76,7 +72,6 @@ class FieldInstancePerViewModeTest extends MigrateSqlSourceTestCase {
|
|||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ class FieldTest extends MigrateSqlSourceTestCase {
|
|||
$this->databaseContents['content_node_field'][0]['global_settings'] = serialize($this->databaseContents['content_node_field'][0]['global_settings']);
|
||||
$this->databaseContents['content_node_field'][0]['db_columns'] = serialize($this->databaseContents['content_node_field'][0]['db_columns']);
|
||||
|
||||
$this->databaseContents['content_node_field_instance'][0]['widget_settings'] = serialize(array());
|
||||
$this->databaseContents['content_node_field_instance'][0]['widget_type'] = 'text_textarea';
|
||||
$this->databaseContents['content_node_field_instance'][0]['field_name'] = 'field_body';
|
||||
parent::setUp();
|
||||
|
|
|
|||
Reference in a new issue