1 | <?php |
||
17 | class StatementByGuidMapTest extends \PHPUnit_Framework_TestCase { |
||
18 | |||
19 | public function testGivenNotPresentGuid_hasStatementWithGuidReturnsFalse() { |
||
20 | $statements = new StatementByGuidMap(); |
||
21 | |||
22 | $this->assertFalse( $statements->hasStatementWithGuid( 'some guid' ) ); |
||
23 | } |
||
24 | |||
25 | public function testGivenPresentGuid_hasStatementWithGuidReturnsTrue() { |
||
33 | |||
34 | private function newStatement( $propertyId, $guid ) { |
||
39 | |||
40 | /** |
||
41 | * @dataProvider nonStringProvider |
||
42 | */ |
||
43 | public function testGivenNonStringGuid_hasStatementWithGuidThrowsException( $nonString ) { |
||
44 | $statements = new StatementByGuidMap(); |
||
45 | |||
46 | $this->setExpectedException( 'InvalidArgumentException' ); |
||
47 | $statements->hasStatementWithGuid( $nonString ); |
||
48 | } |
||
49 | |||
50 | public function nonStringProvider() { |
||
51 | return [ |
||
52 | [ null ], |
||
53 | [ 42 ], |
||
54 | [ 4.2 ], |
||
55 | [ [] ], |
||
56 | [ (object)[] ], |
||
57 | ]; |
||
58 | } |
||
59 | |||
60 | public function testGivenGuidOfPresentStatement_getStatementByGuidReturnsStatement() { |
||
67 | |||
68 | public function testGivenGuidOfNotPresentStatement_getStatementByGuidReturnsNull() { |
||
73 | |||
74 | /** |
||
75 | * @dataProvider nonStringProvider |
||
76 | */ |
||
77 | public function testGivenNonStringGuid_getStatementByGuidThrowsException( $nonString ) { |
||
83 | |||
84 | public function testGivenGuidOfPresentStatement_removeStatementWithGuidRemovesTheStatement() { |
||
92 | |||
93 | public function testGivenGuidOfNonPresentStatement_removeStatementWithGuidDoesNoOp() { |
||
101 | |||
102 | /** |
||
103 | * @dataProvider nonStringProvider |
||
104 | */ |
||
105 | public function testGivenNonStringGuid_removeStatementWithGuidThrowsException( $nonString ) { |
||
111 | |||
112 | public function testGivenStatementWithNoGuid_constructorThrowsException() { |
||
119 | |||
120 | public function testCanConstructWithStatementTraversable() { |
||
121 | $traversable = new ArrayObject( [ |
||
122 | $this->newStatement( 1, 'some guid' ) |
||
123 | ] ); |
||
124 | |||
125 | $statementMap = new StatementByGuidMap( $traversable ); |
||
126 | |||
127 | $this->assertTrue( $statementMap->hasStatementWithGuid( 'some guid' ) ); |
||
128 | } |
||
129 | |||
130 | public function testWhenMapIsEmpty_countReturnsZero() { |
||
135 | |||
136 | public function testMapCanBePassedToCount() { |
||
144 | |||
145 | public function testMapCanBeIteratedOver() { |
||
164 | |||
165 | public function testGivenNotPresentStatement_addStatementAddsIt() { |
||
172 | |||
173 | public function testGivenStatementWithPresentGuid_addStatementReplacesThePresentStatement() { |
||
183 | |||
184 | public function testToArray() { |
||
197 | |||
198 | } |
||
199 |