Skip to content

Commit

Permalink
Merge branch '3.x' into bugfix/fileutility-feat-prop
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszuznanski committed Jun 20, 2023
2 parents 051dabb + 7079586 commit 9ea011f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Classes/Utility/UrlUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;

use function array_merge;
use function count;
use function rtrim;
use function strpos;

Expand Down Expand Up @@ -186,7 +185,9 @@ private function resolveWithVariants(
array $variants = [],
string $returnField = 'frontendBase'
): string {
if (count($variants) === 0) {
$frontendUrl = rtrim($frontendUrl, '/');

if ($variants === []) {
return $frontendUrl;
}

Expand Down
3 changes: 3 additions & 0 deletions Classes/ViewHelpers/Format/Json/DecodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function render()
$json = $this->arguments['json'];
if ($json === null) {
$json = $this->renderChildren();
if ($json !== null) {
$json = trim($json);
}
if (empty($json)) {
return null;
}
Expand Down
12 changes: 6 additions & 6 deletions Tests/Unit/Utility/UrlUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public function testFrontendUrlsWithBaseProductionAndLocalOverride(): void
{
$site = $this->prophesize(Site::class);
$site->getConfiguration()->shouldBeCalled(3)->willReturn([
'base' => 'https://api.typo3.org',
'frontendBase' => 'https://www.typo3.org',
'frontendApiProxy' => 'https://www.typo3.org/headless',
'frontendFileApi' => 'https://www.typo3.org/headless/fileadmin',
'SpecialSitemapKey' => 'https://www.typo3.org/custom-sitemap',
'base' => 'https://api.typo3.org/',
'frontendBase' => 'https://www.typo3.org/',
'frontendApiProxy' => 'https://www.typo3.org/headless/',
'frontendFileApi' => 'https://www.typo3.org/headless/fileadmin/',
'SpecialSitemapKey' => 'https://www.typo3.org/custom-sitemap/',
'languages' => [],
'baseVariants' => [
[
Expand Down Expand Up @@ -672,7 +672,7 @@ public function testEdgeCases()

$urlUtility = new UrlUtility(null, $resolver->reveal(), $siteFinder, $request->reveal());
self::assertSame('https://frontend-domain-from-lang.tld', $urlUtility->getFrontendUrl());
self::assertSame('https://frontend-domain-from-lang.tld/headless/', $urlUtility->getProxyUrl());
self::assertSame('https://frontend-domain-from-lang.tld/headless', $urlUtility->getProxyUrl());
self::assertSame('https://frontend-domain-from-lang.tld/headless/fileadmin', $urlUtility->getStorageProxyUrl());

// configuration on language lvl with variants
Expand Down
28 changes: 28 additions & 0 deletions Tests/Unit/ViewHelpers/Format/Json/DecodeViewHelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the "headless" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.md file that was distributed with this source code.
*/

declare(strict_types=1);

namespace FriendsOfTYPO3\Headless\Tests\Unit\ViewHelpers\Format\Json;

use FriendsOfTYPO3\Headless\ViewHelpers\Format\Json\DecodeViewHelper;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class DecodeViewHelperTest extends UnitTestCase
{
public function testRender(): void
{
$GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = true;
$decodeViewHelper = new DecodeViewHelper();
$decodeViewHelper->setArguments(['json' => null]);
$decodeViewHelper->setRenderChildrenClosure(function () { return "\n \n"; });
$result = $decodeViewHelper->render();
self::assertNull($result);
}
}

0 comments on commit 9ea011f

Please sign in to comment.