Skip to content

Commit

Permalink
Merge pull request #1727 from hydephp/code-cleanup
Browse files Browse the repository at this point in the history
Code cleanup and refactors
  • Loading branch information
caendesilva authored Jun 12, 2024
2 parents 40dc339 + 4e1b97e commit d5fbc71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/framework/src/Foundation/Kernel/Hyperlinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions packages/framework/tests/Feature/Foundation/HyperlinksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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()
Expand Down

0 comments on commit d5fbc71

Please sign in to comment.