comparison core/modules/image/tests/src/FunctionalJavascript/ImageAdminStylesTest.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents
children
comparison
equal deleted inserted replaced
15:e200cb7efeb3 16:c2387f117808
1 <?php
2
3 namespace Drupal\Tests\image\FunctionalJavascript;
4
5 use Drupal\image\Entity\ImageStyle;
6
7 /**
8 * Tests creation, deletion, and editing of image styles and effects.
9 *
10 * @group image
11 */
12 class ImageAdminStylesTest extends ImageFieldTestBase {
13
14 /**
15 * Tests editing Ajax-enabled image effect forms.
16 */
17 public function testAjaxEnabledEffectForm() {
18 $admin_path = 'admin/config/media/image-styles';
19
20 // Setup a style to be created and effects to add to it.
21 $style_name = strtolower($this->randomMachineName(10));
22 $style_label = $this->randomString();
23 $style_path = $admin_path . '/manage/' . $style_name;
24 $effect_edit = [
25 'data[test_parameter]' => 100,
26 ];
27
28 // Add style form.
29 $page = $this->getSession()->getPage();
30 $assert = $this->assertSession();
31 $this->drupalGet($admin_path . '/add');
32 $page->findField('label')->setValue($style_label);
33 $assert->waitForElementVisible('named', ['button', 'Edit'])->press();
34 $assert->waitForElementVisible('named', ['id_or_name', 'name'])->setValue($style_name);
35 $page->pressButton('Create new style');
36 $assert->pageTextContains("Style $style_label was created.");
37
38 // Add two Ajax-enabled test effects.
39 $this->drupalPostForm($style_path, ['new' => 'image_module_test_ajax'], t('Add'));
40 $this->drupalPostForm(NULL, $effect_edit, t('Add effect'));
41 $this->drupalPostForm($style_path, ['new' => 'image_module_test_ajax'], t('Add'));
42 $this->drupalPostForm(NULL, $effect_edit, t('Add effect'));
43
44 // Load the saved image style.
45 $style = ImageStyle::load($style_name);
46
47 // Edit back the effects.
48 foreach ($style->getEffects() as $uuid => $effect) {
49 $effect_path = $admin_path . '/manage/' . $style_name . '/effects/' . $uuid;
50 $this->drupalGet($effect_path);
51 $page->findField('data[test_parameter]')->setValue(111);
52 $ajax_value = $page->find('css', '#ajax-value')->getText();
53 $this->assertSame('Ajax value bar', $ajax_value);
54 $this->getSession()->getPage()->pressButton('Ajax refresh');
55 $this->assertTrue($page->waitFor(10, function ($page) {
56 $ajax_value = $page->find('css', '#ajax-value')->getText();
57 return preg_match('/^Ajax value [0-9.]+ [0-9.]+$/', $ajax_value);
58 }));
59 $page->pressButton('Update effect');
60 $assert->pageTextContains('The image effect was successfully applied.');
61 }
62 }
63
64 }