|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @see https://github.com/zendframework/zend-expressive-zendviewrenderer for the canonical source repository |
| 4 | + * @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com) |
| 5 | + * @license https://github.com/zendframework/zend-expressive-zendviewrenderer/blob/master/LICENSE.md New BSD License |
| 6 | + */ |
| 7 | + |
| 8 | +declare(strict_types=1); |
| 9 | + |
| 10 | +namespace ZendTest\Expressive\ZendView; |
| 11 | + |
| 12 | +use Generator; |
| 13 | +use PHPUnit\Framework\TestCase; |
| 14 | +use Zend\Expressive\Template\Exception\ExceptionInterface as TemplateExceptionInterface; |
| 15 | +use Zend\Expressive\ZendView\Exception\ExceptionInterface; |
| 16 | + |
| 17 | +class ExceptionTest extends TestCase |
| 18 | +{ |
| 19 | + public function testExceptionInterfaceExtendsTemplateExceptionInterface() : void |
| 20 | + { |
| 21 | + self::assertTrue(is_a(ExceptionInterface::class, TemplateExceptionInterface::class, true)); |
| 22 | + } |
| 23 | + |
| 24 | + public function exception() : Generator |
| 25 | + { |
| 26 | + $namespace = substr(ExceptionInterface::class, 0, strrpos(ExceptionInterface::class, '\\') + 1); |
| 27 | + |
| 28 | + $exceptions = glob(__DIR__ . '/../src/Exception/*.php'); |
| 29 | + foreach ($exceptions as $exception) { |
| 30 | + $class = substr(basename($exception), 0, -4); |
| 31 | + |
| 32 | + yield $class => [$namespace . $class]; |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * @dataProvider exception |
| 38 | + */ |
| 39 | + public function testExceptionIsInstanceOfExceptionInterface(string $exception) : void |
| 40 | + { |
| 41 | + self::assertContains('Exception', $exception); |
| 42 | + self::assertTrue(is_a($exception, ExceptionInterface::class, true)); |
| 43 | + } |
| 44 | +} |
0 commit comments