Skip to content

Commit 3cd4d1e

Browse files
committed
Merge pull request #473 from wmde/addtest
Add extra test for statement by guid removal method
2 parents 69f6c6c + 49180fd commit 3cd4d1e

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tests/unit/Statement/StatementListTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public function testAddStatementWithGuid() {
260260
$this->assertEquals( new StatementList( $statement ), $list );
261261
}
262262

263-
public function testRemoveStatementsWithGuid_singleStatementRemoved() {
263+
public function testGivenGuidOfPresenStatement_statementIsRemoved() {
264264
$statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' );
265265
$statement2 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' );
266266
$statement3 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' );
@@ -275,7 +275,7 @@ public function testRemoveStatementsWithGuid_singleStatementRemoved() {
275275
$this->assertEquals( $statements, $list->toArray() );
276276
}
277277

278-
public function testRemoveStatementsWithGuid_multipleStatementsRemoved() {
278+
public function testGivenGuidOfMulitpleStatements_multipleStatementsAreRemoved() {
279279
$statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' );
280280
$statement2 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' );
281281
$statement3 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' );
@@ -289,7 +289,7 @@ public function testRemoveStatementsWithGuid_multipleStatementsRemoved() {
289289
);
290290
}
291291

292-
public function testRemoveStatementsWithGuid_nowStatementRemoved() {
292+
public function testGivenNotPresentGuid_listIsNotModified() {
293293
$statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' );
294294
$statement2 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' );
295295
$statement3 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' );
@@ -303,6 +303,19 @@ public function testRemoveStatementsWithGuid_nowStatementRemoved() {
303303
);
304304
}
305305

306+
public function testGivenNullGuid_allStatementsWithNoGuidAreRemoved() {
307+
$statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' );
308+
$statement2 = new Statement( $this->newSnak( 32, 'bar' ) );
309+
$statement3 = new Statement( $this->newSnak( 32, 'bar' ) );
310+
311+
$list = new StatementList( array( $statement1, $statement2, $statement3 ) );
312+
$list->removeStatementsWithGuid( null );
313+
314+
$this->assertEquals(
315+
new StatementList( array( $statement1 ) ),
316+
$list
317+
);
318+
}
306319

307320
public function testCanConstructWithClaimsObjectContainingOnlyStatements() {
308321
$statementArray = array(

0 commit comments

Comments
 (0)