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.
 
 
 
 
 

87 lines
2.6 KiB

  1. <?php
  2. namespace dokuwiki\plugin\vshare\test;
  3. use DokuWikiTest;
  4. /**
  5. * General tests for the vshare plugin
  6. *
  7. * @group plugin_vshare
  8. * @group plugins
  9. */
  10. class GeneralTest extends DokuWikiTest
  11. {
  12. /**
  13. * Simple test to make sure the plugin.info.txt is in correct format
  14. */
  15. public function testPluginInfo(): void
  16. {
  17. $file = __DIR__ . '/../plugin.info.txt';
  18. $this->assertFileExists($file);
  19. $info = confToHash($file);
  20. $this->assertArrayHasKey('base', $info);
  21. $this->assertArrayHasKey('author', $info);
  22. $this->assertArrayHasKey('email', $info);
  23. $this->assertArrayHasKey('date', $info);
  24. $this->assertArrayHasKey('name', $info);
  25. $this->assertArrayHasKey('desc', $info);
  26. $this->assertArrayHasKey('url', $info);
  27. $this->assertEquals('vshare', $info['base']);
  28. $this->assertRegExp('/^https?:\/\//', $info['url']);
  29. $this->assertTrue(mail_isvalid($info['email']));
  30. $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
  31. $this->assertTrue(false !== strtotime($info['date']));
  32. }
  33. /**
  34. * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in
  35. * conf/metadata.php.
  36. */
  37. public function testPluginConf(): void
  38. {
  39. $conf_file = __DIR__ . '/../conf/default.php';
  40. $meta_file = __DIR__ . '/../conf/metadata.php';
  41. if (!file_exists($conf_file) && !file_exists($meta_file)) {
  42. self::markTestSkipped('No config files exist -> skipping test');
  43. }
  44. if (file_exists($conf_file)) {
  45. include($conf_file);
  46. }
  47. if (file_exists($meta_file)) {
  48. include($meta_file);
  49. }
  50. $this->assertEquals(
  51. gettype($conf),
  52. gettype($meta),
  53. 'Both ' . DOKU_PLUGIN . 'vshare/conf/default.php and ' . DOKU_PLUGIN . 'vshare/conf/metadata.php have to exist and contain the same keys.'
  54. );
  55. if ($conf !== null && $meta !== null) {
  56. foreach ($conf as $key => $value) {
  57. $this->assertArrayHasKey(
  58. $key,
  59. $meta,
  60. 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'vshare/conf/metadata.php'
  61. );
  62. }
  63. foreach ($meta as $key => $value) {
  64. $this->assertArrayHasKey(
  65. $key,
  66. $conf,
  67. 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'vshare/conf/default.php'
  68. );
  69. }
  70. }
  71. }
  72. }