Skip to content

Commit

Permalink
BennoThommo requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wim Verhoogt committed Sep 15, 2023
1 parent e6a2cf9 commit ce4e758
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ composer.lock
# Editor files
.idea
.vscode
*.code-workspace

# Other files
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion tests/Database/UpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class UpdaterTest extends TestCase
{
protected $updater;
protected Updater $updater;

public function setUp(): void
{
Expand Down
5 changes: 2 additions & 3 deletions tests/Foundation/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

class ApplicationTest extends TestCase
{
protected $app;
protected $basePath;

protected string $basePath;

protected function setUp(): void
{
// Mock application
Expand Down
4 changes: 2 additions & 2 deletions tests/Html/BlockBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class BlockBuilderTest extends TestCase
{
protected $Block;
protected BlockBuilder $Block;

public function setUp(): void
{
$this->Block = new BlockBuilder();
Expand Down
28 changes: 14 additions & 14 deletions tests/Parse/MarkdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class MarkdownTest extends TestCase
/**
* Test fixtures that should be skipped by the data provider.
*/
protected static array $specialTests = [
protected array $specialTests = [
'front_matter',
];

Expand All @@ -20,42 +20,42 @@ class MarkdownTest extends TestCase
*/
public function testParse($name, $markdown, $html)
{
$this->assertEquals($html, self::removeLineEndings(Markdown::parse($markdown)), 'Markdown test case "' . $name . '" failed');
$this->assertEquals($html, $this->removeLineEndings(Markdown::parse($markdown)), 'Markdown test case "' . $name . '" failed');
}

public function testParseSafe()
{
$markdown = file_get_contents(dirname(__DIR__) . '/fixtures/markdown/code_block.md');
$html = self::removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/code_block_disabled.html'));
$html = $this->removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/code_block_disabled.html'));

$this->assertEquals($html, self::removeLineEndings(Markdown::parseSafe($markdown)));
$this->assertEquals($html, $this->removeLineEndings(Markdown::parseSafe($markdown)));
}

public function testDisableAndEnableMethods()
{
$parser = Markdown::disableAutolinking()->disableTables();

$markdown = file_get_contents(dirname(__DIR__) . '/fixtures/markdown/table_inline_markdown.md');
$html = self::removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/table_inline_markdown_disabled.html'));
$html = $this->removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/table_inline_markdown_disabled.html'));

$this->assertEquals($html, self::removeLineEndings($parser->parse($markdown)));
$this->assertEquals($html, $this->removeLineEndings($parser->parse($markdown)));

// Re-enable tables and autolinking
$parser->enableAutolinking()->enableTables();

$html = self::removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/table_inline_markdown.html'));
$html = $this->removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/table_inline_markdown.html'));

$this->assertEquals($html, self::removeLineEndings($parser->parse($markdown)));
$this->assertEquals($html, $this->removeLineEndings($parser->parse($markdown)));
}

public function testFrontMatter()
{
$parser = Markdown::enableFrontMatter();

$markdown = file_get_contents(dirname(__DIR__) . '/fixtures/markdown/front_matter.md');
$html = self::removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/front_matter.html'));
$html = $this->removeLineEndings(file_get_contents(dirname(__DIR__) . '/fixtures/markdown/front_matter.html'));

$this->assertEquals($html, self::removeLineEndings($parser->parse($markdown)));
$this->assertEquals($html, $this->removeLineEndings($parser->parse($markdown)));
$this->assertEquals([
'title' => 'My document',
'group' => 'Documents',
Expand All @@ -75,7 +75,7 @@ public function testFrontMatter()
*
* @return array
*/
public static function markdownData()
public function markdownData()
{
$dirName = dirname(__DIR__) . '/fixtures/markdown';
$dir = new DirectoryIterator($dirName);
Expand All @@ -87,19 +87,19 @@ public static function markdownData()
if ($name === 'README') {
continue;
}
if (in_array($name, self::$specialTests)) {
if (in_array($name, $this->specialTests)) {
continue;
}

$markdown = file_get_contents($dirName . DIRECTORY_SEPARATOR . $name . '.md');
$html = self::removeLineEndings(file_get_contents($dirName . DIRECTORY_SEPARATOR . $name . '.html'));
$html = $this->removeLineEndings(file_get_contents($dirName . DIRECTORY_SEPARATOR . $name . '.html'));

yield [$name, $markdown, $html];
}
}
}

protected static function removeLineEndings(string $text)
protected function removeLineEndings(string $text)
{
return str_replace(["\r\n", "\r", "\n"], '', $text);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/EventFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class EventFakeTest extends TestCase
{
protected $faker;
protected EventFake $faker;

public function setUp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/MailFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function setUp(): void
parent::setUp();

App::shouldReceive('getLocale')->andReturn('en/US');
Mail::swap(new MailFake(new MailManager(app())));
Mail::swap(new MailFake(new MailManager($this->app)));

$this->recipient = 'fake@localhost';
$this->subject = 'MailFake test';
Expand Down

0 comments on commit ce4e758

Please sign in to comment.