-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09d8af6
commit 4a3ecaa
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\Views; | ||
|
||
use Hyde\Framework\Hyde; | ||
use Hyde\Framework\Models\MarkdownPost; | ||
use Illuminate\Support\Facades\Blade; | ||
use Tests\TestCase; | ||
|
||
/** | ||
* @see resources/views/components/article-excerpt.blade.php | ||
*/ | ||
class ArticleExcerptViewTest extends TestCase | ||
{ | ||
protected function renderTestView(MarkdownPost $post): string | ||
{ | ||
return Blade::render(file_get_contents( | ||
Hyde::vendorPath('resources/views/components/article-excerpt.blade.php') | ||
), ['post' => $post]); | ||
} | ||
|
||
public function test_component_can_be_rendered() | ||
{ | ||
$view = $this->renderTestView(new MarkdownPost([], '')); | ||
$this->assertStringContainsString('https://schema.org/Article', $view); | ||
} | ||
|
||
public function test_component_renders_post_data() | ||
{ | ||
$view = $this->renderTestView(new MarkdownPost([ | ||
'title' => 'Test Post', | ||
'date' => '2022-01-01 12:00:00', | ||
'author' => 'John Doe', | ||
'description' => 'This is a test post.', | ||
], '# Foo Bar', 'Foo Bar', 'foo-bar')); | ||
|
||
$this->assertStringContainsString('Test Post', $view); | ||
$this->assertStringContainsString('Jan 1st, 2022', $view); | ||
$this->assertStringContainsString('John Doe', $view); | ||
$this->assertStringContainsString('This is a test post.', $view); | ||
$this->assertStringContainsString('Read post', $view); | ||
} | ||
|
||
public function test_component_renders_post_with_author_object() | ||
{ | ||
$view = $this->renderTestView(new MarkdownPost([ | ||
'author' => [ | ||
'name' => 'John Doe', | ||
'url' => '#', | ||
], | ||
], '')); | ||
|
||
$this->assertStringContainsString('John Doe', $view); | ||
} | ||
} |