upgrades core to 8.4.2
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
(function (Drupal) {
|
||||
/**
|
||||
* Call picturefill so newly added responsive images are processed.
|
||||
*/
|
||||
Drupal.behaviors.responsiveImageAJAX = {
|
||||
attach() {
|
||||
if (window.picturefill) {
|
||||
window.picturefill();
|
||||
}
|
||||
},
|
||||
};
|
||||
}(Drupal));
|
||||
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function (Drupal) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Call picturefill so newly added responsive images are processed.
|
||||
*/
|
||||
Drupal.behaviors.responsiveImageAJAX = {
|
||||
attach: function () {
|
||||
attach: function attach() {
|
||||
if (window.picturefill) {
|
||||
window.picturefill();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(Drupal);
|
||||
})(Drupal);
|
||||
@@ -9,8 +9,8 @@ dependencies:
|
||||
- image
|
||||
configure: entity.responsive_image_style.collection
|
||||
|
||||
# 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
|
||||
|
||||
@@ -20,6 +20,8 @@ use Drupal\breakpoint\BreakpointInterface;
|
||||
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\responsive_image\ResponsiveImageStyleInterface::EMPTY_IMAGE
|
||||
* instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2831620
|
||||
*/
|
||||
const RESPONSIVE_IMAGE_EMPTY_IMAGE = '_empty image_';
|
||||
|
||||
@@ -29,6 +31,8 @@ const RESPONSIVE_IMAGE_EMPTY_IMAGE = '_empty image_';
|
||||
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\responsive_image\ResponsiveImageStyleInterface::ORIGINAL_IMAGE
|
||||
* instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2831620
|
||||
*/
|
||||
const RESPONSIVE_IMAGE_ORIGINAL_IMAGE = '_original image_';
|
||||
|
||||
@@ -40,7 +44,7 @@ function responsive_image_help($route_name, RouteMatchInterface $route_match) {
|
||||
case 'help.page.responsive_image':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Responsive Image module provides an image formatter that allows browsers to select which image file to display based on media queries or which image file types the browser supports, using the HTML 5 picture and source elements and/or the sizes, srcset and type attributes. For more information, see the <a href=":responsive_image">online documentation for the Responsive Image module</a>.', [ ':responsive_image' => 'https://www.drupal.org/documentation/modules/responsive_image']) . '</p>';
|
||||
$output .= '<p>' . t('The Responsive Image module provides an image formatter that allows browsers to select which image file to display based on media queries or which image file types the browser supports, using the HTML 5 picture and source elements and/or the sizes, srcset and type attributes. For more information, see the <a href=":responsive_image">online documentation for the Responsive Image module</a>.', [':responsive_image' => 'https://www.drupal.org/documentation/modules/responsive_image']) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Defining responsive image styles') . '</dt>';
|
||||
|
||||
@@ -13,7 +13,7 @@ use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
*/
|
||||
function responsive_image_post_update_recreate_dependencies() {
|
||||
$displays = EntityViewDisplay::loadMultiple();
|
||||
array_walk($displays, function(EntityViewDisplayInterface $entity_view_display) {
|
||||
array_walk($displays, function (EntityViewDisplayInterface $entity_view_display) {
|
||||
$old_dependencies = $entity_view_display->getDependencies();
|
||||
$new_dependencies = $entity_view_display->calculateDependencies()->getDependencies();
|
||||
if ($old_dependencies !== $new_dependencies) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Drupal\responsive_image\Tests;
|
||||
|
||||
|
||||
use Drupal\field_ui\Tests\FieldUiTestTrait;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\responsive_image\Entity\ResponsiveImageStyle;
|
||||
|
||||
+3
-3
@@ -6,8 +6,8 @@ package: Testing
|
||||
# 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
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Thoroughly test the administrative interface of the Responsive Image module.
|
||||
*
|
||||
* @group responsive_image
|
||||
*/
|
||||
class ResponsiveImageAdminUITest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['responsive_image', 'responsive_image_test_module'];
|
||||
|
||||
/**
|
||||
* Drupal\simpletest\WebTestBase\setUp().
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'administer responsive images',
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test responsive image administration functionality.
|
||||
*/
|
||||
public function testResponsiveImageAdmin() {
|
||||
// We start without any default styles.
|
||||
$this->drupalGet('admin/config/media/responsive-image-style');
|
||||
$this->assertText('There is no Responsive image style yet.');
|
||||
|
||||
// Add a responsive image style.
|
||||
$this->drupalGet('admin/config/media/responsive-image-style/add');
|
||||
// The 'Responsive Image' breakpoint group should be selected by default.
|
||||
$this->assertFieldByName('breakpoint_group', 'responsive_image');
|
||||
|
||||
// Create a new group.
|
||||
$edit = [
|
||||
'label' => 'Style One',
|
||||
'id' => 'style_one',
|
||||
'breakpoint_group' => 'responsive_image_test_module',
|
||||
'fallback_image_style' => 'thumbnail',
|
||||
];
|
||||
$this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
|
||||
|
||||
// Check if the new group is created.
|
||||
$this->assertResponse(200);
|
||||
$this->drupalGet('admin/config/media/responsive-image-style');
|
||||
$this->assertNoText('There is no Responsive image style yet.');
|
||||
$this->assertText('Style One');
|
||||
$this->assertText('style_one');
|
||||
|
||||
// Edit the group.
|
||||
$this->drupalGet('admin/config/media/responsive-image-style/style_one');
|
||||
$this->assertFieldByName('label', 'Style One');
|
||||
$this->assertFieldByName('breakpoint_group', 'responsive_image_test_module');
|
||||
$this->assertFieldByName('fallback_image_style', 'thumbnail');
|
||||
|
||||
$cases = [
|
||||
['mobile', '1x'],
|
||||
['mobile', '2x'],
|
||||
['narrow', '1x'],
|
||||
['narrow', '2x'],
|
||||
['wide', '1x'],
|
||||
['wide', '2x'],
|
||||
];
|
||||
$image_styles = array_merge(
|
||||
[RESPONSIVE_IMAGE_EMPTY_IMAGE, RESPONSIVE_IMAGE_ORIGINAL_IMAGE],
|
||||
array_keys(image_style_options(FALSE))
|
||||
);
|
||||
foreach ($cases as $case) {
|
||||
// Check if the radio buttons are present.
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][image_mapping_type]', NULL);
|
||||
// Check if the image style dropdowns are present.
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][image_style]', NULL);
|
||||
// Check if the sizes textfields are present.
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][sizes]', NULL);
|
||||
|
||||
foreach ($image_styles as $image_style_name) {
|
||||
// Check if the image styles are available in the dropdowns.
|
||||
$this->assertTrue($this->xpath(
|
||||
'//select[@name=:name]//option[@value=:style]',
|
||||
[
|
||||
':name' => 'keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][image_style]',
|
||||
':style' => $image_style_name,
|
||||
]
|
||||
));
|
||||
// Check if the image styles checkboxes are present.
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][sizes_image_styles][' . $image_style_name . ']');
|
||||
}
|
||||
}
|
||||
|
||||
// Save styles for 1x variant only.
|
||||
$edit = [
|
||||
'label' => 'Style One',
|
||||
'breakpoint_group' => 'responsive_image_test_module',
|
||||
'fallback_image_style' => 'thumbnail',
|
||||
'keyed_styles[responsive_image_test_module.mobile][1x][image_mapping_type]' => 'image_style',
|
||||
'keyed_styles[responsive_image_test_module.mobile][1x][image_style]' => 'thumbnail',
|
||||
'keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]' => 'sizes',
|
||||
'keyed_styles[responsive_image_test_module.narrow][1x][sizes]' => '(min-width: 700px) 700px, 100vw',
|
||||
'keyed_styles[responsive_image_test_module.narrow][1x][sizes_image_styles][large]' => 'large',
|
||||
'keyed_styles[responsive_image_test_module.narrow][1x][sizes_image_styles][medium]' => 'medium',
|
||||
'keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]' => 'image_style',
|
||||
'keyed_styles[responsive_image_test_module.wide][1x][image_style]' => 'large',
|
||||
];
|
||||
$this->drupalPostForm('admin/config/media/responsive-image-style/style_one', $edit, t('Save'));
|
||||
$this->drupalGet('admin/config/media/responsive-image-style/style_one');
|
||||
|
||||
// Check the mapping for multipliers 1x and 2x for the mobile breakpoint.
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][1x][image_style]', 'thumbnail');
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][1x][image_mapping_type]', 'image_style');
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][2x][image_mapping_type]', '_none');
|
||||
|
||||
// Check the mapping for multipliers 1x and 2x for the narrow breakpoint.
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]', 'sizes');
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][sizes]', '(min-width: 700px) 700px, 100vw');
|
||||
$this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-large');
|
||||
$this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-medium');
|
||||
$this->assertNoFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-thumbnail');
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][2x][image_mapping_type]', '_none');
|
||||
|
||||
// Check the mapping for multipliers 1x and 2x for the wide breakpoint.
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][1x][image_style]', 'large');
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]', 'image_style');
|
||||
$this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][2x][image_mapping_type]', '_none');
|
||||
|
||||
// Delete the style.
|
||||
$this->drupalGet('admin/config/media/responsive-image-style/style_one/delete');
|
||||
$this->drupalPostForm(NULL, [], t('Delete'));
|
||||
$this->drupalGet('admin/config/media/responsive-image-style');
|
||||
$this->assertText('There is no Responsive image style yet.');
|
||||
}
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Update;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
|
||||
/**
|
||||
* Tests responsive image module updates.
|
||||
*
|
||||
* @group responsive_image
|
||||
*/
|
||||
class ResponsiveImageUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
/** @var \Drupal\Core\State\StateInterface $state */
|
||||
$state = $this->container->get('state');
|
||||
|
||||
// Enable responsive_image module without using the module installer to
|
||||
// avoid installation of configuration shipped in module.
|
||||
$system_module_files = $state->get('system.module.files', []);
|
||||
$system_module_files += ['responsive_image' => 'core/modules/responsive_image/responsive_image.info.yml'];
|
||||
$state->set('system.module.files', $system_module_files);
|
||||
$this->config('core.extension')->set('module.responsive_image', 0)->save();
|
||||
$this->container->get('module_handler')->addModule('responsive_image', 'core/modules/responsive_image');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests post-update responsive_image_post_update_dependency().
|
||||
*
|
||||
* @see responsive_image_post_update_dependency()
|
||||
*/
|
||||
public function testPostUpdateDependency() {
|
||||
// Installing the 'wide' responsive image style.
|
||||
$wide_image_style = Yaml::decode(file_get_contents(__DIR__ . '/../../../../../../profiles/standard/config/optional/responsive_image.styles.wide.yml'));
|
||||
$this->config('responsive_image.styles.wide')->setData($wide_image_style)->save(TRUE);
|
||||
|
||||
// Change 'field_image' formatter to a responsive image formatter.
|
||||
$options = [
|
||||
'type' => 'responsive_image',
|
||||
'label' => 'hidden',
|
||||
'settings' => ['responsive_image_style' => 'wide', 'image_link' => ''],
|
||||
'third_party_settings' => [],
|
||||
];
|
||||
$display = $this->config('core.entity_view_display.node.article.default');
|
||||
$display->set('content.field_image', $options)->save(TRUE);
|
||||
|
||||
// Check that there's no dependency to 'responsive_image.styles.wide'.
|
||||
$dependencies = $display->get('dependencies.config') ?: [];
|
||||
$this->assertFalse(in_array('responsive_image.styles.wide', $dependencies));
|
||||
|
||||
// Run updates.
|
||||
$this->runUpdates();
|
||||
|
||||
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
|
||||
$view_display = EntityViewDisplay::load('node.article.default');
|
||||
$dependencies = $view_display->getDependencies() + ['config' => []];
|
||||
// Check that post-update added a 'responsive_image.styles.wide' dependency.
|
||||
$this->assertTrue(in_array('responsive_image.styles.wide', $dependencies['config']));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user