/** * @covers WPSEO_Frontend::author */ public function test_author() { $this->assertFalse(self::$class_instance->author()); // create and go to post $author_id = $this->factory->user->create(array('role' => 'administrator')); $post_id = $this->factory->post->create(array('post_author' => $author_id)); $this->go_to(get_permalink($post_id)); // post type default not set $this->assertFalse(self::$class_instance->author()); // post type default set but author meta not set self::$class_instance->options['noauthorship-post'] = false; $this->assertFalse(self::$class_instance->author()); // post author meta, but not set WPSEO_Meta::set_value('authorship', 'always', $post_id); $this->assertFalse(self::$class_instance->author()); // set author meta $gplus = 'https://plus.google.com/+JoostdeValk'; add_user_meta($author_id, 'googleplus', $gplus); $expected = '<link rel="author" href="' . esc_url($gplus) . '"/>' . "\n"; // post author meta and user meta set $this->assertTrue(self::$class_instance->author()); $this->expectOutput($expected); // post type default and user meta set WPSEO_Meta::set_value('authorship', '-', $post_id); $this->assertTrue(self::$class_instance->author()); $this->expectOutput($expected); }