Esempio n. 1
0
 /**
  * Test our template_include hook
  */
 function test_template_include()
 {
     $this->assertEquals('', wp_oembed_include_template(''));
     $GLOBALS['wp_query'] = new WP_Query();
     $GLOBALS['wp_query']->query_vars['embed'] = true;
     $this->assertEquals(dirname(plugin_dir_path(__FILE__)) . '/includes/template.php', wp_oembed_include_template(''));
 }
Esempio n. 2
0
 /**
  * Test our template_include hook
  */
 function test_template_include()
 {
     $this->assertEquals('', wp_oembed_include_template(''));
     $post_id = $this->factory->post->create();
     $this->go_to(get_permalink($post_id));
     $GLOBALS['wp_query']->query_vars['embed'] = true;
     $this->assertQueryTrue('is_single', 'is_singular');
     $this->assertEquals(dirname(plugin_dir_path(__FILE__)) . '/includes/template.php', wp_oembed_include_template(''));
 }
Esempio n. 3
0
 /**
  * Test oEmbed output for a non-existent post.
  */
 function test_oembed_output_404()
 {
     $this->go_to(home_url('/?p=123&embed=true'));
     $GLOBALS['wp_query']->query_vars['embed'] = true;
     $this->assertQueryTrue('is_404');
     $this->assertEquals(dirname(plugin_dir_path(__FILE__)) . '/includes/template.php', wp_oembed_include_template(''));
     ob_start();
     include dirname(plugin_dir_path(__FILE__)) . '/includes/template.php';
     $actual = ob_get_clean();
     $doc = new DOMDocument();
     $this->assertTrue($doc->loadHTML($actual));
     $this->assertTrue(false !== strpos($actual, 'Page not found'));
 }
Esempio n. 4
0
 /**
  * Test oEmbed output for a private post as an editor.
  */
 function test_oembed_output_private_post_with_permissions()
 {
     $user_id = $this->factory->user->create(array('role' => 'editor'));
     wp_set_current_user($user_id);
     $post_id = $this->factory->post->create(array('post_title' => 'Hello World', 'post_content' => 'Foo Bar', 'post_excerpt' => 'Bar Baz', 'post_status' => 'private', 'post_author' => $user_id));
     $this->go_to(get_post_embed_url($post_id));
     $this->assertQueryTrue('is_single', 'is_singular');
     $this->assertEquals(dirname(plugin_dir_path(__FILE__)) . '/includes/template.php', wp_oembed_include_template(''));
     ob_start();
     include dirname(plugin_dir_path(__FILE__)) . '/includes/template.php';
     $actual = ob_get_clean();
     $doc = new DOMDocument();
     $this->assertTrue($doc->loadHTML($actual));
     $this->assertTrue(false === strpos($actual, 'Page not found'));
     $this->assertTrue(false !== strpos($actual, 'Hello World'));
 }