/** * @covers WPSEO_Frontend::robots_for_single_post */ public function test_robots_for_single_post() { // create and go to post $post_id = $this->factory->post->create(); $this->go_to(get_permalink($post_id)); $robots = array('index' => 'index', 'follow' => 'follow', 'other' => array()); $expected = $robots; // 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, $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, $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, $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, $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, $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, $post_id)); }