-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeclaredHandlerTest.php
More file actions
61 lines (49 loc) · 1.59 KB
/
DeclaredHandlerTest.php
File metadata and controls
61 lines (49 loc) · 1.59 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/*
* This file is part of Respect/Stringifier.
* Copyright (c) Henrique Moody <henriquemoody@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Stringifier\Test\Unit\Handlers;
use ArrayObject;
use BasicEnumeration;
use Countable;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Respect\Stringifier\Handlers\DeclaredHandler;
use Respect\Stringifier\Helpers\ObjectHelper;
use Respect\Stringifier\Test\Double\FakeQuoter;
#[CoversClass(DeclaredHandler::class)]
final class DeclaredHandlerTest extends TestCase
{
private const int DEPTH = 0;
#[Test]
public function itShouldNotStringifyWhenRawValueIsNotExists(): void
{
$sut = new DeclaredHandler(new FakeQuoter());
self::assertNull($sut->handle('NotAClassInterfaceTraitOrEnum', self::DEPTH));
}
#[Test]
#[DataProvider('existsRawValuesProvider')]
public function itShouldStringifyWhenRawValueIsExists(string $raw): void
{
$quoter = new FakeQuoter();
$sut = new DeclaredHandler($quoter);
$actual = $sut->handle($raw, self::DEPTH);
$expected = $quoter->quote($raw, self::DEPTH);
self::assertEquals($expected, $actual);
}
/** @return array<int, array<int, string>> */
public static function existsRawValuesProvider(): array
{
return [
[ArrayObject::class],
[Countable::class],
[BasicEnumeration::class],
[ObjectHelper::class],
];
}
}