Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -443,11 +443,11 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$this->drupalGet('node/' . $nid);
$this->assertRaw($style->buildUrl($original_uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
// Copy config to staging, and delete the image style.
$staging = $this->container->get('config.storage.staging');
// Copy config to sync, and delete the image style.
$sync = $this->container->get('config.storage.sync');
$active = $this->container->get('config.storage');
$this->copyConfig($active, $staging);
$staging->delete('image.style.' . $style_name);
$this->copyConfig($active, $sync);
$sync->delete('image.style.' . $style_name);
$this->configImporter()->import();
$this->assertFalse(ImageStyle::load($style_name), 'Style deleted after config import.');

View file

@ -0,0 +1,36 @@
<?php
/**
* @file
* Contains \Drupal\image\Tests\ImageFieldWidgetTest.
*/
namespace Drupal\image\Tests;
/**
* Tests the image field widget.
*
* @group image
*/
class ImageFieldWidgetTest extends ImageFieldTestBase {
/**
* Tests file widget element.
*/
public function testWidgetElement() {
// Check for image widget in add/node/article page
$field_name = strtolower($this->randomMachineName());
$min_resolution = 50;
$max_resolution = 100;
$field_settings = array(
'max_resolution' => $max_resolution . 'x' . $max_resolution,
'min_resolution' => $min_resolution . 'x' . $min_resolution,
'alt_field' => 0,
);
$this->createImageField($field_name, 'article', array(), $field_settings);
$this->drupalGet('node/add/article');
$this->assertNotEqual(0, count($this->xpath('//div[contains(@class, "field--widget-image-image")]')), 'Image field widget found on add/node page', 'Browser');
}
}

View file

@ -115,6 +115,11 @@ class ImageItemTest extends FieldUnitTestBase {
$entity = entity_create('entity_test', array('mame' => $this->randomMachineName()));
$entity->save();
// Test image item properties.
$expected = array('target_id', 'entity', 'alt', 'title', 'width', 'height');
$properties = $entity->getFieldDefinition('image_test')->getFieldStorageDefinition()->getPropertyDefinitions();
$this->assertEqual(array_keys($properties), $expected);
// Test the generateSampleValue() method.
$entity = entity_create('entity_test');
$entity->image_test->generateSampleItems();

View file

@ -196,10 +196,15 @@ class ImageStylesPathAndUrlTest extends WebTestBase {
$this->assertNoRaw( chr(137) . chr(80) . chr(78) . chr(71) . chr(13) . chr(10) . chr(26) . chr(10), 'No PNG signature found in the response body.');
}
}
elseif ($clean_url) {
// Add some extra chars to the token.
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url));
$this->assertResponse(200, 'Existing image was accessible at the URL with an invalid token.');
else {
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
$this->assertEqual(strpos($this->drupalGetHeader('Cache-Control'), 'no-cache'), FALSE, 'Cache-Control header contains \'no-cache\' to prevent caching.');
if ($clean_url) {
// Add some extra chars to the token.
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url));
$this->assertResponse(200, 'Existing image was accessible at the URL with an invalid token.');
}
}
// Allow insecure image derivatives to be created for the remainder of this
@ -224,6 +229,34 @@ class ImageStylesPathAndUrlTest extends WebTestBase {
$this->assertIdentical(strpos($generate_url, IMAGE_DERIVATIVE_TOKEN . '='), FALSE, 'The security token does not appear in the image style URL.');
$this->drupalGet($generate_url);
$this->assertResponse(200, 'Image was accessible at the URL with a missing token.');
// Stop supressing the security token in the URL.
$this->config('image.settings')->set('suppress_itok_output', FALSE)->save();
// Ensure allow_insecure_derivatives is enabled.
$this->assertEqual($this->config('image.settings')->get('allow_insecure_derivatives'), TRUE);
// Check that a security token is still required when generating a second
// image derivative using the first one as a source.
$nested_url = $this->style->buildUrl($generated_uri, $clean_url);
$matches_expected_url_format = (boolean) preg_match('/styles\/' . $this->style->id() . '\/' . $scheme . '\/styles\/' . $this->style->id() . '\/' . $scheme . '/', $nested_url);
$this->assertTrue($matches_expected_url_format, "Url for a derivative of an image style matches expected format.");
$nested_url_with_wrong_token = str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $nested_url);
$this->drupalGet($nested_url_with_wrong_token);
$this->assertResponse(403, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token.');
// Check that this restriction cannot be bypassed by adding extra slashes
// to the URL.
$this->drupalGet(substr_replace($nested_url_with_wrong_token, '//styles/', strrpos($nested_url_with_wrong_token, '/styles/'), strlen('/styles/')));
$this->assertResponse(403, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token, even with an extra forward slash in the URL.');
$this->drupalGet(substr_replace($nested_url_with_wrong_token, '////styles/', strrpos($nested_url_with_wrong_token, '/styles/'), strlen('/styles/')));
$this->assertResponse(403, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token, even with multiple forward slashes in the URL.');
// Make sure the image can still be generated if a correct token is used.
$this->drupalGet($nested_url);
$this->assertResponse(200, 'Image was accessible when a correct token was provided in the URL.');
// Check that requesting a nonexistent image does not create any new
// directories in the file system.
$directory = $scheme . '://styles/' . $this->style->id() . '/' . $scheme . '/' . $this->randomMachineName();
$this->drupalGet(file_create_url($directory . '/' . $this->randomString()));
$this->assertFalse(file_exists($directory), 'New directory was not created in the filesystem when requesting an unauthorized image.');
}
}

View file

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\d6\MigrateImageCacheTest.
* Contains \Drupal\image\Tests\Migrate\d6\MigrateImageCacheTest.
*/
namespace Drupal\image\Tests\Migrate\d6;
@ -21,32 +21,14 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
*/
class MigrateImageCacheTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('image');
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->prepareMigrations(array(
'd6_imagecache_presets' => [],
));
$this->installConfig(['image']);
}
/**
* Override parent to setup migration prior to run.
*/
public function testSourcePlugin() {
$this->executeMigration('d6_imagecache_presets');
parent::testSourcePlugin();
}
/**
* Test basic passing migrations.
*/

View file

@ -0,0 +1,78 @@
<?php
/**
* @file
* Contains \Drupal\image\Tests\Migrate\d7\MigrateImageStylesTest.
*/
namespace Drupal\image\Tests\Migrate\d7;
use Drupal\image\Entity\ImageStyle;
use Drupal\image\ImageStyleInterface;
use Drupal\image\ImageEffectBase;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
/**
* Test image styles migration to config entities.
*
* @group image
*/
class MigrateImageStylesTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('image');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(static::$modules);
$this->executeMigration('d7_image_styles');
}
/**
* Test the image styles migration.
*/
public function testImageStylesMigration() {
$this->assertEntity('custom_image_style_1', "Custom image style 1", ['image_scale_and_crop', 'image_desaturate'], [['width' => 55, 'height' => 55], []]);
$this->assertEntity('custom_image_style_2', "Custom image style 2", ['image_resize', 'image_rotate'], [['width' => 55, 'height' => 100], ['degrees' => 45, 'bgcolor' => '#FFFFFF', 'random' => false]]);
$this->assertEntity('custom_image_style_3', "Custom image style 3", ['image_scale', 'image_crop'], [['width' => 150, 'height' => NULL, 'upscale' => false], ['width' => 50, 'height' => 50, 'anchor' => 'left-top']]);
}
/**
* Asserts various aspects of an ImageStyle entity.
*
* @param string $id
* The expected image style ID.
* @param string $label
* The expected image style label.
* @param array $expected_effect_plugins
* An array of expected plugins attached to the image style entity
* @param array $expected_effect_config
* An array of expected configuration for each effect in the image style
*/
protected function assertEntity($id, $label, array $expected_effect_plugins, array $expected_effect_config) {
$style = ImageStyle::load($id);
$this->assertTrue($style instanceof ImageStyleInterface);
/** @var \Drupal\image\ImageStyleInterface $style */
$this->assertIdentical($id, $style->id());
$this->assertIdentical($label, $style->label());
// Check the number of effects associated with the style.
$effects = $style->getEffects();
$this->assertIdentical(count($effects), count($expected_effect_plugins));
$index = 0;
foreach ($effects as $effect) {
$this->assertTrue($effect instanceof ImageEffectBase);
$this->assertIdentical($expected_effect_plugins[$index], $effect->getPluginId());
$config = $effect->getConfiguration();
$this->assertIdentical($expected_effect_config[$index], $config['data']);
$index++;
}
}
}

View file

@ -84,7 +84,7 @@ class RelationshipUserImageDataTest extends ViewTestBase {
'user',
],
];
$this->assertIdentical($expected, $view->calculateDependencies());
$this->assertIdentical($expected, $view->getDependencies());
$this->executeView($view);
$expected_result = array(
array(