Merge pull request #72 from pantheon-systems/remove-old

#71: Remove files no longer part of Drupal core in Drupal 8.0.0-beta15.
This commit is contained in:
Greg Anderson 2015-09-18 13:44:24 -07:00
commit cb25860f6a
101 changed files with 0 additions and 9459 deletions

View file

@ -1,43 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Core\ContentNegotiation.
*/
namespace Drupal\Core;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides content negotation based upon query parameters.
*/
class ContentNegotiation {
/**
* Gets the normalized type of a request.
*
* The normalized type is a short, lowercase version of the format, such as
* 'html', 'json' or 'atom'.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object from which to extract the content type.
*
* @return string
* The normalized type of a given request.
*/
public function getContentType(Request $request) {
// AJAX iframe uploads need special handling, because they contain a JSON
// response wrapped in <textarea>.
if ($request->get('ajax_iframe_upload', FALSE)) {
return 'iframeupload';
}
if ($request->query->has('_format')) {
return $request->query->get('_format');
}
// Do HTML last so that it always wins.
return 'html';
}
}

View file

@ -1,13 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Core\Database\Install\TaskException.
*/
namespace Drupal\Core\Database\Install;
/**
* Exception thrown if the database installer fails.
*/
class TaskException extends \RuntimeException { }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

View file

@ -1,15 +0,0 @@
id: d6_locale_settings
label: Drupal 6 locale configuration
migration_tags:
- Drupal 6
source:
plugin: variable
variables:
- locale_cache_strings
- locale_js_directory
process:
cache_strings: locale_cache_strings
'javascript/directory': locale_js_directory
destination:
plugin: config
config_name: locale.settings

View file

@ -1,17 +0,0 @@
id: d6_menu_settings
label: Drupal 6 menu configuration
migration_tags:
- Drupal 6
source:
plugin: variable
variables:
- menu_primary_links_source
- menu_secondary_links_source
- menu_override_parent_selector
process:
main_links: menu_primary_links_source
secondary_links: menu_secondary_links_source
override_parent_selector: menu_override_parent_selector
destination:
plugin: config
config_name: menu_ui.settings

View file

@ -1,21 +0,0 @@
# Schema for the migrate load plugins.
migrate.load.*:
type: migrate_load
label: 'Default load'
migrate.load.drupal_entity:
type: migrate_load
label: 'Default source'
mapping:
bundle_migration:
type: string
label: 'Bundle migration'
migrate.load.d6_term_node:
type: migrate_load
label: 'Default source'
mapping:
bundle_migration:
type: string
label: 'Bundle migration'

View file

@ -1,84 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigratePassword.
*/
namespace Drupal\migrate;
use Drupal\Core\Password\PasswordInterface;
/**
* Replaces the original 'password' service in order to prefix the MD5 re-hashed
* passwords with the 'U' flag. The new salted hash is recreated on first login
* similarly to the D6->D7 upgrade path.
*/
class MigratePassword implements PasswordInterface {
/**
* The original password service.
*
* @var \Drupal\Core\Password\PasswordInterface
*/
protected $originalPassword;
/**
* Indicates if MD5 password prefixing is enabled.
*/
protected $enabled = FALSE;
/**
* Builds the replacement password service class.
*
* @param \Drupal\Core\Password\PasswordInterface $original_password
* The password object.
*/
public function __construct(PasswordInterface $original_password) {
$this->originalPassword = $original_password;
}
/**
* {@inheritdoc}
*/
public function check($password, $hash) {
return $this->originalPassword->check($password, $hash);
}
/**
* {@inheritdoc}
*/
public function needsRehash($hash) {
return $this->originalPassword->needsRehash($hash);
}
/**
* {@inheritdoc}
*/
public function hash($password) {
$hash = $this->originalPassword->hash($password);
// Allow prefixing only if the service was asked to prefix. Check also if
// the $password pattern is conforming to a MD5 result.
if ($this->enabled && preg_match('/^[0-9a-f]{32}$/', $password)) {
$hash = 'U' . $hash;
}
return $hash;
}
/**
* Enables the MD5 password prefixing.
*/
public function enableMd5Prefixing() {
$this->enabled = TRUE;
}
/**
* Disables the MD5 password prefixing.
*/
public function disableMd5Prefixing() {
$this->enabled = FALSE;
}
}

View file

@ -1,30 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateServiceProvider.
*/
namespace Drupal\migrate;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
/**
* Swaps the original 'password' service in order to handle password hashing for
* user migrations that have passwords hashed to MD5.
*
* @see \Drupal\migrate\MigratePassword
* @see \Drupal\Core\Password\PhpassHashedPassword
*/
class MigrateServiceProvider implements ServiceModifierInterface {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
$container->setDefinition('password_original', $container->getDefinition('password'));
$container->setDefinition('password', $container->getDefinition('password_migrate'));
}
}

View file

@ -1,32 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\SourceEntityInterface.
*/
namespace Drupal\migrate\Plugin;
/**
* Interface for sources providing an entity.
*/
interface SourceEntityInterface {
/**
* Whether this migration has a bundle migration.
*
* @return bool
* TRUE when the bundle_migration key is required.
*/
public function bundleMigrationRequired();
/**
* The entity type id (user, node etc).
*
* This function is used when bundleMigrationRequired() is FALSE.
*
* @return string
* The entity type id.
*/
public function entityTypeId();
}

View file

@ -1,90 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityComment.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\State\StateInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* @MigrateDestination(
* id = "entity:comment"
* )
*/
class EntityComment extends EntityContentBase {
/**
* The state storage object.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Builds an comment entity destination.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param MigrationInterface $migration
* The migration.
* @param EntityStorageInterface $storage
* The storage for this entity type.
* @param array $bundles
* The list of bundles this entity type has.
* @param \Drupal\migrate\Plugin\MigratePluginManager $plugin_manager
* The migrate plugin manager.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager service.
* @param \Drupal\Core\State\StateInterface $state
* The state storage object.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
$entity_type = static::getEntityTypeId($plugin_id);
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity.manager')->getStorage($entity_type),
array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
$container->get('entity.manager'),
$container->get('state')
);
}
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
if ($row->isStub() && ($state = $this->state->get('comment.maintain_entity_statistics', 0))) {
$this->state->set('comment.maintain_entity_statistics', 0);
}
$return = parent::import($row, $old_destination_id_values);
if ($row->isStub() && $state) {
$this->state->set('comment.maintain_entity_statistics', $state);
}
return $return;
}
}

View file

@ -1,28 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityCommentType.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Row;
/**
* @MigrateDestination(
* id = "entity:comment_type"
* )
*/
class EntityCommentType extends EntityConfigBase {
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
$entity_ids = parent::import($row, $old_destination_id_values);
\Drupal::service('comment.manager')->addBodyField(reset($entity_ids));
return $entity_ids;
}
}

View file

@ -1,34 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityDateFormat.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Entity\EntityInterface;
/**
* @MigrateDestination(
* id = "entity:date_format"
* )
*/
class EntityDateFormat extends EntityConfigBase {
/**
* {@inheritdoc}
*
* @param \Drupal\Core\Datetime\DateFormatInterface $entity
* The date entity.
*/
protected function updateEntityProperty(EntityInterface $entity, array $parents, $value) {
if ($parents[0] == 'pattern') {
$entity->setPattern($value);
}
else {
parent::updateEntityProperty($entity, $parents, $value);
}
}
}

View file

@ -1,244 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityFile.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\StreamWrapper\LocalStream;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row;
use Drupal\migrate\MigrateException;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Every migration that uses this destination must have an optional
* dependency on the d6_file migration to ensure it runs first.
*
* @MigrateDestination(
* id = "entity:file"
* )
*/
class EntityFile extends EntityContentBase {
/**
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
*/
protected $streamWrapperManager;
/**
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, StreamWrapperManagerInterface $stream_wrappers, FileSystemInterface $file_system) {
$configuration += array(
'source_base_path' => '',
'source_path_property' => 'filepath',
'destination_path_property' => 'uri',
'move' => FALSE,
'urlencode' => FALSE,
);
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
$this->streamWrapperManager = $stream_wrappers;
$this->fileSystem = $file_system;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
$entity_type = static::getEntityTypeId($plugin_id);
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity.manager')->getStorage($entity_type),
array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
$container->get('entity.manager'),
$container->get('stream_wrapper_manager'),
$container->get('file_system')
);
}
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
$file = $row->getSourceProperty($this->configuration['source_path_property']);
$destination = $row->getDestinationProperty($this->configuration['destination_path_property']);
$source = $this->configuration['source_base_path'] . $file;
// Ensure the source file exists, if it's a local URI or path.
if ($this->isLocalUri($source) && !file_exists($source)) {
throw new MigrateException("File '$source' does not exist.");
}
// If the start and end file is exactly the same, there is nothing to do.
if ($this->isLocationUnchanged($source, $destination)) {
return parent::import($row, $old_destination_id_values);
}
$replace = $this->getOverwriteMode($row);
$success = $this->writeFile($source, $destination, $replace);
if (!$success) {
$dir = $this->getDirectory($destination);
if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
$success = $this->writeFile($source, $destination, $replace);
}
else {
throw new MigrateException("Could not create directory '$dir'");
}
}
if ($success) {
return parent::import($row, $old_destination_id_values);
}
else {
throw new MigrateException("File $source could not be copied to $destination.");
}
}
/**
* Tries to move or copy a file.
*
* @param string $source
* The source path or URI.
* @param string $destination
* The destination path or URI.
* @param integer $replace
* FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME.
*
* @return bool
* TRUE on success, FALSE on failure.
*/
protected function writeFile($source, $destination, $replace = FILE_EXISTS_REPLACE) {
if ($this->configuration['move']) {
return (boolean) file_unmanaged_move($source, $destination, $replace);
}
else {
$destination = file_destination($destination, $replace);
$source = $this->urlencode($source);
return @copy($source, $destination);
}
}
/**
* Determines how to handle file conflicts.
*
* @param \Drupal\migrate\Row $row
*
* @return integer
* Either FILE_EXISTS_REPLACE (default) or FILE_EXISTS_RENAME, depending
* on the current configuration.
*/
protected function getOverwriteMode(Row $row) {
if (!empty($this->configuration['rename'])) {
$entity_id = $row->getDestinationProperty($this->getKey('id'));
if ($entity_id && ($entity = $this->storage->load($entity_id))) {
return FILE_EXISTS_RENAME;
}
}
return FILE_EXISTS_REPLACE;
}
/**
* Returns the directory component of a URI or path.
*
* For URIs like public://foo.txt, the full physical path of public://
* will be returned, since a scheme by itself will trip up certain file
* API functions (such as file_prepare_directory()).
*
* @param string $uri
* The URI or path.
*
* @return string|false
* The directory component of the path or URI, or FALSE if it could not
* be determined.
*/
protected function getDirectory($uri) {
$dir = $this->fileSystem->dirname($uri);
if (substr($dir, -3) == '://') {
return $this->fileSystem->realpath($dir);
}
else {
return $dir;
}
}
/**
* Returns if the source and destination URIs represent identical paths.
* If either URI is a remote stream, will return FALSE.
*
* @param string $source
* The source URI.
* @param string $destination
* The destination URI.
*
* @return bool
* TRUE if the source and destination URIs refer to the same physical path,
* otherwise FALSE.
*/
protected function isLocationUnchanged($source, $destination) {
if ($this->isLocalUri($source) && $this->isLocalUri($destination)) {
return $this->fileSystem->realpath($source) === $this->fileSystem->realpath($destination);
}
else {
return FALSE;
}
}
/**
* Returns if the given URI or path is considered local.
*
* A URI or path is considered local if it either has no scheme component,
* or the scheme is implemented by a stream wrapper which extends
* \Drupal\Core\StreamWrapper\LocalStream.
*
* @param string $uri
* The URI or path to test.
*
* @return bool
*/
protected function isLocalUri($uri) {
$scheme = $this->fileSystem->uriScheme($uri);
return $scheme === FALSE || $this->streamWrapperManager->getViaScheme($scheme) instanceof LocalStream;
}
/**
* Urlencode all the components of a remote filename.
*
* @param string $filename
* The filename of the file to be urlencoded.
*
* @return string
* The urlencoded filename.
*/
protected function urlencode($filename) {
// Only apply to a full URL
if ($this->configuration['urlencode'] && strpos($filename, '://')) {
$components = explode('/', $filename);
foreach ($components as $key => $component) {
$components[$key] = rawurlencode($component);
}
$filename = implode('/', $components);
// Actually, we don't want certain characters encoded
$filename = str_replace('%3A', ':', $filename);
$filename = str_replace('%3F', '?', $filename);
$filename = str_replace('%26', '&', $filename);
}
return $filename;
}
}

View file

@ -1,31 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityNodeType.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Row;
/**
* @MigrateDestination(
* id = "entity:node_type"
* )
*/
class EntityNodeType extends EntityConfigBase {
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
$entity_ids = parent::import($row, $old_destination_id_values);
if ($row->getDestinationProperty('create_body')) {
$node_type = $this->storage->load(reset($entity_ids));
node_add_body_field($node_type, $row->getDestinationProperty('create_body_label'));
}
return $entity_ids;
}
}

View file

@ -1,101 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityUser.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Password\PasswordInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigratePassword;
use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* @MigrateDestination(
* id = "entity:user"
* )
*/
class EntityUser extends EntityContentBase {
/**
* The password service class.
*
* @var \Drupal\Core\Password\PasswordInterface
*/
protected $password;
/**
* Builds an user entity destination.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param MigrationInterface $migration
* The migration.
* @param EntityStorageInterface $storage
* The storage for this entity type.
* @param array $bundles
* The list of bundles this entity type has.
* @param \Drupal\migrate\Plugin\MigratePluginManager $plugin_manager
* The migrate plugin manager.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager service.
* @param \Drupal\Core\Password\PasswordInterface $password
* The password service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, PasswordInterface $password) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
if (isset($configuration['md5_passwords'])) {
$this->password = $password;
}
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
$entity_type = static::getEntityTypeId($plugin_id);
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity.manager')->getStorage($entity_type),
array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
$container->get('entity.manager'),
$container->get('password')
);
}
/**
* {@inheritdoc}
* @throws \Drupal\migrate\MigrateException
*/
public function import(Row $row, array $old_destination_id_values = array()) {
if ($this->password) {
if ($this->password instanceof MigratePassword) {
$this->password->enableMd5Prefixing();
}
else {
throw new MigrateException('Password service has been altered by another module, aborting.');
}
}
$ids = parent::import($row, $old_destination_id_values);
if ($this->password) {
$this->password->disableMd5Prefixing();
}
return $ids;
}
}

View file

@ -1,94 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\UserData.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\user\UserData as UserDataStorage;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
/**
* @MigrateDestination(
* id = "user_data"
* )
*/
class UserData extends DestinationBase implements ContainerFactoryPluginInterface {
/**
* @var \Drupal\user\UserData
*/
protected $userData;
/**
* Builds an user data entity destination.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* The migration.
* @param \Drupal\user\UserData $user_data
* The user data service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, UserDataStorage $user_data) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
$this->userData = $user_data;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('user.data')
);
}
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
$uid = $row->getDestinationProperty('uid');
$module = $row->getDestinationProperty('module');
$key = $row->getDestinationProperty('key');
$this->userData->set($module, $uid, $key, $row->getDestinationProperty('settings'));
return [$uid, $module, $key];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['uid']['type'] = 'integer';
$ids['module']['type'] = 'string';
$ids['key']['type'] = 'string';
return $ids;
}
/**
* {@inheritdoc}
*/
public function fields(MigrationInterface $migration = NULL) {
return [
'uid' => 'The user id.',
'module' => 'The module name responsible for the settings.',
'key' => 'The setting key to save under.',
'settings' => 'The settings to save.',
];
}
}

View file

@ -1,295 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\EntityFileTest.
*/
namespace Drupal\migrate\Tests;
use Drupal\Core\Site\Settings;
use Drupal\migrate\Row;
use Drupal\migrate\Plugin\migrate\destination\EntityFile;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\migrate\MigrateException;
use Drupal\simpletest\KernelTestBase;
/**
* Tests the entity file destination plugin.
*
* @group migrate
*/
class EntityFileTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = array('system', 'entity_test', 'user', 'file');
/**
* @var \Drupal\migrate\Tests\TestEntityFile $destination
*/
protected $destination;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->destination = new TestEntityFile([]);
$this->destination->streamWrapperManager = \Drupal::getContainer()->get('stream_wrapper_manager');
$this->destination->fileSystem = \Drupal::getContainer()->get('file_system');
$this->installEntitySchema('file');
file_put_contents('/tmp/test-file.jpg', '');
}
/**
* Test successful imports/copies.
*/
public function testSuccessfulCopies() {
foreach ($this->localFileDataProvider() as $data) {
list($row_values, $destination_path, $expected, $source_base_path) = $data;
$this->doImport($row_values, $destination_path, $source_base_path);
$message = $expected ? sprintf('File %s exists', $destination_path) : sprintf('File %s does not exist', $destination_path);
$this->assertIdentical($expected, is_file($destination_path), $message);
}
}
/**
* The data provider for testing the file destination.
*
* @return array
* An array of file permutations to test.
*/
protected function localFileDataProvider() {
global $base_url;
return [
// Test a local to local copy.
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://file1.jpg', TRUE, DRUPAL_ROOT . '/'],
// Test a temporary file using an absolute path.
[['filepath' => '/tmp/test-file.jpg'], 'temporary://test.jpg', TRUE, ''],
// Test a temporary file using a relative path.
[['filepath' => 'test-file.jpg'], 'temporary://core/modules/simpletest/files/test.jpg', TRUE, '/tmp/'],
// Test a remote path to local.
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://remote-file.jpg', TRUE, $base_url . '/'],
// Test a remote path to local inside a folder that doesn't exist.
[['filepath' => 'core/modules/simpletest/files/image-test.jpg'], 'public://folder/remote-file.jpg', TRUE, DRUPAL_ROOT . '/'],
];
}
/**
* Test that non-existent files throw an exception.
*/
public function testNonExistentSourceFile() {
$destination = '/non/existent/file';
try {
// If this test passes, doImport() will raise a MigrateException and
// we'll never reach fail().
$this->doImport(['filepath' => $destination], 'public://wontmatter.jpg');
$this->fail('Expected Drupal\migrate\MigrateException when importing ' . $destination);
}
catch (MigrateException $e) {
$this->assertIdentical($e->getMessage(), "File '$destination' does not exist.");
}
}
/**
* Tests various invocations of the writeFile() method.
*/
public function testWriteFile() {
$plugin = $this->destination;
$method = new \ReflectionMethod($plugin, 'writeFile');
$method->setAccessible(TRUE);
touch('temporary://baz.txt');
// Moving an actual file should return TRUE.
$plugin->configuration['move'] = TRUE;
$this->assertTrue($method->invoke($plugin, 'temporary://baz.txt', 'public://foo.txt'));
// Trying to move a non-existent file should return FALSE.
$this->assertFalse($method->invoke($plugin, 'temporary://invalid.txt', 'public://invalid.txt'));
// Copying over a file that already exists should replace the existing file.
$plugin->configuration['move'] = FALSE;
touch('temporary://baz.txt');
$this->assertTrue($method->invoke($plugin, 'temporary://baz.txt', 'public://foo.txt'));
// Copying over a file that already exists should rename the resulting file
// if FILE_EXISTS_RENAME is specified.
$method->invoke($plugin, 'temporary://baz.txt', 'public://foo.txt', FILE_EXISTS_RENAME);
$this->assertTrue(file_exists('public://foo_0.txt'));
// Trying to copy a non-existent file should return FALSE.
$this->assertFalse($method->invoke($plugin, 'temporary://invalid.txt', 'public://invalid.txt'));
}
/**
* Tests various invocations of the getOverwriteMode() method.
*/
public function testGetOverwriteMode() {
$plugin = $this->destination;
$method = new \ReflectionMethod($plugin, 'getOverwriteMode');
$method->setAccessible(TRUE);
$row = new Row([], []);
// If the plugin is not configured to rename the destination file, we should
// always get FILE_EXISTS_REPLACE.
$this->assertIdentical(FILE_EXISTS_REPLACE, $method->invoke($plugin, $row));
// When the plugin IS configured to rename the destination file, it should
// return FILE_EXISTS_RENAME if the destination entity already exists,
// and FILE_EXISTS_REPLACE otherwise.
$plugin->configuration['rename'] = TRUE;
$plugin->storage = \Drupal::entityManager()->getStorage('file');
/** @var \Drupal\file\FileInterface $file */
$file = $plugin->storage->create();
touch('public://foo.txt');
$file->setFileUri('public://foo.txt');
$file->save();
$row->setDestinationProperty($plugin->storage->getEntityType()->getKey('id'), $file->id());
$this->assertIdentical(FILE_EXISTS_RENAME, $method->invoke($plugin, $row));
unlink('public://foo.txt');
}
/**
* Tests various invocations of the getDirectory() method.
*/
public function testGetDirectory() {
$plugin = $this->destination;
$method = new \ReflectionMethod($plugin, 'getDirectory');
$method->setAccessible(TRUE);
$this->assertEqual('public://foo', $method->invoke($plugin, 'public://foo/baz.txt'));
$this->assertEqual('/path/to', $method->invoke($plugin, '/path/to/foo.txt'));
// A directory like public:// (no path) needs to resolve to a physical path.
$fs = \Drupal::getContainer()->get('file_system');
$this->assertEqual($fs->realpath(Settings::get('file_public_path')), $method->invoke($plugin, 'public://foo.txt'));
}
/**
* Tests various invocations of the isLocationUnchanged() method.
*/
public function testIsLocationUnchanged() {
$plugin = $this->destination;
$method = new \ReflectionMethod($plugin, 'isLocationUnchanged');
$method->setAccessible(TRUE);
$public_dir = Settings::get('file_public_path');
// Due to the limitations of realpath(), the source file must exist.
touch('public://foo.txt');
$this->assertTrue($method->invoke($plugin, $public_dir . '/foo.txt', 'public://foo.txt'));
unlink('public://foo.txt');
$temporary_file = '/tmp/foo.txt';
touch($temporary_file);
$this->assertTrue($method->invoke($plugin, $temporary_file, 'temporary://foo.txt'));
unlink($temporary_file);
}
/**
* Tests various invocations of the isLocalUri() method.
*/
public function testIsLocalUri() {
$plugin = $this->destination;
$method = new \ReflectionMethod($plugin, 'isLocalUri');
$method->setAccessible(TRUE);
$this->assertTrue($method->invoke($plugin, 'public://foo.txt'));
$this->assertTrue($method->invoke($plugin, 'public://path/to/foo.txt'));
$this->assertTrue($method->invoke($plugin, 'temporary://foo.txt'));
$this->assertTrue($method->invoke($plugin, 'temporary://path/to/foo.txt'));
$this->assertTrue($method->invoke($plugin, 'foo.txt'));
$this->assertTrue($method->invoke($plugin, '/path/to/files/foo.txt'));
$this->assertTrue($method->invoke($plugin, 'relative/path/to/foo.txt'));
$this->assertFalse($method->invoke($plugin, 'http://www.example.com/foo.txt'));
}
/**
* Do an import using the destination.
*
* @param array $row_values
* An array of row values.
* @param string $destination_path
* The destination path to copy to.
* @param string $source_base_path
* The source base path.
* @return array
* An array of saved entities ids.
*
* @throws \Drupal\migrate\MigrateException
*/
protected function doImport($row_values, $destination_path, $source_base_path = '') {
$row = new Row($row_values, []);
$row->setDestinationProperty('uri', $destination_path);
$this->destination->configuration['source_base_path'] = $source_base_path;
// Importing asserts there are no errors, then we just check the file has
// been copied into place.
return $this->destination->import($row, array());
}
}
class TestEntityFile extends EntityFile {
/**
* This is needed to be passed to $this->save().
*
* @var \Drupal\Core\Entity\ContentEntityInterface
*/
public $mockEntity;
/**
* Make this public for easy writing during tests.
*
* @var array
*/
public $configuration;
/**
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
public $storage;
/**
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
*/
public $streamWrapperManager;
/**
* @var \Drupal\Core\File\FileSystemInterface
*/
public $fileSystem;
public function __construct($configuration) {
$configuration += array(
'source_base_path' => '',
'source_path_property' => 'filepath',
'destination_path_property' => 'uri',
'move' => FALSE,
'urlencode' => FALSE,
);
$this->configuration = $configuration;
// We need a mock entity to be passed to save to prevent strict exceptions.
$this->mockEntity = EntityTest::create();
}
/**
* {@inheritdoc}
*/
protected function getEntity(Row $row, array $old_destination_id_values) {
return $this->mockEntity;
}
/**
* {@inheritdoc}
*/
protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {}
}

View file

@ -1,85 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate\Unit\process\MigrationTest.
*/
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\migrate\process\Migration;
/**
* Tests the migration process plugin.
*
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\Migration
* @group migrate
*/
class MigrationTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->migrationConfiguration = [
'id' => 'test',
'process' => [],
'source' => [],
];
parent::setUp();
}
/**
* Assert that exceptions during import are logged.
* @expectedException \Drupal\migrate\MigrateSkipRowException
* @covers ::transform
*/
public function testSaveOnException() {
// A bunch of mock objects to get thing working
$migration = $this->getMigration();
$migration_source = $this->getMock('\Drupal\migrate\Plugin\MigrateSourceInterface');
$migration_source->expects($this->once())
->method('getIds')
->willReturn([]);
$migration->expects($this->once())
->method('getSourcePlugin')
->willReturn($migration_source);
$migration_destination = $this->getMock('\Drupal\migrate\Plugin\MigrateDestinationInterface');
$migration->expects($this->once())
->method('getDestinationPlugin')
->willReturn($migration_destination);
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('loadMultiple')
->willReturn([
'id' => $migration
]);
$manager = $this->getMockBuilder('\Drupal\migrate\Plugin\MigratePluginManager')
->disableOriginalConstructor()
->getMock();
// Throw an exception during import so we can log it.
$migration_destination->expects($this->once())
->method('import')
->willThrowException(new MigrateException());
// Build our migration plugin.
$plugin = new Migration(['migration' => []],
'migration', // ?
[],
$migration,
$storage,
$manager);
// Assert that we log exceptions thrown during the import.
$this->migrateExecutable->expects($this->once())
->method('saveMessage');
$plugin->transform('value', $this->migrateExecutable, $this->row, 'prop');
}
}

View file

@ -1,236 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\MigrationStorage.
*/
namespace Drupal\migrate_drupal;
use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\migrate\Plugin\migrate\source\SourcePluginBase;
use Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface;
use Drupal\migrate\MigrationStorage as BaseMigrationStorage;
use Drupal\migrate\Plugin\MigratePluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Storage for migration entities.
*/
class MigrationStorage extends BaseMigrationStorage {
/**
* A cached array of cck field plugins.
*
* @var array
*/
protected $cckFieldPlugins;
/**
* @var \Drupal\migrate_drupal\Plugin\MigratePluginManager
*/
protected $cckPluginManager;
/**
* Constructs a MigrationStorage object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
* @param \Drupal\Component\Uuid\UuidInterface $uuid_service
* The UUID service.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\migrate_drupal\Plugin\MigratePluginManager
* The cckfield plugin manager.
*/
public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, MigratePluginManager $cck_plugin_manager) {
parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager);
$this->cckPluginManager = $cck_plugin_manager;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('config.factory'),
$container->get('uuid'),
$container->get('language_manager'),
$container->get('plugin.manager.migrate.cckfield')
);
}
/**
* {@inheritdoc}
*/
public function loadMultiple(array $ids = NULL) {
$ids_to_load = array();
$dynamic_ids = array();
if (isset($ids)) {
foreach ($ids as $id) {
// Evaluate whether or not this migration is dynamic in the form of
// migration_id:* to load all the additional migrations.
if (($n = strpos($id, ':')) !== FALSE) {
$base_id = substr($id, 0, $n);
$ids_to_load[] = $base_id;
// Get the ids of the additional migrations.
$sub_id = substr($id, $n + 1);
if ($sub_id == '*') {
// If the id of the additional migration is '*', get all of them.
$dynamic_ids[$base_id] = NULL;
}
elseif (!isset($dynamic_ids[$base_id]) || is_array($dynamic_ids[$base_id])) {
$dynamic_ids[$base_id][] = $sub_id;
}
}
else {
$ids_to_load[] = $id;
}
}
$ids = array_flip($ids);
}
else {
$ids_to_load = NULL;
}
/** @var \Drupal\migrate_drupal\Entity\MigrationInterface[] $entities */
$entities = parent::loadMultiple($ids_to_load);
if (!isset($ids)) {
// Changing the array being foreach()'d is not a good idea.
$return = array();
foreach ($entities as $entity_id => $entity) {
if ($plugin = $entity->getLoadPlugin()) {
$new_entities = $plugin->loadMultiple($this);
$this->postLoad($new_entities);
$this->getDynamicIds($dynamic_ids, $new_entities);
$return += $new_entities;
}
else {
$return[$entity_id] = $entity;
}
}
$entities = $return;
}
else {
foreach ($dynamic_ids as $base_id => $sub_ids) {
$entity = $entities[$base_id];
if ($plugin = $entity->getLoadPlugin()) {
unset($entities[$base_id]);
$new_entities = $plugin->loadMultiple($this, $sub_ids);
$this->postLoad($new_entities);
if (!isset($sub_ids)) {
unset($dynamic_ids[$base_id]);
$this->getDynamicIds($dynamic_ids, $new_entities);
}
$entities += $new_entities;
}
}
}
// Allow modules providing cck field plugins to alter the required
// migrations to assist with the migration a custom field type.
$this->applyCckFieldProcessors($entities);
// Build an array of dependencies and set the order of the migrations.
return $this->buildDependencyMigration($entities, $dynamic_ids);
}
/**
* Extract the dynamic id mapping from entities loaded by plugin.
*
* @param array $dynamic_ids
* Get the dynamic migration ids.
* @param array $entities
* An array of entities.
*/
protected function getDynamicIds(array &$dynamic_ids, array $entities) {
foreach (array_keys($entities) as $new_id) {
list($base_id, $sub_id) = explode(':', $new_id, 2);
$dynamic_ids[$base_id][] = $sub_id;
}
}
/**
* {@inheritdoc}
*/
public function save(EntityInterface $entity) {
if (strpos($entity->id(), ':') !== FALSE) {
throw new EntityStorageException("Dynamic migration '{$entity->id()}' can't be saved");
}
return parent::save($entity);
}
/**
* Allow any field type plugins to adjust the migrations as required.
*
* @param \Drupal\migrate\Entity\Migration[] $entities
* An array of migration entities.
*/
protected function applyCckFieldProcessors(array $entities) {
$method_map = $this->getMigrationPluginMethodMap();
foreach ($entities as $entity_id => $migration) {
// Allow field plugins to process the required migrations.
if (isset($method_map[$entity_id])) {
$method = $method_map[$entity_id];
$cck_plugins = $this->getCckFieldPlugins();
array_walk($cck_plugins, function ($plugin) use ($method, $migration) {
$plugin->$method($migration);
});
}
// If this is a CCK bundle migration, allow the cck field plugins to add
// any field type processing.
$source_plugin = $migration->getSourcePlugin();
if ($source_plugin instanceof CckFieldMigrateSourceInterface && strpos($entity_id, SourcePluginBase::DERIVATIVE_SEPARATOR)) {
$plugins = $this->getCckFieldPlugins();
foreach ($source_plugin->fieldData() as $field_name => $data) {
if (isset($plugins[$data['type']])) {
$plugins[$data['type']]->processCckFieldValues($migration, $field_name, $data);
}
}
}
}
}
/**
* Get an array of loaded cck field plugins.
*
* @return \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[]
* An array of cck field process plugins.
*/
protected function getCckFieldPlugins() {
if (!isset($this->cckFieldPlugins)) {
$this->cckFieldPlugins = [];
foreach ($this->cckPluginManager->getDefinitions() as $definition) {
$this->cckFieldPlugins[$definition['id']] = $this->cckPluginManager->createInstance($definition['id']);
}
}
return $this->cckFieldPlugins;
}
/**
* Provides a map between migration ids and the cck field plugin method.
*
* @return array
* The map between migrations and cck field plugin processing methods.
*/
protected function getMigrationPluginMethodMap() {
return [
'd6_field' => 'processField',
'd6_field_instance' => 'processFieldInstance',
'd6_field_instance_widget_settings' => 'processFieldWidget',
'd6_field_formatter_settings' => 'processFieldFormatter',
];
}
}

View file

@ -1,24 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface.
*/
namespace Drupal\migrate_drupal\Plugin;
use Drupal\migrate\Plugin\MigrateSourceInterface;
/**
* Defines an interface for cck field sources that need per type processing.
*/
interface CckFieldMigrateSourceInterface extends MigrateSourceInterface {
/**
* Field data used for determining the field type in the LoadEntity
*
* @return mixed
* An array of cck field data.
*/
public function fieldData();
}

View file

@ -1,45 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\MigrateLoadInterface.
*/
namespace Drupal\migrate_drupal\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Core\Entity\EntityStorageInterface;
/**
* Defines an interface for migration load plugins.
*
* @see \Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity
*
* @ingroup migration
*/
interface MigrateLoadInterface extends PluginInspectionInterface {
/**
* Load an additional migration.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The migration storage.
* @param string $sub_id
* For example, when loading d6_node:article, this will be article.
* @return \Drupal\migrate\Entity\MigrationInterface
*/
public function load(EntityStorageInterface $storage, $sub_id);
/**
* Load additional migrations.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The migration storage.
* @param array $sub_ids
* For example, when loading d6_node:article, sub_id will be article.
* If NULL then load all sub-migrations.
* @return \Drupal\migrate\Entity\MigrationInterface[]
*/
public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL);
}

View file

@ -1,55 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\FileField.
*/
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
use Drupal\migrate\Entity\MigrationInterface;
/**
* @PluginID("filefield")
*/
class FileField extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldWidgetMap() {
return [
'filefield_widget' => 'file_generic',
];
}
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return [
'default' => 'file_default',
'url_plain' => 'file_url_plain',
'path_plain' => 'file_url_plain',
'image_plain' => 'image',
'image_nodelink' => 'image',
'image_imagelink' => 'image',
];
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'd6_cck_file',
'source' => [
$field_name,
$field_name . '_list',
$field_name . '_data',
],
];
$migration->mergeProcessOfProperty($field_name, $process);
}
}

View file

@ -1,50 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\LinkField.
*/
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
use Drupal\migrate\Entity\MigrationInterface;
/**
* @PluginID("link")
*/
class LinkField extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
// See d6_field_formatter_settings.yml and CckFieldPluginBase
// processFieldFormatter().
return [
'default' => 'link',
'plain' => 'link',
'absolute' => 'link',
'title_plain' => 'link',
'url' => 'link',
'short' => 'link',
'label' => 'link',
'separate' => 'link_separate',
];
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'd6_cck_link',
'source' => [
$field_name,
$field_name . '_title',
$field_name . '_attributes',
],
];
$migration->mergeProcessOfProperty($field_name, $process);
}
}

View file

@ -1,71 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\TextField.
*/
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
use Drupal\migrate\Entity\MigrationInterface;
/**
* @PluginID("text")
*/
class TextField extends CckFieldPluginBase {
/**
* {@inheritdoc}
*/
public function getFieldWidgetMap() {
return [
'text_textfield' => 'text_textfield',
];
}
/**
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
return [
'default' => 'text_default',
'trimmed' => 'text_trimmed',
'plain' => 'basic_string',
];
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
// The data is stored differently depending on whether we're using
// db storage.
$value_key = $data['db_storage'] ? $field_name : "$field_name/value";
$format_key = $data['db_storage'] ? $field_name . '_format' : "$field_name/format" ;
$migration->setProcessOfProperty("$field_name/value", $value_key);
// See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
// signature_format for an example of the YAML that represents this
// process array.
$process = [
[
'plugin' => 'static_map',
'bypass' => TRUE,
'source' => $format_key,
'map' => [0 => NULL]
],
[
'plugin' => 'skip_on_empty',
'method' => 'process',
],
[
'plugin' => 'migration',
'migration' => 'd6_filter_format',
'source' => $format_key,
],
];
$migration->mergeProcessOfProperty("$field_name/format", $process);
}
}

View file

@ -1,84 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCckFieldRevisionTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\node\Tests\Migrate\d6\MigrateNodeTestBase;
/**
* CCK field revision migration.
*
* @group migrate_drupal
*/
class MigrateCckFieldRevisionTest extends MigrateNodeTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('field', 'filter', 'node', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test',
'type' => 'text',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_two',
'type' => 'integer',
'cardinality' => -1,
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_two',
'bundle' => 'story',
))->save();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_cck_field_values' => array(
array(array(1), array(1)),
),
'd6_node' => array(
array(array(1), array(1)),
array(array(2), array(2)),
),
'd6_node_revision' => array(
array(array(1), array(1)),
),
);
$this->prepareMigrations($id_mappings);
$migrations = entity_load_multiple('migration', array('d6_cck_field_revision:*'));
foreach ($migrations as $migration) {
$executable = new MigrateExecutable($migration, $this);
$executable->import();
}
}
/**
* Test CCK revision migration from Drupal 6 to 8.
*/
public function testCckFieldRevision() {
$node = \Drupal::entityManager()->getStorage('node')->loadRevision(2);
$this->assertIdentical('1', $node->id(), 'Node 1 loaded.');
$this->assertIdentical('2', $node->getRevisionId(), 'Node 1 revision 2loaded.');
}
}

View file

@ -1,210 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCckFieldValuesTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\node\Entity\Node;
use Drupal\node\Tests\Migrate\d6\MigrateNodeTestBase;
/**
* CCK field content migration.
*
* @group migrate_drupal
*/
class MigrateCckFieldValuesTest extends MigrateNodeTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'text', 'filter', 'link', 'file');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('file');
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test',
'type' => 'text',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_two',
'type' => 'integer',
'cardinality' => -1,
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_two',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_three',
'type' => 'decimal',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_three',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_integer_selectlist',
'type' => 'integer',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_integer_selectlist',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_exclude_unset',
'type' => 'text',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_exclude_unset',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_multivalue',
'type' => 'decimal',
'precision' => '10',
'scale' => '2',
'cardinality' => -1,
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_multivalue',
'bundle' => 'test_planet',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_identical1',
'type' => 'integer',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_identical1',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_identical2',
'type' => 'integer',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_identical2',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_link',
'type' => 'link',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_link',
'bundle' => 'story',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_filefield',
'type' => 'file',
))->save();
entity_create('field_config', array(
'entity_type' => 'node',
'field_name' => 'field_test_filefield',
'bundle' => 'story',
))->save();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_field_formatter_settings' => array(
array(array('page', 'default', 'node', 'field_test'), array('node', 'page', 'default', 'field_test')),
),
'd6_field_instance_widget_settings' => array(
array(array('page', 'field_test'), array('node', 'page', 'default', 'test')),
),
'd6_node' => array(
array(array(1), array(1)),
array(array(2), array(2)),
array(array(3), array(3)),
),
);
$this->prepareMigrations($id_mappings);
$migrations = entity_load_multiple('migration', array('d6_cck_field_values:*'));
foreach ($migrations as $migration) {
$executable = new MigrateExecutable($migration, $this);
$executable->import();
}
}
/**
* Test CCK migration from Drupal 6 to 8.
*/
public function testCckFields() {
$node = Node::load(1);
$this->assertIdentical('This is a shared text field', $node->field_test->value);
$this->assertIdentical('filtered_html', $node->field_test->format);
$this->assertIdentical('10', $node->field_test_two->value);
$this->assertIdentical('20', $node->field_test_two[1]->value);
$this->assertIdentical('42.42', $node->field_test_three->value, 'Single field second value is correct.');
$this->assertIdentical('3412', $node->field_test_integer_selectlist[0]->value);
$this->assertIdentical('1', $node->field_test_identical1->value, 'Integer value is correct');
$this->assertIdentical('1', $node->field_test_identical2->value, 'Integer value is correct');
$this->assertIdentical('This is a field with exclude unset.', $node->field_test_exclude_unset->value, 'Field with exclude unset is correct.');
// Test that link fields are migrated.
$this->assertIdentical('https://www.drupal.org/project/drupal', $node->field_test_link->uri);
$this->assertIdentical('Drupal project page', $node->field_test_link->title);
$this->assertIdentical(['target' => '_blank'], $node->field_test_link->options['attributes']);
// Test the file field meta.
$this->assertIdentical('desc', $node->field_test_filefield->description);
$this->assertIdentical('5', $node->field_test_filefield->target_id);
$planet_node = Node::load(3);
$value_1 = $planet_node->field_multivalue->value;
$value_2 = $planet_node->field_multivalue[1]->value;
// SQLite does not support scales for float data types so we need to convert
// the value manually.
if ($this->container->get('database')->driver() == 'sqlite') {
$value_1 = sprintf('%01.2f', $value_1);
$value_2 = sprintf('%01.2f', $value_2);
}
$this->assertIdentical('33.00', $value_1);
$this->assertIdentical('44.00', $value_2);
}
}

View file

@ -1,96 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\comment\Tests\CommentTestTrait;
/**
* Upgrade comments.
*
* @group migrate_drupal
*/
class MigrateCommentTest extends MigrateDrupal6TestBase {
use CommentTestTrait;
static $modules = array('node', 'comment', 'text', 'filter');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('comment');
$this->installConfig(['node', 'comment']);
entity_create('node_type', array('type' => 'page'))->save();
entity_create('node_type', array('type' => 'story'))->save();
$this->addDefaultCommentField('node', 'story');
$this->container->get('entity.manager')->getStorage('comment_type')->create(array(
'id' => 'comment_no_subject',
'label' => 'comment_no_subject',
'target_entity_type_id' => 'node',
))->save();
\Drupal::service('comment.manager')->addBodyField('comment_no_subject');
$node = entity_create('node', array(
'type' => 'story',
'nid' => 1,
));
$node->enforceIsNew();
$node->save();
$id_mappings = array(
'd6_filter_format' => array(array(array(1), array('filtered_html'))),
'd6_node' => array(array(array(1), array(1))),
'd6_user' => array(array(array(0), array(0))),
'd6_comment_type' => array(array(array('comment'), array('comment_no_subject'))),
'd6_comment_entity_display' => array(array(array('story'), array('node', 'story', 'default', 'comment'))),
'd6_comment_entity_form_display' => array(array(array('story'), array('node', 'story', 'default', 'comment'))),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps([
'Node.php',
'NodeRevisions.php',
'ContentTypeStory.php',
'ContentTypeTestPlanet.php',
'Variable.php',
'NodeType.php',
'Comments.php',
]);
$this->executeMigration('d6_comment');
}
/**
* Tests the Drupal 6 to Drupal 8 comment migration.
*/
public function testComments() {
/** @var \Drupal\Core\Entity\EntityStorageInterface $comment_storage */
$comment_storage = $this->container->get('entity.manager')->getStorage('comment');
/** @var \Drupal\comment\CommentInterface $comment */
$comment = $comment_storage->load(1);
$this->assertIdentical('The first comment.', $comment->getSubject());
$this->assertIdentical('The first comment body.', $comment->comment_body->value);
$this->assertIdentical('filtered_html', $comment->comment_body->format);
$this->assertIdentical('0', $comment->pid->target_id);
$this->assertIdentical('1', $comment->getCommentedEntityId());
$this->assertIdentical('node', $comment->getCommentedEntityTypeId());
$this->assertIdentical('en', $comment->language()->getId());
$this->assertIdentical('comment_no_subject', $comment->getTypeId());
$comment = $comment_storage->load(2);
$this->assertIdentical('The response to the second comment.', $comment->subject->value);
$this->assertIdentical('3', $comment->pid->target_id);
$comment = $comment_storage->load(3);
$this->assertIdentical('The second comment.', $comment->subject->value);
$this->assertIdentical('0', $comment->pid->target_id);
}
}

View file

@ -1,45 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentTypeTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\comment\Entity\CommentType;
/**
* Upgrade comment type.
*
* @group migrate_drupal
*/
class MigrateCommentTypeTest extends MigrateDrupal6TestBase {
static $modules = array('node', 'comment', 'text', 'filter');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installEntitySchema('comment');
$this->installConfig(['node', 'comment']);
$this->loadDumps(['Variable.php', 'NodeType.php']);
$this->executeMigration('d6_comment_type');
}
/**
* Tests the Drupal 6 to Drupal 8 comment type migration.
*/
public function testCommentType() {
$comment_type = CommentType::load('comment');
$this->assertIdentical('node', $comment_type->getTargetEntityTypeId());
$comment_type = CommentType::load('comment_no_subject');
$this->assertIdentical('node', $comment_type->getTargetEntityTypeId());
}
}

View file

@ -1,70 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentVariableDisplayBase.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Base class for Drupal 6 comment variables to Drupal 8 entity display tests.
*/
abstract class MigrateCommentVariableDisplayBase extends MigrateDrupal6TestBase {
/**
* The ID of migration to run.
*
* This constant needs to be set in the concrete class in order for the test
* to work.
*/
const MIGRATION = '';
/**
* Modules to enable.
*
* @var array
*/
static $modules = array('comment', 'node');
/**
* The node types being tested.
*
* @var array
*/
protected $types = array('page', 'story', 'article');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'comment',
'type' => 'comment',
'translatable' => '0',
))->save();
foreach ($this->types as $type) {
entity_create('node_type', array('type' => $type))->save();
entity_create('field_config', array(
'label' => 'Comments',
'description' => '',
'field_name' => 'comment',
'entity_type' => 'node',
'bundle' => $type,
'required' => 1,
))->save();
}
$id_mappings = array(
'd6_comment_field_instance' => array(
array(array('page'), array('node', 'comment', 'page')),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps(['Variable.php', 'NodeType.php']);
$this->executeMigration(static::MIGRATION);
}
}

View file

@ -1,38 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentVariableEntityDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Upgrade comment variables to entity.display.node.*.default.yml.
*
* @group migrate_drupal
*/
class MigrateCommentVariableEntityDisplayTest extends MigrateCommentVariableDisplayBase {
/**
* The migration to run.
*/
const MIGRATION = 'd6_comment_entity_display';
/**
* The node types being used.
*/
protected $types = array('page', 'story', 'article');
/**
* Tests comment variables migrated into an entity display.
*/
public function testCommentEntityDisplay() {
foreach ($this->types as $type) {
$component = entity_get_display('node', $type, 'default')->getComponent('comment');
$this->assertIdentical('hidden', $component['label']);
$this->assertIdentical('comment_default', $component['type']);
$this->assertIdentical(20, $component['weight']);
}
}
}

View file

@ -1,60 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentVariableEntityFormDisplaySubjectTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Upgrade comment subject variable to core.entity_form_display.comment.*.default.yml
*
* @group migrate_drupal
*/
class MigrateCommentVariableEntityFormDisplaySubjectTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('comment', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
foreach (['comment', 'comment_no_subject'] as $comment_type) {
entity_create('comment_type', array(
'id' => $comment_type,
'target_entity_type_id' => 'node',
))
->save();
}
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_comment_type' => array(
array(array('comment'), array('comment_no_subject')),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps(['Variable.php', 'NodeType.php']);
$this->executeMigration('d6_comment_entity_form_display_subject');
}
/**
* Tests comment subject variable migrated into an entity display.
*/
public function testCommentEntityFormDisplay() {
$component = entity_get_form_display('comment', 'comment', 'default')
->getComponent('subject');
$this->assertIdentical('string_textfield', $component['type']);
$this->assertIdentical(10, $component['weight']);
$component = entity_get_form_display('comment', 'comment_no_subject', 'default')
->getComponent('subject');
$this->assertNull($component);
}
}

View file

@ -1,33 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentVariableEntityFormDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Upgrade comment variables to core.entity_form_display.node.*.default.yml.
*
* @group migrate_drupal
*/
class MigrateCommentVariableEntityFormDisplayTest extends MigrateCommentVariableDisplayBase {
/**
* The migration to run.
*/
const MIGRATION = 'd6_comment_entity_form_display';
/**
* Tests comment variables migrated into an entity display.
*/
public function testCommentEntityFormDisplay() {
foreach ($this->types as $type) {
$component = entity_get_form_display('node', $type, 'default')->getComponent('comment');
$this->assertIdentical('comment_default', $component['type']);
$this->assertIdentical(20, $component['weight']);
}
}
}

View file

@ -1,54 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentVariableFieldTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Upgrade comment variables to field.storage.node.comment.yml.
*
* @group migrate_drupal
*/
class MigrateCommentVariableFieldTest extends MigrateDrupal6TestBase {
static $modules = array('comment', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
foreach (array('page', 'story', 'test') as $type) {
entity_create('node_type', array('type' => $type))->save();
}
foreach (['comment', 'comment_no_subject'] as $comment_type) {
entity_create('comment_type', array(
'id' => $comment_type,
'target_entity_type_id' => 'node',
))
->save();
}
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_comment_type' => array(
array(array('comment'), array('comment_no_subject')),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps(['Variable.php', 'NodeType.php']);
$this->executeMigration('d6_comment_field');
}
/**
* Tests comment variables migrated into a field entity.
*/
public function testCommentField() {
$this->assertTrue(is_object(FieldStorageConfig::load('node.comment')));
}
}

View file

@ -1,79 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateCommentVariableInstanceTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Upgrade comment variables to field.instance.node.*.comment.yml.
*
* @group migrate_drupal
*/
class MigrateCommentVariableInstanceTest extends MigrateDrupal6TestBase {
static $modules = array('comment', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_comment_field' => array(
array(array('page'), array('node', 'page')),
),
'd6_node_type' => array(
array(array('page'), array('page')),
),
);
$this->prepareMigrations($id_mappings);
foreach (array('page', 'story', 'article') as $type) {
entity_create('node_type', array('type' => $type))->save();
}
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'comment',
'type' => 'comment',
'translatable' => '0',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'comment_no_subject',
'type' => 'comment',
'translatable' => '0',
))->save();
$this->loadDumps(['Variable.php', 'NodeType.php']);
$this->executeMigration('d6_comment_field_instance');
}
/**
* Test the migrated field instance values.
*/
public function testCommentFieldInstance() {
$node = entity_create('node', array('type' => 'page'));
$this->assertIdentical(0, $node->comment->status);
$this->assertIdentical('comment', $node->comment->getFieldDefinition()->getName());
$settings = $node->comment->getFieldDefinition()->getSettings();
$this->assertIdentical(4, $settings['default_mode']);
$this->assertIdentical(50, $settings['per_page']);
$this->assertIdentical(0, $settings['anonymous']);
$this->assertIdentical(FALSE, $settings['form_location']);
$this->assertIdentical(1, $settings['preview']);
$node = entity_create('node', array('type' => 'story'));
$this->assertIdentical(2, $node->comment_no_subject->status);
$this->assertIdentical('comment_no_subject', $node->comment_no_subject->getFieldDefinition()->getName());
$settings = $node->comment_no_subject->getFieldDefinition()->getSettings();
$this->assertIdentical(2, $settings['default_mode']);
$this->assertIdentical(70, $settings['per_page']);
$this->assertIdentical(1, $settings['anonymous']);
$this->assertIdentical(FALSE, $settings['form_location']);
$this->assertIdentical(0, $settings['preview']);
}
}

View file

@ -1,235 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateFieldFormatterSettingsTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\Core\Entity\Entity\EntityViewMode;
/**
* Upgrade field formatter settings to entity.display.*.*.yml.
*
* @group migrate_drupal
*/
class MigrateFieldFormatterSettingsTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'field', 'datetime', 'image', 'text', 'link', 'file', 'telephone');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['node']);
entity_create('node_type', array('type' => 'test_page'))->save();
entity_create('node_type', array('type' => 'story'))->save();
// Create the node preview view mode.
EntityViewMode::create(array('id' => 'node.preview', 'targetEntityType' => 'node'))->save();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_view_modes' => array(
array(array(1), array('node', 'preview')),
array(array(4), array('node', 'rss')),
array(array('teaser'), array('node', 'teaser')),
array(array('full'), array('node', 'full')),
),
'd6_field_instance' => array(
array(array('fieldname', 'page'), array('node', 'fieldname', 'page')),
),
'd6_field' => array(
array(array('field_test'), array('node', 'field_test')),
array(array('field_test_two'), array('node', 'field_test_two')),
array(array('field_test_three'), array('node', 'field_test_three')),
array(array('field_test_email'), array('node', 'field_test_email')),
array(array('field_test_link'), array('node', 'field_test_link')),
array(array('field_test_filefield'), array('node', 'field_test_filefield')),
array(array('field_test_imagefield'), array('node', 'field_test_imagefield')),
array(array('field_test_phone'), array('node', 'field_test_phone')),
array(array('field_test_date'), array('node', 'field_test_date')),
array(array('field_test_datestamp'), array('node', 'field_test_datestamp')),
array(array('field_test_datetime'), array('node', 'field_test_datetime')),
array(array('field_test_exclude_unset'), array('node', 'field_test_exclude_unset')),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps([
'ContentNodeFieldInstance.php',
'ContentNodeField.php',
'ContentFieldTest.php',
'ContentFieldTestTwo.php',
'ContentFieldMultivalue.php',
]);
$this->executeMigration('d6_field_formatter_settings');
}
/**
* Test that migrated entity display settings can be loaded using D8 API's.
*/
public function testEntityDisplaySettings() {
// Run tests.
$field_name = "field_test";
$expected = array(
'label' => 'above',
'weight' => 1,
'type' => 'text_trimmed',
'settings' => array('trim_length' => 600),
'third_party_settings' => array(),
);
// Can we load any entity display.
$display = entity_load('entity_view_display', 'node.story.teaser');
$this->assertIdentical($expected, $display->getComponent($field_name));
// Test migrate worked with multiple bundles.
$display = entity_load('entity_view_display', 'node.test_page.teaser');
$expected['weight'] = 35;
$this->assertIdentical($expected, $display->getComponent($field_name));
// Test RSS because that has been converted from 4 to rss.
$display = entity_load('entity_view_display', 'node.story.rss');
$expected['weight'] = 1;
$this->assertIdentical($expected, $display->getComponent($field_name));
// Test the default format with text_default which comes from a static map.
$expected['type'] = 'text_default';
$expected['settings'] = array();
$display = entity_load('entity_view_display', 'node.story.default');
$this->assertIdentical($expected, $display->getComponent($field_name));
// Check that we can migrate multiple fields.
$content = $display->get('content');
$this->assertTrue(isset($content['field_test']), 'Settings for field_test exist.');
$this->assertTrue(isset($content['field_test_two']), "Settings for field_test_two exist.");
// Check that we can migrate a field where exclude is not set.
$this->assertTrue(isset($content['field_test_exclude_unset']), "Settings for field_test_exclude_unset exist.");
// Test the number field formatter settings are correct.
$expected['weight'] = 1;
$expected['type'] = 'number_integer';
$expected['settings'] = array(
'thousand_separator' => ',',
'prefix_suffix' => TRUE,
);
$component = $display->getComponent('field_test_two');
$this->assertIdentical($expected, $component);
$expected['weight'] = 2;
$expected['type'] = 'number_decimal';
$expected['settings'] = array(
'scale' => 2,
'decimal_separator' => '.',
'thousand_separator' => ',',
'prefix_suffix' => TRUE,
);
$component = $display->getComponent('field_test_three');
$this->assertIdentical($expected, $component);
// Test the email field formatter settings are correct.
$expected['weight'] = 6;
$expected['type'] = 'email_mailto';
$expected['settings'] = array();
$component = $display->getComponent('field_test_email');
$this->assertIdentical($expected, $component);
// Test the link field formatter settings.
$expected['weight'] = 7;
$expected['type'] = 'link';
$expected['settings'] = array(
'trim_length' => 80,
'url_only' => TRUE,
'url_plain' => TRUE,
'rel' => '0',
'target' => '0',
);
$component = $display->getComponent('field_test_link');
$this->assertIdentical($expected, $component);
$expected['settings']['url_only'] = FALSE;
$expected['settings']['url_plain'] = FALSE;
$display = entity_load('entity_view_display', 'node.story.teaser');
$component = $display->getComponent('field_test_link');
$this->assertIdentical($expected, $component);
// Test the file field formatter settings.
$expected['weight'] = 8;
$expected['type'] = 'file_default';
$expected['settings'] = array();
$component = $display->getComponent('field_test_filefield');
$this->assertIdentical($expected, $component);
$display = entity_load('entity_view_display', 'node.story.default');
$expected['type'] = 'file_url_plain';
$component = $display->getComponent('field_test_filefield');
$this->assertIdentical($expected, $component);
// Test the image field formatter settings.
$expected['weight'] = 9;
$expected['type'] = 'image';
$expected['settings'] = array('image_style' => '', 'image_link' => '');
$component = $display->getComponent('field_test_imagefield');
$this->assertIdentical($expected, $component);
$display = entity_load('entity_view_display', 'node.story.teaser');
$expected['settings']['image_link'] = 'file';
$component = $display->getComponent('field_test_imagefield');
$this->assertIdentical($expected, $component);
// Test phone field.
$expected['weight'] = 13;
$expected['type'] = 'basic_string';
$expected['settings'] = array();
$component = $display->getComponent('field_test_phone');
$this->assertIdentical($expected, $component);
// Test date field.
$defaults = array('format_type' => 'fallback', 'timezone_override' => '',);
$expected['weight'] = 10;
$expected['type'] = 'datetime_default';
$expected['settings'] = array('format_type' => 'fallback') + $defaults;
$component = $display->getComponent('field_test_date');
$this->assertIdentical($expected, $component);
$display = entity_load('entity_view_display', 'node.story.default');
$expected['settings']['format_type'] = 'long';
$component = $display->getComponent('field_test_date');
$this->assertIdentical($expected, $component);
// Test date stamp field.
$expected['weight'] = 11;
$expected['settings']['format_type'] = 'fallback';
$component = $display->getComponent('field_test_datestamp');
$this->assertIdentical($expected, $component);
$display = entity_load('entity_view_display', 'node.story.teaser');
$expected['settings'] = array('format_type' => 'medium') + $defaults;
$component = $display->getComponent('field_test_datestamp');
$this->assertIdentical($expected, $component);
// Test datetime field.
$expected['weight'] = 12;
$expected['settings'] = array('format_type' => 'short') + $defaults;
$component = $display->getComponent('field_test_datetime');
$this->assertIdentical($expected, $component);
$display = entity_load('entity_view_display', 'node.story.default');
$expected['settings']['format_type'] = 'fallback';
$component = $display->getComponent('field_test_datetime');
$this->assertIdentical($expected, $component);
// Test a date field with a random format which should be mapped
// to datetime_default.
$display = entity_load('entity_view_display', 'node.story.rss');
$expected['settings']['format_type'] = 'fallback';
$component = $display->getComponent('field_test_datetime');
$this->assertIdentical($expected, $component);
// Test that our Id map has the correct data.
$this->assertIdentical(array('node', 'story', 'teaser', 'field_test'), entity_load('migration', 'd6_field_formatter_settings')->getIdMap()->lookupDestinationID(array('story', 'teaser', 'node', 'field_test')));
}
}

View file

@ -1,181 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateFieldInstanceTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldConfig;
use Drupal\link\LinkItemInterface;
/**
* Migrate field instances.
*
* @group migrate_drupal
*/
class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array(
'telephone',
'link',
'file',
'image',
'datetime',
'node',
'field',
'text',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_field' => array(
array(array('field_test'), array('node', 'field_test')),
array(array('field_test_two'), array('node', 'field_test_two')),
array(array('field_test_three'), array('node', 'field_test_three')),
array(array('field_test_four'), array('node', 'field_test_four')),
array(array('field_test_email'), array('node', 'field_test_email')),
array(array('field_test_link'), array('node', 'field_test_link')),
array(array('field_test_filefield'), array('node', 'field_test_filefield')),
array(array('field_test_imagefield'), array('node', 'field_test_imagefield')),
array(array('field_test_phone'), array('node', 'field_test_phone')),
array(array('field_test_date'), array('node', 'field_test_date')),
array(array('field_test_datestamp'), array('node', 'field_test_datestamp')),
array(array('field_test_datetime'), array('node', 'field_test_datetime')),
),
'd6_node_type' => array(
array(array('page'), array('page')),
array(array('story'), array('story')),
array(array('test_page'), array('test_page')),
),
);
$this->prepareMigrations($id_mappings);
entity_create('node_type', array('type' => 'page'))->save();
entity_create('node_type', array('type' => 'story'))->save();
entity_create('node_type', array('type' => 'test_page'))->save();
$this->loadDumps([
'ContentNodeFieldInstance.php',
'ContentNodeField.php',
'ContentFieldTest.php',
'ContentFieldTestTwo.php',
'ContentFieldMultivalue.php',
]);
$this->createFields();
$this->executeMigration('d6_field_instance');
}
/**
* Tests migration of file variables to file.settings.yml.
*/
public function testFieldInstanceSettings() {
$entity = entity_create('node', array('type' => 'story'));
// Test a text field.
$field = FieldConfig::load('node.story.field_test');
$this->assertIdentical('Text Field', $field->label());
$expected = array('max_length' => 255);
$this->assertIdentical($expected, $field->getSettings());
$this->assertIdentical('text for default value', $entity->field_test->value);
// Test a number field.
$field = FieldConfig::load('node.story.field_test_two');
$this->assertIdentical('Integer Field', $field->label());
$expected = array(
'min' => 10,
'max' => 100,
'prefix' => 'pref',
'suffix' => 'suf',
'unsigned' => FALSE,
'size' => 'normal',
);
$this->assertIdentical($expected, $field->getSettings());
$field = FieldConfig::load('node.story.field_test_four');
$this->assertIdentical('Float Field', $field->label());
$expected = array(
'min' => 100.0,
'max' => 200.0,
'prefix' => 'id-',
'suffix' => '',
);
$this->assertIdentical($expected, $field->getSettings());
// Test email field.
$field = FieldConfig::load('node.story.field_test_email');
$this->assertIdentical('Email Field', $field->label());
$this->assertIdentical('benjy@example.com', $entity->field_test_email->value);
// Test a filefield.
$field = FieldConfig::load('node.story.field_test_filefield');
$this->assertIdentical('File Field', $field->label());
$expected = array(
'file_extensions' => 'txt pdf doc',
'file_directory' => 'images',
'description_field' => TRUE,
'max_filesize' => '200KB',
'target_type' => 'file',
'display_field' => FALSE,
'display_default' => FALSE,
'uri_scheme' => 'public',
// This value should be 'default:file' but the test does not migrate field
// storages so we end up with the default value for this setting.
'handler' => 'default:node',
'handler_settings' => array(),
'target_bundle' => NULL,
);
$field_settings = $field->getSettings();
ksort($expected);
ksort($field_settings);
// This is the only way to compare arrays.
$this->assertIdentical($expected, $field_settings);
// Test a link field.
$field = FieldConfig::load('node.story.field_test_link');
$this->assertIdentical('Link Field', $field->label());
$expected = array('title' => 2, 'link_type' => LinkItemInterface::LINK_GENERIC);
$this->assertIdentical($expected, $field->getSettings());
$this->assertIdentical('default link title', $entity->field_test_link->title, 'Field field_test_link default title is correct.');
$this->assertIdentical('https://www.drupal.org', $entity->field_test_link->url, 'Field field_test_link default title is correct.');
$this->assertIdentical([], $entity->field_test_link->options['attributes']);
}
/**
* Helper to create fields.
*/
protected function createFields() {
$fields = array(
'field_test' => 'text',
'field_test_two' => 'integer',
'field_test_three' => 'decimal',
'field_test_four' => 'float',
'field_test_email' => 'email',
'field_test_link' => 'link',
'field_test_filefield' => 'file',
'field_test_imagefield' => 'image',
'field_test_phone' => 'telephone',
'field_test_date' => 'datetime',
'field_test_datestamp' => 'datetime',
'field_test_datetime' => 'datetime',
);
foreach ($fields as $name => $type) {
entity_create('field_storage_config', array(
'field_name' => $name,
'entity_type' => 'node',
'type' => $type,
))->save();
}
}
}

View file

@ -1,113 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateFieldTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Migrate fields.
*
* @group migrate_drupal
*/
class MigrateFieldTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('field', 'telephone', 'link', 'file', 'image', 'datetime', 'node', 'options', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps([
'ContentNodeFieldInstance.php',
'ContentNodeField.php',
'ContentFieldTest.php',
'ContentFieldTestTwo.php',
'ContentFieldMultivalue.php',
]);
$this->executeMigration('d6_field');
}
/**
* Tests the Drupal 6 field to Drupal 8 migration.
*/
public function testFields() {
// Text field.
/** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */
$field_storage = FieldStorageConfig::load('node.field_test');
$expected = array('max_length' => 255);
$this->assertIdentical("text", $field_storage->getType(), t('Field type is @fieldtype. It should be text.', array('@fieldtype' => $field_storage->getType())));
$this->assertIdentical($expected, $field_storage->getSettings(), "Field type text settings are correct");
// Integer field.
$field_storage = FieldStorageConfig::load('node.field_test_two');
$this->assertIdentical("integer", $field_storage->getType(), t('Field type is @fieldtype. It should be integer.', array('@fieldtype' => $field_storage->getType())));
// Float field.
$field_storage = FieldStorageConfig::load('node.field_test_three');
$this->assertIdentical("decimal", $field_storage->getType(), t('Field type is @fieldtype. It should be decimal.', array('@fieldtype' => $field_storage->getType())));
// Link field.
$field_storage = FieldStorageConfig::load('node.field_test_link');
$this->assertIdentical("link", $field_storage->getType(), t('Field type is @fieldtype. It should be link.', array('@fieldtype' => $field_storage->getType())));
// File field.
$field_storage = FieldStorageConfig::load('node.field_test_filefield');
$this->assertIdentical("file", $field_storage->getType(), t('Field type is @fieldtype. It should be file.', array('@fieldtype' => $field_storage->getType())));
$field_storage = FieldStorageConfig::load('node.field_test_imagefield');
$this->assertIdentical("image", $field_storage->getType(), t('Field type is @fieldtype. It should be image.', array('@fieldtype' => $field_storage->getType())));
$settings = $field_storage->getSettings();
$this->assertIdentical('file', $settings['target_type']);
$this->assertIdentical('public', $settings['uri_scheme']);
$this->assertIdentical(array(), array_filter($settings['default_image']));
// Phone field.
$field_storage = FieldStorageConfig::load('node.field_test_phone');
$this->assertIdentical("telephone", $field_storage->getType(), t('Field type is @fieldtype. It should be telephone.', array('@fieldtype' => $field_storage->getType())));
// Date field.
$field_storage = FieldStorageConfig::load('node.field_test_datetime');
$this->assertIdentical("datetime", $field_storage->getType(), t('Field type is @fieldtype. It should be datetime.', array('@fieldtype' => $field_storage->getType())));
// Decimal field with radio buttons.
$field_storage = FieldStorageConfig::load('node.field_test_decimal_radio_buttons');
$this->assertIdentical("list_float", $field_storage->getType(), t('Field type is @fieldtype. It should be list_float.', array('@fieldtype' => $field_storage->getType())));
$this->assertNotNull($field_storage->getSetting('allowed_values')['1.2'], t('First allowed value key is set to 1.2'));
$this->assertNotNull($field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value key is set to 2.1'));
$this->assertIdentical('1.2', $field_storage->getSetting('allowed_values')['1.2'], t('First allowed value is set to 1.2'));
$this->assertIdentical('2.1', $field_storage->getSetting('allowed_values')['2.1'], t('Second allowed value is set to 1.2'));
// Float field with a single checkbox.
$field_storage = FieldStorageConfig::load('node.field_test_float_single_checkbox');
$this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
// Integer field with a select list.
$field_storage = FieldStorageConfig::load('node.field_test_integer_selectlist');
$this->assertIdentical("list_integer", $field_storage->getType(), t('Field type is @fieldtype. It should be list_integer.', array('@fieldtype' => $field_storage->getType())));
$this->assertNotNull($field_storage->getSetting('allowed_values')['1234'], t('First allowed value key is set to 1234'));
$this->assertNotNull($field_storage->getSetting('allowed_values')['2341'], t('Second allowed value key is set to 2341'));
$this->assertNotNull($field_storage->getSetting('allowed_values')['3412'], t('Third allowed value key is set to 3412'));
$this->assertNotNull($field_storage->getSetting('allowed_values')['4123'], t('Fourth allowed value key is set to 4123'));
$this->assertIdentical('1234', $field_storage->getSetting('allowed_values')['1234'], t('First allowed value is set to 1234'));
$this->assertIdentical('2341', $field_storage->getSetting('allowed_values')['2341'], t('Second allowed value is set to 2341'));
$this->assertIdentical('3412', $field_storage->getSetting('allowed_values')['3412'], t('Third allowed value is set to 3412'));
$this->assertIdentical('4123', $field_storage->getSetting('allowed_values')['4123'], t('Fourth allowed value is set to 4123'));
// Text field with a single checkbox.
$field_storage = FieldStorageConfig::load('node.field_test_text_single_checkbox');
$this->assertIdentical("boolean", $field_storage->getType(), t('Field type is @fieldtype. It should be boolean.', array('@fieldtype' => $field_storage->getType())));
}
}

View file

@ -1,149 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateFieldWidgetSettingsTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Migrate field widget settings.
*
* @group migrate_drupal
*/
class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array(
'field',
'telephone',
'link',
'file',
'image',
'datetime',
'node',
'text',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('node_type', array('type' => 'test_page'))->save();
entity_create('node_type', array('type' => 'story'))->save();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_field_instance' => array(
array(array('fieldname', 'page'), array('node', 'fieldname', 'page')),
),
'd6_field' => array(
array(array('field_test'), array('node', 'field_test')),
array(array('field_test_two'), array('node', 'field_test_two')),
array(array('field_test_three'), array('node', 'field_test_three')),
array(array('field_test_email'), array('node', 'field_test_email')),
array(array('field_test_link'), array('node', 'field_test_link')),
array(array('field_test_filefield'), array('node', 'field_test_filefield')),
array(array('field_test_imagefield'), array('node', 'field_test_imagefield')),
array(array('field_test_phone'), array('node', 'field_test_phone')),
array(array('field_test_date'), array('node', 'field_test_date')),
array(array('field_test_datestamp'), array('node', 'field_test_datestamp')),
array(array('field_test_datetime'), array('node', 'field_test_datetime')),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps([
'ContentNodeFieldInstance.php',
'ContentNodeField.php',
'ContentFieldTest.php',
'ContentFieldTestTwo.php',
'ContentFieldMultivalue.php',
]);
$this->executeMigration('d6_field_instance_widget_settings');
}
/**
* Test that migrated view modes can be loaded using D8 API's.
*/
public function testWidgetSettings() {
// Test the config can be loaded.
$form_display = entity_load('entity_form_display', 'node.story.default');
$this->assertIdentical(FALSE, is_null($form_display), "Form display node.story.default loaded with config.");
// Text field.
$component = $form_display->getComponent('field_test');
$expected = array('weight' => 1, 'type' => 'text_textfield');
$expected['settings'] = array('size' => 60, 'placeholder' => '');
$expected['third_party_settings'] = array();
$this->assertIdentical($expected, $component, 'Text field settings are correct.');
// Integer field.
$component = $form_display->getComponent('field_test_two');
$expected['type'] = 'number';
$expected['weight'] = 1;
$expected['settings'] = array('placeholder' => '');
$this->assertIdentical($expected, $component);
// Float field.
$component = $form_display->getComponent('field_test_three');
$expected['weight'] = 2;
$this->assertIdentical($expected, $component);
// Email field.
$component = $form_display->getComponent('field_test_email');
$expected['type'] = 'email_default';
$expected['weight'] = 6;
$this->assertIdentical($expected, $component);
// Link field.
$component = $form_display->getComponent('field_test_link');
$this->assertIdentical('link_default', $component['type']);
$this->assertIdentical(7, $component['weight']);
$this->assertFalse(array_filter($component['settings']));
// File field.
$component = $form_display->getComponent('field_test_filefield');
$expected['type'] = 'file_generic';
$expected['weight'] = 8;
$expected['settings'] = array('progress_indicator' => 'bar');
$this->assertIdentical($expected, $component);
// Image field.
$component = $form_display->getComponent('field_test_imagefield');
$expected['type'] = 'image_image';
$expected['weight'] = 9;
$expected['settings'] = array('progress_indicator' => 'bar', 'preview_image_style' => 'thumbnail');
$this->assertIdentical($expected, $component);
// Phone field.
$component = $form_display->getComponent('field_test_phone');
$expected['type'] = 'telephone_default';
$expected['weight'] = 13;
$expected['settings'] = array('placeholder' => '');
$this->assertIdentical($expected, $component);
// Date fields.
$component = $form_display->getComponent('field_test_date');
$expected['type'] = 'datetime_default';
$expected['weight'] = 10;
$expected['settings'] = array();
$this->assertIdentical($expected, $component);
$component = $form_display->getComponent('field_test_datestamp');
$expected['weight'] = 11;
$this->assertIdentical($expected, $component);
$component = $form_display->getComponent('field_test_datetime');
$expected['weight'] = 12;
$this->assertIdentical($expected, $component);
}
}

View file

@ -1,48 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateFileConfigsTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
/**
* Upgrade variables to file.settings.yml.
*
* @group migrate_drupal
*/
class MigrateFileConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('file');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_file_settings');
}
/**
* Tests migration of file variables to file.settings.yml.
*/
public function testFileSettings() {
$config = $this->config('file.settings');
$this->assertIdentical('textfield', $config->get('description.type'));
$this->assertIdentical(128, $config->get('description.length'));
$this->assertIdentical('sites/default/files/icons', $config->get('icon.directory'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'file.settings', $config->get());
}
}

View file

@ -1,132 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateFileTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\Component\Utility\Random;
use Drupal\migrate\Tests\MigrateDumpAlterInterface;
use Drupal\Core\Database\Database;
use Drupal\simpletest\TestBase;
use Drupal\file\Entity\File;
/**
* file migration.
*
* @group migrate_drupal
*/
class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlterInterface {
/**
* The filename of a file used to test temporary file migration.
*
* @var string
*/
protected static $tempFilename;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('file');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('file');
$this->installConfig(['file']);
$this->loadDumps(['Files.php']);
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
$migration = entity_load('migration', 'd6_file');
$source = $migration->get('source');
$source['site_path'] = 'core/modules/simpletest';
$migration->set('source', $source);
$this->executeMigration($migration);
$this->standalone = TRUE;
}
/**
* Tests the Drupal 6 files to Drupal 8 migration.
*/
public function testFiles() {
/** @var \Drupal\file\FileInterface $file */
$file = File::load(1);
$this->assertIdentical('Image1.png', $file->getFilename());
$this->assertIdentical('39325', $file->getSize());
$this->assertIdentical('public://image-1.png', $file->getFileUri());
$this->assertIdentical('image/png', $file->getMimeType());
$this->assertIdentical("1", $file->getOwnerId());
// It is pointless to run the second half from MigrateDrupal6Test.
if (empty($this->standalone)) {
return;
}
// Test that we can re-import and also test with file_directory_path set.
db_truncate(entity_load('migration', 'd6_file')->getIdMap()->mapTableName())->execute();
$this->loadDumps(['Variable.php']);
// Update the file_directory_path.
Database::getConnection('default', 'migrate')
->update('variable')
->fields(array('value' => serialize('files/test')))
->condition('name', 'file_directory_path')
->execute();
Database::getConnection('default', 'migrate')
->update('variable')
->fields(array('value' => serialize($this->getTempFilesDirectory())))
->condition('name', 'file_directory_temp')
->execute();
$migration = entity_load_unchanged('migration', 'd6_file');
$this->executeMigration($migration);
$file = File::load(2);
$this->assertIdentical('public://core/modules/simpletest/files/image-2.jpg', $file->getFileUri());
// Ensure that a temporary file has been migrated.
$file = File::load(6);
$this->assertIdentical('temporary://' . static::getUniqueFilename(), $file->getFileUri());
}
/**
* @return string
* A filename based upon the test.
*/
public static function getUniqueFilename() {
return static::$tempFilename;
}
/**
* {@inheritdoc}
*/
public static function migrateDumpAlter(TestBase $test) {
// Creates a random filename and updates the source database.
$random = new Random();
$temp_directory = $test->getTempFilesDirectory();
file_prepare_directory($temp_directory, FILE_CREATE_DIRECTORY);
static::$tempFilename = $test->getDatabasePrefix() . $random->name() . '.jpg';
$file_path = $temp_directory . '/' . static::$tempFilename;
file_put_contents($file_path, '');
Database::getConnection('default', 'migrate')
->update('files')
->condition('fid', 6)
->fields(array(
'filename' => static::$tempFilename,
'filepath' => $file_path,
))
->execute();
return static::$tempFilename;
}
}

View file

@ -1,100 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUploadBase.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Base class for file/upload migration tests.
*/
abstract class MigrateUploadBase extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
static $modules = array('file', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('file');
$this->installEntitySchema('node');
$this->installSchema('file', ['file_usage']);
$this->installSchema('node', ['node_access']);
// Create new file entities.
for ($i = 1; $i <= 3; $i++) {
$file = entity_create('file', array(
'fid' => $i,
'uid' => 1,
'filename' => 'druplicon.txt',
'uri' => "public://druplicon-$i.txt",
'filemime' => 'text/plain',
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
));
$file->enforceIsNew();
file_put_contents($file->getFileUri(), 'hello world');
// Save it, inserting a new record.
$file->save();
$id_mappings['d6_file'][] = array(array($i), array($i));
}
// Add a node type.
$node_type = entity_create('node_type', array('type' => 'story'));
$node_type->save();
// Add a file field.
entity_create('field_storage_config', array(
'field_name' => 'upload',
'entity_type' => 'node',
'type' => 'file',
'cardinality' => -1,
'settings' => array(
'display_field' => TRUE,
),
))->save();
entity_create('field_config', array(
'field_name' => 'upload',
'entity_type' => 'node',
'bundle' => 'story',
))->save();
$id_mappings['d6_node'] = array(
array(array(1), array(1)),
array(array(2), array(2)),
);
$this->prepareMigrations($id_mappings);
$vids = array(1, 2, 3);
for ($i = 1; $i <= 2; $i++) {
$node = entity_create('node', array(
'type' => 'story',
'nid' => $i,
'vid' => array_shift($vids),
));
$node->enforceIsNew();
$node->save();
if ($i == 1) {
$node->vid->value = array_shift($vids);
$node->enforceIsNew(FALSE);
$node->isDefaultRevision(FALSE);
$node->save();
}
}
$this->loadDumps([
'Node.php',
'NodeRevisions.php',
'ContentTypeStory.php',
'ContentTypeTestPlanet.php',
'Upload.php',
]);
}
}

View file

@ -1,65 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUploadEntityDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Upload entity display.
*
* @group migrate_drupal
*/
class MigrateUploadEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('node', 'file');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('node_type', array('type' => 'article'))->save();
entity_create('node_type', array('type' => 'story'))->save();
entity_create('node_type', array('type' => 'page'))->save();
$id_mappings = array(
'd6_upload_field_instance' => array(
array(array(1), array('node', 'page', 'upload')),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps(['NodeType.php', 'Variable.php']);
$this->executeMigration('d6_upload_entity_display');
}
/**
* Tests the Drupal 6 upload settings to Drupal 8 entity display migration.
*/
public function testUploadEntityDisplay() {
$display = entity_get_display('node', 'page', 'default');
$component = $display->getComponent('upload');
$this->assertIdentical('file_default', $component['type']);
$display = entity_get_display('node', 'story', 'default');
$component = $display->getComponent('upload');
$this->assertIdentical('file_default', $component['type']);
// Assure this doesn't exist.
$display = entity_get_display('node', 'article', 'default');
$component = $display->getComponent('upload');
$this->assertTrue(is_null($component));
$this->assertIdentical(array('node', 'page', 'default', 'upload'), entity_load('migration', 'd6_upload_entity_display')->getIdMap()->lookupDestinationID(array('page')));
}
}

View file

@ -1,65 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUploadEntityFormDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Upload form entity display.
*
* @group migrate_drupal
*/
class MigrateUploadEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('file', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('node_type', array('type' => 'article'))->save();
entity_create('node_type', array('type' => 'story'))->save();
entity_create('node_type', array('type' => 'page'))->save();
$id_mappings = array(
'd6_upload_field_instance' => array(
array(array(1), array('node', 'page', 'upload')),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps(['NodeType.php', 'Variable.php']);
$this->executeMigration('d6_upload_entity_form_display');
}
/**
* Tests the Drupal 6 upload settings to Drupal 8 entity form display migration.
*/
public function testUploadEntityFormDisplay() {
$display = entity_get_form_display('node', 'page', 'default');
$component = $display->getComponent('upload');
$this->assertIdentical('file_generic', $component['type']);
$display = entity_get_form_display('node', 'story', 'default');
$component = $display->getComponent('upload');
$this->assertIdentical('file_generic', $component['type']);
// Assure this doesn't exist.
$display = entity_get_form_display('node', 'article', 'default');
$component = $display->getComponent('upload');
$this->assertTrue(is_null($component));
$this->assertIdentical(array('node', 'page', 'default', 'upload'), entity_load('migration', 'd6_upload_entity_form_display')->getIdMap()->lookupDestinationID(array('page')));
}
}

View file

@ -1,43 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUploadFieldTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Uploads migration.
*
* @group migrate_drupal
*/
class MigrateUploadFieldTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('file', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_upload_field');
}
/**
* Tests the Drupal 6 upload settings to Drupal 8 field migration.
*/
public function testUpload() {
$field_storage = FieldStorageConfig::load('node.upload');
$this->assertIdentical('node.upload', $field_storage->id());
$this->assertIdentical(array('node', 'upload'), entity_load('migration', 'd6_upload_field')->getIdMap()->lookupDestinationID(array('')));
}
}

View file

@ -1,78 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUploadInstanceTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldConfig;
/**
* Upload field instance migration.
*
* @group migrate_drupal
*/
class MigrateUploadInstanceTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('file', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some node mappings to get past checkRequirements().
$id_mappings = array(
'd6_upload_field' => array(
array(array(1), array('node', 'upload')),
),
'd6_node_type' => array(
array(array('page'), array('page')),
array(array('story'), array('story')),
),
);
$this->prepareMigrations($id_mappings);
foreach (array('page', 'story') as $type) {
entity_create('node_type', array('type' => $type))->save();
}
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'upload',
'type' => 'file',
'translatable' => '0',
))->save();
$this->loadDumps(['NodeType.php', 'Variable.php']);
$this->executeMigration('d6_upload_field_instance');
}
/**
* Tests the Drupal 6 upload settings to Drupal 8 field instance migration.
*/
public function testUploadFieldInstance() {
$field = FieldConfig::load('node.page.upload');
$settings = $field->getSettings();
$this->assertIdentical('node.page.upload', $field->id());
$this->assertIdentical('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp', $settings['file_extensions']);
$this->assertIdentical('1MB', $settings['max_filesize']);
$this->assertIdentical(TRUE, $settings['description_field']);
$field = FieldConfig::load('node.story.upload');
$this->assertIdentical('node.story.upload', $field->id());
// Shouldn't exist.
$field = FieldConfig::load('node.article.upload');
$this->assertTrue(is_null($field));
$this->assertIdentical(array('node', 'page', 'upload'), entity_load('migration', 'd6_upload_field_instance')->getIdMap()->lookupDestinationID(array('page')));
}
}

View file

@ -1,50 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUploadTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\node\Entity\Node;
/**
* Migrate association data between nodes and files.
*
* @group migrate_drupal
*/
class MigrateUploadTest extends MigrateUploadBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_upload');
}
/**
* Test upload migration from Drupal 6 to Drupal 8.
*/
function testUpload() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage->resetCache(array(1, 2));
$nodes = Node::loadMultiple(array(1, 2));
$node = $nodes[1];
$this->assertIdentical(1, count($node->upload));
$this->assertIdentical('1', $node->upload[0]->target_id);
$this->assertIdentical('file 1-1-1', $node->upload[0]->description);
$this->assertIdentical(FALSE, $node->upload[0]->isDisplayed());
$node = $nodes[2];
$this->assertIdentical(2, count($node->upload));
$this->assertIdentical('3', $node->upload[0]->target_id);
$this->assertIdentical('file 2-3-3', $node->upload[0]->description);
$this->assertIdentical(FALSE, $node->upload[0]->isDisplayed());
$this->assertIdentical('2', $node->upload[1]->target_id);
$this->assertIdentical(TRUE, $node->upload[1]->isDisplayed());
$this->assertIdentical('file 2-3-2', $node->upload[1]->description);
}
}

View file

@ -1,65 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserConfigsTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
/**
* Upgrade variables to user.*.yml.
*
* @group migrate_drupal
*/
class MigrateUserConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_user_mail');
$this->executeMigration('d6_user_settings');
}
/**
* Tests migration of user variables to user.mail.yml.
*/
public function testUserMail() {
$config = $this->config('user.mail');
$this->assertIdentical('Account details for !username at !site (approved)', $config->get('status_activated.subject'));
$this->assertIdentical("!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n", $config->get('status_activated.body'));
$this->assertIdentical('Replacement login information for !username at !site', $config->get('password_reset.subject'));
$this->assertIdentical("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $config->get('password_reset.body'));
$this->assertIdentical('Account details for !username at !site (deleted)', $config->get('cancel_confirm.subject'));
$this->assertIdentical("!username,\n\nYour account on !site has been deleted.", $config->get('cancel_confirm.body'));
$this->assertIdentical('An administrator created an account for you at !site', $config->get('register_admin_created.subject'));
$this->assertIdentical("!username,\n\nA site administrator at !site has created an account for you. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $config->get('register_admin_created.body'));
$this->assertIdentical('Account details for !username at !site', $config->get('register_no_approval_required.subject'));
$this->assertIdentical("!username,\n\nThank you for registering at !site. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n-- !site team", $config->get('register_no_approval_required.body'));
$this->assertIdentical('Account details for !username at !site (pending admin approval)', $config->get('register_pending_approval.subject'));
$this->assertIdentical("!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- !site team", $config->get('register_pending_approval.body'));
$this->assertIdentical('Account details for !username at !site (blocked)', $config->get('status_blocked.subject'));
$this->assertIdentical("!username,\n\nYour account on !site has been blocked.", $config->get('status_blocked.body'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get());
}
/**
* Tests migration of user variables to user.settings.yml.
*/
public function testUserSettings() {
$config = $this->config('user.settings');
$this->assertIdentical(TRUE, $config->get('notify.status_blocked'));
$this->assertIdentical(FALSE, $config->get('notify.status_activated'));
$this->assertIdentical(FALSE, $config->get('verify_mail'));
$this->assertIdentical('admin_only', $config->get('register'));
$this->assertIdentical('Guest', $config->get('anonymous'));
}
}

View file

@ -1,68 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserContactSettingsTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* Users contact settings migration.
*
* @group migrate_drupal
*/
class MigrateUserContactSettingsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['contact'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installSchema('user', array('users_data'));
$this->loadDumps([
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
]);
$id_mappings = array(
'd6_user' => array(
array(array(2), array(2)),
array(array(8), array(8)),
array(array(15), array(15)),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_user_contact_settings');
}
/**
* Tests the Drupal6 user contact settings migration.
*/
public function testUserContactSettings() {
$user_data = \Drupal::service('user.data');
$module = $key = 'contact';
$uid = 2;
$setting = $user_data->get($module, $uid, $key);
$this->assertIdentical('1', $setting);
$uid = 8;
$setting = $user_data->get($module, $uid, $key);
$this->assertIdentical('0', $setting);
$uid = 15;
$setting = $user_data->get($module, $uid, $key);
$this->assertIdentical(NULL, $setting);
}
}

View file

@ -1,51 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserPictureEntityDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* User picture entity display.
*
* @group migrate_drupal
*/
class MigrateUserPictureEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
static $modules = array('image');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$id_mappings = array(
'd6_user_picture_field_instance' => array(
array(array(1), array('user', 'user', 'user_picture')),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_user_picture_entity_display');
}
/**
* Tests the Drupal 6 user picture to Drupal 8 entity display migration.
*/
public function testUserPictureEntityDisplay() {
$display = entity_get_display('user', 'user', 'default');
$component = $display->getComponent('user_picture');
$this->assertIdentical('image', $component['type']);
$this->assertIdentical('content', $component['settings']['image_link']);
$this->assertIdentical(array('user', 'user', 'default', 'user_picture'), entity_load('migration', 'd6_user_picture_entity_display')->getIdMap()->lookupDestinationID(array('')));
}
}

View file

@ -1,50 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserPictureEntityFormDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
/**
* User picture entity form display.
*
* @group migrate_drupal
*/
class MigrateUserPictureEntityFormDisplayTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
static $modules = array('image');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$id_mappings = array(
'd6_user_picture_field_instance' => array(
array(array(1), array('user', 'user', 'user_picture')),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_user_picture_entity_form_display');
}
/**
* Tests the Drupal 6 user picture to Drupal 8 entity form display migration.
*/
public function testUserPictureEntityFormDisplay() {
$display = entity_get_form_display('user', 'user', 'default');
$component = $display->getComponent('user_picture');
$this->assertIdentical('image_image', $component['type']);
$this->assertIdentical('throbber', $component['settings']['progress_indicator']);
$this->assertIdentical(array('user', 'user', 'default', 'user_picture'), entity_load('migration', 'd6_user_picture_entity_form_display')->getIdMap()->lookupDestinationID(array('')));
}
}

View file

@ -1,38 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserPictureFieldTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldStorageConfig;
/**
* User picture field migration.
*
* @group migrate_drupal
*/
class MigrateUserPictureFieldTest extends MigrateDrupal6TestBase {
static $modules = array('image', 'file');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_user_picture_field');
}
/**
* Test the user picture field migration.
*/
public function testUserPictureField() {
$field_storage = FieldStorageConfig::load('user.user_picture');
$this->assertIdentical('user.user_picture', $field_storage->id());
$this->assertIdentical(array('user', 'user_picture'), entity_load('migration', 'd6_user_picture_field')->getIdMap()->lookupDestinationID(array('')));
}
}

View file

@ -1,72 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserPictureFileTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\file\Entity\File;
/**
* User pictures migration.
*
* @group migrate_drupal
*/
class MigrateUserPictureFileTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('file');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('file');
$this->loadDumps([
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
]);
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
$migration = entity_load('migration', 'd6_user_picture_file');
$source = $migration->get('source');
$source['site_path'] = 'core/modules/simpletest';
$migration->set('source', $source);
$this->executeMigration($migration);
}
/**
* Tests the Drupal 6 user pictures to Drupal 8 migration.
*/
public function testUserPictures() {
$file_ids = array();
foreach (entity_load('migration', 'd6_user_picture_file')->getIdMap() as $destination_ids) {
$file_ids[] = reset($destination_ids);
}
$files = File::loadMultiple($file_ids);
/** @var \Drupal\file\FileInterface $file */
$file = array_shift($files);
$this->assertIdentical('image-test.jpg', $file->getFilename());
$this->assertIdentical('public://image-test.jpg', $file->getFileUri());
$this->assertIdentical('2', $file->getOwnerId());
$this->assertIdentical('1901', $file->getSize());
$this->assertIdentical('image/jpeg', $file->getMimeType());
$file = array_shift($files);
$this->assertIdentical('image-test.png', $file->getFilename());
$this->assertIdentical('public://image-test.png', $file->getFileUri());
$this->assertIdentical('8', $file->getOwnerId());
$this->assertFalse($files);
}
}

View file

@ -1,62 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserPictureInstanceTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldConfig;
/**
* User picture field instance migration.
*
* @group migrate_drupal
*/
class MigrateUserPictureInstanceTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
static $modules = array('image', 'file');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some node mappings to get past checkRequirements().
$id_mappings = array(
'd6_user_picture_field' => array(
array(array('user_upload'), array('name', 'bundle')),
),
);
$this->prepareMigrations($id_mappings);
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'user_picture',
'type' => 'image',
'translatable' => '0',
))->save();
$this->executeMigration('d6_user_picture_field_instance');
}
/**
* Tests the Drupal 6 user picture to Drupal 8 picture field instance migration.
*/
public function testUserPictureFieldInstance() {
$field = FieldConfig::load('user.user.user_picture');
$settings = $field->getSettings();
$this->assertIdentical('png gif jpg jpeg', $settings['file_extensions']);
$this->assertIdentical('pictures', $settings['file_directory']);
$this->assertIdentical('30KB', $settings['max_filesize']);
$this->assertIdentical('85x85', $settings['max_resolution']);
$this->assertIdentical(array('user', 'user', 'user_picture'), entity_load('migration', 'd6_user_picture_field_instance')->getIdMap()->lookupDestinationID(array('')));
}
}

View file

@ -1,127 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserProfileEntityDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\Core\Database\Database;
/**
* Tests the user profile entity display migration.
*
* @group migrate_drupal
*/
class MigrateUserProfileEntityDisplayTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
static $modules = array('link', 'options', 'datetime', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Create some fields so the data gets stored.
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_color',
'type' => 'text',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_biography',
'type' => 'text_long',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_sell_address',
'type' => 'boolean',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_sold_to',
'type' => 'list_string',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_bands',
'type' => 'text',
'cardinality' => -1,
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_blog',
'type' => 'link',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_birthdate',
'type' => 'datetime',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_love_migrations',
'type' => 'boolean',
))->save();
$this->loadDumps([
'ProfileFields.php',
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
]);
$field_data = Database::getConnection('default', 'migrate')
->select('profile_fields', 'u')
->fields('u')
->execute()
->fetchAll();
foreach ($field_data as $field) {
entity_create('field_config', array(
'label' => $field->title,
'description' => '',
'field_name' => $field->name,
'entity_type' => 'user',
'bundle' => 'user',
'required' => 1,
))->save();
}
$this->executeMigration('d6_user_profile_entity_display');
}
/**
* Tests migration of user profile fields.
*/
public function testUserProfileFields() {
$display = entity_get_display('user', 'user', 'default');
// Test a text field.
$component = $display->getComponent('profile_color');
$this->assertIdentical('text_default', $component['type']);
// Test a list field.
$component = $display->getComponent('profile_bands');
$this->assertIdentical('text_default', $component['type']);
// Test a date field.
$component = $display->getComponent('profile_birthdate');
$this->assertIdentical('datetime_default', $component['type']);
// Test PROFILE_PRIVATE field is hidden.
$this->assertNull($display->getComponent('profile_sell_address'));
// Test PROFILE_HIDDEN field is hidden.
$this->assertNull($display->getComponent('profile_sold_to'));
}
}

View file

@ -1,127 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserProfileEntityFormDisplayTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\Core\Database\Database;
/**
* Tests the user profile entity form display migration.
*
* @group migrate_drupal
*/
class MigrateUserProfileEntityFormDisplayTest extends MigrateDrupal6TestBase {
static $modules = array('link', 'options', 'datetime', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Create some fields so the data gets stored.
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_color',
'type' => 'text',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_biography',
'type' => 'text_long',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_sell_address',
'type' => 'boolean',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_sold_to',
'type' => 'list_string',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_bands',
'type' => 'text',
'cardinality' => -1,
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_blog',
'type' => 'link',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_birthdate',
'type' => 'datetime',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_love_migrations',
'type' => 'boolean',
))->save();
$this->loadDumps([
'ProfileFields.php',
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
]);
$field_data = Database::getConnection('default', 'migrate')
->select('profile_fields', 'u')
->fields('u')
->execute()
->fetchAll();
foreach ($field_data as $field) {
entity_create('field_config', array(
'label' => $field->title,
'description' => '',
'field_name' => $field->name,
'entity_type' => 'user',
'bundle' => 'user',
'required' => 1,
))->save();
}
$this->executeMigration('d6_user_profile_entity_form_display');
}
/**
* Tests migration of user profile fields.
*/
public function testUserProfileEntityFormDisplay() {
$display = entity_get_form_display('user', 'user', 'default');
// Test a text field.
$component = $display->getComponent('profile_color');
$this->assertIdentical('text_textfield', $component['type']);
// Test a list field.
$component = $display->getComponent('profile_bands');
$this->assertIdentical('text_textfield', $component['type']);
// Test a date field.
$component = $display->getComponent('profile_birthdate');
$this->assertIdentical('datetime_default', $component['type']);
// Test PROFILE_PRIVATE field is hidden.
$this->assertNull($display->getComponent('profile_sell_address'));
// Test PROFILE_HIDDEN field is hidden.
$this->assertNull($display->getComponent('profile_sold_to'));
// Test that a checkbox field has the proper display label setting.
$component = $display->getComponent('profile_love_migrations');
$this->assertIdentical('boolean_checkbox', $component['type']);
$this->assertIdentical(true, $component['settings']['display_label']);
}
}

View file

@ -1,114 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserProfileFieldInstanceTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldConfig;
/**
* Tests the user profile field instance migration.
*
* @group migrate_drupal
*/
class MigrateUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
static $modules = array('field', 'link', 'options', 'datetime', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_user_profile_field' => array(
array(array(1), array('user', 'profile_color')),
),
);
$this->prepareMigrations($id_mappings);
$this->createFields();
$this->loadDumps(array(
'ProfileFields.php',
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
));
$this->executeMigration('d6_user_profile_field_instance');
}
/**
* Tests migration of user profile fields.
*/
public function testUserProfileFields() {
// Migrated a text field.
$field = FieldConfig::load('user.user.profile_color');
$this->assertIdentical('Favorite color', $field->label());
$this->assertIdentical('List your favorite color', $field->getDescription());
// Migrated a textarea.
$field = FieldConfig::load('user.user.profile_biography');
$this->assertIdentical('Biography', $field->label());
$this->assertIdentical('Tell people a little bit about yourself', $field->getDescription());
// Migrated checkbox field.
$field = FieldConfig::load('user.user.profile_sell_address');
$this->assertIdentical('Sell your email address?', $field->label());
$this->assertIdentical("If you check this box, we'll sell your address to spammers to help line the pockets of our shareholders. Thanks!", $field->getDescription());
// Migrated selection field.
$field = FieldConfig::load('user.user.profile_sold_to');
$this->assertIdentical('Sales Category', $field->label());
$this->assertIdentical("Select the sales categories to which this user's address was sold.", $field->getDescription());
// Migrated list field.
$field = FieldConfig::load('user.user.profile_bands');
$this->assertIdentical('Favorite bands', $field->label());
$this->assertIdentical("Enter your favorite bands. When you've saved your profile, you'll be able to find other people with the same favorites.", $field->getDescription());
/*
// Migrated URL field.
$field = FieldConfig::load('user.user.profile_blog');
$this->assertIdentical('Your blog', $field->label());
$this->assertIdentical("Paste the full URL, $field->getDescription(), including http://, of your personal blog.");
*/
// Migrated date field.
$field = FieldConfig::load('user.user.profile_birthdate');
$this->assertIdentical('Birthdate', $field->label());
$this->assertIdentical("Enter your birth date and we'll send you a coupon.", $field->getDescription());
// Another migrated checkbox field, with a different source visibility setting.
$field = FieldConfig::load('user.user.profile_love_migrations');
$this->assertIdentical('I love migrations', $field->label());
$this->assertIdentical("If you check this box, you love migrations.", $field->getDescription());
}
/**
* Helper to create fields.
*/
protected function createFields() {
$fields = array(
'profile_color' => 'text',
'profile_biography' => 'text_long',
'profile_sell_address' => 'boolean',
'profile_sold_to' => 'list_string',
'profile_bands' => 'text',
'profile_blog' => 'link',
'profile_birthdate' => 'datetime',
'profile_love_migrations' => 'boolean',
);
foreach ($fields as $name => $type) {
entity_create('field_storage_config', array(
'field_name' => $name,
'entity_type' => 'user',
'type' => $type,
))->save();
}
}
}

View file

@ -1,85 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserProfileFieldTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Tests the user profile field migration.
*
* @group migrate_drupal
*/
class MigrateUserProfileFieldTest extends MigrateDrupal6TestBase {
static $modules = array('link', 'options', 'datetime', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps([
'ProfileFields.php',
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
]);
$this->executeMigration('d6_user_profile_field');
}
/**
* Tests migration of user profile fields.
*/
public function testUserProfileFields() {
// Migrated a text field.
$field_storage = FieldStorageConfig::load('user.profile_color');
$this->assertIdentical('text', $field_storage->getType(), 'Field type is text.');
$this->assertIdentical(1, $field_storage->getCardinality(), 'Text field has correct cardinality');
// Migrated a textarea.
$field_storage = FieldStorageConfig::load('user.profile_biography');
$this->assertIdentical('text_long', $field_storage->getType(), 'Field type is text_long.');
// Migrated checkbox field.
$field_storage = FieldStorageConfig::load('user.profile_sell_address');
$this->assertIdentical('boolean', $field_storage->getType(), 'Field type is boolean.');
// Migrated selection field.
$field_storage = FieldStorageConfig::load('user.profile_sold_to');
$this->assertIdentical('list_string', $field_storage->getType(), 'Field type is list_string.');
$settings = $field_storage->getSettings();
$this->assertEqual($settings['allowed_values'], array(
'Pill spammers' => 'Pill spammers',
'Fitness spammers' => 'Fitness spammers',
'Back\slash' => 'Back\slash',
'Forward/slash' => 'Forward/slash',
'Dot.in.the.middle' => 'Dot.in.the.middle',
'Faithful servant' => 'Faithful servant',
'Anonymous donor' => 'Anonymous donor',
));
$this->assertIdentical('list_string', $field_storage->getType(), 'Field type is list_string.');
// Migrated list field.
$field_storage = FieldStorageConfig::load('user.profile_bands');
$this->assertIdentical('text', $field_storage->getType(), 'Field type is text.');
$this->assertIdentical(-1, $field_storage->getCardinality(), 'List field has correct cardinality');
/*
// Migrated URL field.
$field_storage = FieldStorageConfig::load('user.profile_blog');
$this->assertIdentical('link', $field_storage->getType(), 'Field type is link.');
*/
// Migrated date field.
$field_storage = FieldStorageConfig::load('user.profile_birthdate');
$this->assertIdentical('datetime', $field_storage->getType(), 'Field type is datetime.');
$this->assertIdentical('date', $field_storage->getSettings()['datetime_type']);
}
}

View file

@ -1,174 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserProfileValuesTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\Core\Database\Database;
use Drupal\user\Entity\User;
/**
* User profile values migration.
*
* @group migrate_drupal
*/
class MigrateUserProfileValuesTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array(
'link',
'options',
'datetime',
'text',
'file',
'image',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Create some fields so the data gets stored.
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_color',
'type' => 'text',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_biography',
'type' => 'text_long',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_sell_address',
'type' => 'boolean',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_sold_to',
'type' => 'list_string',
'settings' => array(
'allowed_values' => array(
'Pill spammers' => 'Pill spammers',
'Fitness spammers' => 'Fitness spammers',
)
)
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_bands',
'type' => 'text',
'cardinality' => -1,
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_blog',
'type' => 'link',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_birthdate',
'type' => 'datetime',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'profile_love_migrations',
'type' => 'boolean',
))->save();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_user_profile_field_instance' => array(
array(array(1), array('user', 'user', 'fieldname')),
),
'd6_user_profile_entity_display' => array(
array(array(1), array('user', 'user', 'default', 'fieldname')),
),
'd6_user_profile_entity_form_display' => array(
array(array(1), array('user', 'user', 'default', 'fieldname')),
),
'd6_user' => array(
array(array(2), array(2)),
array(array(8), array(8)),
array(array(15), array(15)),
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps([
'ProfileFields.php',
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
]);
$field_data = Database::getConnection('default', 'migrate')
->select('profile_fields', 'u')
->fields('u')
->execute()
->fetchAll();
// Create the field instances.
foreach ($field_data as $field) {
entity_create('field_config', array(
'label' => $field->title,
'description' => '',
'field_name' => $field->name,
'entity_type' => 'user',
'bundle' => 'user',
'required' => 0,
))->save();
}
// Create our users for the node authors.
$query = Database::getConnection('default', 'migrate')->query('SELECT * FROM {users} WHERE uid NOT IN (0, 1)');
while(($row = $query->fetchAssoc()) !== FALSE) {
$user = entity_create('user', $row);
$user->enforceIsNew();
$user->save();
}
$migration_format = entity_load('migration', 'd6_profile_values:user');
$this->executeMigration($migration_format);
}
/**
* Tests Drupal 6 profile values to Drupal 8 migration.
*/
public function testUserProfileValues() {
$user = User::load(2);
$this->assertFalse(is_null($user));
$this->assertIdentical('red', $user->profile_color->value);
$expected = <<<EOT
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nulla sapien, congue nec risus ut, adipiscing aliquet felis. Maecenas quis justo vel nulla varius euismod. Quisque metus metus, cursus sit amet sem non, bibendum vehicula elit. Cras dui nisl, eleifend at iaculis vitae, lacinia ut felis. Nullam aliquam ligula volutpat nulla consectetur accumsan. Maecenas tincidunt molestie diam, a accumsan enim fringilla sit amet. Morbi a tincidunt tellus. Donec imperdiet scelerisque porta. Sed quis sem bibendum eros congue sodales. Vivamus vel fermentum est, at rutrum orci. Nunc consectetur purus ut dolor pulvinar, ut volutpat felis congue. Cras tincidunt odio sed neque sollicitudin, vehicula tempor metus scelerisque.
EOT;
$this->assertIdentical($expected, $user->profile_biography->value);
$this->assertIdentical('1', $user->profile_sell_address->value);
$this->assertIdentical('Back\slash', $user->profile_sold_to->value);
$this->assertIdentical('AC/DC', $user->profile_bands[0]->value);
$this->assertIdentical('Eagles', $user->profile_bands[1]->value);
$this->assertIdentical('Elton John', $user->profile_bands[2]->value);
$this->assertIdentical('Lemonheads', $user->profile_bands[3]->value);
$this->assertIdentical('Rolling Stones', $user->profile_bands[4]->value);
$this->assertIdentical('Queen', $user->profile_bands[5]->value);
$this->assertIdentical('The White Stripes', $user->profile_bands[6]->value);
$this->assertIdentical('1974-06-02', $user->profile_birthdate->value);
$user = User::load(8);
$this->assertIdentical('Forward/slash', $user->profile_sold_to->value);
$user = User::load(15);
$this->assertIdentical('Dot.in.the.middle', $user->profile_sold_to->value);
}
}

View file

@ -1,98 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserRoleTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\user\Entity\Role;
/**
* Upgrade user roles to user.role.*.yml.
*
* @group migrate_drupal
*/
class MigrateUserRoleTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array('filter', 'node');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// We need some sample data so we can use the Migration process plugin.
$id_mappings = array(
'd6_filter_format' => array(
array(array(1), array('filtered_html')),
array(array(2), array('full_html'))
),
);
$this->prepareMigrations($id_mappings);
$this->loadDumps([
'Permission.php',
'Role.php',
'Filters.php',
'FilterFormats.php',
'Variable.php',
]);
$this->executeMigration('d6_user_role');
}
/**
* Tests user role migration.
*/
public function testUserRole() {
/** @var \Drupal\migrate\entity\Migration $migration */
$migration = entity_load('migration', 'd6_user_role');
$rid = 'anonymous';
$anonymous = Role::load($rid);
$this->assertIdentical($rid, $anonymous->id());
$this->assertIdentical(array('migrate test anonymous permission', 'use text format filtered_html'), $anonymous->getPermissions());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(1)));
$rid = 'authenticated';
$authenticated = Role::load($rid);
$this->assertIdentical($rid, $authenticated->id());
$this->assertIdentical(array('migrate test authenticated permission', 'use text format filtered_html'), $authenticated->getPermissions());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(2)));
$rid = 'migrate_test_role_1';
$migrate_test_role_1 = Role::load($rid);
$this->assertIdentical($rid, $migrate_test_role_1->id());
$this->assertIdentical(array(0 => 'migrate test role 1 test permission', 'use text format full_html'), $migrate_test_role_1->getPermissions());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(3)));
$rid = 'migrate_test_role_2';
$migrate_test_role_2 = Role::load($rid);
$this->assertIdentical(array(
'migrate test role 2 test permission',
'use PHP for settings',
'administer contact forms',
'skip comment approval',
'edit own blog content',
'edit any blog content',
'delete own blog content',
'delete any blog content',
'create forum content',
'delete any forum content',
'delete own forum content',
'edit any forum content',
'edit own forum content',
'administer nodes',
'access content overview',
), $migrate_test_role_2->getPermissions());
$this->assertIdentical($rid, $migrate_test_role_2->id());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(4)));
$rid = 'migrate_test_role_3_that_is_long';
$migrate_test_role_3 = Role::load($rid);
$this->assertIdentical($rid, $migrate_test_role_3->id());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(5)));
}
}

View file

@ -1,184 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateUserTest.
*/
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\user\Entity\User;
use Drupal\file\Entity\File;
use Drupal\Core\Database\Database;
use Drupal\user\RoleInterface;
/**
* Users migration.
*
* @group migrate_drupal
*/
class MigrateUserTest extends MigrateDrupal6TestBase {
/**
* The modules to be enabled during the test.
*
* @var array
*/
static $modules = array(
'link',
'options',
'datetime',
'text',
'file',
'image',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('file');
$this->installSchema('file', ['file_usage']);
// Create the user profile field and instance.
entity_create('field_storage_config', array(
'entity_type' => 'user',
'field_name' => 'user_picture',
'type' => 'image',
'translatable' => '0',
))->save();
entity_create('field_config', array(
'label' => 'User Picture',
'description' => '',
'field_name' => 'user_picture',
'entity_type' => 'user',
'bundle' => 'user',
'required' => 0,
))->save();
$file = entity_create('file', array(
'fid' => 2,
'uid' => 2,
'filename' => 'image-test.jpg',
'uri' => "public://image-test.jpg",
'filemime' => 'image/jpeg',
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
));
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
$file->save();
$file = entity_create('file', array(
'fid' => 8,
'uid' => 8,
'filename' => 'image-test.png',
'uri' => "public://image-test.png",
'filemime' => 'image/png',
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
));
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-2.jpg'));
$file->save();
$this->loadDumps([
'Filters.php',
'FilterFormats.php',
'Variable.php',
'ProfileFields.php',
'Permission.php',
'Role.php',
'Users.php',
'ProfileValues.php',
'UsersRoles.php',
'EventTimezones.php',
]);
$id_mappings = array(
'd6_user_role' => array(
array(array(1), array('anonymous user')),
array(array(2), array('authenticated user')),
array(array(3), array('migrate test role 1')),
array(array(4), array('migrate test role 2')),
array(array(5), array('migrate test role 3')),
),
'd6_user_picture_entity_display' => array(
array(array(1), array('user', 'user', 'default', 'user_picture')),
),
'd6_user_picture_entity_form_display' => array(
array(array(1), array('user', 'user', 'default', 'user_picture')),
),
'd6_user_picture_file' => array(
array(array(2), array(2)),
array(array(8), array(8)),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_user');
}
/**
* Tests the Drupal6 user to Drupal 8 migration.
*/
public function testUser() {
$users = Database::getConnection('default', 'migrate')
->select('users', 'u')
->fields('u')
->execute()
->fetchAll();
foreach ($users as $source) {
// Get roles directly from the source.
$rids = Database::getConnection('default', 'migrate')
->select('users_roles', 'ur')
->fields('ur', array('rid'))
->condition('ur.uid', $source->uid)
->execute()
->fetchCol();
$roles = array(RoleInterface::AUTHENTICATED_ID);
$migration_role = entity_load('migration', 'd6_user_role');
foreach ($rids as $rid) {
$role = $migration_role->getIdMap()->lookupDestinationId(array($rid));
$roles[] = reset($role);
}
/** @var \Drupal\user\UserInterface $user */
$user = User::load($source->uid);
$this->assertIdentical($source->uid, $user->id());
$this->assertIdentical($source->name, $user->label());
$this->assertIdentical($source->mail, $user->getEmail());
$this->assertIdentical($source->created, $user->getCreatedTime());
$this->assertIdentical($source->access, $user->getLastAccessedTime());
$this->assertIdentical($source->login, $user->getLastLoginTime());
$is_blocked = $source->status == 0;
$this->assertIdentical($is_blocked, $user->isBlocked());
// $user->getPreferredLangcode() might fallback to default language if the
// user preferred language is not configured on the site. We just want to
// test if the value was imported correctly.
$this->assertIdentical($source->language, $user->preferred_langcode->value);
$time_zone = $source->expected_timezone ?: $this->config('system.date')->get('timezone.default');
$this->assertIdentical($time_zone, $user->getTimeZone());
$this->assertIdentical($source->init, $user->getInitialEmail());
$this->assertIdentical($roles, $user->getRoles());
// We have one empty picture in the data so don't try load that.
if (!empty($source->picture)) {
// Test the user picture.
$file = File::load($user->user_picture->target_id);
$this->assertIdentical(basename($source->picture), $file->getFilename());
}
// Use the API to check if the password has been salted and re-hashed to
// conform the Drupal >= 7.
$this->assertTrue(\Drupal::service('password')->check($source->pass_plain, $user->getPassword()));
}
}
}

View file

@ -1,78 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\MigrationStorageTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit;
use Drupal\Tests\migrate\Unit\MigrateTestCase;
/**
* Tests the MigrationStorage load plugin.
*
* @group migrate_drupal
*/
class MigrationStorageTest extends MigrateTestCase {
protected $migrationConfiguration = array('id' => 'test_migration', 'migrationClass' => 'Drupal\migrate_drupal\Entity\Migration');
/**
* Test that the entity load hooks are called on dynamic migrations.
*
* @dataProvider entityIdsDataProvider
*/
public function testMigrationStorage($entity_ids) {
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type
->expects($this->exactly(2))
->method('isStaticallyCacheable')
->willReturn(FALSE);
$load_plugin = $this->getMock('Drupal\migrate_drupal\Plugin\MigrateLoadInterface');
$load_plugin
->expects($this->once())
->method('loadMultiple')
->willReturn([]);
$migration = $this->getMigration();
$migration
->expects($this->once())
->method('getLoadPlugin')
->willReturn($load_plugin);
$storage = $this->getMock('Drupal\migrate_drupal\TestMigrationStorage', ['postLoad', 'doLoadMultiple'], [$entity_type]);
$storage
->expects($this->exactly(2))
->method('postLoad');
$storage
->expects($this->once())
->method('doLoadMultiple')
->willReturn(['test_migration' => $migration]);
$storage->loadMultiple($entity_ids);
}
/**
* The data provider for migration storage.
*
* @return array
* The entity ids.
*/
public function entityIdsDataProvider() {
return [
[['test_migration:bundle']],
[NULL],
];
}
}
namespace Drupal\migrate_drupal;
class TestMigrationStorage extends MigrationStorage {
public function __construct($entity_type) {
$this->entityType = $entity_type;
}
}

View file

@ -1,28 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\CommentSourceWithHighWaterTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
/**
* Tests the Drupal 6 comment source w/ high water handling.
*
* @group migrate_drupal
*/
class CommentSourceWithHighWaterTest extends CommentTestBase {
const ORIGINAL_HIGH_WATER = 1382255613;
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->migrationConfiguration['highWaterProperty']['field'] = 'timestamp';
array_shift($this->expectedResults);
parent::setUp();
}
}

View file

@ -1,17 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\CommentTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
/**
* Tests D6 comment source plugin.
*
* @group migrate_drupal
*/
class CommentTest extends CommentTestBase {
}

View file

@ -1,87 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\CommentTestBase.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Base class for comment source unit tests.
*/
abstract class CommentTestBase 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\migrate_drupal\Plugin\migrate\source\d6\Comment';
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
// The ID of the entity, can be any string.
'id' => 'test',
// Leave it empty for now.
'idlist' => array(),
// This needs to be the identifier of the actual key: cid for comment, nid
// for node and so on.
'source' => array(
'plugin' => 'd6_comment',
),
);
// We need to set up the database contents; it's easier to do that below.
protected $expectedResults = array(
array(
'cid' => 1,
'pid' => 0,
'nid' => 2,
'uid' => 3,
'subject' => 'subject value 1',
'comment' => 'comment value 1',
'hostname' => 'hostname value 1',
'timestamp' => 1382255613,
'status' => 1,
'thread' => '',
'name' => '',
'mail' => '',
'homepage' => '',
'format' => 'testformat1',
'type' => 'story',
),
array(
'cid' => 2,
'pid' => 1,
'nid' => 3,
'uid' => 4,
'subject' => 'subject value 2',
'comment' => 'comment value 2',
'hostname' => 'hostname value 2',
'timestamp' => 1382255662,
'status' => 1,
'thread' => '',
'name' => '',
'mail' => '',
'homepage' => '',
'format' => 'testformat2',
'type' => 'page',
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
foreach ($this->expectedResults as $k => $row) {
$this->databaseContents['comments'][$k] = $row;
$this->databaseContents['comments'][$k]['status'] = 1 - $this->databaseContents['comments'][$k]['status'];
}
// Add node table data.
$this->databaseContents['node'][] = array('nid' => 2, 'type' => 'story');
$this->databaseContents['node'][] = array('nid' => 3, 'type' => 'page');
parent::setUp();
}
}

View file

@ -1,108 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FieldInstancePerViewModeTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 fields per view mode source plugin.
*
* @group migrate_drupal
*/
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\migrate_drupal\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',
// Leave it empty for now.
'idlist' => array(),
'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

@ -1,98 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FieldInstanceTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 field instance source plugin.
*
* @group migrate_drupal
*/
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\migrate_drupal\Plugin\migrate\source\d6\FieldInstance';
// The fake Migration configuration entity.
protected $migrationConfiguration = [
// The id of the entity, can be any string.
'id' => 'test_fieldinstance',
// Leave it empty for now.
'idlist' => [],
'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

@ -1,80 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FieldTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 field source plugin.
*
* @group migrate_drupal
*/
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\migrate_drupal\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',
// Leave it empty for now.
'idlist' => array(),
'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

@ -1,63 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FileTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 file source plugin.
*
* @group migrate_drupal
*/
class FileTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\File';
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
// The ID of the entity, can be any string.
'id' => 'test',
// Leave it empty for now.
'idlist' => array(),
'source' => array(
'plugin' => 'd6_file',
),
);
protected $expectedResults = array(
array(
'fid' => 1,
'uid' => 1,
'filename' => 'migrate-test-file-1.pdf',
'filepath' => 'sites/default/files/migrate-test-file-1.pdf',
'filemime' => 'application/pdf',
'filesize' => 890404,
'status' => 1,
'timestamp' => 1382255613,
),
array(
'fid' => 2,
'uid' => 1,
'filename' => 'migrate-test-file-2.pdf',
'filepath' => 'sites/default/files/migrate-test-file-2.pdf',
'filemime' => 'application/pdf',
'filesize' => 204124,
'status' => 1,
'timestamp' => 1382255662,
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['files'] = $this->expectedResults;
parent::setUp();
}
}

View file

@ -1,96 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\ProfileFieldTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 profile field source plugin.
*
* @group migrate_drupal
*/
class ProfileFieldTest 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\migrate_drupal\Plugin\migrate\source\d6\ProfileField';
// The fake Migration configuration entity.
protected $migrationConfiguration = [
// The id of the entity, can be any string.
'id' => 'test_profile_fields',
// Leave it empty for now.
'idlist' => [],
'source' => [
'plugin' => 'd6_profile_field',
],
];
// We need to set up the database contents; it's easier to do that below.
// These are sample result queries.
// @todo Add multiple cases.
protected $expectedResults = [
[
'fid' => 1,
'title' => 'First name',
'name' => 'profile_first_name',
'explanation' => 'First name user',
'category' => 'profile',
'page' => '',
'type' => 'textfield',
'weight' => 0,
'required' => 1,
'register' => 0,
'visibility' => 2,
'autocomplete' => 0,
'options' => [],
],
[
'fid' => 2,
'title' => 'Last name',
'name' => 'profile_last_name',
'explanation' => 'Last name user',
'category' => 'profile',
'page' => '',
'type' => 'textfield',
'weight' => 0,
'required' => 0,
'register' => 0,
'visibility' => 2,
'autocomplete' => 0,
'options' => [],
],
[
'fid' => 3,
'title' => 'Policy',
'name' => 'profile_policy',
'explanation' => 'A checkbox that say if you accept policy of website',
'category' => 'profile',
'page' => '',
'type' => 'checkbox',
'weight' => 0,
'required' => 1,
'register' => 1,
'visibility' => 2,
'autocomplete' => 0,
'options' => [],
],
];
/**
* Prepopulate contents with results.
*/
protected function setUp() {
$this->databaseContents['profile_fields'] = $this->expectedResults;
foreach ($this->databaseContents['profile_fields'] as &$row) {
$row['options'] = serialize([]);
}
parent::setUp();
}
}

View file

@ -1,88 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\RoleTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 role source plugin.
*
* @group migrate_drupal
*/
class RoleTest 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\migrate_drupal\Plugin\migrate\source\d6\Role';
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
// The ID of the entity, can be any string.
'id' => 'test',
// Leave it empty for now.
'idlist' => array(),
// This needs to be the identifier of the actual key: cid for comment, nid
// for node and so on.
'source' => array(
'plugin' => 'd6_user_role',
),
);
protected $expectedResults = array(
array(
'rid' => 1,
'name' => 'anonymous user',
'permissions' => array(
'access content',
),
),
array(
'rid' => 2,
'name' => 'authenticated user',
'permissions' => array(
'access comments',
'access content',
'post comments',
'post comments without approval',
),
),
array(
'rid' => 3,
'name' => 'administrator',
'permissions' => array(
'access comments',
'administer comments',
'post comments',
'post comments without approval',
'access content',
'administer content types',
'administer nodes',
),
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
foreach ($this->expectedResults as $row) {
$this->databaseContents['permission'][] = array(
'perm' => implode(', ', $row['permissions']),
'rid' => $row['rid'],
);
unset($row['permissions']);
$this->databaseContents['role'][] = $row;
}
$this->databaseContents['filter_formats'][] = array(
'format' => 1,
'roles' => '',
);
parent::setUp();
}
}

View file

@ -1,21 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestComment.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment;
class TestComment extends Comment {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}

View file

@ -1,37 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestNode.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Node;
/**
* Provides a node source plugin used for unit testing.
*/
class TestNode extends Node {
/**
* Sets the database connection for this source plugin.
*
* @param \Drupal\Core\Database\Connection $database
*/
public function setDatabase(Connection $database) {
$this->database = $database;
}
/**
* Sets the module handler for this source plugin.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
*/
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}

View file

@ -1,37 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestNodeRevision.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeRevision;
/**
* Provides a node revision source plugin used for unit testing.
*/
class TestNodeRevision extends NodeRevision {
/**
* Sets the database connection for this source plugin.
*
* @param \Drupal\Core\Database\Connection $database
*/
public function setDatabase(Connection $database) {
$this->database = $database;
}
/**
* Sets the module handler for this source plugin.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
*/
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}

View file

@ -1,21 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestTerm.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Term;
class TestTerm extends Term {
public function setDatabase(Connection $database) {
$this->database = $database;
}
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
}

View file

@ -1,50 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\UserPictureTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 user picture source plugin.
*
* @group migrate_drupal
*/
class UserPictureTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPicture';
protected $migrationConfiguration = array(
'id' => 'test_user_picture',
'idlist' => array(),
'source' => array(
'plugin' => 'd6_user_picture',
),
);
protected $expectedResults = array(
array(
'uid' => 1,
'access' => 1382835435,
'picture' => 'sites/default/files/pictures/picture-1.jpg',
),
array(
'uid' => 2,
'access' => 1382835436,
'picture' => 'sites/default/files/pictures/picture-2.jpg',
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['users'] = $this->expectedResults;
parent::setUp();
}
}

View file

@ -1,89 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\UserTest.
*/
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 user source plugin.
*
* @group migrate_drupal
*/
class UserTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\User';
protected $migrationConfiguration = array(
'id' => 'test',
'idlist' => array(),
'source' => array(
'plugin' => 'd6_user',
),
);
protected $expectedResults = array(
array(
'uid' => 2,
'name' => 'admin',
// @todo d6 hash?
'pass' => '1234',
'mail' => 'admin@example.com',
'theme' => '',
'signature' => '',
'signature_format' => 0,
'created' => 1279402616,
'access' => 1322981278,
'login' => 1322699994,
'status' => 0,
'timezone' => 'America/Lima',
'language' => 'en',
// @todo Add the file when needed.
'picture' => 'sites/default/files/pictures/picture-1.jpg',
'init' => 'admin@example.com',
'data' => NULL,
),
array(
'uid' => 4,
'name' => 'alice',
// @todo d6 hash?
'pass' => '1234',
'mail' => 'alice@example.com',
'theme' => '',
'signature' => '',
'signature_format' => 0,
'created' => 1322981368,
'access' => 1322982419,
'login' => 132298140,
'status' => 0,
'timezone' => 'America/Lima',
'language' => 'en',
'picture' => '',
'init' => 'alice@example.com',
'data' => NULL,
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
foreach ($this->expectedResults as $k => $row) {
$this->databaseContents['users'][$k] = $row;
}
// getDatabase() will not create empty tables, so we need to insert data
// even if it's irrelevant to the test.
$this->databaseContents['users_roles'] = array(
array(
'uid' => 99,
'rid' => 99,
),
);
parent::setUp();
}
}

View file

@ -1,50 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\search\Tests\d6\Migrate\SearchConfigsTest.
*/
namespace Drupal\search\Tests\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to search.settings.yml.
*
* @group search
*/
class MigrateSearchConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('search');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_search_settings');
}
/**
* Tests migration of search variables to search.settings.yml.
*/
public function testSearchSettings() {
$config = $this->config('search.settings');
$this->assertIdentical(3, $config->get('index.minimum_word_size'));
$this->assertIdentical(TRUE, $config->get('index.overlap_cjk'));
$this->assertIdentical(100, $config->get('index.cron_limit'));
$this->assertIdentical(TRUE, $config->get('logging'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'search.settings', $config->get());
}
}

View file

@ -1,448 +0,0 @@
/**
* @file
* Generic theme-independent base styles.
*/
/**
* Autocomplete.
*
* @see autocomplete.js
*/
/* Animated throbber */
.js input.form-autocomplete {
background-image: url(../../../misc/throbber-inactive.png);
background-position: 100% center; /* LTR */
background-repeat: no-repeat;
}
.js[dir="rtl"] input.form-autocomplete {
background-position: 0% center;
}
.js input.form-autocomplete.ui-autocomplete-loading {
background-image: url(../../../misc/throbber-active.gif);
background-position: 100% center; /* LTR */
}
.js[dir="rtl"] input.form-autocomplete.ui-autocomplete-loading {
background-position: 0% center;
}
/**
* Unboxed fieldsets for grouping form elements.
*/
.fieldgroup {
border-width: 0;
padding: 0;
}
/**
* Collapsible details.
*
* @see collapse.js
*/
.js details:not([open]) .details-wrapper {
display: none;
}
/**
* Resizable textareas.
*/
.form-textarea-wrapper textarea {
display: block;
margin: 0;
width: 100%;
box-sizing: border-box;
}
.resize-none {
resize: none;
}
.resize-vertical {
resize: vertical;
min-height: 2em;
}
.resize-horizontal {
resize: horizontal;
max-width: 100%;
}
.resize-both {
resize: both;
max-width: 100%;
min-height: 2em;
}
/**
* TableDrag behavior.
*
* @see tabledrag.js
*/
body.drag {
cursor: move;
}
tr.region-title {
font-weight: bold;
}
tr.region-message {
color: #999;
}
tr.region-populated {
display: none;
}
tr.add-new .tabledrag-changed {
display: none;
}
.draggable a.tabledrag-handle {
cursor: move;
float: left; /* LTR */
height: 1.7em;
margin-left: -1em; /* LTR */
overflow: hidden;
text-decoration: none;
}
[dir="rtl"] .draggable a.tabledrag-handle {
float: right;
margin-right: -1em;
margin-left: 0;
}
a.tabledrag-handle:hover {
text-decoration: none;
}
a.tabledrag-handle .handle {
background: url(../../../misc/icons/787878/move.svg) no-repeat 6px 7px;
height: 14px;
margin: -0.4em 0.5em 0;
padding: 0.42em 0.5em;
width: 14px;
}
a.tabledrag-handle:hover .handle,
a.tabledrag-handle:focus .handle {
background-image: url(../../../misc/icons/000000/move.svg);
}
.touch .draggable td {
padding: 0 10px;
}
.touch .draggable .menu-item__link {
display: inline-block;
padding: 10px 0;
}
.touch a.tabledrag-handle {
height: 44px;
width: 40px;
}
.touch a.tabledrag-handle .handle {
background-position: 40% 19px;
height: 21px;
}
.touch .draggable.drag a.tabledrag-handle .handle {
background-position: 50% -32px;
}
.indentation {
float: left; /* LTR */
height: 1.7em;
margin: -0.4em 0.2em -0.4em -0.4em; /* LTR */
padding: 0.42em 0 0.42em 0.6em; /* LTR */
width: 20px;
}
[dir="rtl"] .indentation {
float: right;
margin: -0.4em -0.4em -0.4em 0.2em;
padding: 0.42em 0.6em 0.42em 0;
}
div.tree-child {
background: url(../../../misc/tree.png) no-repeat 11px center; /* LTR */
}
div.tree-child-last {
background: url(../../../misc/tree-bottom.png) no-repeat 11px center; /* LTR */
}
[dir="rtl"] div.tree-child,
[dir="rtl"] div.tree-child-last {
background-position: -65px center;
}
div.tree-child-horizontal {
background: url(../../../misc/tree.png) no-repeat -11px center;
}
.tabledrag-toggle-weight-wrapper {
text-align: right; /* LTR */
}
[dir="rtl"] .tabledrag-toggle-weight-wrapper {
text-align: left;
}
/**
* TableHeader behavior.
*
* @see tableheader.js
*/
table.sticky-header {
background-color: #fff;
margin-top: 0;
z-index: 500;
top: 0;
}
/**
* Progress behavior.
*
* @see progress.js
*/
.progress {
position: relative;
}
.progress__track {
background-color: #fff;
border: 1px solid;
margin-top: 5px;
max-width: 100%;
min-width: 100px;
height: 16px;
}
.progress__bar {
background-color: #000;
height: 1.5em;
min-width: 3%;
max-width: 100%;
}
.progress__description,
.progress__percentage {
color: #555;
overflow: hidden;
font-size: .875em;
margin-top: 0.2em;
}
.progress__description {
float: left; /* LTR */
}
[dir="rtl"] .progress__description {
float: right;
}
.progress__percentage {
float: right; /* LTR */
}
[dir="rtl"] .progress__percentage {
float: left;
}
.progress--small .progress__track {
height: 7px;
}
.progress--small .progress__bar {
height: 7px;
background-size: 20px 20px;
}
/* Throbber */
.ajax-progress {
display: inline-block;
padding: 1px 5px 2px 5px;
}
[dir="rtl"] .ajax-progress {
float: right;
}
.ajax-progress-throbber .throbber {
background: transparent url(../../../misc/throbber-active.gif) no-repeat 0px center;
display: inline;
padding: 1px 5px 2px;
}
.ajax-progress-throbber .message {
display: inline;
padding: 1px 5px 2px;
}
tr .ajax-progress-throbber .throbber {
margin: 0 2px;
}
.ajax-progress-bar {
width: 16em;
}
/* Full screen throbber */
.ajax-progress-fullscreen {
/* Can't do center:50% middle: 50%, so approximate it for a typical window size. */
left: 49%;
position: fixed;
top: 48.5%;
z-index: 1000;
background-color: #232323;
background-image: url("../../../misc/loading-small.gif");
background-position: center center;
background-repeat: no-repeat;
border-radius: 7px;
height: 24px;
opacity: 0.9;
padding: 4px;
width: 24px;
}
/**
* Inline items.
*/
.container-inline div,
.container-inline label {
display: inline;
}
/* Details contents always need to be rendered as block. */
.container-inline .details-wrapper {
display: block;
}
/* Display form elements horizontally. */
.form--inline .form-item {
float: left; /* LTR */
margin-right: 0.5em; /* LTR */
}
[dir="rtl"] .form--inline .form-item {
float: right;
margin-right: 0;
margin-left: 0.5em;
}
.form--inline .form-item-separator {
margin-top: 2.3em;
margin-right: 1em; /* LTR */
margin-left: 0.5em; /* LTR */
}
[dir="rtl"] .form--inline .form-item-separator {
margin-right: 0.5em;
margin-left: 1em;
}
.form--inline .form-actions {
clear: left; /* LTR */
}
[dir="rtl"] .form--inline .form-actions {
clear: right;
}
/**
* Prevent text wrapping.
*/
.nowrap {
white-space: nowrap;
}
/**
* For anything you want to hide on page load when JS is enabled, so
* that you can use the JS to control visibility and avoid flicker.
*/
.js .js-hide {
display: none;
}
/**
* For anything you want to show on page load only when JS is enabled.
*/
.js-show {
display: none;
}
.js .js-show {
display: block;
}
/**
* Hide elements from all users.
*
* Used for elements which should not be immediately displayed to any user. An
* example would be collapsible details that will be expanded with a click
* from a user. The effect of this class can be toggled with the jQuery show()
* and hide() functions.
*/
.hidden {
display: none;
}
/**
* Hide elements visually, but keep them available for screen readers.
*
* Used for information required for screen reader users to understand and use
* the site where visual display is undesirable. Information provided in this
* manner should be kept concise, to avoid unnecessary burden on the user.
* "!important" is used to prevent unintentional overrides.
*/
.visually-hidden {
position: absolute !important;
clip: rect(1px, 1px, 1px, 1px);
overflow: hidden;
height: 1px;
width: 1px;
word-wrap: normal;
}
/**
* The .focusable class extends the .visually-hidden class to allow
* the element to be focusable when navigated to via the keyboard.
*/
.visually-hidden.focusable:active,
.visually-hidden.focusable:focus {
position: static !important;
clip: auto;
overflow: visible;
height: auto;
width: auto;
}
/**
* Hide visually and from screen readers, but maintain layout.
*/
.invisible {
visibility: hidden;
}
/**
* Float clearing.
*
* Based on the micro clearfix hack by Nicolas Gallagher, with the :before
* pseudo selector removed to allow normal top margin collapse.
*
* @see http://nicolasgallagher.com/micro-clearfix-hack
*/
.clearfix:after {
content: "";
display: table;
clear: both;
}
/**
* Text alignment classes.
*/
.text-align-left {
text-align: left;
}
.text-align-right {
text-align: right;
}
.text-align-center {
text-align: center;
}
.text-align-justify {
text-align: justify;
}
/**
* Alignment classes (images, videos, blockquotes ).
*/
.align-left {
float: left;
}
.align-right {
float: right;
}
.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
/*
* Remove browser styles, especially for <buttons> and so on.
*/
.reset-appearance {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: 0 none;
background: transparent;
padding: 0;
margin: 0;
line-height: inherit;
}
/*
* Contain positioned elements.
*/
.position-container {
position: relative;
}

View file

@ -1,616 +0,0 @@
/**
* @file
* Basic styling for common markup.
*/
/**
* Publishing status.
*/
.node--unpublished {
background-color: #fff4f4;
}
/**
* Markup generated by tablesort-indicator.html.twig.
*/
th.is-active img {
display: inline;
}
td.is-active {
background-color: #ddd;
}
/**
* Markup generated by item-list.html.twig.
*/
.item-list .title {
font-weight: bold;
}
.item-list ul {
margin: 0 0 0.75em 0;
padding: 0;
}
.item-list ul li {
margin: 0 0 0.25em 1.5em; /* LTR */
padding: 0;
}
[dir="rtl"] .item-list ul li {
margin: 0 1.5em 0.25em 0;
}
/**
* Markup generated by Form API.
*/
.form-item,
.form-actions {
margin-top: 1em;
margin-bottom: 1em;
}
tr.odd .form-item,
tr.even .form-item {
margin-top: 0;
margin-bottom: 0;
}
.form-composite > .fieldset-wrapper > .description,
.form-item .description {
font-size: 0.85em;
}
label.option {
display: inline;
font-weight: normal;
}
.form-composite > legend,
.label {
display:inline;
font-size: inherit;
font-weight: bold;
margin: 0;
padding: 0;
}
.form-checkboxes .form-item,
.form-radios .form-item {
margin-top: 0.4em;
margin-bottom: 0.4em;
}
.form-type-radio .description,
.form-type-checkbox .description {
margin-left: 2.4em;
}
.marker {
color: #e00;
}
.form-required:after {
content: '';
vertical-align: super;
display: inline-block;
/* Use a background image to prevent screen readers from announcing the text. */
background-image: url(../../../misc/icons/ee0000/required.svg);
background-repeat: no-repeat;
background-size: 6px 6px;
width: 6px;
height: 6px;
margin: 0 0.3em;
}
abbr.tabledrag-changed,
abbr.ajax-changed {
border-bottom: none;
}
.form-item input.error,
.form-item textarea.error,
.form-item select.error {
border: 2px solid red;
}
.button,
.image-button {
margin-left: 1em;
margin-right: 1em;
}
.button:first-child,
.image-button:first-child {
margin-left: 0;
margin-right: 0;
}
/* Inline error messages. */
.form-item--error-message:before {
content: '';
display: inline-block;
height: 14px;
width: 14px;
vertical-align: sub;
background: url(../../../misc/icons/ea2800/error.svg) no-repeat;
background-size: contain;
}
/**
* Inline items.
*/
.container-inline label:after,
.container-inline .label:after {
content: ':';
}
.form-type-radios .container-inline label:after {
content: '';
}
.form-type-radios .container-inline .form-type-radio {
margin: 0 1em;
}
.container-inline .form-actions,
.container-inline.form-actions {
margin-top: 0;
margin-bottom: 0;
}
/**
* Markup generated by #type 'more_link'.
*/
.more-link {
display: block;
text-align: right; /* LTR */
}
[dir="rtl"] .more-link {
text-align: left;
}
/* Style for the help icon. */
.icon-help {
background: url(../../../misc/help.png) 0 50% no-repeat; /* LTR */
padding: 1px 0 1px 20px; /* LTR */
}
[dir="rtl"] .icon-help {
background-position: 100% 50%;
padding: 1px 20px 1px 0;
}
/**
* Feed Icon.
* Markup generated by feed-icon.html.twig.
*/
.feed-icon {
background: url(../../../misc/feed.png) no-repeat;
overflow: hidden;
text-indent: -9999px;
display: block;
width: 16px;
height: 16px;
}
/**
* Markup generated by pager.html.twig.
*/
.pager__items {
clear: both;
text-align: center;
}
.pager__item {
display: inline;
padding: 0.5em;
}
.pager__item.is-active {
font-weight: bold;
}
/**
* Show buttons as links.
*/
button.link {
background: transparent;
border: 0;
cursor: pointer;
margin: 0;
padding: 0;
font-size: 1em;
}
label button.link {
font-weight: bold;
}
/**
* Collapsible details.
*
* @see collapse.js
* @thanks http://nicolasgallagher.com/css-background-image-hacks/
*/
details {
border: 1px solid #ccc;
margin-top: 1em;
margin-bottom: 1em;
}
details > .details-wrapper {
padding: 0.5em 1.5em;
}
/* @todo Regression: The summary of uncollapsible details are no longer
vertically aligned with the .details-wrapper in browsers without native
details support. */
summary {
cursor: pointer;
padding: 0.2em 0.5em;
}
.collapse-processed > summary {
padding-left: 0.5em;
padding-right: 0.5em;
}
.collapse-processed > summary:before {
background: url(../../../misc/menu-expanded.png) 0px 100% no-repeat; /* LTR */
content: "";
float: left;
height: 1em;
width: 1em;
}
[dir="rtl"] .collapse-processed > summary:before {
background-position: 100% 100%;
float: right;
}
.collapse-processed:not([open]) > summary:before {
background-position: 25% 35%; /* LTR */
-ms-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
}
[dir="rtl"] .collapse-processed:not([open]) > summary:before {
background-position: 75% 35%;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
/**
* TableDrag behavior.
*
* @see tabledrag.js
*/
tr.drag {
background-color: #fffff0;
}
tr.drag-previous {
background-color: #ffd;
}
body div.tabledrag-changed-warning {
margin-bottom: 0.5em;
}
/**
* TableSelect behavior.
*
* @see tableselect.js
*/
tr.selected td {
background: #ffc;
}
td.checkbox,
th.checkbox {
text-align: center;
}
/**
* Progress bar.
*
* @see progress.js
*/
.progress__track {
border-color: #b3b3b3;
border-radius: 10em;
background-color: #f2f1eb;
background-image: -webkit-linear-gradient(#e7e7df, #f0f0f0);
background-image: linear-gradient(#e7e7df, #f0f0f0);
box-shadow: inset 0 1px 3px hsla(0, 0%, 0%, 0.16);
}
.progress__bar {
border: 1px #07629a solid;
background: #057ec9;
background-image:
-webkit-linear-gradient( top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15) ),
-webkit-linear-gradient( left top,
#0094f0 0%,
#0094f0 25%,
#007ecc 25%,
#007ecc 50%,
#0094f0 50%,
#0094f0 75%,
#0094f0 100% );
background-image:
-webkit-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15)), -webkit-linear-gradient(left top, #0094f0 0%, #0094f0 25%, #007ecc 25%, #007ecc 50%, #0094f0 50%, #0094f0 75%, #0094f0 100%);
background-image:
linear-gradient( to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15) ),
linear-gradient( to right bottom,
#0094f0 0%,
#0094f0 25%,
#007ecc 25%,
#007ecc 50%,
#0094f0 50%,
#0094f0 75%,
#0094f0 100% );
background-size: 40px 40px;
margin-top: -1px;
margin-left: -1px;
padding: 0 1px;
width: 3%;
height: 16px;
border-radius: 10em;
-webkit-animation: animate-stripes 3s linear infinite;
-moz-animation: animate-stripes 3s linear infinite;
-webkit-transition: width 0.5s ease-out;
transition: width 0.5s ease-out;
}
/**
* Progress bar animations.
*/
@-webkit-keyframes animate-stripes {
0% {background-position: 0 0, 0 0;} 100% {background-position: 0 0, -80px 0;}
}
@-ms-keyframes animate-stripes {
0% {background-position: 0 0, 0 0;} 100% {background-position: 0 0, -80px 0;}
}
@keyframes animate-stripes {
0% {background-position: 0 0, 0 0;} 100% {background-position: 0 0, -80px 0;}
}
/**
* Markup generated by menu.html.twig.
*/
ul.menu {
list-style: none outside;
margin-left: 1em; /* LTR */
padding: 0;
text-align: left; /* LTR */
}
[dir="rtl"] ul.menu {
margin-left: 0;
margin-right: 1em;
text-align: right;
}
.menu-item--expanded {
list-style-image: url(../../../misc/menu-expanded.png);
list-style-type: circle;
}
.menu-item--collapsed {
list-style-image: url(../../../misc/menu-collapsed.png); /* LTR */
list-style-type: disc;
}
[dir="rtl"] .menu-item--collapsed {
list-style-image: url(../../../misc/menu-collapsed-rtl.png);
}
.menu-item {
padding-top: 0.2em;
margin: 0;
}
ul.menu a.is-active {
color: #000;
}
/**
* Markup generated by links.html.twig.
*/
ul.inline,
ul.links.inline {
display: inline;
padding-left: 0;
}
ul.inline li {
display: inline;
list-style-type: none;
padding: 0 0.5em;
}
ul.links a.is-active {
color: #000;
}
/**
* Markup generated by breadcrumb.html.twig.
*/
.breadcrumb {
padding-bottom: 0.5em;
}
.breadcrumb ol {
margin: 0;
padding: 0;
}
[dir="rtl"] .breadcrumb ol {
/* This is required to win over specifity of [dir="rtl"] ol */
margin-right: 0;
}
.breadcrumb li {
display: inline;
list-style-type: none;
margin: 0;
padding: 0;
}
/* IE8 does not support :not() and :last-child. */
.breadcrumb li:before {
content: ' \BB ';
}
.breadcrumb li:first-child:before {
content: none;
}
/**
* Markup generated by menu-local-tasks.html.twig.
*/
div.tabs {
margin: 1em 0;
}
ul.tabs {
list-style: none;
margin: 0 0 0.5em;
padding: 0;
}
.tabs > li {
display: inline-block;
margin-right: 0.3em; /* LTR */
}
[dir="rtl"] .tabs > li {
margin-left: 0.3em;
margin-right: 0;
}
.tabs a {
display: block;
padding: 0.2em 1em;
text-decoration: none;
}
.tabs a.is-active {
background-color: #eee;
}
.tabs a:focus,
.tabs a:hover {
background-color: #f5f5f5;
}
/**
* Styles for link buttons and action links.
*/
.action-links {
list-style: none;
padding: 0;
margin: 1em 0;
}
[dir="rtl"] .action-links {
/* This is required to win over specifity of [dir="rtl"] ul */
margin-right: 0;
}
.action-links li {
display: inline-block;
margin: 0 0.3em;
}
.action-links li:first-child {
margin-left: 0; /* LTR */
}
[dir="rtl"] .action-links li:first-child {
margin-left: 0.3em;
margin-right: 0;
}
.button-action {
display: inline-block;
line-height: 160%;
padding: 0.2em 0.5em 0.3em;
text-decoration: none;
}
.button-action:before {
content: '+';
font-weight: 900;
margin-left: -0.1em; /* LTR */
padding-right: 0.2em; /* LTR */
}
[dir="rtl"] .button-action:before {
margin-left: 0;
margin-right: -0.1em;
padding-left: 0.2em;
padding-right: 0;
}
/**
* Styles for system messages.
*/
.messages {
background: no-repeat 10px 17px; /* LTR */
border: 1px solid;
border-width: 1px 1px 1px 0; /* LTR */
border-radius: 2px;
padding: 15px 20px 15px 35px; /* LTR */
word-wrap: break-word;
overflow-wrap: break-word;
}
[dir="rtl"] .messages {
border-width: 1px 0 1px 1px;
background-position: right 10px top 17px;
padding-left: 20px;
padding-right: 35px;
text-align: right;
}
.messages + .messages {
margin-top: 1.538em;
}
.messages__list {
list-style: none;
padding: 0;
margin: 0;
}
.messages__item + .messages__item {
margin-top: 0.769em;
}
/* See .color-success in Seven's colors.css */
.messages--status {
color: #325e1c;
background-color: #f3faef;
border-color: #c9e1bd #c9e1bd #c9e1bd transparent; /* LTR */
background-image: url(../../../misc/icons/73b355/check.svg);
box-shadow: -8px 0 0 #77b259; /* LTR */
}
[dir="rtl"] .messages--status {
border-color: #c9e1bd transparent #c9e1bd #c9e1bd;
box-shadow: 8px 0 0 #77b259;
margin-left: 0;
}
/* See .color-warning in Seven's colors.css */
.messages--warning {
background-color: #fdf8ed;
background-image: url(../../../misc/icons/e29700/warning.svg);
border-color: #f4daa6 #f4daa6 #f4daa6 transparent; /* LTR */
color: #734c00;
box-shadow: -8px 0 0 #e09600; /* LTR */
}
[dir="rtl"] .messages--warning {
border-color: #f4daa6 transparent #f4daa6 #f4daa6;
box-shadow: 8px 0 0 #e09600;
}
/* See .color-error in Seven's colors.css */
.messages--error {
background-color: #fcf4f2;
color: #a51b00;
background-image: url(../../../misc/icons/ea2800/error.svg);
border-color: #f9c9bf #f9c9bf #f9c9bf transparent; /* LTR */
box-shadow: -8px 0 0 #e62600; /* LTR */
}
[dir="rtl"] .messages--error {
border-color: #f9c9bf transparent #f9c9bf #f9c9bf;
box-shadow: 8px 0 0 #e62600;
}
.messages--error p.error {
color: #a51b00;
}
/* Field display */
.field .field-label {
font-weight: bold;
}
.field-label-inline .field-label,
.field-label-inline .field-items {
float:left; /*LTR*/
margin-right: 0.5em; /*LTR*/
}
[dir="rtl"] .field-label-inline .field-label,
[dir="rtl"] .field-label-inline .field-items {
float: right;
margin-left: 0.5em;
margin-right: 0;
}
.field-label-inline .field-label::after {
content: ':';
}
/* Form display */
form .field-multiple-table {
margin: 0;
}
form .field-multiple-table .field-multiple-drag {
width: 30px;
padding-right: 0; /*LTR*/
}
[dir="rtl"] form .field-multiple-table .field-multiple-drag {
padding-left: 0;
}
form .field-multiple-table .field-multiple-drag .tabledrag-handle {
padding-right: .5em; /*LTR*/
}
[dir="rtl"] form .field-multiple-table .field-multiple-drag .tabledrag-handle {
padding-left: .5em;
}
form .field-add-more-submit {
margin: .5em 0 0;
}

View file

@ -1,12 +0,0 @@
id: d6_menu
label: Drupal 6 menus
migration_tags:
- Drupal 6
source:
plugin: d6_menu
process:
id: menu_name
label: title
description: description
destination:
plugin: entity:menu

View file

@ -1,122 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\system\FileAjaxForm.
*/
namespace Drupal\system;
use Drupal\Core\Form\FormStateInterface;
/**
* Wrapper for Ajax forms data and commands, avoiding a multi-return-value tuple.
*
* @ingroup ajax
*/
class FileAjaxForm {
/**
* The form to cache.
*
* @var array
*/
protected $form;
/**
* The form state.
*
* @var \Drupal\Core\Form\FormStateInterface
*/
protected $formState;
/**
* The unique form ID.
*
* @var string
*/
protected $formId;
/**
* The unique form build ID.
*
* @var string
*/
protected $formBuildId;
/**
* The array of ajax commands.
*
* @var \Drupal\Core\Ajax\CommandInterface[]
*/
protected $commands;
/**
* Constructs a FileAjaxForm object.
*
* @param array $form
* The form definition.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state.
* @param \Drupal\Core\Ajax\string|string $form_id
* The unique form ID.
* @param \Drupal\Core\Ajax\string|string $form_build_id
* The unique form build ID.
* @param \Drupal\Core\Ajax\CommandInterface[] $commands
* The ajax commands.
*/
public function __construct(array $form, FormStateInterface $form_state, $form_id, $form_build_id, array $commands) {
$this->form = $form;
$this->formState = $form_state;
$this->formId = $form_id;
$this->formBuildId = $form_build_id;
$this->commands = $commands;
}
/**
* Gets all AJAX commands.
*
* @return \Drupal\Core\Ajax\CommandInterface[]
* Returns all previously added AJAX commands.
*/
public function getCommands() {
return $this->commands;
}
/**
* Gets the form definition.
*
* @return array
*/
public function getForm() {
return $this->form;
}
/**
* Gets the unique form build ID.
*
* @return string
*/
public function getFormBuildId() {
return $this->formBuildId;
}
/**
* Gets the unique form ID.
*
* @return string
*/
public function getFormId() {
return $this->formId;
}
/**
* Gets the form state.
*
* @return \Drupal\Core\Form\FormStateInterface
*/
public function getFormState() {
return $this->formState;
}
}

View file

@ -1,87 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\system\Tests\Extension\InfoParserUnitTest.
*/
namespace Drupal\system\Tests\Extension;
use Drupal\simpletest\KernelTestBase;
use Drupal\Core\Extension\InfoParser;
use Drupal\Core\Extension\InfoParserException;
/**
* Tests InfoParser class and exception.
*
* Files for this test are stored in core/modules/system/tests/fixtures and end
* with .info.txt instead of info.yml in order not not be considered as real
* extensions.
*
* @group Extension
*/
class InfoParserUnitTest extends KernelTestBase {
/**
* The InfoParser object.
*
* @var \Drupal\Core\Extension\InfoParser
*/
protected $infoParser;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->infoParser = new InfoParser();
}
/**
* Tests the functionality of the infoParser object.
*/
public function testInfoParser() {
$info = $this->infoParser->parse('core/modules/system/tests/fixtures/does_not_exist.info.txt');
$this->assertTrue(empty($info), 'Non existing info.yml returns empty array.');
// Test that invalid YAML throws an exception and that message contains the
// filename that caused it.
$filename = 'core/modules/system/tests/fixtures/broken.info.txt';
try {
$this->infoParser->parse($filename);
$this->fail('Expected InfoParserException not thrown when reading broken.info.txt');
}
catch (InfoParserException $e) {
$this->assertTrue(strpos($e->getMessage(), $filename) !== FALSE, 'Exception message contains info.yml filename.');
}
// Tests that missing required keys are detected.
$filename = 'core/modules/system/tests/fixtures/missing_keys.info.txt';
try {
$this->infoParser->parse($filename);
$this->fail('Expected InfoParserException not thrown when reading missing_keys.info.txt');
}
catch (InfoParserException $e) {
$expected_message = "Missing required keys (type, core, name) in $filename.";
$this->assertEqual($e->getMessage(), $expected_message);
}
// Tests that a single missing required key is detected.
$filename = 'core/modules/system/tests/fixtures/missing_key.info.txt';
try {
$this->infoParser->parse($filename);
$this->fail('Expected InfoParserException not thrown when reading missing_key.info.txt');
}
catch (InfoParserException $e) {
$expected_message = "Missing required keys (type) in $filename.";
$this->assertEqual($e->getMessage(), $expected_message);
}
$info_values = $this->infoParser->parse('core/modules/system/tests/fixtures/common_test.info.txt');
$this->assertEqual($info_values['simple_string'], 'A simple string', 'Simple string value was parsed correctly.', 'System');
$this->assertEqual($info_values['version'], \Drupal::VERSION, 'Constant value was parsed correctly.', 'System');
$this->assertEqual($info_values['double_colon'], 'dummyClassName::', 'Value containing double-colon was parsed correctly.', 'System');
}
}

View file

@ -1,343 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\system\Tests\Extension\ModuleHandlerTest.
*/
namespace Drupal\system\Tests\Extension;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\simpletest\KernelTestBase;
use \Drupal\Core\Extension\ModuleUninstallValidatorException;
/**
* Tests ModuleHandler functionality.
*
* @group Extension
*/
class ModuleHandlerTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('system');
public function setUp() {
parent::setUp();
// Set up the state values so we know where to find the files when running
// drupal_get_filename().
// @todo Remove as part of https://www.drupal.org/node/2186491
system_rebuild_module_data();
}
/**
* {@inheritdoc}
*/
public function containerBuild(ContainerBuilder $container) {
parent::containerBuild($container);
// Put a fake route bumper on the container to be called during uninstall.
$container
->register('router.dumper', 'Drupal\Core\Routing\NullMatcherDumper');
}
/**
* The basic functionality of retrieving enabled modules.
*/
function testModuleList() {
// Prime the drupal_get_filename() static cache with the location of the
// testing profile as it is not the currently active profile and we don't
// yet have any cached way to retrieve its location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml');
// Build a list of modules, sorted alphabetically.
$profile_info = install_profile_info('testing', 'en');
$module_list = $profile_info['dependencies'];
// Installation profile is a module that is expected to be loaded.
$module_list[] = 'testing';
sort($module_list);
// Compare this list to the one returned by the module handler. We expect
// them to match, since all default profile modules have a weight equal to 0
// (except for block.module, which has a lower weight but comes first in
// the alphabet anyway).
$this->assertModuleList($module_list, 'Testing profile');
// Try to install a new module.
$this->moduleInstaller()->install(array('ban'));
$module_list[] = 'ban';
sort($module_list);
$this->assertModuleList($module_list, 'After adding a module');
// Try to mess with the module weights.
module_set_weight('ban', 20);
// Move ban to the end of the array.
unset($module_list[array_search('ban', $module_list)]);
$module_list[] = 'ban';
$this->assertModuleList($module_list, 'After changing weights');
// Test the fixed list feature.
$fixed_list = array(
'system' => 'core/modules/system/system.module',
'menu' => 'core/modules/menu/menu.module',
);
$this->moduleHandler()->setModuleList($fixed_list);
$new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
$this->assertModuleList($new_module_list, t('When using a fixed list'));
}
/**
* Assert that the extension handler returns the expected values.
*
* @param array $expected_values
* The expected values, sorted by weight and module name.
* @param $condition
*/
protected function assertModuleList(Array $expected_values, $condition) {
$expected_values = array_values(array_unique($expected_values));
$enabled_modules = array_keys($this->container->get('module_handler')->getModuleList());
$enabled_modules = sort($enabled_modules);
$this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', array('@condition' => $condition)));
}
/**
* Tests dependency resolution.
*
* Intentionally using fake dependencies added via hook_system_info_alter()
* for modules that normally do not have any dependencies.
*
* To simplify things further, all of the manipulated modules are either
* purely UI-facing or live at the "bottom" of all dependency chains.
*
* @see module_test_system_info_alter()
* @see https://www.drupal.org/files/issues/dep.gv__0.png
*/
function testDependencyResolution() {
$this->enableModules(array('module_test'));
$this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
// Ensure that modules are not enabled.
$this->assertFalse($this->moduleHandler()->moduleExists('color'), 'Color module is disabled.');
$this->assertFalse($this->moduleHandler()->moduleExists('config'), 'Config module is disabled.');
$this->assertFalse($this->moduleHandler()->moduleExists('help'), 'Help module is disabled.');
// Create a missing fake dependency.
// Color will depend on Config, which depends on a non-existing module Foo.
// Nothing should be installed.
\Drupal::state()->set('module_test.dependency', 'missing dependency');
drupal_static_reset('system_rebuild_module_data');
try {
$result = $this->moduleInstaller()->install(array('color'));
$this->fail(t('ModuleInstaller::install() throws an exception if dependencies are missing.'));
}
catch (\Drupal\Core\Extension\MissingDependencyException $e) {
$this->pass(t('ModuleInstaller::install() throws an exception if dependencies are missing.'));
}
$this->assertFalse($this->moduleHandler()->moduleExists('color'), 'ModuleHandler::install() aborts if dependencies are missing.');
// Fix the missing dependency.
// Color module depends on Config. Config depends on Help module.
\Drupal::state()->set('module_test.dependency', 'dependency');
drupal_static_reset('system_rebuild_module_data');
$result = $this->moduleInstaller()->install(array('color'));
$this->assertTrue($result, 'ModuleHandler::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
$this->assertTrue($this->moduleHandler()->moduleExists('config') && $this->moduleHandler()->moduleExists('help'), 'Dependency chain was installed.');
// Verify that the original module was installed.
$this->assertTrue($this->moduleHandler()->moduleExists('color'), 'Module installation with dependencies succeeded.');
// Verify that the modules were enabled in the correct order.
$module_order = \Drupal::state()->get('module_test.install_order') ?: array();
$this->assertEqual($module_order, array('help', 'config', 'color'));
// Uninstall all three modules explicitly, but in the incorrect order,
// and make sure that ModuleHandler::uninstall() uninstalled them in the
// correct sequence.
$result = $this->moduleInstaller()->uninstall(array('config', 'help', 'color'));
$this->assertTrue($result, 'ModuleHandler::uninstall() returned TRUE.');
foreach (array('color', 'config', 'help') as $module) {
$this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, "$module module was uninstalled.");
}
$uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
$this->assertEqual($uninstalled_modules, array('color', 'config', 'help'), 'Modules were uninstalled in the correct order.');
// Enable Color module again, which should enable both the Config module and
// Help module. But, this time do it with Config module declaring a
// dependency on a specific version of Help module in its info file. Make
// sure that Drupal\Core\Extension\ModuleHandler::install() still works.
\Drupal::state()->set('module_test.dependency', 'version dependency');
drupal_static_reset('system_rebuild_module_data');
$result = $this->moduleInstaller()->install(array('color'));
$this->assertTrue($result, 'ModuleHandler::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
$this->assertTrue($this->moduleHandler()->moduleExists('config') && $this->moduleHandler()->moduleExists('help'), 'Dependency chain was installed.');
// Verify that the original module was installed.
$this->assertTrue($this->moduleHandler()->moduleExists('color'), 'Module installation with version dependencies succeeded.');
// Finally, verify that the modules were enabled in the correct order.
$enable_order = \Drupal::state()->get('module_test.install_order') ?: array();
$this->assertIdentical($enable_order, array('help', 'config', 'color'));
}
/**
* Tests uninstalling a module that is a "dependency" of a profile.
*/
function testUninstallProfileDependency() {
$profile = 'minimal';
$dependency = 'dblog';
$this->settingsSet('install_profile', $profile);
// Prime the drupal_get_filename() static cache with the location of the
// minimal profile as it is not the currently active profile and we don't
// yet have any cached way to retrieve its location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', $profile, 'core/profiles/' . $profile . '/' . $profile . '.info.yml');
$this->enableModules(array('module_test', $profile));
drupal_static_reset('system_rebuild_module_data');
$data = system_rebuild_module_data();
$this->assertTrue(isset($data[$profile]->requires[$dependency]));
$this->moduleInstaller()->install(array($dependency));
$this->assertTrue($this->moduleHandler()->moduleExists($dependency));
// Uninstall the profile module "dependency".
$result = $this->moduleInstaller()->uninstall(array($dependency));
$this->assertTrue($result, 'ModuleHandler::uninstall() returns TRUE.');
$this->assertFalse($this->moduleHandler()->moduleExists($dependency));
$this->assertEqual(drupal_get_installed_schema_version($dependency), SCHEMA_UNINSTALLED, "$dependency module was uninstalled.");
// Verify that the installation profile itself was not uninstalled.
$uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
$this->assertTrue(in_array($dependency, $uninstalled_modules), "$dependency module is in the list of uninstalled modules.");
$this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.');
}
/**
* Tests uninstalling a module that has content.
*/
function testUninstallContentDependency() {
$this->enableModules(array('module_test', 'entity_test', 'text', 'user', 'help'));
$this->assertTrue($this->moduleHandler()->moduleExists('entity_test'), 'Test module is enabled.');
$this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
$this->installSchema('user', 'users_data');
$entity_types = \Drupal::entityManager()->getDefinitions();
foreach ($entity_types as $entity_type) {
if ('entity_test' == $entity_type->getProvider()) {
$this->installEntitySchema($entity_type->id());
}
}
// Create a fake dependency.
// entity_test will depend on help. This way help can not be uninstalled
// when there is test content preventing entity_test from being uninstalled.
\Drupal::state()->set('module_test.dependency', 'dependency');
drupal_static_reset('system_rebuild_module_data');
// Create an entity so that the modules can not be disabled.
$entity = entity_create('entity_test', array('name' => $this->randomString()));
$entity->save();
// Uninstalling entity_test is not possible when there is content.
try {
$message = 'ModuleHandler::uninstall() throws ModuleUninstallValidatorException upon uninstalling a module which does not pass validation.';
$this->moduleInstaller()->uninstall(array('entity_test'));
$this->fail($message);
}
catch (ModuleUninstallValidatorException $e) {
$this->pass(get_class($e) . ': ' . $e->getMessage());
}
// Uninstalling help needs entity_test to be un-installable.
try {
$message = 'ModuleHandler::uninstall() throws ModuleUninstallValidatorException upon uninstalling a module which does not pass validation.';
$this->moduleInstaller()->uninstall(array('help'));
$this->fail($message);
}
catch (ModuleUninstallValidatorException $e) {
$this->pass(get_class($e) . ': ' . $e->getMessage());
}
// Deleting the entity.
$entity->delete();
$result = $this->moduleInstaller()->uninstall(array('help'));
$this->assertTrue($result, 'ModuleHandler::uninstall() returns TRUE.');
$this->assertEqual(drupal_get_installed_schema_version('entity_test'), SCHEMA_UNINSTALLED, "entity_test module was uninstalled.");
}
/**
* Tests whether the correct module metadata is returned.
*/
function testModuleMetaData() {
// Generate the list of available modules.
$modules = system_rebuild_module_data();
// Check that the mtime field exists for the system module.
$this->assertTrue(!empty($modules['system']->info['mtime']), 'The system.info.yml file modification time field is present.');
// Use 0 if mtime isn't present, to avoid an array index notice.
$test_mtime = !empty($modules['system']->info['mtime']) ? $modules['system']->info['mtime'] : 0;
// Ensure the mtime field contains a number that is greater than zero.
$this->assertTrue(is_numeric($test_mtime) && ($test_mtime > 0), 'The system.info.yml file modification time field contains a timestamp.');
}
/**
* Tests whether module-provided stream wrappers are registered properly.
*/
public function testModuleStreamWrappers() {
// file_test.module provides (among others) a 'dummy' stream wrapper.
// Verify that it is not registered yet to prevent false positives.
$stream_wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers();
$this->assertFalse(isset($stream_wrappers['dummy']));
$this->moduleInstaller()->install(['file_test']);
// Verify that the stream wrapper is available even without calling
// \Drupal::service('stream_wrapper_manager')->getWrappers() again.
// If the stream wrapper is not available file_exists() will raise a notice.
file_exists('dummy://');
$stream_wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers();
$this->assertTrue(isset($stream_wrappers['dummy']));
}
/**
* Tests whether the correct theme metadata is returned.
*/
function testThemeMetaData() {
// Generate the list of available themes.
$themes = \Drupal::service('theme_handler')->rebuildThemeData();
// Check that the mtime field exists for the bartik theme.
$this->assertTrue(!empty($themes['bartik']->info['mtime']), 'The bartik.info.yml file modification time field is present.');
// Use 0 if mtime isn't present, to avoid an array index notice.
$test_mtime = !empty($themes['bartik']->info['mtime']) ? $themes['bartik']->info['mtime'] : 0;
// Ensure the mtime field contains a number that is greater than zero.
$this->assertTrue(is_numeric($test_mtime) && ($test_mtime > 0), 'The bartik.info.yml file modification time field contains a timestamp.');
}
/**
* Returns the ModuleHandler.
*
* @return \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected function moduleHandler() {
return $this->container->get('module_handler');
}
/**
* Returns the ModuleInstaller.
*
* @return \Drupal\Core\Extension\ModuleInstallerInterface
*/
protected function moduleInstaller() {
return $this->container->get('module_installer');
}
}

View file

@ -1,59 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\system\Tests\Migrate\d6\MigrateMenuTest.
*/
namespace Drupal\system\Tests\Migrate\d6;
use Drupal\migrate\MigrateExecutable;
use Drupal\Core\Database\Database;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\system\Entity\Menu;
/**
* Upgrade menus to system.menu.*.yml.
*
* @group system
*/
class MigrateMenuTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['MenuCustom.php']);
$this->executeMigration('d6_menu');
}
/**
* Tests the Drupal 6 menu to Drupal 8 migration.
*/
public function testMenu() {
$navigation_menu = Menu::load('navigation');
$this->assertIdentical('navigation', $navigation_menu->id());
$this->assertIdentical('Navigation', $navigation_menu->label());
$expected = <<<EOT
The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.
EOT;
$this->assertIdentical($expected, $navigation_menu->getDescription());
// Test that we can re-import using the ConfigEntityBase destination.
Database::getConnection('default', 'migrate')
->update('menu_custom')
->fields(array('title' => 'Home Navigation'))
->condition('menu_name', 'navigation')
->execute();
db_truncate(entity_load('migration', 'd6_menu')->getIdMap()->mapTableName())->execute();
$migration = entity_load_unchanged('migration', 'd6_menu');
$executable = new MigrateExecutable($migration, $this);
$executable->import();
$navigation_menu = entity_load_unchanged('menu', 'navigation');
$this->assertIdentical('Home Navigation', $navigation_menu->label());
}
}

View file

@ -1,9 +0,0 @@
# info.yml for testing broken YAML parsing exception handling.
name: File
type: module
description: 'Defines a file field type.'
package: Core
version: VERSION
core: 8.x
dependencies::;;
- field

View file

@ -1,7 +0,0 @@
core: 8.x
name: common_test
type: module
description: 'testing info file parsing'
simple_string: 'A simple string'
version: "VERSION"
double_colon: dummyClassName::

View file

@ -1,8 +0,0 @@
# info.yml for testing missing type key.
name: File
description: 'Defines a file field type.'
package: Core
version: VERSION
core: 8.x
dependencies:
- field

View file

@ -1,5 +0,0 @@
# info.yml for testing missing name, description, and type keys.
package: Core
version: VERSION
dependencies:
- field

View file

@ -1,13 +0,0 @@
id: d6_text_settings
label: Drupal 6 teaser length configuration
migration_tags:
- Drupal 6
source:
plugin: variable
variables:
- teaser_length
process:
default_summary_length: teaser_length
destination:
plugin: config
config_name: text.settings

View file

@ -1,95 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\user\Tests\Views\UserUnitTestBase.
*/
namespace Drupal\user\Tests\Views;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewUnitTestBase;
/**
* Provides a common test base for user views tests.
*/
abstract class UserUnitTestBase extends ViewUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('user_test_views', 'user', 'system', 'field');
/**
* Users to use during this test.
*
* @var array
*/
protected $users = array();
/**
* The entity storage for roles.
*
* @var \Drupal\user\RoleStorage
*/
protected $roleStorage;
/**
* The entity storage for users.
*
* @var \Drupal\user\UserStorage
*/
protected $userStorage;
protected function setUp() {
parent::setUp();
ViewTestData::createTestViews(get_class($this), array('user_test_views'));
$this->installEntitySchema('user');
$entity_manager = $this->container->get('entity.manager');
$this->roleStorage = $entity_manager->getStorage('user_role');
$this->userStorage = $entity_manager->getStorage('user');
}
/**
* Set some test data for permission related tests.
*/
protected function setupPermissionTestData() {
// Setup a role without any permission.
$this->roleStorage->create(array('id' => 'authenticated'))
->save();
$this->roleStorage->create(array('id' => 'no_permission'))
->save();
// Setup a role with just one permission.
$this->roleStorage->create(array('id' => 'one_permission'))
->save();
user_role_grant_permissions('one_permission', array('administer permissions'));
// Setup a role with multiple permissions.
$this->roleStorage->create(array('id' => 'multiple_permissions'))
->save();
user_role_grant_permissions('multiple_permissions', array('administer permissions', 'administer users', 'access user profiles'));
// Setup a user without an extra role.
$this->users[] = $account = $this->userStorage->create(array());
$account->save();
// Setup a user with just the first role (so no permission beside the
// ones from the authenticated role).
$this->users[] = $account = $this->userStorage->create(array('name' => 'first_role'));
$account->addRole('no_permission');
$account->save();
// Setup a user with just the second role (so one additional permission).
$this->users[] = $account = $this->userStorage->create(array('name' => 'second_role'));
$account->addRole('one_permission');
$account->save();
// Setup a user with both the second and the third role.
$this->users[] = $account = $this->userStorage->create(array('name' => 'second_third_role'));
$account->addRole('one_permission');
$account->addRole('multiple_permissions');
$account->save();
}
}

View file

@ -1,756 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\views\Tests\Handler\FieldUnitTest.
*/
namespace Drupal\views\Tests\Handler;
use Drupal\Core\Render\RenderContext;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Views;
/**
* Tests the generic field handler.
*
* @group views
* @see \Drupal\views\Plugin\views\field\FieldPluginBase
*/
class FieldUnitTest extends ViewUnitTestBase {
public static $modules = array('user');
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view', 'test_field_tokens', 'test_field_output');
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
);
/**
* Overrides Drupal\views\Tests\ViewTestBase::viewsData().
*/
protected function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['job']['field']['id'] = 'test_field';
$data['views_test_data']['job']['field']['click sortable'] = FALSE;
$data['views_test_data']['id']['field']['click sortable'] = TRUE;
return $data;
}
/**
* Tests that the render function is called.
*/
public function testRender() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_field_tokens');
$this->executeView($view);
$random_text = $this->randomMachineName();
$view->field['job']->setTestValue($random_text);
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['job']->theme($view->result[0]);
});
$this->assertEqual($output, $random_text, 'Make sure the render method rendered the manual set value.');
}
/**
* Tests all things related to the query.
*/
public function testQuery() {
// Tests adding additional fields to the query.
$view = Views::getView('test_view');
$view->initHandlers();
$id_field = $view->field['id'];
$id_field->additional_fields['job'] = 'job';
// Choose also a field alias key which doesn't match to the table field.
$id_field->additional_fields['created_test'] = array('table' => 'views_test_data', 'field' => 'created');
$view->build();
// Make sure the field aliases have the expected value.
$this->assertEqual($id_field->aliases['job'], 'views_test_data_job');
$this->assertEqual($id_field->aliases['created_test'], 'views_test_data_created');
$this->executeView($view);
// Tests the getValue method with and without a field aliases.
foreach ($this->dataSet() as $key => $row) {
$id = $key + 1;
$result = $view->result[$key];
$this->assertEqual($id_field->getValue($result), $id);
$this->assertEqual($id_field->getValue($result, 'job'), $row['job']);
$this->assertEqual($id_field->getValue($result, 'created_test'), $row['created']);
}
}
/**
* Asserts that a string is part of another string.
*
* @param string $haystack
* The value to search in.
* @param string $needle
* The value to search for.
* @param string $message
* (optional) A message to display with the assertion. Do not translate
* messages: use format_string() to embed variables in the message text, not
* t(). If left blank, a default message will be displayed.
* @param string $group
* (optional) The group this message is in, which is displayed in a column
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertSubString($haystack, $needle, $message = '', $group = 'Other') {
return $this->assertTrue(strpos($haystack, $needle) !== FALSE, $message, $group);
}
/**
* Asserts that a string is not part of another string.
*
* @param string $haystack
* The value to search in.
* @param string $needle
* The value to search for.
* @param string $message
* (optional) A message to display with the assertion. Do not translate
* messages: use format_string() to embed variables in the message text, not
* t(). If left blank, a default message will be displayed.
* @param string $group
* (optional) The group this message is in, which is displayed in a column
* in test output. Use 'Debug' to indicate this is debugging output. Do not
* translate this string. Defaults to 'Other'; most tests do not override
* this default.
*
* @return bool
* TRUE if the assertion succeeded, FALSE otherwise.
*/
protected function assertNotSubString($haystack, $needle, $message = '', $group = 'Other') {
return $this->assertTrue(strpos($haystack, $needle) === FALSE, $message, $group);
}
/**
* Tests general rewriting of the output.
*/
public function testRewrite() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_view');
$view->initHandlers();
$this->executeView($view);
$row = $view->result[0];
$id_field = $view->field['id'];
// Don't check the rewrite checkbox, so the text shouldn't appear.
$id_field->options['alter']['text'] = $random_text = $this->randomMachineName();
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
$this->assertNotSubString($output, $random_text);
$id_field->options['alter']['alter_text'] = TRUE;
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
$this->assertSubString($output, $random_text);
}
/**
* Tests the field tokens, row level and field level.
*/
public function testFieldTokens() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_field_tokens');
$this->executeView($view);
$name_field_0 = $view->field['name'];
$name_field_1 = $view->field['name_1'];
$name_field_2 = $view->field['name_2'];
$row = $view->result[0];
$name_field_0->options['alter']['alter_text'] = TRUE;
$name_field_0->options['alter']['text'] = '{{ name }}';
$name_field_1->options['alter']['alter_text'] = TRUE;
$name_field_1->options['alter']['text'] = '{{ name_1 }} {{ name }}';
$name_field_2->options['alter']['alter_text'] = TRUE;
$name_field_2->options['alter']['text'] = '{% if name_2|length > 3 %}{{ name_2 }} {{ name_1 }}{% endif %}';
foreach ($view->result as $row) {
$expected_output_0 = $row->views_test_data_name;
$expected_output_1 = "$row->views_test_data_name $row->views_test_data_name";
$expected_output_2 = "$row->views_test_data_name $row->views_test_data_name $row->views_test_data_name";
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field_0, $row) {
return $name_field_0->advancedRender($row);
});
$this->assertEqual($output, $expected_output_0, format_string('Test token replacement: "!token" gave "!output"', [
'!token' => $name_field_0->options['alter']['text'],
'!output' => $output,
]));
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field_1, $row) {
return $name_field_1->advancedRender($row);
});
$this->assertEqual($output, $expected_output_1, format_string('Test token replacement: "!token" gave "!output"', [
'!token' => $name_field_1->options['alter']['text'],
'!output' => $output,
]));
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($name_field_2, $row) {
return $name_field_2->advancedRender($row);
});
$this->assertEqual($output, $expected_output_2, format_string('Test token replacement: "!token" gave "!output"', [
'!token' => $name_field_2->options['alter']['text'],
'!output' => $output,
]));
}
$job_field = $view->field['job'];
$job_field->options['alter']['alter_text'] = TRUE;
$job_field->options['alter']['text'] = '{{ job }}';
$random_text = $this->randomMachineName();
$job_field->setTestValue($random_text);
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($job_field, $row) {
return $job_field->advancedRender($row);
});
$this->assertSubString($output, $random_text, format_string('Make sure the self token (!token => !value) appears in the output (!output)', [
'!value' => $random_text,
'!output' => $output,
'!token' => $job_field->options['alter']['text'],
]));
// Verify the token format used in D7 and earlier does not get substituted.
$old_token = '[job]';
$job_field->options['alter']['text'] = $old_token;
$random_text = $this->randomMachineName();
$job_field->setTestValue($random_text);
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($job_field, $row) {
return $job_field->advancedRender($row);
});
$this->assertEqual($output, $old_token, format_string('Make sure the old token style (!token => !value) is not changed in the output (!output)', [
'!value' => $random_text,
'!output' => $output,
'!token' => $job_field->options['alter']['text'],
]));
// Verify HTML tags are allowed in rewrite templates while token
// replacements are escaped.
$job_field->options['alter']['text'] = '<h1>{{ job }}</h1>';
$random_text = $this->randomMachineName();
$job_field->setTestValue('<span>' . $random_text . '</span>');
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($job_field, $row) {
return $job_field->advancedRender($row);
});
$this->assertEqual($output, '<h1>&lt;span&gt;' . $random_text . '&lt;/span&gt;</h1>', 'Valid tags are allowed in rewrite templates and token replacements.');
// Verify <script> tags are correctly removed from rewritten text.
$rewrite_template = '<script>alert("malicious");</script>';
$job_field->options['alter']['text'] = $rewrite_template;
$random_text = $this->randomMachineName();
$job_field->setTestValue($random_text);
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($job_field, $row) {
return $job_field->advancedRender($row);
});
$this->assertNotSubString($output, '<script>', 'Ensure a script tag in the rewrite template is removed.');
$rewrite_template = '<script>{{ job }}</script>';
$job_field->options['alter']['text'] = $rewrite_template;
$random_text = $this->randomMachineName();
$job_field->setTestValue($random_text);
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($job_field, $row) {
return $job_field->advancedRender($row);
});
$this->assertEqual($output, $random_text, format_string('Make sure a script tag in the template (!template) is removed, leaving only the replaced token in the output (!output)', [
'!output' => $output,
'!template' => $rewrite_template,
]));
}
/**
* Tests the exclude setting.
*/
public function testExclude() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
$view = Views::getView('test_field_output');
$view->initHandlers();
// Hide the field and see whether it's rendered.
$view->field['name']->options['exclude'] = TRUE;
$output = $view->preview();
$output = $renderer->renderRoot($output);
foreach ($this->dataSet() as $entry) {
$this->assertNotSubString($output, $entry['name']);
}
// Show and check the field.
$view->field['name']->options['exclude'] = FALSE;
$output = $view->preview();
$output = $renderer->renderRoot($output);
foreach ($this->dataSet() as $entry) {
$this->assertSubString($output, $entry['name']);
}
}
/**
* Tests everything related to empty output of a field.
*/
function testEmpty() {
$this->_testHideIfEmpty();
$this->_testEmptyText();
}
/**
* Tests the hide if empty functionality.
*
* This tests alters the result to get easier and less coupled results.
*/
function _testHideIfEmpty() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_view');
$view->initDisplay();
$this->executeView($view);
$column_map_reversed = array_flip($this->columnMap);
$view->row_index = 0;
$random_name = $this->randomMachineName();
$random_value = $this->randomMachineName();
// Test when results are not rewritten and empty values are not hidden.
$view->field['name']->options['hide_alter_empty'] = FALSE;
$view->field['name']->options['hide_empty'] = FALSE;
$view->field['name']->options['empty_zero'] = FALSE;
// Test a valid string.
$view->result[0]->{$column_map_reversed['name']} = $random_name;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_name, 'By default, a string should not be treated as empty.');
// Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'By default, "" should not be treated as empty.');
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, '0', 'By default, 0 should not be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'By default, "0" should not be treated as empty.');
// Test when results are not rewritten and non-zero empty values are hidden.
$view->field['name']->options['hide_alter_empty'] = TRUE;
$view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = FALSE;
// Test a valid string.
$view->result[0]->{$column_map_reversed['name']} = $random_name;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_name, 'If hide_empty is checked, a string should not be treated as empty.');
// Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If hide_empty is checked, "" should be treated as empty.');
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, '0', 'If hide_empty is checked, but not empty_zero, 0 should not be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'If hide_empty is checked, but not empty_zero, "0" should not be treated as empty.');
// Test when results are not rewritten and all empty values are hidden.
$view->field['name']->options['hide_alter_empty'] = TRUE;
$view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = TRUE;
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If hide_empty and empty_zero are checked, 0 should be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If hide_empty and empty_zero are checked, "0" should be treated as empty.');
// Test when results are rewritten to a valid string and non-zero empty
// results are hidden.
$view->field['name']->options['hide_alter_empty'] = FALSE;
$view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = FALSE;
$view->field['name']->options['alter']['alter_text'] = TRUE;
$view->field['name']->options['alter']['text'] = $random_name;
// Test a valid string.
$view->result[0]->{$column_map_reversed['name']} = $random_value;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, it should not be treated as empty.');
// Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, "" should not be treated as empty.');
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, 0 should not be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, "0" should not be treated as empty.');
// Test when results are rewritten to an empty string and non-zero empty results are hidden.
$view->field['name']->options['hide_alter_empty'] = TRUE;
$view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = FALSE;
$view->field['name']->options['alter']['alter_text'] = TRUE;
$view->field['name']->options['alter']['text'] = "";
// Test a valid string.
$view->result[0]->{$column_map_reversed['name']} = $random_name;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_name, 'If the rewritten string is empty, it should not be treated as empty.');
// Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If the rewritten string is empty, "" should be treated as empty.');
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, '0', 'If the rewritten string is empty, 0 should not be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'If the rewritten string is empty, "0" should not be treated as empty.');
// Test when results are rewritten to zero as a string and non-zero empty
// results are hidden.
$view->field['name']->options['hide_alter_empty'] = FALSE;
$view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = FALSE;
$view->field['name']->options['alter']['alter_text'] = TRUE;
$view->field['name']->options['alter']['text'] = "0";
// Test a valid string.
$view->result[0]->{$column_map_reversed['name']} = $random_name;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, the string rewritten as 0 should not be treated as empty.');
// Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, "" rewritten as 0 should not be treated as empty.');
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, 0 should not be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'If the rewritten string is zero and empty_zero is not checked, "0" should not be treated as empty.');
// Test when results are rewritten to a valid string and non-zero empty
// results are hidden.
$view->field['name']->options['hide_alter_empty'] = TRUE;
$view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = FALSE;
$view->field['name']->options['alter']['alter_text'] = TRUE;
$view->field['name']->options['alter']['text'] = $random_value;
// Test a valid string.
$view->result[0]->{$column_map_reversed['name']} = $random_name;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_value, 'If the original and rewritten strings are valid, it should not be treated as empty.');
// Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If either the original or rewritten string is invalid, "" should be treated as empty.');
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_value, 'If the original and rewritten strings are valid, 0 should not be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $random_value, 'If the original and rewritten strings are valid, "0" should not be treated as empty.');
// Test when results are rewritten to zero as a string and all empty
// original values and results are hidden.
$view->field['name']->options['hide_alter_empty'] = TRUE;
$view->field['name']->options['hide_empty'] = TRUE;
$view->field['name']->options['empty_zero'] = TRUE;
$view->field['name']->options['alter']['alter_text'] = TRUE;
$view->field['name']->options['alter']['text'] = "0";
// Test a valid string.
$view->result[0]->{$column_map_reversed['name']} = $random_name;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If the rewritten string is zero, it should be treated as empty.');
// Test an empty string.
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If the rewritten string is zero, "" should be treated as empty.');
// Test zero as an integer.
$view->result[0]->{$column_map_reversed['name']} = 0;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If the rewritten string is zero, 0 should not be treated as empty.');
// Test zero as a string.
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "", 'If the rewritten string is zero, "0" should not be treated as empty.');
}
/**
* Tests the usage of the empty text.
*/
function _testEmptyText() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_view');
$view->initDisplay();
$this->executeView($view);
$column_map_reversed = array_flip($this->columnMap);
$view->row_index = 0;
$empty_text = $view->field['name']->options['empty'] = $this->randomMachineName();
$view->result[0]->{$column_map_reversed['name']} = "";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $empty_text, 'If a field is empty, the empty text should be used for the output.');
$view->result[0]->{$column_map_reversed['name']} = "0";
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, "0", 'If a field is 0 and empty_zero is not checked, the empty text should not be used for the output.');
$view->result[0]->{$column_map_reversed['name']} = "0";
$view->field['name']->options['empty_zero'] = TRUE;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $empty_text, 'If a field is 0 and empty_zero is checked, the empty text should be used for the output.');
$view->result[0]->{$column_map_reversed['name']} = "";
$view->field['name']->options['alter']['alter_text'] = TRUE;
$alter_text = $view->field['name']->options['alter']['text'] = $this->randomMachineName();
$view->field['name']->options['hide_alter_empty'] = FALSE;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $alter_text, 'If a field is empty, some rewrite text exists, but hide_alter_empty is not checked, render the rewrite text.');
$view->field['name']->options['hide_alter_empty'] = TRUE;
$render = $renderer->executeInRenderContext(new RenderContext(), function () use ($view) {
return $view->field['name']->advancedRender($view->result[0]);
});
$this->assertIdentical($render, $empty_text, 'If a field is empty, some rewrite text exists, and hide_alter_empty is checked, use the empty text.');
}
/**
* Tests views_handler_field::isValueEmpty().
*/
function testIsValueEmpty() {
$view = Views::getView('test_view');
$view->initHandlers();
$field = $view->field['name'];
$this->assertFalse($field->isValueEmpty("not empty", TRUE), 'A normal string is not empty.');
$this->assertTrue($field->isValueEmpty("not empty", TRUE, FALSE), 'A normal string which skips empty() can be seen as empty.');
$this->assertTrue($field->isValueEmpty("", TRUE), '"" is considered as empty.');
$this->assertTrue($field->isValueEmpty('0', TRUE), '"0" is considered as empty if empty_zero is TRUE.');
$this->assertTrue($field->isValueEmpty(0, TRUE), '0 is considered as empty if empty_zero is TRUE.');
$this->assertFalse($field->isValueEmpty('0', FALSE), '"0" is considered not as empty if empty_zero is FALSE.');
$this->assertFalse($field->isValueEmpty(0, FALSE), '0 is considered not as empty if empty_zero is FALSE.');
$this->assertTrue($field->isValueEmpty(NULL, TRUE, TRUE), 'Null should be always seen as empty, regardless of no_skip_empty.');
$this->assertTrue($field->isValueEmpty(NULL, TRUE, FALSE), 'Null should be always seen as empty, regardless of no_skip_empty.');
}
/**
* Tests whether the filters are click sortable as expected.
*/
public function testClickSortable() {
// Test that clickSortable is TRUE by default.
$item = array(
'table' => 'views_test_data',
'field' => 'name',
);
$plugin = $this->container->get('plugin.manager.views.field')->getHandler($item);
$this->assertTrue($plugin->clickSortable(), 'TRUE as a default value is correct.');
// Test that clickSortable is TRUE by when set TRUE in the data.
$item['field'] = 'id';
$plugin = $this->container->get('plugin.manager.views.field')->getHandler($item);
$this->assertTrue($plugin->clickSortable(), 'TRUE as a views data value is correct.');
// Test that clickSortable is FALSE by when set FALSE in the data.
$item['field'] = 'job';
$plugin = $this->container->get('plugin.manager.views.field')->getHandler($item);
$this->assertFalse($plugin->clickSortable(), 'FALSE as a views data value is correct.');
}
/**
* Tests the trimText method.
*/
public function testTrimText() {
// Test unicode. See https://www.drupal.org/node/513396#comment-2839416.
$text = array(
'Tuy nhiên, những hi vọng',
'Giả sử chúng tôi có 3 Apple',
'siêu nhỏ này là bộ xử lý',
'Di động của nhà sản xuất Phần Lan',
'khoảng cách từ đại lí đến',
'của hãng bao gồm ba dòng',
'сд асд асд ас',
'асд асд асд ас'
);
// Just test maxlength without word boundary.
$alter = array(
'max_length' => 10,
);
$expect = array(
'Tuy nhiên,',
'Giả sử chú',
'siêu nhỏ n',
'Di động củ',
'khoảng các',
'của hãng b',
'сд асд асд',
'асд асд ас',
);
foreach ($text as $key => $line) {
$result_text = FieldPluginBase::trimText($alter, $line);
$this->assertEqual($result_text, $expect[$key]);
}
// Test also word_boundary
$alter['word_boundary'] = TRUE;
$expect = array(
'Tuy nhiên',
'Giả sử',
'siêu nhỏ',
'Di động',
'khoảng',
'của hãng',
'сд асд',
'асд асд',
);
foreach ($text as $key => $line) {
$result_text = FieldPluginBase::trimText($alter, $line);
$this->assertEqual($result_text, $expect[$key]);
}
}
}

View file

@ -1,122 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\views\Tests\Plugin\DisplayUnitTest.
*/
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Views;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\views\Plugin\views\access\AccessPluginBase;
use Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase;
use Drupal\views\Plugin\views\pager\PagerPluginBase;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\Plugin\views\row\RowPluginBase;
/**
* Drupal unit tests for the DisplayPluginBase class.
*
* @group views
*/
class DisplayUnitTest extends ViewUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('block', 'node', 'field', 'user');
/**
* Views plugin types to test.
*
* @var array
*/
protected $pluginTypes = array(
'access',
'cache',
'query',
'exposed_form',
'pager',
'style',
'row',
);
/**
* Views handler types to test.
*
* @var array
*/
protected $handlerTypes = array(
'fields',
'sorts',
);
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_display_defaults');
/**
* Tests the default display options.
*/
public function testDefaultOptions() {
// Save the view.
$view = Views::getView('test_display_defaults');
$view->mergeDefaults();
$view->save();
// Reload to get saved storage values.
$view = Views::getView('test_display_defaults');
$view->initDisplay();
$display_data = $view->storage->get('display');
foreach ($view->displayHandlers as $id => $display) {
// Test the view plugin options against the storage.
foreach ($this->pluginTypes as $type) {
$options = $display->getOption($type);
$this->assertIdentical($display_data[$id]['display_options'][$type]['options'], $options['options']);
}
// Test the view handler options against the storage.
foreach ($this->handlerTypes as $type) {
$options = $display->getOption($type);
$this->assertIdentical($display_data[$id]['display_options'][$type], $options);
}
}
}
/**
* Tests the \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin() method.
*/
public function testGetPlugin() {
$view = Views::getView('test_display_defaults');
$view->initDisplay();
$display_handler = $view->display_handler;
$this->assertTrue($display_handler->getPlugin('access') instanceof AccessPluginBase, 'An access plugin instance was returned.');
$this->assertTrue($display_handler->getPlugin('cache') instanceof CachePluginBase, 'A cache plugin instance was returned.');
$this->assertTrue($display_handler->getPlugin('exposed_form') instanceof ExposedFormPluginBase, 'An exposed_form plugin instance was returned.');
$this->assertTrue($display_handler->getPlugin('pager') instanceof PagerPluginBase, 'A pager plugin instance was returned.');
$this->assertTrue($display_handler->getPlugin('query') instanceof QueryPluginBase, 'A query plugin instance was returned.');
$this->assertTrue($display_handler->getPlugin('row') instanceof RowPluginBase, 'A row plugin instance was returned.');
$this->assertTrue($display_handler->getPlugin('style') instanceof StylePluginBase, 'A style plugin instance was returned.');
// Test that nothing is returned when an invalid type is requested.
$this->assertNull($display_handler->getPlugin('invalid'), 'NULL was returned for an invalid instance');
// Test that nothing was returned for an instance with no 'type' in options.
unset($display_handler->options['access']);
$this->assertNull($display_handler->getPlugin('access'), 'NULL was returned for a plugin type with no "type" option');
// Get a plugin twice, and make sure the same instance is returned.
$view->destroy();
$view->initDisplay();
$first = spl_object_hash($display_handler->getPlugin('style'));
$second = spl_object_hash($display_handler->getPlugin('style'));
$this->assertIdentical($first, $second, 'The same plugin instance was returned.');
}
}

View file

@ -1,17 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\views\Tests\Plugin\PluginUnitTestBase.
*/
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Tests\ViewUnitTestBase;
/**
* Base test class for views plugin unit tests.
*/
abstract class PluginUnitTestBase extends ViewUnitTestBase {
}

View file

@ -1,153 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\views\Tests\ViewUnitTestBase.
*/
namespace Drupal\views\Tests;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\ViewsBundle;
use Drupal\simpletest\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
/**
* Defines a base class for Views unit testing.
*
* Use this test class for unit tests of Views functionality. If a test
* requires the full web test environment provided by WebTestBase, extend
* ViewTestBase instead.
*
* @see \Drupal\views\Tests\ViewTestBase
*/
abstract class ViewUnitTestBase extends KernelTestBase {
use ViewResultAssertionTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('system', 'views', 'views_test_config', 'views_test_data', 'user');
/**
* {@inheritdoc}
*
* @param bool $import_test_views
* Should the views specififed on the test class be imported. If you need
* to setup some additional stuff, like fields, you need to call false and
* then call createTestViews for your own.
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp();
$this->installSchema('system', array('router', 'sequences'));
$this->setUpFixtures();
if ($import_test_views) {
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
}
}
/**
* Sets up the configuration and schema of views and views_test_data modules.
*
* Because the schema of views_test_data.module is dependent on the test
* using it, it cannot be enabled normally.
*/
protected function setUpFixtures() {
// First install the system module. Many Views have Page displays have menu
// links, and for those to work, the system menus must already be present.
$this->installConfig(array('system'));
// Define the schema and views data variable before enabling the test module.
\Drupal::state()->set('views_test_data_schema', $this->schemaDefinition());
\Drupal::state()->set('views_test_data_views_data', $this->viewsData());
$this->installConfig(array('views', 'views_test_config', 'views_test_data'));
foreach ($this->schemaDefinition() as $table => $schema) {
$this->installSchema('views_test_data', $table);
}
\Drupal::service('router.builder')->rebuild();
// Load the test dataset.
$data_set = $this->dataSet();
$query = db_insert('views_test_data')
->fields(array_keys($data_set[0]));
foreach ($data_set as $record) {
$query->values($record);
}
$query->execute();
}
/**
* Orders a nested array containing a result set based on a given column.
*
* @param array $result_set
* An array of rows from a result set, with each row as an associative
* array keyed by column name.
* @param string $column
* The column name by which to sort the result set.
* @param bool $reverse
* (optional) Boolean indicating whether to sort the result set in reverse
* order. Defaults to FALSE.
*
* @return array
* The sorted result set.
*/
protected function orderResultSet($result_set, $column, $reverse = FALSE) {
$order = $reverse ? -1 : 1;
usort($result_set, function ($a, $b) use ($column, $order) {
if ($a[$column] == $b[$column]) {
return 0;
}
return $order * (($a[$column] < $b[$column]) ? -1 : 1);
});
return $result_set;
}
/**
* Executes a view with debugging.
*
* @param \Drupal\views\ViewExecutable $view
* The view object.
* @param array $args
* (optional) An array of the view arguments to use for the view.
*/
protected function executeView($view, array $args = array()) {
$view->setDisplay();
$view->preExecute($args);
$view->execute();
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']). '</pre>';
if ($view->build_info['query'] instanceof SelectInterface) {
$verbose_message .= '<pre>Arguments: ' . print_r($view->build_info['query']->getArguments(), TRUE) . '</pre>';
}
$this->verbose($verbose_message);
}
/**
* Returns the schema definition.
*/
protected function schemaDefinition() {
return ViewTestData::schemaDefinition();
}
/**
* Returns the views data definition.
*/
protected function viewsData() {
return ViewTestData::viewsData();
}
/**
* Returns a very simple test dataset.
*/
protected function dataSet() {
return ViewTestData::dataSet();
}
}

View file

@ -1,79 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\views\Tests\Wizard\WizardPluginBaseUnitTest.
*/
namespace Drupal\views\Tests\Wizard;
use Drupal\Core\Form\FormState;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views_ui\ViewUI;
/**
* Tests the wizard base plugin class.
*
* @group views
* @see \Drupal\views\Plugin\views\wizard\WizardPluginBase
*/
class WizardPluginBaseUnitTest extends ViewUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('language', 'system', 'user', 'views_ui');
/**
* Contains thw wizard plugin manager.
*
* @var \Drupal\views\Plugin\views\wizard\WizardPluginBase
*/
protected $wizard;
protected function setUp() {
parent::setUp();
$this->installConfig(array('language'));
$this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', array());
}
/**
* Tests the creating of a view.
*
* @see \Drupal\views\Plugin\views\wizard\WizardPluginBase
*/
public function testCreateView() {
$form = array();
$form_state = new FormState();
$form = $this->wizard->buildForm($form, $form_state);
$random_id = strtolower($this->randomMachineName());
$random_label = $this->randomMachineName();
$random_description = $this->randomMachineName();
// Add a new language and mark it as default.
ConfigurableLanguage::createFromLangcode('it')->save();
$this->config('system.site')->set('default_langcode', 'it')->save();
$form_state->setValues([
'id' => $random_id,
'label' => $random_label,
'description' => $random_description,
'base_table' => 'views_test_data',
]);
$this->wizard->validateView($form, $form_state);
$view = $this->wizard->createView($form, $form_state);
$this->assertTrue($view instanceof ViewUI, 'The created view is a ViewUI object.');
$this->assertEqual($view->get('id'), $random_id);
$this->assertEqual($view->get('label'), $random_label);
$this->assertEqual($view->get('description'), $random_description);
$this->assertEqual($view->get('base_table'), 'views_test_data');
$this->assertEqual($view->get('langcode'), 'it');
}
}

View file

@ -1,79 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\Core\ContentNegotiationTest.
*/
namespace Drupal\Tests\Core;
use Drupal\Core\ContentNegotiation;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
/**
* @coversDefaultClass \Drupal\Core\ContentNegotiation
* @group ContentNegotiation
*/
class ContentNegotiationTest extends UnitTestCase {
/**
* @var \Drupal\Core\ContentNegotiation
*/
protected $contentNegotiation;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->contentNegotiation = new ContentNegotiation;
}
/**
* Tests the getContentType() method with AJAX iframe upload.
*
* @covers ::getContentType
*/
public function testAjaxIframeUpload() {
$request = new Request();
$request->attributes->set('ajax_iframe_upload', '1');
$this->assertSame('iframeupload', $this->contentNegotiation->getContentType($request));
}
/**
* Tests the specifying a format via query parameters gets used.
*/
public function testFormatViaQueryParameter() {
$request = new Request();
$request->query->set('_format', 'bob');
$this->assertSame('bob', $this->contentNegotiation->getContentType($request));
}
/**
* Tests the getContentType() method when no priority format is found.
*
* @covers ::getContentType
*/
public function testUnknowContentTypeReturnsHtmlByDefault() {
$request = new Request();
$this->assertSame('html', $this->contentNegotiation->getContentType($request));
}
/**
* Tests the getContentType() method when no priority format is found but it's an AJAX request.
*
* @covers ::getContentType
*/
public function testUnknowContentTypeButAjaxRequest() {
$request = new Request();
$request->headers->set('X-Requested-With', 'XMLHttpRequest');
$this->assertSame('html', $this->contentNegotiation->getContentType($request));
}
}

View file

@ -1,34 +0,0 @@
/* ---------- Admin-specific Theming ---------- */
.path-admin #content img {
margin-right: 15px; /* LTR */
}
[dir="rtl"] .path-admin #content img {
margin-left: 15px;
margin-right: 0;
}
.path-admin #content .simpletest-image img {
margin: 0;
}
.path-admin #admin-dblog img {
margin: 0 5px;
}
/* Block demo mode */
.demo-block {
background: #ffff66;
border: 1px dotted #9f9e00;
color: #000;
font: 90% "Lucida Grande", "Lucida Sans Unicode", sans-serif;
margin: 5px;
padding: 5px;
text-align: center;
text-shadow: none;
}
.featured-top .demo-block {
font-size: 0.55em;
}
#header .demo-block {
width: 500px;
}

View file

@ -1,241 +0,0 @@
/* ----------------- Content ------------------ */
.content,
.node__content {
margin-top: 10px;
}
h1#page-title {
font-size: 2em;
line-height: 1;
}
.main-content .section {
padding: 0 15px;
}
@media all and (min-width: 851px) {
.main-content {
float: left; /* LTR */
position: relative;
}
[dir="rtl"] .main-content {
float: right;
}
.layout-two-sidebars .main-content {
margin-left: 25%;
margin-right: 25%;
width: 50%;
}
.layout-one-sidebar .main-content {
width: 75%;
}
.layout-no-sidebars .main-content {
width: 100%;
}
.layout-sidebar-first .main-content {
margin-left: 25%; /* LTR */
margin-right: 0; /* LTR */
}
[dir="rtl"] .layout-sidebar-first .main-content {
margin-left: 0;
margin-right: 25%;
}
.layout-sidebar-second .main-content {
margin-right: 25%; /* LTR */
margin-left: 0; /* LTR */
}
[dir="rtl"] .layout-sidebar-second .main-content {
margin-right: 0;
margin-left: 25%;
}
}
#content h2 {
margin-bottom: 2px;
font-size: 1.429em;
line-height: 1.4;
}
.node__content {
font-size: 1.071em;
}
.node--view-mode-teaser .node__content {
font-size: 1em;
}
.node--view-mode-teaser h2 {
margin-top: 0;
padding-top: 0.5em;
}
.node--view-mode-teaser h2 a {
color: #181818;
}
.node--view-mode-teaser {
border-bottom: 1px solid #d3d7d9;
margin-bottom: 30px;
padding-bottom: 15px;
}
.node--view-mode-teaser.node--sticky {
background: #f9f9f9;
background: rgba(0, 0, 0, 0.024);
border: 1px solid #d3d7d9;
padding: 0 15px 15px;
}
.node--view-mode-teaser .node__content {
clear: none;
line-height: 1.6;
}
.node__meta {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 0.857em;
color: #68696b;
margin-bottom: -5px;
}
.node__meta .field-name-field-user-picture img {
float: left; /* LTR */
margin: 1px 20px 0 0; /* LTR */
}
[dir="rtl"] .node__meta .field-name-field-user-picture img {
float: right;
margin-left: 20px;
margin-right: 0;
}
.field-name-field-tags {
margin: 0 0 1.2em;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.field-name-field-tags .field-label {
font-weight: normal;
margin: 0;
padding-right: 5px; /* LTR */
}
[dir="rtl"] .field-name-field-tags .field-label {
padding-left: 5px;
padding-right: 0;
}
.field-name-field-tags .field-label,
.field-name-field-tags ul.links {
font-size: 0.8em;
}
.node--view-mode-teaser .field-name-field-tags .field-label,
.node--view-mode-teaser .field-name-field-tags ul.links {
font-size: 0.821em;
}
.field-name-field-tags ul.links {
padding: 0;
margin: 0;
list-style: none;
}
.field-name-field-tags ul.links li {
float: left; /* LTR */
padding: 0 1em 0 0; /* LTR */
white-space: nowrap;
}
[dir="rtl"] .field-name-field-tags ul.links li {
padding: 0 0 0 1em;
float: right;
}
.node__links {
text-align: right; /* LTR */
}
[dir="rtl"] .node__links {
text-align: left;
}
@media all and (min-width: 560px) {
.node .field-type-image {
float: left; /* LTR */
margin: 0 1em 0 0; /* LTR */
}
[dir="rtl"] .node .field-type-image {
float: right;
margin: 0 0 0 1em;
}
.node .field-type-image + .field-type-image {
clear: both;
}
}
.field-type-image img,
.field-name-field-user-picture img {
margin: 0 0 1em;
}
.field-type-image a {
border-bottom: none;
}
ul.links {
color: #68696b;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 0.821em;
}
.node--unpublished,
.unpublished {
padding: 20px 15px 0;
}
.node-preview-container {
background: #d1e8f5;
background-image: -webkit-linear-gradient(top, #d1e8f5, #d3e8f4);
background-image: linear-gradient(to bottom, #d1e8f5, #d3e8f4);
font-family: Arial, sans-serif;
box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.3333);
position: fixed;
z-index: 499;
width: 100%;
padding: 10px;
}
.node-preview-backlink {
background-color: #419ff1;
background: url(../../../../misc/icons/000000/chevron-left.svg) left no-repeat, -webkit-linear-gradient(top, #419ff1, #1076d5);
background: url(../../../../misc/icons/000000/chevron-left.svg) left no-repeat, linear-gradient(to bottom, #419ff1, #1076d5); /* LTR */
border: 1px solid #0048c8;
border-radius: .4em;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4);
color: #fff;
font-size: 0.9em;
line-height: normal;
margin: 0;
padding: 4px 1em 4px 0.6em; /* LTR */
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}
[dir="rtl"] .node-preview-backlink {
background: url(../../../../misc/icons/000000/chevron-right.svg) right no-repeat, -webkit-linear-gradient(top, #419ff1, #1076d5);
background: url(../../../../misc/icons/000000/chevron-right.svg) right no-repeat, linear-gradient(to bottom, #419ff1, #1076d5);
padding: 4px 0.6em 4px 1em;
float: right;
}
.node-preview-backlink:focus,
.node-preview-backlink:hover {
background-color: #419cf1;
background: url(../../../../misc/icons/000000/chevron-left.svg) left no-repeat, -webkit-linear-gradient(top, #59abf3, #2a90ef);
background: url(../../../../misc/icons/000000/chevron-left.svg) left no-repeat, linear-gradient(to bottom, #59abf3, #2a90ef); /* LTR */
border: 1px solid #0048c8;
text-decoration: none;
color: #fff;
}
[dir="rtl"] .node-preview-backlink:focus,
[dir="rtl"] .node-preview-backlink:hover {
background: url(../../../../misc/icons/000000/chevron-right.svg) right no-repeat, -webkit-linear-gradient(top, #59abf3, #2a90ef);
background: url(../../../../misc/icons/000000/chevron-right.svg) right no-repeat, linear-gradient(to bottom, #59abf3, #2a90ef);
}
.node-preview-backlink:active {
background-color: #0e69be;
background: url(../../../../misc/icons/000000/chevron-left.svg) left no-repeat, -webkit-linear-gradient(top, #0e69be, #2a93ef);
background: url(../../../../misc/icons/000000/chevron-left.svg) left no-repeat, linear-gradient(to bottom, #0e69be, #2a93ef); /* LTR */
border: 1px solid #0048c8;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25);
}
.node-preview-backlink:active {
background: url(../../../../misc/icons/000000/chevron-right.svg) right no-repeat, -webkit-linear-gradient(top, #0e69be, #2a93ef);
background: url(../../../../misc/icons/000000/chevron-right.svg) right no-repeat, linear-gradient(to bottom, #0e69be, #2a93ef);
}
.node-preview-backlink::before {
content: '';
width: 10px;
display: inline-block;
}
.region-content ul,
.region-content ol {
margin: 1em 0;
padding: 0 0 0.25em 15px; /* LTR */
}
[dir="rtl"] .region-content ul,
[dir="rtl"] .region-content ol {
padding: 0 15px 0.25em 0;
}
#page .ui-widget {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

View file

@ -1,10 +0,0 @@
/**
* @file
* Styles for the help region.
*/
.region-help {
border: 1px solid #d3d7d9;
padding: 0 1.5em;
margin-bottom: 30px;
}

View file

@ -1,7 +0,0 @@
/* ----------------- Tips ----------------- */
ul.tips {
padding: 0 0 0 1.25em; /* LTR */
}
[dir="rtl"] ul.tips {
padding: 0 1.25em 0 0;
}

Some files were not shown because too many files have changed in this diff Show more