X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fimage%2Ftests%2Fsrc%2FFunctionalJavascript%2FImageAdminStylesTest.php;fp=web%2Fcore%2Fmodules%2Fimage%2Ftests%2Fsrc%2FFunctionalJavascript%2FImageAdminStylesTest.php;h=e573c89a885e5e6000cc88be3d66b7cf8d21be58;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/image/tests/src/FunctionalJavascript/ImageAdminStylesTest.php b/web/core/modules/image/tests/src/FunctionalJavascript/ImageAdminStylesTest.php new file mode 100644 index 000000000..e573c89a8 --- /dev/null +++ b/web/core/modules/image/tests/src/FunctionalJavascript/ImageAdminStylesTest.php @@ -0,0 +1,64 @@ +randomMachineName(10)); + $style_label = $this->randomString(); + $style_path = $admin_path . '/manage/' . $style_name; + $effect_edit = [ + 'data[test_parameter]' => 100, + ]; + + // Add style form. + $page = $this->getSession()->getPage(); + $assert = $this->assertSession(); + $this->drupalGet($admin_path . '/add'); + $page->findField('label')->setValue($style_label); + $assert->waitForElementVisible('named', ['button', 'Edit'])->press(); + $assert->waitForElementVisible('named', ['id_or_name', 'name'])->setValue($style_name); + $page->pressButton('Create new style'); + $assert->pageTextContains("Style $style_label was created."); + + // Add two Ajax-enabled test effects. + $this->drupalPostForm($style_path, ['new' => 'image_module_test_ajax'], t('Add')); + $this->drupalPostForm(NULL, $effect_edit, t('Add effect')); + $this->drupalPostForm($style_path, ['new' => 'image_module_test_ajax'], t('Add')); + $this->drupalPostForm(NULL, $effect_edit, t('Add effect')); + + // Load the saved image style. + $style = ImageStyle::load($style_name); + + // Edit back the effects. + foreach ($style->getEffects() as $uuid => $effect) { + $effect_path = $admin_path . '/manage/' . $style_name . '/effects/' . $uuid; + $this->drupalGet($effect_path); + $page->findField('data[test_parameter]')->setValue(111); + $ajax_value = $page->find('css', '#ajax-value')->getText(); + $this->assertSame('Ajax value bar', $ajax_value); + $this->getSession()->getPage()->pressButton('Ajax refresh'); + $this->assertTrue($page->waitFor(10, function ($page) { + $ajax_value = $page->find('css', '#ajax-value')->getText(); + return preg_match('/^Ajax value [0-9.]+ [0-9.]+$/', $ajax_value); + })); + $page->pressButton('Update effect'); + $assert->pageTextContains('The image effect was successfully applied.'); + } + } + +}