Total Complexity | 1 |
Total Lines | 17 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class GetLatestMarkdownPostsTest extends TestCase |
||
14 | { |
||
15 | public function test_markdown_page_get_latest_helper_returns_sorted_markdown_page_collection() |
||
16 | { |
||
17 | file_put_contents(Hyde::path('_posts/new.md'), "---\ndate: '2022-01-01 12:00'\n---\n"); |
||
18 | file_put_contents(Hyde::path('_posts/old.md'), "---\ndate: '2021-01-01 12:00'\n---\n"); |
||
19 | |||
20 | $collection = MarkdownPost::getLatestPosts(); |
||
21 | $this->assertCount(2, $collection); |
||
22 | $this->assertInstanceOf(Collection::class, $collection); |
||
23 | $this->assertContainsOnlyInstancesOf(MarkdownPost::class, $collection); |
||
24 | |||
25 | $this->assertEquals('new', $collection->first()->identifier); |
||
26 | $this->assertEquals('old', $collection->last()->identifier); |
||
27 | |||
28 | unlink(Hyde::path('_posts/new.md')); |
||
29 | unlink(Hyde::path('_posts/old.md')); |
||
30 | } |
||
32 |