diff -u b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php --- b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -316,7 +316,7 @@ */ public function testStyleReplacement() { // Create a new style. - list($style, $style_name) = $this->createRandomStyle(); + $style = $this->createRandomStyle(); $style_path = 'admin/config/media/image-styles/manage/'; // Create an image field that uses the new style. @@ -326,7 +326,7 @@ ->getViewDisplay('node', 'article') ->setComponent($field_name, [ 'type' => 'image', - 'settings' => ['image_style' => $style_name], + 'settings' => ['image_style' => $style->getName()], ]) ->save(); @@ -353,7 +353,7 @@ 'name' => $new_style_name, 'label' => $new_style_label, ]; - $this->drupalGet($style_path . $style_name); + $this->drupalGet($style_path . $style->getName()); $this->submitForm($edit, 'Save'); $this->assertSession()->pageTextContains('Changes to the style have been saved.'); $this->drupalGet('node/' . $nid); @@ -436,7 +436,7 @@ $admin_path = 'admin/config/media/image-styles'; // Create a new style. - list($style, , $style_path) = $this->createRandomStyle(); + $style = $this->createRandomStyle(); // Create an image to make sure it gets flushed. $files = $this->drupalGetTestFiles('image'); @@ -448,7 +448,7 @@ // Go to image styles list page and check if the flush operation link // exists. $this->drupalGet($admin_path); - $flush_path = $style_path . '/flush'; + $flush_path = $style->toUrl()->toString() . '/flush'; $this->assertSession()->linkByHrefExists($flush_path); // Flush the image style derivatives using the user interface. @@ -464,7 +464,7 @@ */ public function testConfigImport() { // Create a new style. - list($style, $style_name) = $this->createRandomStyle(); + $style = $this->createRandomStyle(); // Create an image field that uses the new style. $field_name = strtolower($this->randomMachineName(10)); @@ -473,7 +473,7 @@ ->getViewDisplay('node', 'article') ->setComponent($field_name, [ 'type' => 'image', - 'settings' => ['image_style' => $style_name], + 'settings' => ['image_style' => $style->getName()], ]) ->save(); @@ -499,10 +499,10 @@ ->removeComponent($field_name) ->save(); $this->copyConfig($active, $sync); - $sync->delete('image.style.' . $style_name); + $sync->delete('image.style.' . $style->getName()); $this->configImporter()->import(); - $this->assertNull(ImageStyle::load($style_name), 'Style deleted after config import.'); + $this->assertNull(ImageStyle::load($style->getName()), 'Style deleted after config import.'); $this->assertEquals(0, $this->getImageCount($style), 'Image style was flushed after being deleted by config import.'); } diff -u b/core/modules/image/tests/src/Functional/ImageAdminUiTest.php b/core/modules/image/tests/src/Functional/ImageAdminUiTest.php --- b/core/modules/image/tests/src/Functional/ImageAdminUiTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminUiTest.php @@ -27,15 +27,15 @@ * Test if the help text is available on the edit effect form. */ public function testAddEffectHelpText(): void { - list(, , $style_path) = $this->createRandomStyle(); + $style = $this->createRandomStyle(); // Add the help block to the page. $this->drupalPlaceBlock('help_block', ['region' => 'help', 'id' => 'block-help']); // Open the add effect form and check for the help text. - $this->drupalGet($style_path . '/add/image_resize'); + $this->drupalGet($style->toUrl()->toString() . '/add/image_resize'); - $this->assertSession()->pageTextContains(t('Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.')); + $this->assertSession()->pageTextContains('Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.'); } /** @@ -43,7 +43,7 @@ */ public function testEditEffectHelpText(): void { // Create a random image style. - list(, $style_name, $style_path) = $this->createRandomStyle(); + $style = $this->createRandomStyle(); // Add the help block to the page. $this->drupalPlaceBlock('help_block', ['region' => 'help', 'id' => 'block-help']); @@ -52,16 +52,16 @@ $edit = []; $edit['data[width]'] = 20; $edit['data[height]'] = 20; - $this->drupalGet($style_path . '/add/image_resize'); + $this->drupalGet($style->toUrl()->toString() . '/add/image_resize'); $this->submitForm($edit, t('Add effect')); // Open the edit effect form and check image style effect help text. - $style = ImageStyle::load($style_name); + $style = ImageStyle::load($style->getName()); $effects = $style->get('effects'); foreach ($effects as $ieid => $effect) { - $this->drupalGet($style_path . '/effects/' . $ieid); + $this->drupalGet($style->toUrl()->toString() . '/effects/' . $ieid); - $this->assertSession()->pageTextContains(t('Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.')); + $this->assertSession()->pageTextContains('Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.'); } } diff -u b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php --- b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php +++ b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php @@ -92,20 +92,16 @@ /** * Create a random style. * - * @return array + * @return object * A list containing the details of the generated image style. */ - public function createRandomStyle(): array { + public function createRandomStyle(): object { $style_name = strtolower($this->randomMachineName()); $style_label = $this->randomString(); $values = ['name' => $style_name, 'label' => $style_label]; $style = \Drupal::entityTypeManager()->getStorage('image_style')->create($values); $style->save(); - return [ - $style, - $style_name, - 'admin/config/media/image-styles/manage/' . $style_name, - ]; + return $style; } /**