Browse files

added first tests

  • Loading branch information...
1 parent 0fcd0e7 commit cb88c1cca16af2e8187d7d51452aee8802b591aa @willdurand willdurand committed Jun 30, 2012
Showing with 78 additions and 2 deletions.
  1. +78 −2 tests/EqualNestBehaviorTest.php
View
80 tests/EqualNestBehaviorTest.php
@@ -22,12 +22,88 @@ protected function setUp()
</table>
</database>
XML;
+ $this->getBuilder($schema)->build();
}
-
- $this->getBuilder($schema)->build();
}
public function testObjectMethods()
{
+ $this->assertTrue(method_exists('Person', 'hasFriend'));
+ $this->assertTrue(method_exists('Person', 'addFriend'));
+ $this->assertTrue(method_exists('Person', 'removeFriend'));
+ $this->assertTrue(method_exists('Person', 'getFriends'));
+ $this->assertTrue(method_exists('Person', 'setFriends'));
+ $this->assertTrue(method_exists('Person', 'addFriends'));
+ $this->assertTrue(method_exists('Person', 'removeFriends'));
+ $this->assertTrue(method_exists('Person', 'countFriends'));
+ }
+
+ public function testQueryMethods()
+ {
+ $this->assertTrue(method_exists('PersonQuery', 'countFriendsOf'));
+ $this->assertTrue(method_exists('PersonQuery', 'findFriendsOf'));
+ }
+
+ public function testHasFriend()
+ {
+ $john = new Person();
+ $jean = new Person();
+
+ $this->assertEquals(0, $john->countFriends());
+ $this->assertEquals(0, $jean->countFriends());
+ $this->assertFalse($john->hasFriend($jean));
+ $this->assertFalse($jean->hasFriend($john));
+ $this->assertFalse($jean->hasFriend($jean));
+ $this->assertFalse($john->hasFriend($john));
+ }
+
+ public function testHasFriendWithFriendship()
+ {
+ $john = new Person();
+ $jean = new Person();
+
+ $this->assertEquals(0, $john->countFriends());
+ $this->assertEquals(0, $jean->countFriends());
+ $this->assertFalse($john->hasFriend($jean));
+ $this->assertFalse($jean->hasFriend($john));
+
+ $john->addFriend($jean);
+
+ $this->assertTrue($john->hasFriend($jean));
+ $this->assertTrue($jean->hasFriend($john));
+ $this->assertEquals(1, $john->countFriends());
+ $this->assertEquals(1, $jean->countFriends());
+ }
+
+ public function testAddFriend()
+ {
+ $john = new Person();
+ $jean = new Person();
+
+ $this->assertEquals(0, $john->countFriends());
+ $this->assertEquals(0, $jean->countFriends());
+
+ $john->addFriend($jean);
+
+ $this->assertEquals(1, $john->countFriends());
+ $this->assertEquals(1, $jean->countFriends());
+ }
+
+ public function testRemoveFriend()
+ {
+ $john = new Person();
+ $jean = new Person();
+
+ $this->assertEquals(0, $john->countFriends());
+ $this->assertEquals(0, $jean->countFriends());
+
+ $john->addFriend($jean);
+ $this->assertEquals(1, $john->countFriends());
+ $this->assertEquals(1, $jean->countFriends());
+
+ $john->removeFriend($jean);
+ $this->assertEquals(0, $john->countFriends());
+ // TODO: fix this test
+ // $this->assertEquals(0, $jean->countFriends());
}
}

0 comments on commit cb88c1c

Please sign in to comment.