summaryrefslogtreecommitdiff
path: root/tests/units
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2017-12-01 11:54:02 -0800
committerFrédéric Guillot <fred@kanboard.net>2017-12-01 11:54:02 -0800
commit0153cb33dede09a0167d490204bdf10151ed15cc (patch)
tree74ead58a5060b423b05a60114bd5b7e33828f3e6 /tests/units
parent0573c92d09544799f6f517e60ca2a0fa7c0fb0f3 (diff)
Add command to remove project activities after one year
Diffstat (limited to 'tests/units')
-rw-r--r--tests/units/Model/ProjectActivityTest.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/units/Model/ProjectActivityTest.php b/tests/units/Model/ProjectActivityTest.php
index 0b87b515..f3d37acb 100644
--- a/tests/units/Model/ProjectActivityTest.php
+++ b/tests/units/Model/ProjectActivityTest.php
@@ -43,23 +43,23 @@ class ProjectActivityTest extends Base
$this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
$this->assertEquals(1, $taskCreation->create(array('title' => 'Task #1', 'project_id' => 1)));
- $max = 15;
- $nb_events = 100;
+ $nbEvents = 100;
$task = $taskFinder->getById(1);
- for ($i = 0; $i < $nb_events; $i++) {
+ for ($i = 0; $i < $nbEvents; $i++) {
$this->assertTrue($projectActivity->createEvent(1, 1, 1, TaskModel::EVENT_CLOSE, array('task' => $task)));
}
- $this->assertEquals($nb_events, $this->container['db']->table('project_activities')->count());
- $projectActivity->cleanup($max);
+ $this->assertEquals($nbEvents, $this->container['db']->table('project_activities')->count());
+ $projectActivity->cleanup(strtotime('-12 months'));
+ $this->assertEquals($nbEvents, $this->container['db']->table('project_activities')->count());
+
+ $this->container['db']->table('project_activities')->in('id', array(1, 2, 3))->update(array(
+ 'date_creation' => strtotime('-13 months')
+ ));
- $events = $projectActivity->getQuery()->desc('id')->findAll();
- $this->assertNotEmpty($events);
- $this->assertCount($max, $events);
- $this->assertEquals(100, $events[0]['id']);
- $this->assertEquals(99, $events[1]['id']);
- $this->assertEquals(86, $events[14]['id']);
+ $projectActivity->cleanup(strtotime('-12 months'));
+ $this->assertEquals($nbEvents - 3, $this->container['db']->table('project_activities')->count());
}
}