Skip to content
Permalink
Browse files

Add phpunit tests for helpers

  • Loading branch information...
dignityinside committed Jun 19, 2019
1 parent 38709bc commit ed0771c47c600a047b54f4dd91dce1e9a1942965
Showing with 82 additions and 0 deletions.
  1. +24 −0 tests/Unit/Helpers/HtmlPurifier.php
  2. +24 −0 tests/Unit/Helpers/MarkdownTest.php
  3. +34 −0 tests/Unit/Helpers/TextTest.php
@@ -0,0 +1,24 @@
<?php
namespace Tests\Unit\Helpers;
use Tests\TestCase;
use App\Helpers\HtmlPurifier;
/**
* Class HtmlPurifierTest
*
* @package Tests\Unit\Helpers
*
* @author Alexander Schilling <dignityinside@protonmail.com>
*/
class HtmlPurifierTest extends TestCase
{
public $data = "I'm evil code: <script>alert('hallo welt');</script>";
public function test_html_purifier_work()
{
$this->assertNotEquals(HtmlPurifier::process($this->data), $this->data);
}
}
@@ -0,0 +1,24 @@
<?php
namespace Tests\Unit\Helpers;
use Tests\TestCase;
use App\Helpers\Markdown;
/**
* Class MarkdownTest
*
* @package Tests\Unit\Helpers
*
* @author Alexander Schilling <dignityinside@protonmail.com>
*/
class MarkdownTest extends TestCase
{
public function test_markdown_work()
{
$markdownText = Markdown::process('**Hallo welt**');
$parsedHtml = '<p><strong>Hallo welt</strong></p>';
$this->assertContains($parsedHtml, $markdownText);
}
}
@@ -0,0 +1,34 @@
<?php
namespace Tests\Unit\Helpers;
use Tests\TestCase;
use App\Helpers\Text;
/**
* Class TextTest
*
* @package Tests\Unit\Helpers
*
* @author Alexander Schilling <dignityinside@protonmail.com>
*/
class TextTest extends TestCase
{
public $data = 'Lorem ipsum dolor sit amet. [cut] Consectetur adipisicing elit. Accusantium blanditiis cum.';
public function test_cut()
{
$this->assertEquals(28, strlen(Text::cut($this->data)));
}
public function test_cut_with_more_link()
{
$this->assertEquals(36, strlen(Text::cut($this->data, 'More...')));
}
public function test_hidecut()
{
$this->assertEquals(86, strlen(Text::hideCut($this->data)));
}
}

0 comments on commit ed0771c

Please sign in to comment.
You can’t perform that action at this time.