‪TYPO3CMS  9.5
VimeoHelperTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪VimeoHelperTest extends UnitTestCase
28 {
32  protected ‪$subject;
33 
37  protected ‪$extension;
38 
42  protected function ‪setUp()
43  {
44  parent::setUp();
45 
46  $this->extension = 'video/vimeo';
47  $this->subject = $this->getAccessibleMock(VimeoHelper::class, ['transformMediaIdToFile'], [$this->extension]);
48  }
49 
60  public function ‪transformUrlToFileReturnsExpectedResult($url, $videoId, $expectedResult): void
61  {
63  $mockedFolder = $this->createMock(Folder::class);
64 
65  $this->subject->expects($this->any())->method('transformMediaIdToFile')
66  ->with($videoId, $mockedFolder, $this->extension)
67  ->will($this->returnValue($expectedResult));
68 
69  $result = $this->subject->transformUrlToFile($url . $videoId, $mockedFolder);
70 
71  $this->assertSame($expectedResult, $result);
72  }
73 
74  public function ‪transformUrlDataProvider()
75  {
76  $fileResourceMock = $this->createMock(File::class);
77 
78  return [
79  [null, null, null],
80  ['https://typo3.org/', null, null],
81  ['https://vimeo.com/', '7215347324', $fileResourceMock],
82  ['https://vimeo.com/', '7215347324/hasf8a65sdsa7d', $fileResourceMock],
83  ['https://player.vimeo.com/', '7215347324', $fileResourceMock],
84  ['https://player.vimeo.com/', '7215347324/hasf8a65sdsa7d', $fileResourceMock]
85  ];
86  }
87 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\setUp
‪setUp()
Definition: VimeoHelperTest.php:40
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\transformUrlDataProvider
‪transformUrlDataProvider()
Definition: VimeoHelperTest.php:72
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\$extension
‪string $extension
Definition: VimeoHelperTest.php:35
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest
Definition: VimeoHelperTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\transformUrlToFileReturnsExpectedResult
‪transformUrlToFileReturnsExpectedResult($url, $videoId, $expectedResult)
Definition: VimeoHelperTest.php:58
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:34
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:23
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\VimeoHelper
Definition: VimeoHelper.php:25
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers\VimeoHelperTest\$subject
‪VimeoHelper PHPUnit_Framework_MockObject_MockObject $subject
Definition: VimeoHelperTest.php:31
‪TYPO3\CMS\Core\Tests\Unit\Resource\OnlineMedia\Helpers
Definition: VimeoHelperTest.php:4