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.
 
 
 
 
 

63 lines
1.5 KiB

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