From c3f7f02fcff8c3dd980004467cdc6f8193b36d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sat, 29 Jan 2022 18:52:08 +0100 Subject: [PATCH] Fix: Cases --- test/Unit/JsonPointerTest.php | 19 +++++++++++++++++-- test/Unit/ReferenceTokenTest.php | 26 +++++++++++++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/test/Unit/JsonPointerTest.php b/test/Unit/JsonPointerTest.php index 3ec12fa9..dcc15143 100644 --- a/test/Unit/JsonPointerTest.php +++ b/test/Unit/JsonPointerTest.php @@ -50,8 +50,7 @@ public function provideInvalidJsonStringValue(): \Generator { $values = [ 'does-not-start-with-forward-slash' => 'foo', - 'property-with-unescaped-tilde' => '/foo~bar', - 'property-with-unescaped-tildes' => '/foo~~bar', + 'property-with-tilde-followed-by-word' => '/foo~bar', ]; foreach ($values as $key => $value) { @@ -59,6 +58,22 @@ public function provideInvalidJsonStringValue(): \Generator $value, ]; } + + foreach (\range(2, 9) as $digit) { + $key = \sprintf( + 'property-with-tilde-followed-by-digit-%d', + $digit, + ); + + $value = \sprintf( + '/foo~%d', + $digit, + ); + + yield $key => [ + $value, + ]; + } } /** diff --git a/test/Unit/ReferenceTokenTest.php b/test/Unit/ReferenceTokenTest.php index 56b784b4..23cd2d88 100644 --- a/test/Unit/ReferenceTokenTest.php +++ b/test/Unit/ReferenceTokenTest.php @@ -47,8 +47,8 @@ public function testFromJsonStringRejectsInvalidValue(string $value): void public function provideInvalidJsonStringValue(): \Generator { $values = [ - 'property-with-unescaped-forward-slash' => 'foo/bar', - 'property-with-unescaped-tilde' => 'foo~bar', + 'property-with-slash-forward' => 'foo/bar', + 'property-with-tilde-followed-by-word' => 'foo~bar', ]; foreach ($values as $key => $value) { @@ -56,6 +56,22 @@ public function provideInvalidJsonStringValue(): \Generator $value, ]; } + + foreach (\range(2, 9) as $digit) { + $key = \sprintf( + 'property-with-tilde-followed-by-digit-%d', + $digit, + ); + + $value = \sprintf( + 'foo~%d', + $digit, + ); + + yield $key => [ + $value, + ]; + } } /** @@ -124,7 +140,7 @@ public function provideValueAndJsonStringValue(): \Generator "'", "'", ], - 'slash-backwards' => [ + 'slash-backward' => [ '\\', '\\', ], @@ -168,11 +184,11 @@ public function provideValueAndJsonStringValue(): \Generator "foo'bar", "foo'bar", ], - 'with-slash-backwards' => [ + 'with-slash-backward' => [ 'foo\\bar', 'foo\\bar', ], - 'with-slash-forwards' => [ + 'with-slash-forward' => [ 'foo/bar', 'foo~1bar', ],