-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtoMethodTest.php
44 lines (38 loc) · 1.07 KB
/
toMethodTest.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
<?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 toMethodTest extends TestCase
{
public function testFunction(): void
{
$source = [
'id' => 10,
'name' => 'Hello, world!',
'price' => 999,
];
$target = new TestClass(0, '', 0);
a::map(
new Context(),
$source,
$target,
a::toMethod('setId', a::get('[id]')),
a::toMethod('setName', a::get('[name]')),
a::toMethod('setPrice', a::get('[price]')),
);
self::assertEquals(
[
'id' => 10,
'name' => 'Hello, world!',
'price' => 999,
],
[
'id' => $target->getId(),
'name' => $target->getName(),
'price' => $target->getPrice(),
]
);
}
}