From d43d6473789d64a5d14a2ac850a28104c3627ea9 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 12 Jun 2024 16:34:10 +0000 Subject: [PATCH] Merge pull request #1727 from hydephp/code-cleanup Code cleanup and refactors https://github.com/hydephp/develop/commit/d5fbc714c90c1db8730296f23d901dd2f18eb8d4 --- src/Foundation/Kernel/Hyperlinks.php | 6 +++--- tests/Feature/Foundation/HyperlinksTest.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Foundation/Kernel/Hyperlinks.php b/src/Foundation/Kernel/Hyperlinks.php index 97558414..98b2acdc 100644 --- a/src/Foundation/Kernel/Hyperlinks.php +++ b/src/Foundation/Kernel/Hyperlinks.php @@ -135,16 +135,16 @@ public function hasSiteUrl(): bool /** * Return a qualified URL to the supplied path if a base URL is set. * - * @param string $path optional relative path suffix. Omit to return base url. + * @param string $path An optional relative path suffix. Omit to return the base URL. * - * @throws BaseUrlNotSetException If no site URL is set and no default is provided + * @throws BaseUrlNotSetException If no site URL is set and no path is provided. */ public function url(string $path = ''): string { $path = $this->formatLink(trim($path, '/')); if ($this->hasSiteUrl()) { - return rtrim(rtrim((string) Config::getNullableString('hyde.url'), '/')."/$path", '/'); + return rtrim(rtrim(Config::getString('hyde.url'), '/')."/$path", '/'); } throw new BaseUrlNotSetException(); diff --git a/tests/Feature/Foundation/HyperlinksTest.php b/tests/Feature/Foundation/HyperlinksTest.php index 584b8e33..10eb5db9 100644 --- a/tests/Feature/Foundation/HyperlinksTest.php +++ b/tests/Feature/Foundation/HyperlinksTest.php @@ -35,7 +35,7 @@ public function testAssetHelperGetsRelativeWebLinkToImageStoredInSiteMediaFolder ]; foreach ($tests as $input => $expected) { - $this->assertEquals($this->class->asset($input), $expected); + $this->assertSame($this->class->asset($input), $expected); } } @@ -50,30 +50,30 @@ public function testAssetHelperResolvesPathsForNestedPages() foreach ($tests as $input => $expected) { $this->mockCurrentPage('foo/bar'); - $this->assertEquals($this->class->asset($input), $expected); + $this->assertSame($this->class->asset($input), $expected); } } public function testAssetHelperReturnsQualifiedAbsoluteUriWhenRequestedAndSiteHasBaseUrl() { - $this->assertEquals('http://localhost/media/test.jpg', $this->class->asset('test.jpg', true)); + $this->assertSame('http://localhost/media/test.jpg', $this->class->asset('test.jpg', true)); } public function testAssetHelperReturnsDefaultRelativePathWhenQualifiedAbsoluteUriIsRequestedButSiteHasNoBaseUrl() { config(['hyde.url' => null]); - $this->assertEquals('media/test.jpg', $this->class->asset('test.jpg', true)); + $this->assertSame('media/test.jpg', $this->class->asset('test.jpg', true)); } public function testAssetHelperReturnsInputWhenQualifiedAbsoluteUriIsRequestedButImageIsAlreadyQualified() { - $this->assertEquals('http://localhost/media/test.jpg', $this->class->asset('http://localhost/media/test.jpg', true)); + $this->assertSame('http://localhost/media/test.jpg', $this->class->asset('http://localhost/media/test.jpg', true)); } public function testAssetHelperUsesConfiguredMediaDirectory() { Hyde::setMediaDirectory('_assets'); - $this->assertEquals('assets/test.jpg', $this->class->asset('test.jpg')); + $this->assertSame('assets/test.jpg', $this->class->asset('test.jpg')); } public function testMediaLinkHelper()