/** * @covers WPSEO_Frontend::flush_cache */ public function test_flush_cache() { $c = self::$class_instance; // should not run when output buffering is not turned on $this->assertFalse(self::$class_instance->flush_cache()); // turn on output buffering self::$class_instance->force_rewrite_output_buffer(); $content = '<!DOCTYPE><html><head><title>TITLETOBEREPLACED</title>' . self::$class_instance->debug_marker(false) . '</head><body>Some body content. Should remain unchanged.</body></html>'; // create expected output global $sep; $title = self::$class_instance->title('', $sep); $expected = preg_replace('/<title(.*)\\/title>/i', '', $content); $expected = str_replace($c->debug_marker(false), $c->debug_marker(false) . "\n" . '<title>' . $title . '</title>', $expected); echo $content; // run function $result = self::$class_instance->flush_cache(); // run assertions $this->expectOutput($expected, $result); $this->assertTrue($result); }