Ejemplo n.º 1
0
 /**
  * @param string $inputFile
  * @param string $expectedResultFile
  * @dataProvider ruleDataProvider
  * @depends testPhpCsAvailability
  */
 public function testRule($inputFile, $expectedResultFile)
 {
     $expectedXml = simplexml_load_file($expectedResultFile);
     // rule is not implemented
     $elements = $expectedXml->xpath('/config/incomplete');
     if ($elements) {
         $message = (string) $elements[0];
         $this->markTestIncomplete("Rule for the fixture '{$inputFile}' is not implemented. {$message}");
     }
     // run additional methods before making test
     $elements = $expectedXml->xpath('/config/run');
     foreach ($elements as $element) {
         $method = (string) $element->attributes()->method;
         $this->{$method}();
     }
     self::$_cmd->run(array($inputFile));
     $resultXml = simplexml_load_file(self::$_reportFile);
     $this->_assertTotalErrorsAndWarnings($resultXml, $expectedXml);
     $this->_assertErrors($resultXml, $expectedXml);
     $this->_assertWarnings($resultXml, $expectedXml);
     // verify that there has been at least one assertion performed
     if ($this->getCount() == 0) {
         $this->fail("Broken test: there has no assertions been performed for the fixture '{$inputFile}'.");
     }
 }
Ejemplo n.º 2
0
 public function testCodeStyle()
 {
     $reportFile = self::$_reportDir . '/phpcs_report.xml';
     $cmd = new Inspection_CodeSniffer_Command(realpath(__DIR__ . '/_files/phpcs'), $reportFile);
     if (!$cmd->canRun()) {
         $this->markTestSkipped('PHP Code Sniffer command is not available.');
     }
     $cmd->setExtensions(array('php', 'phtml'));
     $this->assertTrue($cmd->run(self::$_whiteList, self::$_blackList), "See detailed report in '{$reportFile}'.");
 }
Ejemplo n.º 3
0
 /**
  * @depends testRun
  */
 public function testRunWithExtensions()
 {
     $this->assertSame($this->_cmd, $this->_cmd->setExtensions(array('txt', 'xml')));
     $this->_cmd->expects($this->once())->method('_execShellCmd')->with($this->stringContains(' --extensions=txt,xml '));
     $this->_cmd->run(array());
 }