Loading core/modules/image/tests/modules/image_module_test/src/Hook/ImageModuleTestHooks.php +7 −8 Changes for core/modules/image/tests/modules/image_module_test/src/Hook/ImageModuleTestHooks.php: 7 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -17,16 +17,16 @@ class ImageModuleTestHooks { */ #[Hook('image_effect_info_alter')] public function imageEffectInfoAlter(&$effects): void { $state = \Drupal::state(); // The 'image_module_test.counter' state variable value is set and accessed $key_value = \Drupal::keyValue('image'); // The 'image_module_test.counter' key/value entry is set and accessed // from the ImageEffectsTest::testImageEffectsCaching() test and used to // signal if the image effect plugin definitions were computed or were // retrieved from the cache. // @see \Drupal\Tests\image\Kernel\ImageEffectsTest::testImageEffectsCaching() $counter = $state->get('image_module_test.counter'); $counter = $key_value->get('image_module_test.counter'); // Increase the test counter, signaling that image effects were processed, // rather than being served from the cache. $state->set('image_module_test.counter', ++$counter); $key_value->set('image_module_test.counter', ++$counter); } /** Loading @@ -44,8 +44,7 @@ public function imageStylePresave(ImageStyleInterface $style): void { */ #[Hook('image_style_flush')] public function imageStyleFlush($style, $path = NULL): void { $state = \Drupal::state(); $state->set('image_module_test_image_style_flush.called', $path); \Drupal::keyValue('image')->set('image_module_test_image_style_flush.called', $path); } /** Loading @@ -58,9 +57,9 @@ public function fileDownload($uri): array|int { return ['X-Image-Owned-By' => 'image_module_test']; } // When we have custom stream wrapper is enabled, do the validation based // on state variable to allow it. // on a key/value entry to allow it. if (str_starts_with($uri, 'image-test-dummy://')) { if (\Drupal::state()->get('image_module_test.allow_image_test_dummy', FALSE)) { if (\Drupal::keyValue('image')->get('image_module_test.allow_image_test_dummy', FALSE)) { return ['X-Allowed-By' => 'image_module_test']; } return -1; Loading core/modules/image/tests/src/Functional/ImageStyleDownloadAccessControlTest.php +2 −2 Changes for core/modules/image/tests/src/Functional/ImageStyleDownloadAccessControlTest.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -134,9 +134,9 @@ public function testNonPublicSchemeInvokesFileDownloadHook(): void { $this->drupalGet($url); $this->assertSession()->statusCodeEquals(403); // Set the state variable so that file download hook in image_module_test // Set the key/value entry so that file download hook in image_module_test // allows the access of the file. \Drupal::state()->set('image_module_test.allow_image_test_dummy', TRUE); \Drupal::keyValue('image')->set('image_module_test.allow_image_test_dummy', TRUE); $this->drupalGet($url); $this->assertSession()->statusCodeEquals(200); } Loading core/modules/image/tests/src/Functional/ImageStyleFlushTest.php +4 −4 Changes for core/modules/image/tests/src/Functional/ImageStyleFlushTest.php: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -127,12 +127,12 @@ public function testFlush(): void { // Post flush, expected no image in the 'private' wrapper. $this->assertEquals(0, $this->getImageCount($style, 'private'), "Image style {$style->label()} flushed correctly for private wrapper."); $state = \Drupal::state(); $state->set('image_module_test_image_style_flush.called', FALSE); $key_value = \Drupal::keyValue('image'); $key_value->set('image_module_test_image_style_flush.called', FALSE); $style->flush(); $this->assertNull($state->get('image_module_test_image_style_flush.called')); $this->assertNull($key_value->get('image_module_test_image_style_flush.called')); $style->flush('/made/up/path'); $this->assertSame('/made/up/path', $state->get('image_module_test_image_style_flush.called')); $this->assertSame('/made/up/path', $key_value->get('image_module_test_image_style_flush.called')); } } core/modules/image/tests/src/Kernel/ImageEffectsTest.php +6 −6 Changes for core/modules/image/tests/src/Kernel/ImageEffectsTest.php: 6 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -226,22 +226,22 @@ public function testRotateEffect(): void { * Tests image effect caching. */ public function testImageEffectsCaching(): void { $state = $this->container->get('state'); $key_value = $this->container->get('keyvalue')->get('image'); // The 'image_module_test.counter' state variable value is incremented in // The 'image_module_test.counter' key/value entry is incremented in // image_module_test_image_effect_info_alter() every time the image effect // plugin definitions are recomputed. // @see image_module_test_image_effect_info_alter() $state->set('image_module_test.counter', 0); $key_value->set('image_module_test.counter', 0); // First call should grab a fresh copy of the data. $effects = $this->imageEffectPluginManager->getDefinitions(); $this->assertEquals(1, $state->get('image_module_test.counter')); $this->assertEquals(1, $key_value->get('image_module_test.counter')); // Second call should come from cache. $state->set('image_module_test.counter', 0); $key_value->set('image_module_test.counter', 0); $cached_effects = $this->imageEffectPluginManager->getDefinitions(); $this->assertEquals(0, $state->get('image_module_test.counter')); $this->assertEquals(0, $key_value->get('image_module_test.counter')); // Check that cached effects are the same as the processed. $this->assertSame($effects, $cached_effects); Loading Loading
core/modules/image/tests/modules/image_module_test/src/Hook/ImageModuleTestHooks.php +7 −8 Changes for core/modules/image/tests/modules/image_module_test/src/Hook/ImageModuleTestHooks.php: 7 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -17,16 +17,16 @@ class ImageModuleTestHooks { */ #[Hook('image_effect_info_alter')] public function imageEffectInfoAlter(&$effects): void { $state = \Drupal::state(); // The 'image_module_test.counter' state variable value is set and accessed $key_value = \Drupal::keyValue('image'); // The 'image_module_test.counter' key/value entry is set and accessed // from the ImageEffectsTest::testImageEffectsCaching() test and used to // signal if the image effect plugin definitions were computed or were // retrieved from the cache. // @see \Drupal\Tests\image\Kernel\ImageEffectsTest::testImageEffectsCaching() $counter = $state->get('image_module_test.counter'); $counter = $key_value->get('image_module_test.counter'); // Increase the test counter, signaling that image effects were processed, // rather than being served from the cache. $state->set('image_module_test.counter', ++$counter); $key_value->set('image_module_test.counter', ++$counter); } /** Loading @@ -44,8 +44,7 @@ public function imageStylePresave(ImageStyleInterface $style): void { */ #[Hook('image_style_flush')] public function imageStyleFlush($style, $path = NULL): void { $state = \Drupal::state(); $state->set('image_module_test_image_style_flush.called', $path); \Drupal::keyValue('image')->set('image_module_test_image_style_flush.called', $path); } /** Loading @@ -58,9 +57,9 @@ public function fileDownload($uri): array|int { return ['X-Image-Owned-By' => 'image_module_test']; } // When we have custom stream wrapper is enabled, do the validation based // on state variable to allow it. // on a key/value entry to allow it. if (str_starts_with($uri, 'image-test-dummy://')) { if (\Drupal::state()->get('image_module_test.allow_image_test_dummy', FALSE)) { if (\Drupal::keyValue('image')->get('image_module_test.allow_image_test_dummy', FALSE)) { return ['X-Allowed-By' => 'image_module_test']; } return -1; Loading
core/modules/image/tests/src/Functional/ImageStyleDownloadAccessControlTest.php +2 −2 Changes for core/modules/image/tests/src/Functional/ImageStyleDownloadAccessControlTest.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -134,9 +134,9 @@ public function testNonPublicSchemeInvokesFileDownloadHook(): void { $this->drupalGet($url); $this->assertSession()->statusCodeEquals(403); // Set the state variable so that file download hook in image_module_test // Set the key/value entry so that file download hook in image_module_test // allows the access of the file. \Drupal::state()->set('image_module_test.allow_image_test_dummy', TRUE); \Drupal::keyValue('image')->set('image_module_test.allow_image_test_dummy', TRUE); $this->drupalGet($url); $this->assertSession()->statusCodeEquals(200); } Loading
core/modules/image/tests/src/Functional/ImageStyleFlushTest.php +4 −4 Changes for core/modules/image/tests/src/Functional/ImageStyleFlushTest.php: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -127,12 +127,12 @@ public function testFlush(): void { // Post flush, expected no image in the 'private' wrapper. $this->assertEquals(0, $this->getImageCount($style, 'private'), "Image style {$style->label()} flushed correctly for private wrapper."); $state = \Drupal::state(); $state->set('image_module_test_image_style_flush.called', FALSE); $key_value = \Drupal::keyValue('image'); $key_value->set('image_module_test_image_style_flush.called', FALSE); $style->flush(); $this->assertNull($state->get('image_module_test_image_style_flush.called')); $this->assertNull($key_value->get('image_module_test_image_style_flush.called')); $style->flush('/made/up/path'); $this->assertSame('/made/up/path', $state->get('image_module_test_image_style_flush.called')); $this->assertSame('/made/up/path', $key_value->get('image_module_test_image_style_flush.called')); } }
core/modules/image/tests/src/Kernel/ImageEffectsTest.php +6 −6 Changes for core/modules/image/tests/src/Kernel/ImageEffectsTest.php: 6 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -226,22 +226,22 @@ public function testRotateEffect(): void { * Tests image effect caching. */ public function testImageEffectsCaching(): void { $state = $this->container->get('state'); $key_value = $this->container->get('keyvalue')->get('image'); // The 'image_module_test.counter' state variable value is incremented in // The 'image_module_test.counter' key/value entry is incremented in // image_module_test_image_effect_info_alter() every time the image effect // plugin definitions are recomputed. // @see image_module_test_image_effect_info_alter() $state->set('image_module_test.counter', 0); $key_value->set('image_module_test.counter', 0); // First call should grab a fresh copy of the data. $effects = $this->imageEffectPluginManager->getDefinitions(); $this->assertEquals(1, $state->get('image_module_test.counter')); $this->assertEquals(1, $key_value->get('image_module_test.counter')); // Second call should come from cache. $state->set('image_module_test.counter', 0); $key_value->set('image_module_test.counter', 0); $cached_effects = $this->imageEffectPluginManager->getDefinitions(); $this->assertEquals(0, $state->get('image_module_test.counter')); $this->assertEquals(0, $key_value->get('image_module_test.counter')); // Check that cached effects are the same as the processed. $this->assertSame($effects, $cached_effects); Loading