Skip to content
Snippets Groups Projects
Verified Commit 7546eb2a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3439981 by fago, ericgsmith, petar_basic, acbramley: Uploading a file...

Issue #3439981 by fago, ericgsmith, petar_basic, acbramley: Uploading a file to media library flushes theme registry

(cherry picked from commit 7b24d548)
parent 557022fc
No related branches found
No related tags found
23 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9944Issue #3483353: Consider making the createCopy config action optionally fail...,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8597Draft: Issue #3442259 by catch, quietone, dww: Reduce time of Migrate Upgrade tests...,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!8325Update file Sort.php,!8095Expose document root on install,!7930Resolve #3427374 "Taxonomytid viewsargumentdefault plugin",!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #154893 passed with warnings
Pipeline: drupal

#154897

    ......@@ -298,10 +298,12 @@ public function flush($path = NULL) {
    $module_handler = \Drupal::moduleHandler();
    $module_handler->invokeAll('image_style_flush', [$this, $path]);
    // Clear caches so that formatters may be added for this style.
    \Drupal::service('theme.registry')->reset();
    Cache::invalidateTags($this->getCacheTagsToInvalidate());
    // Clear caches when the complete image style is flushed,
    // so that field formatters may be added for this style.
    if (!isset($path)) {
    \Drupal::service('theme.registry')->reset();
    Cache::invalidateTags($this->getCacheTagsToInvalidate());
    }
    return $this;
    }
    ......
    ......@@ -5,6 +5,7 @@
    namespace Drupal\Tests\image\Unit;
    use Drupal\Component\Utility\Crypt;
    use Drupal\Core\DependencyInjection\ContainerBuilder;
    use Drupal\Tests\UnitTestCase;
    /**
    ......@@ -198,6 +199,62 @@ public function testGetPathToken() {
    $this->assertEquals(substr(Crypt::hmacBase64($image_style->id() . ':' . 'public://test.jpeg', $private_key . $hash_salt), 0, 8), $image_style->getPathToken('public://test.jpeg'));
    }
    /**
    * @covers ::flush
    */
    public function testFlush() {
    $cache_tag_invalidator = $this->createMock('\Drupal\Core\Cache\CacheTagsInvalidator');
    $file_system = $this->createMock('\Drupal\Core\File\FileSystemInterface');
    $module_handler = $this->createMock('\Drupal\Core\Extension\ModuleHandlerInterface');
    $stream_wrapper_manager = $this->createMock('\Drupal\Core\StreamWrapper\StreamWrapperManagerInterface');
    $stream_wrapper_manager->expects($this->any())
    ->method('getWrappers')
    ->will($this->returnValue([]));
    $theme_registry = $this->createMock('\Drupal\Core\Theme\Registry');
    $container = new ContainerBuilder();
    $container->set('cache_tags.invalidator', $cache_tag_invalidator);
    $container->set('file_system', $file_system);
    $container->set('module_handler', $module_handler);
    $container->set('stream_wrapper_manager', $stream_wrapper_manager);
    $container->set('theme.registry', $theme_registry);
    \Drupal::setContainer($container);
    $image_effect_id = $this->randomMachineName();
    $image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase');
    $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['buildUri', 'getCacheTagsToInvalidate']);
    $image_style->expects($this->any())
    ->method('buildUri')
    ->willReturn('test.jpg');
    $image_style->expects($this->any())
    ->method('getCacheTagsToInvalidate')
    ->willReturn([]);
    // Assert the theme registry is reset.
    $theme_registry
    ->expects($this->once())
    ->method('reset');
    // Assert the cache tags are invalidated.
    $cache_tag_invalidator
    ->expects($this->once())
    ->method('invalidateTags');
    $image_style->flush();
    // Assert the theme registry is not reset a path is flushed.
    $theme_registry
    ->expects($this->never())
    ->method('reset');
    // Assert the cache tags are not reset a path is flushed.
    $cache_tag_invalidator
    ->expects($this->never())
    ->method('invalidateTags');
    $image_style->flush('test.jpg');
    }
    /**
    * Mock function for ImageStyle::fileDefaultScheme().
    */
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment