@@ -19,87 +19,121 @@ public function test_helper_returns_string_as_is_if_current_is_not_set()
19
19
20
20
public function test_helper_injects_proper_number_of_doubles_slash ()
21
21
{
22
- $ this ->assertEquals ('../foo.html ' , Hyde::relativeLink ('foo.html ' , 'foo/bar.html ' ));
22
+ $ this ->mockCurrentPage ('foo/bar.html ' );
23
+ $ this ->assertEquals ('../foo.html ' , Hyde::relativeLink ('foo.html ' ));
23
24
}
24
25
25
26
public function test_helper_injects_proper_number_of_doubles_slash_for_deeply_nested_paths ()
26
27
{
27
- $ this ->assertEquals ('../../../foo.html ' , Hyde::relativeLink ('foo.html ' , 'foo/bar/baz/qux.html ' ));
28
+ $ this ->mockCurrentPage ('foo/bar/baz/qux.html ' );
29
+ $ this ->assertEquals ('../../../foo.html ' , Hyde::relativeLink ('foo.html ' ));
28
30
}
29
31
30
32
public function test_helper_handles_destination_without_file_extension ()
31
33
{
32
- $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo ' , 'foo/bar.html ' ));
34
+ $ this ->mockCurrentPage ('foo/bar.html ' );
35
+ $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo ' ));
33
36
}
34
37
35
38
public function test_helper_handles_current_without_file_extension ()
36
39
{
37
- $ this ->assertEquals ('../foo.html ' , Hyde::relativeLink ('foo.html ' , 'foo/bar ' ));
40
+ $ this ->mockCurrentPage ('foo/bar ' );
41
+ $ this ->assertEquals ('../foo.html ' , Hyde::relativeLink ('foo.html ' ));
38
42
}
39
43
40
44
public function test_helper_handles_case_without_any_file_extensions ()
41
45
{
42
- $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo ' , 'foo/bar ' ));
46
+ $ this ->mockCurrentPage ('foo/bar ' );
47
+ $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo ' ));
43
48
}
44
49
45
50
public function test_helper_handles_case_with_mixed_file_extensions ()
46
51
{
52
+ $ this ->mockCurrentPage ('foo/bar.md ' );
47
53
$ this ->assertEquals ('../foo.md ' , Hyde::relativeLink ('foo.md ' , 'foo/bar.md ' ));
54
+ $ this ->mockCurrentPage ('foo/bar.txt ' );
48
55
$ this ->assertEquals ('../foo.txt ' , Hyde::relativeLink ('foo.txt ' , 'foo/bar.txt ' ));
49
56
}
50
57
51
58
public function test_helper_handles_different_file_extensions ()
52
59
{
53
- $ this ->assertEquals ('../foo.png ' , Hyde::relativeLink ('foo.png ' , 'foo/bar ' ));
54
- $ this ->assertEquals ('../foo.css ' , Hyde::relativeLink ('foo.css ' , 'foo/bar ' ));
55
- $ this ->assertEquals ('../foo.js ' , Hyde::relativeLink ('foo.js ' , 'foo/bar ' ));
60
+ $ this ->mockCurrentPage ('foo/bar ' );
61
+ $ this ->assertEquals ('../foo.png ' , Hyde::relativeLink ('foo.png ' ));
62
+ $ this ->assertEquals ('../foo.css ' , Hyde::relativeLink ('foo.css ' ));
63
+ $ this ->assertEquals ('../foo.js ' , Hyde::relativeLink ('foo.js ' ));
56
64
}
57
65
58
66
public function test_helper_returns_pretty_url_if_enabled_and_destination_is_a_html_file ()
59
67
{
60
68
config (['site.pretty_urls ' => true ]);
61
- $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo.html ' , 'foo/bar.html ' ));
69
+ $ this ->mockCurrentPage ('foo/bar.html ' );
70
+ $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo.html ' ));
62
71
}
63
72
64
73
public function test_helper_method_does_not_require_current_path_to_be_html_to_use_pretty_urls ()
65
74
{
66
75
config (['site.pretty_urls ' => true ]);
67
- $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo.html ' , 'foo/bar ' ));
76
+ $ this ->mockCurrentPage ('foo/bar ' );
77
+ $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('foo.html ' ));
68
78
}
69
79
70
80
public function test_helper_returns_does_not_return_pretty_url_if_when_enabled_but_and_destination_is_not_a_html_file ()
71
81
{
72
82
config (['site.pretty_urls ' => true ]);
73
- $ this ->assertEquals ('../foo.png ' , Hyde::relativeLink ('foo.png ' , 'foo/bar.html ' ));
83
+ $ this ->mockCurrentPage ('foo/bar.html ' );
84
+ $ this ->assertEquals ('../foo.png ' , Hyde::relativeLink ('foo.png ' ));
74
85
}
75
86
76
87
public function test_helper_rewrites_index_when_using_pretty_urls ()
77
88
{
78
89
config (['site.pretty_urls ' => true ]);
79
- $ this ->assertEquals ('/ ' , Hyde::relativeLink ('index.html ' , 'foo.html ' ));
80
- $ this ->assertEquals ('../ ' , Hyde::relativeLink ('index.html ' , 'foo/bar.html ' ));
81
- $ this ->assertEquals ('../../ ' , Hyde::relativeLink ('index.html ' , 'foo/bar/baz.html ' ));
90
+ $ this ->mockCurrentPage ('foo.html ' );
91
+ $ this ->assertEquals ('/ ' , Hyde::relativeLink ('index.html ' ));
92
+ $ this ->mockCurrentPage ('foo/bar.html ' );
93
+ $ this ->assertEquals ('../ ' , Hyde::relativeLink ('index.html ' ));
94
+ $ this ->mockCurrentPage ('foo/bar/baz.html ' );
95
+ $ this ->assertEquals ('../../ ' , Hyde::relativeLink ('index.html ' ));
82
96
}
83
97
84
98
public function test_helper_does_not_rewrite_index_when_not_using_pretty_urls ()
85
99
{
86
100
config (['site.pretty_urls ' => false ]);
87
- $ this ->assertEquals ('index.html ' , Hyde::relativeLink ('index.html ' , 'foo.html ' ));
88
- $ this ->assertEquals ('../index.html ' , Hyde::relativeLink ('index.html ' , 'foo/bar.html ' ));
89
- $ this ->assertEquals ('../../index.html ' , Hyde::relativeLink ('index.html ' , 'foo/bar/baz.html ' ));
101
+ $ this ->mockCurrentPage ('foo.html ' );
102
+ $ this ->assertEquals ('index.html ' , Hyde::relativeLink ('index.html ' ));
103
+ $ this ->mockCurrentPage ('foo/bar.html ' );
104
+ $ this ->assertEquals ('../index.html ' , Hyde::relativeLink ('index.html ' ));
105
+ $ this ->mockCurrentPage ('foo/bar/baz.html ' );
106
+ $ this ->assertEquals ('../../index.html ' , Hyde::relativeLink ('index.html ' ));
90
107
}
91
108
92
109
public function test_helper_rewrites_documentation_page_index_when_using_pretty_urls ()
93
110
{
94
111
config (['site.pretty_urls ' => true ]);
95
- $ this ->assertEquals ('docs/ ' , Hyde::relativeLink ('docs/index.html ' , 'foo.html ' ));
96
- $ this ->assertEquals ('docs/ ' , Hyde::relativeLink ('docs/index.html ' , 'docs.html ' ));
97
- $ this ->assertEquals ('../docs/ ' , Hyde::relativeLink ('docs/index.html ' , 'foo/bar.html ' ));
98
- $ this ->assertEquals ('../docs/ ' , Hyde::relativeLink ('docs/index.html ' , 'docs/foo.html ' ));
112
+ $ this ->mockCurrentPage ('foo.html ' );
113
+ $ this ->assertEquals ('docs/ ' , Hyde::relativeLink ('docs/index.html ' ));
114
+ $ this ->mockCurrentPage ('docs.html ' );
115
+ $ this ->assertEquals ('docs/ ' , Hyde::relativeLink ('docs/index.html ' ));
116
+ $ this ->mockCurrentPage ('foo/bar.html ' );
117
+ $ this ->assertEquals ('../docs/ ' , Hyde::relativeLink ('docs/index.html ' ));
118
+ $ this ->mockCurrentPage ('docs/foo.html ' );
119
+ $ this ->assertEquals ('../docs/ ' , Hyde::relativeLink ('docs/index.html ' ));
120
+ }
121
+
122
+ public function test_helper_does_not_rewrite_documentation_page_index_when_not_using_pretty_urls ()
123
+ {
124
+ config (['site.pretty_urls ' => false ]);
125
+ $ this ->mockCurrentPage ('foo.html ' );
126
+ $ this ->assertEquals ('docs/index.html ' , Hyde::relativeLink ('docs/index.html ' ));
127
+ $ this ->mockCurrentPage ('docs.html ' );
128
+ $ this ->assertEquals ('docs/index.html ' , Hyde::relativeLink ('docs/index.html ' ));
129
+ $ this ->mockCurrentPage ('foo/bar.html ' );
130
+ $ this ->assertEquals ('../docs/index.html ' , Hyde::relativeLink ('docs/index.html ' ));
131
+ $ this ->mockCurrentPage ('docs/foo.html ' );
132
+ $ this ->assertEquals ('../docs/index.html ' , Hyde::relativeLink ('docs/index.html ' ));
99
133
}
100
134
101
135
public function test_helper_does_not_rewrite_already_processed_links ()
102
136
{
103
- $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('../foo ' , ' foo/bar.html ' ));
137
+ $ this ->assertEquals ('../foo ' , Hyde::relativeLink ('../foo ' ));
104
138
}
105
139
}
0 commit comments