‪TYPO3CMS  ‪main
VimeoHelperTest.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;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
27 final class ‪VimeoHelperTest extends UnitTestCase
28 {
29  public static function ‪transformUrlDataProvider(): array
30  {
31  return [
32  [null, null, false],
33  ['https://typo3.org/', null, false],
34  ['https://vimeo.com/', '7215347324', true],
35  ['https://vimeo.com/', '7215347324/hasf8a65sdsa7d', true],
36  ['https://vimeo.com/video/', '7215347324', true],
37  ['https://vimeo.com/video/', '7215347324/hasf8a65sdsa7d', true],
38  ['https://player.vimeo.com/', '7215347324', true],
39  ['https://player.vimeo.com/', '7215347324/hasf8a65sdsa7d', true],
40  ['https://vimeo.com/event/', '7215347324', true],
41  ];
42  }
43 
44  #[DataProvider('transformUrlDataProvider')]
45  #[Test]
46  public function ‪transformUrlToFileReturnsExpectedResult(?string ‪$url, ?string $videoId, bool $expectsMock): void
47  {
48  $mockedFolder = $this->createMock(Folder::class);
49  $expectedResult = null;
50  if ($expectsMock) {
51  $expectedResult = $this->createMock(File::class);
52  }
53 
54  $subject = $this->getAccessibleMock(VimeoHelper::class, ['transformMediaIdToFile'], ['video/vimeo']);
55  $subject->method('transformMediaIdToFile')
56  ->with($videoId, $mockedFolder, 'video/vimeo')
57  ->willReturn($expectedResult);
58 
59  $result = $subject->transformUrlToFile(‪$url . $videoId, $mockedFolder);
60 
61  self::assertSame($expectedResult, $result);
62  }
63 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest
Definition: VimeoHelperTest.php:28
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:38
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\transformUrlDataProvider
‪static transformUrlDataProvider()
Definition: VimeoHelperTest.php:29
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\VimeoHelper
Definition: VimeoHelper.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers
Definition: VimeoHelperTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\transformUrlToFileReturnsExpectedResult
‪transformUrlToFileReturnsExpectedResult(?string $url, ?string $videoId, bool $expectsMock)
Definition: VimeoHelperTest.php:46