updated core to 8.6.1 via composer
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
(function (Drupal) {
|
||||
(function(Drupal) {
|
||||
/**
|
||||
* Call picturefill so newly added responsive images are processed.
|
||||
*/
|
||||
@@ -9,4 +9,4 @@
|
||||
}
|
||||
},
|
||||
};
|
||||
}(Drupal));
|
||||
})(Drupal);
|
||||
|
||||
@@ -5,6 +5,6 @@ package: Core
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- breakpoint
|
||||
- image
|
||||
- drupal:breakpoint
|
||||
- drupal:image
|
||||
configure: entity.responsive_image_style.collection
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
use Drupal\responsive_image\Entity\ResponsiveImageStyle;
|
||||
@@ -127,7 +126,7 @@ function template_preprocess_responsive_image_formatter(&$variables) {
|
||||
$item = $variables['item'];
|
||||
$attributes = [];
|
||||
// Do not output an empty 'title' attribute.
|
||||
if (Unicode::strlen($item->title) != 0) {
|
||||
if (mb_strlen($item->title) != 0) {
|
||||
$attributes['title'] = $item->title;
|
||||
}
|
||||
$attributes['alt'] = $item->alt;
|
||||
@@ -449,7 +448,7 @@ function _responsive_image_build_source_attributes(array $variables, BreakpointI
|
||||
// be sorted from small to large, since the first matching source will
|
||||
// be used. We multiply it by 100 so multipliers with up to two decimals
|
||||
// can be used.
|
||||
$srcset[intval(Unicode::substr($multiplier, 0, -1) * 100)] = _responsive_image_image_style_url($image_style_mapping['image_mapping'], $variables['uri']) . ' ' . $multiplier;
|
||||
$srcset[intval(mb_substr($multiplier, 0, -1) * 100)] = _responsive_image_image_style_url($image_style_mapping['image_mapping'], $variables['uri']) . ' ' . $multiplier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,13 @@ use Drupal\responsive_image\ResponsiveImageStyleInterface;
|
||||
* @ConfigEntityType(
|
||||
* id = "responsive_image_style",
|
||||
* label = @Translation("Responsive image style"),
|
||||
* label_collection = @Translation("Responsive image styles"),
|
||||
* label_singular = @Translation("responsive image style"),
|
||||
* label_plural = @Translation("responsive image styles"),
|
||||
* label_count = @PluralTranslation(
|
||||
* singular = "@count responsive image style",
|
||||
* plural = "@count responsive image styles",
|
||||
* ),
|
||||
* handlers = {
|
||||
* "list_builder" = "Drupal\responsive_image\ResponsiveImageStyleListBuilder",
|
||||
* "form" = {
|
||||
|
||||
+1
-1
@@ -138,7 +138,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa
|
||||
$elements['responsive_image_style'] = [
|
||||
'#title' => t('Responsive image style'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $this->getSetting('responsive_image_style'),
|
||||
'#default_value' => $this->getSetting('responsive_image_style') ?: NULL,
|
||||
'#required' => TRUE,
|
||||
'#options' => $responsive_image_options,
|
||||
'#description' => [
|
||||
|
||||
@@ -259,7 +259,7 @@ class ResponsiveImageStyleForm extends EntityForm {
|
||||
'image_mapping' => [
|
||||
'sizes' => $image_style_mapping['sizes'],
|
||||
'sizes_image_styles' => array_keys(array_filter($image_style_mapping['sizes_image_styles'])),
|
||||
]
|
||||
],
|
||||
];
|
||||
$responsive_image_style->addImageStyleMapping($breakpoint_id, $multiplier, $mapping);
|
||||
}
|
||||
@@ -276,7 +276,7 @@ class ResponsiveImageStyleForm extends EntityForm {
|
||||
$responsive_image_style->save();
|
||||
|
||||
$this->logger('responsive_image')->notice('Responsive image style @label saved.', ['@label' => $responsive_image_style->label()]);
|
||||
drupal_set_message($this->t('Responsive image style %label saved.', ['%label' => $responsive_image_style->label()]));
|
||||
$this->messenger()->addStatus($this->t('Responsive image style %label saved.', ['%label' => $responsive_image_style->label()]));
|
||||
|
||||
// Redirect to edit form after creating a new responsive image style or
|
||||
// after selecting another breakpoint group.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Drupal\responsive_image\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\image\Tests\ImageFieldTestBase;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
use Drupal\node\Entity\Node;
|
||||
@@ -52,7 +51,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
|
||||
'create article content',
|
||||
'edit any article content',
|
||||
'delete any article content',
|
||||
'administer image styles'
|
||||
'administer image styles',
|
||||
]);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
// Add responsive image style.
|
||||
@@ -152,6 +151,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test responsive image formatters on node display.
|
||||
*
|
||||
@@ -168,7 +168,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = $this->container->get('renderer');
|
||||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
$field_name = Unicode::strtolower($this->randomMachineName());
|
||||
$field_name = mb_strtolower($this->randomMachineName());
|
||||
$this->createImageField($field_name, 'article', ['uri_scheme' => $scheme]);
|
||||
// Create a new node with an image attached. Make sure we use a large image
|
||||
// so the scale effects of the image styles always have an effect.
|
||||
@@ -366,7 +366,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
|
||||
])
|
||||
->save();
|
||||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
$field_name = Unicode::strtolower($this->randomMachineName());
|
||||
$field_name = mb_strtolower($this->randomMachineName());
|
||||
$this->createImageField($field_name, 'article', ['uri_scheme' => 'public']);
|
||||
// Create a new node with an image attached.
|
||||
$test_image = current($this->drupalGetTestFiles('image'));
|
||||
@@ -414,7 +414,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
|
||||
])
|
||||
->save();
|
||||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
$field_name = Unicode::strtolower($this->randomMachineName());
|
||||
$field_name = mb_strtolower($this->randomMachineName());
|
||||
$this->createImageField($field_name, 'article', ['uri_scheme' => 'public']);
|
||||
// Create a new node with an image attached.
|
||||
$test_image = current($this->drupalGetTestFiles('image'));
|
||||
@@ -451,7 +451,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
|
||||
* The link type to test. Either 'file' or 'content'.
|
||||
*/
|
||||
private function assertResponsiveImageFieldFormattersLink($link_type) {
|
||||
$field_name = Unicode::strtolower($this->randomMachineName());
|
||||
$field_name = mb_strtolower($this->randomMachineName());
|
||||
$field_settings = ['alt_field_required' => 0];
|
||||
$this->createImageField($field_name, 'article', ['uri_scheme' => 'public'], $field_settings);
|
||||
// Create a new node with an image attached.
|
||||
|
||||
@@ -77,7 +77,7 @@ class ResponsiveImageFieldUiTest extends WebTestBase {
|
||||
])
|
||||
->addImageStyleMapping('responsive_image_test_module.narrow', '1x', [
|
||||
'image_mapping_type' => 'image_style',
|
||||
'image_mapping' => 'medium'
|
||||
'image_mapping' => 'medium',
|
||||
])
|
||||
// Test the normal output of mapping to an image style.
|
||||
->addImageStyleMapping('responsive_image_test_module.wide', '1x', [
|
||||
|
||||
-1
@@ -4,4 +4,3 @@ description: 'Test theme for responsive image.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\responsive_image\Functional\Rest\ResponsiveImageStyleResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ResponsiveImageStyleHalJsonAnonTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\responsive_image\Functional\Rest\ResponsiveImageStyleResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ResponsiveImageStyleHalJsonBasicAuthTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal', 'basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\responsive_image\Functional\Rest\ResponsiveImageStyleResourceTestBase;
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ResponsiveImageStyleHalJsonCookieTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class ResponsiveImageAdminUITest extends BrowserTestBase {
|
||||
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.');
|
||||
$this->assertText('There are no responsive image styles yet.');
|
||||
|
||||
// Add a responsive image style.
|
||||
$this->drupalGet('admin/config/media/responsive-image-style/add');
|
||||
@@ -54,7 +54,7 @@ class ResponsiveImageAdminUITest extends BrowserTestBase {
|
||||
// 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->assertNoText('There are no responsive image styles yet.');
|
||||
$this->assertText('Style One');
|
||||
$this->assertText('style_one');
|
||||
|
||||
@@ -137,7 +137,7 @@ class ResponsiveImageAdminUITest extends BrowserTestBase {
|
||||
$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.');
|
||||
$this->assertText('There are no responsive image styles yet.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ResponsiveImageStyleJsonAnonTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ResponsiveImageStyleJsonBasicAuthTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ResponsiveImageStyleJsonCookieTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Rest;
|
||||
|
||||
use Drupal\responsive_image\Entity\ResponsiveImageStyle;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
|
||||
|
||||
/**
|
||||
* ResourceTestBase for ResponsiveImageStyle entity.
|
||||
*/
|
||||
abstract class ResponsiveImageStyleResourceTestBase extends EntityResourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['responsive_image'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $entityTypeId = 'responsive_image_style';
|
||||
|
||||
/**
|
||||
* The ResponsiveImageStyle entity.
|
||||
*
|
||||
* @var \Drupal\responsive_image\ResponsiveImageStyleInterface
|
||||
*/
|
||||
protected $entity;
|
||||
|
||||
/**
|
||||
* The effect UUID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $effectUuid;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpAuthorization($method) {
|
||||
$this->grantPermissionsToTestedRole(['administer responsive images']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createEntity() {
|
||||
// Create a "Camelids" responsive image style.
|
||||
$camelids = ResponsiveImageStyle::create([
|
||||
'id' => 'camelids',
|
||||
'label' => 'Camelids',
|
||||
]);
|
||||
$camelids->setBreakpointGroup('test_group');
|
||||
$camelids->setFallbackImageStyle('fallback');
|
||||
$camelids->addImageStyleMapping('test_breakpoint', '1x', [
|
||||
'image_mapping_type' => 'image_style',
|
||||
'image_mapping' => 'small',
|
||||
]);
|
||||
$camelids->addImageStyleMapping('test_breakpoint', '2x', [
|
||||
'image_mapping_type' => 'sizes',
|
||||
'image_mapping' => [
|
||||
'sizes' => '(min-width:700px) 700px, 100vw',
|
||||
'sizes_image_styles' => [
|
||||
'medium' => 'medium',
|
||||
'large' => 'large',
|
||||
],
|
||||
],
|
||||
]);
|
||||
$camelids->save();
|
||||
|
||||
return $camelids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
return [
|
||||
'breakpoint_group' => 'test_group',
|
||||
'dependencies' => [
|
||||
'config' => [
|
||||
'image.style.large',
|
||||
'image.style.medium',
|
||||
],
|
||||
],
|
||||
'fallback_image_style' => 'fallback',
|
||||
'id' => 'camelids',
|
||||
'image_style_mappings' => [
|
||||
0 => [
|
||||
'breakpoint_id' => 'test_breakpoint',
|
||||
'image_mapping' => 'small',
|
||||
'image_mapping_type' => 'image_style',
|
||||
'multiplier' => '1x',
|
||||
],
|
||||
1 => [
|
||||
'breakpoint_id' => 'test_breakpoint',
|
||||
'image_mapping' => [
|
||||
'sizes' => '(min-width:700px) 700px, 100vw',
|
||||
'sizes_image_styles' => [
|
||||
'large' => 'large',
|
||||
'medium' => 'medium',
|
||||
],
|
||||
],
|
||||
'image_mapping_type' => 'sizes',
|
||||
'multiplier' => '2x',
|
||||
],
|
||||
],
|
||||
'label' => 'Camelids',
|
||||
'langcode' => 'en',
|
||||
'status' => TRUE,
|
||||
'uuid' => $this->entity->uuid(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
// @todo Update in https://www.drupal.org/node/2300677.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedUnauthorizedAccessMessage($method) {
|
||||
if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
|
||||
return parent::getExpectedUnauthorizedAccessMessage($method);
|
||||
}
|
||||
|
||||
return "The 'administer responsive images' permission is required.";
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ResponsiveImageStyleXmlAnonTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ResponsiveImageStyleXmlBasicAuthTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ResponsiveImageStyleXmlCookieTest extends ResponsiveImageStyleResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
+1
@@ -10,6 +10,7 @@ use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
* Tests responsive image module updates.
|
||||
*
|
||||
* @group responsive_image
|
||||
* @group legacy
|
||||
*/
|
||||
class ResponsiveImageUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\responsive_image\Functional;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\responsive_image\Entity\ResponsiveImageStyle;
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
|
||||
/**
|
||||
* Tests the integration of responsive image with Views.
|
||||
*
|
||||
* @group responsive_image
|
||||
*/
|
||||
class ViewsIntegrationTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* The responsive image style ID to use.
|
||||
*/
|
||||
const RESPONSIVE_IMAGE_STYLE_ID = 'responsive_image_style_id';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'views',
|
||||
'views_ui',
|
||||
'responsive_image',
|
||||
'field',
|
||||
'image',
|
||||
'file',
|
||||
'entity_test',
|
||||
'breakpoint',
|
||||
'responsive_image_test_module',
|
||||
];
|
||||
|
||||
/**
|
||||
* The test views to enable.
|
||||
*/
|
||||
public static $testViews = ['entity_test_row'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
|
||||
// Create a responsive image style.
|
||||
$responsive_image_style = ResponsiveImageStyle::create([
|
||||
'id' => self::RESPONSIVE_IMAGE_STYLE_ID,
|
||||
'label' => 'Foo',
|
||||
'breakpoint_group' => 'responsive_image_test_module',
|
||||
]);
|
||||
// Create an image field to be used with a responsive image formatter.
|
||||
FieldStorageConfig::create([
|
||||
'type' => 'image',
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'bar',
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => 'entity_test',
|
||||
'field_name' => 'bar',
|
||||
])->save();
|
||||
|
||||
$responsive_image_style
|
||||
->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
|
||||
'image_mapping_type' => 'image_style',
|
||||
'image_mapping' => 'thumbnail',
|
||||
])
|
||||
->addImageStyleMapping('responsive_image_test_module.narrow', '1x', [
|
||||
'image_mapping_type' => 'image_style',
|
||||
'image_mapping' => 'medium',
|
||||
])
|
||||
// Test the normal output of mapping to an image style.
|
||||
->addImageStyleMapping('responsive_image_test_module.wide', '1x', [
|
||||
'image_mapping_type' => 'image_style',
|
||||
'image_mapping' => 'large',
|
||||
])
|
||||
->save();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(['administer views']);
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests integration with Views.
|
||||
*/
|
||||
public function testViewsAddResponsiveImageField() {
|
||||
// Add the image field to the View.
|
||||
$this->drupalGet('admin/structure/views/nojs/add-handler/entity_test_row/default/field');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/entity_test_row/default/field', ['name[entity_test__bar.bar]' => TRUE], 'Add and configure field');
|
||||
// Set the formatter to 'Responsive image'.
|
||||
$this->drupalPostForm(NULL, ['options[type]' => 'responsive_image'], 'Apply');
|
||||
$this->assertSession()
|
||||
->responseContains('Responsive image style field is required.');
|
||||
$this->drupalPostForm(NULL, ['options[settings][responsive_image_style]' => self::RESPONSIVE_IMAGE_STYLE_ID], 'Apply');
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/entity_test_row/default/field/bar');
|
||||
// Make sure the selected value is set.
|
||||
$this->assertSession()
|
||||
->fieldValueEquals('options[settings][responsive_image_style]', self::RESPONSIVE_IMAGE_STYLE_ID);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -248,7 +248,7 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
|
||||
'image_mapping_type' => 'image_style',
|
||||
'image_mapping' => '_original image_',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
$this->assertEquals($expected, $entity->getKeyedImageStyleMappings());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user