-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHydeBuildSearchCommandTest.php
77 lines (64 loc) · 2.51 KB
/
HydeBuildSearchCommandTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace Hyde\Framework\Testing\Feature\Commands;
use Hyde\Framework\Commands\HydeBuildSearchCommand;
use Hyde\Framework\Hyde;
use Hyde\Testing\TestCase;
/**
* @covers \Hyde\Framework\Commands\HydeBuildSearchCommand
*/
class HydeBuildSearchCommandTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
unlinkIfExists(Hyde::path('_site/docs/search.json'));
unlinkIfExists(Hyde::path('_site/docs/search.html'));
}
protected function tearDown(): void
{
unlinkIfExists(Hyde::path('_site/docs/search.html'));
unlinkIfExists(Hyde::path('_site/docs/search.json'));
HydeBuildSearchCommand::$guesstimationFactor = 52.5;
parent::tearDown();
}
public function test_it_creates_the_search_json_file()
{
$this->artisan('build:search')
->expectsOutput('Generating documentation site search index...')
->assertExitCode(0);
$this->assertFileExists(Hyde::path('_site/docs/search.json'));
}
public function test_it_creates_the_search_page()
{
$this->artisan('build:search')
->expectsOutput('Generating documentation site search index...')
->assertExitCode(0);
$this->assertFileExists(Hyde::path('_site/docs/search.html'));
}
public function test_it_does_not_create_the_search_page_if_disabled()
{
config(['docs.create_search_page' => false]);
$this->artisan('build:search')
->expectsOutput('Generating documentation site search index...')
->assertExitCode(0);
$this->assertFileDoesNotExist(Hyde::path('_site/docs/search.html'));
}
public function test_it_does_not_display_the_estimation_message_when_it_is_less_than_1_second()
{
HydeBuildSearchCommand::$guesstimationFactor = 0;
$this->artisan('build:search')
->expectsOutput('Generating documentation site search index...')
->doesntExpectOutputToContain('> This will take an estimated')
->assertExitCode(0);
}
public function test_it_displays_the_estimation_message_when_it_is_greater_than_1_second()
{
HydeBuildSearchCommand::$guesstimationFactor = 1000;
touch(Hyde::path('_docs/foo.md'));
$this->artisan('build:search')
->expectsOutput('Generating documentation site search index...')
->expectsOutputToContain('> This will take an estimated')
->assertExitCode(0);
unlink(Hyde::path('_docs/foo.md'));
}
}