/** * @covers WPSEO_OpenGraph::publish_date */ public function test_publish_date() { // not on singular, should return false $this->assertFalse(self::$class_instance->publish_date()); // create post, without tags $post_id = $this->factory->post->create(); $this->go_to(get_permalink($post_id)); // test published_time tags output $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->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_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); }