/** * @dataProvider getMessages * * @param string $method * @param bool $append * @param string|array $messages1 * @param string|array $messages2 * @param bool $newline * @param int $type */ public function testWrite($method, $append, $messages1, $messages2, $newline, $type) { $export = new Export($this->output, $this->file, $append); if ($method == 'write') { $this->output->expects($this->at(0))->method($method)->with($messages1, $newline, $type); $this->output->expects($this->at(1))->method($method)->with($messages2, $newline, $type); call_user_func([$export, $method], $messages1, $newline, $type); call_user_func([$export, $method], $messages2, $newline, $type); } else { $newline = true; $this->output->expects($this->at(0))->method($method)->with($messages1, $type); $this->output->expects($this->at(1))->method($method)->with($messages2, $type); call_user_func([$export, $method], $messages1, $type); call_user_func([$export, $method], $messages2, $type); } $expected = ''; if ($append) { foreach ((array) $messages1 as $message) { $expected .= strip_tags($message) . ($newline ? PHP_EOL : ''); } } foreach ((array) $messages2 as $message) { $expected .= strip_tags($message) . ($newline ? PHP_EOL : ''); } $export->unlock(); $this->assertEquals($expected, file_get_contents($this->file)); }
public function __destruct() { // say that scanning is completed $this->output->write('100%'); $this->output->unlock(); }