Skip to content

Commit

Permalink
more deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Jan 25, 2023
1 parent f000607 commit c7e2199
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 42 deletions.
3 changes: 3 additions & 0 deletions src/Url/UrlUtil.php
Expand Up @@ -291,6 +291,9 @@ public function addURIScheme(string $url = '', string $protocol = 'http'): strin
* @param array $options pass additional options
*
* @return string
*
* @deprecated
* @codeCoverageIgnore
*/
public function prepareUrl($url = null, array $options = [])
{
Expand Down
42 changes: 0 additions & 42 deletions tests/Url/UrlUtilTest.php
Expand Up @@ -101,48 +101,6 @@ public function testGetJumpToPageObject()
$this->assertNull($jumpToPage);
}

public function testPrepareUrl()
{
$pageModel = $this->createMock(PageModel::class);
$pageModel->method('row')->willReturn(['id' => 1, 'rootId' => 12, 'alias' => 'alias']);
$pageModel->method('getAbsoluteUrl')->willReturn('www.localhost.de/page');
$pageModel->method('getFrontendUrl')->willReturn('/page');

$pageModelAdapter = $this->mockAdapter(['findByPk', 'getAbsoluteUrl', 'getFrontendUrl']);
$pageModelAdapter->method('findByPk')->willReturn(null);

$urlUtil = $this->createTestInstance([
'framework' => $this->mockContaoFramework([PageModel::class => $pageModelAdapter]),
]);

try {
$url = $urlUtil->prepareUrl(1);
} catch (\Exception $exception) {
$this->assertSame('Given page id does not exist.', $exception->getMessage());
}

$pageModelAdapter = $this->mockAdapter(['findByPk']);
$pageModelAdapter->method('findByPk')->willReturn($pageModel);
$urlUtil = $this->createTestInstance([
'framework' => $this->mockContaoFramework([
PageModel::class => $pageModelAdapter,
]),
]);

$url = $urlUtil->prepareUrl(1, ['absoluteUrl' => true]);
$this->assertSame('www.localhost.de/page?answer=12', $url);
$url = $urlUtil->prepareUrl(1);
$this->assertSame('/page?answer=12', $url);

Environment::set('uri', 'https://example.org/page/1');
Environment::set('requestUri', '/page/1');

$url = $urlUtil->prepareUrl(null, ['absoluteUrl' => true]);
$this->assertSame('https://example.org/page/1', $url);
$url = $urlUtil->prepareUrl(null);
$this->assertSame('/page/1', $url);
}

/**
* Test redirect() when headers_sent() is true.
*/
Expand Down

0 comments on commit c7e2199

Please sign in to comment.