Skip to content

Commit

Permalink
Fix some errors in the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed May 30, 2014
1 parent de1c91c commit d98a4e8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/framework/class-wpseo-unit-test-case.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function unset_post( $key ) {
* Fake a request to the WP front page
*/
protected function go_to_home() {
$this->go_to( home_url() );
$this->go_to( home_url( '/' ) );
}

/**
Expand Down
17 changes: 9 additions & 8 deletions tests/test-class-wpseo-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,31 +396,31 @@ public function test_robots_for_single_post() {
// test noindex
WPSEO_Meta::set_value( 'meta-robots-noindex', '1', $post_id );
$expected['index'] = 'noindex';
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $this->post_id ) );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $post_id ) );

// test nofollow
WPSEO_Meta::set_value( 'meta-robots-nofollow', 1, $post_id );
$expected['follow'] = 'nofollow';
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $this->post_id ) );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $post_id ) );

// test noodp with default meta-robots-adv
self::$class_instance->options['noodp'] = true;
$expected['other'] = array( 'noodp' );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $this->post_id ) );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $post_id ) );

// test noydir with default meta-robots-adv
self::$class_instance->options['noydir'] = true;
$expected['other'] = array( 'noodp', 'noydir' );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $this->post_id ) );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $post_id ) );

// test meta-robots adv noodp and nosnippet
WPSEO_Meta::set_value( 'meta-robots-adv', 'noodp,nosnippet', $post_id );
$expected['other'] = array( 'noodp', 'nosnippet' );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $this->post_id ) );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $post_id ) );

WPSEO_Meta::set_value( 'meta-robots-noindex', '2', $post_id );
$expected['index'] = 'index';
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $this->post_id ) );
$this->assertEquals( $expected, self::$class_instance->robots_for_single_post( $robots, $post_id ) );
}

/**
Expand Down Expand Up @@ -715,7 +715,7 @@ public function test_clean_permalink() {
$c = self::$class_instance;

// test requests to the robots file
$this->go_to( add_query_arg( array( 'robots' => 1 ), home_url() ) );
$this->go_to( add_query_arg( array( 'robots' => 1 ), home_url( '/' ) ) );
$this->assertFalse( $c->clean_permalink() );

// test requests to the sitemap
Expand All @@ -735,13 +735,14 @@ public function test_rss_replace_vars() {

// create and go to post
$post_id = $this->factory->post->create();
$post = $this->factory->post->get_object_by_id( $post_id );
$this->go_to( get_permalink( $post_id ) );

// input
$text = 'Some text with some RSS Variables. Written by %%AUTHORLINK%%, the post is %%POSTLINK%% on the blog %%BLOGLINK%%. %%BLOGDESCLINK%%.';

// generate expected output
$author_link = '<a rel="nofollow" rel="author" href="' . esc_url( get_author_posts_url( $this->post->post_author ) ) . '">' . get_the_author() . '</a>';
$author_link = '<a rel="nofollow" rel="author" href="' . esc_url( get_author_posts_url( $post->post_author ) ) . '">' . get_the_author() . '</a>';
$post_link = '<a rel="nofollow" href="' . esc_url( get_permalink() ) . '">' . get_the_title() . '</a>';
$blog_link = '<a rel="nofollow" href="' . esc_url( get_bloginfo( 'url' ) ) . '">' . get_bloginfo( 'name' ) . '</a>';
$blog_desc_link = '<a rel="nofollow" href="' . esc_url( get_bloginfo( 'url' ) ) . '">' . get_bloginfo( 'name' ) . ' - ' . get_bloginfo( 'description' ) . '</a>';
Expand Down
10 changes: 5 additions & 5 deletions tests/test-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function test_wp_head() {
public function test_wp_head_options() {
$wp_head = $this->wp_filter['wp_head'];

$this->assertEquals( $this->options['hide-rsdlink'], ! array_key_exists( 'rsd_link', $wp_head[10] ) );
$this->assertEquals( $this->options['hide-wlwmanifest'], ! array_key_exists( 'wlwmanifest_link', $wp_head[10] ) );
$this->assertEquals( $this->options['hide-shortlink'], ! array_key_exists( 'wp_shortlink_wp_head', $wp_head[10] ) );
$this->assertEquals( $this->options['hide-feedlinks'], ! array_key_exists( 'feed_links', $wp_head[2] ) );
$this->assertEquals( $this->options['hide-feedlinks'], ! array_key_exists( 'feed_links_extra', $wp_head[3] ) );
$this->assertEquals( get_option( 'hide-rsdlink' ), ! array_key_exists( 'rsd_link', $wp_head[10] ) );
$this->assertEquals( get_option( 'hide-wlwmanifest' ), ! array_key_exists( 'wlwmanifest_link', $wp_head[10] ) );
$this->assertEquals( get_option( 'hide-shortlink' ), ! array_key_exists( 'wp_shortlink_wp_head', $wp_head[10] ) );
$this->assertEquals( get_option( 'hide-feedlinks' ), ! array_key_exists( 'feed_links', $wp_head[2] ) );
$this->assertEquals( get_option( 'hide-feedlinks' ), ! array_key_exists( 'feed_links_extra', $wp_head[3] ) );
}

}
2 changes: 1 addition & 1 deletion tests/test-wpseo-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function test_wpseo_replace_vars() {
);

// get post
$post = get_post( $post_id );
$post = $this->factory->post->get_object_by_id( $post_id );

$input = '%%title%% %%excerpt%% %%date%% %%name%%';
$expected = "Post_Title Post_Excerpt ". mysql2date( get_option( 'date_format' ), $post->post_date , true ) ." User_Nicename";
Expand Down

0 comments on commit d98a4e8

Please sign in to comment.