Change comments table structure (drop foreign key on user_id)
This commit is contained in:
@@ -17,16 +17,24 @@ class CommentTest extends Base
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test1')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 3, 'owner_id' => 1)));
|
||||
$this->assertNotFalse($c->create(array('task_id' => 1, 'comment' => 'bla bla', 'user_id' => 1)));
|
||||
$this->assertEquals(1, $c->create(array('task_id' => 1, 'comment' => 'bla bla', 'user_id' => 1)));
|
||||
$this->assertEquals(2, $c->create(array('task_id' => 1, 'comment' => 'bla bla')));
|
||||
|
||||
$comment = $c->getById(1);
|
||||
|
||||
$this->assertNotEmpty($comment);
|
||||
$this->assertEquals('bla bla', $comment['comment']);
|
||||
$this->assertEquals(1, $comment['task_id']);
|
||||
$this->assertEquals(1, $comment['user_id']);
|
||||
$this->assertEquals('admin', $comment['username']);
|
||||
$this->assertNotEmpty($comment['date']);
|
||||
$this->assertEquals(time(), $comment['date_creation'], '', 3);
|
||||
|
||||
$comment = $c->getById(2);
|
||||
$this->assertNotEmpty($comment);
|
||||
$this->assertEquals('bla bla', $comment['comment']);
|
||||
$this->assertEquals(1, $comment['task_id']);
|
||||
$this->assertEquals(0, $comment['user_id']);
|
||||
$this->assertEquals('', $comment['username']);
|
||||
$this->assertEquals(time(), $comment['date_creation'], '', 3);
|
||||
}
|
||||
|
||||
public function testGetAll()
|
||||
@@ -103,7 +111,7 @@ class CommentTest extends Base
|
||||
$this->assertFalse($result[0]);
|
||||
|
||||
$result = $c->validateCreation(array('task_id' => 1, 'comment' => 'bla'));
|
||||
$this->assertFalse($result[0]);
|
||||
$this->assertTrue($result[0]);
|
||||
|
||||
$result = $c->validateCreation(array('comment' => 'bla'));
|
||||
$this->assertFalse($result[0]);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
use Model\User;
|
||||
use Model\Subtask;
|
||||
use Model\Comment;
|
||||
use Model\Task;
|
||||
use Model\TaskCreation;
|
||||
use Model\TaskFinder;
|
||||
@@ -133,10 +135,14 @@ class UserTest extends Base
|
||||
$tc = new TaskCreation($this->container);
|
||||
$tf = new TaskFinder($this->container);
|
||||
$p = new Project($this->container);
|
||||
$s = new Subtask($this->container);
|
||||
$c = new Comment($this->container);
|
||||
|
||||
$this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
|
||||
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
|
||||
$this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'owner_id' => 2)));
|
||||
$this->assertEquals(1, $s->create(array('title' => 'Subtask #1', 'user_id' => 2, 'task_id' => 1)));
|
||||
$this->assertEquals(1, $c->create(array('comment' => 'foobar', 'user_id' => 2, 'task_id' => 1)));
|
||||
|
||||
$task = $tf->getById(1);
|
||||
$this->assertEquals(1, $task['id']);
|
||||
@@ -152,6 +158,16 @@ class UserTest extends Base
|
||||
$this->assertEquals(1, $task['id']);
|
||||
$this->assertEquals(0, $task['owner_id']);
|
||||
|
||||
// Make sure that assigned subtasks are unassigned after removing the user
|
||||
$subtask = $s->getById(1);
|
||||
$this->assertEquals(1, $subtask['id']);
|
||||
$this->assertEquals(0, $subtask['user_id']);
|
||||
|
||||
// Make sure that comments are not related to the user anymore
|
||||
$comment = $c->getById(1);
|
||||
$this->assertEquals(1, $comment['id']);
|
||||
$this->assertEquals(0, $comment['user_id']);
|
||||
|
||||
// Make sure that private projects are also removed
|
||||
$user_id1 = $u->create(array('username' => 'toto1', 'password' => '123456', 'name' => 'Toto'));
|
||||
$user_id2 = $u->create(array('username' => 'toto2', 'password' => '123456', 'name' => 'Toto'));
|
||||
|
||||
Reference in New Issue
Block a user