forked from sofascore/purgatory-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompoundValuesTest.php
More file actions
49 lines (40 loc) · 1.86 KB
/
CompoundValuesTest.php
File metadata and controls
49 lines (40 loc) · 1.86 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
<?php
declare(strict_types=1);
namespace Sofascore\PurgatoryBundle\Tests\Attribute\RouteParamValue;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\CompoundValues;
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\PropertyValues;
use Sofascore\PurgatoryBundle\Attribute\RouteParamValue\RawValues;
use Sofascore\PurgatoryBundle\Exception\InvalidArgumentException;
#[CoversClass(CompoundValues::class)]
final class CompoundValuesTest extends TestCase
{
#[TestWith([['foo'], [new PropertyValues('foo')]])]
#[TestWith([[['foo', 'bar']], [new PropertyValues('foo', 'bar')]])]
#[TestWith([[new RawValues('foo', 'bar')], [new RawValues('foo', 'bar')]])]
#[TestWith([['foo', new RawValues('foo', 'bar')], [new PropertyValues('foo'), new RawValues('foo', 'bar')]])]
public function testValueNormalization(mixed $values, mixed $expectedValues): void
{
$compoundValues = new CompoundValues(...$values);
self::assertEquals($expectedValues, $compoundValues->getValues());
}
public function testExceptionIsThrownOnSelf(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(\sprintf('An argument cannot be an instance of "%s".', CompoundValues::class));
new CompoundValues(new CompoundValues('foo'));
}
public function testToArray(): void
{
$compoundValues = new CompoundValues(['foo', 'bar'], new RawValues('baz', 'qux'));
self::assertSame([
'type' => CompoundValues::type(),
'values' => [
['type' => PropertyValues::type(), 'values' => ['foo', 'bar']],
['type' => RawValues::type(), 'values' => ['baz', 'qux']],
],
], $compoundValues->toArray());
}
}