Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed May 30, 2014
1 parent d98a4e8 commit 8f2ebcd
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 103 deletions.
6 changes: 3 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

// disable xdebug backtrace
if( function_exists( 'xdebug_disable' ) ) {
if ( function_exists( 'xdebug_disable' ) ) {
xdebug_disable();
}

echo "Welcome to the WordPress SEO Test Suite" . PHP_EOL;
echo "Version: 1.0" . PHP_EOL . PHP_EOL;
echo 'Welcome to the WordPress SEO Test Suite' . PHP_EOL;
echo 'Version: 1.0' . PHP_EOL . PHP_EOL;

// load some helpful functions
require_once getenv( 'WP_TESTS_DIR' ) . 'tests/phpunit/includes/functions.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/test-class-googleplus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function test_class_is_tested() {
public function test_description() {

self::$class_instance->description();
$this->expectOutput('');
$this->expectOutput( '' );

// create and go to post
$post_id = $this->factory->post->create();
Expand Down
42 changes: 21 additions & 21 deletions tests/test-class-opengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function test_facebook_filter() {
* @covers WPSEO_OpenGraph::add_opengraph_namespace
*/
public function test_add_opengraph_namespace() {
$c = self::$class_instance;
$c = self::$class_instance;
$expected = ' prefix="og: http://ogp.me/ns#' . ( ( $c->options['fbadminapp'] != 0 || ( is_array( $c->options['fb_admins'] ) && $c->options['fb_admins'] !== array() ) ) ? ' fb: http://ogp.me/ns/fb#' : '' ) . '"';
$this->assertEquals( $c->add_opengraph_namespace( '' ), $expected );
}
Expand All @@ -98,14 +98,14 @@ public function test_article_author_facebook() {

// create post with author
$author_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$post_id = $this->factory->post->create( array( 'post_author' => $author_id ));
$post_id = $this->factory->post->create( array( 'post_author' => $author_id ) );
$this->go_to( get_permalink( $post_id ) );

// on post page but facebook meta not set.
$this->assertFalse( self::$class_instance->article_author_facebook() );

// add facebook meta to post author
$post = get_post( $post_id );
$post = get_post( $post_id );
$author = $post->post_author;
add_user_meta( $author, 'facebook', 'facebook_author' );

Expand Down Expand Up @@ -148,7 +148,7 @@ public function test_og_title() {
$this->go_to( get_permalink( $post_id ) );

$expected_title = self::$class_instance->title( '' );
$expected_html = '<meta property="og:title" content="'.$expected_title.'" />' . "\n";
$expected_html = '<meta property="og:title" content="' . $expected_title . '" />' . "\n";

$this->assertTrue( self::$class_instance->og_title() );
$this->expectOutput( $expected_html );
Expand All @@ -164,7 +164,7 @@ public function test_url() {

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

Expand All @@ -176,19 +176,19 @@ public function test_url() {
* @covers WPSEO_OpenGraph::locale
*/
public function test_locale() {
global $locale;
global $locale;

$this->assertEquals( 'en_US', self::$class_instance->locale( false ) );
$this->assertEquals( 'en_US', self::$class_instance->locale( false ) );

$locale = 'ca';
$this->assertEquals( 'ca_ES', self::$class_instance->locale( false ) );
$locale = 'ca';
$this->assertEquals( 'ca_ES', self::$class_instance->locale( false ) );

$locale = 'nl';
$this->assertEquals( 'nl_NL', self::$class_instance->locale( false ) );
$locale = 'nl';
$this->assertEquals( 'nl_NL', self::$class_instance->locale( false ) );

$locale = 'nl_NL';
$this->assertEquals( 'nl_NL', self::$class_instance->locale( true ) );
$this->expectOutput( '<meta property="og:locale" content="nl_NL" />' . "\n" );
$locale = 'nl_NL';
$this->assertEquals( 'nl_NL', self::$class_instance->locale( true ) );
$this->expectOutput( '<meta property="og:locale" content="nl_NL" />' . "\n" );
}

/**
Expand All @@ -197,7 +197,7 @@ public function test_locale() {
public function test_type() {
$this->assertEquals( 'website', self::$class_instance->type( false ) );

$category_id = wp_create_category( "WordPress SEO" );
$category_id = wp_create_category( 'WordPress SEO' );
$this->go_to( get_category_link( $category_id ) );
$this->assertEquals( 'object', self::$class_instance->type( false ) );

Expand All @@ -213,9 +213,9 @@ public function test_type() {
public function test_image_output() {
$this->assertFalse( self::$class_instance->image_output( '' ) );

$this->assertFalse( self::$class_instance->image_output('malformed-relative-url') );
$this->assertFalse( self::$class_instance->image_output( 'malformed-relative-url' ) );

$img_url = home_url('absolute-image.jpg');
$img_url = home_url( 'absolute-image.jpg' );

// test with absolute image
$this->assertTrue( self::$class_instance->image_output( $img_url ) );
Expand Down Expand Up @@ -286,7 +286,7 @@ public function test_category() {

// Create post in category, go to post.
$category_id = wp_create_category( 'Category Name' );
$post_id = $this->factory->post->create( array( 'post_category' => array( $category_id ) ) );
$post_id = $this->factory->post->create( array( 'post_category' => array( $category_id ) ) );
$this->go_to( get_permalink( $post_id ) );

$this->assertTrue( self::$class_instance->category() );
Expand All @@ -306,19 +306,19 @@ public function test_publish_date() {
$this->go_to( get_permalink( $post_id ) );

// test published_time tags output
$published_time = get_the_date( 'c' );
$published_time = get_the_date( 'c' );
$published_output = '<meta property="article:published_time" content="' . $published_time . '" />' . "\n";
$this->assertTrue( self::$class_instance->publish_date() );
$this->expectOutput( $published_output );

// modify post time
global $post;
$post = get_post( $post_id );
$post = get_post( $post_id );
$post->post_modified = gmdate( 'Y-m-d H:i:s', time() + 1 );
$post->post_modified_gmt = gmdate( 'Y-m-d H:i:s', ( time() + 1 + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );

// test modified tags output
$modified_time = get_the_modified_date( 'c' );
$modified_time = get_the_modified_date( 'c' );
$modified_output = '<meta property="article:modified_time" content="' . $modified_time . '" />' . "\n" . '<meta property="og:updated_time" content="' . $modified_time . '" />' . "\n";
$this->assertTrue( self::$class_instance->publish_date() );
$this->expectOutput( $published_output . $modified_output );
Expand Down
12 changes: 6 additions & 6 deletions tests/test-class-rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public function test_no_category_base() {
* @covers WPSEO_Rewrite::query_vars
*/
public function test_query_vars() {
$this->assertEquals( array( ), self::$class_instance->query_vars( array( ) ) );
$this->assertEquals( array(), self::$class_instance->query_vars( array() ) );

$options = WPSEO_Options::get_all();
$options['stripcategorybase'] = true;
update_option( WPSEO_Option_Permalinks::get_instance()->option_name, $options );
$this->assertEquals( array( 'wpseo_category_redirect' ), self::$class_instance->query_vars( array( ) ) );
$this->assertEquals( array( 'wpseo_category_redirect' ), self::$class_instance->query_vars( array() ) );
}

/**
Expand All @@ -87,22 +87,22 @@ public function test_category_rewrite_rules() {

$categories = get_categories( array( 'hide_empty' => false ) );

if( false == is_multisite() ) {
if ( false == is_multisite() ) {
$expected = array(
'(uncategorized)/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
'(uncategorized)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
'(uncategorized)/?$' => 'index.php?category_name=$matches[1]',
'$' => 'index.php?wpseo_category_redirect=$matches[1]'
'$' => 'index.php?wpseo_category_redirect=$matches[1]',
);
} else {
$expected = array(
'blog/(uncategorized)/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
'blog/(uncategorized)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
'blog/(uncategorized)/?$' => 'index.php?category_name=$matches[1]'
'blog/(uncategorized)/?$' => 'index.php?category_name=$matches[1]',
);

global $wp_rewrite;
$old_base = trim( str_replace( '%category%', '(.+)', $wp_rewrite->get_category_permastruct() ), '/' );
$old_base = trim( str_replace( '%category%', '(.+)', $wp_rewrite->get_category_permastruct() ), '/' );

$expected[ $old_base . '$' ] = 'index.php?wpseo_category_redirect=$matches[1]';
}
Expand Down
12 changes: 6 additions & 6 deletions tests/test-class-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public function test_type() {

// test invalid option, should default to summary
self::$class_instance->options['twitter_card_type'] = 'something_invalid';
$expected = $this->metatag( 'card', 'summary' );
$expected = $this->metatag( 'card', 'summary' );

self::$class_instance->type();
$this->expectOutput( $expected );

// test valid option
self::$class_instance->options['twitter_card_type'] = 'photo';
$expected = $this->metatag( 'card', 'photo' );
$expected = $this->metatag( 'card', 'photo' );

self::$class_instance->type();
$this->expectOutput( $expected );
Expand All @@ -51,7 +51,7 @@ public function test_type() {
public function test_site_twitter() {
// test valid option
self::$class_instance->options['twitter_site'] = 'yoast';
$expected = $this->metatag( 'site', '@yoast' );
$expected = $this->metatag( 'site', '@yoast' );

self::$class_instance->site_twitter();
$this->expectOutput( $expected );
Expand All @@ -62,7 +62,7 @@ public function test_site_twitter() {
*/
public function test_site_domain() {
// test valid option
$expected = $this->metatag( 'domain', get_bloginfo('name') );
$expected = $this->metatag( 'domain', get_bloginfo( 'name' ) );

self::$class_instance->site_domain();
$this->expectOutput( $expected );
Expand All @@ -73,7 +73,7 @@ public function test_site_domain() {
*/
public function test_author_twitter() {

$name = 'yoast';
$name = 'yoast';
$expected = $this->metatag( 'creator', '@' . $name );

// test option
Expand Down Expand Up @@ -163,7 +163,7 @@ public function test_image_output() {

// test image url
$expected = $this->metatag( 'image:src', $image_url );
$result = self::$class_instance->image_output( $image_url );
$result = self::$class_instance->image_output( $image_url );
$this->assertTrue( $result );
$this->expectOutput( $expected );

Expand Down
4 changes: 2 additions & 2 deletions tests/test-class-wpseo-breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public function test_breadcrumb() {
$this->assertEmpty( $output );

// test before argument
$output = WPSEO_Breadcrumbs::breadcrumb( 'before', '', false );
$output = WPSEO_Breadcrumbs::breadcrumb( 'before', '', false );
$expected = 'before';
$this->assertStringStartsWith( $expected, $output );

// test after argument
$output = WPSEO_Breadcrumbs::breadcrumb( '', 'after', false );
$output = WPSEO_Breadcrumbs::breadcrumb( '', 'after', false );
$expected = 'after';
$this->assertStringEndsWith( $expected, $output );

Expand Down
Loading

0 comments on commit 8f2ebcd

Please sign in to comment.