-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathValueWithContextNormalizerTest.php
More file actions
56 lines (50 loc) · 1.32 KB
/
ValueWithContextNormalizerTest.php
File metadata and controls
56 lines (50 loc) · 1.32 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
<?php declare(strict_types=1);
namespace Tests\Torr\SimpleNormalizer\Normalizer\ObjectNormalizer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Tests\Torr\SimpleNormalizer\Fixture\DummyVO;
use Torr\SimpleNormalizer\Data\ValueWithContext;
use Torr\SimpleNormalizer\Normalizer\ObjectNormalizer\ValueWithContextNormalizer;
use Torr\SimpleNormalizer\Normalizer\SimpleNormalizer;
use Torr\SimpleNormalizer\Normalizer\SimpleObjectNormalizerInterface;
/**
* @internal
*/
final class ValueWithContextNormalizerTest extends TestCase
{
/**
*
*/
public function testContextPassing () : void
{
$value = new ValueWithContext(
new DummyVO(5),
[
"o" => "hai",
],
);
$dummyNormalizer = $this->createMock(SimpleObjectNormalizerInterface::class);
$dummyNormalizer
->expects(self::once())
->method("normalize")
->with(
$value->value,
[
"test" => 123,
"o" => "hai",
"simple-normalizer.debug-stack" => [
get_debug_type($value),
DummyVO::class,
],
],
);
$normalizer = new SimpleNormalizer(new ServiceLocator([
ValueWithContext::class => static fn () => new ValueWithContextNormalizer(),
DummyVO::class => static fn () => $dummyNormalizer,
]));
$normalizer->normalize($value, [
"test" => 123,
"o" => 5,
]);
}
}