|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Tests\Fhp\Model\StatementOfAccount; |
|
4
|
|
|
|
|
5
|
|
|
use Fhp\Model\StatementOfAccount\Statement; |
|
6
|
|
|
use Fhp\Model\StatementOfAccount\Transaction; |
|
7
|
|
|
|
|
8
|
|
|
class StatementTest extends \PHPUnit_Framework_TestCase |
|
9
|
|
|
{ |
|
10
|
|
|
public function test_getter_and_setter() |
|
11
|
|
|
{ |
|
12
|
|
|
$obj = new Statement(); |
|
13
|
|
|
|
|
14
|
|
|
$this->assertInternalType('array', $obj->getTransactions()); |
|
15
|
|
|
$this->assertEmpty($obj->getTransactions()); |
|
16
|
|
|
$this->assertSame(0.0, $obj->getStartBalance()); |
|
17
|
|
|
$this->assertNull($obj->getCreditDebit()); |
|
18
|
|
|
$this->assertNull($obj->getDate()); |
|
19
|
|
|
|
|
20
|
|
|
$trx1 = new Transaction(); |
|
21
|
|
|
$trx2 = new Transaction(); |
|
22
|
|
|
|
|
23
|
|
|
$obj->addTransaction($trx1); |
|
24
|
|
|
$this->assertCount(1, $obj->getTransactions()); |
|
25
|
|
|
|
|
26
|
|
|
$obj->addTransaction($trx2); |
|
27
|
|
|
$this->assertCount(2, $obj->getTransactions()); |
|
28
|
|
|
|
|
29
|
|
|
$obj->setTransactions(null); |
|
30
|
|
|
$this->assertNull($obj->getTransactions()); |
|
31
|
|
|
|
|
32
|
|
|
$obj->setTransactions(array()); |
|
33
|
|
|
$this->assertInternalType('array', $obj->getTransactions()); |
|
34
|
|
|
$this->assertCount(0, $obj->getTransactions()); |
|
35
|
|
|
|
|
36
|
|
|
$trxArray = array($trx1, $trx2); |
|
37
|
|
|
$obj->setTransactions($trxArray); |
|
38
|
|
|
$this->assertInternalType('array', $obj->getTransactions()); |
|
39
|
|
|
$this->assertCount(2, $obj->getTransactions()); |
|
40
|
|
|
|
|
41
|
|
|
$obj->setStartBalance(20.00); |
|
42
|
|
|
$this->assertInternalType('float', $obj->getStartBalance()); |
|
43
|
|
|
$this->assertSame(20.00, $obj->getStartBalance()); |
|
44
|
|
|
|
|
45
|
|
|
$obj->setStartBalance('string'); |
|
46
|
|
|
$this->assertSame(0.0, $obj->getStartBalance()); |
|
47
|
|
|
|
|
48
|
|
|
$obj->setCreditDebit(Statement::CD_CREDIT); |
|
49
|
|
|
$this->assertSame(Statement::CD_CREDIT, $obj->getCreditDebit()); |
|
50
|
|
|
|
|
51
|
|
|
$obj->setCreditDebit(Statement::CD_DEBIT); |
|
52
|
|
|
$this->assertSame(Statement::CD_DEBIT, $obj->getCreditDebit()); |
|
53
|
|
|
|
|
54
|
|
|
$date = new \DateTime(); |
|
55
|
|
|
$obj->setDate($date); |
|
56
|
|
|
$this->assertSame($date, $obj->getDate()); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|