public function testMoveUp() { $tc = new TaskCreation($this->container); $s = new Subtask($this->container); $p = new Project($this->container); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(1, $tc->create(array('title' => 'test 1', 'project_id' => 1))); $this->assertEquals(1, $s->create(array('title' => 'subtask #1', 'task_id' => 1))); $this->assertEquals(2, $s->create(array('title' => 'subtask #2', 'task_id' => 1))); $this->assertEquals(3, $s->create(array('title' => 'subtask #3', 'task_id' => 1))); // Check positions $subtask = $s->getById(1); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['position']); $subtask = $s->getById(2); $this->assertNotEmpty($subtask); $this->assertEquals(2, $subtask['position']); $subtask = $s->getById(3); $this->assertNotEmpty($subtask); $this->assertEquals(3, $subtask['position']); // Move up $this->assertTrue($s->moveUp(1, 2)); // Check positions $subtask = $s->getById(1); $this->assertNotEmpty($subtask); $this->assertEquals(2, $subtask['position']); $subtask = $s->getById(2); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['position']); $subtask = $s->getById(3); $this->assertNotEmpty($subtask); $this->assertEquals(3, $subtask['position']); // We can't move up #2 $this->assertFalse($s->moveUp(1, 2)); // Test remove $this->assertTrue($s->remove(1)); $this->assertTrue($s->moveUp(1, 3)); // Check positions $subtask = $s->getById(1); $this->assertEmpty($subtask); $subtask = $s->getById(2); $this->assertNotEmpty($subtask); $this->assertEquals(2, $subtask['position']); $subtask = $s->getById(3); $this->assertNotEmpty($subtask); $this->assertEquals(1, $subtask['position']); }