Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -7,6 +7,7 @@
namespace Drupal\Tests\field\Unit;
use Drupal\Core\Entity\EntityType;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
@ -115,26 +116,10 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
*/
public function testCalculateDependencies() {
// Mock the interfaces necessary to create a dependency on a bundle entity.
$bundle_entity = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$bundle_entity->expects($this->any())
->method('getConfigDependencyName')
->will($this->returnValue('test.test_entity_type.id'));
$storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$storage->expects($this->any())
->method('load')
->with('test_bundle')
->will($this->returnValue($bundle_entity));
$this->entityManager->expects($this->any())
->method('getStorage')
->with('bundle_entity_type')
->will($this->returnValue($storage));
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getBundleEntityType')
->will($this->returnValue('bundle_entity_type'));
->method('getBundleConfigDependency')
->will($this->returnValue(array('type' => 'config', 'name' => 'test.test_entity_type.id')));
$this->entityManager->expects($this->at(0))
->method('getDefinition')
@ -192,10 +177,10 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
->with('bundle_entity_type')
->will($this->returnValue($storage));
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getBundleEntityType')
->will($this->returnValue('bundle_entity_type'));
$target_entity_type = new EntityType(array(
'id' => 'test_entity_type',
'bundle_entity_type' => 'bundle_entity_type',
));
$this->entityManager->expects($this->at(0))
->method('getDefinition')

View file

@ -0,0 +1,45 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\process\d7\FieldInstanceSettingsTest.
*/
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d7;
use Drupal\field\Plugin\migrate\process\d7\FieldInstanceSettings;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\Tests\migrate\Unit\MigrateTestCase;
/**
* @coversDefaultClass \Drupal\field\Plugin\migrate\process\d7\FieldInstanceSettings
* @group field
*/
class FieldInstanceSettingsTest extends MigrateTestCase {
/**
* Tests transformation of image field settings.
*
* @covers ::transform
*/
public function testTransformImageSettings() {
$migration = $this->getMock(MigrationInterface::class);
$plugin = new FieldInstanceSettings([], 'd7_field_instance_settings', [], $migration);
$executable = $this->getMock(MigrateExecutableInterface::class);
$row = $this->getMockBuilder(Row::class)
->disableOriginalConstructor()
->getMock();
$value = $plugin->transform([[], ['type' => 'image_image']], $executable, $row, 'foo');
$this->assertInternalType('array', $value['default_image']);
$this->assertSame('', $value['default_image']['alt']);
$this->assertSame('', $value['default_image']['title']);
$this->assertNull($value['default_image']['width']);
$this->assertNull($value['default_image']['height']);
$this->assertSame('', $value['default_image']['uuid']);
}
}

View file

@ -0,0 +1,48 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\process\d7\FieldInstanceSettingsTest.
*/
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d7;
use Drupal\field\Plugin\migrate\process\d7\FieldSettings;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\Tests\migrate\Unit\MigrateTestCase;
/**
* @coversDefaultClass \Drupal\field\Plugin\migrate\process\d7\FieldSettings
* @group field
*/
class FieldSettingsTest extends MigrateTestCase {
/**
* Tests transformation of image field settings.
*
* @covers ::transform
*/
public function testTransformImageSettings() {
$migration = $this->getMock(MigrationInterface::class);
$plugin = new FieldSettings([], 'd7_field_settings', [], $migration);
$executable = $this->getMock(MigrateExecutableInterface::class);
$row = $this->getMockBuilder(Row::class)
->disableOriginalConstructor()
->getMock();
$row->expects($this->atLeastOnce())
->method('getSourceProperty')
->willReturnMap([
['settings', ['default_image' => NULL]],
['type', 'image'],
]);
$value = $plugin->transform([], $executable, $row, 'foo');
$this->assertInternalType('array', $value);
$this->assertSame('', $value['default_image']['uuid']);
}
}

View file

@ -0,0 +1,106 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d6\FieldInstancePerViewModeTest.
*/
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 {
// The plugin system is not working during unit testing so the source plugin
// class needs to be manually specified.
const PLUGIN_CLASS = 'Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode';
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
// The ID of the entity, can be any string.
'id' => 'view_mode_test',
'source' => array(
'plugin' => 'd6_field_instance_per_view_mode',
),
);
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();
}
}

View file

@ -0,0 +1,96 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d6\FieldInstanceTest.
*/
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();
}
}

View file

@ -0,0 +1,78 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d6\FieldTest.
*/
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_settings'] = serialize(array());
$this->databaseContents['content_node_field_instance'][0]['widget_type'] = 'text_textarea';
$this->databaseContents['content_node_field_instance'][0]['field_name'] = 'field_body';
parent::setUp();
}
}

View file

@ -0,0 +1,81 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d7\FieldInstancePerFormDisplayTest.
*/
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(),
),
);
/**
* 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();
}
}

View file

@ -0,0 +1,73 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d7\FieldInstancePerViewModeTest.
*/
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();
}
}

View file

@ -0,0 +1,81 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d7\FieldInstanceTest.
*/
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(
'type' => 'text_textarea_with_summary',
),
'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();
}
}

View file

@ -0,0 +1,101 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d7\FieldTest.
*/
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(
'type' => 'field_sql_storage',
'module' => 'field_sql_storage',
),
'module' => 'file',
'db_columns' => '',
'locked' => 0,
'entity_type' => 'node',
),
array(
'field_name' => 'field_file',
'type' => 'file',
'global_settings' => '',
'storage' => array(
'type' => 'field_sql_storage',
'module' => '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();
}
}

View file

@ -0,0 +1,83 @@
<?php
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d7\ViewModeTest.
*/
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' => '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: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: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: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();
}
}