Update copyright
[friendica.git/.git] / tests / src / Content / Text / BBCode / VideoTest.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2021, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Test\src\Content\Text\BBCode;
23
24 use Friendica\Content\Text\BBCode\Video;
25 use Friendica\Test\MockedTest;
26
27 class VideoTest extends MockedTest
28 {
29         public function dataVideo()
30         {
31                 return [
32                         'youtube' => [
33                                 'input' => '[video]https://youtube.link/4523[/video]',
34                                 'assert' => '[youtube]https://youtube.link/4523[/youtube]',
35                         ],
36                         'youtu.be' => [
37                                 'input' => '[video]https://youtu.be.link/4523[/video]',
38                                 'assert' => '[youtube]https://youtu.be.link/4523[/youtube]',
39                         ],
40                         'vimeo' => [
41                                 'input' => '[video]https://vimeo.link/2343[/video]',
42                                 'assert' => '[vimeo]https://vimeo.link/2343[/vimeo]',
43                         ],
44                         'mixed' => [
45                                 'input' => '[video]https://vimeo.link/2343[/video] With other [b]string[/b] [video]https://youtu.be/blaa[/video]',
46                                 'assert' => '[vimeo]https://vimeo.link/2343[/vimeo] With other [b]string[/b] [youtube]https://youtu.be/blaa[/youtube]',
47                         ]
48                 ];
49         }
50
51         /**
52          * Test if the BBCode is successfully transformed for video links
53          *
54          * @dataProvider dataVideo
55          */
56         public function testTransform(string $input, string $assert)
57         {
58                 $bbCodeVideo = new Video();
59
60                 self::assertEquals($assert, $bbCodeVideo->transform($input));
61         }
62 }