Use Pimple instead of Core\Registry and add Monolog for logging

This commit is contained in:
Frédéric Guillot
2014-11-14 22:44:25 -05:00
parent 1487cb2763
commit b081288188
57 changed files with 549 additions and 593 deletions

View File

@@ -12,7 +12,7 @@ class AclTest extends Base
'controller1' => array('action1', 'action3'),
);
$acl = new Acl($this->registry);
$acl = new Acl($this->container);
$this->assertTrue($acl->isAllowedAction($acl_rules, 'controller1', 'action1'));
$this->assertTrue($acl->isAllowedAction($acl_rules, 'controller1', 'action3'));
$this->assertFalse($acl->isAllowedAction($acl_rules, 'controller1', 'action2'));
@@ -22,7 +22,7 @@ class AclTest extends Base
public function testIsAdmin()
{
$acl = new Acl($this->registry);
$acl = new Acl($this->container);
$_SESSION = array();
$this->assertFalse($acl->isAdminUser());
@@ -45,7 +45,7 @@ class AclTest extends Base
public function testIsUser()
{
$acl = new Acl($this->registry);
$acl = new Acl($this->container);
$_SESSION = array();
$this->assertFalse($acl->isRegularUser());
@@ -68,7 +68,7 @@ class AclTest extends Base
public function testIsPageAllowed()
{
$acl = new Acl($this->registry);
$acl = new Acl($this->container);
// Public access
$_SESSION = array();

View File

@@ -11,7 +11,7 @@ class ActionTaskAssignColorCategory extends Base
{
public function testBadProject()
{
$action = new Action\TaskAssignColorCategory($this->registry, 3, Task::EVENT_CREATE_UPDATE);
$action = new Action\TaskAssignColorCategory($this->container, 3, Task::EVENT_CREATE_UPDATE);
$event = array(
'project_id' => 2,
@@ -25,15 +25,15 @@ class ActionTaskAssignColorCategory extends Base
public function testExecute()
{
$action = new Action\TaskAssignColorCategory($this->registry, 1, Task::EVENT_CREATE_UPDATE);
$action = new Action\TaskAssignColorCategory($this->container, 1, Task::EVENT_CREATE_UPDATE);
$action->setParam('category_id', 1);
$action->setParam('color_id', 'blue');
// We create a task in the first column
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $c->create(array('name' => 'c1')));

View File

@@ -10,7 +10,7 @@ class ActionTaskAssignColorUser extends Base
{
public function testBadProject()
{
$action = new Action\TaskAssignColorUser($this->registry, 3, Task::EVENT_CREATE);
$action = new Action\TaskAssignColorUser($this->container, 3, Task::EVENT_CREATE);
$event = array(
'project_id' => 2,
@@ -24,14 +24,14 @@ class ActionTaskAssignColorUser extends Base
public function testExecute()
{
$action = new Action\TaskAssignColorUser($this->registry, 1, Task::EVENT_ASSIGNEE_CHANGE);
$action = new Action\TaskAssignColorUser($this->container, 1, Task::EVENT_ASSIGNEE_CHANGE);
$action->setParam('user_id', 1);
$action->setParam('color_id', 'blue');
// We create a task in the first column
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1, 'color_id' => 'green')));

View File

@@ -11,7 +11,7 @@ class ActionTaskAssignCurrentUser extends Base
{
public function testBadProject()
{
$action = new Action\TaskAssignCurrentUser($this->registry, 3, Task::EVENT_CREATE);
$action = new Action\TaskAssignCurrentUser($this->container, 3, Task::EVENT_CREATE);
$action->setParam('column_id', 5);
$event = array(
@@ -26,7 +26,7 @@ class ActionTaskAssignCurrentUser extends Base
public function testBadColumn()
{
$action = new Action\TaskAssignCurrentUser($this->registry, 3, Task::EVENT_CREATE);
$action = new Action\TaskAssignCurrentUser($this->container, 3, Task::EVENT_CREATE);
$action->setParam('column_id', 5);
$event = array(
@@ -40,17 +40,17 @@ class ActionTaskAssignCurrentUser extends Base
public function testExecute()
{
$action = new Action\TaskAssignCurrentUser($this->registry, 1, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskAssignCurrentUser($this->container, 1, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 2);
$_SESSION = array(
'user' => array('id' => 5)
);
// We create a task in the first column
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$a = new Acl($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$a = new Acl($this->container);
$this->assertEquals(5, $a->getUserId());
$this->assertEquals(1, $p->create(array('name' => 'test')));

View File

@@ -10,7 +10,7 @@ class ActionTaskAssignSpecificUser extends Base
{
public function testBadProject()
{
$action = new Action\TaskAssignSpecificUser($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskAssignSpecificUser($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -25,7 +25,7 @@ class ActionTaskAssignSpecificUser extends Base
public function testBadColumn()
{
$action = new Action\TaskAssignSpecificUser($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskAssignSpecificUser($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -39,14 +39,14 @@ class ActionTaskAssignSpecificUser extends Base
public function testExecute()
{
$action = new Action\TaskAssignSpecificUser($this->registry, 1, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskAssignSpecificUser($this->container, 1, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 2);
$action->setParam('user_id', 1);
// We create a task in the first column
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));

View File

@@ -11,7 +11,7 @@ class ActionTaskCloseTest extends Base
{
public function testExecutable()
{
$action = new Action\TaskClose($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskClose($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -22,7 +22,7 @@ class ActionTaskCloseTest extends Base
$this->assertTrue($action->isExecutable($event));
$action = new Action\TaskClose($this->registry, 3, GithubWebhook::EVENT_COMMIT);
$action = new Action\TaskClose($this->container, 3, GithubWebhook::EVENT_COMMIT);
$event = array(
'project_id' => 3,
@@ -34,7 +34,7 @@ class ActionTaskCloseTest extends Base
public function testBadEvent()
{
$action = new Action\TaskClose($this->registry, 3, Task::EVENT_UPDATE);
$action = new Action\TaskClose($this->container, 3, Task::EVENT_UPDATE);
$action->setParam('column_id', 5);
$event = array(
@@ -49,7 +49,7 @@ class ActionTaskCloseTest extends Base
public function testBadProject()
{
$action = new Action\TaskClose($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskClose($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -64,7 +64,7 @@ class ActionTaskCloseTest extends Base
public function testBadColumn()
{
$action = new Action\TaskClose($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskClose($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -78,13 +78,13 @@ class ActionTaskCloseTest extends Base
public function testExecute()
{
$action = new Action\TaskClose($this->registry, 1, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskClose($this->container, 1, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 2);
// We create a task in the first column
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));

View File

@@ -10,7 +10,7 @@ class ActionTaskDuplicateAnotherProject extends Base
{
public function testBadProject()
{
$action = new Action\TaskDuplicateAnotherProject($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskDuplicateAnotherProject($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -25,7 +25,7 @@ class ActionTaskDuplicateAnotherProject extends Base
public function testBadColumn()
{
$action = new Action\TaskDuplicateAnotherProject($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskDuplicateAnotherProject($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -39,12 +39,12 @@ class ActionTaskDuplicateAnotherProject extends Base
public function testExecute()
{
$action = new Action\TaskDuplicateAnotherProject($this->registry, 1, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskDuplicateAnotherProject($this->container, 1, Task::EVENT_MOVE_COLUMN);
// We create a task in the first column
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($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, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));

View File

@@ -10,7 +10,7 @@ class ActionTaskMoveAnotherProject extends Base
{
public function testBadProject()
{
$action = new Action\TaskMoveAnotherProject($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskMoveAnotherProject($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -25,7 +25,7 @@ class ActionTaskMoveAnotherProject extends Base
public function testBadColumn()
{
$action = new Action\TaskMoveAnotherProject($this->registry, 3, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskMoveAnotherProject($this->container, 3, Task::EVENT_MOVE_COLUMN);
$action->setParam('column_id', 5);
$event = array(
@@ -39,12 +39,12 @@ class ActionTaskMoveAnotherProject extends Base
public function testExecute()
{
$action = new Action\TaskMoveAnotherProject($this->registry, 1, Task::EVENT_MOVE_COLUMN);
$action = new Action\TaskMoveAnotherProject($this->container, 1, Task::EVENT_MOVE_COLUMN);
// We create a task in the first column
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($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, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));

View File

@@ -13,9 +13,9 @@ class ActionTest extends Base
{
public function testFetchActions()
{
$action = new Action($this->registry);
$board = new Board($this->registry);
$project = new Project($this->registry);
$action = new Action($this->container);
$board = new Board($this->container);
$project = new Project($this->container);
$this->assertEquals(1, $project->create(array('name' => 'unit_test')));
@@ -49,11 +49,11 @@ class ActionTest extends Base
public function testEventMoveColumn()
{
$task = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$board = new Board($this->registry);
$project = new Project($this->registry);
$action = new Action($this->registry);
$task = new Task($this->container);
$tf = new TaskFinder($this->container);
$board = new Board($this->container);
$project = new Project($this->container);
$action = new Action($this->container);
// We create a project
$this->assertEquals(1, $project->create(array('name' => 'unit_test')));
@@ -88,8 +88,8 @@ class ActionTest extends Base
// We move our task
$task->movePosition(1, 1, 4, 1);
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
$this->assertFalse($this->registry->shared('event')->isEventTriggered(Task::EVENT_UPDATE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
$this->assertFalse($this->container['event']->isEventTriggered(Task::EVENT_UPDATE));
// Our task should be closed
$t1 = $tf->getById(1);
@@ -99,11 +99,11 @@ class ActionTest extends Base
public function testExecuteMultipleActions()
{
$task = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$board = new Board($this->registry);
$project = new Project($this->registry);
$action = new Action($this->registry);
$task = new Task($this->container);
$tf = new TaskFinder($this->container);
$board = new Board($this->container);
$project = new Project($this->container);
$action = new Action($this->container);
// We create 2 projects
$this->assertEquals(1, $project->create(array('name' => 'unit_test1')));
@@ -142,8 +142,8 @@ class ActionTest extends Base
$action->attachEvents();
// Events should be attached
$this->assertTrue($this->registry->shared('event')->hasListener(Task::EVENT_CLOSE, 'Action\TaskDuplicateAnotherProject'));
$this->assertTrue($this->registry->shared('event')->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\TaskClose'));
$this->assertTrue($this->container['event']->hasListener(Task::EVENT_CLOSE, 'Action\TaskDuplicateAnotherProject'));
$this->assertTrue($this->container['event']->hasListener(Task::EVENT_MOVE_COLUMN, 'Action\TaskClose'));
// Our task should be open, linked to the first project and in the first column
$t1 = $tf->getById(1);
@@ -154,8 +154,8 @@ class ActionTest extends Base
// We move our task
$task->movePosition(1, 1, 4, 1);
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CLOSE));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CLOSE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
// Our task should be closed
$t1 = $tf->getById(1);

View File

@@ -3,19 +3,12 @@
require __DIR__.'/../../vendor/autoload.php';
require __DIR__.'/../../app/constants.php';
use Core\Loader;
use Core\Registry;
date_default_timezone_set('UTC');
abstract class Base extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->registry = new Registry;
$this->registry->db = function() { return setup_db(); };
$this->registry->event = function() { return setup_events(); };
if (DB_DRIVER === 'mysql') {
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$pdo->exec('DROP DATABASE '.DB_NAME);
@@ -28,10 +21,14 @@ abstract class Base extends PHPUnit_Framework_TestCase
$pdo->exec('CREATE DATABASE '.DB_NAME.' WITH OWNER '.DB_USERNAME);
$pdo = null;
}
$this->container = new Pimple\Container;
$this->container->register(new ServiceProvider\Database);
$this->container->register(new ServiceProvider\Event);
}
public function tearDown()
{
$this->registry->shared('db')->closeConnection();
$this->container['db']->closeConnection();
}
}

View File

@@ -10,9 +10,9 @@ class BoardTest extends Base
{
public function testCreation()
{
$p = new Project($this->registry);
$b = new Board($this->registry);
$c = new Config($this->registry);
$p = new Project($this->container);
$b = new Board($this->container);
$c = new Config($this->container);
// Default columns
@@ -43,8 +43,8 @@ class BoardTest extends Base
public function testGetBoard()
{
$p = new Project($this->registry);
$b = new Board($this->registry);
$p = new Project($this->container);
$b = new Board($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
@@ -57,8 +57,8 @@ class BoardTest extends Base
public function testGetColumn()
{
$p = new Project($this->registry);
$b = new Board($this->registry);
$p = new Project($this->container);
$b = new Board($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
@@ -72,8 +72,8 @@ class BoardTest extends Base
public function testRemoveColumn()
{
$p = new Project($this->registry);
$b = new Board($this->registry);
$p = new Project($this->container);
$b = new Board($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
$this->assertTrue($b->removeColumn(3));
@@ -86,8 +86,8 @@ class BoardTest extends Base
public function testUpdateColumn()
{
$p = new Project($this->registry);
$b = new Board($this->registry);
$p = new Project($this->container);
$b = new Board($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
@@ -107,8 +107,8 @@ class BoardTest extends Base
public function testAddColumn()
{
$p = new Project($this->registry);
$b = new Board($this->registry);
$p = new Project($this->container);
$b = new Board($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
$this->assertTrue($b->addColumn(1, 'another column'));
@@ -129,8 +129,8 @@ class BoardTest extends Base
public function testMoveColumns()
{
$p = new Project($this->registry);
$b = new Board($this->registry);
$p = new Project($this->container);
$b = new Board($this->container);
// We create 2 projects
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));

View File

@@ -12,10 +12,10 @@ class CategoryTest extends Base
{
public function testCreation()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1)));
@@ -35,10 +35,10 @@ class CategoryTest extends Base
public function testRemove()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $c->create(array('name' => 'Category #1', 'project_id' => 1)));

View File

@@ -10,9 +10,9 @@ class CommentTest extends Base
{
public function testCreate()
{
$c = new Comment($this->registry);
$t = new Task($this->registry);
$p = new Project($this->registry);
$c = new Comment($this->container);
$t = new Task($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
@@ -30,9 +30,9 @@ class CommentTest extends Base
public function testGetAll()
{
$c = new Comment($this->registry);
$t = new Task($this->registry);
$p = new Project($this->registry);
$c = new Comment($this->container);
$t = new Task($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
@@ -53,9 +53,9 @@ class CommentTest extends Base
public function testUpdate()
{
$c = new Comment($this->registry);
$t = new Task($this->registry);
$p = new Project($this->registry);
$c = new Comment($this->container);
$t = new Task($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
@@ -69,9 +69,9 @@ class CommentTest extends Base
public function validateRemove()
{
$c = new Comment($this->registry);
$t = new Task($this->registry);
$p = new Project($this->registry);
$c = new Comment($this->container);
$t = new Task($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
@@ -84,7 +84,7 @@ class CommentTest extends Base
public function testValidateCreation()
{
$c = new Comment($this->registry);
$c = new Comment($this->container);
$result = $c->validateCreation(array('user_id' => 1, 'task_id' => 1, 'comment' => 'bla'));
$this->assertTrue($result[0]);
@@ -113,7 +113,7 @@ class CommentTest extends Base
public function testValidateModification()
{
$c = new Comment($this->registry);
$c = new Comment($this->container);
$result = $c->validateModification(array('id' => 1, 'comment' => 'bla'));
$this->assertTrue($result[0]);

View File

@@ -8,7 +8,7 @@ class ConfigTest extends Base
{
public function testDefaultValues()
{
$c = new Config($this->registry);
$c = new Config($this->container);
$this->assertEquals('en_US', $c->get('application_language'));
$this->assertEquals('UTC', $c->get('application_timezone'));
@@ -23,7 +23,7 @@ class ConfigTest extends Base
public function testGet()
{
$c = new Config($this->registry);
$c = new Config($this->container);
$this->assertEquals('', $c->get('board_columns'));
$this->assertEquals('test', $c->get('board_columns', 'test'));

View File

@@ -8,7 +8,7 @@ class DateParserTest extends Base
{
public function testValidDate()
{
$d = new DateParser($this->registry);
$d = new DateParser($this->container);
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('2014-03-05', 'Y-m-d')));
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getValidDate('2014_03_05', 'Y_m_d')));
@@ -23,7 +23,7 @@ class DateParserTest extends Base
public function testGetTimestamp()
{
$d = new DateParser($this->registry);
$d = new DateParser($this->container);
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014-03-05')));
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('2014_03_05')));

View File

@@ -11,10 +11,10 @@ class NotificationTest extends Base
{
public function testGetUsersWithNotification()
{
$u = new User($this->registry);
$p = new Project($this->registry);
$n = new Notification($this->registry);
$pp = new ProjectPermission($this->registry);
$u = new User($this->container);
$p = new Project($this->container);
$n = new Notification($this->container);
$pp = new ProjectPermission($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
@@ -51,10 +51,10 @@ class NotificationTest extends Base
public function testGetUserList()
{
$u = new User($this->registry);
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$n = new Notification($this->registry);
$u = new User($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$n = new Notification($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest1')));
$this->assertEquals(2, $p->create(array('name' => 'UnitTest2')));

View File

@@ -11,10 +11,10 @@ class ProjectActivityTest extends Base
{
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);
$t = new Task($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)));
@@ -36,10 +36,10 @@ class ProjectActivityTest extends Base
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);
$t = new Task($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)));
@@ -62,10 +62,10 @@ 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);
$t = new Task($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)));
@@ -77,7 +77,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 +97,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());
}
}

View File

@@ -10,12 +10,12 @@ class ProjectPermissionTest extends Base
{
public function testAllowEverybody()
{
$user = new User($this->registry);
$user = new User($this->container);
$this->assertTrue($user->create(array('username' => 'unittest#1', 'password' => 'unittest')));
$this->assertTrue($user->create(array('username' => 'unittest#2', 'password' => 'unittest')));
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertFalse($pp->isEverybodyAllowed(1));
@@ -37,11 +37,11 @@ class ProjectPermissionTest extends Base
public function testDisallowEverybody()
{
// We create a regular user
$user = new User($this->registry);
$user = new User($this->container);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
@@ -52,9 +52,9 @@ class ProjectPermissionTest extends Base
public function testAllowUser()
{
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$user = new User($this->registry);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$user = new User($this->container);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
@@ -79,9 +79,9 @@ class ProjectPermissionTest extends Base
public function testRevokeUser()
{
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$user = new User($this->registry);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$user = new User($this->container);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
@@ -135,10 +135,10 @@ class ProjectPermissionTest extends Base
public function testUsersList()
{
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$user = new User($this->registry);
$user = new User($this->container);
$user->create(array('username' => 'unittest', 'password' => 'unittest'));
// We create project

View File

@@ -13,7 +13,7 @@ class ProjectTest extends Base
{
public function testCreation()
{
$p = new Project($this->registry);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
@@ -28,7 +28,7 @@ class ProjectTest extends Base
public function testUpdateLastModifiedDate()
{
$p = new Project($this->registry);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$now = time();
@@ -47,8 +47,8 @@ class ProjectTest extends Base
public function testIsLastModified()
{
$p = new Project($this->registry);
$t = new Task($this->registry);
$p = new Project($this->container);
$t = new Task($this->container);
$now = time();
$p->attachEvents();
@@ -62,8 +62,8 @@ class ProjectTest extends Base
sleep(1);
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
$this->assertEquals('Event\ProjectModificationDateListener', $this->registry->shared('event')->getLastListenerExecuted());
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
$this->assertEquals('Event\ProjectModificationDateListener', $this->container['event']->getLastListenerExecuted());
$project = $p->getById(1);
$this->assertNotEmpty($project);
@@ -72,7 +72,7 @@ class ProjectTest extends Base
public function testRemove()
{
$p = new Project($this->registry);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertTrue($p->remove(1));
@@ -81,7 +81,7 @@ class ProjectTest extends Base
public function testEnable()
{
$p = new Project($this->registry);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertTrue($p->disable(1));
@@ -95,7 +95,7 @@ class ProjectTest extends Base
public function testDisable()
{
$p = new Project($this->registry);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertTrue($p->disable(1));
@@ -110,7 +110,7 @@ class ProjectTest extends Base
public function testEnablePublicAccess()
{
$p = new Project($this->registry);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertTrue($p->enablePublicAccess(1));
@@ -125,7 +125,7 @@ class ProjectTest extends Base
public function testDisablePublicAccess()
{
$p = new Project($this->registry);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertTrue($p->enablePublicAccess(1));
@@ -141,7 +141,7 @@ class ProjectTest extends Base
public function testDuplicate()
{
$p = new Project($this->registry);
$p = new Project($this->container);
// Clone public project
$this->assertEquals(1, $p->create(array('name' => 'Public')));
@@ -165,7 +165,7 @@ class ProjectTest extends Base
$this->assertEquals(0, $project['is_public']);
$this->assertEmpty($project['token']);
$pp = new ProjectPermission($this->registry);
$pp = new ProjectPermission($this->container);
$this->assertEquals(array(1 => 'admin'), $pp->getMembers(3));
$this->assertEquals(array(1 => 'admin'), $pp->getMembers(4));

View File

@@ -12,9 +12,9 @@ class SubTaskTest extends Base
{
public function testDuplicate()
{
$t = new Task($this->registry);
$s = new SubTask($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$s = new SubTask($this->container);
$p = new Project($this->container);
// We create a project
$this->assertEquals(1, $p->create(array('name' => 'test1')));

View File

@@ -12,10 +12,10 @@ class TaskExportTest extends Base
{
public function testExport()
{
$t = new Task($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
$e = new TaskExport($this->registry);
$t = new Task($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
$e = new TaskExport($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Export Project')));
$this->assertNotFalse($c->create(array('name' => 'Category #1', 'project_id' => 1)));

View File

@@ -13,9 +13,9 @@ class TaskFinderTest extends Base
{
public function testGetOverdueTasks()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($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, 'date_due' => strtotime('-1 day'))));

View File

@@ -13,11 +13,11 @@ class TaskPermissionTest extends Base
{
public function testPrepareCreation()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$tp = new TaskPermission($this->registry);
$p = new Project($this->registry);
$u = new User($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$tp = new TaskPermission($this->container);
$p = new Project($this->container);
$u = new User($this->container);
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456')));
$this->assertTrue($u->create(array('username' => 'toto2', 'password' => '123456')));

View File

@@ -13,9 +13,9 @@ class TaskTest extends Base
{
public function testPrepareCreation()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -92,9 +92,9 @@ class TaskTest extends Base
public function testPrepareModification()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -112,9 +112,9 @@ class TaskTest extends Base
public function testCreation()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($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, 'column_id' => 1)));
@@ -150,9 +150,9 @@ class TaskTest extends Base
public function testRemove()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1)));
@@ -163,9 +163,9 @@ class TaskTest extends Base
public function testMoveTaskWithColumnThatNotChange()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
@@ -225,16 +225,16 @@ class TaskTest extends Base
public function testMoveTaskWithBadPreviousPosition()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $this->registry->shared('db')->table('tasks')->insert(array('title' => 'A', 'column_id' => 1, 'project_id' => 1, 'position' => 1)));
$this->assertEquals(1, $this->container['db']->table('tasks')->insert(array('title' => 'A', 'column_id' => 1, 'project_id' => 1, 'position' => 1)));
// Both tasks have the same position
$this->assertEquals(2, $this->registry->shared('db')->table('tasks')->insert(array('title' => 'B', 'column_id' => 2, 'project_id' => 1, 'position' => 1)));
$this->assertEquals(3, $this->registry->shared('db')->table('tasks')->insert(array('title' => 'C', 'column_id' => 2, 'project_id' => 1, 'position' => 1)));
$this->assertEquals(2, $this->container['db']->table('tasks')->insert(array('title' => 'B', 'column_id' => 2, 'project_id' => 1, 'position' => 1)));
$this->assertEquals(3, $this->container['db']->table('tasks')->insert(array('title' => 'C', 'column_id' => 2, 'project_id' => 1, 'position' => 1)));
// Move the first column to the last position of the 2nd column
$this->assertTrue($t->movePosition(1, 1, 2, 3));
@@ -258,9 +258,9 @@ class TaskTest extends Base
public function testMoveTaskTop()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($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, 'column_id' => 1)));
@@ -295,9 +295,9 @@ class TaskTest extends Base
public function testMoveTaskBottom()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($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, 'column_id' => 1)));
@@ -332,9 +332,9 @@ class TaskTest extends Base
public function testMovePosition()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$counter = 1;
@@ -487,10 +487,10 @@ class TaskTest extends Base
public function testDuplicateToTheSameProject()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
// We create a task and a project
$this->assertEquals(1, $p->create(array('name' => 'test1')));
@@ -509,7 +509,7 @@ class TaskTest extends Base
// We duplicate our task
$this->assertEquals(2, $t->duplicateToSameProject($task));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
$task = $tf->getById(2);
@@ -524,10 +524,10 @@ class TaskTest extends Base
public function testDuplicateToAnotherProject()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$c = new Category($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$c = new Category($this->container);
// We create 2 projects
$this->assertEquals(1, $p->create(array('name' => 'test1')));
@@ -542,7 +542,7 @@ class TaskTest extends Base
// We duplicate our task to the 2nd project
$this->assertEquals(2, $t->duplicateToAnotherProject(2, $task));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
$task = $tf->getById(2);
@@ -557,11 +557,11 @@ class TaskTest extends Base
public function testMoveToAnotherProject()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$pp = new ProjectPermission($this->registry);
$user = new User($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$user = new User($this->container);
// We create a regular user
$user->create(array('username' => 'unittest1', 'password' => 'unittest'));
@@ -578,7 +578,7 @@ class TaskTest extends Base
// We duplicate our task to the 2nd project
$task = $tf->getById(1);
$this->assertEquals(1, $t->moveToAnotherProject(2, $task));
//$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
//$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
// Check the values of the duplicated task
$task = $tf->getById(1);
@@ -604,44 +604,44 @@ class TaskTest extends Base
public function testEvents()
{
$t = new Task($this->registry);
$p = new Project($this->registry);
$t = new Task($this->container);
$p = new Project($this->container);
// We create a project
$this->assertEquals(1, $p->create(array('name' => 'test')));
// We create task
$this->assertEquals(1, $t->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE));
// We update a task
$this->assertTrue($t->update(array('title' => 'test2', 'id' => 1)));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_UPDATE));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CREATE_UPDATE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_UPDATE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CREATE_UPDATE));
// We close our task
$this->assertTrue($t->close(1));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_CLOSE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_CLOSE));
// We open our task
$this->assertTrue($t->open(1));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_OPEN));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_OPEN));
// We change the column of our task
$this->assertTrue($t->movePosition(1, 1, 2, 1));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
// We change the position of our task
$this->assertEquals(2, $t->create(array('title' => 'test 2', 'project_id' => 1, 'column_id' => 2)));
$this->assertTrue($t->movePosition(1, 1, 2, 2));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_POSITION));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_POSITION));
// We change the column and the position of our task
$this->assertTrue($t->movePosition(1, 1, 1, 1));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_MOVE_COLUMN));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_MOVE_COLUMN));
// We change the assignee
$this->assertTrue($t->update(array('owner_id' => 1, 'id' => 1)));
$this->assertTrue($this->registry->shared('event')->isEventTriggered(Task::EVENT_ASSIGNEE_CHANGE));
$this->assertTrue($this->container['event']->isEventTriggered(Task::EVENT_ASSIGNEE_CHANGE));
}
}

View File

@@ -12,11 +12,11 @@ class TimeTrackingTest extends Base
{
public function testCalculateTime()
{
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$s = new SubTask($this->registry);
$ts = new TimeTracking($this->registry);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$s = new SubTask($this->container);
$ts = new TimeTracking($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
$this->assertEquals(1, $t->create(array('title' => 'Task #1', 'project_id' => 1, 'time_estimated' => 4.5)));

View File

@@ -20,7 +20,7 @@ class UserTest extends Base
public function testPrepare()
{
$u = new User($this->registry);
$u = new User($this->container);
$input = array(
'username' => 'user1',
@@ -71,7 +71,7 @@ class UserTest extends Base
public function testCreate()
{
$u = new User($this->registry);
$u = new User($this->container);
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
$this->assertTrue($u->create(array('username' => 'titi', 'is_ldap_user' => 1)));
$this->assertFalse($u->create(array('username' => 'toto')));
@@ -103,7 +103,7 @@ class UserTest extends Base
public function testUpdate()
{
$u = new User($this->registry);
$u = new User($this->container);
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
$this->assertTrue($u->update(array('id' => 2, 'username' => 'biloute')));
@@ -118,10 +118,10 @@ class UserTest extends Base
public function testRemove()
{
$u = new User($this->registry);
$t = new Task($this->registry);
$tf = new TaskFinder($this->registry);
$p = new Project($this->registry);
$u = new User($this->container);
$t = new Task($this->container);
$tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertTrue($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));