TYPO3 CMS  TYPO3_8-7
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 
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)
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 }