diff options
-rw-r--r-- | _testing/core/DokuWikiTest.php | 25 | ||||
-rw-r--r-- | _testing/core/TestRequest.php | 30 | ||||
-rw-r--r-- | _testing/core/TestResponse.php | 35 | ||||
-rw-r--r-- | _testing/core/TestUtils.php | 24 |
4 files changed, 80 insertions, 34 deletions
diff --git a/_testing/core/DokuWikiTest.php b/_testing/core/DokuWikiTest.php index f464aab8e..e47c06329 100644 --- a/_testing/core/DokuWikiTest.php +++ b/_testing/core/DokuWikiTest.php @@ -4,17 +4,28 @@ */ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase { - // tests can override this + /** + * tests can override this + * + * @var array plugins to enable for test class + */ protected $pluginsEnabled = array(); - // tests can override this + + /** + * tests can override this + * + * @var array plugins to disable for test class + */ protected $pluginsDisabled = array(); /** - * Reset the DokuWiki environment before each test run + * Reset the DokuWiki environment before each test run. Makes sure loaded config, + * language and plugins are correct. * - * Makes sure loaded config, language and plugins are correct + * @throws Exception if plugin actions fail + * @return void */ - function setUp() { + public function setUp() { // reload config global $conf, $config_cascade; $conf = array(); @@ -53,7 +64,9 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase { global $default_plugins; foreach ($plugin_controller->getList() as $plugin) { if (!in_array($plugin, $default_plugins)) { - $plugin_controller->disable($plugin); + if (!$plugin_controller->disable($plugin)) { + throw new Exception('Could not disable plugin "'.$plugin.'"!'); + } } } diff --git a/_testing/core/TestRequest.php b/_testing/core/TestRequest.php index c9fc06bf2..fa3ddec90 100644 --- a/_testing/core/TestRequest.php +++ b/_testing/core/TestRequest.php @@ -13,32 +13,32 @@ function ob_start_callback($buffer) { } - /** * Helper class to execute a fake request */ class TestRequest { - var $server = array(); - var $session = array(); - var $get = array(); - var $post = array(); - function getServer($key) { return $this->server[$key]; } - function getSession($key) { return $this->session[$key]; } - function getGet($key) { return $this->get[$key]; } - function getPost($key) { return $this->post[$key]; } + private $server = array(); + private $session = array(); + private $get = array(); + private $post = array(); + + public function getServer($key) { return $this->server[$key]; } + public function getSession($key) { return $this->session[$key]; } + public function getGet($key) { return $this->get[$key]; } + public function getPost($key) { return $this->post[$key]; } - function setServer($key, $value) { $this->server[$key] = $value; } - function setSession($key, $value) { $this->session[$key] = $value; } - function setGet($key, $value) { $this->get[$key] = $value; } - function setPost($key, $value) { $this->post[$key] = $value; } + public function setServer($key, $value) { $this->server[$key] = $value; } + public function setSession($key, $value) { $this->session[$key] = $value; } + public function setGet($key, $value) { $this->get[$key] = $value; } + public function setPost($key, $value) { $this->post[$key] = $value; } /** * Executes the request * - * @return TestResponse response + * @return TestResponse the resulting output of the request */ - function execute() { + public function execute() { // save old environment $server = $_SERVER; $session = $_SESSION; diff --git a/_testing/core/TestResponse.php b/_testing/core/TestResponse.php index ed112b42e..6d20afb28 100644 --- a/_testing/core/TestResponse.php +++ b/_testing/core/TestResponse.php @@ -3,35 +3,52 @@ * holds a copy of all produced outputs of a TestRequest */ class TestResponse { - protected $content; - protected $headers; + /** + * @var string + */ + private $content; + + /** + * @var array + */ + private $headers; /** * @var phpQueryObject */ - protected $pq = null; + private $pq = null; + /** + * @param $content string + * @param $headers array + */ function __construct($content, $headers) { $this->content = $content; $this->headers = $headers; } - function getContent() { + /** + * @return string + */ + public function getContent() { return $this->content; } - function getHeaders() { + /** + * @return array + */ + public function getHeaders() { return $this->headers; } /** * Query the response for a JQuery compatible CSS selector * - * @link https://code.google.com/p/phpquery/wiki/Selectors - * @param string selector - * @returns object a PHPQuery object + * @link https://code.google.com/p/phpquery/wiki/Selectors + * @param $selector string + * @return phpQueryObject */ - function queryHTML($selector){ + public function queryHTML($selector){ if(is_null($this->pq)) $this->pq = phpQuery::newDocument($this->content); return $this->pq->find($selector); } diff --git a/_testing/core/TestUtils.php b/_testing/core/TestUtils.php index 4fd56e85d..64de62213 100644 --- a/_testing/core/TestUtils.php +++ b/_testing/core/TestUtils.php @@ -1,11 +1,18 @@ <?php +/** + * Helper class with some filesystem utilities. + */ class TestUtils { /** * helper for recursive copy() + * + * @static + * @param $destdir string + * @param $source string */ - static function rcopy($destdir, $source) { + public static function rcopy($destdir, $source) { if (!is_dir($source)) { copy($source, $destdir.'/'.basename($source)); } else { @@ -25,8 +32,11 @@ class TestUtils { /** * helper for recursive rmdir()/unlink() + * + * @static + * @param $target string */ - static function rdelete($target) { + public static function rdelete($target) { if (!is_dir($target)) { unlink($target); } else { @@ -42,8 +52,14 @@ class TestUtils { } } - // helper to append text to a file - static function fappend($file, $text) { + /** + * helper to append text to a file + * + * @static + * @param $file string + * @param $text string + */ + public static function fappend($file, $text) { $fh = fopen($file, 'a'); fwrite($fh, $text); fclose($fh); |