' . implode(', ', $image_styles) . '');
+ $image_styles = implode(', ', $image_styles);
+ $list = new TranslatableMarkup("$image_styles");
return t('You can display images using site-wide styles by adding a data-image-style attribute, whose values is one of the image style machine names: @image-style-machine-name-list.
', ['@image-style-machine-name-list' => $list]);
}
return t('You can display images using site-wide styles by adding a data-image-style attribute.');
diff --git a/core/modules/image/src/Tests/Update/ImageUpdateTextFormatsTest.php b/core/modules/image/src/Tests/Update/ImageUpdateTextFormatsTest.php
deleted file mode 100644
index fd0441c..0000000
--- a/core/modules/image/src/Tests/Update/ImageUpdateTextFormatsTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-databaseDumpFiles = [
- __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
- ];
- }
-
- /**
- * Tests image_post_update_enable_filter_image_style().
- *
- * @see image_post_update_enable_filter_image_style()
- */
- public function testPostUpdateFilterImageStyle() {
- // Check that the 'basic_html' and 'full_html' formats do not have the image
- // style filter before starting the update.
- $config_factory = \Drupal::configFactory();
- $basic_html_data = $config_factory->get('filter.format.basic_html');
- $this->assertNull($basic_html_data->get('filters.filter_image_style'));
- $full_html_data = $config_factory->get('filter.format.full_html');
- $this->assertNull($full_html_data->get('filters.filter_image_style'));
-
- // Run updates.
- $this->runUpdates();
-
- // Check that the filter_format entities have been updated.
- $basic_html_data = $config_factory->get('filter.format.basic_html');
- $this->assertNotNull($basic_html_data->get('filters.filter_image_style'));
- $full_html_data = $config_factory->get('filter.format.full_html');
- $this->assertNotNull($full_html_data->get('filters.filter_image_style'));
- }
-
-}
diff --git a/core/modules/image/tests/src/Functional/FilterImageStyleTest.php b/core/modules/image/tests/src/Functional/FilterImageStyleTest.php
index 2c7aee6..40c99e1 100644
--- a/core/modules/image/tests/src/Functional/FilterImageStyleTest.php
+++ b/core/modules/image/tests/src/Functional/FilterImageStyleTest.php
@@ -11,6 +11,7 @@
* Tests FilterImageStyle conversion of inline images to utilize image styles.
*
* @coversDefaultClass \Drupal\image\Plugin\Filter\FilterImageStyle
+ *
* @group image
*/
class FilterImageStyleTest extends BrowserTestBase {
@@ -110,9 +111,9 @@ public function testImageStyle() {
/** @var \Behat\Mink\Element\NodeElement $img_element */
$image_element = $this->getSession()->getPage()->find('css', 'img.image-style-medium');
- $this->assertFalse(empty($image_element));
+ $this->assertNotEmpty($image_element);
- $this->assertTrue(strpos($image_element->getAttribute('src'), 'medium'));
+ $this->assertContains('medium', $image_element->getAttribute('src'));
$this->assertEquals('220', $image_element->getAttribute('width'));
$this->assertEquals('164', $image_element->getAttribute('height'));
}
diff --git a/core/modules/image/tests/src/Functional/Update/ImageUpdateTest.php b/core/modules/image/tests/src/Functional/Update/ImageUpdateTest.php
index c3a5ddf..865f898 100644
--- a/core/modules/image/tests/src/Functional/Update/ImageUpdateTest.php
+++ b/core/modules/image/tests/src/Functional/Update/ImageUpdateTest.php
@@ -32,11 +32,11 @@ public function testPostUpdateImageStylesDependencies() {
// 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));
+ $this->assertNotContains('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));
+ $this->assertNotContains('image.style.thumbnail', $dependencies);
// Run updates.
$this->runUpdates();
@@ -44,11 +44,35 @@ public function testPostUpdateImageStylesDependencies() {
// 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));
+ $this->assertContains('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));
+ $this->assertContains('image.style.large', $dependencies);
+ }
+
+ /**
+ * Tests image_post_update_enable_filter_image_style().
+ *
+ * @see image_post_update_enable_filter_image_style()
+ */
+ public function testPostUpdateFilterImageStyle() {
+ // Check that the 'basic_html' and 'full_html' formats do not have the image
+ // style filter before starting the update.
+ $config_factory = \Drupal::configFactory();
+ $basic_html_data = $config_factory->get('filter.format.basic_html');
+ $this->assertNull($basic_html_data->get('filters.filter_image_style'));
+ $full_html_data = $config_factory->get('filter.format.full_html');
+ $this->assertNull($full_html_data->get('filters.filter_image_style'));
+
+ // Run updates.
+ $this->runUpdates();
+
+ // Check that the filter_format entities have been updated.
+ $basic_html_data = $config_factory->get('filter.format.basic_html');
+ $this->assertNotNull($basic_html_data->get('filters.filter_image_style'));
+ $full_html_data = $config_factory->get('filter.format.full_html');
+ $this->assertNotNull($full_html_data->get('filters.filter_image_style'));
}
}
diff --git a/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php b/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php
index f8562e5..4f65cf0 100644
--- a/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php
+++ b/core/modules/image/tests/src/FunctionalJavascript/AddImageTest.php
@@ -69,10 +69,8 @@ public function testDataImageStyleElement() {
$image_button = $page->find('css', $image_button_selector);
$this->assertNotEmpty($image_button);
$image_button->click();
- // Wait for the modal form elements to appear (loading is done).
- $this->assertJsCondition("jQuery('input[data-drupal-selector=\"edit-attributes-alt\"]').length > 0");
- $url_input = $page->findField('attributes[src]');
+ $url_input = $this->assertSession()->waitForField('attributes[src]');
$this->assertNotEmpty($url_input);
$url_input->setValue($image_url);
@@ -87,8 +85,8 @@ public function testDataImageStyleElement() {
// To prevent 403s on save, we re-set our request (cookie) state.
$this->prepareRequest();
- // Using NodeElement::click() on the button or NodeElement::submit() on the
- // form generated phantomjs-internal exceptions. This was the only recourse.
+ // @todo: Switch to using NodeElement::click() on the button or
+ // NodeElement::submit() on the form when #2831506 is fixed.
// @see https://www.drupal.org/node/2831506
$script = "jQuery('input[id^=\"edit-actions-save-modal\"]').click()";
$this->getSession()->executeScript($script);
@@ -97,7 +95,6 @@ public function testDataImageStyleElement() {
$source_button = $page->find('css', 'a.cke_button__source');
$this->assertNotEmpty($source_button);
$source_button->click();
- $this->assertSession()->assertWaitOnAjaxRequest();
$this->assertContains('data-image-style="thumbnail"', $page->find('css', 'textarea.cke_source')->getValue());
}
diff --git a/core/modules/image/tests/src/Kernel/EditorImageStyleDialogTest.php b/core/modules/image/tests/src/Kernel/EditorImageStyleDialogTest.php
index bdcad28..5c456af 100644
--- a/core/modules/image/tests/src/Kernel/EditorImageStyleDialogTest.php
+++ b/core/modules/image/tests/src/Kernel/EditorImageStyleDialogTest.php
@@ -27,7 +27,11 @@ class EditorImageStyleDialogTest extends EntityKernelTestBase {
protected $editor;
/**
- * {@inheritdoc}
+ * Modules to enable.
+ *
+ * @var array
+ *
+ * @todo: Change to protected. https://www.drupal.org/node/2822382
*/
public static $modules = [
'ckeditor',
@@ -151,7 +155,8 @@ protected function setUpForm($enable_image_filter) {
public function testDialogNoStyles() {
$form = $this->setUpForm(FALSE);
- $this->assertArrayNotHasKey('image_style', $form);
+ $this->assertFalse($form['image_style']['selection']['#access']);
+ $this->assertFalse($form['image_style']['link']['#access']);
}
/**
@@ -160,10 +165,9 @@ public function testDialogNoStyles() {
public function testDialogStyles() {
$form = $this->setUpForm(TRUE);
- $this->assertEquals(['large', 'medium', 'thumbnail'], array_keys($form['image_style']['selection']['#options']));
+ $this->assertEquals(['', 'large', 'medium', 'thumbnail'], array_keys($form['image_style']['selection']['#options']));
$this->assertEquals('medium', $form['image_style']['selection']['#default_value']);
- $this->assertEquals(TRUE, $form['image_style']['selection']['#required']);
}
}