-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImmutableStateTest.php
More file actions
33 lines (28 loc) · 963 Bytes
/
ImmutableStateTest.php
File metadata and controls
33 lines (28 loc) · 963 Bytes
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
<?php
declare(strict_types=1);
namespace KaririCode\Serializer\Tests\Conformance;
use KaririCode\Serializer\Core\SerializationContextImpl;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
#[CoversClass(SerializationContextImpl::class)]
final class ImmutableStateTest extends TestCase
{
#[Test]
public function testContextImmutability(): void
{
$ctx = SerializationContextImpl::create('json');
$ctx2 = $ctx->withFormat('xml');
$this->assertNotSame($ctx, $ctx2);
$this->assertSame('json', $ctx->getFormat());
$this->assertSame('xml', $ctx2->getFormat());
}
#[Test]
public function testParametersImmutability(): void
{
$ctx = SerializationContextImpl::create();
$ctx2 = $ctx->withParameters(['x' => 1]);
$this->assertNotSame($ctx, $ctx2);
$this->assertSame([], $ctx->getParameters());
}
}