ExchangeRateTest::testGetRate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
Intraface_Doctrine_Intranet::singleton(1);
3
4
class ExchangeRateTest extends PHPUnit_Framework_TestCase
5
{
6
    private $object = null;
0 ignored issues
show
Unused Code introduced by
The property $object is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
7
8
    function setUp()
9
    {
10
        $db = MDB2::singleton(DB_DSN);
11
        $db->query('TRUNCATE currency');
12
        $db->query('TRUNCATE currency_exchangerate');
13
    }
14
15 View Code Duplication
    function createCurrency()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
    {
17
        $object = new Intraface_modules_currency_Currency;
18
        $type = new Intraface_modules_currency_Currency_Type;
19
        $object->setType($type->getByIsoCode('EUR'));
20
        $object->save();
21
        return $object;
22
    }
23
24
    ///////////////////////////////////////////////////////
25
26
    function testConstruct()
27
    {
28
        $object = new Intraface_modules_currency_Currency_ExchangeRate;
29
        $this->assertTrue(is_object($object));
30
    }
31
32
    function testSave()
33
    {
34
        $object = new Intraface_modules_currency_Currency_ExchangeRate;
35
        $object->used_for_key = 1;
36
        $object->setRate(new Ilib_Variable_Float('745,23', 'da_dk'));
37
        $object->setCurrency($this->createCurrency());
38
39
        try {
40
            $object->save();
41
        } catch(Exception $e) {
42
            // $this->assertTrue(false, $e->getErrorMessage());
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
        }
44
    }
45
46
    function testGetRate()
47
    {
48
        $object = new Intraface_modules_currency_Currency_ExchangeRate;
49
        $object->used_for_key = 1;
50
        $object->setRate(new Ilib_Variable_Float('745,23', 'da_dk'));
51
        $object->setCurrency($this->createCurrency());
52
        $object->save();
53
54
        $object = Doctrine::getTable('Intraface_modules_currency_Currency_ExchangeRate')->find(1);
55
        $this->assertEquals('745,23', $object->getRate()->getAsLocal('da_dk'));
56
    }
57
}
58