Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -0,0 +1,70 @@
<?php
namespace Drupal\Tests\image\Kernel;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
/**
* Provides a helper method for creating Image fields.
*/
trait ImageFieldCreationTrait {
/**
* Create a new image field.
*
* @param string $name
* The name of the new field (all lowercase), exclude the "field_" prefix.
* @param string $type_name
* The node type that this field will be added to.
* @param array $storage_settings
* (optional) A list of field storage settings that will be added to the
* defaults.
* @param array $field_settings
* (optional) A list of instance settings that will be added to the instance
* defaults.
* @param array $widget_settings
* (optional) Widget settings to be added to the widget defaults.
* @param array $formatter_settings
* (optional) Formatter settings to be added to the formatter defaults.
* @param string $description
* (optional) A description for the field. Defaults to ''.
*/
protected function createImageField($name, $type_name, $storage_settings = array(), $field_settings = array(), $widget_settings = array(), $formatter_settings = array(), $description = '') {
FieldStorageConfig::create(array(
'field_name' => $name,
'entity_type' => 'node',
'type' => 'image',
'settings' => $storage_settings,
'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1,
))->save();
$field_config = FieldConfig::create([
'field_name' => $name,
'label' => $name,
'entity_type' => 'node',
'bundle' => $type_name,
'required' => !empty($field_settings['required']),
'settings' => $field_settings,
'description' => $description,
]);
$field_config->save();
entity_get_form_display('node', $type_name, 'default')
->setComponent($name, array(
'type' => 'image_image',
'settings' => $widget_settings,
))
->save();
entity_get_display('node', $type_name, 'default')
->setComponent($name, array(
'type' => 'image',
'settings' => $formatter_settings,
))
->save();
return $field_config;
}
}

View file

@ -77,7 +77,7 @@ class ImageItemTest extends FieldKernelTestBase {
$entity->name->value = $this->randomMachineName();
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
$this->assertTrue($entity->image_test instanceof FieldItemListInterface, 'Field implements interface.');
$this->assertTrue($entity->image_test[0] instanceof FieldItemInterface, 'Field item implements interface.');
$this->assertEqual($entity->image_test->target_id, $this->image->id());

View file

@ -0,0 +1,111 @@
<?php
namespace Drupal\Tests\image\Kernel;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\StreamWrapper\PrivateStream;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\file_test\StreamWrapper\DummyReadOnlyStreamWrapper;
use Drupal\file_test\StreamWrapper\DummyRemoteReadOnlyStreamWrapper;
use Drupal\file_test\StreamWrapper\DummyStreamWrapper;
use Drupal\image\Entity\ImageStyle;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests derivative generation with source images using stream wrappers.
*
* @group image
*/
class ImageStyleCustomStreamWrappersTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var string[]
*/
public static $modules = ['system', 'image'];
/**
* A testing image style entity.
*
* @var \Drupal\image\ImageStyleInterface
*/
protected $imageStyle;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->fileSystem = $this->container->get('file_system');
$this->config('system.file')->set('default_scheme', 'public')->save();
$this->imageStyle = ImageStyle::create(['name' => 'test']);
$this->imageStyle->save();
}
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
parent::register($container);
foreach ($this->providerTestCustomStreamWrappers() as $stream_wrapper) {
$scheme = $stream_wrapper[0];
$class = $stream_wrapper[2];
$container->register("stream_wrapper.$scheme", $class)
->addTag('stream_wrapper', ['scheme' => $scheme]);
}
}
/**
* Tests derivative creation with several source on a local writable stream.
*
* @dataProvider providerTestCustomStreamWrappers
*
* @param string $source_scheme
* The source stream wrapper scheme.
* @param string $expected_scheme
* The derivative expected stream wrapper scheme.
*/
public function testCustomStreamWrappers($source_scheme, $expected_scheme) {
$derivative_uri = $this->imageStyle->buildUri("$source_scheme://some/path/image.png");
$derivative_scheme = $this->fileSystem->uriScheme($derivative_uri);
// Check that the derivative scheme is the expected scheme.
$this->assertSame($expected_scheme, $derivative_scheme);
// Check that the derivative URI is the expected one.
$expected_uri = "$expected_scheme://styles/{$this->imageStyle->id()}/$source_scheme/some/path/image.png";
$this->assertSame($expected_uri, $derivative_uri);
}
/**
* Provide test cases for testCustomStreamWrappers().
*
* Derivatives created from writable source stream wrappers will inherit the
* scheme from source. Derivatives created from read-only stream wrappers will
* fall-back to the default scheme.
*
* @return array[]
* An array having each element an array with three items:
* - The source stream wrapper scheme.
* - The derivative expected stream wrapper scheme.
* - The stream wrapper service class.
*/
public function providerTestCustomStreamWrappers() {
return [
['public', 'public', PublicStream::class],
['private', 'private', PrivateStream::class],
['dummy', 'dummy', DummyStreamWrapper::class],
['dummy-readonly', 'public', DummyReadOnlyStreamWrapper::class],
['dummy-remote-readonly', 'public', DummyRemoteReadOnlyStreamWrapper::class],
];
}
}

View file

@ -86,64 +86,64 @@ class MigrateImageCacheTest extends MigrateDrupal6TestBase {
/**
* Test that missing actions causes failures.
*/
public function testMissingEffectPlugin() {
Database::getConnection('default', 'migrate')->insert("imagecache_action")
public function testMissingEffectPlugin() {
Database::getConnection('default', 'migrate')->insert("imagecache_action")
->fields([
'presetid',
'weight',
'module',
'action',
'data',
])
'presetid',
'weight',
'module',
'action',
'data',
])
->values([
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_deprecated_scale',
'data' => 'a:3:{s:3:"fit";s:7:"outside";s:5:"width";s:3:"200";s:6:"height";s:3:"200";}',
])->execute();
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_deprecated_scale',
'data' => 'a:3:{s:3:"fit";s:7:"outside";s:5:"width";s:3:"200";s:6:"height";s:3:"200";}',
])->execute();
$this->startCollectingMessages();
$this->executeMigration('d6_imagecache_presets');
$messages = $this->migration->getIdMap()->getMessageIterator();
$count = 0;
foreach ($messages as $message) {
$count++;
$this->assertEqual($message->message, 'The "image_deprecated_scale" plugin does not exist.');
$this->assertEqual($message->level, MigrationInterface::MESSAGE_ERROR);
}
// There should be only the one message.
$this->assertEqual($count, 1);
$this->startCollectingMessages();
$this->executeMigration('d6_imagecache_presets');
$messages = $this->migration->getIdMap()->getMessageIterator();
$count = 0;
foreach ($messages as $message) {
$count++;
$this->assertEqual($message->message, 'The "image_deprecated_scale" plugin does not exist.');
$this->assertEqual($message->level, MigrationInterface::MESSAGE_ERROR);
}
// There should be only the one message.
$this->assertEqual($count, 1);
}
/**
* Test that missing action's causes failures.
*/
public function testInvalidCropValues() {
Database::getConnection('default', 'migrate')->insert("imagecache_action")
public function testInvalidCropValues() {
Database::getConnection('default', 'migrate')->insert("imagecache_action")
->fields([
'presetid',
'weight',
'module',
'action',
'data',
])
'presetid',
'weight',
'module',
'action',
'data',
])
->values([
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_crop',
'data' => serialize([
'xoffset' => '10',
'yoffset' => '10',
]),
])->execute();
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_crop',
'data' => serialize([
'xoffset' => '10',
'yoffset' => '10',
]),
])->execute();
$this->startCollectingMessages();
$this->executeMigration('d6_imagecache_presets');
$this->assertEqual(['error' => [
'The Drupal 8 image crop effect does not support numeric values for x and y offsets. Use keywords to set crop effect offsets instead.'
]], $this->migrateMessages);
$this->startCollectingMessages();
$this->executeMigration('d6_imagecache_presets');
$this->assertEqual(['error' => [
'The Drupal 8 image crop effect does not support numeric values for x and y offsets. Use keywords to set crop effect offsets instead.'
]], $this->migrateMessages);
}
/**