You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

101 lines
2.9 KiB

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