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