Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 85caffb

Browse files
committed
Added Exception tests
Check if all exceptions implements ExceptionInteface - marker interface for package-specific exceptions
1 parent 0832c05 commit 85caffb

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
4-
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
4+
* @copyright Copyright (c) 2017-2018 Zend Technologies USA Inc. (https://www.zend.com)
55
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
66
*/
77

88
declare(strict_types=1);
99

1010
namespace Zend\Expressive\Authentication\Exception;
1111

12-
class InvalidConfigException extends RuntimeException implements ExceptionInterface
12+
class InvalidConfigException extends RuntimeException
1313
{
1414
}

src/Exception/RuntimeException.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
22
/**
33
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
4-
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
4+
* @copyright Copyright (c) 2017-2018 Zend Technologies USA Inc. (https://www.zend.com)
55
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
66
*/
77

88
declare(strict_types=1);
99

1010
namespace Zend\Expressive\Authentication\Exception;
1111

12-
class RuntimeException extends \RuntimeException implements
13-
ExceptionInterface
12+
class RuntimeException extends \RuntimeException implements ExceptionInterface
1413
{
1514
}

test/ExceptionTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-expressive-authentication for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-expressive-authentication/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace ZendTest\Expressive\Authentication;
11+
12+
use Generator;
13+
use PHPUnit\Framework\TestCase;
14+
use Psr\Container\ContainerExceptionInterface;
15+
use Zend\Expressive\Authentication\Exception\ExceptionInterface;
16+
17+
class ExceptionTest extends TestCase
18+
{
19+
public function exception() : Generator
20+
{
21+
$namespace = substr(ExceptionInterface::class, 0, strrpos(ExceptionInterface::class, '\\') + 1);
22+
23+
$exceptions = glob(__DIR__ . '/../src/Exception/*.php');
24+
foreach ($exceptions as $exception) {
25+
$class = substr(basename($exception), 0, -4);
26+
27+
yield $class => [$namespace . $class];
28+
}
29+
}
30+
31+
/**
32+
* @dataProvider exception
33+
*/
34+
public function testExceptionIsInstanceOfExceptionInterface(string $exception) : void
35+
{
36+
$this->assertContains('Exception', $exception);
37+
$this->assertTrue(is_a($exception, ExceptionInterface::class, true));
38+
}
39+
}

0 commit comments

Comments
 (0)