summaryrefslogtreecommitdiff
path: root/tests/units/ProjectActivityTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/ProjectActivityTest.php')
-rw-r--r--tests/units/ProjectActivityTest.php50
1 files changed, 31 insertions, 19 deletions
diff --git a/tests/units/ProjectActivityTest.php b/tests/units/ProjectActivityTest.php
index 7e7841dd..f0b27649 100644
--- a/tests/units/ProjectActivityTest.php
+++ b/tests/units/ProjectActivityTest.php
@@ -4,21 +4,33 @@ require_once __DIR__.'/Base.php';
use Model\Task;
use Model\TaskFinder;
+use Model\TaskCreation;
use Model\ProjectActivity;
use Model\Project;
class ProjectActivityTest extends Base
{
+ public function testDecode()
+ {
+ $e = new ProjectActivity($this->container);
+ $input = array('test');
+ $serialized = serialize($input);
+ $json = json_encode($input);
+
+ $this->assertEquals($input, $e->decode($serialized));
+ $this->assertEquals($input, $e->decode($json));
+ }
+
public function testCreation()
{
- $e = new ProjectActivity($this->registry);
- $t = new Task($this->registry);
- $tf = new TaskFinder($this->registry);
- $p = new Project($this->registry);
+ $e = new ProjectActivity($this->container);
+ $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(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
- $this->assertEquals(2, $t->create(array('title' => 'Task #2', 'project_id' => 1)));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1)));
$this->assertTrue($e->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $tf->getbyId(1))));
$this->assertTrue($e->createEvent(1, 2, 1, Task::EVENT_UPDATE, array('task' => $tf->getById(2))));
@@ -29,20 +41,20 @@ class ProjectActivityTest extends Base
$this->assertNotEmpty($events);
$this->assertTrue(is_array($events));
$this->assertEquals(2, count($events));
- $this->assertEquals(time(), $events[0]['date_creation']);
+ $this->assertEquals(time(), $events[0]['date_creation'], '', 1);
$this->assertEquals(Task::EVENT_UPDATE, $events[0]['event_name']);
$this->assertEquals(Task::EVENT_CLOSE, $events[1]['event_name']);
}
public function testFetchAllContent()
{
- $e = new ProjectActivity($this->registry);
- $t = new Task($this->registry);
- $tf = new TaskFinder($this->registry);
- $p = new Project($this->registry);
+ $e = new ProjectActivity($this->container);
+ $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(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
$nb_events = 80;
@@ -62,13 +74,13 @@ class ProjectActivityTest extends Base
public function testCleanup()
{
- $e = new ProjectActivity($this->registry);
- $t = new Task($this->registry);
- $tf = new TaskFinder($this->registry);
- $p = new Project($this->registry);
+ $e = new ProjectActivity($this->container);
+ $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(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
$max = 15;
$nb_events = 100;
@@ -77,7 +89,7 @@ class ProjectActivityTest extends Base
$this->assertTrue($e->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $tf->getbyId(1))));
}
- $this->assertEquals($nb_events, $this->registry->shared('db')->table('project_activities')->count());
+ $this->assertEquals($nb_events, $this->container['db']->table('project_activities')->count());
$e->cleanup($max);
$events = $e->getProject(1);
@@ -97,6 +109,6 @@ class ProjectActivityTest extends Base
$this->assertTrue($e->createEvent(1, 1, 1, Task::EVENT_CLOSE, array('task' => $tf->getbyId(1))));
}
- $this->assertEquals(ProjectActivity::MAX_EVENTS, $this->registry->shared('db')->table('project_activities')->count());
+ $this->assertEquals(ProjectActivity::MAX_EVENTS, $this->container['db']->table('project_activities')->count());
}
}