summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/configtest/DefaultConfigFileTest.php9
-rw-r--r--tests/integration/TaskMetadataProcedureTest.php45
-rw-r--r--tests/units/Base.php1
-rw-r--r--tests/units/Core/Cache/FileCacheTest.php186
-rw-r--r--tests/units/Core/ObjectStorage/FileStorageTest.php (renamed from tests/units/Core/FileStorageTest.php)4
-rw-r--r--tests/units/Core/Plugin/HookTest.php62
-rw-r--r--tests/units/Core/User/UserSessionTest.php21
-rw-r--r--tests/units/Decorator/MetadataCacheDecoratorTest.php127
-rw-r--r--tests/units/Helper/HookHelperTest.php91
-rw-r--r--tests/units/Helper/TaskHelperTest.php1
-rw-r--r--tests/units/Model/TaskFinderModelTest.php61
-rw-r--r--tests/units/Notification/MailNotificationTest.php5
12 files changed, 557 insertions, 56 deletions
diff --git a/tests/configtest/DefaultConfigFileTest.php b/tests/configtest/DefaultConfigFileTest.php
new file mode 100644
index 00000000..0840925b
--- /dev/null
+++ b/tests/configtest/DefaultConfigFileTest.php
@@ -0,0 +1,9 @@
+<?php
+
+class DefaultConfigFileTest extends PHPUnit_Framework_TestCase
+{
+ public function testThatFileCanBeImported()
+ {
+ $this->assertNotFalse(include __DIR__.'/../../config.default.php');
+ }
+}
diff --git a/tests/integration/TaskMetadataProcedureTest.php b/tests/integration/TaskMetadataProcedureTest.php
new file mode 100644
index 00000000..9b9b2f39
--- /dev/null
+++ b/tests/integration/TaskMetadataProcedureTest.php
@@ -0,0 +1,45 @@
+<?php
+
+require_once __DIR__.'/BaseProcedureTest.php';
+
+class TaskMetadataProcedureTest extends BaseProcedureTest
+{
+ protected $projectName = 'My project to test tasks metadata';
+ protected $metaKey = 'MyTestMetaKey';
+
+ public function testAll()
+ {
+ $this->assertCreateTeamProject();
+ $this->assertCreateTask();
+ $this->assertSaveTaskMetadata();
+ $this->assertGetTaskMetadata();
+ $this->assertGetTaskMetadataByName();
+ $this->assertRemoveTaskMetadata();
+ }
+
+ public function assertSaveTaskMetadata()
+ {
+ $this->assertTrue($this->app->saveTaskMetadata($this->taskId, array($this->metaKey => 'metaValue1')));
+ }
+
+ public function assertGetTaskMetadata()
+ {
+ $metaData = $this->app->getTaskMetadata(($this->taskId));
+ $this->assertArrayHasKey($this->metaKey, $metaData);
+ $this->assertEquals('metaValue1', $metaData[$this->metaKey]);
+ }
+
+ public function assertGetTaskMetadataByName()
+ {
+ $metaValue = $this->app->getTaskMetadataByName($this->taskId, $this->metaKey);
+ $this->assertEquals('metaValue1', $metaValue, 'Did not return correct metadata value');
+ }
+
+ public function assertRemoveTaskMetadata()
+ {
+ $result = $this->app->removeTaskMetadata($this->taskId, $this->metaKey);
+ $this->assertTrue($result, 'Did not remove metakey with success');
+ $metaValue = $this->app->getTaskMetadataByName($this->taskId, $this->metaKey);
+ $this->assertEquals('', $metaValue, 'Did not return an empty string due to metadata being deleted');
+ }
+}
diff --git a/tests/units/Base.php b/tests/units/Base.php
index e44223ce..722a1335 100644
--- a/tests/units/Base.php
+++ b/tests/units/Base.php
@@ -38,6 +38,7 @@ abstract class Base extends PHPUnit_Framework_TestCase
}
$this->container = new Pimple\Container;
+ $this->container->register(new Kanboard\ServiceProvider\CacheProvider());
$this->container->register(new Kanboard\ServiceProvider\HelperProvider());
$this->container->register(new Kanboard\ServiceProvider\AuthenticationProvider());
$this->container->register(new Kanboard\ServiceProvider\DatabaseProvider());
diff --git a/tests/units/Core/Cache/FileCacheTest.php b/tests/units/Core/Cache/FileCacheTest.php
new file mode 100644
index 00000000..b6336581
--- /dev/null
+++ b/tests/units/Core/Cache/FileCacheTest.php
@@ -0,0 +1,186 @@
+<?php
+
+namespace Kanboard\Core\Cache;
+
+require_once __DIR__.'/../../Base.php';
+
+function file_put_contents($filename, $data)
+{
+ return FileCacheTest::$functions->file_put_contents($filename, $data);
+}
+
+function file_get_contents($filename)
+{
+ return FileCacheTest::$functions->file_get_contents($filename);
+}
+
+function mkdir($filename, $mode = 0777, $recursif = false)
+{
+ return FileCacheTest::$functions->mkdir($filename, $mode, $recursif);
+}
+
+function is_dir($filename)
+{
+ return FileCacheTest::$functions->is_dir($filename);
+}
+
+function file_exists($filename)
+{
+ return FileCacheTest::$functions->file_exists($filename);
+}
+
+function unlink($filename)
+{
+ return FileCacheTest::$functions->unlink($filename);
+}
+
+class FileCacheTest extends \Base
+{
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ public static $functions;
+
+ public function setUp()
+ {
+ parent::setup();
+
+ self::$functions = $this
+ ->getMockBuilder('stdClass')
+ ->setMethods(array(
+ 'file_put_contents',
+ 'file_get_contents',
+ 'file_exists',
+ 'mkdir',
+ 'is_dir',
+ 'unlink',
+ ))
+ ->getMock();
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ self::$functions = null;
+ }
+
+ public function testSet()
+ {
+ $key = 'mykey';
+ $data = 'data';
+ $cache = new FileCache();
+
+ self::$functions
+ ->expects($this->at(0))
+ ->method('is_dir')
+ ->with(
+ $this->equalTo(CACHE_DIR)
+ )
+ ->will($this->returnValue(false));
+
+ self::$functions
+ ->expects($this->at(1))
+ ->method('mkdir')
+ ->with(
+ $this->equalTo(CACHE_DIR),
+ 0755
+ )
+ ->will($this->returnValue(true));
+
+ self::$functions
+ ->expects($this->at(2))
+ ->method('file_put_contents')
+ ->with(
+ $this->equalTo(CACHE_DIR.DIRECTORY_SEPARATOR.$key),
+ $this->equalTo(serialize($data))
+ )
+ ->will($this->returnValue(true));
+
+ $cache->set($key, $data);
+ }
+
+ public function testGet()
+ {
+ $key = 'mykey';
+ $data = 'data';
+ $cache = new FileCache();
+
+ self::$functions
+ ->expects($this->at(0))
+ ->method('file_exists')
+ ->with(
+ $this->equalTo(CACHE_DIR.DIRECTORY_SEPARATOR.$key)
+ )
+ ->will($this->returnValue(true));
+
+ self::$functions
+ ->expects($this->at(1))
+ ->method('file_get_contents')
+ ->with(
+ $this->equalTo(CACHE_DIR.DIRECTORY_SEPARATOR.$key)
+ )
+ ->will($this->returnValue(serialize($data)));
+
+ $this->assertSame($data, $cache->get($key));
+ }
+
+ public function testGetWithKeyNotFound()
+ {
+ $key = 'mykey';
+ $cache = new FileCache();
+
+ self::$functions
+ ->expects($this->at(0))
+ ->method('file_exists')
+ ->with(
+ $this->equalTo(CACHE_DIR.DIRECTORY_SEPARATOR.$key)
+ )
+ ->will($this->returnValue(false));
+
+ $this->assertNull($cache->get($key));
+ }
+
+ public function testRemoveWithKeyNotFound()
+ {
+ $key = 'mykey';
+ $cache = new FileCache();
+
+ self::$functions
+ ->expects($this->at(0))
+ ->method('file_exists')
+ ->with(
+ $this->equalTo(CACHE_DIR.DIRECTORY_SEPARATOR.$key)
+ )
+ ->will($this->returnValue(false));
+
+ self::$functions
+ ->expects($this->never())
+ ->method('unlink');
+
+ $cache->remove($key);
+ }
+
+ public function testRemove()
+ {
+ $key = 'mykey';
+ $cache = new FileCache();
+
+ self::$functions
+ ->expects($this->at(0))
+ ->method('file_exists')
+ ->with(
+ $this->equalTo(CACHE_DIR.DIRECTORY_SEPARATOR.$key)
+ )
+ ->will($this->returnValue(true));
+
+ self::$functions
+ ->expects($this->at(1))
+ ->method('unlink')
+ ->with(
+ $this->equalTo(CACHE_DIR.DIRECTORY_SEPARATOR.$key)
+ )
+ ->will($this->returnValue(true));
+
+ $cache->remove($key);
+ }
+}
diff --git a/tests/units/Core/FileStorageTest.php b/tests/units/Core/ObjectStorage/FileStorageTest.php
index a3ad2448..ed77dedd 100644
--- a/tests/units/Core/FileStorageTest.php
+++ b/tests/units/Core/ObjectStorage/FileStorageTest.php
@@ -2,7 +2,7 @@
namespace Kanboard\Core\ObjectStorage;
-require_once __DIR__.'/../Base.php';
+require_once __DIR__.'/../../Base.php';
function file_put_contents($filename, $data)
{
@@ -105,7 +105,7 @@ class FileStorageTest extends \Base
->method('file_put_contents')
->with(
$this->equalTo('somewhere'.DIRECTORY_SEPARATOR.'mykey'),
- $this->equalTo('data')
+ $this->equalTo($data)
)
->will($this->returnValue(true));
diff --git a/tests/units/Core/Plugin/HookTest.php b/tests/units/Core/Plugin/HookTest.php
index d1c139b3..acadede0 100644
--- a/tests/units/Core/Plugin/HookTest.php
+++ b/tests/units/Core/Plugin/HookTest.php
@@ -8,89 +8,103 @@ class HookTest extends Base
{
public function testGetListeners()
{
- $h = new Hook;
- $this->assertEmpty($h->getListeners('myhook'));
+ $hook = new Hook;
+ $this->assertEmpty($hook->getListeners('myhook'));
- $h->on('myhook', 'A');
- $h->on('myhook', 'B');
+ $hook->on('myhook', 'A');
+ $hook->on('myhook', 'B');
- $this->assertEquals(array('A', 'B'), $h->getListeners('myhook'));
+ $this->assertEquals(array('A', 'B'), $hook->getListeners('myhook'));
}
public function testExists()
{
- $h = new Hook;
- $this->assertFalse($h->exists('myhook'));
+ $hook = new Hook;
+ $this->assertFalse($hook->exists('myhook'));
- $h->on('myhook', 'A');
+ $hook->on('myhook', 'A');
- $this->assertTrue($h->exists('myhook'));
+ $this->assertTrue($hook->exists('myhook'));
}
public function testMergeWithNoBinding()
{
- $h = new Hook;
+ $hook = new Hook;
$values = array('A', 'B');
- $result = $h->merge('myhook', $values, array('p' => 'c'));
+ $result = $hook->merge('myhook', $values, array('p' => 'c'));
$this->assertEquals($values, $result);
}
public function testMergeWithBindings()
{
- $h = new Hook;
+ $hook = new Hook;
$values = array('A', 'B');
$expected = array('A', 'B', 'c', 'D');
- $h->on('myhook', function ($p) {
+ $hook->on('myhook', function ($p) {
return array($p);
});
- $h->on('myhook', function () {
+ $hook->on('myhook', function () {
return array('D');
});
- $result = $h->merge('myhook', $values, array('p' => 'c'));
+ $result = $hook->merge('myhook', $values, array('p' => 'c'));
$this->assertEquals($expected, $result);
$this->assertEquals($expected, $values);
}
public function testMergeWithBindingButReturningBadData()
{
- $h = new Hook;
+ $hook = new Hook;
$values = array('A', 'B');
$expected = array('A', 'B');
- $h->on('myhook', function () {
+ $hook->on('myhook', function () {
return 'string';
});
- $result = $h->merge('myhook', $values);
+ $result = $hook->merge('myhook', $values);
$this->assertEquals($expected, $result);
$this->assertEquals($expected, $values);
}
public function testFirstWithNoBinding()
{
- $h = new Hook;
+ $hook = new Hook;
- $result = $h->first('myhook', array('p' => 2));
+ $result = $hook->first('myhook', array('p' => 2));
$this->assertEquals(null, $result);
}
public function testFirstWithMultipleBindings()
{
- $h = new Hook;
+ $hook = new Hook;
- $h->on('myhook', function ($p) {
+ $hook->on('myhook', function ($p) {
return $p + 1;
});
- $h->on('myhook', function ($p) {
+ $hook->on('myhook', function ($p) {
return $p;
});
- $result = $h->first('myhook', array('p' => 3));
+ $result = $hook->first('myhook', array('p' => 3));
$this->assertEquals(4, $result);
}
+
+ public function testHookWithReference()
+ {
+ $hook = new Hook();
+
+ $hook->on('myhook', function (&$p) {
+ $p = 2;
+ });
+
+ $param = 123;
+ $result = $hook->reference('myhook', $param);
+ $this->assertSame(2, $result);
+ $this->assertSame(2, $param);
+ }
}
diff --git a/tests/units/Core/User/UserSessionTest.php b/tests/units/Core/User/UserSessionTest.php
index 64413f98..2a118079 100644
--- a/tests/units/Core/User/UserSessionTest.php
+++ b/tests/units/Core/User/UserSessionTest.php
@@ -83,27 +83,6 @@ class UserSessionTest extends Base
$this->assertFalse($us->isAdmin());
}
- public function testCommentSorting()
- {
- $us = new UserSession($this->container);
- $this->assertEquals('ASC', $us->getCommentSorting());
-
- $us->setCommentSorting('DESC');
- $this->assertEquals('DESC', $us->getCommentSorting());
- }
-
- public function testBoardCollapseMode()
- {
- $us = new UserSession($this->container);
- $this->assertFalse($us->isBoardCollapsed(2));
-
- $us->setBoardDisplayMode(3, false);
- $this->assertFalse($us->isBoardCollapsed(3));
-
- $us->setBoardDisplayMode(3, true);
- $this->assertTrue($us->isBoardCollapsed(3));
- }
-
public function testFilters()
{
$us = new UserSession($this->container);
diff --git a/tests/units/Decorator/MetadataCacheDecoratorTest.php b/tests/units/Decorator/MetadataCacheDecoratorTest.php
new file mode 100644
index 00000000..3e4dd320
--- /dev/null
+++ b/tests/units/Decorator/MetadataCacheDecoratorTest.php
@@ -0,0 +1,127 @@
+<?php
+
+use Kanboard\Decorator\MetadataCacheDecorator;
+
+require_once __DIR__.'/../Base.php';
+
+class MetadataCacheDecoratorTest extends Base
+{
+ protected $cachePrefix = 'cache_prefix';
+ protected $entityId = 123;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $cacheMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $metadataModelMock;
+
+ /**
+ * @var MetadataCacheDecorator
+ */
+ protected $metadataCacheDecorator;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->cacheMock = $this
+ ->getMockBuilder('\Kanboard\Core\Cache\MemoryCache')
+ ->setMethods(array(
+ 'set',
+ 'get',
+ ))
+ ->getMock();
+
+ $this->metadataModelMock = $this
+ ->getMockBuilder('\Kanboard\Model\UserMetadataModel')
+ ->setConstructorArgs(array($this->container))
+ ->setMethods(array(
+ 'getAll',
+ 'save',
+ ))
+ ->getMock()
+ ;
+
+ $this->metadataCacheDecorator = new MetadataCacheDecorator(
+ $this->cacheMock,
+ $this->metadataModelMock,
+ $this->cachePrefix,
+ $this->entityId
+ );
+ }
+
+ public function testSet()
+ {
+ $this->cacheMock
+ ->expects($this->once())
+ ->method('set');
+
+ $this->metadataModelMock
+ ->expects($this->at(0))
+ ->method('save');
+
+ $this->metadataModelMock
+ ->expects($this->at(1))
+ ->method('getAll')
+ ->with($this->entityId)
+ ;
+
+ $this->metadataCacheDecorator->set('key', 'value');
+ }
+
+ public function testGetWithCache()
+ {
+ $this->cacheMock
+ ->expects($this->once())
+ ->method('get')
+ ->with($this->cachePrefix.$this->entityId)
+ ->will($this->returnValue(array('key' => 'foobar')))
+ ;
+
+ $this->assertEquals('foobar', $this->metadataCacheDecorator->get('key', 'default'));
+ }
+
+ public function testGetWithCacheAndDefaultValue()
+ {
+ $this->cacheMock
+ ->expects($this->once())
+ ->method('get')
+ ->with($this->cachePrefix.$this->entityId)
+ ->will($this->returnValue(array('key1' => 'foobar')))
+ ;
+
+ $this->assertEquals('default', $this->metadataCacheDecorator->get('key', 'default'));
+ }
+
+ public function testGetWithoutCache()
+ {
+ $this->cacheMock
+ ->expects($this->at(0))
+ ->method('get')
+ ->with($this->cachePrefix.$this->entityId)
+ ->will($this->returnValue(null))
+ ;
+
+ $this->cacheMock
+ ->expects($this->at(1))
+ ->method('set')
+ ->with(
+ $this->cachePrefix.$this->entityId,
+ array('key' => 'something')
+ )
+ ;
+
+ $this->metadataModelMock
+ ->expects($this->once())
+ ->method('getAll')
+ ->with($this->entityId)
+ ->will($this->returnValue(array('key' => 'something')))
+ ;
+
+ $this->assertEquals('something', $this->metadataCacheDecorator->get('key', 'default'));
+ }
+}
diff --git a/tests/units/Helper/HookHelperTest.php b/tests/units/Helper/HookHelperTest.php
index 6e03acd1..a67eaed9 100644
--- a/tests/units/Helper/HookHelperTest.php
+++ b/tests/units/Helper/HookHelperTest.php
@@ -6,6 +6,79 @@ use Kanboard\Helper\HookHelper;
class HookHelperTest extends Base
{
+ public function testAttachCallable()
+ {
+ $this->container['template'] = $this
+ ->getMockBuilder('\Kanboard\Core\Template')
+ ->setConstructorArgs(array($this->container['helper']))
+ ->setMethods(array('render'))
+ ->getMock();
+
+ $this->container['template']
+ ->expects($this->once())
+ ->method('render')
+ ->with(
+ $this->equalTo('tpl1'),
+ $this->equalTo(array('k0' => 'v0', 'k1' => 'v1'))
+ )
+ ->will($this->returnValue('tpl1_content'));
+
+ $hookHelper = new HookHelper($this->container);
+ $hookHelper->attachCallable('test', 'tpl1', function() {
+ return array(
+ 'k1' => 'v1',
+ );
+ });
+
+ $this->assertEquals('tpl1_content', $hookHelper->render('test', array('k0' => 'v0')));
+ }
+
+ public function testAttachCallableWithNoResult()
+ {
+ $this->container['template'] = $this
+ ->getMockBuilder('\Kanboard\Core\Template')
+ ->setConstructorArgs(array($this->container['helper']))
+ ->setMethods(array('render'))
+ ->getMock();
+
+ $this->container['template']
+ ->expects($this->once())
+ ->method('render')
+ ->with(
+ $this->equalTo('tpl1'),
+ $this->equalTo(array('k0' => 'v0'))
+ )
+ ->will($this->returnValue('tpl1_content'));
+
+ $hookHelper = new HookHelper($this->container);
+ $hookHelper->attachCallable('test', 'tpl1', function() {
+ });
+
+ $this->assertEquals('tpl1_content', $hookHelper->render('test', array('k0' => 'v0')));
+ }
+
+ public function testAttachLocalVariables()
+ {
+ $this->container['template'] = $this
+ ->getMockBuilder('\Kanboard\Core\Template')
+ ->setConstructorArgs(array($this->container['helper']))
+ ->setMethods(array('render'))
+ ->getMock();
+
+ $this->container['template']
+ ->expects($this->once())
+ ->method('render')
+ ->with(
+ $this->equalTo('tpl1'),
+ $this->equalTo(array('k0' => 'v0', 'k1' => 'v1'))
+ )
+ ->will($this->returnValue('tpl1_content'));
+
+ $hookHelper = new HookHelper($this->container);
+ $hookHelper->attach('test', 'tpl1', array('k1' => 'v1'));
+ $this->assertEquals('tpl1_content', $hookHelper->render('test', array('k0' => 'v0')));
+ }
+
public function testMultipleHooks()
{
$this->container['template'] = $this
@@ -32,10 +105,10 @@ class HookHelperTest extends Base
)
->will($this->returnValue('tpl2_content'));
- $h = new HookHelper($this->container);
- $h->attach('test', 'tpl1');
- $h->attach('test', 'tpl2');
- $this->assertEquals('tpl1_contenttpl2_content', $h->render('test'));
+ $hookHelper = new HookHelper($this->container);
+ $hookHelper->attach('test', 'tpl1');
+ $hookHelper->attach('test', 'tpl2');
+ $this->assertEquals('tpl1_contenttpl2_content', $hookHelper->render('test'));
}
public function testAssetHooks()
@@ -64,11 +137,11 @@ class HookHelperTest extends Base
)
->will($this->returnValue('<script src="skin.js"></script>'));
- $h = new HookHelper($this->container);
- $h->attach('test1', 'skin.css');
- $h->attach('test2', 'skin.js');
+ $hookHelper = new HookHelper($this->container);
+ $hookHelper->attach('test1', 'skin.css');
+ $hookHelper->attach('test2', 'skin.js');
- $this->assertContains('<link rel="stylesheet" href="skin.css"></link>', $h->asset('css', 'test1'));
- $this->assertContains('<script src="skin.js"></script>', $h->asset('js', 'test2'));
+ $this->assertContains('<link rel="stylesheet" href="skin.css"></link>', $hookHelper->asset('css', 'test1'));
+ $this->assertContains('<script src="skin.js"></script>', $hookHelper->asset('js', 'test2'));
}
}
diff --git a/tests/units/Helper/TaskHelperTest.php b/tests/units/Helper/TaskHelperTest.php
index 454da553..2e2da6ee 100644
--- a/tests/units/Helper/TaskHelperTest.php
+++ b/tests/units/Helper/TaskHelperTest.php
@@ -9,6 +9,7 @@ class TaskHelperTest extends Base
public function testSelectPriority()
{
$helper = new TaskHelper($this->container);
+ $this->assertNotEmpty($helper->selectPriority(array('priority_end' => '1', 'priority_start' => '5', 'priority_default' => '2'), array()));
$this->assertNotEmpty($helper->selectPriority(array('priority_end' => '3', 'priority_start' => '1', 'priority_default' => '2'), array()));
$this->assertEmpty($helper->selectPriority(array('priority_end' => '3', 'priority_start' => '3', 'priority_default' => '2'), array()));
}
diff --git a/tests/units/Model/TaskFinderModelTest.php b/tests/units/Model/TaskFinderModelTest.php
index b2e2bd84..a9f018ff 100644
--- a/tests/units/Model/TaskFinderModelTest.php
+++ b/tests/units/Model/TaskFinderModelTest.php
@@ -6,9 +6,70 @@ use Kanboard\Model\ColumnModel;
use Kanboard\Model\TaskCreationModel;
use Kanboard\Model\TaskFinderModel;
use Kanboard\Model\ProjectModel;
+use Kanboard\Model\TaskModel;
class TaskFinderModelTest extends Base
{
+ public function testGetDetails()
+ {
+ $taskCreationModel = new TaskCreationModel($this->container);
+ $taskFinderModel = new TaskFinderModel($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $categoryModel = new \Kanboard\Model\CategoryModel($this->container);
+
+ $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1')));
+ $this->assertEquals(1, $categoryModel->create(array('project_id' => 1, 'name' => 'C1')));
+ $this->assertEquals(1, $taskCreationModel->create(array(
+ 'project_id' => 1,
+ 'title' => 'Task #1',
+ 'reference' => 'test',
+ 'description' => 'desc',
+ 'owner_id' => 1,
+ 'category_id' => 1,
+ )));
+
+ $task = $taskFinderModel->getDetails(1);
+ $this->assertEquals(1, $task['id']);
+ $this->assertEquals('test', $task['reference']);
+ $this->assertEquals('Task #1', $task['title']);
+ $this->assertEquals('desc', $task['description']);
+ $this->assertEquals(time(), $task['date_creation'], 'Delta', 1);
+ $this->assertEquals(time(), $task['date_modification'], 'Delta', 1);
+ $this->assertEquals(time(), $task['date_moved'], 'Delta', 1);
+ $this->assertEquals(0, $task['date_completed']);
+ $this->assertEquals(0, $task['date_due']);
+ $this->assertEquals(0, $task['date_started']);
+ $this->assertEquals(0, $task['time_estimated']);
+ $this->assertEquals(0, $task['time_spent']);
+ $this->assertEquals('yellow', $task['color_id']);
+ $this->assertEquals(1, $task['project_id']);
+ $this->assertEquals(1, $task['column_id']);
+ $this->assertEquals(1, $task['owner_id']);
+ $this->assertEquals(0, $task['creator_id']);
+ $this->assertEquals(1, $task['position']);
+ $this->assertEquals(TaskModel::STATUS_OPEN, $task['is_active']);
+ $this->assertEquals(0, $task['score']);
+ $this->assertEquals(1, $task['category_id']);
+ $this->assertEquals(0, $task['priority']);
+ $this->assertEquals(0, $task['swimlane_id']);
+ $this->assertEquals(TaskModel::RECURRING_STATUS_NONE, $task['recurrence_status']);
+ $this->assertEquals(TaskModel::RECURRING_TRIGGER_FIRST_COLUMN, $task['recurrence_trigger']);
+ $this->assertEquals(0, $task['recurrence_factor']);
+ $this->assertEquals(TaskModel::RECURRING_TIMEFRAME_DAYS, $task['recurrence_timeframe']);
+ $this->assertEquals(TaskModel::RECURRING_BASEDATE_DUEDATE, $task['recurrence_basedate']);
+ $this->assertEquals(0, $task['recurrence_parent']);
+ $this->assertEquals(0, $task['recurrence_child']);
+ $this->assertEquals('C1', $task['category_name']);
+ $this->assertNull($task['swimlane_name']);
+ $this->assertEquals('Default swimlane', $task['default_swimlane']);
+ $this->assertEquals('Project #1', $task['project_name']);
+ $this->assertEquals('Backlog', $task['column_title']);
+ $this->assertEquals('admin', $task['assignee_username']);
+ $this->assertEquals('', $task['assignee_name']);
+ $this->assertEquals('', $task['creator_username']);
+ $this->assertEquals('', $task['creator_name']);
+ }
+
public function testGetTasksForDashboardWithHiddenColumn()
{
$taskCreationModel = new TaskCreationModel($this->container);
diff --git a/tests/units/Notification/MailNotificationTest.php b/tests/units/Notification/MailNotificationTest.php
index 05f1f882..93eeef0c 100644
--- a/tests/units/Notification/MailNotificationTest.php
+++ b/tests/units/Notification/MailNotificationTest.php
@@ -58,6 +58,11 @@ class MailNotificationTest extends Base
$this->assertNotEmpty($mailNotification->getMailContent($eventName, $eventData));
$this->assertStringStartsWith('[test] ', $mailNotification->getMailSubject($eventName, $eventData));
}
+
+ $this->assertStringStartsWith('[Test1, Test2] ', $mailNotification->getMailSubject(TaskModel::EVENT_OVERDUE, array(
+ 'tasks' => array(array('id' => 123), array('id' => 456)),
+ 'project_name' => 'Test1, Test2',
+ )));
}
public function testSendWithEmailAddress()