/** * @param string $inputFile * @param string|array $expectedXpaths * @depends testRulesetFormat * @depends testPhpMdAvailability * @dataProvider ruleViolationDataProvider */ public function testRuleViolation($inputFile, $expectedXpaths) { $this->assertFalse(self::$_cmd->run(array($inputFile)), "PHP Mess Detector has failed to identify problem at the erroneous file {$inputFile}"); $actualReportXml = simplexml_load_file(self::$_cmd->getReportFile()); $expectedXpaths = (array) $expectedXpaths; foreach ($expectedXpaths as $expectedXpath) { $this->assertNotEmpty($actualReportXml->xpath($expectedXpath), "Expected xpath: '{$expectedXpath}' for file: '{$inputFile}'"); } }
/** * @param string $inputFile * @param string $expectedReportFile * @depends testRulesetFormat * @depends testPhpMdAvailability * @dataProvider ruleViolationDataProvider */ public function testRuleViolation($inputFile, $expectedReportFile) { $this->assertFalse(self::$_cmd->run(array($inputFile)), "PHP Mess Detector has failed to identify problem at the erroneous file {$inputFile}"); /* Cleanup report from the variable information */ $actualReportXml = file_get_contents(self::$_cmd->getReportFile()); $actualReportXml = preg_replace('/(?<!\\?xml)\\s+version=".+?"/', '', $actualReportXml, 1); $actualReportXml = preg_replace('/\\s+(?:timestamp|externalInfoUrl)=".+?"/', '', $actualReportXml); $actualReportXml = str_replace(realpath($inputFile), basename($inputFile), $actualReportXml); $this->assertXmlStringEqualsXmlFile($expectedReportFile, $actualReportXml); }