MoneyFieldsetTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 6
Bugs 1 Features 0
Metric Value
wmc 3
c 6
b 1
f 0
lcom 1
cbo 3
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanHydrateMoneyWithInteger() 0 10 1
A getMoneyFieldset() 0 7 1
A testCanHydrateMoneyWithString() 0 11 1
1
<?php
2
3
namespace ZFBrasil\Test\DoctrineMoneyModule\Form;
4
5
use Money\Currency;
6
use Money\Money;
7
use PHPUnit_Framework_TestCase as TestCase;
8
use Zend\Form\FormElementManager;
9
use ZFBrasil\DoctrineMoneyModule\Form\Factory\MoneyFieldsetFactory;
10
use ZFBrasil\DoctrineMoneyModule\Form\MoneyFieldset;
11
12
/**
13
 * Description of MoneyFieldsetTest.
14
 *
15
 * @author  Fábio Carneiro <[email protected]>
16
 * @license MIT
17
 */
18
class MoneyFieldsetTest extends TestCase
19
{
20
    public function testCanHydrateMoneyWithInteger()
21
    {
22
        $fieldset = $this->getMoneyFieldset();
23
24
        $fieldset->bindValues([
25
            'amount' => 500,
26
            'currency' => 'BRL',
27
        ]);
28
        $this->assertInstanceOf(Money::class, $fieldset->getObject());
29
    }
30
31
    /**
32
     * @return MoneyFieldset
33
     */
34
    private function getMoneyFieldset()
35
    {
36
        $factory = new MoneyFieldsetFactory();
37
        $formManager = $this->getMock(FormElementManager::class);
38
39
        return $factory($formManager);
40
    }
41
42
    public function testCanHydrateMoneyWithString()
43
    {
44
        $fieldset = $this->getMoneyFieldset();
45
46
        $fieldset->bindValues([
47
            'amount' => '500',
48
            'currency' => 'BRL',
49
        ]);
50
51
        $this->assertInstanceOf(Money::class, $fieldset->getObject());
52
    }
53
}
54