Skip to content

Commit 5811af9

Browse files
committed
Merge branch 'master' into 2.x-dev
2 parents ec50f83 + 6c8712a commit 5811af9

20 files changed

+145
-111
lines changed

packages/framework/tests/Feature/Commands/BuildRssFeedCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BuildRssFeedCommandTest extends TestCase
1616
{
1717
public function testRssFeedIsGeneratedWhenConditionsAreMet()
1818
{
19-
config(['hyde.url' => 'https://example.com']);
19+
$this->withSiteUrl();
2020
config(['hyde.rss.enabled' => true]);
2121
$this->file('_posts/foo.md');
2222

@@ -29,7 +29,7 @@ public function testRssFeedIsGeneratedWhenConditionsAreMet()
2929

3030
public function testRssFilenameCanBeChanged()
3131
{
32-
config(['hyde.url' => 'https://example.com']);
32+
$this->withSiteUrl();
3333
config(['hyde.rss.enabled' => true]);
3434
config(['hyde.rss.filename' => 'blog.xml']);
3535
$this->file('_posts/foo.md');

packages/framework/tests/Feature/Commands/BuildSitemapCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BuildSitemapCommandTest extends TestCase
1616
{
1717
public function testSitemapIsGeneratedWhenConditionsAreMet()
1818
{
19-
config(['hyde.url' => 'https://example.com']);
19+
$this->withSiteUrl();
2020
config(['hyde.generate_sitemap' => true]);
2121

2222
$this->assertFileDoesNotExist(Hyde::path('_site/sitemap.xml'));

packages/framework/tests/Feature/ConfigurableFeaturesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testCanGenerateSitemapHelperReturnsFalseIfHydeDoesNotHaveBaseUrl
6161

6262
public function testCanGenerateSitemapHelperReturnsFalseIfSitemapsAreDisabledInConfig()
6363
{
64-
config(['hyde.url' => 'foo']);
64+
$this->withSiteUrl();
6565
config(['hyde.generate_sitemap' => false]);
6666
$this->assertFalse(Features::hasSitemap());
6767
}

packages/framework/tests/Feature/Foundation/HyperlinksTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testAssetHelperReturnsQualifiedAbsoluteUriWhenRequestedAndSiteHa
6262

6363
public function testAssetHelperReturnsDefaultRelativePathWhenQualifiedAbsoluteUriIsRequestedButSiteHasNoBaseUrl()
6464
{
65-
config(['hyde.url' => null]);
65+
$this->withoutSiteUrl();
6666
$this->assertSame('media/test.jpg', $this->class->asset('test.jpg', true));
6767
}
6868

packages/framework/tests/Feature/GlobalMetadataBagTest.php

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515
*/
1616
class GlobalMetadataBagTest extends TestCase
1717
{
18-
public function testSiteMetadataAddsConfigDefinedMetadata()
18+
protected function setUp(): void
1919
{
20+
parent::setUp();
21+
2022
$this->withEmptyConfig();
23+
}
2124

25+
public function testSiteMetadataAddsConfigDefinedMetadata()
26+
{
2227
config(['hyde.meta' => [
2328
Meta::link('foo', 'bar'),
2429
Meta::name('foo', 'bar'),
@@ -43,53 +48,37 @@ public function testSiteMetadataAddsConfigDefinedMetadata()
4348

4449
public function testSiteMetadataAutomaticallyAddsSitemapWhenEnabled()
4550
{
46-
$this->withEmptyConfig();
47-
48-
config(['hyde.url' => 'foo']);
49-
config(['hyde.generate_sitemap' => true]);
51+
config(['hyde.url' => 'foo', 'hyde.generate_sitemap' => true]);
5052

5153
$this->assertSame('<link rel="sitemap" href="foo/sitemap.xml" type="application/xml" title="Sitemap">', GlobalMetadataBag::make()->render());
5254
}
5355

5456
public function testSiteMetadataSitemapUsesConfiguredSiteUrl()
5557
{
56-
$this->withEmptyConfig();
57-
58-
config(['hyde.url' => 'bar']);
59-
config(['hyde.generate_sitemap' => true]);
58+
config(['hyde.url' => 'bar', 'hyde.generate_sitemap' => true]);
6059

6160
$this->assertSame('<link rel="sitemap" href="bar/sitemap.xml" type="application/xml" title="Sitemap">', GlobalMetadataBag::make()->render());
6261
}
6362

6463
public function testSiteMetadataAutomaticallyAddsRssFeedWhenEnabled()
6564
{
66-
$this->withEmptyConfig();
67-
68-
config(['hyde.url' => 'foo']);
69-
config(['hyde.rss.enabled' => true]);
65+
config(['hyde.url' => 'foo', 'hyde.rss.enabled' => true]);
7066
$this->file('_posts/foo.md');
7167

7268
$this->assertSame('<link rel="alternate" href="foo/feed.xml" type="application/rss+xml" title="HydePHP RSS Feed">', GlobalMetadataBag::make()->render());
7369
}
7470

7571
public function testSiteMetadataRssFeedUsesConfiguredSiteUrl()
7672
{
77-
$this->withEmptyConfig();
78-
79-
config(['hyde.url' => 'bar']);
80-
config(['hyde.rss.enabled' => true]);
73+
config(['hyde.url' => 'bar', 'hyde.rss.enabled' => true]);
8174
$this->file('_posts/foo.md');
8275

8376
$this->assertSame('<link rel="alternate" href="bar/feed.xml" type="application/rss+xml" title="HydePHP RSS Feed">', GlobalMetadataBag::make()->render());
8477
}
8578

8679
public function testSiteMetadataRssFeedUsesConfiguredSiteName()
8780
{
88-
$this->withEmptyConfig();
89-
90-
config(['hyde.url' => 'foo']);
91-
config(['hyde.name' => 'Site']);
92-
config(['hyde.rss.enabled' => true]);
81+
config(['hyde.url' => 'foo', 'hyde.name' => 'Site', 'hyde.rss.enabled' => true]);
9382
$config = config('hyde');
9483
unset($config['rss']['description']);
9584
config(['hyde' => $config]);
@@ -100,11 +89,7 @@ public function testSiteMetadataRssFeedUsesConfiguredSiteName()
10089

10190
public function testSiteMetadataRssFeedUsesConfiguredRssFileName()
10291
{
103-
$this->withEmptyConfig();
104-
105-
config(['hyde.url' => 'foo']);
106-
config(['hyde.rss.filename' => 'posts.rss']);
107-
config(['hyde.rss.enabled' => true]);
92+
config(['hyde.url' => 'foo', 'hyde.rss.filename' => 'posts.rss', 'hyde.rss.enabled' => true]);
10893
$this->file('_posts/foo.md');
10994

11095
$this->assertStringContainsString(
@@ -115,15 +100,10 @@ public function testSiteMetadataRssFeedUsesConfiguredRssFileName()
115100

116101
public function testMetadataExistingInTheCurrentPageIsNotAdded()
117102
{
118-
$this->withEmptyConfig();
119-
120103
$duplicate = Meta::name('remove', 'me');
121104
$keep = Meta::name('keep', 'this');
122105

123-
config(['hyde.meta' => [
124-
$duplicate,
125-
$keep,
126-
]]);
106+
config(['hyde.meta' => [$duplicate, $keep]]);
127107

128108
$page = new MarkdownPage('foo');
129109
$page->metadata->add($duplicate);
@@ -136,8 +116,6 @@ public function testMetadataExistingInTheCurrentPageIsNotAdded()
136116

137117
public function testMetadataExistingInTheCurrentPageIsNotAddedRegardlessOfItsValue()
138118
{
139-
$this->withEmptyConfig();
140-
141119
config(['hyde.meta' => [Meta::name('foo', 'bar')]]);
142120

143121
$page = new MarkdownPage('foo');
@@ -151,9 +129,11 @@ public function testMetadataExistingInTheCurrentPageIsNotAddedRegardlessOfItsVal
151129

152130
protected function withEmptyConfig(): void
153131
{
154-
config(['hyde.url' => null]);
155-
config(['hyde.meta' => []]);
156-
config(['hyde.rss.enabled' => false]);
157-
config(['hyde.generate_sitemap' => false]);
132+
config([
133+
'hyde.url' => null,
134+
'hyde.meta' => [],
135+
'hyde.rss.enabled' => false,
136+
'hyde.generate_sitemap' => false,
137+
]);
158138
}
159139
}

packages/framework/tests/Feature/HydePageTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -822,15 +822,15 @@ public function testDocumentationPageCanBeHiddenFromNavigationUsingConfig()
822822

823823
public function testGetCanonicalUrlReturnsUrlForTopLevelPage()
824824
{
825-
config(['hyde.url' => 'https://example.com']);
825+
$this->withSiteUrl();
826826

827827
$page = new MarkdownPage('foo');
828828
$this->assertSame('https://example.com/foo.html', $page->getCanonicalUrl());
829829
}
830830

831831
public function testGetCanonicalUrlReturnsPrettyUrlForTopLevelPage()
832832
{
833-
config(['hyde.url' => 'https://example.com']);
833+
$this->withSiteUrl();
834834
config(['hyde.pretty_urls' => true]);
835835

836836
$page = new MarkdownPage('foo');
@@ -840,7 +840,7 @@ public function testGetCanonicalUrlReturnsPrettyUrlForTopLevelPage()
840840

841841
public function testGetCanonicalUrlReturnsUrlForNestedPage()
842842
{
843-
config(['hyde.url' => 'https://example.com']);
843+
$this->withSiteUrl();
844844

845845
$page = new MarkdownPage('foo/bar');
846846

@@ -849,7 +849,7 @@ public function testGetCanonicalUrlReturnsUrlForNestedPage()
849849

850850
public function testGetCanonicalUrlReturnsUrlForDeeplyNestedPage()
851851
{
852-
config(['hyde.url' => 'https://example.com']);
852+
$this->withSiteUrl();
853853

854854
$page = new MarkdownPage('foo/bar/baz');
855855

@@ -858,7 +858,7 @@ public function testGetCanonicalUrlReturnsUrlForDeeplyNestedPage()
858858

859859
public function testCanonicalUrlIsNotSetWhenIdentifierIsNull()
860860
{
861-
config(['hyde.url' => 'https://example.com']);
861+
$this->withSiteUrl();
862862

863863
$page = new MarkdownPage();
864864

@@ -869,7 +869,7 @@ public function testCanonicalUrlIsNotSetWhenIdentifierIsNull()
869869

870870
public function testCanonicalUrlIsNotSetWhenSiteUrlIsNull()
871871
{
872-
config(['hyde.url' => null]);
872+
$this->withoutSiteUrl();
873873

874874
$page = new MarkdownPage('foo');
875875

@@ -880,7 +880,7 @@ public function testCanonicalUrlIsNotSetWhenSiteUrlIsNull()
880880

881881
public function testCustomCanonicalLinkCanBeSetInFrontMatter()
882882
{
883-
config(['hyde.url' => 'https://example.com']);
883+
$this->withSiteUrl();
884884

885885
$page = MarkdownPage::make(matter: ['canonicalUrl' => 'foo/bar']);
886886

packages/framework/tests/Feature/MetadataHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected function setUp(): void
1818
parent::setUp();
1919

2020
config(['hyde.meta' => []]);
21-
config(['hyde.url' => null]);
21+
$this->withoutSiteUrl();
2222
}
2323

2424
public function testNameMethodReturnsAValidHtmlMetaString()

packages/framework/tests/Feature/MetadataTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function setUp(): void
2929
{
3030
parent::setUp();
3131

32-
config(['hyde.url' => null]);
32+
$this->withoutSiteUrl();
3333
config(['hyde.meta' => []]);
3434
config(['hyde.rss.enabled' => false]);
3535
config(['hyde.generate_sitemap' => false]);
@@ -205,7 +205,7 @@ public function testDynamicMetadataOverridesConfigDefinedMetadata()
205205

206206
public function testDoesNotAddCanonicalLinkWhenBaseUrlIsNotSet()
207207
{
208-
config(['hyde.url' => null]);
208+
$this->withoutSiteUrl();
209209

210210
$page = MarkdownPage::make('bar');
211211

packages/framework/tests/Feature/Services/BuildTaskServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BuildTaskServiceTest extends TestCase
2929
*/
3030
public function testBuildCommandCanRunBuildTasks()
3131
{
32-
config(['hyde.url' => 'https://example.com']);
32+
$this->withSiteUrl();
3333

3434
$this->artisan('build')
3535
->expectsOutputToContain('Removing all files from build directory')

packages/framework/tests/Feature/Services/RssFeedServiceTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testXmlElementHasChannelElement()
4141
public function testXmlChannelElementHasRequiredElements()
4242
{
4343
config(['hyde.name' => 'Test Blog']);
44-
config(['hyde.url' => 'https://example.com']);
44+
$this->withSiteUrl();
4545
config(['hyde.rss.description' => 'Test Blog RSS Feed']);
4646

4747
$service = new RssFeedGenerator();
@@ -57,7 +57,7 @@ public function testXmlChannelElementHasRequiredElements()
5757

5858
public function testXmlChannelElementHasAdditionalElements()
5959
{
60-
config(['hyde.url' => 'https://example.com']);
60+
$this->withSiteUrl();
6161

6262
$service = new RssFeedGenerator();
6363

@@ -102,7 +102,7 @@ public function testMarkdownBlogPostsAreAddedToRssFeedThroughAutodiscovery()
102102
MD
103103
);
104104

105-
config(['hyde.url' => 'https://example.com']);
105+
$this->withSiteUrl();
106106

107107
file_put_contents(Hyde::path('_media/rss-test.jpg'), 'statData'); // 8 bytes to test stat gets file length
108108

@@ -150,7 +150,7 @@ public function testCanGenerateFeedHelperReturnsTrueIfHydeHasBaseUrl()
150150

151151
public function testCanGenerateFeedHelperReturnsFalseIfHydeDoesNotHaveBaseUrl()
152152
{
153-
config(['hyde.url' => '']);
153+
$this->withoutSiteUrl();
154154
$this->file('_posts/foo.md');
155155
$this->assertFalse(Features::hasRss());
156156
}

0 commit comments

Comments
 (0)