private function doTestConverter(SfbConverter $conv, $inFile, $outFile, $callback = null) { $conv->setObjectCount(1); $conv->rmPattern(' —')->rmRegExpPattern('/^— /'); $conv->disableParagraphIds(); $conv->convert(); $testOutput = $conv->getContent(); if (is_callable($callback)) { $testOutput = call_user_func($callback, $testOutput); } // remove double new lines $testOutput = preg_replace('/\\n\\n+/', "\n", $testOutput); $testOutput = strtr($testOutput, ["<p>\n" => '<p>', "\n</p>" => '</p>']); $testOutput = rtrim($testOutput, "\n"); // save output if wanted $outDir = dirname($outFile) . '/output'; if (file_exists($outDir)) { file_put_contents($outDir . '/' . basename($outFile), $testOutput); } $expected = rtrim(file_get_contents($outFile), "\n"); $this->assertEquals($expected, $testOutput, get_class($conv) . ": {$inFile}"); }
/** * @dataProvider providerForTestAddMissingCommandDelimiters */ public function testAddMissingCommandDelimiters($input, $expected) { $this->assertEquals($expected, rtrim(SfbConverter::addMissingCommandDelimiters($input))); }