X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fimage%2Fsrc%2FTests%2FImageStyleFlushTest.php;fp=web%2Fcore%2Fmodules%2Fimage%2Fsrc%2FTests%2FImageStyleFlushTest.php;h=0000000000000000000000000000000000000000;hp=4e8cd2c779e23cfba70b94d9472d93231263420a;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/image/src/Tests/ImageStyleFlushTest.php b/web/core/modules/image/src/Tests/ImageStyleFlushTest.php deleted file mode 100644 index 4e8cd2c77..000000000 --- a/web/core/modules/image/src/Tests/ImageStyleFlushTest.php +++ /dev/null @@ -1,110 +0,0 @@ -drupalGetTestFiles('image'); - $file = reset($files); - } - - // Make sure we have an image in our wrapper testing file directory. - $source_uri = file_unmanaged_copy($file->uri, $wrapper . '://'); - // Build the derivative image. - $derivative_uri = $style->buildUri($source_uri); - $derivative = $style->createDerivative($source_uri, $derivative_uri); - - return $derivative ? $derivative_uri : FALSE; - } - - /** - * Count the number of images currently created for a style in a wrapper. - */ - public function getImageCount($style, $wrapper) { - return count(file_scan_directory($wrapper . '://styles/' . $style->id(), '/.*/')); - } - - /** - * General test to flush a style. - */ - public function testFlush() { - - // Setup a style to be created and effects to add to it. - $style_name = strtolower($this->randomMachineName(10)); - $style_label = $this->randomString(); - $style_path = 'admin/config/media/image-styles/manage/' . $style_name; - $effect_edits = [ - 'image_resize' => [ - 'data[width]' => 100, - 'data[height]' => 101, - ], - 'image_scale' => [ - 'data[width]' => 110, - 'data[height]' => 111, - 'data[upscale]' => 1, - ], - ]; - - // Add style form. - $edit = [ - 'name' => $style_name, - 'label' => $style_label, - ]; - $this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style')); - - // Add each sample effect to the style. - foreach ($effect_edits as $effect => $edit) { - // Add the effect. - $this->drupalPostForm($style_path, ['new' => $effect], t('Add')); - if (!empty($edit)) { - $this->drupalPostForm(NULL, $edit, t('Add effect')); - } - } - - // Load the saved image style. - $style = ImageStyle::load($style_name); - - // Create an image for the 'public' wrapper. - $image_path = $this->createSampleImage($style, 'public'); - // Expecting to find 2 images, one is the sample.png image shown in - // image style preview. - $this->assertEqual($this->getImageCount($style, 'public'), 2, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path])); - - // Create an image for the 'private' wrapper. - $image_path = $this->createSampleImage($style, 'private'); - $this->assertEqual($this->getImageCount($style, 'private'), 1, format_string('Image style %style image %file successfully generated.', ['%style' => $style->label(), '%file' => $image_path])); - - // Remove the 'image_scale' effect and updates the style, which in turn - // forces an image style flush. - $style_path = 'admin/config/media/image-styles/manage/' . $style->id(); - $uuids = []; - foreach ($style->getEffects() as $uuid => $effect) { - $uuids[$effect->getPluginId()] = $uuid; - } - $this->drupalPostForm($style_path . '/effects/' . $uuids['image_scale'] . '/delete', [], t('Delete')); - $this->assertResponse(200); - $this->drupalPostForm($style_path, [], t('Update style')); - $this->assertResponse(200); - - // Post flush, expected 1 image in the 'public' wrapper (sample.png). - $this->assertEqual($this->getImageCount($style, 'public'), 1, format_string('Image style %style flushed correctly for %wrapper wrapper.', ['%style' => $style->label(), '%wrapper' => 'public'])); - - // Post flush, expected no image in the 'private' wrapper. - $this->assertEqual($this->getImageCount($style, 'private'), 0, format_string('Image style %style flushed correctly for %wrapper wrapper.', ['%style' => $style->label(), '%wrapper' => 'private'])); - } - -}