blob: 68410024f5e594651c0ad5d85ca73729922cdf0b (
plain)
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
50
51
52
|
<?php
namespace OpenCloud\Test\Common;
use OpenCloud\Common\HydratorStrategyTrait;
use OpenCloud\Test\TestCase;
class HydratorStrategyTraitTest extends TestCase
{
private $fixture;
public function setUp()
{
$this->fixture = new Fixture();
}
public function test_it_hydrates()
{
$data = ['foo' => 1, 'bar' => 2, 'baz' => 3, 'boo' => 4];
$this->fixture->hydrate($data);
$this->assertEquals(1, $this->fixture->foo);
$this->assertEquals(2, $this->fixture->getBar());
$this->assertEquals(3, $this->fixture->getBaz());
}
public function test_it_hydrates_aliases()
{
$this->fixture->hydrate(['FOO!' => 1], ['FOO!' => 'foo']);
$this->assertEquals(1, $this->fixture->foo);
}
}
class Fixture
{
public $foo;
protected $bar;
private $baz;
use HydratorStrategyTrait;
public function getBar()
{
return $this->bar;
}
public function getBaz()
{
return $this->baz;
}
}
|