‪TYPO3CMS  10.4
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 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪VimeoHelperTest extends UnitTestCase
29 {
33  protected ‪$subject;
34 
38  protected ‪$extension;
39 
43  protected function ‪setUp(): void
44  {
45  parent::setUp();
46 
47  $this->extension = 'video/vimeo';
48  $this->subject = $this->getAccessibleMock(VimeoHelper::class, ['transformMediaIdToFile'], [$this->extension]);
49  }
50 
61  public function ‪transformUrlToFileReturnsExpectedResult($url, $videoId, $expectedResult): void
62  {
64  $mockedFolder = $this->createMock(Folder::class);
65 
66  $this->subject->expects(self::any())->method('transformMediaIdToFile')
67  ->with($videoId, $mockedFolder, $this->extension)
68  ->willReturn($expectedResult);
69 
70  $result = $this->subject->transformUrlToFile($url . $videoId, $mockedFolder);
71 
72  self::assertSame($expectedResult, $result);
73  }
74 
75  public function ‪transformUrlDataProvider()
76  {
77  $fileResourceMock = $this->createMock(File::class);
78 
79  return [
80  [null, null, null],
81  ['https://typo3.org/', null, null],
82  ['https://vimeo.com/', '7215347324', $fileResourceMock],
83  ['https://vimeo.com/', '7215347324/hasf8a65sdsa7d', $fileResourceMock],
84  ['https://vimeo.com/video/', '7215347324', $fileResourceMock],
85  ['https://vimeo.com/video/', '7215347324/hasf8a65sdsa7d', $fileResourceMock],
86  ['https://player.vimeo.com/', '7215347324', $fileResourceMock],
87  ['https://player.vimeo.com/', '7215347324/hasf8a65sdsa7d', $fileResourceMock],
88  ['https://vimeo.com/event/', '7215347324', $fileResourceMock],
89  ];
90  }
91 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\setUp
‪setUp()
Definition: VimeoHelperTest.php:41
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\transformUrlDataProvider
‪transformUrlDataProvider()
Definition: VimeoHelperTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\$extension
‪string $extension
Definition: VimeoHelperTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest
Definition: VimeoHelperTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\transformUrlToFileReturnsExpectedResult
‪transformUrlToFileReturnsExpectedResult($url, $videoId, $expectedResult)
Definition: VimeoHelperTest.php:59
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\$subject
‪VimeoHelper PHPUnit Framework MockObject MockObject $subject
Definition: VimeoHelperTest.php:32
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\VimeoHelper
Definition: VimeoHelper.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers
Definition: VimeoHelperTest.php:18