Passed
Branch master (e17e02)
by Jacques
02:12
created

InvestmentValid   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 3
c 1
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadOfx() 0 4 1
1
<?php
2
3
namespace OfxParserTest\Entities;
4
5
use SimpleXMLElement;
6
use PHPUnit\Framework\TestCase;
7
use OfxParser\Entities\Investment;
8
9
/**
10
 * Need to extend the abstract Investment entity to test it.
11
 *
12
 * Defined properties, but no loadOfx method defined.
13
 */
14
class InvestmentNoLoadOfx extends Investment
15
{
16
    /**
17
     * @var string
18
     */
19
    public $public1 = 'value 100';
20
21
    /**
22
     * @var string
23
     */
24
    protected $protected1 = 'value 200';
25
26
    /**
27
     * @var string
28
     */
29
    private $private1 = 'value 300';
0 ignored issues
show
introduced by
The private property $private1 is not used, and could be removed.
Loading history...
30
}
31
32
/**
33
 * Need to extend the abstract Investment entity to test it.
34
 *
35
 * This should be a "complete" investment entity
36
 */
37
class InvestmentValid extends InvestmentNoLoadOfx
38
{
39
    /**
40
     * @var string
41
     */
42
    private $private2 = 'value 310';
0 ignored issues
show
introduced by
The private property $private2 is not used, and could be removed.
Loading history...
43
44
    /**
45
     * Imports the OFX data for this node.
46
     * @param SimpleXMLElement $node
47
     * @return $this
48
     */
49
    public function loadOfx(SimpleXMLElement $node)
50
    {
51
        // No-op: just need to test the exception
52
        return $this;
53
    }
54
}
55
56
/**
57
 * @covers OfxParser\Entities\Investment
58
 */
59
class InvestmentTest extends TestCase
60
{
61
    /**
62
     * @expectedException \Exception
63
     */
64
    public function testLoadOfxException()
65
    {
66
        $xml = new SimpleXMLElement('<xml></xml>');
67
        $entity = new InvestmentNoLoadOfx();
68
        $entity->loadOfx($xml);
69
    }
70
71
    /**
72
     * If no exception thrown, we're good.
73
     */
74
    public function testLoadOfxValid()
75
    {
76
        $xml = new SimpleXMLElement('<xml></xml>');
77
        $entity = new InvestmentValid();
78
        $entity->loadOfx($xml);
79
        $this->assertTrue(true);
80
    }
81
82
    /**
83
     * If no exception thrown, we're good.
84
     */
85
    public function testGetProperties()
86
    {
87
        $expectedProps = array(
88
            'public1',
89
            'protected1',
90
        );
91
92
        $entity = new InvestmentValid();
93
        $actualProps = $entity->getProperties();
94
95
        $this->assertSame($expectedProps, array_keys($actualProps));
96
        $this->assertSame($expectedProps, array_values($actualProps));
97
    }
98
}
99