| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| ApprovalMismatchException | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests; |
| 4 | |
| 5 | use Exception; |
| 6 | |
| 7 | class ApprovalMismatchException extends Exception |
| 8 | { |
| 9 | public function __construct($approvedFilename, $receivedFilename) |
| 10 | { |
| 11 | parent::__construct("The approved file does not match the received file\nApproved: $approvedFilename\nReceived: $receivedFilename"); |
| 12 | } |
| 13 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 35 |
+
+
+
+ |
+ 0.00% |
+ 0 / 12 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| Approvals | +
+
+
+ |
+ 0.00% |
+ 0 / 35 |
+
+
+
+ |
+ 0.00% |
+ 0 / 12 |
+ 306 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| verifyString | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyStringWithFileExtension | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verify | +
+
+
+ |
+ 0.00% |
+ 0 / 17 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 20 | ++ | ||
| verifyTransformedList | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| verifyList | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| verifyHtml | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| approveString | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| approveList | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| approveHtml | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAsJson | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| satisfyPHPUnitRequirementForAssert | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php namespace ApprovalTests; |
| 2 | |
| 3 | use ApprovalTests\Reporters\DiffReporter; |
| 4 | use ApprovalTests\Writers\Writer; |
| 5 | use ApprovalTests\Writers\TextWriter; |
| 6 | use ApprovalTests\Reporters\Reporter; |
| 7 | use ApprovalTests\Namers\PHPUnitNamer; |
| 8 | use ApprovalTests\Namers\Namer; |
| 9 | use PHPUnit\Framework\Assert; |
| 10 | |
| 11 | class Approvals |
| 12 | { |
| 13 | public static function verifyString($received, Reporter $reporter = null) |
| 14 | { |
| 15 | self::verifyStringWithFileExtension($received, 'txt', $reporter); |
| 16 | } |
| 17 | |
| 18 | public static function verifyStringWithFileExtension($received, $extensionWithoutDot, Reporter $reporter = null) |
| 19 | { |
| 20 | self::verify(new TextWriter($received, $extensionWithoutDot), new PHPUnitNamer(), $reporter); |
| 21 | } |
| 22 | |
| 23 | public static function getReporter() |
| 24 | { |
| 25 | return new DiffReporter(); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Perform the approval test by comparing the contents of one file to another |
| 30 | */ |
| 31 | public static function verify(Writer $writer, Namer $namer, Reporter $reporter = null) |
| 32 | { |
| 33 | self::satisfyPHPUnitRequirementForAssert(); |
| 34 | if ($reporter == null) { |
| 35 | $reporter = self::getReporter(); |
| 36 | } |
| 37 | |
| 38 | $extension = $writer->getExtensionWithoutDot(); |
| 39 | $approvedFilename = $namer->getApprovedFile($extension); |
| 40 | if (!file_exists($approvedFilename)) { |
| 41 | $writer->writeEmpty( |
| 42 | $namer->getApprovedFile($extension), |
| 43 | $namer->getApprovalsDirectory()); |
| 44 | } |
| 45 | |
| 46 | $receivedFilename = $writer->write( |
| 47 | $namer->getReceivedFile($extension), |
| 48 | $namer->getApprovalsDirectory()); |
| 49 | |
| 50 | $matching = FileApprover::checkFiles($approvedFilename, $receivedFilename); |
| 51 | |
| 52 | if ($matching) { |
| 53 | $writer->delete($receivedFilename); |
| 54 | } |
| 55 | else { |
| 56 | $reporter->report($approvedFilename, $receivedFilename); |
| 57 | throw new ApprovalMismatchException($approvedFilename, $receivedFilename); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | public static function verifyTransformedList(array $list, $callbackObject, $methodName, $reporter = null) |
| 62 | { |
| 63 | $string = ''; |
| 64 | foreach ($list as $item) { |
| 65 | $string .= $item . ' -> ' . $callbackObject->$methodName($item) . "\n"; |
| 66 | } |
| 67 | self::verifyString($string, $reporter); |
| 68 | } |
| 69 | |
| 70 | public static function verifyList(array $list, $reporter = null) |
| 71 | { |
| 72 | $string = ''; |
| 73 | foreach ($list as $key => $item) { |
| 74 | $string .= '[' . $key . '] -> ' . $item . "\n"; |
| 75 | } |
| 76 | self::verifyString($string, $reporter); |
| 77 | } |
| 78 | |
| 79 | public static function verifyHtml($html, $reporter = null) |
| 80 | { |
| 81 | self::verifyStringWithFileExtension($html, 'html', $reporter); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @param $received |
| 86 | * @deprecated Use verifyString instead. |
| 87 | */ |
| 88 | public static function approveString($received) |
| 89 | { |
| 90 | self::verifyString($received); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * @param array $list |
| 95 | * @deprecated Use verifyList instead. |
| 96 | */ |
| 97 | public static function approveList(array $list) |
| 98 | { |
| 99 | self::verifyList($list); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * @param $html |
| 104 | * @deprecated Use verifyHtml instead. |
| 105 | */ |
| 106 | public static function approveHtml($html) |
| 107 | { |
| 108 | self::verifyHtml($html); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * @param mixed $data |
| 113 | * @param Reporter $reporter |
| 114 | * @throws ApprovalMismatchException |
| 115 | */ |
| 116 | public static function verifyAsJson($data, $reporter = null) |
| 117 | { |
| 118 | $json = json_encode(SortingUtil::orderFieldNamesAlphabetically($data), JSON_PRETTY_PRINT); |
| 119 | self::verifyStringWithFileExtension($json, 'json', $reporter); |
| 120 | } |
| 121 | |
| 122 | private static function satisfyPHPUnitRequirementForAssert() |
| 123 | { |
| 124 | Assert::assertTrue(true); |
| 125 | } |
| 126 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 27 |
+
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| SkipCombinationException | ++ | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ 0 | ++ | n/a |
+ 0 / 0 |
+
| CombinationApprovals | +
+
+
+ |
+ 0.00% |
+ 0 / 27 |
+
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+ 462 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| verifyAllCombinations1 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations3 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations4 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations5 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations6 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations7 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations8 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| verifyAllCombinations9 | +
+
+
+ |
+ 0.00% |
+ 0 / 18 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 156 | ++ | ||
| displayArguments | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests; |
| 4 | |
| 5 | use ApprovalTests\Reporters\Reporter; |
| 6 | |
| 7 | class SkipCombinationException extends \Exception { |
| 8 | } |
| 9 | |
| 10 | class CombinationApprovals |
| 11 | { |
| 12 | static $empty = ["CombinationApprovalsEmpty"]; |
| 13 | |
| 14 | public static function verifyAllCombinations1($param, array $values, Reporter $reporter = null) |
| 15 | { |
| 16 | self::verifyAllCombinations9($param, $values, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter); |
| 17 | } |
| 18 | |
| 19 | public static function verifyAllCombinations2($param, array $values1, array $values2, Reporter $reporter = null) |
| 20 | { |
| 21 | self::verifyAllCombinations9($param, $values1, $values2, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter); |
| 22 | } |
| 23 | |
| 24 | public static function verifyAllCombinations3($param, array $values1, array $values2, array $values3, Reporter $reporter = null) |
| 25 | { |
| 26 | self::verifyAllCombinations9($param, $values1, $values2, $values3, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter); |
| 27 | } |
| 28 | |
| 29 | public static function verifyAllCombinations4($param, array $values1, array $values2, array $values3, array $values4, Reporter $reporter = null) |
| 30 | { |
| 31 | self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter); |
| 32 | } |
| 33 | |
| 34 | public static function verifyAllCombinations5($param, array $values1, array $values2, array $values3, array $values4, array $values5, Reporter $reporter = null) |
| 35 | { |
| 36 | self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, self::$empty, self::$empty, self::$empty, self::$empty, $reporter); |
| 37 | } |
| 38 | |
| 39 | public static function verifyAllCombinations6($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, Reporter $reporter = null) |
| 40 | { |
| 41 | self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, $values6, self::$empty, self::$empty, self::$empty, $reporter); |
| 42 | } |
| 43 | |
| 44 | public static function verifyAllCombinations7($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, array $values7, Reporter $reporter = null) |
| 45 | { |
| 46 | self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, $values6, $values7, self::$empty, self::$empty, $reporter); |
| 47 | } |
| 48 | |
| 49 | public static function verifyAllCombinations8($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, array $values7, array $values8, Reporter $reporter = null) |
| 50 | { |
| 51 | self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, $values6, $values7, $values8, self::$empty, $reporter); |
| 52 | } |
| 53 | |
| 54 | public static function verifyAllCombinations9($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, array $values7, array $values8, array $values9, Reporter $reporter = null) |
| 55 | { |
| 56 | $output = ''; |
| 57 | foreach ($values1 as $i1) { |
| 58 | foreach ($values2 as $i2) { |
| 59 | foreach ($values3 as $i3) { |
| 60 | foreach ($values4 as $i4) { |
| 61 | foreach ($values5 as $i5) { |
| 62 | foreach ($values6 as $i6) { |
| 63 | foreach ($values7 as $i7) { |
| 64 | foreach ($values8 as $i8) { |
| 65 | foreach ($values9 as $i9) { |
| 66 | $thisOutput = self::displayArguments($i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9); |
| 67 | try { |
| 68 | $thisOutput .= $param($i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9); |
| 69 | } catch (SkipCombinationException $e) { |
| 70 | continue; |
| 71 | } catch (\Exception $e) { |
| 72 | $thisOutput .= get_class($e) . ' thrown: ' . $e->getMessage(); |
| 73 | } |
| 74 | $output .= $thisOutput . "\n"; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | Approvals::verifyString($output, $reporter); |
| 85 | } |
| 86 | |
| 87 | public static function displayArguments(...$args): string |
| 88 | { |
| 89 | return '[' . implode(', ', array_filter($args, function($i) { return $i !== self::$empty[0]; })) . "] => "; |
| 90 | } |
| 91 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| FileApprover | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ 6 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| checkFiles | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| clean | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests; |
| 4 | |
| 5 | class FileApprover |
| 6 | { |
| 7 | public static function checkFiles(string $approvedFilename, string $receivedFilename): bool |
| 8 | { |
| 9 | $approvedContents = FileApprover::clean(file_get_contents($approvedFilename)); |
| 10 | $receivedContents = FileApprover::clean(file_get_contents($receivedFilename)); |
| 11 | |
| 12 | return $approvedContents === $receivedContents; |
| 13 | } |
| 14 | |
| 15 | private static function clean(string $contents): string |
| 16 | { |
| 17 | return str_replace("\r\n", "\n", $contents); |
| 18 | } |
| 19 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| FileUtil | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ 20 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| createFileIfNotExists | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| createFolderIfNotExists | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| 1 | <?php namespace ApprovalTests; |
| 2 | |
| 3 | class FileUtil |
| 4 | { |
| 5 | public static function createFileIfNotExists($filename) |
| 6 | { |
| 7 | if (!file_exists($filename)) { |
| 8 | return touch($filename); |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | public static function createFolderIfNotExists($approvalsFolder) |
| 13 | { |
| 14 | if (!is_dir($approvalsFolder)) { |
| 15 | return mkdir($approvalsFolder); |
| 16 | } |
| 17 | } |
| 18 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | ++ | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ CRAP | ++ | n/a |
+ 0 / 0 |
+
| 1 | <?php namespace ApprovalTests\Namers; |
| 2 | |
| 3 | interface Namer |
| 4 | { |
| 5 | public function getApprovedFile($extensionWithoutDot); |
| 6 | public function getReceivedFile($extensionWithoutDot); |
| 7 | public function getCallingTestClassName(); |
| 8 | public function getCallingTestClassNameWithoutNamespace(); |
| 9 | public function getCallingTestMethodName(); |
| 10 | public function getCallingTestDirectory(); |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 51 |
+
+
+
+ |
+ 0.00% |
+ 0 / 15 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
| StackTraceMetadata | +
+
+
+ |
+ 0.00% |
+ 0 / 22 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ 156 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 11 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 20 | ++ | ||
| isPHPUnitTest | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| isReflection | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 12 | ++ | ||
| endsWith | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| __toString | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| PHPUnitNamer | +
+
+
+ |
+ 0.00% |
+ 0 / 29 |
+
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+ 210 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getStackTrace | +
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 30 | ++ | ||
| getApprovedFile | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getReceivedFile | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getFile | +
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getCallingTestClassName | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getCallingTestClassNameWithoutNamespace | +
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getCallingTestMethodName | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getCallingTestDirectory | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getApprovalsDirectory | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php namespace ApprovalTests\Namers; |
| 2 | |
| 3 | class StackTraceMetadata |
| 4 | { |
| 5 | /** |
| 6 | * @var bool |
| 7 | */ |
| 8 | public $isPHPUnitTest; |
| 9 | |
| 10 | /** |
| 11 | * @var bool |
| 12 | */ |
| 13 | public $isReflection; |
| 14 | |
| 15 | /** |
| 16 | * @var string|null |
| 17 | */ |
| 18 | public $testDirectory; |
| 19 | |
| 20 | public $class; |
| 21 | |
| 22 | public $function; |
| 23 | |
| 24 | /** |
| 25 | * @var array |
| 26 | */ |
| 27 | public $stackTraceLine; |
| 28 | |
| 29 | public function __construct(array $stackTraceLine, array $prevStackTraceLine) { |
| 30 | if (array_key_exists('file', $stackTraceLine)) { |
| 31 | $this->isPHPUnitTest = self::isPHPUnitTest($stackTraceLine['file']); |
| 32 | } else { |
| 33 | $this->isPHPUnitTest = false; |
| 34 | } |
| 35 | if (array_key_exists('file', $prevStackTraceLine)) { |
| 36 | $this->testDirectory = dirname($prevStackTraceLine['file']); |
| 37 | } else { |
| 38 | $this->testDirectory = null; |
| 39 | } |
| 40 | $this->isReflection = self::isReflection($stackTraceLine); |
| 41 | $this->stackTraceLine = $stackTraceLine; |
| 42 | $clazz = isset($stackTraceLine['class']) ? $stackTraceLine['class'] : ''; |
| 43 | $this->class = $clazz; |
| 44 | $this->function = $stackTraceLine['function']; |
| 45 | } |
| 46 | |
| 47 | public static function isPHPUnitTest($path) |
| 48 | { |
| 49 | $expectedLocalPath = implode(DIRECTORY_SEPARATOR, ['', 'phpunit', 'src', 'Framework', 'TestCase.php']); |
| 50 | $expectedPharPath = implode('/', ['', 'phpunit', 'Framework', 'TestCase.php']); |
| 51 | return self::endsWith($path, $expectedLocalPath) || self::endsWith($path, $expectedPharPath); |
| 52 | } |
| 53 | |
| 54 | public static function isReflection($stackTraceLine) |
| 55 | { |
| 56 | $clazz = isset($stackTraceLine['class']) ? $stackTraceLine['class'] : ''; |
| 57 | return $clazz === 'ReflectionMethod' && $stackTraceLine['function'] === 'invokeArgs'; |
| 58 | } |
| 59 | |
| 60 | private static function endsWith($haystack, $needle) |
| 61 | { |
| 62 | // https://stackoverflow.com/a/834355/25507 |
| 63 | $length = strlen($needle); |
| 64 | if ($length == 0) { |
| 65 | return true; |
| 66 | } |
| 67 | |
| 68 | return substr($haystack, -$length) === $needle; |
| 69 | } |
| 70 | |
| 71 | public function __toString(): string { |
| 72 | return "[PHPUnit,class,method,reflection,testDirectory]=" |
| 73 | ."[{$this->isPHPUnitTest},{$this->class},{$this->function},{$this->isReflection},{$this->testDirectory}]"; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | class PHPUnitNamer implements Namer |
| 78 | { |
| 79 | private $caller; |
| 80 | private $testDirectory; |
| 81 | |
| 82 | /** |
| 83 | * PHPUnitNamer constructor. |
| 84 | * @throws \Exception |
| 85 | */ |
| 86 | public function __construct() |
| 87 | { |
| 88 | $metadata = self::getStackTrace(); |
| 89 | $this->caller = $metadata->stackTraceLine; |
| 90 | $this->testDirectory = $metadata->testDirectory; |
| 91 | } |
| 92 | |
| 93 | private static function getStackTrace() |
| 94 | { |
| 95 | $stackTraceLines = debug_backtrace(false); |
| 96 | $stackTraceMetadata = []; |
| 97 | for ($i = 1; $i < count($stackTraceLines); $i++) { |
| 98 | $metadata = new StackTraceMetadata($stackTraceLines[$i], $stackTraceLines[$i - 1]); |
| 99 | $stackTraceMetadata[] = $metadata; |
| 100 | } |
| 101 | for ($i = 0; $i < count($stackTraceMetadata); $i++) { |
| 102 | $metadata = $stackTraceMetadata[$i]; |
| 103 | if ($metadata->isPHPUnitTest) { |
| 104 | return $stackTraceMetadata[$metadata->isReflection ? $i - 1 : $i]; |
| 105 | } |
| 106 | } |
| 107 | throw new \Exception("Failed to identify the testing framework you are using; currently PHPUnit 5-8 is supported. Please raise a bug if you find this."); |
| 108 | } |
| 109 | |
| 110 | public function getApprovedFile($extensionWithoutDot) |
| 111 | { |
| 112 | return $this->getFile('approved', $extensionWithoutDot); |
| 113 | } |
| 114 | |
| 115 | public function getReceivedFile($extensionWithoutDot) |
| 116 | { |
| 117 | return $this->getFile('received', $extensionWithoutDot); |
| 118 | } |
| 119 | |
| 120 | private function getFile($status, $extensionWithoutDot) |
| 121 | { |
| 122 | return $this->getApprovalsDirectory() |
| 123 | . DIRECTORY_SEPARATOR . $this->getCallingTestClassNameWithoutNamespace() |
| 124 | . '.' . $this->getCallingTestMethodName() |
| 125 | . '.' . $status |
| 126 | . '.' . $extensionWithoutDot; |
| 127 | } |
| 128 | |
| 129 | public function getCallingTestClassName() |
| 130 | { |
| 131 | return $this->caller['class']; |
| 132 | } |
| 133 | |
| 134 | public function getCallingTestClassNameWithoutNamespace() |
| 135 | { |
| 136 | return array_values( |
| 137 | array_slice( |
| 138 | explode('\\', $this->getCallingTestClassName()), |
| 139 | -1 |
| 140 | ))[0]; |
| 141 | } |
| 142 | |
| 143 | public function getCallingTestMethodName() |
| 144 | { |
| 145 | return $this->caller['function']; |
| 146 | } |
| 147 | |
| 148 | public function getCallingTestDirectory() |
| 149 | { |
| 150 | return $this->testDirectory; |
| 151 | } |
| 152 | |
| 153 | public function getApprovalsDirectory() |
| 154 | { |
| 155 | return $this->getCallingTestDirectory() . DIRECTORY_SEPARATOR . 'approvals'; |
| 156 | } |
| 157 | } |
| Class | +Coverage | +
|---|---|
| ApprovalTests\Namers\StackTraceMetadata | 0% |
| ApprovalTests\Namers\PHPUnitNamer | 0% |
| Class | +CRAP | +
|---|---|
| ApprovalTests\Namers\PHPUnitNamer | 210 |
| ApprovalTests\Namers\StackTraceMetadata | 156 |
| Method | +Coverage | +
|---|---|
| __construct | 0% |
| isPHPUnitTest | 0% |
| isReflection | 0% |
| endsWith | 0% |
| __toString | 0% |
| __construct | 0% |
| getStackTrace | 0% |
| getApprovedFile | 0% |
| getReceivedFile | 0% |
| getFile | 0% |
| getCallingTestClassName | 0% |
| getCallingTestClassNameWithoutNamespace | 0% |
| getCallingTestMethodName | 0% |
| getCallingTestDirectory | 0% |
| getApprovalsDirectory | 0% |
| Method | +CRAP | +
|---|---|
| getStackTrace | 30 |
| __construct | 20 |
| isReflection | 12 |
| isPHPUnitTest | 6 |
| endsWith | 6 |
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 51 |
+
+
+
+ |
+ 0.00% |
+ 0 / 15 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
| + | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 51 |
+
+
+
+ |
+ 0.00% |
+ 0 / 15 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 9 |
+
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| ClipboardReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 9 |
+
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+ 42 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| getCommandLineFor | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| report | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| copyToClipboard | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| isWorkingInThisEnvironment | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | use ApprovalTests\SystemUtil; |
| 6 | |
| 7 | class ClipboardReporter implements Reporter |
| 8 | { |
| 9 | public static function getCommandLineFor(string $approvedFilename, string $receivedFilename, bool $isWindows) |
| 10 | { |
| 11 | if ($isWindows) { |
| 12 | return "move /Y \"$receivedFilename\" \"$approvedFilename\""; |
| 13 | } else { |
| 14 | return "mv \"$receivedFilename\" \"$approvedFilename\""; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | public function report($approvedFilename, $receivedFilename) |
| 19 | { |
| 20 | $commandLine = self::getCommandLineFor($approvedFilename, $receivedFilename, SystemUtil::isWindows()); |
| 21 | self::copyToClipboard($commandLine); |
| 22 | } |
| 23 | |
| 24 | public static function copyToClipboard(string $newClipboardText) |
| 25 | { |
| 26 | $clipboardCommand = SystemUtil::isWindows() ? "clip" : "pbclip"; |
| 27 | $cmd = "echo " . $newClipboardText . " | " . $clipboardCommand; |
| 28 | shell_exec($cmd); |
| 29 | } |
| 30 | |
| 31 | public function isWorkingInThisEnvironment($receivedFilename) |
| 32 | { |
| 33 | return true; |
| 34 | } |
| 35 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 13 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| CombinationReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 13 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ 90 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| report | +
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 30 | ++ | ||
| isWorkingInThisEnvironment | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 12 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | use Exception; |
| 6 | |
| 7 | class CombinationReporter |
| 8 | { |
| 9 | /** |
| 10 | * @var Reporter[] |
| 11 | */ |
| 12 | private $reporters; |
| 13 | |
| 14 | /** |
| 15 | * @param Reporter[] $reporters |
| 16 | */ |
| 17 | public function __construct(...$reporters) |
| 18 | { |
| 19 | $this->reporters = $reporters; |
| 20 | } |
| 21 | |
| 22 | public function report($approvedFilename, $receivedFilename) |
| 23 | { |
| 24 | $exception = null; |
| 25 | foreach ($this->reporters as $reporter) { |
| 26 | if ($reporter->isWorkingInThisEnvironment($receivedFilename)) { |
| 27 | try { |
| 28 | $reporter->report($approvedFilename, $receivedFilename); |
| 29 | } catch (Exception $e) { |
| 30 | $exception = $e; |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | if ($exception) { |
| 35 | throw $exception; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | public function isWorkingInThisEnvironment($receivedFilename) |
| 40 | { |
| 41 | foreach ($this->reporters as $reporter) { |
| 42 | if ($reporter->isWorkingInThisEnvironment($receivedFilename)) { |
| 43 | return true; |
| 44 | } |
| 45 | } |
| 46 | return false; |
| 47 | } |
| 48 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 23 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| DiffInfo | +
+
+
+ |
+ 0.00% |
+ 0 / 23 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ 72 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| resolveWindowsPath | +
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| getPathInProgramFilesX86 | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getFirstWorking | +
+
+
+ |
+ 0.00% |
+ 0 / 6 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 12 | ++ | ||
| getProgramFilesPaths | +
+
+
+ |
+ 0.00% |
+ 0 / 7 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | class DiffInfo |
| 6 | { |
| 7 | public $diffProgram; |
| 8 | public $parameters; |
| 9 | public $fileExtensions; |
| 10 | |
| 11 | public function __construct(string $diffProgram, array $fileExtensions, string $parameters = null) |
| 12 | { |
| 13 | $this->diffProgram = self::resolveWindowsPath($diffProgram); |
| 14 | $this->parameters = $parameters ?? GenericDiffReporter::$STANDARD_ARGUMENTS; |
| 15 | $this->fileExtensions = $fileExtensions; |
| 16 | } |
| 17 | |
| 18 | private static function resolveWindowsPath(string $diffProgram): string |
| 19 | { |
| 20 | $tag = "{ProgramFiles}"; |
| 21 | |
| 22 | $startsWith = substr($diffProgram, 0, strlen($tag)) === $tag; |
| 23 | if ($startsWith) { |
| 24 | $diffProgram = self::getPathInProgramFilesX86(substr($diffProgram, strlen($tag))); |
| 25 | } |
| 26 | return $diffProgram; |
| 27 | } |
| 28 | |
| 29 | private static function getPathInProgramFilesX86(string $path): string |
| 30 | { |
| 31 | $paths = self::getProgramFilesPaths(); |
| 32 | return self::getFirstWorking($path, $paths, "C:\\Program Files\\"); |
| 33 | } |
| 34 | |
| 35 | public static function getFirstWorking(string $path, array $paths, string $ifNotFoundDefault): string |
| 36 | { |
| 37 | $fullPath = $ifNotFoundDefault . $path; |
| 38 | foreach ($paths as $p) { |
| 39 | $fullPath = $p . DIRECTORY_SEPARATOR . $path; |
| 40 | if (file_exists($fullPath)) { |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | return $fullPath; |
| 45 | } |
| 46 | |
| 47 | public static function getProgramFilesPaths(): array |
| 48 | { |
| 49 | $paths = [ |
| 50 | getenv("ProgramFiles(x86)"), |
| 51 | getenv("ProgramFiles"), |
| 52 | getenv("ProgramW6432"), |
| 53 | // Programs like Beyond Compare 4 that support per-user installation |
| 54 | // will likely install themselves here. |
| 55 | getenv("LocalAppData"), |
| 56 | ]; |
| 57 | return array_unique(array_filter($paths)); |
| 58 | } |
| 59 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 41 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| DiffPrograms | +
+
+
+ |
+ 0.00% |
+ 0 / 41 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ 42 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| getInstance | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| Text | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| Image | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| TextAndImage | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 35 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | class DiffPrograms |
| 6 | { |
| 7 | private static $instance = null; |
| 8 | |
| 9 | public static function getInstance(): DiffPrograms { |
| 10 | if (!self::$instance) { |
| 11 | self::$instance = new DiffPrograms(); |
| 12 | } |
| 13 | return self::$instance; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * @var DiffInfo[] |
| 18 | */ |
| 19 | public $MacDiffPrograms; |
| 20 | |
| 21 | /** |
| 22 | * @var DiffInfo[] |
| 23 | */ |
| 24 | public $WindowsDiffPrograms; |
| 25 | |
| 26 | public static function Text() |
| 27 | { |
| 28 | return GenericDiffReporter::$TEXT_FILE_EXTENSIONS; |
| 29 | } |
| 30 | |
| 31 | public static function Image() |
| 32 | { |
| 33 | return GenericDiffReporter::$IMAGE_FILE_EXTENSIONS; |
| 34 | } |
| 35 | |
| 36 | public static function TextAndImage() |
| 37 | { |
| 38 | return array_merge(self::Text(), self::Image()); |
| 39 | } |
| 40 | |
| 41 | private function __construct() |
| 42 | { |
| 43 | $this->MacDiffPrograms = [ |
| 44 | 'DIFF_MERGE' => new DiffInfo( |
| 45 | "/Applications/DiffMerge.app/Contents/MacOS/DiffMerge", DiffPrograms::Text(), "%s %s -nosplash"), |
| 46 | 'BEYOND_COMPARE' => new DiffInfo( |
| 47 | "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", DiffPrograms::Text()), |
| 48 | 'KALEIDOSCOPE' => new DiffInfo( |
| 49 | "/Applications/Kaleidoscope.app/Contents/MacOS/ksdiff", DiffPrograms::TextAndImage()), |
| 50 | 'KDIFF3' => new DiffInfo("/Applications/kdiff3.app/Contents/MacOS/kdiff3", |
| 51 | DiffPrograms::Text(), "%s %s -m"), |
| 52 | 'P4MERGE' => new DiffInfo("/Applications/p4merge.app/Contents/MacOS/p4merge", |
| 53 | DiffPrograms::TextAndImage()), |
| 54 | 'TK_DIFF' => new DiffInfo("/Applications/TkDiff.app/Contents/MacOS/tkdiff", |
| 55 | DiffPrograms::Text()), |
| 56 | 'VISUAL_STUDIO_CODE' => new DiffInfo( |
| 57 | "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", DiffPrograms::Text(), "-d %s %s"), |
| 58 | ]; |
| 59 | |
| 60 | $this->WindowsDiffPrograms = [ |
| 61 | 'BEYOND_COMPARE_3' => new DiffInfo("{ProgramFiles}Beyond Compare 3\\BCompare.exe", |
| 62 | DiffPrograms::TextAndImage()), |
| 63 | 'BEYOND_COMPARE_4' => new DiffInfo("{ProgramFiles}Beyond Compare 4\\BCompare.exe", |
| 64 | DiffPrograms::TextAndImage()), |
| 65 | 'TORTOISE_IMAGE_DIFF' => new DiffInfo("{ProgramFiles}TortoiseSVN\\bin\\TortoiseIDiff.exe", |
| 66 | DiffPrograms::Image(), "/left:%s /right:%s"), |
| 67 | 'TORTOISE_TEXT_DIFF' => new DiffInfo("{ProgramFiles}TortoiseSVN\\bin\\TortoiseMerge.exe", |
| 68 | DiffPrograms::Text()), |
| 69 | 'WIN_MERGE' => new DiffInfo("{ProgramFiles}WinMerge\\WinMergeU.exe", DiffPrograms::Text()), |
| 70 | 'ARAXIS_MERGE' => new DiffInfo("{ProgramFiles}Araxis\\Araxis Merge\\Compare.exe", |
| 71 | DiffPrograms::Text()), |
| 72 | 'CODE_COMPARE' => new DiffInfo( |
| 73 | "{ProgramFiles}Devart\\Code Compare\\CodeCompare.exe", DiffPrograms::Text()), |
| 74 | 'KDIFF3' => new DiffInfo("{ProgramFiles}KDiff3\\kdiff3.exe", DiffPrograms::Text()), |
| 75 | 'VISUAL_STUDIO_CODE' => new DiffInfo("{ProgramFiles}Microsoft VS Code\\Code.exe", |
| 76 | DiffPrograms::Text(), "-d %s %s"), |
| 77 | 'MELD' => new DiffInfo("{ProgramFiles}Meld\\Meld.exe", DiffPrograms::Text()), |
| 78 | ]; |
| 79 | } |
| 80 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| DiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | use ApprovalTests\Reporters\Mac\MacDiffReporter; |
| 6 | use ApprovalTests\Reporters\Windows\WindowsDiffReporter; |
| 7 | |
| 8 | class DiffReporter extends FirstWorkingReporter |
| 9 | { |
| 10 | public function __construct() |
| 11 | { |
| 12 | parent::__construct(new MacDiffReporter(), new WindowsDiffReporter(), new PHPUnitReporter()); |
| 13 | } |
| 14 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| FileLaunchReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ 6 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| report | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| isWorkingInThisEnvironment | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | use ApprovalTests\SystemUtil; |
| 6 | |
| 7 | class FileLaunchReporter implements Reporter |
| 8 | { |
| 9 | public function report($approvedFilename, $receivedFilename) |
| 10 | { |
| 11 | SystemUtil::viewFile($receivedFilename); |
| 12 | } |
| 13 | |
| 14 | public function isWorkingInThisEnvironment($receivedFilename) |
| 15 | { |
| 16 | return true; |
| 17 | } |
| 18 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 9 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| FirstWorkingReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 9 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ 56 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| report | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 12 | ++ | ||
| isWorkingInThisEnvironment | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 12 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | class FirstWorkingReporter implements Reporter |
| 6 | { |
| 7 | /** |
| 8 | * @var Reporter[] |
| 9 | */ |
| 10 | private $reporters; |
| 11 | |
| 12 | /** |
| 13 | * @param Reporter[] $reporters |
| 14 | */ |
| 15 | public function __construct(...$reporters) |
| 16 | { |
| 17 | $this->reporters = $reporters; |
| 18 | } |
| 19 | |
| 20 | public function report($approvedFilename, $receivedFilename) |
| 21 | { |
| 22 | foreach ($this->reporters as $reporter) { |
| 23 | if ($reporter->isWorkingInThisEnvironment($receivedFilename)) { |
| 24 | $reporter->report($approvedFilename, $receivedFilename); |
| 25 | return; |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | public function isWorkingInThisEnvironment($receivedFilename) |
| 31 | { |
| 32 | foreach ($this->reporters as $reporter) { |
| 33 | if ($reporter->isWorkingInThisEnvironment($receivedFilename)) { |
| 34 | return true; |
| 35 | } |
| 36 | } |
| 37 | return false; |
| 38 | } |
| 39 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| GenericDiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ 12 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| report | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| isWorkingInThisEnvironment | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | use ApprovalTests\SystemUtil; |
| 6 | |
| 7 | class GenericDiffReporter implements Reporter |
| 8 | { |
| 9 | public static $STANDARD_ARGUMENTS = "%s %s"; |
| 10 | public static $TEXT_FILE_EXTENSIONS = [".txt", ".csv", ".htm", ".html", ".xml", ".eml", |
| 11 | ".java", ".css", ".js", ".json"]; |
| 12 | public static $IMAGE_FILE_EXTENSIONS = [".png", ".gif", ".jpg", ".jpeg", ".bmp", ".tif", |
| 13 | ".tiff"]; |
| 14 | |
| 15 | private $diffProgram; |
| 16 | private $fileExtensions; |
| 17 | private $parameters; |
| 18 | |
| 19 | public function __construct(string $diffProgram, array $fileExtensions, string $parameters) { |
| 20 | $this->diffProgram = $diffProgram; |
| 21 | $this->fileExtensions = $fileExtensions; |
| 22 | $this->parameters = $parameters; |
| 23 | } |
| 24 | |
| 25 | public function report($approvedFilename, $receivedFilename) |
| 26 | { |
| 27 | SystemUtil::execInBackground(sprintf('"%s" ' . $this->parameters, $this->diffProgram, $receivedFilename, $approvedFilename)); |
| 28 | } |
| 29 | |
| 30 | public function isWorkingInThisEnvironment($receivedFilename) |
| 31 | { |
| 32 | return is_executable($this->diffProgram); |
| 33 | } |
| 34 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| BeyondCompareReporterMac | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | class BeyondCompareReporterMac extends MacDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('BEYOND_COMPARE'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| DiffMergeReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | class DiffMergeReporter extends MacDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('DIFF_MERGE'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| KDiff3ReporterMac | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | class KDiff3ReporterMac extends MacDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('KDIFF3'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| KaleidoscopeReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | class KaleidoscopeReporter extends MacDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('KALEIDOSCOPE'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| MacDiffInfoReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | use ApprovalTests\Reporters\DiffPrograms; |
| 6 | use ApprovalTests\Reporters\GenericDiffReporter; |
| 7 | |
| 8 | class MacDiffInfoReporter extends GenericDiffReporter |
| 9 | { |
| 10 | public function __construct(string $diffInfoName) |
| 11 | { |
| 12 | $diffInfo = DiffPrograms::getInstance()->MacDiffPrograms[$diffInfoName]; |
| 13 | parent::__construct($diffInfo->diffProgram, $diffInfo->fileExtensions, $diffInfo->parameters); |
| 14 | } |
| 15 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 7 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| MacDiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 7 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 7 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | use ApprovalTests\Reporters\FirstWorkingReporter; |
| 6 | |
| 7 | class MacDiffReporter extends FirstWorkingReporter |
| 8 | { |
| 9 | public function __construct() |
| 10 | { |
| 11 | parent::__construct( |
| 12 | new BeyondCompareReporterMac(), |
| 13 | new KaleidoscopeReporter(), |
| 14 | new DiffMergeReporter(), |
| 15 | new P4MergeReporter(), |
| 16 | new TkDiffReporter(), |
| 17 | new KDiff3ReporterMac()); |
| 18 | } |
| 19 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| P4MergeReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | class P4MergeReporter extends MacDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('P4MERGE'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| TkDiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Mac; |
| 4 | |
| 5 | class TkDiffReporter extends MacDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('TK_DIFF'); |
| 10 | } |
| 11 | } |
| Class | +CRAP | +
|---|
| Method | +Coverage | +
|---|---|
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| Method | +CRAP | +
|---|
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 15 |
+
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 7 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| PHPUnitReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ 6 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| report | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| isWorkingInThisEnvironment | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php namespace ApprovalTests\Reporters; |
| 2 | |
| 3 | use PHPUnit\Framework\Assert; |
| 4 | |
| 5 | class PHPUnitReporter implements Reporter |
| 6 | { |
| 7 | public function report($approvedFilename, $receivedFilename) |
| 8 | { |
| 9 | $approvedContents = file_get_contents($approvedFilename); |
| 10 | $receivedContents = file_get_contents($receivedFilename); |
| 11 | Assert::assertEquals($approvedContents, $receivedContents); |
| 12 | } |
| 13 | |
| 14 | public function isWorkingInThisEnvironment($receivedFilename) |
| 15 | { |
| 16 | return true; |
| 17 | } |
| 18 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| QuietReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ 6 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| report | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| isWorkingInThisEnvironment | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters; |
| 4 | |
| 5 | class QuietReporter implements Reporter |
| 6 | { |
| 7 | public function report($approvedFilename, $receivedFilename) |
| 8 | { |
| 9 | } |
| 10 | |
| 11 | public function isWorkingInThisEnvironment($receivedFilename) |
| 12 | { |
| 13 | return true; |
| 14 | } |
| 15 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | ++ | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ CRAP | ++ | n/a |
+ 0 / 0 |
+
| 1 | <?php namespace ApprovalTests\Reporters; |
| 2 | |
| 3 | interface Reporter |
| 4 | { |
| 5 | public function report($approvedFilename, $receivedFilename); |
| 6 | public function isWorkingInThisEnvironment($receivedFilename); |
| 7 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| AraxisMergeReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class AraxisMergeReporter extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('ARAXIS_MERGE'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| BeyondCompare3ReporterWindows | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class BeyondCompare3ReporterWindows extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('BEYOND_COMPARE_3'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| BeyondCompare4ReporterWindows | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class BeyondCompare4ReporterWindows extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('BEYOND_COMPARE_4'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| BeyondCompareReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | use ApprovalTests\Reporters\FirstWorkingReporter; |
| 6 | |
| 7 | class BeyondCompareReporter extends FirstWorkingReporter |
| 8 | { |
| 9 | public function __construct() |
| 10 | { |
| 11 | parent::__construct(new BeyondCompare4ReporterWindows(), new BeyondCompare3ReporterWindows()); |
| 12 | } |
| 13 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| CodeCompareReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class CodeCompareReporter extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('CODE_COMPARE'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| KDiff3ReporterWindows | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class KDiff3ReporterWindows extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() { |
| 8 | parent::__construct('KDIFF3'); |
| 9 | } |
| 10 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| MeldReporterWindows | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class MeldReporterWindows extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() { |
| 8 | parent::__construct('MELD'); |
| 9 | } |
| 10 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| TortoiseDiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | use ApprovalTests\Reporters\FirstWorkingReporter; |
| 6 | |
| 7 | class TortoiseDiffReporter extends FirstWorkingReporter |
| 8 | { |
| 9 | public function __construct() |
| 10 | { |
| 11 | parent::__construct(new TortoiseImageDiffReporter(), new TortoiseTextDiffReporter()); |
| 12 | } |
| 13 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| TortoiseImageDiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class TortoiseImageDiffReporter extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('TORTOISE_IMAGE_DIFF'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| TortoiseTextDiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class TortoiseTextDiffReporter extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('TORTOISE_TEXT_DIFF'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| WinMergeReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | class WinMergeReporter extends WindowsDiffInfoReporter |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | parent::__construct('WIN_MERGE'); |
| 10 | } |
| 11 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| WindowsDiffInfoReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | use ApprovalTests\Reporters\DiffPrograms; |
| 6 | use ApprovalTests\Reporters\GenericDiffReporter; |
| 7 | |
| 8 | class WindowsDiffInfoReporter extends GenericDiffReporter |
| 9 | { |
| 10 | public function __construct(string $diffInfoName) |
| 11 | { |
| 12 | $diffInfo = DiffPrograms::getInstance()->WindowsDiffPrograms[$diffInfoName]; |
| 13 | parent::__construct($diffInfo->diffProgram, $diffInfo->fileExtensions, $diffInfo->parameters); |
| 14 | } |
| 15 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| WindowsDiffReporter | +
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests\Reporters\Windows; |
| 4 | |
| 5 | use ApprovalTests\Reporters\FirstWorkingReporter; |
| 6 | |
| 7 | class WindowsDiffReporter extends FirstWorkingReporter |
| 8 | { |
| 9 | public function __construct() |
| 10 | { |
| 11 | parent::__construct( |
| 12 | new BeyondCompareReporter(), |
| 13 | new TortoiseDiffReporter(), |
| 14 | new CodeCompareReporter(), |
| 15 | new WinMergeReporter(), |
| 16 | new AraxisMergeReporter(), |
| 17 | new MeldReporterWindows(), |
| 18 | new KDiff3ReporterWindows()); |
| 19 | } |
| 20 | } |
| Class | +CRAP | +
|---|
| Method | +Coverage | +
|---|---|
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| Method | +CRAP | +
|---|
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 21 |
+
+
+
+ |
+ 0.00% |
+ 0 / 13 |
+
+
+
+ |
+ 0.00% |
+ 0 / 13 |
+
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
| Class | +CRAP | +
|---|---|
| ApprovalTests\Reporters\CombinationReporter | 90 |
| ApprovalTests\Reporters\DiffInfo | 72 |
| ApprovalTests\Reporters\FirstWorkingReporter | 56 |
| ApprovalTests\Reporters\ClipboardReporter | 42 |
| ApprovalTests\Reporters\DiffPrograms | 42 |
| Method | +Coverage | +
|---|---|
| getCommandLineFor | 0% |
| report | 0% |
| copyToClipboard | 0% |
| isWorkingInThisEnvironment | 0% |
| __construct | 0% |
| report | 0% |
| isWorkingInThisEnvironment | 0% |
| __construct | 0% |
| resolveWindowsPath | 0% |
| getPathInProgramFilesX86 | 0% |
| getFirstWorking | 0% |
| getProgramFilesPaths | 0% |
| getInstance | 0% |
| Text | 0% |
| Image | 0% |
| TextAndImage | 0% |
| __construct | 0% |
| __construct | 0% |
| report | 0% |
| isWorkingInThisEnvironment | 0% |
| __construct | 0% |
| report | 0% |
| isWorkingInThisEnvironment | 0% |
| __construct | 0% |
| report | 0% |
| isWorkingInThisEnvironment | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| report | 0% |
| isWorkingInThisEnvironment | 0% |
| report | 0% |
| isWorkingInThisEnvironment | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| __construct | 0% |
| Method | +CRAP | +
|---|---|
| report | 30 |
| isWorkingInThisEnvironment | 12 |
| getFirstWorking | 12 |
| report | 12 |
| isWorkingInThisEnvironment | 12 |
| getCommandLineFor | 6 |
| copyToClipboard | 6 |
| resolveWindowsPath | 6 |
| getInstance | 6 |
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 145 |
+
+
+
+ |
+ 0.00% |
+ 0 / 51 |
+
+
+
+ |
+ 0.00% |
+ 0 / 31 |
+
|
+
+
+ |
+ 0.00% |
+ 0 / 15 |
+
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 21 |
+
+
+
+ |
+ 0.00% |
+ 0 / 13 |
+
+
+
+ |
+ 0.00% |
+ 0 / 13 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 9 |
+
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 13 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 23 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 41 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 9 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 4 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
|
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
| + | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| SortingUtil | +
+
+
+ |
+ 0.00% |
+ 0 / 8 |
+
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+ 20 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| ksortRecursive | +
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 12 | ++ | ||
| orderFieldNamesAlphabetically | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php namespace ApprovalTests; |
| 2 | |
| 3 | class SortingUtil |
| 4 | { |
| 5 | // https://gist.github.com/cdzombak/601849 |
| 6 | private static function ksortRecursive(&$array, $sort_flags = SORT_REGULAR) |
| 7 | { |
| 8 | if (!is_array($array)) return false; |
| 9 | ksort($array, $sort_flags); |
| 10 | foreach ($array as &$arr) { |
| 11 | self::ksortRecursive($arr, $sort_flags); |
| 12 | } |
| 13 | return true; |
| 14 | } |
| 15 | |
| 16 | public static function orderFieldNamesAlphabetically($array) |
| 17 | { |
| 18 | $result = $array; |
| 19 | self::ksortRecursive($result); |
| 20 | return $result; |
| 21 | } |
| 22 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 7 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| SystemUtil | +
+
+
+ |
+ 0.00% |
+ 0 / 7 |
+
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+ 30 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| isWindows | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| execInBackground | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| viewFile | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 6 | ++ | ||
| 1 | <?php |
| 2 | |
| 3 | namespace ApprovalTests; |
| 4 | |
| 5 | class SystemUtil |
| 6 | { |
| 7 | public static function isWindows(): bool |
| 8 | { |
| 9 | // Based on http://php.net/manual/en/function.php-uname.php |
| 10 | return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; |
| 11 | } |
| 12 | |
| 13 | public static function execInBackground(string $cmd) |
| 14 | { |
| 15 | // Taken from http://php.net/manual/en/function.exec.php#86329 |
| 16 | if (self::isWindows()) { |
| 17 | pclose(popen("start /B \"needed title\" " . $cmd, "r")); |
| 18 | } else { |
| 19 | exec($cmd . " > /dev/null &"); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | public static function viewFile(string $filename) |
| 24 | { |
| 25 | if (self::isWindows()) { |
| 26 | pclose(popen("start /B \"needed title\" \"" . $filename . "\"", "r")); |
| 27 | } else { |
| 28 | exec("open \"" . $filename . "\" > /dev/null &"); |
| 29 | } |
| 30 | } |
| 31 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ CRAP | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| TextWriter | +
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+ 30 | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
| __construct | +
+
+
+ |
+ 0.00% |
+ 0 / 2 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| getExtensionWithoutDot | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| write | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| writeEmpty | +
+
+
+ |
+ 0.00% |
+ 0 / 3 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| delete | +
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ 2 | ++ | ||
| 1 | <?php namespace ApprovalTests\Writers; |
| 2 | |
| 3 | use ApprovalTests\FileUtil; |
| 4 | |
| 5 | class TextWriter implements Writer |
| 6 | { |
| 7 | private $received; |
| 8 | private $extensionWithoutDot; |
| 9 | |
| 10 | public function __construct($received, $extensionWithoutDot) |
| 11 | { |
| 12 | $this->received = $received; |
| 13 | $this->extensionWithoutDot = $extensionWithoutDot; |
| 14 | } |
| 15 | |
| 16 | public function getExtensionWithoutDot() |
| 17 | { |
| 18 | return $this->extensionWithoutDot; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Write the file to disk |
| 23 | */ |
| 24 | public function write(string $fileNameAndPath, string $approvalsFolder) |
| 25 | { |
| 26 | FileUtil::createFolderIfNotExists($approvalsFolder); |
| 27 | file_put_contents($fileNameAndPath, $this->received); |
| 28 | return $fileNameAndPath; |
| 29 | } |
| 30 | |
| 31 | public function writeEmpty(string $fileNameAndPath, string $approvalsFolder) |
| 32 | { |
| 33 | FileUtil::createFolderIfNotExists($approvalsFolder); |
| 34 | file_put_contents($fileNameAndPath, " "); |
| 35 | return $fileNameAndPath; |
| 36 | } |
| 37 | |
| 38 | public function delete(string $fileNameAndPath) |
| 39 | { |
| 40 | return unlink($fileNameAndPath); |
| 41 | } |
| 42 | } |
| + | Code Coverage |
+ |||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ |||||||
| Total | ++ | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ CRAP | ++ | n/a |
+ 0 / 0 |
+
| 1 | <?php namespace ApprovalTests\Writers; |
| 2 | |
| 3 | use ApprovalTests\Namers\Namer; |
| 4 | |
| 5 | interface Writer |
| 6 | { |
| 7 | public function getExtensionWithoutDot(); |
| 8 | |
| 9 | public function write(string $fileNameAndPath, string $approvalsFolder); |
| 10 | public function writeEmpty(string $fileNameAndPath, string $approvalsFolder); |
| 11 | |
| 12 | public function delete(string $fileNameAndPath); |
| 13 | } |
| Class | +Coverage | +
|---|---|
| ApprovalTests\Writers\TextWriter | 0% |
| Class | +CRAP | +
|---|
| Method | +Coverage | +
|---|---|
| __construct | 0% |
| getExtensionWithoutDot | 0% |
| write | 0% |
| writeEmpty | 0% |
| delete | 0% |
| Method | +CRAP | +
|---|
| + | Code Coverage |
+ ||||||||
| + | Lines |
+ Functions and Methods |
+ Classes and Traits |
+ ||||||
| Total | +
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+
|
+
+
+ |
+ 0.00% |
+ 0 / 10 |
+
+
+
+ |
+ 0.00% |
+ 0 / 5 |
+
+
+
+ |
+ 0.00% |
+ 0 / 1 |
+ |
| + | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ + | n/a |
+ 0 / 0 |
+ |
0)for(u=-1;++u 0)for(u=-1;++u","
"],col:[2,"
"],tr:[2,"","
"],td:[3,"
"],_default:[0,"",""]};function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n"," ").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return B(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=_e(v.pixelPosition,function(e,t){if(t)return t=Be(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return B(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0
"}),b},a.models.candlestickBarChart=function(){var b=a.models.historicalBarChart(a.models.candlestickBar());return b.useInteractiveGuideline(!0),b.interactiveLayer.tooltip.contentGenerator(function(a){var c=a.series[0].data,d=c.openopen: "+b.yAxis.tickFormat()(c.open)+" close: "+b.yAxis.tickFormat()(c.close)+" high "+b.yAxis.tickFormat()(c.high)+" low: "+b.yAxis.tickFormat()(c.low)+"
"}),b},a.models.legend=function(){"use strict";function b(p){function q(a,b){return"furious"!=o?"#000":m?a.disengaged?"#000":"#fff":m?void 0:(a.color||(a.color=g(a,b)),a.disabled?a.color:"#fff")}function r(a,b){return m&&"furious"==o&&a.disengaged?"#eee":a.color||g(a,b)}function s(a){return m&&"furious"==o?1:a.disabled?0:1}return p.each(function(b){var g=d-c.left-c.right,p=d3.select(this);a.utils.initSVG(p);var t=p.selectAll("g.nv-legend").data([b]),u=t.enter().append("g").attr("class","nvd3 nv-legend").append("g"),v=t.select("g");t.attr("transform","translate("+c.left+","+c.top+")");var w,x,y=v.selectAll(".nv-series").data(function(a){return"furious"!=o?a:a.filter(function(a){return m?!0:!a.disengaged})}),z=y.enter().append("g").attr("class","nv-series");switch(o){case"furious":x=23;break;case"classic":x=20}if("classic"==o)z.append("circle").style("stroke-width",2).attr("class","nv-legend-symbol").attr("r",5),w=y.select("circle");else if("furious"==o){z.append("rect").style("stroke-width",2).attr("class","nv-legend-symbol").attr("rx",3).attr("ry",3),w=y.select(".nv-legend-symbol"),z.append("g").attr("class","nv-check-box").property("innerHTML",'open: "+b.yAxis.tickFormat()(c.open)+" close: "+b.yAxis.tickFormat()(c.close)+" high "+b.yAxis.tickFormat()(c.high)+" low: "+b.yAxis.tickFormat()(c.low)+" s[c]&&(e.offsets.popper[m]+=d[m]+u-s[c]),e.offsets.popper=g(e.offsets.popper);var b=d[m]+d[l]/2-u/2,w=t(e.instance.popper),y=parseFloat(w['margin'+f]),E=parseFloat(w['border'+f+'Width']),v=b-e.offsets.popper[m]-y-E;return v=ee(Q(s[l]-u,v),0),e.arrowElement=i,e.offsets.arrow=(n={},ae(n,m,$(v)),ae(n,h,''),n),e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=v(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),n=e.placement.split('-')[0],i=T(n),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case ce.FLIP:p=[n,i];break;case ce.CLOCKWISE:p=G(n);break;case ce.COUNTERCLOCKWISE:p=G(n,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(n!==s||p.length===d+1)return e;n=e.placement.split('-')[0],i=T(n);var a=e.offsets.popper,l=e.offsets.reference,f=Z,m='left'===n&&f(a.right)>f(l.left)||'right'===n&&f(a.left)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Total
+
+
+
+
+
+
+ CRAP
+
+
+
+
+
+
+
+
+ exception_error_handler
+
+
+
+
+
+
+ 2
+
+
+
+
+
+
+
+
+ 1 <?php
+ 2
+ 3 $vendor_autoload = dirname(__FILE__) . "/../vendor/autoload.php";
+ 4 require_once($vendor_autoload);
+ 5
+ 6 function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+ 7 throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
+ 8 }
+
+
+9 set_error_handler(__NAMESPACE__ .'\exception_error_handler'); Classes
+ Coverage Distribution
+ Complexity
+ Insufficient Coverage
+ Project Risks
+ Methods
+ Coverage Distribution
+ Complexity
+ Insufficient Coverage
+ Project Risks
+
+
+
+
+
+
+
+ Method
+ CRAP
+
+ verifyAllCombinations9 156
+ getStackTrace 30
+ report 30
+ verify 20
+ __construct 20
+ isReflection 12
+ isWorkingInThisEnvironment 12
+ getFirstWorking 12
+ report 12
+ isWorkingInThisEnvironment 12
+ ksortRecursive 12
+ verifyTransformedList 6
+ verifyList 6
+ createFileIfNotExists 6
+ createFolderIfNotExists 6
+ isPHPUnitTest 6
+ endsWith 6
+ getCommandLineFor 6
+ copyToClipboard 6
+ resolveWindowsPath 6
+ getInstance 6
+ execInBackground 6
+
+
+ viewFile 6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Total
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Namers
+
+
+
+
+
+
+
+
+
+
+
+
+ Reporters
+
+
+
+
+
+
+
+
+
+
+
+
+ Writers
+
+
+
+
+
+
+
+
+
+
+
+
+ ApprovalMismatchException.php
+
+
+
+
+
+
+
+
+
+
+
+
+ Approvals.php
+
+
+
+
+
+
+
+
+
+
+
+
+ CombinationApprovals.php
+
+
+
+
+
+
+
+
+
+
+
+
+ FileApprover.php
+
+
+
+
+
+
+
+
+
+
+
+
+ FileUtil.php
+
+
+
+
+
+
+
+
+
+
+
+
+ SortingUtil.php
+
+
+
+
+
+
+
+
+
+
+
+
+ SystemUtil.php
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ autoload.php
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- ApprovalMismatchException
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests;
- 4
- 5 use Exception;
- 6
- 7 class ApprovalMismatchException extends Exception
- 8 {
- 9 public function __construct($approvedFilename, $receivedFilename)
- 10 {
- 11 parent::__construct("The approved file does not match the received file\nApproved: $approvedFilename\nReceived: $receivedFilename");
- 12 }
-
-
-13 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- Approvals
-
-
-
-
-
-
- 306
-
-
-
-
-
-
- verifyString
-
-
-
-
-
-
- 2
-
-
-
-
- verifyStringWithFileExtension
-
-
-
-
-
-
- 2
-
-
-
-
- getReporter
-
-
-
-
-
-
- 2
-
-
-
-
- verify
-
-
-
-
-
-
- 20
-
-
-
-
- verifyTransformedList
-
-
-
-
-
-
- 6
-
-
-
-
- verifyList
-
-
-
-
-
-
- 6
-
-
-
-
- verifyHtml
-
-
-
-
-
-
- 2
-
-
-
-
- approveString
-
-
-
-
-
-
- 2
-
-
-
-
- approveList
-
-
-
-
-
-
- 2
-
-
-
-
- approveHtml
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAsJson
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- satisfyPHPUnitRequirementForAssert
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests;
- 2
- 3 use ApprovalTests\Reporters\DiffReporter;
- 4 use ApprovalTests\Writers\Writer;
- 5 use ApprovalTests\Writers\TextWriter;
- 6 use ApprovalTests\Reporters\Reporter;
- 7 use ApprovalTests\Namers\PHPUnitNamer;
- 8 use ApprovalTests\Namers\Namer;
- 9 use PHPUnit\Framework\Assert;
- 10
- 11 class Approvals
- 12 {
- 13 public static function verifyString($received, Reporter $reporter = null)
- 14 {
- 15 self::verifyStringWithFileExtension($received, 'txt', $reporter);
- 16 }
- 17
- 18 public static function verifyStringWithFileExtension($received, $extensionWithoutDot, Reporter $reporter = null)
- 19 {
- 20 self::verify(new TextWriter($received, $extensionWithoutDot), new PHPUnitNamer(), $reporter);
- 21 }
- 22
- 23 public static function getReporter()
- 24 {
- 25 return new DiffReporter();
- 26 }
- 27
- 28 /**
- 29 * Perform the approval test by comparing the contents of one file to another
- 30 */
- 31 public static function verify(Writer $writer, Namer $namer, Reporter $reporter = null)
- 32 {
- 33 self::satisfyPHPUnitRequirementForAssert();
- 34 if ($reporter == null) {
- 35 $reporter = self::getReporter();
- 36 }
- 37
- 38 $extension = $writer->getExtensionWithoutDot();
- 39 $approvedFilename = $namer->getApprovedFile($extension);
- 40 if (!file_exists($approvedFilename)) {
- 41 $writer->writeEmpty(
- 42 $namer->getApprovedFile($extension),
- 43 $namer->getApprovalsDirectory());
- 44 }
- 45
- 46 $receivedFilename = $writer->write(
- 47 $namer->getReceivedFile($extension),
- 48 $namer->getApprovalsDirectory());
- 49
- 50 $matching = FileApprover::checkFiles($approvedFilename, $receivedFilename);
- 51
- 52 if ($matching) {
- 53 $writer->delete($receivedFilename);
- 54 }
- 55 else {
- 56 $reporter->report($approvedFilename, $receivedFilename);
- 57 throw new ApprovalMismatchException($approvedFilename, $receivedFilename);
- 58 }
- 59 }
- 60
- 61 public static function verifyTransformedList(array $list, $callbackObject, $methodName, $reporter = null)
- 62 {
- 63 $string = '';
- 64 foreach ($list as $item) {
- 65 $string .= $item . ' -> ' . $callbackObject->$methodName($item) . "\n";
- 66 }
- 67 self::verifyString($string, $reporter);
- 68 }
- 69
- 70 public static function verifyList(array $list, $reporter = null)
- 71 {
- 72 $string = '';
- 73 foreach ($list as $key => $item) {
- 74 $string .= '[' . $key . '] -> ' . $item . "\n";
- 75 }
- 76 self::verifyString($string, $reporter);
- 77 }
- 78
- 79 public static function verifyHtml($html, $reporter = null)
- 80 {
- 81 self::verifyStringWithFileExtension($html, 'html', $reporter);
- 82 }
- 83
- 84 /**
- 85 * @param $received
- 86 * @deprecated Use verifyString instead.
- 87 */
- 88 public static function approveString($received)
- 89 {
- 90 self::verifyString($received);
- 91 }
- 92
- 93 /**
- 94 * @param array $list
- 95 * @deprecated Use verifyList instead.
- 96 */
- 97 public static function approveList(array $list)
- 98 {
- 99 self::verifyList($list);
- 100 }
- 101
- 102 /**
- 103 * @param $html
- 104 * @deprecated Use verifyHtml instead.
- 105 */
- 106 public static function approveHtml($html)
- 107 {
- 108 self::verifyHtml($html);
- 109 }
- 110
- 111 /**
- 112 * @param mixed $data
- 113 * @param Reporter $reporter
- 114 * @throws ApprovalMismatchException
- 115 */
- 116 public static function verifyAsJson($data, $reporter = null)
- 117 {
- 118 $json = json_encode(SortingUtil::orderFieldNamesAlphabetically($data), JSON_PRETTY_PRINT);
- 119 self::verifyStringWithFileExtension($json, 'json', $reporter);
- 120 }
- 121
- 122 private static function satisfyPHPUnitRequirementForAssert()
- 123 {
- 124 Assert::assertTrue(true);
- 125 }
-
-
-126 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- SkipCombinationException
-
-
-
-
-
-
- 0
-
-
-
-
-
-
- CombinationApprovals
-
-
-
-
-
-
- 462
-
-
-
-
-
-
- verifyAllCombinations1
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations2
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations3
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations4
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations5
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations6
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations7
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations8
-
-
-
-
-
-
- 2
-
-
-
-
- verifyAllCombinations9
-
-
-
-
-
-
- 156
-
-
-
-
-
-
- displayArguments
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests;
- 4
- 5 use ApprovalTests\Reporters\Reporter;
- 6
- 7 class SkipCombinationException extends \Exception {
- 8 }
- 9
- 10 class CombinationApprovals
- 11 {
- 12 static $empty = ["CombinationApprovalsEmpty"];
- 13
- 14 public static function verifyAllCombinations1($param, array $values, Reporter $reporter = null)
- 15 {
- 16 self::verifyAllCombinations9($param, $values, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter);
- 17 }
- 18
- 19 public static function verifyAllCombinations2($param, array $values1, array $values2, Reporter $reporter = null)
- 20 {
- 21 self::verifyAllCombinations9($param, $values1, $values2, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter);
- 22 }
- 23
- 24 public static function verifyAllCombinations3($param, array $values1, array $values2, array $values3, Reporter $reporter = null)
- 25 {
- 26 self::verifyAllCombinations9($param, $values1, $values2, $values3, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter);
- 27 }
- 28
- 29 public static function verifyAllCombinations4($param, array $values1, array $values2, array $values3, array $values4, Reporter $reporter = null)
- 30 {
- 31 self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, self::$empty, self::$empty, self::$empty, self::$empty, self::$empty, $reporter);
- 32 }
- 33
- 34 public static function verifyAllCombinations5($param, array $values1, array $values2, array $values3, array $values4, array $values5, Reporter $reporter = null)
- 35 {
- 36 self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, self::$empty, self::$empty, self::$empty, self::$empty, $reporter);
- 37 }
- 38
- 39 public static function verifyAllCombinations6($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, Reporter $reporter = null)
- 40 {
- 41 self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, $values6, self::$empty, self::$empty, self::$empty, $reporter);
- 42 }
- 43
- 44 public static function verifyAllCombinations7($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, array $values7, Reporter $reporter = null)
- 45 {
- 46 self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, $values6, $values7, self::$empty, self::$empty, $reporter);
- 47 }
- 48
- 49 public static function verifyAllCombinations8($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, array $values7, array $values8, Reporter $reporter = null)
- 50 {
- 51 self::verifyAllCombinations9($param, $values1, $values2, $values3, $values4, $values5, $values6, $values7, $values8, self::$empty, $reporter);
- 52 }
- 53
- 54 public static function verifyAllCombinations9($param, array $values1, array $values2, array $values3, array $values4, array $values5, array $values6, array $values7, array $values8, array $values9, Reporter $reporter = null)
- 55 {
- 56 $output = '';
- 57 foreach ($values1 as $i1) {
- 58 foreach ($values2 as $i2) {
- 59 foreach ($values3 as $i3) {
- 60 foreach ($values4 as $i4) {
- 61 foreach ($values5 as $i5) {
- 62 foreach ($values6 as $i6) {
- 63 foreach ($values7 as $i7) {
- 64 foreach ($values8 as $i8) {
- 65 foreach ($values9 as $i9) {
- 66 $thisOutput = self::displayArguments($i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9);
- 67 try {
- 68 $thisOutput .= $param($i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9);
- 69 } catch (SkipCombinationException $e) {
- 70 continue;
- 71 } catch (\Exception $e) {
- 72 $thisOutput .= get_class($e) . ' thrown: ' . $e->getMessage();
- 73 }
- 74 $output .= $thisOutput . "\n";
- 75 }
- 76 }
- 77 }
- 78 }
- 79 }
- 80 }
- 81 }
- 82 }
- 83 }
- 84 Approvals::verifyString($output, $reporter);
- 85 }
- 86
- 87 public static function displayArguments(...$args): string
- 88 {
- 89 return '[' . implode(', ', array_filter($args, function($i) { return $i !== self::$empty[0]; })) . "] => ";
- 90 }
-
-
-91 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- FileApprover
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- checkFiles
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- clean
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests;
- 4
- 5 class FileApprover
- 6 {
- 7 public static function checkFiles(string $approvedFilename, string $receivedFilename): bool
- 8 {
- 9 $approvedContents = FileApprover::clean(file_get_contents($approvedFilename));
- 10 $receivedContents = FileApprover::clean(file_get_contents($receivedFilename));
- 11
- 12 return $approvedContents === $receivedContents;
- 13 }
- 14
- 15 private static function clean(string $contents): string
- 16 {
- 17 return str_replace("\r\n", "\n", $contents);
- 18 }
-
-
-19 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- FileUtil
-
-
-
-
-
-
- 20
-
-
-
-
-
-
- createFileIfNotExists
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- createFolderIfNotExists
-
-
-
-
-
-
- 6
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests;
- 2
- 3 class FileUtil
- 4 {
- 5 public static function createFileIfNotExists($filename)
- 6 {
- 7 if (!file_exists($filename)) {
- 8 return touch($filename);
- 9 }
- 10 }
- 11
- 12 public static function createFolderIfNotExists($approvalsFolder)
- 13 {
- 14 if (!is_dir($approvalsFolder)) {
- 15 return mkdir($approvalsFolder);
- 16 }
- 17 }
-
-
-18 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests\Namers;
- 2
- 3 interface Namer
- 4 {
- 5 public function getApprovedFile($extensionWithoutDot);
- 6 public function getReceivedFile($extensionWithoutDot);
- 7 public function getCallingTestClassName();
- 8 public function getCallingTestClassNameWithoutNamespace();
- 9 public function getCallingTestMethodName();
- 10 public function getCallingTestDirectory();
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- StackTraceMetadata
-
-
-
-
-
-
- 156
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 20
-
-
-
-
- isPHPUnitTest
-
-
-
-
-
-
- 6
-
-
-
-
- isReflection
-
-
-
-
-
-
- 12
-
-
-
-
- endsWith
-
-
-
-
-
-
- 6
-
-
-
-
- __toString
-
-
-
-
-
-
- 2
-
-
-
-
- PHPUnitNamer
-
-
-
-
-
-
- 210
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
- getStackTrace
-
-
-
-
-
-
- 30
-
-
-
-
- getApprovedFile
-
-
-
-
-
-
- 2
-
-
-
-
- getReceivedFile
-
-
-
-
-
-
- 2
-
-
-
-
- getFile
-
-
-
-
-
-
- 2
-
-
-
-
- getCallingTestClassName
-
-
-
-
-
-
- 2
-
-
-
-
- getCallingTestClassNameWithoutNamespace
-
-
-
-
-
-
- 2
-
-
-
-
- getCallingTestMethodName
-
-
-
-
-
-
- 2
-
-
-
-
- getCallingTestDirectory
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- getApprovalsDirectory
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests\Namers;
- 2
- 3 class StackTraceMetadata
- 4 {
- 5 /**
- 6 * @var bool
- 7 */
- 8 public $isPHPUnitTest;
- 9
- 10 /**
- 11 * @var bool
- 12 */
- 13 public $isReflection;
- 14
- 15 /**
- 16 * @var string|null
- 17 */
- 18 public $testDirectory;
- 19
- 20 public $class;
- 21
- 22 public $function;
- 23
- 24 /**
- 25 * @var array
- 26 */
- 27 public $stackTraceLine;
- 28
- 29 public function __construct(array $stackTraceLine, array $prevStackTraceLine) {
- 30 if (array_key_exists('file', $stackTraceLine)) {
- 31 $this->isPHPUnitTest = self::isPHPUnitTest($stackTraceLine['file']);
- 32 } else {
- 33 $this->isPHPUnitTest = false;
- 34 }
- 35 if (array_key_exists('file', $prevStackTraceLine)) {
- 36 $this->testDirectory = dirname($prevStackTraceLine['file']);
- 37 } else {
- 38 $this->testDirectory = null;
- 39 }
- 40 $this->isReflection = self::isReflection($stackTraceLine);
- 41 $this->stackTraceLine = $stackTraceLine;
- 42 $clazz = isset($stackTraceLine['class']) ? $stackTraceLine['class'] : '';
- 43 $this->class = $clazz;
- 44 $this->function = $stackTraceLine['function'];
- 45 }
- 46
- 47 public static function isPHPUnitTest($path)
- 48 {
- 49 $expectedLocalPath = implode(DIRECTORY_SEPARATOR, ['', 'phpunit', 'src', 'Framework', 'TestCase.php']);
- 50 $expectedPharPath = implode('/', ['', 'phpunit', 'Framework', 'TestCase.php']);
- 51 return self::endsWith($path, $expectedLocalPath) || self::endsWith($path, $expectedPharPath);
- 52 }
- 53
- 54 public static function isReflection($stackTraceLine)
- 55 {
- 56 $clazz = isset($stackTraceLine['class']) ? $stackTraceLine['class'] : '';
- 57 return $clazz === 'ReflectionMethod' && $stackTraceLine['function'] === 'invokeArgs';
- 58 }
- 59
- 60 private static function endsWith($haystack, $needle)
- 61 {
- 62 // https://stackoverflow.com/a/834355/25507
- 63 $length = strlen($needle);
- 64 if ($length == 0) {
- 65 return true;
- 66 }
- 67
- 68 return substr($haystack, -$length) === $needle;
- 69 }
- 70
- 71 public function __toString(): string {
- 72 return "[PHPUnit,class,method,reflection,testDirectory]="
- 73 ."[{$this->isPHPUnitTest},{$this->class},{$this->function},{$this->isReflection},{$this->testDirectory}]";
- 74 }
- 75 }
- 76
- 77 class PHPUnitNamer implements Namer
- 78 {
- 79 private $caller;
- 80 private $testDirectory;
- 81
- 82 /**
- 83 * PHPUnitNamer constructor.
- 84 * @throws \Exception
- 85 */
- 86 public function __construct()
- 87 {
- 88 $metadata = self::getStackTrace();
- 89 $this->caller = $metadata->stackTraceLine;
- 90 $this->testDirectory = $metadata->testDirectory;
- 91 }
- 92
- 93 private static function getStackTrace()
- 94 {
- 95 $stackTraceLines = debug_backtrace(false);
- 96 $stackTraceMetadata = [];
- 97 for ($i = 1; $i < count($stackTraceLines); $i++) {
- 98 $metadata = new StackTraceMetadata($stackTraceLines[$i], $stackTraceLines[$i - 1]);
- 99 $stackTraceMetadata[] = $metadata;
- 100 }
- 101 for ($i = 0; $i < count($stackTraceMetadata); $i++) {
- 102 $metadata = $stackTraceMetadata[$i];
- 103 if ($metadata->isPHPUnitTest) {
- 104 return $stackTraceMetadata[$metadata->isReflection ? $i - 1 : $i];
- 105 }
- 106 }
- 107 throw new \Exception("Failed to identify the testing framework you are using; currently PHPUnit 5-8 is supported. Please raise a bug if you find this.");
- 108 }
- 109
- 110 public function getApprovedFile($extensionWithoutDot)
- 111 {
- 112 return $this->getFile('approved', $extensionWithoutDot);
- 113 }
- 114
- 115 public function getReceivedFile($extensionWithoutDot)
- 116 {
- 117 return $this->getFile('received', $extensionWithoutDot);
- 118 }
- 119
- 120 private function getFile($status, $extensionWithoutDot)
- 121 {
- 122 return $this->getApprovalsDirectory()
- 123 . DIRECTORY_SEPARATOR . $this->getCallingTestClassNameWithoutNamespace()
- 124 . '.' . $this->getCallingTestMethodName()
- 125 . '.' . $status
- 126 . '.' . $extensionWithoutDot;
- 127 }
- 128
- 129 public function getCallingTestClassName()
- 130 {
- 131 return $this->caller['class'];
- 132 }
- 133
- 134 public function getCallingTestClassNameWithoutNamespace()
- 135 {
- 136 return array_values(
- 137 array_slice(
- 138 explode('\\', $this->getCallingTestClassName()),
- 139 -1
- 140 ))[0];
- 141 }
- 142
- 143 public function getCallingTestMethodName()
- 144 {
- 145 return $this->caller['function'];
- 146 }
- 147
- 148 public function getCallingTestDirectory()
- 149 {
- 150 return $this->testDirectory;
- 151 }
- 152
- 153 public function getApprovalsDirectory()
- 154 {
- 155 return $this->getCallingTestDirectory() . DIRECTORY_SEPARATOR . 'approvals';
- 156 }
-
-
-157 } Classes
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Class
- Coverage
-
- ApprovalTests\Namers\StackTraceMetadata 0%
-
-
- ApprovalTests\Namers\PHPUnitNamer 0% Project Risks
-
-
-
-
-
-
-
- Class
- CRAP
-
- ApprovalTests\Namers\PHPUnitNamer 210
-
-
- ApprovalTests\Namers\StackTraceMetadata 156 Methods
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Method
- Coverage
-
- __construct 0%
- isPHPUnitTest 0%
- isReflection 0%
- endsWith 0%
- __toString 0%
- __construct 0%
- getStackTrace 0%
- getApprovedFile 0%
- getReceivedFile 0%
- getFile 0%
- getCallingTestClassName 0%
- getCallingTestClassNameWithoutNamespace 0%
- getCallingTestMethodName 0%
- getCallingTestDirectory 0%
-
-
- getApprovalsDirectory 0% Project Risks
-
-
-
-
-
-
-
- Method
- CRAP
-
- getStackTrace 30
- __construct 20
- isReflection 12
- isPHPUnitTest 6
-
-
- endsWith 6
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
-
- Namer.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PHPUnitNamer.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- ClipboardReporter
-
-
-
-
-
-
- 42
-
-
-
-
-
-
- getCommandLineFor
-
-
-
-
-
-
- 6
-
-
-
-
- report
-
-
-
-
-
-
- 2
-
-
-
-
- copyToClipboard
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- isWorkingInThisEnvironment
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 use ApprovalTests\SystemUtil;
- 6
- 7 class ClipboardReporter implements Reporter
- 8 {
- 9 public static function getCommandLineFor(string $approvedFilename, string $receivedFilename, bool $isWindows)
- 10 {
- 11 if ($isWindows) {
- 12 return "move /Y \"$receivedFilename\" \"$approvedFilename\"";
- 13 } else {
- 14 return "mv \"$receivedFilename\" \"$approvedFilename\"";
- 15 }
- 16 }
- 17
- 18 public function report($approvedFilename, $receivedFilename)
- 19 {
- 20 $commandLine = self::getCommandLineFor($approvedFilename, $receivedFilename, SystemUtil::isWindows());
- 21 self::copyToClipboard($commandLine);
- 22 }
- 23
- 24 public static function copyToClipboard(string $newClipboardText)
- 25 {
- 26 $clipboardCommand = SystemUtil::isWindows() ? "clip" : "pbclip";
- 27 $cmd = "echo " . $newClipboardText . " | " . $clipboardCommand;
- 28 shell_exec($cmd);
- 29 }
- 30
- 31 public function isWorkingInThisEnvironment($receivedFilename)
- 32 {
- 33 return true;
- 34 }
-
-
-35 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- CombinationReporter
-
-
-
-
-
-
- 90
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
- report
-
-
-
-
-
-
- 30
-
-
-
-
-
-
- isWorkingInThisEnvironment
-
-
-
-
-
-
- 12
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 use Exception;
- 6
- 7 class CombinationReporter
- 8 {
- 9 /**
- 10 * @var Reporter[]
- 11 */
- 12 private $reporters;
- 13
- 14 /**
- 15 * @param Reporter[] $reporters
- 16 */
- 17 public function __construct(...$reporters)
- 18 {
- 19 $this->reporters = $reporters;
- 20 }
- 21
- 22 public function report($approvedFilename, $receivedFilename)
- 23 {
- 24 $exception = null;
- 25 foreach ($this->reporters as $reporter) {
- 26 if ($reporter->isWorkingInThisEnvironment($receivedFilename)) {
- 27 try {
- 28 $reporter->report($approvedFilename, $receivedFilename);
- 29 } catch (Exception $e) {
- 30 $exception = $e;
- 31 }
- 32 }
- 33 }
- 34 if ($exception) {
- 35 throw $exception;
- 36 }
- 37 }
- 38
- 39 public function isWorkingInThisEnvironment($receivedFilename)
- 40 {
- 41 foreach ($this->reporters as $reporter) {
- 42 if ($reporter->isWorkingInThisEnvironment($receivedFilename)) {
- 43 return true;
- 44 }
- 45 }
- 46 return false;
- 47 }
-
-
-48 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- DiffInfo
-
-
-
-
-
-
- 72
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
- resolveWindowsPath
-
-
-
-
-
-
- 6
-
-
-
-
- getPathInProgramFilesX86
-
-
-
-
-
-
- 2
-
-
-
-
- getFirstWorking
-
-
-
-
-
-
- 12
-
-
-
-
-
-
- getProgramFilesPaths
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 class DiffInfo
- 6 {
- 7 public $diffProgram;
- 8 public $parameters;
- 9 public $fileExtensions;
- 10
- 11 public function __construct(string $diffProgram, array $fileExtensions, string $parameters = null)
- 12 {
- 13 $this->diffProgram = self::resolveWindowsPath($diffProgram);
- 14 $this->parameters = $parameters ?? GenericDiffReporter::$STANDARD_ARGUMENTS;
- 15 $this->fileExtensions = $fileExtensions;
- 16 }
- 17
- 18 private static function resolveWindowsPath(string $diffProgram): string
- 19 {
- 20 $tag = "{ProgramFiles}";
- 21
- 22 $startsWith = substr($diffProgram, 0, strlen($tag)) === $tag;
- 23 if ($startsWith) {
- 24 $diffProgram = self::getPathInProgramFilesX86(substr($diffProgram, strlen($tag)));
- 25 }
- 26 return $diffProgram;
- 27 }
- 28
- 29 private static function getPathInProgramFilesX86(string $path): string
- 30 {
- 31 $paths = self::getProgramFilesPaths();
- 32 return self::getFirstWorking($path, $paths, "C:\\Program Files\\");
- 33 }
- 34
- 35 public static function getFirstWorking(string $path, array $paths, string $ifNotFoundDefault): string
- 36 {
- 37 $fullPath = $ifNotFoundDefault . $path;
- 38 foreach ($paths as $p) {
- 39 $fullPath = $p . DIRECTORY_SEPARATOR . $path;
- 40 if (file_exists($fullPath)) {
- 41 break;
- 42 }
- 43 }
- 44 return $fullPath;
- 45 }
- 46
- 47 public static function getProgramFilesPaths(): array
- 48 {
- 49 $paths = [
- 50 getenv("ProgramFiles(x86)"),
- 51 getenv("ProgramFiles"),
- 52 getenv("ProgramW6432"),
- 53 // Programs like Beyond Compare 4 that support per-user installation
- 54 // will likely install themselves here.
- 55 getenv("LocalAppData"),
- 56 ];
- 57 return array_unique(array_filter($paths));
- 58 }
-
-
-59 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- DiffPrograms
-
-
-
-
-
-
- 42
-
-
-
-
-
-
- getInstance
-
-
-
-
-
-
- 6
-
-
-
-
- Text
-
-
-
-
-
-
- 2
-
-
-
-
- Image
-
-
-
-
-
-
- 2
-
-
-
-
- TextAndImage
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 class DiffPrograms
- 6 {
- 7 private static $instance = null;
- 8
- 9 public static function getInstance(): DiffPrograms {
- 10 if (!self::$instance) {
- 11 self::$instance = new DiffPrograms();
- 12 }
- 13 return self::$instance;
- 14 }
- 15
- 16 /**
- 17 * @var DiffInfo[]
- 18 */
- 19 public $MacDiffPrograms;
- 20
- 21 /**
- 22 * @var DiffInfo[]
- 23 */
- 24 public $WindowsDiffPrograms;
- 25
- 26 public static function Text()
- 27 {
- 28 return GenericDiffReporter::$TEXT_FILE_EXTENSIONS;
- 29 }
- 30
- 31 public static function Image()
- 32 {
- 33 return GenericDiffReporter::$IMAGE_FILE_EXTENSIONS;
- 34 }
- 35
- 36 public static function TextAndImage()
- 37 {
- 38 return array_merge(self::Text(), self::Image());
- 39 }
- 40
- 41 private function __construct()
- 42 {
- 43 $this->MacDiffPrograms = [
- 44 'DIFF_MERGE' => new DiffInfo(
- 45 "/Applications/DiffMerge.app/Contents/MacOS/DiffMerge", DiffPrograms::Text(), "%s %s -nosplash"),
- 46 'BEYOND_COMPARE' => new DiffInfo(
- 47 "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", DiffPrograms::Text()),
- 48 'KALEIDOSCOPE' => new DiffInfo(
- 49 "/Applications/Kaleidoscope.app/Contents/MacOS/ksdiff", DiffPrograms::TextAndImage()),
- 50 'KDIFF3' => new DiffInfo("/Applications/kdiff3.app/Contents/MacOS/kdiff3",
- 51 DiffPrograms::Text(), "%s %s -m"),
- 52 'P4MERGE' => new DiffInfo("/Applications/p4merge.app/Contents/MacOS/p4merge",
- 53 DiffPrograms::TextAndImage()),
- 54 'TK_DIFF' => new DiffInfo("/Applications/TkDiff.app/Contents/MacOS/tkdiff",
- 55 DiffPrograms::Text()),
- 56 'VISUAL_STUDIO_CODE' => new DiffInfo(
- 57 "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", DiffPrograms::Text(), "-d %s %s"),
- 58 ];
- 59
- 60 $this->WindowsDiffPrograms = [
- 61 'BEYOND_COMPARE_3' => new DiffInfo("{ProgramFiles}Beyond Compare 3\\BCompare.exe",
- 62 DiffPrograms::TextAndImage()),
- 63 'BEYOND_COMPARE_4' => new DiffInfo("{ProgramFiles}Beyond Compare 4\\BCompare.exe",
- 64 DiffPrograms::TextAndImage()),
- 65 'TORTOISE_IMAGE_DIFF' => new DiffInfo("{ProgramFiles}TortoiseSVN\\bin\\TortoiseIDiff.exe",
- 66 DiffPrograms::Image(), "/left:%s /right:%s"),
- 67 'TORTOISE_TEXT_DIFF' => new DiffInfo("{ProgramFiles}TortoiseSVN\\bin\\TortoiseMerge.exe",
- 68 DiffPrograms::Text()),
- 69 'WIN_MERGE' => new DiffInfo("{ProgramFiles}WinMerge\\WinMergeU.exe", DiffPrograms::Text()),
- 70 'ARAXIS_MERGE' => new DiffInfo("{ProgramFiles}Araxis\\Araxis Merge\\Compare.exe",
- 71 DiffPrograms::Text()),
- 72 'CODE_COMPARE' => new DiffInfo(
- 73 "{ProgramFiles}Devart\\Code Compare\\CodeCompare.exe", DiffPrograms::Text()),
- 74 'KDIFF3' => new DiffInfo("{ProgramFiles}KDiff3\\kdiff3.exe", DiffPrograms::Text()),
- 75 'VISUAL_STUDIO_CODE' => new DiffInfo("{ProgramFiles}Microsoft VS Code\\Code.exe",
- 76 DiffPrograms::Text(), "-d %s %s"),
- 77 'MELD' => new DiffInfo("{ProgramFiles}Meld\\Meld.exe", DiffPrograms::Text()),
- 78 ];
- 79 }
-
-
-80 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- DiffReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 use ApprovalTests\Reporters\Mac\MacDiffReporter;
- 6 use ApprovalTests\Reporters\Windows\WindowsDiffReporter;
- 7
- 8 class DiffReporter extends FirstWorkingReporter
- 9 {
- 10 public function __construct()
- 11 {
- 12 parent::__construct(new MacDiffReporter(), new WindowsDiffReporter(), new PHPUnitReporter());
- 13 }
-
-
-14 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- FileLaunchReporter
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- report
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- isWorkingInThisEnvironment
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 use ApprovalTests\SystemUtil;
- 6
- 7 class FileLaunchReporter implements Reporter
- 8 {
- 9 public function report($approvedFilename, $receivedFilename)
- 10 {
- 11 SystemUtil::viewFile($receivedFilename);
- 12 }
- 13
- 14 public function isWorkingInThisEnvironment($receivedFilename)
- 15 {
- 16 return true;
- 17 }
-
-
-18 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- FirstWorkingReporter
-
-
-
-
-
-
- 56
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
- report
-
-
-
-
-
-
- 12
-
-
-
-
-
-
- isWorkingInThisEnvironment
-
-
-
-
-
-
- 12
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 class FirstWorkingReporter implements Reporter
- 6 {
- 7 /**
- 8 * @var Reporter[]
- 9 */
- 10 private $reporters;
- 11
- 12 /**
- 13 * @param Reporter[] $reporters
- 14 */
- 15 public function __construct(...$reporters)
- 16 {
- 17 $this->reporters = $reporters;
- 18 }
- 19
- 20 public function report($approvedFilename, $receivedFilename)
- 21 {
- 22 foreach ($this->reporters as $reporter) {
- 23 if ($reporter->isWorkingInThisEnvironment($receivedFilename)) {
- 24 $reporter->report($approvedFilename, $receivedFilename);
- 25 return;
- 26 }
- 27 }
- 28 }
- 29
- 30 public function isWorkingInThisEnvironment($receivedFilename)
- 31 {
- 32 foreach ($this->reporters as $reporter) {
- 33 if ($reporter->isWorkingInThisEnvironment($receivedFilename)) {
- 34 return true;
- 35 }
- 36 }
- 37 return false;
- 38 }
-
-
-39 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- GenericDiffReporter
-
-
-
-
-
-
- 12
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
- report
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- isWorkingInThisEnvironment
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 use ApprovalTests\SystemUtil;
- 6
- 7 class GenericDiffReporter implements Reporter
- 8 {
- 9 public static $STANDARD_ARGUMENTS = "%s %s";
- 10 public static $TEXT_FILE_EXTENSIONS = [".txt", ".csv", ".htm", ".html", ".xml", ".eml",
- 11 ".java", ".css", ".js", ".json"];
- 12 public static $IMAGE_FILE_EXTENSIONS = [".png", ".gif", ".jpg", ".jpeg", ".bmp", ".tif",
- 13 ".tiff"];
- 14
- 15 private $diffProgram;
- 16 private $fileExtensions;
- 17 private $parameters;
- 18
- 19 public function __construct(string $diffProgram, array $fileExtensions, string $parameters) {
- 20 $this->diffProgram = $diffProgram;
- 21 $this->fileExtensions = $fileExtensions;
- 22 $this->parameters = $parameters;
- 23 }
- 24
- 25 public function report($approvedFilename, $receivedFilename)
- 26 {
- 27 SystemUtil::execInBackground(sprintf('"%s" ' . $this->parameters, $this->diffProgram, $receivedFilename, $approvedFilename));
- 28 }
- 29
- 30 public function isWorkingInThisEnvironment($receivedFilename)
- 31 {
- 32 return is_executable($this->diffProgram);
- 33 }
-
-
-34 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- BeyondCompareReporterMac
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 class BeyondCompareReporterMac extends MacDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('BEYOND_COMPARE');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- DiffMergeReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 class DiffMergeReporter extends MacDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('DIFF_MERGE');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- KDiff3ReporterMac
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 class KDiff3ReporterMac extends MacDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('KDIFF3');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- KaleidoscopeReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 class KaleidoscopeReporter extends MacDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('KALEIDOSCOPE');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- MacDiffInfoReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 use ApprovalTests\Reporters\DiffPrograms;
- 6 use ApprovalTests\Reporters\GenericDiffReporter;
- 7
- 8 class MacDiffInfoReporter extends GenericDiffReporter
- 9 {
- 10 public function __construct(string $diffInfoName)
- 11 {
- 12 $diffInfo = DiffPrograms::getInstance()->MacDiffPrograms[$diffInfoName];
- 13 parent::__construct($diffInfo->diffProgram, $diffInfo->fileExtensions, $diffInfo->parameters);
- 14 }
-
-
-15 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- MacDiffReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 use ApprovalTests\Reporters\FirstWorkingReporter;
- 6
- 7 class MacDiffReporter extends FirstWorkingReporter
- 8 {
- 9 public function __construct()
- 10 {
- 11 parent::__construct(
- 12 new BeyondCompareReporterMac(),
- 13 new KaleidoscopeReporter(),
- 14 new DiffMergeReporter(),
- 15 new P4MergeReporter(),
- 16 new TkDiffReporter(),
- 17 new KDiff3ReporterMac());
- 18 }
-
-
-19 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- P4MergeReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 class P4MergeReporter extends MacDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('P4MERGE');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- TkDiffReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Mac;
- 4
- 5 class TkDiffReporter extends MacDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('TK_DIFF');
- 10 }
-
-
-11 } Classes
- Coverage Distribution
- Complexity
- Insufficient Coverage
- Project Risks
-
-
-
-
-
-
-
-
-
- Class
- CRAP
- Methods
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Method
- Coverage
-
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
-
-
- __construct 0% Project Risks
-
-
-
-
-
-
-
-
-
- Method
- CRAP
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
-
- BeyondCompareReporterMac.php
-
-
-
-
-
-
-
-
-
-
-
-
- DiffMergeReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- KDiff3ReporterMac.php
-
-
-
-
-
-
-
-
-
-
-
-
- KaleidoscopeReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- MacDiffInfoReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- MacDiffReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- P4MergeReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TkDiffReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- PHPUnitReporter
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- report
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- isWorkingInThisEnvironment
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests\Reporters;
- 2
- 3 use PHPUnit\Framework\Assert;
- 4
- 5 class PHPUnitReporter implements Reporter
- 6 {
- 7 public function report($approvedFilename, $receivedFilename)
- 8 {
- 9 $approvedContents = file_get_contents($approvedFilename);
- 10 $receivedContents = file_get_contents($receivedFilename);
- 11 Assert::assertEquals($approvedContents, $receivedContents);
- 12 }
- 13
- 14 public function isWorkingInThisEnvironment($receivedFilename)
- 15 {
- 16 return true;
- 17 }
-
-
-18 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- QuietReporter
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- report
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- isWorkingInThisEnvironment
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters;
- 4
- 5 class QuietReporter implements Reporter
- 6 {
- 7 public function report($approvedFilename, $receivedFilename)
- 8 {
- 9 }
- 10
- 11 public function isWorkingInThisEnvironment($receivedFilename)
- 12 {
- 13 return true;
- 14 }
-
-
-15 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests\Reporters;
- 2
- 3 interface Reporter
- 4 {
- 5 public function report($approvedFilename, $receivedFilename);
- 6 public function isWorkingInThisEnvironment($receivedFilename);
-
-
-7 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- AraxisMergeReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class AraxisMergeReporter extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('ARAXIS_MERGE');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- BeyondCompare3ReporterWindows
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class BeyondCompare3ReporterWindows extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('BEYOND_COMPARE_3');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- BeyondCompare4ReporterWindows
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class BeyondCompare4ReporterWindows extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('BEYOND_COMPARE_4');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- BeyondCompareReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 use ApprovalTests\Reporters\FirstWorkingReporter;
- 6
- 7 class BeyondCompareReporter extends FirstWorkingReporter
- 8 {
- 9 public function __construct()
- 10 {
- 11 parent::__construct(new BeyondCompare4ReporterWindows(), new BeyondCompare3ReporterWindows());
- 12 }
-
-
-13 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- CodeCompareReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class CodeCompareReporter extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('CODE_COMPARE');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- KDiff3ReporterWindows
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class KDiff3ReporterWindows extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct() {
- 8 parent::__construct('KDIFF3');
- 9 }
-
-
-10 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- MeldReporterWindows
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class MeldReporterWindows extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct() {
- 8 parent::__construct('MELD');
- 9 }
-
-
-10 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- TortoiseDiffReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 use ApprovalTests\Reporters\FirstWorkingReporter;
- 6
- 7 class TortoiseDiffReporter extends FirstWorkingReporter
- 8 {
- 9 public function __construct()
- 10 {
- 11 parent::__construct(new TortoiseImageDiffReporter(), new TortoiseTextDiffReporter());
- 12 }
-
-
-13 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- TortoiseImageDiffReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class TortoiseImageDiffReporter extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('TORTOISE_IMAGE_DIFF');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- TortoiseTextDiffReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class TortoiseTextDiffReporter extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('TORTOISE_TEXT_DIFF');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- WinMergeReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 class WinMergeReporter extends WindowsDiffInfoReporter
- 6 {
- 7 public function __construct()
- 8 {
- 9 parent::__construct('WIN_MERGE');
- 10 }
-
-
-11 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- WindowsDiffInfoReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 use ApprovalTests\Reporters\DiffPrograms;
- 6 use ApprovalTests\Reporters\GenericDiffReporter;
- 7
- 8 class WindowsDiffInfoReporter extends GenericDiffReporter
- 9 {
- 10 public function __construct(string $diffInfoName)
- 11 {
- 12 $diffInfo = DiffPrograms::getInstance()->WindowsDiffPrograms[$diffInfoName];
- 13 parent::__construct($diffInfo->diffProgram, $diffInfo->fileExtensions, $diffInfo->parameters);
- 14 }
-
-
-15 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- WindowsDiffReporter
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests\Reporters\Windows;
- 4
- 5 use ApprovalTests\Reporters\FirstWorkingReporter;
- 6
- 7 class WindowsDiffReporter extends FirstWorkingReporter
- 8 {
- 9 public function __construct()
- 10 {
- 11 parent::__construct(
- 12 new BeyondCompareReporter(),
- 13 new TortoiseDiffReporter(),
- 14 new CodeCompareReporter(),
- 15 new WinMergeReporter(),
- 16 new AraxisMergeReporter(),
- 17 new MeldReporterWindows(),
- 18 new KDiff3ReporterWindows());
- 19 }
-
-
-20 } Classes
- Coverage Distribution
- Complexity
- Insufficient Coverage
- Project Risks
-
-
-
-
-
-
-
-
-
- Class
- CRAP
- Methods
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Method
- Coverage
-
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
-
-
- __construct 0% Project Risks
-
-
-
-
-
-
-
-
-
- Method
- CRAP
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
-
- AraxisMergeReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- BeyondCompare3ReporterWindows.php
-
-
-
-
-
-
-
-
-
-
-
-
- BeyondCompare4ReporterWindows.php
-
-
-
-
-
-
-
-
-
-
-
-
- BeyondCompareReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- CodeCompareReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- KDiff3ReporterWindows.php
-
-
-
-
-
-
-
-
-
-
-
-
- MeldReporterWindows.php
-
-
-
-
-
-
-
-
-
-
-
-
- TortoiseDiffReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- TortoiseImageDiffReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- TortoiseTextDiffReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- WinMergeReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- WindowsDiffInfoReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- WindowsDiffReporter.php
-
-
-
-
-
-
-
-
- Classes
- Coverage Distribution
- Complexity
- Insufficient Coverage
- Project Risks
-
-
-
-
-
-
-
- Class
- CRAP
-
- ApprovalTests\Reporters\CombinationReporter 90
- ApprovalTests\Reporters\DiffInfo 72
- ApprovalTests\Reporters\FirstWorkingReporter 56
- ApprovalTests\Reporters\ClipboardReporter 42
-
-
- ApprovalTests\Reporters\DiffPrograms 42 Methods
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Method
- Coverage
-
- getCommandLineFor 0%
- report 0%
- copyToClipboard 0%
- isWorkingInThisEnvironment 0%
- __construct 0%
- report 0%
- isWorkingInThisEnvironment 0%
- __construct 0%
- resolveWindowsPath 0%
- getPathInProgramFilesX86 0%
- getFirstWorking 0%
- getProgramFilesPaths 0%
- getInstance 0%
- Text 0%
- Image 0%
- TextAndImage 0%
- __construct 0%
- __construct 0%
- report 0%
- isWorkingInThisEnvironment 0%
- __construct 0%
- report 0%
- isWorkingInThisEnvironment 0%
- __construct 0%
- report 0%
- isWorkingInThisEnvironment 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- report 0%
- isWorkingInThisEnvironment 0%
- report 0%
- isWorkingInThisEnvironment 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
- __construct 0%
-
-
- __construct 0% Project Risks
-
-
-
-
-
-
-
- Method
- CRAP
-
- report 30
- isWorkingInThisEnvironment 12
- getFirstWorking 12
- report 12
- isWorkingInThisEnvironment 12
- getCommandLineFor 6
- copyToClipboard 6
- resolveWindowsPath 6
-
-
- getInstance 6
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
-
- Mac
-
-
-
-
-
-
-
-
-
-
-
-
- Windows
-
-
-
-
-
-
-
-
-
-
-
-
- ClipboardReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- CombinationReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- DiffInfo.php
-
-
-
-
-
-
-
-
-
-
-
-
- DiffPrograms.php
-
-
-
-
-
-
-
-
-
-
-
-
- DiffReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- FileLaunchReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- FirstWorkingReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- GenericDiffReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- PHPUnitReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
- QuietReporter.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Reporter.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- SortingUtil
-
-
-
-
-
-
- 20
-
-
-
-
-
-
- ksortRecursive
-
-
-
-
-
-
- 12
-
-
-
-
-
-
- orderFieldNamesAlphabetically
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests;
- 2
- 3 class SortingUtil
- 4 {
- 5 // https://gist.github.com/cdzombak/601849
- 6 private static function ksortRecursive(&$array, $sort_flags = SORT_REGULAR)
- 7 {
- 8 if (!is_array($array)) return false;
- 9 ksort($array, $sort_flags);
- 10 foreach ($array as &$arr) {
- 11 self::ksortRecursive($arr, $sort_flags);
- 12 }
- 13 return true;
- 14 }
- 15
- 16 public static function orderFieldNamesAlphabetically($array)
- 17 {
- 18 $result = $array;
- 19 self::ksortRecursive($result);
- 20 return $result;
- 21 }
-
-
-22 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- SystemUtil
-
-
-
-
-
-
- 30
-
-
-
-
-
-
- isWindows
-
-
-
-
-
-
- 2
-
-
-
-
- execInBackground
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- viewFile
-
-
-
-
-
-
- 6
-
-
-
-
-
-
-
-
- 1 <?php
- 2
- 3 namespace ApprovalTests;
- 4
- 5 class SystemUtil
- 6 {
- 7 public static function isWindows(): bool
- 8 {
- 9 // Based on http://php.net/manual/en/function.php-uname.php
- 10 return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
- 11 }
- 12
- 13 public static function execInBackground(string $cmd)
- 14 {
- 15 // Taken from http://php.net/manual/en/function.exec.php#86329
- 16 if (self::isWindows()) {
- 17 pclose(popen("start /B \"needed title\" " . $cmd, "r"));
- 18 } else {
- 19 exec($cmd . " > /dev/null &");
- 20 }
- 21 }
- 22
- 23 public static function viewFile(string $filename)
- 24 {
- 25 if (self::isWindows()) {
- 26 pclose(popen("start /B \"needed title\" \"" . $filename . "\"", "r"));
- 27 } else {
- 28 exec("open \"" . $filename . "\" > /dev/null &");
- 29 }
- 30 }
-
-
-31 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
- TextWriter
-
-
-
-
-
-
- 30
-
-
-
-
-
-
- __construct
-
-
-
-
-
-
- 2
-
-
-
-
- getExtensionWithoutDot
-
-
-
-
-
-
- 2
-
-
-
-
- write
-
-
-
-
-
-
- 2
-
-
-
-
- writeEmpty
-
-
-
-
-
-
- 2
-
-
-
-
-
-
- delete
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests\Writers;
- 2
- 3 use ApprovalTests\FileUtil;
- 4
- 5 class TextWriter implements Writer
- 6 {
- 7 private $received;
- 8 private $extensionWithoutDot;
- 9
- 10 public function __construct($received, $extensionWithoutDot)
- 11 {
- 12 $this->received = $received;
- 13 $this->extensionWithoutDot = $extensionWithoutDot;
- 14 }
- 15
- 16 public function getExtensionWithoutDot()
- 17 {
- 18 return $this->extensionWithoutDot;
- 19 }
- 20
- 21 /**
- 22 * Write the file to disk
- 23 */
- 24 public function write(string $fileNameAndPath, string $approvalsFolder)
- 25 {
- 26 FileUtil::createFolderIfNotExists($approvalsFolder);
- 27 file_put_contents($fileNameAndPath, $this->received);
- 28 return $fileNameAndPath;
- 29 }
- 30
- 31 public function writeEmpty(string $fileNameAndPath, string $approvalsFolder)
- 32 {
- 33 FileUtil::createFolderIfNotExists($approvalsFolder);
- 34 file_put_contents($fileNameAndPath, " ");
- 35 return $fileNameAndPath;
- 36 }
- 37
- 38 public function delete(string $fileNameAndPath)
- 39 {
- 40 return unlink($fileNameAndPath);
- 41 }
-
-
-42 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
- CRAP
-
-
-
-
-
-
-
-
-
-
- 1 <?php namespace ApprovalTests\Writers;
- 2
- 3 use ApprovalTests\Namers\Namer;
- 4
- 5 interface Writer
- 6 {
- 7 public function getExtensionWithoutDot();
- 8
- 9 public function write(string $fileNameAndPath, string $approvalsFolder);
- 10 public function writeEmpty(string $fileNameAndPath, string $approvalsFolder);
- 11
- 12 public function delete(string $fileNameAndPath);
-
-
-13 } Classes
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Class
- Coverage
-
-
-
- ApprovalTests\Writers\TextWriter 0% Project Risks
-
-
-
-
-
-
-
-
-
- Class
- CRAP
- Methods
- Coverage Distribution
- Complexity
- Insufficient Coverage
-
-
-
-
-
-
-
- Method
- Coverage
-
- __construct 0%
- getExtensionWithoutDot 0%
- write 0%
- writeEmpty 0%
-
-
- delete 0% Project Risks
-
-
-
-
-
-
-
-
-
- Method
- CRAP
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
-
- TextWriter.php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Writer.php
-
-
-
-
-
-
-
-
- ","
"],col:[2,"
"],tr:[2,"","
"],td:[3,"
"],_default:[0,"",""]};function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n"," ").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return B(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=_e(v.pixelPosition,function(e,t){if(t)return t=Be(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return B(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0
"}),b},a.models.candlestickBarChart=function(){var b=a.models.historicalBarChart(a.models.candlestickBar());return b.useInteractiveGuideline(!0),b.interactiveLayer.tooltip.contentGenerator(function(a){var c=a.series[0].data,d=c.openopen: "+b.yAxis.tickFormat()(c.open)+" close: "+b.yAxis.tickFormat()(c.close)+" high "+b.yAxis.tickFormat()(c.high)+" low: "+b.yAxis.tickFormat()(c.low)+"
"}),b},a.models.legend=function(){"use strict";function b(p){function q(a,b){return"furious"!=o?"#000":m?a.disengaged?"#000":"#fff":m?void 0:(a.color||(a.color=g(a,b)),a.disabled?a.color:"#fff")}function r(a,b){return m&&"furious"==o&&a.disengaged?"#eee":a.color||g(a,b)}function s(a){return m&&"furious"==o?1:a.disabled?0:1}return p.each(function(b){var g=d-c.left-c.right,p=d3.select(this);a.utils.initSVG(p);var t=p.selectAll("g.nv-legend").data([b]),u=t.enter().append("g").attr("class","nvd3 nv-legend").append("g"),v=t.select("g");t.attr("transform","translate("+c.left+","+c.top+")");var w,x,y=v.selectAll(".nv-series").data(function(a){return"furious"!=o?a:a.filter(function(a){return m?!0:!a.disengaged})}),z=y.enter().append("g").attr("class","nv-series");switch(o){case"furious":x=23;break;case"classic":x=20}if("classic"==o)z.append("circle").style("stroke-width",2).attr("class","nv-legend-symbol").attr("r",5),w=y.select("circle");else if("furious"==o){z.append("rect").style("stroke-width",2).attr("class","nv-legend-symbol").attr("rx",3).attr("ry",3),w=y.select(".nv-legend-symbol"),z.append("g").attr("class","nv-check-box").property("innerHTML",'open: "+b.yAxis.tickFormat()(c.open)+" close: "+b.yAxis.tickFormat()(c.close)+" high "+b.yAxis.tickFormat()(c.high)+" low: "+b.yAxis.tickFormat()(c.low)+" s[c]&&(e.offsets.popper[m]+=d[m]+u-s[c]),e.offsets.popper=g(e.offsets.popper);var b=d[m]+d[l]/2-u/2,w=t(e.instance.popper),y=parseFloat(w['margin'+f]),E=parseFloat(w['border'+f+'Width']),v=b-e.offsets.popper[m]-y-E;return v=ee(Q(s[l]-u,v),0),e.arrowElement=i,e.offsets.arrow=(n={},ae(n,m,$(v)),ae(n,h,''),n),e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=v(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),n=e.placement.split('-')[0],i=T(n),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case ce.FLIP:p=[n,i];break;case ce.CLOCKWISE:p=G(n);break;case ce.COUNTERCLOCKWISE:p=G(n,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(n!==s||p.length===d+1)return e;n=e.placement.split('-')[0],i=T(n);var a=e.offsets.popper,l=e.offsets.reference,f=Z,m='left'===n&&f(a.right)>f(l.left)||'right'===n&&f(a.left)