1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Hyde\Framework\Testing\Unit\Foundation; |
4
|
|
|
|
5
|
|
|
use Hyde\Framework\Hyde; |
6
|
|
|
use Hyde\Testing\TestCase; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @covers \Hyde\Framework\Foundation\Hyperlinks::formatHtmlPath |
10
|
|
|
*/ |
11
|
|
|
class HyperlinkFormatHtmlPathTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
public function test_helper_returns_string_as_is_if_pretty_urls_is_not_true() |
14
|
|
|
{ |
15
|
|
|
config(['site.pretty_urls' => false]); |
16
|
|
|
|
17
|
|
|
$this->assertEquals('foo/bar.html', Hyde::formatHtmlPath('foo/bar.html')); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function test_helper_returns_pretty_url_if_pretty_urls_is_true() |
21
|
|
|
{ |
22
|
|
|
config(['site.pretty_urls' => true]); |
23
|
|
|
|
24
|
|
|
$this->assertEquals('foo/bar', Hyde::formatHtmlPath('foo/bar.html')); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function test_non_pretty_urls_is_default_value_when_config_is_not_set() |
28
|
|
|
{ |
29
|
|
|
config(['site.pretty_urls' => null]); |
30
|
|
|
|
31
|
|
|
$this->assertEquals('foo/bar.html', Hyde::formatHtmlPath('foo/bar.html')); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function test_helper_respects_absolute_urls() |
35
|
|
|
{ |
36
|
|
|
config(['site.pretty_urls' => false]); |
37
|
|
|
$this->assertEquals('/foo/bar.html', Hyde::formatHtmlPath('/foo/bar.html')); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function test_helper_respects_pretty_absolute_urls() |
41
|
|
|
{ |
42
|
|
|
config(['site.pretty_urls' => true]); |
43
|
|
|
$this->assertEquals('/foo/bar', Hyde::formatHtmlPath('/foo/bar.html')); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function test_helper_respects_relative_urls() |
47
|
|
|
{ |
48
|
|
|
config(['site.pretty_urls' => false]); |
49
|
|
|
$this->assertEquals('../foo/bar.html', Hyde::formatHtmlPath('../foo/bar.html')); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function test_helper_respects_pretty_relative_urls() |
53
|
|
|
{ |
54
|
|
|
config(['site.pretty_urls' => true]); |
55
|
|
|
$this->assertEquals('../foo/bar', Hyde::formatHtmlPath('../foo/bar.html')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function test_non_html_links_are_not_modified() |
59
|
|
|
{ |
60
|
|
|
config(['site.pretty_urls' => true]); |
61
|
|
|
$this->assertEquals('/foo/bar.jpg', Hyde::formatHtmlPath('/foo/bar.jpg')); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function test_helper_respects_absolute_urls_with_pretty_urls_enabled() |
65
|
|
|
{ |
66
|
|
|
config(['site.pretty_urls' => true]); |
67
|
|
|
$this->assertEquals('/foo/bar.jpg', Hyde::formatHtmlPath('/foo/bar.jpg')); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function test_helper_rewrites_index_when_using_pretty_urls() |
71
|
|
|
{ |
72
|
|
|
config(['site.pretty_urls' => true]); |
73
|
|
|
$this->assertEquals('/', Hyde::formatHtmlPath('index.html')); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function test_helper_does_not_rewrite_index_when_not_using_pretty_urls() |
77
|
|
|
{ |
78
|
|
|
config(['site.pretty_urls' => false]); |
79
|
|
|
$this->assertEquals('index.html', Hyde::formatHtmlPath('index.html')); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function test_helper_rewrites_documentation_page_index_when_using_pretty_urls() |
83
|
|
|
{ |
84
|
|
|
config(['site.pretty_urls' => true]); |
85
|
|
|
$this->assertEquals('docs/', Hyde::formatHtmlPath('docs/index.html')); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function test_helper_does_not_rewrite_documentation_page_index_when_not_using_pretty_urls() |
89
|
|
|
{ |
90
|
|
|
config(['site.pretty_urls' => false]); |
91
|
|
|
$this->assertEquals('docs/index.html', Hyde::formatHtmlPath('docs/index.html')); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|