Exemplo n.º 1
0
 /**
  * @param FileTool $tool
  * @param string $input
  * @param string $expect
  */
 public static function assertFixer(FileTool $tool, $input, $expect)
 {
     $path = BaseTestCase::createTempFile($input);
     $file = new File($path, File::STATUS_UNKNOWN);
     self::assertNotEmpty($file->getContent()->get());
     # content is loaded, we can delete source file
     unlink($path);
     $tool->process($file, new Report());
     $output = $file->getContent()->get();
     static::assertEquals($expect, $output);
 }
Exemplo n.º 2
0
 /**
  * @param string $code
  * @param string $tool
  */
 protected static function assertValidPhpCode($code, $tool)
 {
     $path = BaseTestCase::createTempFile($code);
     $result = shell_exec('php -l ' . $path);
     $exitCode = trim(shell_exec('php ' . $path . '  > /dev/null 2>&1 && echo $?'));
     unlink($path);
     $isValid = strpos($result, 'No syntax errors detected') === 0;
     static::assertTrue($isValid, 'Invalid code syntax:' . $code);
     static::assertEquals(0, $exitCode, 'Invalid code. Exit status ' . $exitCode . '. Tool: ' . $tool . ' Code:' . $code);
 }