Passed
Push — master ( a0ff31...47a9f8 )
by Caen
03:50 queued 14s
created

MarkdownPageTest::test_title_was_inferred_from_heading()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hyde\Framework\Testing\Feature;
4
5
use Hyde\Framework\Hyde;
6
use Hyde\Framework\Models\Pages\MarkdownPage;
7
use Hyde\Framework\Services\DiscoveryService;
8
use Hyde\Testing\TestCase;
9
use Illuminate\Support\Facades\File;
10
11
/**
12
 * Test the Markdown page parser.
13
 */
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);
0 ignored issues
show
Bug introduced by
Accessing title on the interface Hyde\Framework\Contracts\PageContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
48
        $this->assertEquals("# PHPUnit Test File \n Hello World!", $page->body);
0 ignored issues
show
Bug introduced by
Accessing body on the interface Hyde\Framework\Contracts\PageContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
49
        $this->assertEquals('test-post', $page->slug);
0 ignored issues
show
Bug introduced by
Accessing slug on the interface Hyde\Framework\Contracts\PageContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
50
    }
51
}
52