testResetOperatingAccountsReturnsFalseWhenNoAccountsIsFound()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
require_once 'Intraface/modules/accounting/Account.php';
3
require_once 'Intraface/modules/accounting/YearEnd.php';
4
require_once 'Intraface/Kernel.php';
5
6 View Code Duplication
class FakeYearEndYear
0 ignored issues
show
Duplication introduced by
This class 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...
7
{
8
    public $kernel;
9
    function __construct()
10
    {
11
        $this->kernel = new Stub_Kernel;
12
        $this->kernel->setting->set('intranet', 'vatpercent', 25);
13
    }
14
    function get()
15
    {
16
        return 1;
17
    }
18
19
    function getSetting()
20
    {
21
        return 1;
22
    }
23
24
    function isYearOpen()
25
    {
26
        return true;
27
    }
28
29
    function isDateInYear()
30
    {
31
        return true;
32
    }
33
}
34
35
class FakeYearEndAccount extends Account
36
{
37
    function __construct($year)
38
    {
39
        $this->value['number'] = 100;
40
        parent::__construct($year);
41
    }
42
}
43
44
class TestableYearEnd extends YearEnd
45
{
46
    function getAccount()
47
    {
48
        return new FakeYearEndAccount($this->year);
49
    }
50
}
51
52
class YearEndTest extends PHPUnit_Framework_TestCase
53
{
54
55
    private $end;
56
57
    function setUp()
58
    {
59
        $this->end = $this->createYearEnd();
60
    }
61
62 View Code Duplication
    function tearDown()
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...
63
    {
64
        $db = MDB2::singleton(DB_DSN);
65
        $db->exec('TRUNCATE accounting_year_end');
66
        $db->exec('TRUNCATE accounting_year_end_action');
67
        $db->exec('TRUNCATE accounting_year_end_statement');
68
        $db->exec('TRUNCATE setting');
69
        $db->exec('TRUNCATE accounting_year');
70
        $db->exec('TRUNCATE accounting_account');
71
    }
72
73
    function createYearEnd()
74
    {
75
        return new YearEnd(new FakeYearEndYear);
76
    }
77
78
    function testConstruction()
79
    {
80
        $vat = $this->createYearEnd();
81
        $this->assertTrue(is_object($vat));
82
    }
83
84
    function testStartReturnsTrue()
85
    {
86
        $this->assertTrue($this->end->start());
87
    }
88
89
    function testSetStepReturnsTrue()
90
    {
91
        $this->assertTrue($this->end->setStep(1));
92
    }
93
94
    function testSetStatedReturnsTrue()
95
    {
96
        $this->assertTrue($this->end->setStated('operating_reset', 100));
97
        $this->assertTrue($this->end->setStated('result_account_reset', 100));
98
    }
99
100
    function testGetStatedActionsReturnsArray()
101
    {
102
        $this->assertTrue(is_array($this->end->getStatedActions('operating_reset')));
103
        $this->assertTrue(is_array($this->end->getStatedActions('result_account_reset')));
104
    }
105
106
    function testSaveStatement()
107
    {
108
        $end = new TestableYearEnd(new FakeYearEndYear);
109
        $this->assertTrue($end->saveStatement('operating'));
110
        $this->assertTrue($end->saveStatement('balance'));
111
    }
112
113
    function testResetOperatingAccountsReturnsFalseWhenNoAccountsIsFound()
114
    {
115
        $result = $this->end->resetOperatingAccounts();
116
        $this->assertFalse($result);
117
    }
118
119
    function testResetYearResultReturnsTrue()
120
    {
121
        $this->assertTrue($this->end->resetYearResult());
122
    }
123
}
124