Some content with an [embed url="' . $url . '" thumbnail="https://example.com/mythumb.jpg" ' . 'class="leftAlone ss-htmleditorfield-file embed" width="480" height="270"]' . $url . '[/embed]
'; $embedHtml = ''; $parser = ShortcodeParser::get('default'); // use reflection to access private methods $provider = new EmbedShortcodeProvider(); $reflector = new \ReflectionClass(EmbedShortcodeProvider::class); $method = $reflector->getMethod('getCache'); $method->setAccessible(true); $cache = $method->invokeArgs($provider, []); $method = $reflector->getMethod('deriveCacheKey'); $method->setAccessible(true); $key = $method->invokeArgs($provider, [$url]); // assertions $this->assertEquals('embed-shortcode-httpwwwtest-servicecomabc123', $key); $cache->set($key, $embedHtml); $this->assertTrue($cache->has($key)); EmbedShortcodeProvider::flushCachedShortcodes($parser, $content); $this->assertFalse($cache->has($key)); } }