/** * @covers WPSEO_Frontend::get_title_from_options */ public function test_get_title_from_options() { // should return an empty string $this->assertEmpty(self::$class_instance->get_title_from_options('__not-existing-index')); // create and go to post $post_id = $this->factory->post->create(); $this->go_to(get_permalink($post_id)); $var_source = (array) get_queried_object(); $expected_title = wpseo_replace_vars('%%title%% %%sep%% %%sitename%%', $var_source); $this->assertEquals($expected_title, self::$class_instance->get_title_from_options('__not-existing-index', $var_source)); // test with an option that exists $index = 'title-post'; $expected_title = wpseo_replace_vars(self::$class_instance->options[$index], $var_source); $this->assertEquals($expected_title, self::$class_instance->get_title_from_options($index, $var_source)); }