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