diff options
Diffstat (limited to 'tests/units/Helper')
-rw-r--r-- | tests/units/Helper/FileHelperTest.php (renamed from tests/units/Helper/FileHelperText.php) | 9 | ||||
-rw-r--r-- | tests/units/Helper/MailHelperTest.php | 1 | ||||
-rw-r--r-- | tests/units/Helper/TaskHelperTest.php | 6 | ||||
-rw-r--r-- | tests/units/Helper/TextHelperTest.php | 91 |
4 files changed, 80 insertions, 27 deletions
diff --git a/tests/units/Helper/FileHelperText.php b/tests/units/Helper/FileHelperTest.php index 215b024b..7db43460 100644 --- a/tests/units/Helper/FileHelperText.php +++ b/tests/units/Helper/FileHelperTest.php @@ -30,7 +30,14 @@ class FileHelperTest extends Base $helper = new FileHelper($this->container); $this->assertEquals('text', $helper->getPreviewType('test.txt')); $this->assertEquals('markdown', $helper->getPreviewType('test.markdown')); - $this->assertEquals('md', $helper->getPreviewType('test.md')); + $this->assertEquals('markdown', $helper->getPreviewType('test.md')); $this->assertEquals(null, $helper->getPreviewType('test.doc')); } + + public function testGetBrowserViewType() + { + $fileHelper = new FileHelper($this->container); + $this->assertSame('application/pdf', $fileHelper->getBrowserViewType('SomeFile.PDF')); + $this->assertSame(null, $fileHelper->getBrowserViewType('SomeFile.doc')); + } } diff --git a/tests/units/Helper/MailHelperTest.php b/tests/units/Helper/MailHelperTest.php index e871a57d..c6f13042 100644 --- a/tests/units/Helper/MailHelperTest.php +++ b/tests/units/Helper/MailHelperTest.php @@ -20,6 +20,7 @@ class MailHelperTest extends Base $this->assertEquals('Test', $helper->filterSubject('Test')); $this->assertEquals('Test', $helper->filterSubject('RE: Test')); $this->assertEquals('Test', $helper->filterSubject('FW: Test')); + $this->assertEquals('Test', $helper->filterSubject('Fwd: Test')); } public function testGetSenderAddress() diff --git a/tests/units/Helper/TaskHelperTest.php b/tests/units/Helper/TaskHelperTest.php index 2e2da6ee..8609983e 100644 --- a/tests/units/Helper/TaskHelperTest.php +++ b/tests/units/Helper/TaskHelperTest.php @@ -9,9 +9,9 @@ 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())); + $this->assertNotEmpty($helper->renderPriorityField(array('priority_end' => '1', 'priority_start' => '5', 'priority_default' => '2'), array())); + $this->assertNotEmpty($helper->renderPriorityField(array('priority_end' => '3', 'priority_start' => '1', 'priority_default' => '2'), array())); + $this->assertEmpty($helper->renderPriorityField(array('priority_end' => '3', 'priority_start' => '3', 'priority_default' => '2'), array())); } public function testFormatPriority() diff --git a/tests/units/Helper/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php index c9447abb..35ed5a1e 100644 --- a/tests/units/Helper/TextHelperTest.php +++ b/tests/units/Helper/TextHelperTest.php @@ -5,12 +5,13 @@ require_once __DIR__.'/../Base.php'; use Kanboard\Helper\TextHelper; use Kanboard\Model\ProjectModel; use Kanboard\Model\TaskCreationModel; +use Kanboard\Model\UserModel; class TextHelperTest extends Base { public function testMarkdownTaskLink() { - $helper = new TextHelper($this->container); + $textHelper = new TextHelper($this->container); $projectModel = new ProjectModel($this->container); $taskCreationModel = new TaskCreationModel($this->container); @@ -19,26 +20,26 @@ class TextHelperTest extends Base $this->assertEquals(1, $taskCreationModel->create(array('title' => 'Task #1', 'project_id' => 1))); $project = $projectModel->getById(1); - $this->assertEquals('<p>Test</p>', $helper->markdown('Test')); + $this->assertEquals('<p>Test</p>', $textHelper->markdown('Test')); $this->assertEquals( '<p>Task <a href="?controller=TaskViewController&action=show&task_id=123">#123</a></p>', - $helper->markdown('Task #123') + $textHelper->markdown('Task #123') ); $this->assertEquals( '<p>Task #123</p>', - $helper->markdown('Task #123', true) + $textHelper->markdown('Task #123', true) ); $this->assertEquals( - '<p>Task <a href="?controller=TaskViewController&action=readonly&token='.$project['token'].'&task_id=1">#1</a></p>', - $helper->markdown('Task #1', true) + '<p>Task <a href="http://localhost/?controller=TaskViewController&action=readonly&token='.$project['token'].'&task_id=1">#1</a></p>', + $textHelper->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>', - $helper->markdown( + $textHelper->markdown( 'Check that: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454' ) ); @@ -46,39 +47,83 @@ class TextHelperTest extends Base public function testMarkdownUserLink() { - $h = new TextHelper($this->container); - $this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&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)); + $textHelper = new TextHelper($this->container); + $userModel = new UserModel($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'firstname.lastname', 'name' => 'Firstname Lastname'))); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link" title="admin">@admin</a> @notfound</p>', + $textHelper->markdown('Text @admin @notfound') + ); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link" title="admin">@admin</a>,</p>', + $textHelper->markdown('Text @admin,') + ); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link" title="admin">@admin</a>!</p>', + $textHelper->markdown('Text @admin!') + ); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link" title="admin">@admin</a>? </p>', + $textHelper->markdown('Text @admin? ') + ); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link" title="admin">@admin</a>.</p>', + $textHelper->markdown('Text @admin.') + ); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link" title="admin">@admin</a>: test</p>', + $textHelper->markdown('Text @admin: test') + ); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link" title="admin">@admin</a>: test</p>', + $textHelper->markdown('Text @admin: test') + ); + + $this->assertEquals( + '<p>Text <a href="?controller=UserViewController&action=profile&user_id=2" class="user-mention-link" title="Firstname Lastname">@firstname.lastname</a>. test</p>', + $textHelper->markdown('Text @firstname.lastname. test') + ); + + $this->assertEquals('<p>Text @admin @notfound</p>', $textHelper->markdown('Text @admin @notfound', true)); } public function testMarkdownAttribute() { - $helper = new TextHelper($this->container); - $this->assertEquals('<p>Ça marche</p>', $helper->markdownAttribute('Ça marche')); - $this->assertEquals('<p>Test with &quot;double quotes&quot;</p>', $helper->markdownAttribute('Test with "double quotes"')); - $this->assertEquals('<p>Test with 'single quotes'</p>', $helper->markdownAttribute("Test with 'single quotes'")); + $textHelper = new TextHelper($this->container); + $this->assertEquals('<p>Ça marche</p>', $textHelper->markdownAttribute('Ça marche')); + $this->assertEquals('<p>Test with &quot;double quotes&quot;</p>', $textHelper->markdownAttribute('Test with "double quotes"')); + $this->assertEquals('<p>Test with 'single quotes'</p>', $textHelper->markdownAttribute("Test with 'single quotes'")); } public function testFormatBytes() { - $h = new TextHelper($this->container); + $textHelper = new TextHelper($this->container); - $this->assertEquals('1k', $h->bytes(1024)); - $this->assertEquals('33.71k', $h->bytes(34520)); + $this->assertEquals('0', $textHelper->bytes(0)); + $this->assertEquals('1k', $textHelper->bytes(1024)); + $this->assertEquals('33.71k', $textHelper->bytes(34520)); } public function testContains() { - $h = new TextHelper($this->container); + $textHelper = new TextHelper($this->container); - $this->assertTrue($h->contains('abc', 'b')); - $this->assertFalse($h->contains('abc', 'd')); + $this->assertTrue($textHelper->contains('abc', 'b')); + $this->assertFalse($textHelper->contains('abc', 'd')); } public function testInList() { - $h = new TextHelper($this->container); - $this->assertEquals('?', $h->in('a', array('b' => 'c'))); - $this->assertEquals('c', $h->in('b', array('b' => 'c'))); + $textHelper = new TextHelper($this->container); + $this->assertEquals('?', $textHelper->in('a', array('b' => 'c'))); + $this->assertEquals('c', $textHelper->in('b', array('b' => 'c'))); } } |