|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Tests\Unit; |
| 4 | + |
| 5 | +use Hyde\Framework\Hyde; |
| 6 | +use Tests\TestCase; |
| 7 | + |
| 8 | +/** |
| 9 | + * Class HydeFileHelperForPageLinksCanCreatePrettyUrlsTest. |
| 10 | + * |
| 11 | + * @covers \Hyde\Framework\Concerns\Internal\FileHelpers |
| 12 | + */ |
| 13 | +class HydeFileHelperForPageLinksCanCreatePrettyUrlsTest extends TestCase |
| 14 | +{ |
| 15 | + public function test_helper_returns_string_as_is_if_pretty_urls_is_not_true() |
| 16 | + { |
| 17 | + config(['hyde.prettyUrls' => false]); |
| 18 | + |
| 19 | + $this->assertEquals('foo/bar.html', Hyde::pageLink('foo/bar.html')); |
| 20 | + } |
| 21 | + |
| 22 | + public function test_helper_returns_pretty_url_if_pretty_urls_is_true() |
| 23 | + { |
| 24 | + config(['hyde.prettyUrls' => true]); |
| 25 | + |
| 26 | + $this->assertEquals('foo/bar', Hyde::pageLink('foo/bar.html')); |
| 27 | + } |
| 28 | + |
| 29 | + public function test_non_pretty_urls_is_default_value_when_config_is_not_set() |
| 30 | + { |
| 31 | + config(['hyde.prettyUrls' => null]); |
| 32 | + |
| 33 | + $this->assertEquals('foo/bar.html', Hyde::pageLink('foo/bar.html')); |
| 34 | + } |
| 35 | + |
| 36 | + public function test_helper_respects_absolute_urls() |
| 37 | + { |
| 38 | + config(['hyde.prettyUrls' => false]); |
| 39 | + $this->assertEquals('/foo/bar.html', Hyde::pageLink('/foo/bar.html')); |
| 40 | + } |
| 41 | + |
| 42 | + public function test_helper_respects_pretty_absolute_urls() |
| 43 | + { |
| 44 | + config(['hyde.prettyUrls' => true]); |
| 45 | + $this->assertEquals('/foo/bar', Hyde::pageLink('/foo/bar.html')); |
| 46 | + } |
| 47 | + |
| 48 | + public function test_helper_respects_relative_urls() |
| 49 | + { |
| 50 | + config(['hyde.prettyUrls' => false]); |
| 51 | + $this->assertEquals('../foo/bar.html', Hyde::pageLink('../foo/bar.html')); |
| 52 | + } |
| 53 | + |
| 54 | + public function test_helper_respects_pretty_relative_urls() |
| 55 | + { |
| 56 | + config(['hyde.prettyUrls' => true]); |
| 57 | + $this->assertEquals('../foo/bar', Hyde::pageLink('../foo/bar.html')); |
| 58 | + } |
| 59 | + |
| 60 | + public function test_non_html_links_are_not_modified() |
| 61 | + { |
| 62 | + config(['hyde.prettyUrls' => true]); |
| 63 | + $this->assertEquals('/foo/bar.jpg', Hyde::pageLink('/foo/bar.jpg')); |
| 64 | + } |
| 65 | + |
| 66 | + public function test_helper_respects_absolute_urls_with_pretty_urls_enabled() |
| 67 | + { |
| 68 | + config(['hyde.prettyUrls' => true]); |
| 69 | + $this->assertEquals('/foo/bar.jpg', Hyde::pageLink('/foo/bar.jpg')); |
| 70 | + } |
| 71 | +} |
0 commit comments