main() public static method

The main method that can be used by a calling shell script, the return value can be used as exit code.
public static main ( array $args ) : integer
$args array The raw command line arguments array.
return integer
 /**
  * testReportContainsCouplingBetweenObjectsWarning
  *
  * @return void
  * @outputBuffering enabled
  */
 public function testReportContainsCouplingBetweenObjectsWarning()
 {
     $file = self::createTempFileUri();
     Command::main(array(__FILE__, $this->createCodeResourceUriForTest(), 'text', 'design', '--reportfile', $file));
     self::assertContains('has a coupling between objects value of 14. ' . 'Consider to reduce the number of dependencies under 13.', file_get_contents($file));
 }
Exemplo n.º 2
0
 /**
  * testMainReturnsViolationExitCodeForSourceWithNPathViolation
  *
  * @return void
  * @covers \PHPMD\TextUI\Command
  * @group phpmd
  * @group phpmd::textui
  * @group unittest
  */
 public function testMainReturnsViolationExitCodeForSourceWithNPathViolation()
 {
     $exitCode = Command::main(array(__FILE__, self::createFileUri('source/source_with_npath_violation.php'), 'text', 'codesize', '--reportfile', self::createTempFileUri()));
     $this->assertEquals(Command::EXIT_VIOLATION, $exitCode);
 }
 /**
  * testReportContainsGotoStatementWarning
  *
  * @return void
  * @outputBuffering enabled
  */
 public function testReportContainsGotoStatementWarning()
 {
     $file = self::createTempFileUri();
     Command::main(array(__FILE__, $this->createCodeResourceUriForTest(), 'text', 'design', '--reportfile', $file));
     self::assertContains('utilizes a goto statement.', file_get_contents($file));
 }
 /**
  * Runs the PHPMD command line interface and returns the report content.
  *
  * @return string
  */
 protected static function runCommandLine()
 {
     $inputfile = self::createResourceUriForTest('inputfile.txt');
     $reportfile = self::createTempFileUri();
     self::changeWorkingDirectory(dirname($inputfile));
     Command::main(array(__FILE__, 'text', 'unusedcode', '--reportfile', $reportfile, '--inputfile', $inputfile));
     return file_get_contents($reportfile);
 }