container); $html = '<img src=x onerror=alert(0)>'; $this->assertEquals($html, $textHelper->implode(', ', array(''))); } public function testMarkdownTaskLink() { $textHelper = 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('

Test

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

Task #123

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

Task #123

', $textHelper->markdown('Task #123', true) ); $this->assertEquals( '

Task #1

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

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

', $textHelper->markdown( 'Check that: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454' ) ); } public function testMarkdownUserLink() { $textHelper = new TextHelper($this->container); $userModel = new UserModel($this->container); $this->assertEquals(2, $userModel->create(array('username' => 'firstname.lastname', 'name' => 'Firstname Lastname'))); $this->assertEquals( '

Text @admin @notfound

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

Text @admin,

', $textHelper->markdown('Text @admin,') ); $this->assertEquals( '

Text @admin!

', $textHelper->markdown('Text @admin!') ); $this->assertEquals( '

Text @admin?

', $textHelper->markdown('Text @admin? ') ); $this->assertEquals( '

Text @admin.

', $textHelper->markdown('Text @admin.') ); $this->assertEquals( '

Text @admin: test

', $textHelper->markdown('Text @admin: test') ); $this->assertEquals( '

Text @admin: test

', $textHelper->markdown('Text @admin: test') ); $this->assertEquals( '

Text @firstname.lastname. test

', $textHelper->markdown('Text @firstname.lastname. test') ); $this->assertEquals('

Text @admin @notfound

', $textHelper->markdown('Text @admin @notfound', true)); } public function testFormatBytes() { $textHelper = new TextHelper($this->container); $this->assertEquals('0', $textHelper->bytes(0)); $this->assertEquals('1k', $textHelper->bytes(1024)); $this->assertEquals('33.71k', $textHelper->bytes(34520)); } public function testContains() { $textHelper = new TextHelper($this->container); $this->assertTrue($textHelper->contains('abc', 'b')); $this->assertFalse($textHelper->contains('abc', 'd')); } public function testInList() { $textHelper = new TextHelper($this->container); $this->assertEquals('?', $textHelper->in('a', array('b' => 'c'))); $this->assertEquals('c', $textHelper->in('b', array('b' => 'c'))); } }