Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add test for countFriend() method

  • Loading branch information...
commit 8efdb13a6d72b113fcce21b0496951ee8c1ac6b7 1 parent 66b5ad1
@willdurand willdurand authored
Showing with 29 additions and 0 deletions.
  1. +29 −0 tests/EqualNestBehaviorTest.php
View
29 tests/EqualNestBehaviorTest.php
@@ -299,4 +299,33 @@ public function testRemoveFriends()
$this->assertFalse($phil->hasFriend($john));
$this->assertFalse($jean->hasFriend($john));
}
+
+ public function testCountFriends()
+ {
+ $john = new Person();
+ $john->setName('john');
+ $jean = new Person();
+ $jean->setName('jean');
+ $phil = new Person();
+ $phil->setName('phil');
+
+ $this->assertEquals(0, $john->countFriends());
+
+ $john->setFriends(array($jean, $phil));
+ $john->save();
+
+ $this->assertEquals(2, $john->countFriends());
+
+ $john->removeFriends();
+ $this->assertEquals(0, $john->countFriends());
+
+ $john->save();
+ $this->assertEquals(0, $john->countFriends());
+
+ $john->addFriend($phil);
+ $this->assertEquals(1, $john->countFriends());
+
+ $john->save();
+ $this->assertEquals(1, $john->countFriends());
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.