1<?php 2/** 3 * Tests over DokuWiki function for the 404manager plugin 4 * 5 * @group plugin_404manager 6 * @group plugins 7 */ 8require_once(__DIR__ . '/constant_parameters.php'); 9 10class dokuwiki_plugin_404manager_test extends DokuWikiTest 11{ 12 13 public static function setUpBeforeClass() 14 { 15 16 parent::setUpBeforeClass(); 17 saveWikiText(constant_parameters::$PAGE_EXIST_ID, 'A page', 'Test initialization'); 18 idx_addPage(constant_parameters::$PAGE_EXIST_ID); 19 20 } 21 22 23 /** 24 * Simple test to make sure the plugin.info.txt is in correct format 25 */ 26 public function test_plugininfo() 27 { 28 29 $file = __DIR__ . '/../plugin.info.txt'; 30 $this->assertFileExists($file); 31 32 $info = confToHash($file); 33 34 $this->assertArrayHasKey('base', $info); 35 $this->assertArrayHasKey('author', $info); 36 $this->assertArrayHasKey('email', $info); 37 $this->assertArrayHasKey('date', $info); 38 $this->assertArrayHasKey('name', $info); 39 $this->assertArrayHasKey('desc', $info); 40 $this->assertArrayHasKey('url', $info); 41 42 $this->assertEquals('404manager', $info['base']); 43 $this->assertRegExp('/^https?:\/\//', $info['url']); 44 $this->assertTrue(mail_isvalid($info['email'])); 45 $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); 46 $this->assertTrue(false !== strtotime($info['date'])); 47 48 } 49 50 /** Page exist can be tested on two ways within DokuWiki 51 * * page_exist 52 * * and the $INFO global variable 53 */ 54 public function test_pageExists() 55 { 56 57 // Not in a request 58 $this->assertTrue(page_exists(constant_parameters::$PAGE_EXIST_ID)); 59 60 // In a request 61 $request = new TestRequest(); 62 $request->get(array('id' => constant_parameters::$PAGE_EXIST_ID), '/doku.php'); 63 $request->execute(); 64 global $INFO; 65 $this->assertTrue($INFO['exists']); 66 67 // Not in a request 68 $this->assertFalse(page_exists(constant_parameters::$PAGE_DOES_NOT_EXIST_ID)); 69 70 // In a request 71 $request = new TestRequest(); 72 $request->get(array('id' => constant_parameters::$PAGE_DOES_NOT_EXIST_ID), '/doku.php'); 73 $request->execute(); 74 global $INFO; 75 $this->assertFalse($INFO['exists']); 76 77 } 78 79} 80