summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functionals/ApiTest.php24
-rw-r--r--tests/units/Base.php2
-rw-r--r--tests/units/DateParserTest.php6
-rw-r--r--tests/units/DatetimeHelperTest.php10
-rw-r--r--tests/units/ProjectDailyColumnStatsTest.php (renamed from tests/units/ProjectDailySummaryTest.php)6
-rw-r--r--tests/units/TaskCreationTest.php52
-rw-r--r--tests/units/TaskDuplicationTest.php30
-rw-r--r--tests/units/TaskFilterTest.php59
-rw-r--r--tests/units/TaskModificationTest.php18
-rw-r--r--tests/units/TaskPositionTest.php107
-rw-r--r--tests/units/UrlHelperTest.php12
11 files changed, 242 insertions, 84 deletions
diff --git a/tests/functionals/ApiTest.php b/tests/functionals/ApiTest.php
index b7ae80f1..284c31b9 100644
--- a/tests/functionals/ApiTest.php
+++ b/tests/functionals/ApiTest.php
@@ -63,6 +63,9 @@ class Api extends PHPUnit_Framework_TestCase
if ($projects) {
foreach ($projects as $project) {
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
$this->assertTrue($this->client->removeProject($project['id']));
}
}
@@ -80,6 +83,9 @@ class Api extends PHPUnit_Framework_TestCase
$project = $this->client->getProjectById(1);
$this->assertNotEmpty($project);
$this->assertEquals(1, $project['id']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
}
public function testGetProjectByName()
@@ -87,6 +93,9 @@ class Api extends PHPUnit_Framework_TestCase
$project = $this->client->getProjectByName('API test');
$this->assertNotEmpty($project);
$this->assertEquals(1, $project['id']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
$project = $this->client->getProjectByName(array('name' => 'API test'));
$this->assertNotEmpty($project);
@@ -97,6 +106,18 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNull($project);
}
+ public function testGetAllProjects()
+ {
+ $projects = $this->client->getAllProjects();
+ $this->assertNotEmpty($projects);
+
+ foreach ($projects as $project) {
+ $this->assertEquals('http://127.0.0.1:8000/?controller=board&action=show&project_id='.$project['id'], $project['url']['board']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=calendar&action=show&project_id='.$project['id'], $project['url']['calendar']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=listing&action=show&project_id='.$project['id'], $project['url']['list']);
+ }
+ }
+
public function testUpdateProject()
{
$project = $this->client->getProjectById(1);
@@ -385,6 +406,7 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNotFalse($task);
$this->assertTrue(is_array($task));
$this->assertEquals('Task #1', $task['title']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']);
}
public function testGetAllTasks()
@@ -394,6 +416,7 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNotFalse($tasks);
$this->assertTrue(is_array($tasks));
$this->assertEquals('Task #1', $tasks[0]['title']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$tasks[0]['id'].'&project_id='.$tasks[0]['project_id'], $tasks[0]['url']);
$tasks = $this->client->getAllTasks(2, 0);
@@ -1030,5 +1053,6 @@ class Api extends PHPUnit_Framework_TestCase
$this->assertNotEmpty($task);
$this->assertEquals('Task with external ticket number', $task['title']);
$this->assertEquals('TICKET-1234', $task['reference']);
+ $this->assertEquals('http://127.0.0.1:8000/?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'], $task['url']);
}
} \ No newline at end of file
diff --git a/tests/units/Base.php b/tests/units/Base.php
index 7ad4e626..0a045a09 100644
--- a/tests/units/Base.php
+++ b/tests/units/Base.php
@@ -58,6 +58,8 @@ abstract class Base extends PHPUnit_Framework_TestCase
public function setUp()
{
+ date_default_timezone_set('UTC');
+
if (DB_DRIVER === 'mysql') {
$pdo = new PDO('mysql:host='.DB_HOSTNAME, DB_USERNAME, DB_PASSWORD);
$pdo->exec('DROP DATABASE '.DB_NAME);
diff --git a/tests/units/DateParserTest.php b/tests/units/DateParserTest.php
index 9403063b..4b3e93c8 100644
--- a/tests/units/DateParserTest.php
+++ b/tests/units/DateParserTest.php
@@ -56,6 +56,12 @@ class DateParserTest extends Base
$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')));
$this->assertEquals('2014-03-05', date('Y-m-d', $d->getTimestamp('03/05/2014')));
+ $this->assertEquals('2014-03-25 17:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18 pm')));
+ $this->assertEquals('2014-03-25 05:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18 am')));
+ $this->assertEquals('2014-03-25 05:18', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 5:18am')));
+ $this->assertEquals('2014-03-25 23:14', date('Y-m-d H:i', $d->getTimestamp('03/25/2014 23:14')));
+ $this->assertEquals('2014-03-29 23:14', date('Y-m-d H:i', $d->getTimestamp('2014_03_29 23:14')));
+ $this->assertEquals('2014-03-29 23:14', date('Y-m-d H:i', $d->getTimestamp('2014-03-29 23:14')));
}
public function testConvert()
diff --git a/tests/units/DatetimeHelperTest.php b/tests/units/DatetimeHelperTest.php
index 216cf34c..21d452dd 100644
--- a/tests/units/DatetimeHelperTest.php
+++ b/tests/units/DatetimeHelperTest.php
@@ -2,13 +2,13 @@
require_once __DIR__.'/Base.php';
-use Helper\Datetime;
+use Helper\Dt;
class DatetimeHelperTest extends Base
{
public function testAge()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$this->assertEquals('<15m', $h->age(0, 30));
$this->assertEquals('<30m', $h->age(0, 1000));
@@ -20,7 +20,7 @@ class DatetimeHelperTest extends Base
public function testGetDayHours()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$slots = $h->getDayHours();
@@ -36,7 +36,7 @@ class DatetimeHelperTest extends Base
public function testGetWeekDays()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$slots = $h->getWeekDays();
@@ -48,7 +48,7 @@ class DatetimeHelperTest extends Base
public function testGetWeekDay()
{
- $h = new Datetime($this->container);
+ $h = new Dt($this->container);
$this->assertEquals('Monday', $h->getWeekDay(1));
$this->assertEquals('Sunday', $h->getWeekDay(7));
diff --git a/tests/units/ProjectDailySummaryTest.php b/tests/units/ProjectDailyColumnStatsTest.php
index ed806361..d314ac93 100644
--- a/tests/units/ProjectDailySummaryTest.php
+++ b/tests/units/ProjectDailyColumnStatsTest.php
@@ -3,17 +3,17 @@
require_once __DIR__.'/Base.php';
use Model\Project;
-use Model\ProjectDailySummary;
+use Model\ProjectDailyColumnStats;
use Model\Task;
use Model\TaskCreation;
use Model\TaskStatus;
-class ProjectDailySummaryTest extends Base
+class ProjectDailyColumnStatsTest extends Base
{
public function testUpdateTotals()
{
$p = new Project($this->container);
- $pds = new ProjectDailySummary($this->container);
+ $pds = new ProjectDailyColumnStats($this->container);
$tc = new TaskCreation($this->container);
$ts = new TaskStatus($this->container);
diff --git a/tests/units/TaskCreationTest.php b/tests/units/TaskCreationTest.php
index b3f001c7..03a85b64 100644
--- a/tests/units/TaskCreationTest.php
+++ b/tests/units/TaskCreationTest.php
@@ -175,6 +175,28 @@ class TaskCreationTest extends Base
$this->assertEquals(1, $task['creator_id']);
}
+ public function testThatCreatorIsDefined()
+ {
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+
+ $_SESSION = array();
+ $_SESSION['user']['id'] = 1;
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test')));
+
+ $task = $tf->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertNotFalse($task);
+
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(1, $task['creator_id']);
+
+ $_SESSION = array();
+ }
+
public function testColumnId()
{
$p = new Project($this->container);
@@ -284,29 +306,35 @@ class TaskCreationTest extends Base
public function testDateStarted()
{
- $date = '2014-11-23';
- $timestamp = strtotime('+2days');
$p = new Project($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
- $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $date)));
- $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => $timestamp)));
+
+ // Set only a date
+ $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24')));
$task = $tf->getById(1);
- $this->assertNotEmpty($task);
- $this->assertNotFalse($task);
+ $this->assertEquals('2014-11-24 '.date('H:i'), date('Y-m-d H:i', $task['date_started']));
- $this->assertEquals(1, $task['id']);
- $this->assertEquals($date, date('Y-m-d', $task['date_started']));
+ // Set a datetime
+ $this->assertEquals(2, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24 16:25')));
$task = $tf->getById(2);
- $this->assertNotEmpty($task);
- $this->assertNotFalse($task);
+ $this->assertEquals('2014-11-24 16:25', date('Y-m-d H:i', $task['date_started']));
- $this->assertEquals(2, $task['id']);
- $this->assertEquals($timestamp, $task['date_started']);
+ // Set a datetime
+ $this->assertEquals(3, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => '2014-11-24 6:25pm')));
+
+ $task = $tf->getById(3);
+ $this->assertEquals('2014-11-24 18:25', date('Y-m-d H:i', $task['date_started']));
+
+ // Set a timestamp
+ $this->assertEquals(4, $tc->create(array('project_id' => 1, 'title' => 'test', 'date_started' => time())));
+
+ $task = $tf->getById(4);
+ $this->assertEquals(time(), $task['date_started'], '', 1);
}
public function testTime()
diff --git a/tests/units/TaskDuplicationTest.php b/tests/units/TaskDuplicationTest.php
index cd791312..4e44fd75 100644
--- a/tests/units/TaskDuplicationTest.php
+++ b/tests/units/TaskDuplicationTest.php
@@ -15,6 +15,36 @@ use Model\Swimlane;
class TaskDuplicationTest extends Base
{
+ public function testThatDuplicateDefineCreator()
+ {
+ $td = new TaskDuplication($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
+ $p = new Project($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test1')));
+ $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
+
+ $task = $tf->getById(1);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(1, $task['project_id']);
+ $this->assertEquals(0, $task['creator_id']);
+
+ $_SESSION = array();
+ $_SESSION['user']['id'] = 1;
+
+ // We duplicate our task
+ $this->assertEquals(2, $td->duplicate(1));
+
+ // Check the values of the duplicated task
+ $task = $tf->getById(2);
+ $this->assertNotEmpty($task);
+ $this->assertEquals(1, $task['creator_id']);
+
+ $_SESSION = array();
+ }
+
public function testDuplicateSameProject()
{
$td = new TaskDuplication($this->container);
diff --git a/tests/units/TaskFilterTest.php b/tests/units/TaskFilterTest.php
index 80d15484..98142ec7 100644
--- a/tests/units/TaskFilterTest.php
+++ b/tests/units/TaskFilterTest.php
@@ -9,9 +9,60 @@ use Model\TaskCreation;
use Model\DateParser;
use Model\Category;
use Model\Subtask;
+use Model\Config;
class TaskFilterTest extends Base
{
+ public function testIcalEventsWithCreatorAndDueDate()
+ {
+ $dp = new DateParser($this->container);
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'creator_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('-2 days'))));
+
+ $events = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->addAllDayIcalEvents();
+ $ics = $events->render();
+
+ $this->assertContains('UID:task-#1-date_due', $ics);
+ $this->assertContains('DTSTART;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('-2 days')), $ics);
+ $this->assertContains('DTEND;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('-2 days')), $ics);
+ $this->assertContains('URL:http://localhost/?controller=task&action=show&task_id=1&project_id=1', $ics);
+ $this->assertContains('SUMMARY:#1 task1', $ics);
+ $this->assertContains('ATTENDEE:MAILTO:admin@kanboard.local', $ics);
+ $this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics);
+ }
+
+ public function testIcalEventsWithAssigneeAndDueDate()
+ {
+ $dp = new DateParser($this->container);
+ $p = new Project($this->container);
+ $tc = new TaskCreation($this->container);
+ $tf = new TaskFilter($this->container);
+ $u = new User($this->container);
+ $c = new Config($this->container);
+
+ $this->assertNotFalse($c->save(array('application_url' => 'http://kb/')));
+ $this->assertEquals('http://kb/', $c->get('application_url'));
+
+ $this->assertNotFalse($u->update(array('id' => 1, 'email' => 'bob@localhost')));
+ $this->assertEquals(1, $p->create(array('name' => 'test')));
+ $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'owner_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('+5 days'))));
+
+ $events = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->addAllDayIcalEvents();
+ $ics = $events->render();
+
+ $this->assertContains('UID:task-#1-date_due', $ics);
+ $this->assertContains('DTSTART;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('+5 days')), $ics);
+ $this->assertContains('DTEND;TZID=UTC;VALUE=DATE:'.date('Ymd', strtotime('+5 days')), $ics);
+ $this->assertContains('URL:http://kb/?controller=task&action=show&task_id=1&project_id=1', $ics);
+ $this->assertContains('SUMMARY:#1 task1', $ics);
+ $this->assertContains('ORGANIZER:MAILTO:bob@localhost', $ics);
+ $this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics);
+ }
+
public function testSearchWithEmptyResult()
{
$dp = new DateParser($this->container);
@@ -441,19 +492,13 @@ class TaskFilterTest extends Base
$this->assertEquals('my task title is awesome', $tasks[0]['title']);
$this->assertEquals('my task title is amazing', $tasks[1]['title']);
-
$tf->search('assignee:nobody');
$tasks = $tf->findAll();
$this->assertNotEmpty($tasks);
$this->assertCount(1, $tasks);
- $this->assertEquals('my task title is amazing', $tasks[0]['title']);
-
-
-
+ $this->assertEquals('my task title is amazing', $tasks[0]['title']);
}
-
-
public function testCopy()
{
$tf = new TaskFilter($this->container);
diff --git a/tests/units/TaskModificationTest.php b/tests/units/TaskModificationTest.php
index e6d8f8dc..4dd89c5e 100644
--- a/tests/units/TaskModificationTest.php
+++ b/tests/units/TaskModificationTest.php
@@ -202,15 +202,29 @@ class TaskModificationTest extends Base
$task = $tf->getById(1);
$this->assertEquals(0, $task['date_started']);
+ // Set only a date
$this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24')));
$task = $tf->getById(1);
- $this->assertEquals('2014-11-24', date('Y-m-d', $task['date_started']));
+ $this->assertEquals('2014-11-24 '.date('H:i'), date('Y-m-d H:i', $task['date_started']));
+ // Set a datetime
+ $this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24 16:25')));
+
+ $task = $tf->getById(1);
+ $this->assertEquals('2014-11-24 16:25', date('Y-m-d H:i', $task['date_started']));
+
+ // Set a datetime
+ $this->assertTrue($tm->update(array('id' => 1, 'date_started' => '2014-11-24 6:25pm')));
+
+ $task = $tf->getById(1);
+ $this->assertEquals('2014-11-24 18:25', date('Y-m-d H:i', $task['date_started']));
+
+ // Set a timestamp
$this->assertTrue($tm->update(array('id' => 1, 'date_started' => time())));
$task = $tf->getById(1);
- $this->assertEquals(date('Y-m-d'), date('Y-m-d', $task['date_started']));
+ $this->assertEquals(time(), $task['date_started'], '', 1);
}
public function testChangeTimeEstimated()
diff --git a/tests/units/TaskPositionTest.php b/tests/units/TaskPositionTest.php
index ca7b3bf2..f3be325b 100644
--- a/tests/units/TaskPositionTest.php
+++ b/tests/units/TaskPositionTest.php
@@ -11,49 +11,88 @@ use Model\Swimlane;
class TaskPositionTest extends Base
{
- public function testCalculatePositionBadPosition()
+ public function testMoveTaskToWrongPosition()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
- $this->assertFalse($tp->calculatePositions(1, 1, 2, 0));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
+
+ // We move the task 2 to the position 0
+ $this->assertFalse($tp->movePosition(1, 1, 3, 0));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(2, $task['position']);
}
- public function testCalculatePositionBadColumn()
+ public function testMoveTaskToGreaterPosition()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
- $this->assertFalse($tp->calculatePositions(1, 1, 10, 1));
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
+
+ // We move the task 2 to the position 42
+ $this->assertTrue($tp->movePosition(1, 1, 1, 42));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(2, $task['position']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
}
- public function testCalculatePositions()
+ public function testMoveTaskToEmptyColumn()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
+ $tf = new TaskFinder($this->container);
$p = new Project($this->container);
$this->assertEquals(1, $p->create(array('name' => 'Project #1')));
- $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1)));
-
- $positions = $tp->calculatePositions(1, 1, 2, 1);
- $this->assertNotFalse($positions);
- $this->assertNotEmpty($positions);
- $this->assertEmpty($positions[1]);
- $this->assertEmpty($positions[3]);
- $this->assertEmpty($positions[4]);
- $this->assertEquals(array(1), $positions[2]);
+
+ $this->assertEquals(1, $tc->create(array('title' => 'Task #1', 'project_id' => 1, 'column_id' => 1)));
+ $this->assertEquals(2, $tc->create(array('title' => 'Task #2', 'project_id' => 1, 'column_id' => 1)));
+
+ // We move the task 2 to the column 3
+ $this->assertTrue($tp->movePosition(1, 1, 3, 1));
+
+ // Check tasks position
+ $task = $tf->getById(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals(3, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
+
+ $task = $tf->getById(2);
+ $this->assertEquals(2, $task['id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['position']);
}
- public function testMoveTaskWithColumnThatNotChange()
+ public function testMoveTaskToAnotherColumn()
{
$tp = new TaskPosition($this->container);
$tc = new TaskCreation($this->container);
@@ -116,40 +155,6 @@ class TaskPositionTest extends Base
$this->assertEquals(3, $task['position']);
}
- public function testMoveTaskWithBadPreviousPosition()
- {
- $tp = new TaskPosition($this->container);
- $tc = new TaskCreation($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->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->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($tp->movePosition(1, 1, 2, 3));
-
- // Check tasks position
- $task = $tf->getById(2);
- $this->assertEquals(2, $task['id']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(1, $task['position']);
-
- $task = $tf->getById(3);
- $this->assertEquals(3, $task['id']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(2, $task['position']);
-
- $task = $tf->getById(1);
- $this->assertEquals(1, $task['id']);
- $this->assertEquals(2, $task['column_id']);
- $this->assertEquals(3, $task['position']);
- }
-
public function testMoveTaskTop()
{
$tp = new TaskPosition($this->container);
diff --git a/tests/units/UrlHelperTest.php b/tests/units/UrlHelperTest.php
index d70842aa..3ef3402a 100644
--- a/tests/units/UrlHelperTest.php
+++ b/tests/units/UrlHelperTest.php
@@ -38,22 +38,26 @@ class UrlHelperTest extends Base
{
$h = new Url($this->container);
+ $this->assertEquals('http://localhost/', $h->server());
+
$_SERVER['PHP_SELF'] = '/';
- $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
- $this->assertEquals('http://localhost:1234/', $h->server());
+ $this->assertEquals('http://kb:1234/', $h->server());
}
public function testBase()
{
$h = new Url($this->container);
+ $this->assertEquals('http://localhost/', $h->base());
+
$_SERVER['PHP_SELF'] = '/';
- $_SERVER['SERVER_NAME'] = 'localhost';
+ $_SERVER['SERVER_NAME'] = 'kb';
$_SERVER['SERVER_PORT'] = 1234;
- $this->assertEquals('http://localhost:1234/', $h->base());
+ $this->assertEquals('http://kb:1234/', $h->base());
$c = new Config($this->container);
$c->save(array('application_url' => 'https://mykanboard/'));