Move task link validator methods
This commit is contained in:
@@ -194,53 +194,4 @@ class TaskLinkTest extends Base
|
||||
$links = $tl->getAll(2);
|
||||
$this->assertEmpty($links);
|
||||
}
|
||||
|
||||
public function testValidation()
|
||||
{
|
||||
$tl = new TaskLink($this->container);
|
||||
$p = new Project($this->container);
|
||||
$tc = new TaskCreation($this->container);
|
||||
|
||||
$this->assertEquals(1, $p->create(array('name' => 'test')));
|
||||
$this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'A')));
|
||||
$this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'B')));
|
||||
|
||||
$links = $tl->getAll(1);
|
||||
$this->assertEmpty($links);
|
||||
|
||||
$links = $tl->getAll(2);
|
||||
$this->assertEmpty($links);
|
||||
|
||||
// Check creation
|
||||
$r = $tl->validateCreation(array('task_id' => 1, 'link_id' => 1, 'opposite_task_id' => 2));
|
||||
$this->assertTrue($r[0]);
|
||||
|
||||
$r = $tl->validateCreation(array('task_id' => 1, 'link_id' => 1));
|
||||
$this->assertFalse($r[0]);
|
||||
|
||||
$r = $tl->validateCreation(array('task_id' => 1, 'opposite_task_id' => 2));
|
||||
$this->assertFalse($r[0]);
|
||||
|
||||
$r = $tl->validateCreation(array('task_id' => 1, 'opposite_task_id' => 2));
|
||||
$this->assertFalse($r[0]);
|
||||
|
||||
$r = $tl->validateCreation(array('task_id' => 1, 'link_id' => 1, 'opposite_task_id' => 1));
|
||||
$this->assertFalse($r[0]);
|
||||
|
||||
// Check modification
|
||||
$r = $tl->validateModification(array('id' => 1, 'task_id' => 1, 'link_id' => 1, 'opposite_task_id' => 2));
|
||||
$this->assertTrue($r[0]);
|
||||
|
||||
$r = $tl->validateModification(array('id' => 1, 'task_id' => 1, 'link_id' => 1));
|
||||
$this->assertFalse($r[0]);
|
||||
|
||||
$r = $tl->validateModification(array('id' => 1, 'task_id' => 1, 'opposite_task_id' => 2));
|
||||
$this->assertFalse($r[0]);
|
||||
|
||||
$r = $tl->validateModification(array('id' => 1, 'task_id' => 1, 'opposite_task_id' => 2));
|
||||
$this->assertFalse($r[0]);
|
||||
|
||||
$r = $tl->validateModification(array('id' => 1, 'task_id' => 1, 'link_id' => 1, 'opposite_task_id' => 1));
|
||||
$this->assertFalse($r[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user