-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExistsExceptionTest.php
More file actions
45 lines (37 loc) · 1.25 KB
/
ExistsExceptionTest.php
File metadata and controls
45 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
declare(strict_types=1);
namespace Chubbyphp\Tests\Container\Unit\Exceptions;
use Chubbyphp\Container\Exceptions\ExistsException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
* @internal
*/
#[CoversClass(ExistsException::class)]
final class ExistsExceptionTest extends TestCase
{
public function testConstruct(): void
{
$this->expectException(\Error::class);
$this->expectExceptionMessage('Call to private');
new ExistsException('test', 0);
}
#[DataProvider('provideCreateCases')]
public function testCreate(string $type): void
{
$exception = ExistsException::create('id', $type);
self::assertSame(\sprintf('Factory with id "id" already exists as "%s"', $type), $exception->getMessage());
self::assertSame(2, $exception->getCode());
}
/**
* @return array<string, array<string, string>>
*/
public static function provideCreateCases(): iterable
{
return [
ExistsException::TYPE_FACTORY => ['type' => ExistsException::TYPE_FACTORY],
ExistsException::TYPE_PROTOTYPE_FACTORY => ['type' => ExistsException::TYPE_PROTOTYPE_FACTORY],
];
}
}