From fc8f8748b9f89167ca9e6f4670bbc5e032e068b7 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 29 Apr 2016 17:32:43 -0400 Subject: Fixed wrong task link generation within Markdown text --- tests/units/Helper/TextHelperTest.php | 30 ++++++++++++++++++++++-------- tests/units/Model/TaskFinderTest.php | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/units/Helper/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php index d7324dfd..c6b55d0e 100644 --- a/tests/units/Helper/TextHelperTest.php +++ b/tests/units/Helper/TextHelperTest.php @@ -3,30 +3,43 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Helper\TextHelper; +use Kanboard\Model\Project; +use Kanboard\Model\TaskCreation; class TextHelperTest extends Base { public function testMarkdownTaskLink() { - $h = new TextHelper($this->container); + $helper = new TextHelper($this->container); + $projectModel = new Project($this->container); + $taskCreationModel = new TaskCreation($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertTrue($projectModel->enablePublicAccess(1)); + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1))); + $project = $projectModel->getById(1); + + $this->assertEquals('

Test

', $helper->markdown('Test')); - $this->assertEquals('

Test

', $h->markdown('Test')); + $this->assertEquals( + '

Task #123

', + $helper->markdown('Task #123') + ); $this->assertEquals( '

Task #123

', - $h->markdown('Task #123') + $helper->markdown('Task #123', true) ); $this->assertEquals( - '

Task #123

', - $h->markdown('Task #123', array('controller' => 'a', 'action' => 'b', 'params' => array('c' => 'd'))) + '

Task #1

', + $helper->markdown('Task #1', true) ); $this->assertEquals( '

Check that: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

', - $h->markdown( - 'Check that: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454', - array('controller' => 'a', 'action' => 'b', 'params' => array('c' => 'd')) + $helper->markdown( + 'Check that: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454' ) ); } @@ -35,6 +48,7 @@ class TextHelperTest extends Base { $h = new TextHelper($this->container); $this->assertEquals('

Text @admin @notfound

', $h->markdown('Text @admin @notfound')); + $this->assertEquals('

Text @admin @notfound

', $h->markdown('Text @admin @notfound', true)); } public function testFormatBytes() diff --git a/tests/units/Model/TaskFinderTest.php b/tests/units/Model/TaskFinderTest.php index 0ed211ed..859a9ea6 100644 --- a/tests/units/Model/TaskFinderTest.php +++ b/tests/units/Model/TaskFinderTest.php @@ -93,4 +93,23 @@ class TaskFinderTest extends Base $this->assertEquals(1, $tf->countByProjectId(1)); $this->assertEquals(2, $tf->countByProjectId(2)); } + + public function testGetProjectToken() + { + $taskCreationModel = new TaskCreation($this->container); + $taskFinderModel = new TaskFinder($this->container); + $projectModel = new Project($this->container); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Project #1'))); + $this->assertEquals(2, $projectModel->create(array('name' => 'Project #2'))); + + $this->assertTrue($projectModel->enablePublicAccess(1)); + + $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1))); + $this->assertEquals(2, $taskCreationModel->create(array('title' => 'Task #2', 'project_id' => 2))); + + $project = $projectModel->getById(1); + $this->assertEquals($project['token'], $taskFinderModel->getProjectToken(1)); + $this->assertEmpty($taskFinderModel->getProjectToken(2)); + } } -- cgit v1.2.3