-
Notifications
You must be signed in to change notification settings - Fork 2
/
marshalObjectTest.php
35 lines (29 loc) · 936 Bytes
/
marshalObjectTest.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
<?php declare(strict_types=1);
namespace Acelot\AutoMapper\Tests\Functional;
use Acelot\AutoMapper\AutoMapper as a;
use Acelot\AutoMapper\Context\Context;
use PHPUnit\Framework\TestCase;
use stdClass;
final class marshalObjectTest extends TestCase
{
public function testFunction(): void
{
$source = [
'id' => 10,
'title' => 'Hello, world!',
'tags' => ['one', 'two', 'three'],
];
$result = a::marshalObject(
new Context(),
$source,
a::toProp('mappedId', a::get('[id]')),
a::toProp('mappedTitle', a::get('[title]')),
a::toProp('mappedTags', a::get('[tags]')),
);
$expected = new stdClass();
$expected->mappedId = 10;
$expected->mappedTitle = 'Hello, world!';
$expected->mappedTags = ['one', 'two', 'three'];
self::assertEquals($expected, $result);
}
}