Skip to content

Commit bb08aaa

Browse files
committed
[TASK] provide test for loading attribute
Relates to: #98
1 parent 18f5e37 commit bb08aaa

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html
2+
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
3+
xmlns:i="http://typo3.org/ns/B13/Picture/ViewHelpers"
4+
data-namespace-typo3-fluid="true"
5+
>
6+
<f:spaceless>
7+
<i:image src="EXT:picture/Resources/Public/Test/Picture.png" width="400" alt="Testimage 400px width" loading="eager" />
8+
</f:spaceless>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"pages"
2+
,"uid","pid","title","slug"
3+
,1,0,"root","/"
4+
"sys_template"
5+
,"uid","pid","root","constants","config"
6+
,1,1,1,styles.content.image.lazyLoading=lazy,"@import 'EXT:picture/Configuration/TypoScript/test.typoscript'
7+
page = PAGE
8+
page.config.disableAllHeaderCode = 1
9+
page.10 = FLUIDTEMPLATE
10+
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
11+
page.10.templateName = ImageWithLoadingTag.html
12+
config.absRefPrefix = /
13+
"

Tests/Functional/Frontend/TagRenderingTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
use TYPO3\CMS\Core\Utility\GeneralUtility;
1717
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
1818
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
19+
use function RectorPrefix202605\Symfony\Component\String\s;
1920

2021
class TagRenderingTest extends FunctionalTestCase
2122
{
2223
protected array $pathsToLinkInTestInstance = ['typo3conf/ext/picture/Build/sites' => 'typo3conf/sites'];
2324
protected array $testExtensionsToLoad = ['typo3conf/ext/picture'];
2425
// use this to run tests local if you have /usr/local/bin/gm
25-
//protected array $configurationToUseInTestInstance = ['GFX' => ['processor_path' => '/usr/local/bin/']];
26+
// protected array $configurationToUseInTestInstance = ['GFX' => ['processor_path' => '/usr/local/bin/']];
2627

2728
#[Test]
2829
public function simpleImage(): void
@@ -282,4 +283,14 @@ protected function anonymouseProcessdImage(string $content): string
282283
$content = preg_replace('/Picture_alt_[0-9a-z]+\./', 'Picture_alt_xxx.', $content);
283284
return $content;
284285
}
286+
287+
#[Test]
288+
public function imageWithLoadingAttributeKeepsLoadingAttribute(): void
289+
{
290+
$this->importCSVDataSet(__DIR__ . '/Fixtures/image_with_loading_tag.csv');
291+
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/'));
292+
$body = (string)$response->getBody();
293+
$expected = 'loading="eager"';
294+
self::assertStringContainsString($this->anonymouseProcessdImage($expected), $this->anonymouseProcessdImage($body));
295+
}
285296
}

0 commit comments

Comments
 (0)