|
17 | 17 | use PHPUnit\Framework\TestCase;
|
18 | 18 | use RuntimeException;
|
19 | 19 |
|
20 |
| -use const STDERR; |
21 |
| - |
22 | 20 | class QueryTest extends TestCase
|
23 | 21 | {
|
| 22 | + public static array $baselineFailedQueries; |
| 23 | + |
| 24 | + public static function setUpBeforeClass(): void |
| 25 | + { |
| 26 | + parent::setUpBeforeClass(); |
| 27 | + self::$baselineFailedQueries = \array_map('trim', \file(__DIR__ . '/data/baselineFailedQueries.txt')); |
| 28 | + } |
| 29 | + |
24 | 30 | /**
|
25 | 31 | * This method aims to test the current implementation against
|
26 | 32 | * all queries listed on https://cburgmer.github.io/json-path-comparison/
|
@@ -70,21 +76,24 @@ public function testQueries(
|
70 | 76 | // assert in these cases. There might be still some false positives
|
71 | 77 | // (e.g. multidimensional comparisons), but that's okay, I guess. Maybe,
|
72 | 78 | // we can also find a way around that in the future.
|
| 79 | + $message = "==========================\n"; |
| 80 | + $message .= "Query: {$query}\n\nMore information: {$url}\n"; |
| 81 | + $message .= "==========================\n\n"; |
73 | 82 | self::assertEqualsCanonicalizing(
|
74 | 83 | \json_decode($consensus, true),
|
75 |
| - \json_decode($results, true) |
| 84 | + \json_decode($results, true), |
| 85 | + $message |
76 | 86 | );
|
77 | 87 | } catch (ExpectationFailedException) {
|
78 |
| - $e = $e->getComparisonFailure(); |
79 |
| - |
80 |
| - \fwrite(STDERR, "==========================\n"); |
81 |
| - \fwrite(STDERR, "Query: {$query}\n\n{$e->toString()}\nMore information: {$url}\n"); |
82 |
| - \fwrite(STDERR, "==========================\n\n"); |
| 88 | + if (!\in_array($id, self::$baselineFailedQueries, true)) { |
| 89 | + throw new ExpectationFailedException( |
| 90 | + $e->getMessage() . "\nQuery: {$query}\n\nMore information: {$url}", |
| 91 | + $e->getComparisonFailure() |
| 92 | + ); |
| 93 | + } |
83 | 94 | }
|
84 | 95 | } catch (JSONPathException $e) {
|
85 |
| - \fwrite(STDERR, "==========================\n"); |
86 |
| - \fwrite(STDERR, "Query: {$query}\n\n{$e->getMessage()}\n"); |
87 |
| - \fwrite(STDERR, "==========================\n\n"); |
| 96 | + // ignore |
88 | 97 | } catch (RuntimeException) {
|
89 | 98 | // ignore
|
90 | 99 | }
|
|
0 commit comments