public function testValidateCreation()
 {
     $validator = new TaskLinkValidator($this->container);
     $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 = $validator->validateCreation(array('task_id' => 1, 'link_id' => 1, 'opposite_task_id' => 2));
     $this->assertTrue($r[0]);
     $r = $validator->validateCreation(array('task_id' => 1, 'link_id' => 1));
     $this->assertFalse($r[0]);
     $r = $validator->validateCreation(array('task_id' => 1, 'opposite_task_id' => 2));
     $this->assertFalse($r[0]);
     $r = $validator->validateCreation(array('task_id' => 1, 'opposite_task_id' => 2));
     $this->assertFalse($r[0]);
     $r = $validator->validateCreation(array('task_id' => 1, 'link_id' => 1, 'opposite_task_id' => 1));
     $this->assertFalse($r[0]);
 }
Example #2
0
 public function testSearchWithLink()
 {
     $p = new Project($this->container);
     $u = new User($this->container);
     $tc = new TaskCreation($this->container);
     $tl = new TaskLink($this->container);
     $tf = new TaskFilter($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(2, $u->create(array('username' => 'bob', 'name' => 'Bob Ryan')));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is awesome', 'color_id' => 'light_green')));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'my task title is amazing', 'color_id' => 'blue')));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'Bob at work')));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'I have a bad feeling about that')));
     $this->assertEquals(1, $tl->create(1, 2, 9));
     // #1 is a milestone of #2
     $this->assertEquals(3, $tl->create(2, 1, 2));
     // #2 blocks #1
     $this->assertEquals(5, $tl->create(3, 2, 2));
     // #3 blocks #2
     $tf->search('link:"is a milestone of"');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(1, $tasks);
     $this->assertEquals('my task title is awesome', $tasks[0]['title']);
     $tf->search('link:"is a milestone of" amazing');
     $tasks = $tf->findAll();
     $this->assertEmpty($tasks);
     $tf->search('link:"unknown"');
     $tasks = $tf->findAll();
     $this->assertEmpty($tasks);
     $tf->search('link:unknown');
     $tasks = $tf->findAll();
     $this->assertEmpty($tasks);
     $tf->search('link:blocks amazing');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(1, $tasks);
     $this->assertEquals('my task title is amazing', $tasks[0]['title']);
     $tf->search('link:"is a milestone of" link:blocks');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(3, $tasks);
     $this->assertEquals('my task title is awesome', $tasks[0]['title']);
     $this->assertEquals('my task title is amazing', $tasks[1]['title']);
     $this->assertEquals('Bob at work', $tasks[2]['title']);
     $tf->search('link:"is a milestone of" link:blocks link:unknown');
     $tasks = $tf->findAll();
     $this->assertNotEmpty($tasks);
     $this->assertCount(3, $tasks);
     $this->assertEquals('my task title is awesome', $tasks[0]['title']);
     $this->assertEquals('my task title is amazing', $tasks[1]['title']);
     $this->assertEquals('Bob at work', $tasks[2]['title']);
 }
 public function testRemove()
 {
     $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')));
     $this->assertEquals(1, $tl->create(1, 2, 2));
     $links = $tl->getAll(1);
     $this->assertNotEmpty($links);
     $links = $tl->getAll(2);
     $this->assertNotEmpty($links);
     $this->assertTrue($tl->remove($links[0]['id']));
     $links = $tl->getAll(1);
     $this->assertEmpty($links);
     $links = $tl->getAll(2);
     $this->assertEmpty($links);
 }