updated core

This commit is contained in:
Bachir Soussi Chiadmi
2018-01-24 13:36:32 +01:00
parent cd7dea45a9
commit f9374cf96d
1997 changed files with 5175 additions and 127715 deletions
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- text
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- entity_test
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- field
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -5,8 +5,8 @@ description: 'Support module for the Field API configuration tests.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- views
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -8,8 +8,8 @@ dependencies:
- entity_test
- field_test
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -197,9 +197,10 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
* An array of entity objects.
*/
protected function getTestEntities() {
$config_entity_1 = entity_create('config_test', ['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]);
$storage = \Drupal::entityTypeManager()->getStorage('config_test');
$config_entity_1 = $storage->create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]);
$config_entity_1->save();
$config_entity_2 = entity_create('config_test', ['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]);
$config_entity_2 = $storage->create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]);
$config_entity_2->save();
$content_entity_1 = EntityTest::create(['name' => $this->randomMachineName()]);
@@ -33,7 +33,7 @@ abstract class FieldTestBase extends BrowserTestBase {
*
* This function only checks a single column in the field values.
*
* @param EntityInterface $entity
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to test.
* @param $field_name
* The name of the field to test
@@ -3,11 +3,14 @@
namespace Drupal\Tests\field\Kernel\EntityReference;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\node\Entity\NodeType;
use Drupal\KernelTests\KernelTestBase;
use Drupal\taxonomy\Entity\Vocabulary;
use Symfony\Component\Debug\BufferingLogger;
/**
* Tests entity reference field settings.
@@ -44,6 +47,13 @@ class EntityReferenceSettingsTest extends KernelTestBase {
*/
protected $customBundle;
/**
* The service name for a logger implementation that collects anything logged.
*
* @var string
*/
protected $testLogServiceName = 'entity_reference_settings_test.logger';
/**
* {@inheritdoc}
*/
@@ -60,26 +70,38 @@ class EntityReferenceSettingsTest extends KernelTestBase {
]);
$this->nodeType->save();
$this->vocabulary = Vocabulary::create([
'vid' => Unicode::strtolower($this->randomMachineName()),
'name' => $this->randomString(),
]);
$this->vocabulary->save();
// Create a custom bundle.
$this->customBundle = 'test_bundle_' . Unicode::strtolower($this->randomMachineName());
entity_test_create_bundle($this->customBundle, NULL, 'entity_test');
// Prepare the logger for collecting the expected critical error.
$this->container->get($this->testLogServiceName)->cleanLogs();
}
/**
* Tests that config bundle deletions are mirrored in field config settings.
*/
public function testConfigTargetBundleDeletion() {
// Create two vocabularies.
/** @var \Drupal\taxonomy\Entity\Vocabulary[] $vocabularies */
$vocabularies = [];
for ($i = 0; $i < 2; $i++) {
$vid = Unicode::strtolower($this->randomMachineName());
$vocabularies[$i] = Vocabulary::create([
'name' => $this->randomString(),
'vid' => $vid,
]);
$vocabularies[$i]->save();
}
// Attach an entity reference field to $this->nodeType.
$name = Unicode::strtolower($this->randomMachineName());
$label = $this->randomString();
$vid = $this->vocabulary->id();
$handler_settings = ['target_bundles' => [$vid => $vid]];
$handler_settings = [
'target_bundles' => [
$vocabularies[0]->id() => $vocabularies[0]->id(),
$vocabularies[1]->id() => $vocabularies[1]->id(),
],
];
$this->createEntityReferenceField('node', $this->nodeType->id(), $name, $label, 'taxonomy_term', 'default', $handler_settings);
// Check that the 'target_bundle' setting contains the vocabulary.
@@ -88,13 +110,32 @@ class EntityReferenceSettingsTest extends KernelTestBase {
$this->assertEqual($handler_settings, $actual_handler_settings);
// Delete the vocabulary.
$this->vocabulary->delete();
$vocabularies[0]->delete();
// Ensure that noting is logged.
$this->assertEmpty($this->container->get($this->testLogServiceName)->cleanLogs());
// Check that the deleted vocabulary is no longer present in the
// 'target_bundles' field setting.
$field_config = FieldConfig::loadByName('node', $this->nodeType->id(), $name);
$handler_settings = $field_config->getSetting('handler_settings');
$this->assertTrue(empty($handler_settings['target_bundles']));
$this->assertEquals([$vocabularies[1]->id() => $vocabularies[1]->id()], $handler_settings['target_bundles']);
// Delete the other vocabulary.
$vocabularies[1]->delete();
// Ensure that field_field_config_presave() logs the expected critical
// error.
$log_message = $this->container->get($this->testLogServiceName)->cleanLogs()[0];
$this->assertEquals(RfcLogLevel::CRITICAL, $log_message[0]);
$this->assertEquals('The %field_name entity reference field (entity_type: %entity_type, bundle: %bundle) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.', $log_message[1]);
$this->assertEquals($field_config->getName(), $log_message[2]['%field_name']);
$this->assertEquals('node', $log_message[2]['%entity_type']);
$this->assertEquals($this->nodeType->id(), $log_message[2]['%bundle']);
// Check that the deleted bundle is no longer present in the
// 'target_bundles' field setting.
$field_config = FieldConfig::loadByName('node', $this->nodeType->id(), $name);
$handler_settings = $field_config->getSetting('handler_settings');
$this->assertEquals([], $handler_settings['target_bundles']);
}
/**
@@ -115,6 +156,15 @@ class EntityReferenceSettingsTest extends KernelTestBase {
// Delete the custom bundle.
entity_test_delete_bundle($this->customBundle, 'entity_test');
// Ensure that field_field_config_presave() logs the expected critical
// error.
$log_message = $this->container->get($this->testLogServiceName)->cleanLogs()[0];
$this->assertEquals(RfcLogLevel::CRITICAL, $log_message[0]);
$this->assertEquals('The %field_name entity reference field (entity_type: %entity_type, bundle: %bundle) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.', $log_message[1]);
$this->assertEquals($field_config->getName(), $log_message[2]['%field_name']);
$this->assertEquals('node', $log_message[2]['%entity_type']);
$this->assertEquals($this->nodeType->id(), $log_message[2]['%bundle']);
// Check that the deleted bundle is no longer present in the
// 'target_bundles' field setting.
$field_config = FieldConfig::loadByName('node', $this->nodeType->id(), $name);
@@ -122,4 +172,14 @@ class EntityReferenceSettingsTest extends KernelTestBase {
$this->assertTrue(empty($handler_settings['target_bundles']));
}
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
parent::register($container);
$container
->register($this->testLogServiceName, BufferingLogger::class)
->addTag('logger');
}
}
@@ -2,7 +2,13 @@
namespace Drupal\Tests\field\Kernel;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\KernelTests\KernelTestBase;
/**
@@ -21,22 +27,13 @@ class FieldDefinitionIntegrityTest extends KernelTestBase {
* Tests the integrity of field plugin definitions.
*/
public function testFieldPluginDefinitionIntegrity() {
// Enable all core modules that provide field plugins.
$modules = system_rebuild_module_data();
$modules = array_filter($modules, function (Extension $module) {
// Filter contrib, hidden, already enabled modules and modules in the
// Testing package.
if ($module->origin === 'core'
&& empty($module->info['hidden'])
&& $module->status == FALSE
&& $module->info['package'] !== 'Testing'
&& is_readable($module->getPath() . '/src/Plugin/Field')) {
return TRUE;
}
return FALSE;
});
$this->enableModules(array_keys($modules));
// Enable all core modules that provide field plugins, and their
// dependencies.
$this->enableModules(
$this->modulesWithSubdirectory(
'src' . DIRECTORY_SEPARATOR . 'Plugin' . DIRECTORY_SEPARATOR . 'Field'
)
);
/** @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface $field_type_manager */
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
@@ -108,7 +105,114 @@ class FieldDefinitionIntegrityTest extends KernelTestBase {
else {
$this->pass(sprintf('Field formatter %s integrates with existing field types.', $definition['id']));
}
}
}
/**
* Tests to load field plugin definitions used in core's existing entities.
*/
public function testFieldPluginDefinitionAvailability() {
$this->enableModules(
$this->modulesWithSubdirectory('src' . DIRECTORY_SEPARATOR . 'Entity')
);
/** @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface $field_type_manager */
$field_formatter_manager = $this->container->get('plugin.manager.field.formatter');
/** @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface $field_type_manager */
$field_widget_manager = $this->container->get('plugin.manager.field.widget');
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
$entity_field_manager = $this->container->get('entity_field.manager');
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $this->container->get('entity_type.manager');
/** @var \Drupal\Core\Field\BaseFieldDefinition[][] $field_definitions */
$field_definitions = [];
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $content_entity_types */
$content_entity_types = array_filter($entity_type_manager->getDefinitions(), function (EntityTypeInterface $entity_type) {
return $entity_type instanceof ContentEntityTypeInterface;
});
foreach ($content_entity_types as $entity_type_id => $entity_type_definition) {
$field_definitions[$entity_type_id] = $entity_field_manager->getBaseFieldDefinitions($entity_type_id);
}
foreach ($field_definitions as $entity_type_id => $definitions) {
foreach ($definitions as $field_id => $field_definition) {
$this->checkDisplayOption($entity_type_id, $field_id, $field_definition, $field_formatter_manager, 'view');
$this->checkDisplayOption($entity_type_id, $field_id, $field_definition, $field_widget_manager, 'form');
}
}
}
/**
* Helper method that tries to load plugin definitions.
*
* @param string $entity_type_id
* Id of entity type. Required by message.
* @param string $field_id
* Id of field. Required by message.
* @param \Drupal\Core\Field\BaseFieldDefinition $field_definition
* Field definition that provide display options.
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $plugin_manager
* Plugin manager that will try to provide plugin definition.
* @param string $display_context
* Defines which display options should be loaded.
*/
protected function checkDisplayOption($entity_type_id, $field_id, BaseFieldDefinition $field_definition, DiscoveryInterface $plugin_manager, $display_context) {
$display_options = $field_definition->getDisplayOptions($display_context);
if (!empty($display_options['type'])) {
try {
$plugin_manager->getDefinition($display_options['type']);
}
catch (PluginNotFoundException $e) {
$this->fail(sprintf(
'PluginNotFoundException here for "%s" field %s display options of "%s" entity type. Original message: %s',
$field_id,
$display_context,
$entity_type_id,
$e->getMessage()
));
}
}
}
/**
* Find modules with a specified subdirectory.
*
* @param string $subdirectory
* The required path, relative to the module directory.
*
* @return string[]
* A list of module names satisfying these criteria:
* - provided by core
* - not hidden
* - not already enabled
* - not in the Testing package
* - containing the required $subdirectory
* and all modules required by any of these modules.
*/
protected function modulesWithSubdirectory($subdirectory) {
$modules = system_rebuild_module_data();
$modules = array_filter($modules, function (Extension $module) use ($subdirectory) {
// Filter contrib, hidden, already enabled modules and modules in the
// Testing package.
return ($module->origin === 'core'
&& empty($module->info['hidden'])
&& $module->status == FALSE
&& $module->info['package'] !== 'Testing'
&& is_readable($module->getPath() . DIRECTORY_SEPARATOR . $subdirectory));
});
// Gather the dependencies of the modules.
$dependencies = NestedArray::mergeDeepArray(array_map(function (Extension $module) {
return array_keys($module->requires);
}, $modules));
return array_unique(NestedArray::mergeDeep(array_keys($modules), $dependencies));
}
}
@@ -172,7 +172,7 @@ abstract class FieldKernelTestBase extends KernelTestBase {
*
* This function only checks a single column in the field values.
*
* @param EntityInterface $entity
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to test.
* @param $field_name
* The name of the field to test
@@ -128,7 +128,6 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
$this->assertEntity('comment.comment_node_test_content_type.field_integer', 'Integer', 'integer', FALSE, FALSE);
$this->assertEntity('user.user.field_file', 'File', 'file', FALSE, FALSE);
$this->assertLinkFields('node.test_content_type.field_link', DRUPAL_OPTIONAL);
$this->assertLinkFields('node.article.field_link', DRUPAL_DISABLED);
$this->assertLinkFields('node.blog.field_link', DRUPAL_REQUIRED);
@@ -101,6 +101,8 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
$this->assertEntity('node.field_node_entityreference', 'entity_reference', TRUE, -1);
$this->assertEntity('node.field_user_entityreference', 'entity_reference', TRUE, 1);
$this->assertEntity('node.field_term_entityreference', 'entity_reference', TRUE, -1);
$this->assertEntity('node.field_date_without_time', 'datetime', TRUE, 1);
$this->assertEntity('node.field_datetime_without_time', 'datetime', TRUE, 1);
// Assert that the taxonomy term reference fields are referencing the
// correct entity type.
@@ -117,6 +119,18 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
$this->assertEquals('user', $field->getSetting('target_type'));
$field = FieldStorageConfig::load('node.field_term_entityreference');
$this->assertEquals('taxonomy_term', $field->getSetting('target_type'));
// Make sure that datetime fields get the right datetime_type setting
$field = FieldStorageConfig::load('node.field_date');
$this->assertEquals('datetime', $field->getSetting('datetime_type'));
$field = FieldStorageConfig::load('node.field_date_without_time');
$this->assertEquals('date', $field->getSetting('datetime_type'));
$field = FieldStorageConfig::load('node.field_datetime_without_time');
$this->assertEquals('date', $field->getSetting('datetime_type'));
// Except for field_date_with_end_time which is a timestamp and so does not
// have a datetime_type setting.
$field = FieldStorageConfig::load('node.field_date_with_end_time');
$this->assertNull($field->getSetting('datetime_type'));
}
/**
@@ -1,75 +0,0 @@
<?php
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();
}
}
@@ -1,96 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 fields per view mode source plugin.
*
* @group field
*/
class FieldInstancePerViewModeTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode';
protected $migrationConfiguration = array(
'id' => 'view_mode_test',
'source' => array(
'plugin' => 'd6_field_instance_per_view_mode',
),
);
protected $expectedResults = array(
array(
'entity_type' => 'node',
'view_mode' => 4,
'type_name' => 'article',
'field_name' => 'field_test',
'type' => 'text',
'module' => 'text',
'weight' => 1,
'label' => 'above',
'display_settings' => array(
'weight' => 1,
'parent' => '',
'label' => array(
'format' => 'above',
),
4 => array(
'format' => 'trimmed',
'exclude' => 0,
),
),
'widget_settings' => array(),
),
array(
'entity_type' => 'node',
'view_mode' => 'teaser',
'type_name' => 'story',
'field_name' => 'field_test',
'type' => 'text',
'module' => 'text',
'weight' => 2,
'label' => 'above',
'display_settings' => array(
'weight' => 1,
'parent' => '',
'label' => array(
'format' => 'above',
),
'teaser' => array(
'format' => 'trimmed',
'exclude' => 0,
),
),
'widget_settings' => array(),
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
foreach ($this->expectedResults as $k => $field_view_mode) {
// These are stored as serialized strings.
$field_view_mode['display_settings'] = serialize($field_view_mode['display_settings']);
$field_view_mode['widget_settings'] = serialize($field_view_mode['widget_settings']);
$this->databaseContents['content_node_field'][] = array(
'field_name' => $field_view_mode['field_name'],
'type' => $field_view_mode['type'],
'module' => $field_view_mode['module'],
);
unset($field_view_mode['type']);
unset($field_view_mode['module']);
$this->databaseContents['content_node_field_instance'][] = $field_view_mode;
// Update the expected display settings.
$this->expectedResults[$k]['display_settings'] = $this->expectedResults[$k]['display_settings'][$field_view_mode['view_mode']];
}
parent::setUp();
}
}
@@ -1,91 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 field instance source plugin.
*
* @group field
*/
class FieldInstanceTest 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\FieldInstance';
// The fake Migration configuration entity.
protected $migrationConfiguration = [
// The id of the entity, can be any string.
'id' => 'test_fieldinstance',
'source' => [
'plugin' => 'd6_field_instance',
],
];
// We need to set up the database contents; it's easier to do that below.
// These are sample result queries.
protected $expectedResults = [
[
'field_name' => 'field_body',
'type_name' => 'page',
'weight' => 1,
'label' => 'body',
'widget_type' => 'text_textarea',
'widget_settings' => '',
'display_settings' => '',
'description' => '',
'widget_module' => 'text',
'widget_active' => 1,
'required' => 1,
'active' => 1,
'global_settings' => [],
],
];
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->expectedResults[0]['widget_settings'] = [
'rows' => 5,
'size' => 60,
'default_value' => [
[
'value' => '',
'_error_element' => 'default_value_widget][field_body][0][value',
'default_value_php' => '',
],
],
];
$this->expectedResults[0]['display_settings'] = [
'label' => [
'format' => 'above',
'exclude' => 0,
],
'teaser' => [
'format' => 'default',
'exclude' => 0,
],
'full' => [
'format' => 'default',
'exclude' => 0,
],
];
$this->databaseContents['content_node_field_instance'] = $this->expectedResults;
$this->databaseContents['content_node_field_instance'][0]['widget_settings'] = serialize($this->expectedResults[0]['widget_settings']);
$this->databaseContents['content_node_field_instance'][0]['display_settings'] = serialize($this->expectedResults[0]['display_settings']);
$this->databaseContents['content_node_field_instance'][0]['global_settings'] = 'a:0:{}';
$this->databaseContents['content_node_field'][0] = [
'field_name' => 'field_body',
'required' => 1,
'type' => 'text',
'active' => 1,
'global_settings' => serialize([]),
];
parent::setUp();
}
}
@@ -1,72 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 field source plugin.
*
* @group field
*/
class FieldTest 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\Field';
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
// The id of the entity, can be any string.
'id' => 'test_field',
'source' => array(
'plugin' => 'd6_field',
),
);
// We need to set up the database contents; it's easier to do that below.
// These are sample result queries.
protected $expectedResults = array(
array(
'field_name' => 'field_body',
'type' => 'text',
'global_settings' => '',
'required' => 0,
'multiple' => 0,
'db_storage' => 1,
'module' => 'text',
'db_columns' => '',
'active' => 1,
'locked' => 0,
),
);
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->expectedResults[0]['global_settings'] = array(
'text_processing' => 0,
'max_length' => '',
'allowed_values' => '',
'allowed_values_php' => '',
);
$this->expectedResults[0]['db_columns'] = array(
'value' => array(
'type' => 'text',
'size' => 'big',
'not null' => '',
'sortable' => 1,
'views' => 1,
),
);
$this->databaseContents['content_node_field'] = $this->expectedResults;
$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_type'] = 'text_textarea';
$this->databaseContents['content_node_field_instance'][0]['field_name'] = 'field_body';
parent::setUp();
}
}
@@ -1,184 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 field instance per form display source plugin.
*
* @group field
*/
class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d7\FieldInstancePerFormDisplay';
protected $migrationConfiguration = array(
'id' => 'test_fieldinstance',
'source' => array(
'plugin' => 'd7_field_instance_per_form_display',
),
);
// We need to set up the database contents; it's easier to do that below.
// These are sample result queries.
protected $expectedResults = array(
array(
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => 'page',
'widget_settings' => array(
),
'display_settings' => array(
),
'description' => '',
'required' => FALSE,
'global_settings' => array(),
),
array(
'field_name' => 'field_file',
'entity_type' => 'user',
'bundle' => 'user',
'widget_settings' => array(
),
'display_settings' => array(
),
'description' => '',
'required' => FALSE,
'global_settings' => array(),
),
array(
'field_name' => 'field_integer',
'entity_type' => 'comment',
'bundle' => 'comment_node_test_content_type',
'widget_settings' => array(
),
'display_settings' => array(
),
'description' => '',
'required' => FALSE,
'global_settings' => array(),
),
array(
'field_name' => 'field_link',
'entity_type' => 'taxonomy_term',
'bundle' => 'test_vocabulary',
'widget_settings' => array(
),
'display_settings' => array(
),
'description' => '',
'required' => FALSE,
'global_settings' => array(),
),
);
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->databaseContents['field_config_instance'] = array(
array(
'id' => '2',
'field_id' => '2',
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => 'page',
'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
array(
'id' => '33',
'field_id' => '11',
'field_name' => 'field_file',
'entity_type' => 'user',
'bundle' => 'user',
'data' => 'a:6:{s:5:"label";s:4:"File";s:6:"widget";a:5:{s:6:"weight";s:1:"8";s:4:"type";s:12:"file_generic";s:6:"module";s:4:"file";s:6:"active";i:1;s:8:"settings";a:1:{s:18:"progress_indicator";s:8:"throbber";}}s:8:"settings";a:5:{s:14:"file_directory";s:0:"";s:15:"file_extensions";s:3:"txt";s:12:"max_filesize";s:0:"";s:17:"description_field";i:0;s:18:"user_register_form";i:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"file_default";s:8:"settings";a:0:{}s:6:"module";s:4:"file";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
array(
'id' => '32',
'field_id' => '14',
'field_name' => 'field_integer',
'entity_type' => 'comment',
'bundle' => 'comment_node_test_content_type',
'data' => 'a:7:{s:5:"label";s:7:"Integer";s:6:"widget";a:5:{s:6:"weight";s:1:"2";s:4:"type";s:6:"number";s:6:"module";s:6:"number";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:5:{s:3:"min";s:0:"";s:3:"max";s:0:"";s:6:"prefix";s:0:"";s:6:"suffix";s:0:"";s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:14:"number_integer";s:8:"settings";a:4:{s:18:"thousand_separator";s:1:" ";s:17:"decimal_separator";s:1:".";s:5:"scale";i:0;s:13:"prefix_suffix";b:1;}s:6:"module";s:6:"number";s:6:"weight";i:1;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
'deleted' => '0',
),
array(
'id' => '25',
'field_id' => '15',
'field_name' => 'field_link',
'entity_type' => 'taxonomy_term',
'bundle' => 'test_vocabulary',
'data' => 'a:7:{s:5:"label";s:4:"Link";s:6:"widget";a:5:{s:6:"weight";s:2:"10";s:4:"type";s:10:"link_field";s:6:"module";s:4:"link";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:12:{s:12:"absolute_url";i:1;s:12:"validate_url";i:1;s:3:"url";i:0;s:5:"title";s:8:"optional";s:11:"title_value";s:19:"Unused Static Title";s:27:"title_label_use_field_label";i:0;s:15:"title_maxlength";s:3:"128";s:7:"display";a:1:{s:10:"url_cutoff";s:2:"81";}s:10:"attributes";a:6:{s:6:"target";s:6:"_blank";s:3:"rel";s:8:"nofollow";s:18:"configurable_class";i:0;s:5:"class";s:7:"classes";s:18:"configurable_title";i:1;s:5:"title";s:0:"";}s:10:"rel_remove";s:19:"rel_remove_external";s:13:"enable_tokens";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"link_default";s:6:"weight";s:1:"9";s:8:"settings";a:0:{}s:6:"module";s:4:"link";}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
'deleted' => '0',
),
);
$this->databaseContents['field_config'] = array(
array(
'id' => '2',
'field_name' => 'body',
'type' => 'text_with_summary',
'module' => 'text',
'active' => '1',
'storage_type' => 'field_sql_storage',
'storage_module' => 'field_sql_storage',
'storage_active' => '1',
'locked' => '0',
'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}',
'cardinality' => '1',
'translatable' => '0',
'deleted' => '0',
),
array(
'id' => '11',
'field_name' => 'field_file',
'type' => 'file',
'module' => 'file',
'active' => '1',
'storage_type' => 'field_sql_storage',
'storage_module' => 'field_sql_storage',
'storage_active' => '1',
'locked' => '0',
'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:13:"display_field";i:0;s:15:"display_default";i:0;s:10:"uri_scheme";s:6:"public";}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:21:"field_data_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:25:"field_revision_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}}}}s:12:"foreign keys";a:1:{s:3:"fid";a:2:{s:5:"table";s:12:"file_managed";s:7:"columns";a:1:{s:3:"fid";s:3:"fid";}}}s:7:"indexes";a:1:{s:3:"fid";a:1:{i:0;s:3:"fid";}}s:2:"id";s:2:"11";}',
'cardinality' => '1',
'translatable' => '0',
'deleted' => '0',
),
array(
'id' => '14',
'field_name' => 'field_integer',
'type' => 'number_integer',
'module' => 'number',
'active' => '1',
'storage_type' => 'field_sql_storage',
'storage_module' => 'field_sql_storage',
'storage_active' => '1',
'locked' => '0',
'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:0:{}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:24:"field_data_field_integer";a:1:{s:5:"value";s:19:"field_integer_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:28:"field_revision_field_integer";a:1:{s:5:"value";s:19:"field_integer_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:0:{}s:2:"id";s:2:"14";}',
'cardinality' => '1',
'translatable' => '0',
'deleted' => '0',
),
array(
'id' => '15',
'field_name' => 'field_link',
'type' => 'link_field',
'module' => 'link',
'active' => '1',
'storage_type' => 'field_sql_storage',
'storage_module' => 'field_sql_storage',
'storage_active' => '1',
'locked' => '0',
'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:7:{s:10:"attributes";a:3:{s:6:"target";s:7:"default";s:5:"class";s:0:"";s:3:"rel";s:0:"";}s:3:"url";i:0;s:5:"title";s:8:"optional";s:11:"title_value";s:0:"";s:15:"title_maxlength";i:128;s:13:"enable_tokens";i:1;s:7:"display";a:1:{s:10:"url_cutoff";i:80;}}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:21:"field_data_field_link";a:3:{s:3:"url";s:14:"field_link_url";s:5:"title";s:16:"field_link_title";s:10:"attributes";s:21:"field_link_attributes";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:25:"field_revision_field_link";a:3:{s:3:"url";s:14:"field_link_url";s:5:"title";s:16:"field_link_title";s:10:"attributes";s:21:"field_link_attributes";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:0:{}s:2:"id";s:2:"15";}',
'cardinality' => '1',
'translatable' => '0',
'deleted' => '0',
),
);
parent::setUp();
}
}
@@ -1,68 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 field instance per view mode source plugin.
*
* @group field
*/
class FieldInstancePerViewModeTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode';
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd7_field_instance_per_view_mode',
),
);
protected $expectedResults = array(
array(
'entity_type' => 'node',
'bundle' => 'page',
'field_name' => 'body',
'label' => 'hidden',
'type' => 'text_default',
'settings' => array(),
'module' => 'text',
'weight' => 0,
'view_mode' => 'default',
),
array(
'entity_type' => 'node',
'bundle' => 'page',
'field_name' => 'body',
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
'settings' => array(
'trim_length' => 600,
),
'module' => 'text',
'weight' => 0,
'view_mode' => 'teaser',
),
);
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->databaseContents['field_config_instance'] = array(
array(
'id' => '2',
'field_id' => '2',
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => 'page',
'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
);
parent::setUp();
}
}
@@ -1,82 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 field instance source plugin.
*
* @group field
*/
class FieldInstanceTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d7\FieldInstance';
protected $migrationConfiguration = array(
'id' => 'test_fieldinstance',
'source' => array(
'plugin' => 'd7_field_instance',
),
);
protected $expectedResults = array(
array(
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'Body',
'widget_settings' => array(
'module' => 'text',
'settings' => array(
'rows' => 20,
'summary_rows' => 5,
),
'type' => 'text_textarea_with_summary',
'weight' => -4,
),
'display_settings' => array(
),
'description' => '',
'required' => FALSE,
'global_settings' => array(),
),
);
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->databaseContents['field_config_instance'] = array(
array(
'id' => '2',
'field_id' => '2',
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => 'page',
'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
);
$this->databaseContents['field_config'] = array(
array(
'id' => '2',
'field_name' => 'body',
'type' => 'text_with_summary',
'module' => 'text',
'active' => '1',
'storage_type' => 'field_sql_storage',
'storage_module' => 'field_sql_storage',
'storage_active' => '1',
'locked' => '0',
'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}',
'cardinality' => '1',
'translatable' => '0',
'deleted' => '0',
),
);
parent::setUp();
}
}
@@ -1,136 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 field source plugin.
*
* @group field
*/
class FieldTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d7\Field';
protected $migrationConfiguration = array(
'id' => 'test_field',
'source' => array(
'plugin' => 'd7_field',
),
);
protected $expectedResults = array(
array(
'field_name' => 'field_file',
'type' => 'file',
'global_settings' => '',
'storage' => array(
'active' => 1,
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_field_file' => array(
'description' => 'field_file_description',
'display' => 'field_file_display',
'fid' => 'field_file_fid',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_field_file' => array(
'description' => 'field_file_description',
'display' => 'field_file_display',
'fid' => 'field_file_fid',
),
),
),
),
'module' => 'field_sql_storage',
'settings' => array(),
'type' => 'field_sql_storage',
),
'module' => 'file',
'db_columns' => '',
'locked' => 0,
'entity_type' => 'node',
),
array(
'field_name' => 'field_file',
'type' => 'file',
'global_settings' => '',
'storage' => array(
'active' => 1,
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_field_file' => array(
'description' => 'field_file_description',
'display' => 'field_file_display',
'fid' => 'field_file_fid',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_field_file' => array(
'description' => 'field_file_description',
'display' => 'field_file_display',
'fid' => 'field_file_fid',
),
),
),
),
'module' => 'field_sql_storage',
'settings' => array(),
'type' => 'field_sql_storage',
),
'module' => 'file',
'db_columns' => '',
'locked' => 0,
'entity_type' => 'user',
),
);
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->databaseContents['field_config'] = array(
array(
'id' => '11',
'field_name' => 'field_file',
'type' => 'file',
'module' => 'file',
'active' => '1',
'storage_type' => 'field_sql_storage',
'storage_module' => 'field_sql_storage',
'storage_active' => '1',
'locked' => '0',
'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:13:"display_field";i:0;s:15:"display_default";i:0;s:10:"uri_scheme";s:6:"public";}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:21:"field_data_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:25:"field_revision_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}}}}s:12:"foreign keys";a:1:{s:3:"fid";a:2:{s:5:"table";s:12:"file_managed";s:7:"columns";a:1:{s:3:"fid";s:3:"fid";}}}s:7:"indexes";a:1:{s:3:"fid";a:1:{i:0;s:3:"fid";}}s:2:"id";s:2:"11";}',
'cardinality' => '1',
'translatable' => '0',
'deleted' => '0',
),
);
$this->databaseContents['field_config_instance'] = array(
array(
'id' => '33',
'field_id' => '11',
'field_name' => 'field_file',
'entity_type' => 'user',
'bundle' => 'user',
'data' => 'a:6:{s:5:"label";s:4:"File";s:6:"widget";a:5:{s:6:"weight";s:1:"8";s:4:"type";s:12:"file_generic";s:6:"module";s:4:"file";s:6:"active";i:1;s:8:"settings";a:1:{s:18:"progress_indicator";s:8:"throbber";}}s:8:"settings";a:5:{s:14:"file_directory";s:0:"";s:15:"file_extensions";s:3:"txt";s:12:"max_filesize";s:0:"";s:17:"description_field";i:0;s:18:"user_register_form";i:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"file_default";s:8:"settings";a:0:{}s:6:"module";s:4:"file";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
array(
'id' => '21',
'field_id' => '11',
'field_name' => 'field_file',
'entity_type' => 'node',
'bundle' => 'test_content_type',
'data' => 'a:6:{s:5:"label";s:4:"File";s:6:"widget";a:5:{s:6:"weight";s:1:"5";s:4:"type";s:12:"file_generic";s:6:"module";s:4:"file";s:6:"active";i:1;s:8:"settings";a:1:{s:18:"progress_indicator";s:8:"throbber";}}s:8:"settings";a:5:{s:14:"file_directory";s:0:"";s:15:"file_extensions";s:15:"txt pdf ods odf";s:12:"max_filesize";s:5:"10 MB";s:17:"description_field";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"file_default";s:6:"weight";s:1:"5";s:8:"settings";a:0:{}s:6:"module";s:4:"file";}}s:8:"required";i:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
);
parent::setUp();
}
}
@@ -1,82 +0,0 @@
<?php
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 view mode source plugin.
*
* @group field
*/
class ViewModeTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d7\ViewMode';
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd7_view_mode',
),
);
protected $expectedResults = array(
array(
'entity_type' => 'node',
'view_mode' => 'default',
),
array(
'entity_type' => 'node',
'view_mode' => 'teaser',
),
array(
'entity_type' => 'node',
'view_mode' => 'custom',
),
array(
'entity_type' => 'user',
'view_mode' => 'default',
),
array(
'entity_type' => 'comment',
'view_mode' => 'default',
),
);
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->databaseContents['field_config_instance'] = array(
array(
'id' => '13',
'field_id' => '2',
'field_name' => 'body',
'entity_type' => 'node',
'bundle' => 'forum',
'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:1;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:3:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:11;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:11;}s:6:"custom";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:11;}}s:8:"required";b:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
array(
'id' => '33',
'field_id' => '11',
'field_name' => 'field_file',
'entity_type' => 'user',
'bundle' => 'user',
'data' => 'a:6:{s:5:"label";s:4:"File";s:6:"widget";a:5:{s:6:"weight";s:1:"8";s:4:"type";s:12:"file_generic";s:6:"module";s:4:"file";s:6:"active";i:1;s:8:"settings";a:1:{s:18:"progress_indicator";s:8:"throbber";}}s:8:"settings";a:5:{s:14:"file_directory";s:0:"";s:15:"file_extensions";s:3:"txt";s:12:"max_filesize";s:0:"";s:17:"description_field";i:0;s:18:"user_register_form";i:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"file_default";s:8:"settings";a:0:{}s:6:"module";s:4:"file";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";}',
'deleted' => '0',
),
array(
'id' => '12',
'field_id' => '1',
'field_name' => 'comment_body',
'entity_type' => 'comment',
'bundle' => 'comment_node_forum',
'data' => 'a:6:{s:5:"label";s:7:"Comment";s:8:"settings";a:2:{s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:8:"required";b:1;s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:6:"weight";i:0;s:8:"settings";a:0:{}s:6:"module";s:4:"text";}}s:6:"widget";a:4:{s:4:"type";s:13:"text_textarea";s:8:"settings";a:1:{s:4:"rows";i:5;}s:6:"weight";i:0;s:6:"module";s:4:"text";}s:11:"description";s:0:"";}',
'deleted' => '0',
),
);
parent::setUp();
}
}