public function test_cache_oembed_for_post() { $url = 'https://example.com/'; $expected = '<b>Embedded content</b>'; $key_suffix = md5($url . serialize(wp_embed_defaults($url))); $cachekey = '_oembed_' . $key_suffix; $cachekey_time = '_oembed_time_' . $key_suffix; $post_id = $this->factory()->post->create(array('post_content' => 'https://example.com/')); add_filter('pre_oembed_result', array($this, '_pre_oembed_result_callback')); $this->wp_embed->cache_oembed($post_id); remove_filter('pre_oembed_result', array($this, '_pre_oembed_result_callback')); $this->assertSame($post_id, $this->wp_embed->post_ID); $this->assertEquals($expected, get_post_meta($post_id, $cachekey, true)); $this->assertNotEmpty(get_post_meta($post_id, $cachekey_time, true)); }