Skip to content

Commit

Permalink
added first tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Jun 29, 2012
1 parent 0fcd0e7 commit cb88c1c
Showing 1 changed file with 78 additions and 2 deletions.
80 changes: 78 additions & 2 deletions tests/EqualNestBehaviorTest.php
Expand Up @@ -22,12 +22,88 @@ protected function setUp()
</table> </table>
</database> </database>
XML; XML;
$this->getBuilder($schema)->build();
} }

$this->getBuilder($schema)->build();
} }


public function testObjectMethods() 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.