Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests & missing Markdown facade #1074

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/system/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Event;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Markdown;
use Request;
use System\Classes\CombineAssets;
use System\Classes\ErrorHandler;
Expand Down
33 changes: 29 additions & 4 deletions modules/system/tests/twig/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

class FilterTest extends TestCase
{
public function testFilterUpper()
public function setUp(): void
{
// Get the Twig Environment
$twig = $this->app->make('twig.environment');
parent::setUp();

$this->twig = $this->app->make('twig.environment');
}

public function testFilterUpper()
{
// Run the Twig Filter tests
// @see /~https://github.com/twigphp/Twig/commit/d475a92c83d13951fbcadd20e64b8ebca82bfc7e
$tests = [
Expand Down Expand Up @@ -112,7 +116,7 @@ public function testFilterUpper()
];

foreach ($tests as $name => $test) {
$template = $twig->createTemplate($test['template']);
$template = $this->twig->createTemplate($test['template']);
$this->assertEquals(
str_replace(
"\r\n",
Expand All @@ -127,4 +131,25 @@ public function testFilterUpper()
);
}
}

public function testFilterMdNull()
{
$template = $this->twig->createTemplate('{% filter md %}{{ value }}{% endfilter %}');

$this->assertEquals('', $template->render(['value' => null]));
}

public function testFilterMdSafeNull()
{
$template = $this->twig->createTemplate('{% filter md_safe %}{{ value }}{% endfilter %}');

$this->assertEquals('', $template->render(['value' => null]));
}

public function testFilterMdLineNull()
{
$template = $this->twig->createTemplate('{% filter md_line %}{{ value }}{% endfilter %}');

$this->assertEquals('', $template->render(['value' => null]));
}
}
Loading