summaryrefslogtreecommitdiff
path: root/tests/units/Helper/TextHelperTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Helper/TextHelperTest.php')
-rw-r--r--tests/units/Helper/TextHelperTest.php40
1 files changed, 31 insertions, 9 deletions
diff --git a/tests/units/Helper/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php
index d7324dfd..c9447abb 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\ProjectModel;
+use Kanboard\Model\TaskCreationModel;
class TextHelperTest extends Base
{
public function testMarkdownTaskLink()
{
- $h = new TextHelper($this->container);
+ $helper = new TextHelper($this->container);
+ $projectModel = new ProjectModel($this->container);
+ $taskCreationModel = new TaskCreationModel($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('<p>Test</p>', $h->markdown('Test'));
+ $this->assertEquals('<p>Test</p>', $helper->markdown('Test'));
+
+ $this->assertEquals(
+ '<p>Task <a href="?controller=TaskViewController&amp;action=show&amp;task_id=123">#123</a></p>',
+ $helper->markdown('Task #123')
+ );
$this->assertEquals(
'<p>Task #123</p>',
- $h->markdown('Task #123')
+ $helper->markdown('Task #123', true)
);
$this->assertEquals(
- '<p>Task <a href="?controller=a&amp;action=b&amp;c=d&amp;task_id=123">#123</a></p>',
- $h->markdown('Task #123', array('controller' => 'a', 'action' => 'b', 'params' => array('c' => 'd')))
+ '<p>Task <a href="?controller=TaskViewController&amp;action=readonly&amp;token='.$project['token'].'&amp;task_id=1">#1</a></p>',
+ $helper->markdown('Task #1', true)
);
$this->assertEquals(
'<p>Check that: <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454</a></p>',
- $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'
)
);
}
@@ -34,7 +47,16 @@ class TextHelperTest extends Base
public function testMarkdownUserLink()
{
$h = new TextHelper($this->container);
- $this->assertEquals('<p>Text <a href="?controller=user&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a> @notfound</p>', $h->markdown('Text @admin @notfound'));
+ $this->assertEquals('<p>Text <a href="?controller=UserViewController&amp;action=profile&amp;user_id=1" class="user-mention-link">@admin</a> @notfound</p>', $h->markdown('Text @admin @notfound'));
+ $this->assertEquals('<p>Text @admin @notfound</p>', $h->markdown('Text @admin @notfound', true));
+ }
+
+ public function testMarkdownAttribute()
+ {
+ $helper = new TextHelper($this->container);
+ $this->assertEquals('&lt;p&gt;&Ccedil;a marche&lt;/p&gt;', $helper->markdownAttribute('Ça marche'));
+ $this->assertEquals('&lt;p&gt;Test with &amp;quot;double quotes&amp;quot;&lt;/p&gt;', $helper->markdownAttribute('Test with "double quotes"'));
+ $this->assertEquals('&lt;p&gt;Test with &#039;single quotes&#039;&lt;/p&gt;', $helper->markdownAttribute("Test with 'single quotes'"));
}
public function testFormatBytes()