Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2
This commit is contained in:
parent
23ffed3665
commit
507b45a0ed
378 changed files with 11434 additions and 5542 deletions
|
@ -15,105 +15,101 @@ process:
|
|||
langcode: 'constants/langcode'
|
||||
field_name: field_name
|
||||
type:
|
||||
-
|
||||
plugin: field_type
|
||||
source:
|
||||
- type
|
||||
- widget_type
|
||||
map:
|
||||
number_integer:
|
||||
number: integer
|
||||
optionwidgets_select: list_integer
|
||||
optionwidgets_buttons: list_integer
|
||||
optionwidgets_onoff: boolean
|
||||
number_decimal:
|
||||
number: decimal
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
number_float:
|
||||
number: float
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
email:
|
||||
email_textfield: email
|
||||
filefield:
|
||||
imagefield_widget: image
|
||||
filefield_widget: file
|
||||
date:
|
||||
date_select: datetime
|
||||
datestamp:
|
||||
date_select: datetime
|
||||
datetime:
|
||||
date_select: datetime
|
||||
fr_phone:
|
||||
phone_textfield: telephone
|
||||
be_phone:
|
||||
phone_textfield: telephone
|
||||
it_phone:
|
||||
phone_textfield: telephone
|
||||
el_phone:
|
||||
phone_textfield: telephone
|
||||
ch_phone:
|
||||
phone_textfield: telephone
|
||||
ca_phone:
|
||||
phone_textfield: telephone
|
||||
cr_phone:
|
||||
phone_textfield: telephone
|
||||
pa_phone:
|
||||
phone_textfield: telephone
|
||||
gb_phone:
|
||||
phone_textfield: telephone
|
||||
ru_phone:
|
||||
phone_textfield: telephone
|
||||
ua_phone:
|
||||
phone_textfield: telephone
|
||||
es_phone:
|
||||
phone_textfield: telephone
|
||||
au_phone:
|
||||
phone_textfield: telephone
|
||||
cs_phone:
|
||||
phone_textfield: telephone
|
||||
hu_phone:
|
||||
phone_textfield: telephone
|
||||
pl_phone:
|
||||
phone_textfield: telephone
|
||||
nl_phone:
|
||||
phone_textfield: telephone
|
||||
se_phone:
|
||||
phone_textfield: telephone
|
||||
za_phone:
|
||||
phone_textfield: telephone
|
||||
il_phone:
|
||||
phone_textfield: telephone
|
||||
nz_phone:
|
||||
phone_textfield: telephone
|
||||
br_phone:
|
||||
phone_textfield: telephone
|
||||
cl_phone:
|
||||
phone_textfield: telephone
|
||||
cn_phone:
|
||||
phone_textfield: telephone
|
||||
hk_phone:
|
||||
phone_textfield: telephone
|
||||
mo_phone:
|
||||
phone_textfield: telephone
|
||||
ph_phone:
|
||||
phone_textfield: telephone
|
||||
sg_phone:
|
||||
phone_textfield: telephone
|
||||
jo_phone:
|
||||
phone_textfield: telephone
|
||||
eg_phone:
|
||||
phone_textfield: telephone
|
||||
pk_phone:
|
||||
phone_textfield: telephone
|
||||
int_phone:
|
||||
phone_textfield: telephone
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
plugin: field_type
|
||||
source:
|
||||
- type
|
||||
- widget_type
|
||||
map:
|
||||
number_integer:
|
||||
number: integer
|
||||
optionwidgets_select: list_integer
|
||||
optionwidgets_buttons: list_integer
|
||||
optionwidgets_onoff: boolean
|
||||
number_decimal:
|
||||
number: decimal
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
number_float:
|
||||
number: float
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
email:
|
||||
email_textfield: email
|
||||
filefield:
|
||||
imagefield_widget: image
|
||||
filefield_widget: file
|
||||
date:
|
||||
date_select: datetime
|
||||
datestamp:
|
||||
date_select: datetime
|
||||
datetime:
|
||||
date_select: datetime
|
||||
fr_phone:
|
||||
phone_textfield: telephone
|
||||
be_phone:
|
||||
phone_textfield: telephone
|
||||
it_phone:
|
||||
phone_textfield: telephone
|
||||
el_phone:
|
||||
phone_textfield: telephone
|
||||
ch_phone:
|
||||
phone_textfield: telephone
|
||||
ca_phone:
|
||||
phone_textfield: telephone
|
||||
cr_phone:
|
||||
phone_textfield: telephone
|
||||
pa_phone:
|
||||
phone_textfield: telephone
|
||||
gb_phone:
|
||||
phone_textfield: telephone
|
||||
ru_phone:
|
||||
phone_textfield: telephone
|
||||
ua_phone:
|
||||
phone_textfield: telephone
|
||||
es_phone:
|
||||
phone_textfield: telephone
|
||||
au_phone:
|
||||
phone_textfield: telephone
|
||||
cs_phone:
|
||||
phone_textfield: telephone
|
||||
hu_phone:
|
||||
phone_textfield: telephone
|
||||
pl_phone:
|
||||
phone_textfield: telephone
|
||||
nl_phone:
|
||||
phone_textfield: telephone
|
||||
se_phone:
|
||||
phone_textfield: telephone
|
||||
za_phone:
|
||||
phone_textfield: telephone
|
||||
il_phone:
|
||||
phone_textfield: telephone
|
||||
nz_phone:
|
||||
phone_textfield: telephone
|
||||
br_phone:
|
||||
phone_textfield: telephone
|
||||
cl_phone:
|
||||
phone_textfield: telephone
|
||||
cn_phone:
|
||||
phone_textfield: telephone
|
||||
hk_phone:
|
||||
phone_textfield: telephone
|
||||
mo_phone:
|
||||
phone_textfield: telephone
|
||||
ph_phone:
|
||||
phone_textfield: telephone
|
||||
sg_phone:
|
||||
phone_textfield: telephone
|
||||
jo_phone:
|
||||
phone_textfield: telephone
|
||||
eg_phone:
|
||||
phone_textfield: telephone
|
||||
pk_phone:
|
||||
phone_textfield: telephone
|
||||
int_phone:
|
||||
phone_textfield: telephone
|
||||
cardinality:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
|
@ -126,6 +122,5 @@ process:
|
|||
source:
|
||||
- '@type'
|
||||
- global_settings
|
||||
|
||||
destination:
|
||||
plugin: md_entity:field_storage_config
|
||||
|
|
|
@ -21,8 +21,6 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
|
|||
$rows = array();
|
||||
$result = $this->prepareQuery()->execute();
|
||||
while ($field_row = $result->fetchAssoc()) {
|
||||
$field_row['display_settings'] = unserialize($field_row['display_settings']);
|
||||
$field_row['widget_settings'] = unserialize($field_row['widget_settings']);
|
||||
$bundle = $field_row['type_name'];
|
||||
$field_name = $field_row['field_name'];
|
||||
|
||||
|
@ -34,7 +32,8 @@ class FieldInstancePerFormDisplay extends DrupalSqlBase {
|
|||
$rows[$index]['module'] = $field_row['module'];
|
||||
$rows[$index]['weight'] = $field_row['weight'];
|
||||
$rows[$index]['widget_type'] = $field_row['widget_type'];
|
||||
$rows[$index]['widget_settings'] = $field_row['widget_settings'];
|
||||
$rows[$index]['widget_settings'] = unserialize($field_row['widget_settings']);
|
||||
$rows[$index]['display_settings'] = unserialize($field_row['display_settings']);
|
||||
}
|
||||
|
||||
return new \ArrayIterator($rows);
|
||||
|
|
|
@ -165,4 +165,30 @@ class NestedFormTest extends FieldTestBase {
|
|||
$this->assertFieldValues($entity_2, 'field_unlimited', array(13, 14, 15));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests entity level validation within subforms.
|
||||
*/
|
||||
public function testNestedEntityFormEntityLevelValidation() {
|
||||
// Create two entities.
|
||||
$storage = $this->container->get('entity_type.manager')
|
||||
->getStorage('entity_test_constraints');
|
||||
|
||||
$entity_1 = $storage->create();
|
||||
$entity_1->save();
|
||||
|
||||
$entity_2 = $storage->create();
|
||||
$entity_2->save();
|
||||
|
||||
// Display the 'combined form'.
|
||||
$this->drupalGet("test-entity-constraints/nested/{$entity_1->id()}/{$entity_2->id()}");
|
||||
$this->assertFieldByName('entity_2[changed]', 0, 'Entity 2: changed value appears correctly in the form.');
|
||||
|
||||
// Submit the form and check that the entities are updated accordingly.
|
||||
$edit = ['entity_2[changed]' => REQUEST_TIME - 86400];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
|
||||
$elements = $this->cssSelect('.entity-2.error');
|
||||
$this->assertEqual(1, count($elements), 'The whole nested entity form has been correctly flagged with an error class.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,3 +11,17 @@ field_test.entity_nested_form:
|
|||
type: 'entity:entity_test'
|
||||
requirements:
|
||||
_permission: 'administer entity_test content'
|
||||
|
||||
field_test.entity_constraints_nested_form:
|
||||
path: '/test-entity-constraints/nested/{entity_1}/{entity_2}'
|
||||
defaults:
|
||||
_title: 'Nested entity form'
|
||||
_form: '\Drupal\field_test\Form\NestedEntityTestForm'
|
||||
options:
|
||||
parameters:
|
||||
entity_1:
|
||||
type: 'entity:entity_test_constraints'
|
||||
entity_2:
|
||||
type: 'entity:entity_test_constraints'
|
||||
requirements:
|
||||
_permission: 'administer entity_test content'
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\field_test\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityChangedInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
@ -33,16 +34,26 @@ class NestedEntityTestForm extends FormBase {
|
|||
$form_state->set('entity_2', $entity_2);
|
||||
$form_display_2 = EntityFormDisplay::collectRenderDisplay($entity_2, 'default');
|
||||
$form_state->set('form_display_2', $form_display_2);
|
||||
$form['entity_2'] = array(
|
||||
$form['entity_2'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Second entity'),
|
||||
'#tree' => TRUE,
|
||||
'#parents' => array('entity_2'),
|
||||
'#parents' => ['entity_2'],
|
||||
'#weight' => 50,
|
||||
);
|
||||
'#attributes' => ['class' => ['entity-2']]
|
||||
];
|
||||
|
||||
$form_display_2->buildForm($entity_2, $form['entity_2'], $form_state);
|
||||
|
||||
if ($entity_2 instanceof EntityChangedInterface) {
|
||||
// Changed must be sent to the client, for later overwrite error checking.
|
||||
// @see Drupal\field\Tests\NestedFormTest::testNestedEntityFormEntityLevelValidation()
|
||||
$form['entity_2']['changed'] = [
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => $entity_1->getChangedTime(),
|
||||
];
|
||||
}
|
||||
|
||||
$form['save'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
|
@ -65,7 +76,16 @@ class NestedEntityTestForm extends FormBase {
|
|||
$entity_2 = $form_state->get('entity_2');
|
||||
/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display_2 */
|
||||
$form_display_2 = $form_state->get('form_display_2');
|
||||
$form_display_2->extractFormValues($entity_2, $form['entity_2'], $form_state);
|
||||
$extracted = $form_display_2->extractFormValues($entity_2, $form['entity_2'], $form_state);
|
||||
// Extract the values of fields that are not rendered through widgets, by
|
||||
// simply copying from top-level form values. This leaves the fields that
|
||||
// are not being edited within this form untouched.
|
||||
// @see Drupal\field\Tests\NestedFormTest::testNestedEntityFormEntityLevelValidation()
|
||||
foreach ($form_state->getValues()['entity_2'] as $name => $values) {
|
||||
if ($entity_2->hasField($name) && !isset($extracted[$name])) {
|
||||
$entity_2->set($name, $values);
|
||||
}
|
||||
}
|
||||
$form_display_2->validateFormValues($entity_2, $form['entity_2'], $form_state);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,19 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
|
|||
$this->assertIdentical($expected_entity_type . '.' . $expected_name, $field->getFieldStorageDefinition()->id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts the settings of a link field config entity.
|
||||
*
|
||||
* @param $id
|
||||
* The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.
|
||||
* @param $title_setting
|
||||
* The expected title setting.
|
||||
*/
|
||||
protected function assertLinkFields($id, $title_setting) {
|
||||
$field = FieldConfig::load($id);
|
||||
$this->assertSame($title_setting, $field->getSetting('title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migrating D7 field instances to field_config entities.
|
||||
*/
|
||||
|
@ -131,6 +144,10 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
|
|||
$this->assertEntity('node.test_content_type.field_text', 'Text', 'text', FALSE);
|
||||
$this->assertEntity('comment.comment_node_test_content_type.field_integer', 'Integer', 'integer', FALSE);
|
||||
$this->assertEntity('user.user.field_file', 'File', 'file', 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests d6_field_instance_per_form_display source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerFormDisplay
|
||||
* @group field
|
||||
*/
|
||||
class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'display_settings' => [],
|
||||
'widget_settings' => [],
|
||||
'type_name' => 'story',
|
||||
'widget_active' => TRUE,
|
||||
'field_name' => 'field_test_filefield',
|
||||
'type' => 'filefield',
|
||||
'module' => 'filefield',
|
||||
'weight' => '8',
|
||||
'widget_type' => 'filefield_widget',
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$empty_array = serialize([]);
|
||||
$tests[0]['source_data']['content_node_field'] = [
|
||||
[
|
||||
'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',
|
||||
]
|
||||
];
|
||||
$tests[0]['source_data']['content_node_field_instance'] = [
|
||||
[
|
||||
'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',
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 fields per view mode source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode
|
||||
* @group field
|
||||
*/
|
||||
class FieldInstancePerViewModeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field', 'migrate_drupal', 'node', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 4,
|
||||
'type_name' => 'article',
|
||||
'field_name' => 'field_test',
|
||||
'type' => 'text',
|
||||
'module' => 'text',
|
||||
'weight' => 1,
|
||||
'label' => 'above',
|
||||
'display_settings' => [
|
||||
'weight' => 1,
|
||||
'parent' => '',
|
||||
'label' => [
|
||||
'format' => 'above',
|
||||
],
|
||||
4 => [
|
||||
'format' => 'trimmed',
|
||||
'exclude' => 0,
|
||||
],
|
||||
],
|
||||
'widget_settings' => [],
|
||||
],
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'teaser',
|
||||
'type_name' => 'story',
|
||||
'field_name' => 'field_test',
|
||||
'type' => 'text',
|
||||
'module' => 'text',
|
||||
'weight' => 2,
|
||||
'label' => 'above',
|
||||
'display_settings' => [
|
||||
'weight' => 1,
|
||||
'parent' => '',
|
||||
'label' => [
|
||||
'format' => 'above',
|
||||
],
|
||||
'teaser' => [
|
||||
'format' => 'trimmed',
|
||||
'exclude' => 0,
|
||||
],
|
||||
],
|
||||
'widget_settings' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
foreach ($tests[0]['expected_data'] 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']);
|
||||
|
||||
$tests[0]['source_data']['content_node_field'][] = [
|
||||
'field_name' => $field_view_mode['field_name'],
|
||||
'type' => $field_view_mode['type'],
|
||||
'module' => $field_view_mode['module'],
|
||||
];
|
||||
unset($field_view_mode['type'], $field_view_mode['module']);
|
||||
|
||||
$tests[0]['source_data']['content_node_field_instance'][] = $field_view_mode;
|
||||
|
||||
// Update the expected display settings.
|
||||
$tests[0]['expected_data'][$k]['display_settings'] = $tests[0]['expected_data'][$k]['display_settings'][$field_view_mode['view_mode']];
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 field instance source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d6\FieldInstance
|
||||
* @group field
|
||||
*/
|
||||
class FieldInstanceTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'field_name' => 'field_body',
|
||||
'type_name' => 'page',
|
||||
'weight' => 1,
|
||||
'label' => 'body',
|
||||
'widget_type' => 'text_textarea',
|
||||
'description' => '',
|
||||
'widget_module' => 'text',
|
||||
'widget_active' => 1,
|
||||
'required' => 1,
|
||||
'active' => 1,
|
||||
'global_settings' => [],
|
||||
'widget_settings' => [
|
||||
'rows' => 5,
|
||||
'size' => 60,
|
||||
'default_value' => [
|
||||
[
|
||||
'value' => '',
|
||||
'_error_element' => 'default_value_widget][field_body][0][value',
|
||||
'default_value_php' => '',
|
||||
],
|
||||
],
|
||||
],
|
||||
'display_settings' => [
|
||||
'label' => [
|
||||
'format' => 'above',
|
||||
'exclude' => 0,
|
||||
],
|
||||
'teaser' => [
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
],
|
||||
'full' => [
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['content_node_field_instance'] = array_map(
|
||||
function (array $row) {
|
||||
$row['widget_settings'] = serialize($row['widget_settings']);
|
||||
$row['display_settings'] = serialize($row['display_settings']);
|
||||
$row['global_settings'] = serialize($row['global_settings']);
|
||||
return $row;
|
||||
},
|
||||
$tests[0]['expected_data']
|
||||
);
|
||||
$tests[0]['source_data']['content_node_field'] = [
|
||||
[
|
||||
'field_name' => 'field_body',
|
||||
'required' => 1,
|
||||
'type' => 'text',
|
||||
'active' => 1,
|
||||
'global_settings' => serialize([]),
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 field source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d6\Field
|
||||
* @group field
|
||||
*/
|
||||
class FieldTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'field_name' => 'field_body',
|
||||
'type' => 'text',
|
||||
'global_settings' => [
|
||||
'text_processing' => 0,
|
||||
'max_length' => '',
|
||||
'allowed_values' => '',
|
||||
'allowed_values_php' => '',
|
||||
],
|
||||
'required' => 0,
|
||||
'multiple' => 0,
|
||||
'db_storage' => 1,
|
||||
'module' => 'text',
|
||||
'db_columns' => [
|
||||
'value' => [
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'not null' => '',
|
||||
'sortable' => 1,
|
||||
'views' => 1,
|
||||
],
|
||||
],
|
||||
'active' => 1,
|
||||
'locked' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['content_node_field'] = array_map(
|
||||
function (array $row) {
|
||||
$row['global_settings'] = serialize($row['global_settings']);
|
||||
$row['db_columns'] = serialize($row['db_columns']);
|
||||
return $row;
|
||||
},
|
||||
$tests[0]['expected_data']
|
||||
);
|
||||
$tests[0]['source_data']['content_node_field_instance'] = [
|
||||
[
|
||||
'widget_type' => 'text_textarea',
|
||||
'field_name' => 'field_body',
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 field instance per form display source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerFormDisplay
|
||||
* @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(),
|
||||
),
|
||||
);
|
||||
class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'id' => '2',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'body',
|
||||
|
@ -86,8 +38,8 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'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',
|
||||
|
@ -95,8 +47,8 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'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',
|
||||
|
@ -104,8 +56,8 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'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',
|
||||
|
@ -113,10 +65,10 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'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(
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config'] = [
|
||||
[
|
||||
'id' => '2',
|
||||
'field_name' => 'body',
|
||||
'type' => 'text_with_summary',
|
||||
|
@ -130,8 +82,8 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'cardinality' => '1',
|
||||
'translatable' => '0',
|
||||
'deleted' => '0',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'id' => '11',
|
||||
'field_name' => 'field_file',
|
||||
'type' => 'file',
|
||||
|
@ -145,8 +97,8 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'cardinality' => '1',
|
||||
'translatable' => '0',
|
||||
'deleted' => '0',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'id' => '14',
|
||||
'field_name' => 'field_integer',
|
||||
'type' => 'number_integer',
|
||||
|
@ -160,8 +112,8 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'cardinality' => '1',
|
||||
'translatable' => '0',
|
||||
'deleted' => '0',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'id' => '15',
|
||||
'field_name' => 'field_link',
|
||||
'type' => 'link_field',
|
||||
|
@ -175,10 +127,43 @@ class FieldInstancePerFormDisplayTest extends MigrateSqlSourceTestCase {
|
|||
'cardinality' => '1',
|
||||
'translatable' => '0',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
parent::setUp();
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'field_name' => 'body',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'widget_settings' => [
|
||||
'rows' => 20,
|
||||
'summary_rows' => 5,
|
||||
],
|
||||
],
|
||||
[
|
||||
'field_name' => 'field_file',
|
||||
'entity_type' => 'user',
|
||||
'bundle' => 'user',
|
||||
'widget_settings' => [
|
||||
'progress_indicator' => 'throbber',
|
||||
],
|
||||
],
|
||||
[
|
||||
'field_name' => 'field_integer',
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_test_content_type',
|
||||
'widget_settings' => [],
|
||||
],
|
||||
[
|
||||
'field_name' => 'field_link',
|
||||
'entity_type' => 'taxonomy_term',
|
||||
'bundle' => 'test_vocabulary',
|
||||
'widget_settings' => [],
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 field instance per view mode source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode
|
||||
* @group field
|
||||
*/
|
||||
class FieldInstancePerViewModeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'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',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'field_name' => 'body',
|
||||
'label' => 'hidden',
|
||||
'type' => 'text_default',
|
||||
'settings' => [],
|
||||
'module' => 'text',
|
||||
'weight' => 0,
|
||||
'view_mode' => 'default',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'field_name' => 'body',
|
||||
'label' => 'hidden',
|
||||
'type' => 'text_summary_or_trimmed',
|
||||
'settings' => [
|
||||
'trim_length' => 600,
|
||||
],
|
||||
'module' => 'text',
|
||||
'weight' => 0,
|
||||
'view_mode' => 'teaser',
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 field instance source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d7\FieldInstance
|
||||
* @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(),
|
||||
),
|
||||
);
|
||||
class FieldInstanceTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'id' => '2',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'body',
|
||||
|
@ -56,10 +38,10 @@ class FieldInstanceTest extends MigrateSqlSourceTestCase {
|
|||
'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(
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config'] = [
|
||||
[
|
||||
'id' => '2',
|
||||
'field_name' => 'body',
|
||||
'type' => 'text_with_summary',
|
||||
|
@ -73,10 +55,49 @@ class FieldInstanceTest extends MigrateSqlSourceTestCase {
|
|||
'cardinality' => '1',
|
||||
'translatable' => '0',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
parent::setUp();
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'field_name' => 'body',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'label' => 'Body',
|
||||
'widget_settings' => [
|
||||
'module' => 'text',
|
||||
'settings' => [
|
||||
'rows' => 20,
|
||||
'summary_rows' => 5,
|
||||
],
|
||||
'type' => 'text_textarea_with_summary',
|
||||
'weight' => -4,
|
||||
],
|
||||
'display_settings' => [
|
||||
'default' => [
|
||||
'label' => 'hidden',
|
||||
'type' => 'text_default',
|
||||
'settings' => [],
|
||||
'module' => 'text',
|
||||
'weight' => 0,
|
||||
],
|
||||
'teaser' => [
|
||||
'label' => 'hidden',
|
||||
'type' => 'text_summary_or_trimmed',
|
||||
'settings' => [
|
||||
'trim_length' => 600,
|
||||
],
|
||||
'module' => 'text',
|
||||
'weight' => 0,
|
||||
],
|
||||
],
|
||||
'description' => '',
|
||||
'required' => FALSE,
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,100 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 field source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d7\Field
|
||||
* @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',
|
||||
),
|
||||
);
|
||||
class FieldTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['field_config'] = array(
|
||||
array(
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['field_config'] = [
|
||||
[
|
||||
'id' => '11',
|
||||
'field_name' => 'field_file',
|
||||
'type' => 'file',
|
||||
|
@ -108,10 +44,10 @@ class FieldTest extends MigrateSqlSourceTestCase {
|
|||
'cardinality' => '1',
|
||||
'translatable' => '0',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'id' => '33',
|
||||
'field_id' => '11',
|
||||
'field_name' => 'field_file',
|
||||
|
@ -119,8 +55,8 @@ class FieldTest extends MigrateSqlSourceTestCase {
|
|||
'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',
|
||||
|
@ -128,9 +64,76 @@ class FieldTest extends MigrateSqlSourceTestCase {
|
|||
'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();
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'field_name' => 'field_file',
|
||||
'type' => 'file',
|
||||
'storage' => [
|
||||
'active' => 1,
|
||||
'details' => [
|
||||
'sql' => [
|
||||
'FIELD_LOAD_CURRENT' => [
|
||||
'field_data_field_file' => [
|
||||
'description' => 'field_file_description',
|
||||
'display' => 'field_file_display',
|
||||
'fid' => 'field_file_fid',
|
||||
],
|
||||
],
|
||||
'FIELD_LOAD_REVISION' => [
|
||||
'field_revision_field_file' => [
|
||||
'description' => 'field_file_description',
|
||||
'display' => 'field_file_display',
|
||||
'fid' => 'field_file_fid',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'module' => 'field_sql_storage',
|
||||
'settings' => [],
|
||||
'type' => 'field_sql_storage',
|
||||
],
|
||||
'module' => 'file',
|
||||
'locked' => 0,
|
||||
'entity_type' => 'node',
|
||||
],
|
||||
[
|
||||
'field_name' => 'field_file',
|
||||
'type' => 'file',
|
||||
'storage' => [
|
||||
'active' => 1,
|
||||
'details' => [
|
||||
'sql' => [
|
||||
'FIELD_LOAD_CURRENT' => [
|
||||
'field_data_field_file' => [
|
||||
'description' => 'field_file_description',
|
||||
'display' => 'field_file_display',
|
||||
'fid' => 'field_file_fid',
|
||||
],
|
||||
],
|
||||
'FIELD_LOAD_REVISION' => [
|
||||
'field_revision_field_file' => [
|
||||
'description' => 'field_file_description',
|
||||
'display' => 'field_file_display',
|
||||
'fid' => 'field_file_fid',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'module' => 'field_sql_storage',
|
||||
'settings' => [],
|
||||
'type' => 'field_sql_storage',
|
||||
],
|
||||
'module' => 'file',
|
||||
'locked' => 0,
|
||||
'entity_type' => 'user',
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d7;
|
||||
namespace Drupal\Tests\field\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 view mode source plugin.
|
||||
*
|
||||
* @covers \Drupal\field\Plugin\migrate\source\d7\ViewMode
|
||||
* @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',
|
||||
),
|
||||
);
|
||||
class ViewModeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
public static $modules = ['field', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [
|
||||
[
|
||||
'source_data' => [],
|
||||
'expected_data' => [],
|
||||
],
|
||||
];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'id' => '13',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'body',
|
||||
|
@ -56,8 +38,8 @@ class ViewModeTest extends MigrateSqlSourceTestCase {
|
|||
'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',
|
||||
|
@ -65,8 +47,8 @@ class ViewModeTest extends MigrateSqlSourceTestCase {
|
|||
'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',
|
||||
|
@ -74,9 +56,34 @@ class ViewModeTest extends MigrateSqlSourceTestCase {
|
|||
'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();
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'default',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'teaser',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'custom',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'user',
|
||||
'view_mode' => 'default',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'comment',
|
||||
'view_mode' => 'default',
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -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,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();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue