1*b82f24afSAndreas Gohr<?php 2*b82f24afSAndreas Gohr 3*b82f24afSAndreas Gohrnamespace dokuwiki\plugin\vshare\test; 4*b82f24afSAndreas Gohr 5*b82f24afSAndreas Gohruse DokuWikiTest; 6*b82f24afSAndreas Gohr 7*b82f24afSAndreas Gohr/** 8*b82f24afSAndreas Gohr * syntax handling tests for the vshare plugin 9*b82f24afSAndreas Gohr * 10*b82f24afSAndreas Gohr * @group plugin_vshare 11*b82f24afSAndreas Gohr * @group plugins 12*b82f24afSAndreas Gohr */ 13*b82f24afSAndreas Gohrclass VideoSyntaxTest extends DokuWikiTest 14*b82f24afSAndreas Gohr{ 15*b82f24afSAndreas Gohr 16*b82f24afSAndreas Gohr /** 17*b82f24afSAndreas Gohr * @return array[] 18*b82f24afSAndreas Gohr * @see testParseSize 19*b82f24afSAndreas Gohr */ 20*b82f24afSAndreas Gohr public function provideParseSize() 21*b82f24afSAndreas Gohr { 22*b82f24afSAndreas Gohr return [ 23*b82f24afSAndreas Gohr ['', 425, 239], 24*b82f24afSAndreas Gohr ['small', 255, 143], 25*b82f24afSAndreas Gohr ['Small', 255, 143], 26*b82f24afSAndreas Gohr ['178x123', 178, 123], 27*b82f24afSAndreas Gohr ['178X123', 178, 123], 28*b82f24afSAndreas Gohr ['small&medium', 255, 143, ['medium' => '']], 29*b82f24afSAndreas Gohr ['small&autoplay=false', 255, 143, ['autoplay' => 'false']], 30*b82f24afSAndreas Gohr ['178x123&autoplay=false', 178, 123, ['autoplay' => 'false']], 31*b82f24afSAndreas Gohr ['autoplay=false', 425, 239, ['autoplay' => 'false']], 32*b82f24afSAndreas Gohr ]; 33*b82f24afSAndreas Gohr } 34*b82f24afSAndreas Gohr 35*b82f24afSAndreas Gohr /** 36*b82f24afSAndreas Gohr * @dataProvider provideParseSize 37*b82f24afSAndreas Gohr * @param string $input 38*b82f24afSAndreas Gohr * @param int $ewidth 39*b82f24afSAndreas Gohr * @param int $eheight 40*b82f24afSAndreas Gohr * @param array $eparams 41*b82f24afSAndreas Gohr */ 42*b82f24afSAndreas Gohr public function testParseSize($input, $ewidth, $eheight, $eparams = []) 43*b82f24afSAndreas Gohr { 44*b82f24afSAndreas Gohr $syntax = new \syntax_plugin_vshare_video(); 45*b82f24afSAndreas Gohr parse_str($input, $params); 46*b82f24afSAndreas Gohr list($width, $height) = $syntax->parseSize($params); 47*b82f24afSAndreas Gohr 48*b82f24afSAndreas Gohr $this->assertEquals($ewidth, $width, 'width'); 49*b82f24afSAndreas Gohr $this->assertEquals($eheight, $height, 'height'); 50*b82f24afSAndreas Gohr $this->assertEquals($eparams, $eparams, 'height'); 51*b82f24afSAndreas Gohr } 52*b82f24afSAndreas Gohr 53*b82f24afSAndreas Gohr /** 54*b82f24afSAndreas Gohr * @see testHandle 55*b82f24afSAndreas Gohr */ 56*b82f24afSAndreas Gohr public function provideHandle() 57*b82f24afSAndreas Gohr { 58*b82f24afSAndreas Gohr return [ 59*b82f24afSAndreas Gohr [ 60*b82f24afSAndreas Gohr '{{youtube>L-WM8YxwqEU}}', 61*b82f24afSAndreas Gohr [ 62*b82f24afSAndreas Gohr 'site' => 'youtube', 63*b82f24afSAndreas Gohr 'domain' => 'www.youtube-nocookie.com', 64*b82f24afSAndreas Gohr 'video' => 'L-WM8YxwqEU', 65*b82f24afSAndreas Gohr 'url' => '//www.youtube-nocookie.com/embed/L-WM8YxwqEU?', 66*b82f24afSAndreas Gohr 'align' => 'none', 67*b82f24afSAndreas Gohr 'width' => 425, 68*b82f24afSAndreas Gohr 'height' => 239, 69*b82f24afSAndreas Gohr 'title' => '', 70*b82f24afSAndreas Gohr ], 71*b82f24afSAndreas Gohr ], 72*b82f24afSAndreas Gohr [ 73*b82f24afSAndreas Gohr '{{youtube>L-WM8YxwqEU?small&start=30&end=45|A random segment of 15 seconds}}', 74*b82f24afSAndreas Gohr [ 75*b82f24afSAndreas Gohr 'site' => 'youtube', 76*b82f24afSAndreas Gohr 'domain' => 'www.youtube-nocookie.com', 77*b82f24afSAndreas Gohr 'video' => 'L-WM8YxwqEU', 78*b82f24afSAndreas Gohr 'url' => '//www.youtube-nocookie.com/embed/L-WM8YxwqEU?start=30&end=45', 79*b82f24afSAndreas Gohr 'align' => 'none', 80*b82f24afSAndreas Gohr 'width' => 255, 81*b82f24afSAndreas Gohr 'height' => 143, 82*b82f24afSAndreas Gohr 'title' => 'A random segment of 15 seconds', 83*b82f24afSAndreas Gohr ], 84*b82f24afSAndreas Gohr ], 85*b82f24afSAndreas Gohr // FIXME add more tests 86*b82f24afSAndreas Gohr ]; 87*b82f24afSAndreas Gohr } 88*b82f24afSAndreas Gohr 89*b82f24afSAndreas Gohr /** 90*b82f24afSAndreas Gohr * @dataProvider provideHandle 91*b82f24afSAndreas Gohr * @param string $input 92*b82f24afSAndreas Gohr * @param array $expect 93*b82f24afSAndreas Gohr */ 94*b82f24afSAndreas Gohr public function testHandle($input, $expect) 95*b82f24afSAndreas Gohr { 96*b82f24afSAndreas Gohr $syntax = new \syntax_plugin_vshare_video(); 97*b82f24afSAndreas Gohr $result = $syntax->handle($input, DOKU_LEXER_MATCHED, 0, new \Doku_Handler()); 98*b82f24afSAndreas Gohr $this->assertEquals($expect, $result); 99*b82f24afSAndreas Gohr } 100*b82f24afSAndreas Gohr} 101