Passed
Branch master (1e39e8)
by Caen
03:01
created

RebuildServiceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2
1
<?php
2
3
namespace Hyde\Framework\Testing\Feature;
4
5
use Hyde\Framework\Hyde;
6
use Hyde\Framework\Services\RebuildService;
7
use Hyde\Framework\StaticPageBuilder;
8
use Hyde\Testing\TestCase;
9
10
/**
11
 * Note that we don't fully test the created files since the service is
12
 * just a proxy for the actual builders, which have their own tests.
13
 *
14
 * @covers \Hyde\Framework\Services\RebuildService
15
 */
16
class RebuildServiceTest extends TestCase
17
{
18
    public function test_execute_methods()
19
    {
20
        $this->runExecuteTest('_posts');
21
        $this->runExecuteTest('_pages');
22
        $this->runExecuteTest('_docs');
23
        $this->runExecuteTest('_pages', '.blade.php');
24
25
        unlink(Hyde::path('_site/foo.html'));
26
        unlink(Hyde::path('_site/docs/foo.html'));
27
        unlink(Hyde::path('_site/posts/foo.html'));
28
    }
29
30
    protected function runExecuteTest(string $prefix, string $suffix = '.md')
31
    {
32
        $path = $prefix.'/foo'.$suffix;
33
        Hyde::touch(($path));
34
        $service = new RebuildService($path);
35
        $result = $service->execute();
36
        $this->assertInstanceOf(StaticPageBuilder::class, $result);
37
        unlink(Hyde::path($path));
38
    }
39
}
40