MoneyHydratorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testHydratorExtractAsExpected() 0 9 1
A testHydratorHydratesAsExpected() 0 11 1
1
<?php
2
3
namespace ZFBrasil\Test\DoctrineMoneyModule\Hydrator;
4
5
use Money\Currency;
6
use PHPUnit_Framework_TestCase as TestCase;
7
use Money\Money;
8
use ZFBrasil\DoctrineMoneyModule\Hydrator\MoneyHydrator;
9
10
/**
11
 * @author  Gabriel Schmitt <[email protected]>
12
 * @license MIT
13
 */
14
class MoneyHydratorTest extends TestCase
15
{
16
    public function testHydratorExtractAsExpected()
17
    {
18
        $object = new Money(500, new Currency('BRL'));
19
        $hydrator = new MoneyHydrator();
20
        $extracted = $hydrator->extract($object);
21
        $expected = ['amount' => 500, 'currency' => $object->getCurrency()->getName()];
22
23
        $this->assertEquals($expected, $extracted);
24
    }
25
26
    public function testHydratorHydratesAsExpected()
27
    {
28
        $hydrator = new MoneyHydrator();
29
        $data = ['amount' => 500, 'currency' => 'BRL'];
30
31
        $money = new Money(500, new Currency('BRL'));
32
        $object = $hydrator->hydrate($data, new \stdClass());
33
34
        $this->assertEquals($money->getAmount(), $object->getAmount());
35
        $this->assertEquals($money->getCurrency(), $object->getCurrency());
36
    }
37
}
38