1<?php 2 3namespace dokuwiki\plugin\vshare\test; 4 5use DokuWikiTest; 6 7/** 8 * FIXME tests for the vshare plugin 9 * 10 * @group plugin_vshare 11 * @group plugins 12 */ 13class SitesTest extends DokuWikiTest 14{ 15 16 public function provideSites() 17 { 18 $sites = parse_ini_file(__DIR__ . '/../sites.ini', true, INI_SCANNER_RAW); 19 foreach ($sites as $site => $data) { 20 yield [$site, $data]; 21 } 22 } 23 24 /** 25 * @dataProvider provideSites 26 * @param string $site 27 * @param string[] $data 28 */ 29 public function testPlaceholder($site, $data) 30 { 31 $this->assertArrayHasKey('url', $data, $site); 32 $this->assertStringContainsString('@VIDEO@', $data['url'], $site); 33 } 34 35 /** 36 * @dataProvider provideSites 37 * @param string $site 38 * @param string[] $data 39 */ 40 public function testRegEx($site, $data) 41 { 42 if (empty($data['web']) || empty($data['vid'])) { 43 $this->markTestSkipped("$site has no sample data configured"); 44 } 45 if (empty($data['rex'])) { 46 $this->markTestSkipped("$site has no regular expression"); 47 } 48 49 // URL to use 50 $url = empty($data['emb']) ? $data['web'] : $data['emb']; 51 52 $this->assertSame( 53 1, 54 preg_match('!' . $data['rex'] . '!i', $url, $match), 55 "$site regex did not match web/emb url" 56 ); 57 $this->assertEquals($data['vid'], $match[1], "$site regex did not return vid"); 58 } 59} 60