Skip to content

Commit

Permalink
Use the snake_case config format
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed May 22, 2022
1 parent 92b9ae5 commit f578855
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Commands/HydeBuildStaticSiteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function runPreBuildActions(): void
if ($this->option('pretty-urls')) {
$this->info('Generating site with pretty URLs');
$this->newLine();
Config::set(['hyde.prettyUrls' => true]);
Config::set(['hyde.pretty_urls' => true]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Concerns/HasPageMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function setUp(): void

config(['hyde.meta' => []]);
config(['hyde.site_url' => null]);
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);
config(['hyde.generateSitemap' => false]);
}

Expand All @@ -46,7 +46,7 @@ public function test_get_canonical_url_returns_pretty_url_for_top_level_page()
public string $slug = 'foo';
};
config(['hyde.site_url' => 'https://example.com']);
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);

$this->assertEquals('https://example.com/foo', $page->getCanonicalUrl());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Services/SitemapServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function test_can_generate_sitemap_helper_returns_false_if_sitemaps_are_d

public function test_url_item_is_generated_correctly()
{
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);
config(['hyde.site_url' => 'https://example.com']);
touch(Hyde::path('_pages/0-test.blade.php'));

Expand All @@ -129,7 +129,7 @@ public function test_url_item_is_generated_correctly()

public function test_url_item_is_generated_with_pretty_ur_ls_if_enabled()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
config(['hyde.site_url' => 'https://example.com']);
touch(Hyde::path('_pages/0-test.blade.php'));

Expand Down
26 changes: 13 additions & 13 deletions tests/Unit/FileHelperPageLinkPrettyUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,82 +14,82 @@ class FileHelperPageLinkPrettyUrlTest extends TestCase
{
public function test_helper_returns_string_as_is_if_pretty_urls_is_not_true()
{
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);

$this->assertEquals('foo/bar.html', Hyde::pageLink('foo/bar.html'));
}

public function test_helper_returns_pretty_url_if_pretty_urls_is_true()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);

$this->assertEquals('foo/bar', Hyde::pageLink('foo/bar.html'));
}

public function test_non_pretty_urls_is_default_value_when_config_is_not_set()
{
config(['hyde.prettyUrls' => null]);
config(['hyde.pretty_urls' => null]);

$this->assertEquals('foo/bar.html', Hyde::pageLink('foo/bar.html'));
}

public function test_helper_respects_absolute_urls()
{
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);
$this->assertEquals('/foo/bar.html', Hyde::pageLink('/foo/bar.html'));
}

public function test_helper_respects_pretty_absolute_urls()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('/foo/bar', Hyde::pageLink('/foo/bar.html'));
}

public function test_helper_respects_relative_urls()
{
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);
$this->assertEquals('../foo/bar.html', Hyde::pageLink('../foo/bar.html'));
}

public function test_helper_respects_pretty_relative_urls()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('../foo/bar', Hyde::pageLink('../foo/bar.html'));
}

public function test_non_html_links_are_not_modified()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('/foo/bar.jpg', Hyde::pageLink('/foo/bar.jpg'));
}

public function test_helper_respects_absolute_urls_with_pretty_urls_enabled()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('/foo/bar.jpg', Hyde::pageLink('/foo/bar.jpg'));
}

public function test_helper_rewrites_index_when_using_pretty_urls()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('/', Hyde::pageLink('index.html'));
}

public function test_helper_does_not_rewrite_index_when_not_using_pretty_urls()
{
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);
$this->assertEquals('index.html', Hyde::pageLink('index.html'));
}

public function test_helper_rewrites_documentation_page_index_when_using_pretty_urls()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('docs/', Hyde::pageLink('docs/index.html'));
}

public function test_helper_does_not_rewrite_documentation_page_index_when_not_using_pretty_urls()
{
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);
$this->assertEquals('docs/index.html', Hyde::pageLink('docs/index.html'));
}
}
12 changes: 6 additions & 6 deletions tests/Unit/FileHelperRelativeLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,43 @@ public function test_helper_handles_different_file_extensions()
// Test helper returns pretty URL if enabled and destination is a HTML file
public function test_helper_returns_pretty_url_if_enabled_and_destination_is_a_html_file()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('../foo', Hyde::relativeLink('foo.html', 'foo/bar.html'));
}

// Test helper method does not require current path to be HTML to use pretty URLs
public function test_helper_method_does_not_require_current_path_to_be_html_to_use_pretty_urls()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('../foo', Hyde::relativeLink('foo.html', 'foo/bar'));
}

// Test helper returns does not return pretty URL if when enabled but and destination is not a HTML file
public function test_helper_returns_does_not_return_pretty_url_if_when_enabled_but_and_destination_is_not_a_html_file()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('../foo.png', Hyde::relativeLink('foo.png', 'foo/bar.html'));
}

public function test_helper_rewrites_index_when_using_pretty_urls()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('/', Hyde::relativeLink('index.html', 'foo.html'));
$this->assertEquals('../', Hyde::relativeLink('index.html', 'foo/bar.html'));
$this->assertEquals('../../', Hyde::relativeLink('index.html', 'foo/bar/baz.html'));
}

public function test_helper_does_not_rewrite_index_when_not_using_pretty_urls()
{
config(['hyde.prettyUrls' => false]);
config(['hyde.pretty_urls' => false]);
$this->assertEquals('index.html', Hyde::relativeLink('index.html', 'foo.html'));
$this->assertEquals('../index.html', Hyde::relativeLink('index.html', 'foo/bar.html'));
$this->assertEquals('../../index.html', Hyde::relativeLink('index.html', 'foo/bar/baz.html'));
}

public function test_helper_rewrites_documentation_page_index_when_using_pretty_urls()
{
config(['hyde.prettyUrls' => true]);
config(['hyde.pretty_urls' => true]);
$this->assertEquals('docs/', Hyde::relativeLink('docs/index.html', 'foo.html'));
$this->assertEquals('docs/', Hyde::relativeLink('docs/index.html', 'docs.html'));
$this->assertEquals('../docs/', Hyde::relativeLink('docs/index.html', 'foo/bar.html'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MarkdownPostHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function test_get_canonical_link_returns_canonical_uri_path_for_post_slug

public function test_get_canonical_link_returns_pretty_url_when_enabled()
{
config(['hyde.site_url' => 'https://example.com', 'hyde.prettyUrls' => true]);
config(['hyde.site_url' => 'https://example.com', 'hyde.pretty_urls' => true]);
$post = new MarkdownPost([], '', '', 'foo-bar');
$this->assertEquals('https://example.com/posts/foo-bar', $post->getCanonicalLink());
}
Expand Down

0 comments on commit f578855

Please sign in to comment.