upgrades core to 8.4.2
This commit is contained in:
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -8,8 +8,8 @@ dependencies:
|
||||
- image
|
||||
- views
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\image\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
|
||||
/**
|
||||
* Tests Image update path.
|
||||
*
|
||||
* @group image
|
||||
*/
|
||||
class ImageUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests image_post_update_image_style_dependencies().
|
||||
*
|
||||
* @see image_post_update_image_style_dependencies()
|
||||
*/
|
||||
public function testPostUpdateImageStylesDependencies() {
|
||||
$view = 'core.entity_view_display.node.article.default';
|
||||
$form = 'core.entity_form_display.node.article.default';
|
||||
|
||||
// Check that view display 'node.article.default' doesn't depend on image
|
||||
// style 'image.style.large'.
|
||||
$dependencies = $this->config($view)->get('dependencies.config');
|
||||
$this->assertFalse(in_array('image.style.large', $dependencies));
|
||||
// Check that form display 'node.article.default' doesn't depend on image
|
||||
// style 'image.style.thumbnail'.
|
||||
$dependencies = $this->config($form)->get('dependencies.config');
|
||||
$this->assertFalse(in_array('image.style.thumbnail', $dependencies));
|
||||
|
||||
// Run updates.
|
||||
$this->runUpdates();
|
||||
|
||||
// Check that view display 'node.article.default' depend on image style
|
||||
// 'image.style.large'.
|
||||
$dependencies = $this->config($view)->get('dependencies.config');
|
||||
$this->assertTrue(in_array('image.style.large', $dependencies));
|
||||
// Check that form display 'node.article.default' depend on image style
|
||||
// 'image.style.thumbnail'.
|
||||
$dependencies = $this->config($view)->get('dependencies.config');
|
||||
$this->assertTrue(in_array('image.style.large', $dependencies));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,8 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
use Drupal\Tests\field\Kernel\FieldKernelTestBase;
|
||||
|
||||
/**
|
||||
@@ -99,4 +101,89 @@ class ImageFormatterTest extends FieldKernelTestBase {
|
||||
$this->assertEquals($entity->{$this->fieldName}[1]->entity->getCacheTags(), $build[$this->fieldName][1]['#cache']['tags'], 'Second image cache tags is as expected');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ImageFormatter's handling of SVG images.
|
||||
*
|
||||
* @requires extension gd
|
||||
*/
|
||||
public function testImageFormatterSvg() {
|
||||
// Install the default image styles.
|
||||
$this->installConfig(['image']);
|
||||
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = $this->container->get('renderer');
|
||||
|
||||
$png = File::create([
|
||||
'uri' => 'public://test-image.png',
|
||||
]);
|
||||
$png->save();
|
||||
|
||||
// We need to create an actual empty PNG, or the GD toolkit will not
|
||||
// consider the image valid.
|
||||
$png_resource = imagecreate(300, 300);
|
||||
imagefill($png_resource, 0, 0, imagecolorallocate($png_resource, 0, 0, 0));
|
||||
imagepng($png_resource, $png->getFileUri());
|
||||
|
||||
$svg = File::create([
|
||||
'uri' => 'public://test-image.svg',
|
||||
]);
|
||||
$svg->save();
|
||||
// We don't have to put any real SVG data in here, because the GD toolkit
|
||||
// won't be able to load it anyway.
|
||||
touch($svg->getFileUri());
|
||||
|
||||
$entity = EntityTest::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
$this->fieldName => [$png, $svg],
|
||||
]);
|
||||
$entity->save();
|
||||
|
||||
// Ensure that the display is using the medium image style.
|
||||
$component = $this->display->getComponent($this->fieldName);
|
||||
$component['settings']['image_style'] = 'medium';
|
||||
$this->display->setComponent($this->fieldName, $component)->save();
|
||||
|
||||
$build = $this->display->build($entity);
|
||||
|
||||
// The first image is a PNG, so it is supported by the GD image toolkit.
|
||||
// The image style should be applied with its cache tags, image derivative
|
||||
// computed with its URI and dimensions.
|
||||
$this->assertCacheTags($build[$this->fieldName][0], ImageStyle::load('medium')->getCacheTags());
|
||||
$renderer->renderRoot($build[$this->fieldName][0]);
|
||||
$this->assertEquals('medium', $build[$this->fieldName][0]['#image_style']);
|
||||
// We check that the image URL contains the expected style directory
|
||||
// structure.
|
||||
$this->assertTrue(strpos($build[$this->fieldName][0]['#markup'], 'styles/medium/public/test-image.png') !== FALSE);
|
||||
$this->assertTrue(strpos($build[$this->fieldName][0]['#markup'], 'width="220"') !== FALSE);
|
||||
$this->assertTrue(strpos($build[$this->fieldName][0]['#markup'], 'height="220"') !== FALSE);
|
||||
|
||||
// The second image is an SVG, which is not supported by the GD toolkit.
|
||||
// The image style should still be applied with its cache tags, but image
|
||||
// derivative will not be available so <img> tag will point to the original
|
||||
// image.
|
||||
$this->assertCacheTags($build[$this->fieldName][1], ImageStyle::load('medium')->getCacheTags());
|
||||
$renderer->renderRoot($build[$this->fieldName][1]);
|
||||
$this->assertEquals('medium', $build[$this->fieldName][1]['#image_style']);
|
||||
// We check that the image URL does not contain the style directory
|
||||
// structure.
|
||||
$this->assertFalse(strpos($build[$this->fieldName][1]['#markup'], 'styles/medium/public/test-image.svg'));
|
||||
// Since we did not store original image dimensions, width and height
|
||||
// HTML attributes will not be present.
|
||||
$this->assertFalse(strpos($build[$this->fieldName][1]['#markup'], 'width'));
|
||||
$this->assertFalse(strpos($build[$this->fieldName][1]['#markup'], 'height'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a renderable array has a set of cache tags.
|
||||
*
|
||||
* @param array $renderable
|
||||
* The renderable array. Must have a #cache[tags] element.
|
||||
* @param array $cache_tags
|
||||
* The expected cache tags.
|
||||
*/
|
||||
protected function assertCacheTags(array $renderable, array $cache_tags) {
|
||||
$diff = array_diff($cache_tags, $renderable['#cache']['tags']);
|
||||
$this->assertEmpty($diff);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\image\Kernel;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageException;
|
||||
use Drupal\Core\Field\FieldItemInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
@@ -129,4 +130,26 @@ class ImageItemTest extends FieldKernelTestBase {
|
||||
$this->assertEqual($entity->image_test->entity->get('filemime')->value, 'image/jpeg');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a malformed image.
|
||||
*/
|
||||
public function testImageItemMalformed() {
|
||||
// Validate entity is an image and don't gather dimensions if it is not.
|
||||
$entity = EntityTest::create();
|
||||
$entity->image_test = NULL;
|
||||
$entity->image_test->target_id = 9999;
|
||||
// PHPUnit re-throws E_USER_WARNING as an exception.
|
||||
try {
|
||||
$entity->save();
|
||||
$this->fail('Exception did not fail');
|
||||
}
|
||||
catch (EntityStorageException $exception) {
|
||||
$this->assertInstanceOf(\PHPUnit_Framework_Error_Warning::class, $exception->getPrevious());
|
||||
$this->assertEquals($exception->getMessage(), 'Missing file with ID 9999.');
|
||||
$this->assertEmpty($entity->image_test->width);
|
||||
$this->assertEmpty($entity->image_test->height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -141,9 +141,11 @@ class MigrateImageCacheTest extends MigrateDrupal6TestBase {
|
||||
|
||||
$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->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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user