|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hyde\RealtimeCompiler\Tests\Integration; |
|
4
|
|
|
|
|
5
|
|
|
class IntegrationTest extends IntegrationTestCase |
|
6
|
|
|
{ |
|
7
|
|
|
public function testWelcome() |
|
8
|
|
|
{ |
|
9
|
|
|
$this->get('/') |
|
10
|
|
|
->assertStatus(200) |
|
11
|
|
|
->assertSeeText("You're running on HydePHP"); |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
public function test404() |
|
15
|
|
|
{ |
|
16
|
|
|
$this->get('/non-existent-page') |
|
17
|
|
|
->assertStatus(404) |
|
18
|
|
|
->assertSeeText('RouteNotFoundException') |
|
19
|
|
|
->assertSeeText('Route [non-existent-page] not found.'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function testNestedIndexPageRouting() |
|
23
|
|
|
{ |
|
24
|
|
|
if (! is_dir($this->projectPath('_pages/about'))) { |
|
25
|
|
|
mkdir($this->projectPath('_pages/about'), 0755, true); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
file_put_contents($this->projectPath('_docs/index.md'), '# Documentation'); |
|
29
|
|
|
file_put_contents($this->projectPath('_pages/about/index.md'), '# About'); |
|
30
|
|
|
file_put_contents($this->projectPath('_pages/about/contact.md'), '# Contact'); |
|
31
|
|
|
|
|
32
|
|
|
$this->get('/docs/index.html')->assertStatus(200)->assertSeeText('Documentation'); |
|
33
|
|
|
$this->get('/about/index.html')->assertStatus(200)->assertSeeText('About'); |
|
34
|
|
|
$this->get('/about/contact.html')->assertStatus(200)->assertSeeText('Contact'); |
|
35
|
|
|
|
|
36
|
|
|
$this->get('/docs/index')->assertStatus(200)->assertSeeText('Documentation'); |
|
37
|
|
|
$this->get('/about/index')->assertStatus(200)->assertSeeText('About'); |
|
38
|
|
|
$this->get('/about/contact')->assertStatus(200)->assertSeeText('Contact'); |
|
39
|
|
|
|
|
40
|
|
|
$this->get('/docs/')->assertStatus(200)->assertSeeText('Documentation'); |
|
41
|
|
|
$this->get('/about/')->assertStatus(200)->assertSeeText('About'); |
|
42
|
|
|
$this->get('/about/contact/')->assertStatus(200)->assertSeeText('Contact'); |
|
43
|
|
|
|
|
44
|
|
|
$this->get('/docs')->assertStatus(200)->assertSeeText('Documentation'); |
|
45
|
|
|
$this->get('/about')->assertStatus(200)->assertSeeText('About'); |
|
46
|
|
|
$this->get('/about/contact')->assertStatus(200)->assertSeeText('Contact'); |
|
47
|
|
|
|
|
48
|
|
|
$this->get('/about/contact/index')->assertStatus(404); |
|
49
|
|
|
|
|
50
|
|
|
unlink($this->projectPath('_docs/index.md')); |
|
51
|
|
|
unlink($this->projectPath('_pages/about/index.md')); |
|
52
|
|
|
unlink($this->projectPath('_pages/about/contact.md')); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testDynamicDocumentationSearchPages() |
|
56
|
|
|
{ |
|
57
|
|
|
file_put_contents($this->projectPath('_docs/index.md'), '# Documentation'); |
|
58
|
|
|
file_put_contents($this->projectPath('_docs/installation.md'), '# Installation'); |
|
59
|
|
|
|
|
60
|
|
|
$this->get('/docs/search') |
|
61
|
|
|
->assertStatus(200) |
|
62
|
|
|
->assertSeeText('Search the documentation site'); |
|
63
|
|
|
|
|
64
|
|
|
$this->get('/docs/search.html') |
|
65
|
|
|
->assertStatus(200) |
|
66
|
|
|
->assertSeeText('Search the documentation site'); |
|
67
|
|
|
|
|
68
|
|
|
$this->get('/docs/search.json') |
|
69
|
|
|
->assertStatus(200) |
|
70
|
|
|
->assertHeader('Content-Type', 'application/json') |
|
71
|
|
|
->assertJson([ |
|
72
|
|
|
[ |
|
73
|
|
|
'slug' => 'index', |
|
74
|
|
|
'title' => 'Documentation', |
|
75
|
|
|
'content' => 'Documentation', |
|
76
|
|
|
'destination' => 'index.html', |
|
77
|
|
|
], |
|
78
|
|
|
[ |
|
79
|
|
|
'slug' => 'installation', |
|
80
|
|
|
'title' => 'Installation', |
|
81
|
|
|
'content' => 'Installation', |
|
82
|
|
|
'destination' => 'installation.html', |
|
83
|
|
|
], |
|
84
|
|
|
]); |
|
85
|
|
|
|
|
86
|
|
|
unlink($this->projectPath('_docs/index.md')); |
|
87
|
|
|
unlink($this->projectPath('_docs/installation.md')); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|