From 260c8515c507b8c339fdbe1a10b0f13792eac09d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 3 Oct 2015 17:21:29 -0400 Subject: Add more unit tests --- tests/units/Model/TaskFinderTest.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'tests/units/Model/TaskFinderTest.php') diff --git a/tests/units/Model/TaskFinderTest.php b/tests/units/Model/TaskFinderTest.php index 3601efdd..1d850ba7 100644 --- a/tests/units/Model/TaskFinderTest.php +++ b/tests/units/Model/TaskFinderTest.php @@ -27,7 +27,7 @@ class TaskFinderTest extends Base $tasks = $tf->getOverdueTasks(); $this->assertNotEmpty($tasks); $this->assertTrue(is_array($tasks)); - $this->assertEquals(1, count($tasks)); + $this->assertCount(1, $tasks); $this->assertEquals('Task #1', $tasks[0]['title']); } @@ -48,7 +48,7 @@ class TaskFinderTest extends Base $tasks = $tf->getOverdueTasksByProject(1); $this->assertNotEmpty($tasks); $this->assertTrue(is_array($tasks)); - $this->assertEquals(1, count($tasks)); + $this->assertcount(1, $tasks); $this->assertEquals('Task #1', $tasks[0]['title']); } @@ -69,7 +69,7 @@ class TaskFinderTest extends Base $tasks = $tf->getOverdueTasksByUser(1); $this->assertNotEmpty($tasks); $this->assertTrue(is_array($tasks)); - $this->assertEquals(2, count($tasks)); + $this->assertCount(2, $tasks); $this->assertEquals(1, $tasks[0]['id']); $this->assertEquals('Task #1', $tasks[0]['title']); @@ -81,4 +81,20 @@ class TaskFinderTest extends Base $this->assertEquals('Task #2', $tasks[1]['title']); } + + public function testCountByProject() + { + $tc = new TaskCreation($this->container); + $tf = new TaskFinder($this->container); + $p = new Project($this->container); + + $this->assertEquals(1, $p->create(array('name' => 'Project #1'))); + $this->assertEquals(2, $p->create(array('name' => 'Project #2'))); + $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1))); + $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 2))); + $this->assertEquals(3, $tc->create(array('title' => 'Task #3', 'project_id' => 2))); + + $this->assertEquals(1, $tf->countByProjectId(1)); + $this->assertEquals(2, $tf->countByProjectId(2)); + } } -- cgit v1.2.3