-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgetTest.php
48 lines (43 loc) · 1.48 KB
/
getTest.php
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
<?php declare(strict_types=1);
namespace Acelot\AutoMapper\Tests\Functional;
use Acelot\AutoMapper\AutoMapper as a;
use Acelot\AutoMapper\Context\Context;
use Acelot\AutoMapper\Tests\Fixtures\TestClass;
use PHPUnit\Framework\TestCase;
final class getTest extends TestCase
{
public function testFunction(): void
{
$source = [
'id' => 10,
'title' => 'Hello, world!',
'tags' => ['one', 'two', 'three'],
'object' => (object)[
'property' => 'value',
'property with spaces' => 'wow, value',
],
'deep' => [
'test class' => new TestClass(222, 'test class name', 500.0),
],
];
$result = a::marshalArray(
new Context(),
$source,
a::toKey('title_fifth_letter', a::get('[title][4]')),
a::toKey('last_tag', a::get('[tags][#last]')),
a::toKey('object_prop', a::get('[object]->property')),
a::toKey('object_prop_with_spaces', a::get('[object]->{property with spaces}')),
a::toKey('deep_class_price', a::get('[deep][test class]->getPrice()')),
);
self::assertSame(
[
'title_fifth_letter' => 'o',
'last_tag' => 'three',
'object_prop' => 'value',
'object_prop_with_spaces' => 'wow, value',
'deep_class_price' => 500.0,
],
$result
);
}
}