| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class MarkdownPageTest extends TestCase |
||
| 15 | { |
||
| 16 | protected function setUp(): void |
||
| 17 | { |
||
| 18 | parent::setUp(); |
||
| 19 | |||
| 20 | backupDirectory(Hyde::path('_pages')); |
||
| 21 | File::deleteDirectory(Hyde::path('_pages')); |
||
| 22 | mkdir(Hyde::path('_pages')); |
||
| 23 | |||
| 24 | file_put_contents(Hyde::path('_pages/test-post.md'), "# PHPUnit Test File \n Hello World!"); |
||
| 25 | } |
||
| 26 | |||
| 27 | protected function tearDown(): void |
||
| 28 | { |
||
| 29 | restoreDirectory(Hyde::path('_pages')); |
||
| 30 | |||
| 31 | parent::tearDown(); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function test_can_get_collection_of_slugs() |
||
| 35 | { |
||
| 36 | $array = DiscoveryService::getMarkdownPageFiles(); |
||
| 37 | |||
| 38 | $this->assertIsArray($array); |
||
| 39 | $this->assertCount(1, $array); |
||
| 40 | $this->assertArrayHasKey('test-post', array_flip($array)); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function test_created_model_contains_expected_data() |
||
| 44 | { |
||
| 45 | $page = MarkdownPage::parse('test-post'); |
||
| 46 | |||
| 47 | $this->assertEquals('PHPUnit Test File', $page->title); |
||
| 48 | $this->assertEquals("# PHPUnit Test File \n Hello World!", $page->markdown); |
||
| 49 | $this->assertEquals('test-post', $page->identifier); |
||
| 50 | } |
||
| 52 |