‪TYPO3CMS  ‪main
MediaViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪MediaViewHelperTest extends FunctionalTestCase
27 {
28  protected array ‪$additionalFoldersToCreate = [
29  '/fileadmin/user_upload',
30  ];
31 
33  'typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/Link/FileViewHelper/Folders/fileadmin/user_upload/typo3_image2.jpg' => 'fileadmin/user_upload/typo3_image2.jpg',
34  'typo3/sysext/fluid/Tests/Functional/Fixtures/ViewHelpers/Link/FileViewHelper/Folders/fileadmin/user_upload/example.mp4' => 'fileadmin/user_upload/example.mp4',
35  ];
36 
37  public static function ‪renderReturnsExpectedMarkupDataProvider(): array
38  {
39  return [
40  'fallback to image' => [
41  '1:/user_upload/typo3_image2.jpg',
42  ['title' => 'null'],
43  '<img src="fileadmin/user_upload/typo3_image2.jpg" width="400" height="300" alt="" />',
44  ],
45  'show media image' => [
46  '1:/user_upload/example.mp4',
47  ['title' => 'null', 'additionalConfig' => ['controlsList' => 'nodownload']],
48  '<video controls controlsList="nodownload"><source src="fileadmin/user_upload/example.mp4" type="video/mp4"></video>',
49  ],
50  ];
51  }
52 
53  #[DataProvider('renderReturnsExpectedMarkupDataProvider')]
54  #[Test]
55  public function ‪renderReturnsExpectedMarkup(string $file, array $arguments, string $expected): void
56  {
57  $file = $this->get(ResourceFactory::class)->getFileObjectFromCombinedIdentifier($file);
58  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
59  $this->setUpBackendUser(1);
60  $subject = new ‪MediaViewHelper();
61  $subject->setArguments(['file' => $file] + $arguments);
62  $result = $subject->render();
63  self::assertEquals($expected, $result);
64  }
65 }
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\MediaViewHelperTest
Definition: MediaViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\MediaViewHelperTest\renderReturnsExpectedMarkup
‪renderReturnsExpectedMarkup(string $file, array $arguments, string $expected)
Definition: MediaViewHelperTest.php:55
‪TYPO3\CMS\Fluid\ViewHelpers\MediaViewHelper
Definition: MediaViewHelper.php:72
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:42
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\MediaViewHelperTest\$pathsToProvideInTestInstance
‪array $pathsToProvideInTestInstance
Definition: MediaViewHelperTest.php:32
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\MediaViewHelperTest\$additionalFoldersToCreate
‪array $additionalFoldersToCreate
Definition: MediaViewHelperTest.php:28
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\MediaViewHelperTest\renderReturnsExpectedMarkupDataProvider
‪static renderReturnsExpectedMarkupDataProvider()
Definition: MediaViewHelperTest.php:37