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.
 
 
 
 
 

80 lines
2.3 KiB

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