| 1 | <?php |
||
| 8 | abstract class AbstractNormalizerTest extends \PHPUnit_Framework_TestCase |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @dataProvider getValidSubjects |
||
| 12 | * |
||
| 13 | * @param string $expected |
||
| 14 | * @param mixed $subject |
||
| 15 | */ |
||
| 16 | public function testValidObjectNormalization($expected, $subject) |
||
| 17 | { |
||
| 18 | $normalizer = $this->createNormalizer(); |
||
| 19 | |||
| 20 | self::assertTrue($normalizer->supports($subject)); |
||
| 21 | self::assertEquals($expected, $normalizer->normalize($subject)); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @dataProvider getInvalidSubjects |
||
| 26 | * |
||
| 27 | * @param mixed $subject |
||
| 28 | */ |
||
| 29 | public function testUnsupportedNormalizerThrowsException($subject) |
||
| 30 | { |
||
| 31 | $normalizer = $this->createNormalizer(); |
||
| 32 | self::assertFalse($normalizer->supports($subject)); |
||
| 33 | |||
| 34 | try { |
||
| 35 | $normalizer->normalize($subject); |
||
| 36 | } catch (DestinationException $exception) { |
||
| 37 | return; |
||
| 38 | } |
||
| 39 | |||
| 40 | self::fail('DestinationException is not thrown on invalid normalization'); |
||
| 41 | } |
||
| 42 | |||
| 43 | abstract public function getValidSubjects(); |
||
| 44 | |||
| 45 | abstract public function getInvalidSubjects(); |
||
| 46 | |||
| 47 | /** @return DestinationNormalizer */ |
||
| 48 | abstract protected function createNormalizer(); |
||
| 49 | } |
||
| 50 |