Skip to content

Commit

Permalink
[TASK] Adapt expectations for backend link viewhelpers
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed May 16, 2023
1 parent c49f988 commit f5a9125
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 29 deletions.
21 changes: 14 additions & 7 deletions Tests/Functional/ViewHelpers/Link/Be/AuthorViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
Expand Down Expand Up @@ -55,34 +57,39 @@ public function render(string $template, string $expected): void

public static function renderDataProvider(): array
{
$expectedReturnUrl = '/';
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) {
$expectedReturnUrl = '%2F';
}

return [
'simple' => [
'<blogvh:link.be.author author="{author}" />',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=%2F">Info</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Info</a>',
],
'target' => [
'<blogvh:link.be.author author="{author}" target="_blank" />',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=%2F">Info</a>',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Info</a>',
],
'itemprop' => [
'<blogvh:link.be.author author="{author}" itemprop="name" />',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=%2F">Info</a>',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Info</a>',
],
'rel' => [
'<blogvh:link.be.author author="{author}" rel="noreferrer" />',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=%2F">Info</a>',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Info</a>',
],
'returnUri' => [
'<blogvh:link.be.author author="{author}" returnUri="1" />',
'/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=%2F',
'/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl,
],
'content' => [
'<blogvh:link.be.author author="{author}">Hello</blogvh:link.be.author>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=%2F">Hello</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Hello</a>',
],
'class' => [
'<blogvh:link.be.author author="{author}" class="class" />',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=%2F">Info</a>',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_author%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Info</a>',
],
];
}
Expand Down
21 changes: 14 additions & 7 deletions Tests/Functional/ViewHelpers/Link/Be/CategoryViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
Expand Down Expand Up @@ -54,34 +56,39 @@ public function render(string $template, string $expected): void

public static function renderDataProvider(): array
{
$expectedReturnUrl = '/';
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) {
$expectedReturnUrl = '%2F';
}

return [
'simple' => [
'<blogvh:link.be.category category="{category}" />',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'target' => [
'<blogvh:link.be.category category="{category}" target="_blank" />',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'itemprop' => [
'<blogvh:link.be.category category="{category}" itemprop="name" />',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'rel' => [
'<blogvh:link.be.category category="{category}" rel="noreferrer" />',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'returnUri' => [
'<blogvh:link.be.category category="{category}" returnUri="1" />',
'/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=%2F',
'/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '',
],
'content' => [
'<blogvh:link.be.category category="{category}">Hello</blogvh:link.be.category>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=%2F">Hello</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Hello</a>',
],
'class' => [
'<blogvh:link.be.category category="{category}" class="class" />',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Bsys_category%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
];
}
Expand Down
21 changes: 14 additions & 7 deletions Tests/Functional/ViewHelpers/Link/Be/CommentViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
Expand Down Expand Up @@ -54,34 +56,39 @@ public function render(string $template, string $expected): void

public static function renderDataProvider(): array
{
$expectedReturnUrl = '/';
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) {
$expectedReturnUrl = '%2F';
}

return [
'simple' => [
'<blogvh:link.be.comment comment="{comment}" />',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=%2F">Lipsum</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Lipsum</a>',
],
'target' => [
'<blogvh:link.be.comment comment="{comment}" target="_blank" />',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=%2F">Lipsum</a>',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Lipsum</a>',
],
'itemprop' => [
'<blogvh:link.be.comment comment="{comment}" itemprop="name" />',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=%2F">Lipsum</a>',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Lipsum</a>',
],
'rel' => [
'<blogvh:link.be.comment comment="{comment}" rel="noreferrer" />',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=%2F">Lipsum</a>',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Lipsum</a>',
],
'returnUri' => [
'<blogvh:link.be.comment comment="{comment}" returnUri="1" />',
'/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=%2F',
'/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '',
],
'content' => [
'<blogvh:link.be.comment comment="{comment}">Hello</blogvh:link.be.comment>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=%2F">Hello</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Hello</a>',
],
'class' => [
'<blogvh:link.be.comment comment="{comment}" class="class" />',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=%2F">Lipsum</a>',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_comment%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Lipsum</a>',
],
];
}
Expand Down
9 changes: 8 additions & 1 deletion Tests/Functional/ViewHelpers/Link/Be/PostViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
Expand Down Expand Up @@ -54,14 +56,19 @@ public function render(string $template, string $expected): void

public static function renderDataProvider(): array
{
$expectedReturnUrl = '/';
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) {
$expectedReturnUrl = '%2F';
}

return [
'simple' => [
'<blogvh:link.be.post post="{post}" />',
'<a href="/typo3/module/web/layout?token=dummyToken&amp;id=123">Demo</a>',
],
'action edit' => [
'<blogvh:link.be.post post="{post}" action="edit" />',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Bpages%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Bpages%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'target' => [
'<blogvh:link.be.post post="{post}" target="_blank" />',
Expand Down
21 changes: 14 additions & 7 deletions Tests/Functional/ViewHelpers/Link/Be/TagViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
Expand Down Expand Up @@ -54,34 +56,39 @@ public function render(string $template, string $expected): void

public static function renderDataProvider(): array
{
$expectedReturnUrl = '/';
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) {
$expectedReturnUrl = '%2F';
}

return [
'simple' => [
'<blogvh:link.be.tag tag="{tag}" />',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'target' => [
'<blogvh:link.be.tag tag="{tag}" target="_blank" />',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a target="_blank" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'itemprop' => [
'<blogvh:link.be.tag tag="{tag}" itemprop="name" />',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a itemprop="name" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'rel' => [
'<blogvh:link.be.tag tag="{tag}" rel="noreferrer" />',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a rel="noreferrer" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
'returnUri' => [
'<blogvh:link.be.tag tag="{tag}" returnUri="1" />',
'/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=%2F',
'/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '',
],
'content' => [
'<blogvh:link.be.tag tag="{tag}">Hello</blogvh:link.be.tag>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=%2F">Hello</a>',
'<a href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Hello</a>',
],
'class' => [
'<blogvh:link.be.tag tag="{tag}" class="class" />',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=%2F">Demo</a>',
'<a class="class" href="/typo3/record/edit?token=dummyToken&amp;edit%5Btx_blog_domain_model_tag%5D%5B123%5D=edit&amp;returnUrl=' . $expectedReturnUrl . '">Demo</a>',
],
];
}
Expand Down

0 comments on commit f5a9125

Please sign in to comment.