Add more unit tests

This commit is contained in:
Frederic Guillot
2015-10-03 17:21:29 -04:00
parent d7c0fabcb7
commit 260c8515c5
7 changed files with 152 additions and 31 deletions

View File

@@ -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));
}
}