-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Extract AbstractNormalizerTestCase
- Loading branch information
1 parent
a5c43f4
commit fff9ad3
Showing
4 changed files
with
61 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2018 Andreas Möller. | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/localheinz/json-normalizer | ||
*/ | ||
|
||
namespace Localheinz\Json\Normalizer\Test\Unit; | ||
|
||
use Localheinz\Json\Normalizer\NormalizerInterface; | ||
use Localheinz\Test\Util\Helper; | ||
use PHPUnit\Framework; | ||
|
||
abstract class AbstractNormalizerTestCase extends Framework\TestCase | ||
{ | ||
use Helper; | ||
|
||
final public function testImplementsNormalizerInterface() | ||
{ | ||
$this->assertClassImplementsInterface(NormalizerInterface::class, $this->className()); | ||
} | ||
|
||
final public function testNormalizeRejectsInvalidJson() | ||
{ | ||
$json = $this->faker()->realText(); | ||
|
||
$reflection = new \ReflectionClass($this->className()); | ||
|
||
$normalizer = $reflection->newInstanceWithoutConstructor(); | ||
|
||
$this->expectException(\InvalidArgumentException::class); | ||
$this->expectExceptionMessage(\sprintf( | ||
'"%s" is not valid JSON.', | ||
$json | ||
)); | ||
|
||
$normalizer->normalize($json); | ||
} | ||
|
||
final protected function className(): string | ||
{ | ||
return \preg_replace( | ||
'/Test$/', | ||
'', | ||
\str_replace( | ||
'Localheinz\\Json\\Normalizer\\Test\\Unit\\', | ||
'Localheinz\\Json\\Normalizer\\', | ||
static::class | ||
) | ||
); | ||
} | ||
} |
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