generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from ergebnis/feature/sub-schema
Enhancement: Require `JsonPointer` to allow resolving sub-schemas
- Loading branch information
Showing
10 changed files
with
468 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/json-schema-validator | ||
*/ | ||
|
||
namespace Ergebnis\Json\SchemaValidator\Exception; | ||
|
||
use Ergebnis\Json\SchemaValidator; | ||
|
||
final class CanNotResolve extends \InvalidArgumentException | ||
{ | ||
public static function jsonPointer(SchemaValidator\JsonPointer $jsonPointer): self | ||
{ | ||
return new self(\sprintf( | ||
'Can not resolve JSON pointer "%s".', | ||
$jsonPointer->toString(), | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/json-schema-validator | ||
*/ | ||
|
||
namespace Ergebnis\Json\SchemaValidator\Exception; | ||
|
||
use Ergebnis\Json\SchemaValidator; | ||
|
||
final class ResolvedToRootSchema extends \RuntimeException | ||
{ | ||
public static function jsonPointer(SchemaValidator\JsonPointer $jsonPointer): self | ||
{ | ||
return new self(\sprintf( | ||
'Resolved JSON pointer "%s" to root schema.', | ||
$jsonPointer->toString(), | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/json-schema-validator | ||
*/ | ||
|
||
namespace Ergebnis\Json\SchemaValidator\Test\Unit\Exception; | ||
|
||
use Ergebnis\Json\SchemaValidator\Exception; | ||
use Ergebnis\Json\SchemaValidator\JsonPointer; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Ergebnis\Json\SchemaValidator\Exception\CanNotResolve | ||
* | ||
* @uses \Ergebnis\Json\SchemaValidator\JsonPointer | ||
*/ | ||
final class CanNotResolveTest extends Framework\TestCase | ||
{ | ||
public function testJsonPointerReturnsException(): void | ||
{ | ||
$jsonPointer = JsonPointer::fromString('/foo/bar'); | ||
|
||
$exception = Exception\CanNotResolve::jsonPointer($jsonPointer); | ||
|
||
$expected = \sprintf( | ||
'Can not resolve JSON pointer "%s".', | ||
$jsonPointer->toString(), | ||
); | ||
|
||
self::assertSame($expected, $exception->getMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/json-schema-validator | ||
*/ | ||
|
||
namespace Ergebnis\Json\SchemaValidator\Test\Unit\Exception; | ||
|
||
use Ergebnis\Json\SchemaValidator\Exception; | ||
use Ergebnis\Json\SchemaValidator\JsonPointer; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Ergebnis\Json\SchemaValidator\Exception\ResolvedToRootSchema | ||
* | ||
* @uses \Ergebnis\Json\SchemaValidator\JsonPointer | ||
*/ | ||
final class ResolvedToRootSchemaTest extends Framework\TestCase | ||
{ | ||
public function testJsonPointerReturnsException(): void | ||
{ | ||
$jsonPointer = JsonPointer::fromString('/foo/bar'); | ||
|
||
$exception = Exception\ResolvedToRootSchema::jsonPointer($jsonPointer); | ||
|
||
$expected = \sprintf( | ||
'Resolved JSON pointer "%s" to root schema.', | ||
$jsonPointer->toString(), | ||
); | ||
|
||
self::assertSame($expected, $exception->getMessage()); | ||
} | ||
} |
Oops, something went wrong.