Skip to content

Commit

Permalink
Fix: Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 29, 2022
1 parent 537a5b0 commit c3f7f02
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
19 changes: 17 additions & 2 deletions test/Unit/JsonPointerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,30 @@ 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) {
yield $key => [
$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,
];
}
}

/**
Expand Down
26 changes: 21 additions & 5 deletions test/Unit/ReferenceTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,31 @@ 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) {
yield $key => [
$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,
];
}
}

/**
Expand Down Expand Up @@ -124,7 +140,7 @@ public function provideValueAndJsonStringValue(): \Generator
"'",
"'",
],
'slash-backwards' => [
'slash-backward' => [
'\\',
'\\',
],
Expand Down Expand Up @@ -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',
],
Expand Down

0 comments on commit c3f7f02

Please sign in to comment.