Skip to content

Commit

Permalink
added scope tests
Browse files Browse the repository at this point in the history
verify that multiple requests can be made with multiple test methods.
  • Loading branch information
sarnowski committed Apr 16, 2012
1 parent 9a5e1c6 commit 1101eda
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
13 changes: 13 additions & 0 deletions _testing/inttests.php
Expand Up @@ -41,6 +41,17 @@ function rcopy($destdir, $source) {
rcopy(TMP_DIR, dirname(__FILE__).'/inttests.conf');
rcopy(TMP_DIR, dirname(__FILE__).'/inttests.data');

// cleanup dir after exit
register_shutdown_function(function() {
// TODO delete recursive tmp dir
});

// TODO disable all non-default plugins in config
// TODO if plugin test, enable plugin
// TODO load plugin descriptor and enable dependent plugins

// TODO set global variables, phpunit will restore them for every test (test that)

// load dw
require_once(DOKU_INC.'inc/init.php');

Expand Down Expand Up @@ -142,4 +153,6 @@ function getContent() {
function getHeaders() {
return $this->headers;
}

// TODO provide findById, findBy... (https://github.com/cosmocode/dokuwiki-plugin-scrape/blob/master/phpQuery-onefile.php)
}
@@ -1,6 +1,11 @@
<?php

class BasicTest extends PHPUnit_Framework_TestCase {
/**
* Execute the simplest possible request and expect
* a dokuwiki page which obviously has the word "DokuWiki"
* in it somewhere.
*/
function testSimpleRun() {
$request = new TestRequest();

Expand Down
File renamed without changes.
46 changes: 46 additions & 0 deletions _testing/inttests/inttests_scope.test.php
@@ -0,0 +1,46 @@
<?php

class ScopeTest extends PHPUnit_Framework_TestCase {
/**
* It should be possible to have two test cases within one test class.
*/
function testFirstRun() {
$request = new TestRequest();
$response = $request->execute();
$this->assertTrue(
strpos($response->getContent(), 'DokuWiki') >= 0,
'DokuWiki was not a word in the output'
);
}

/**
* @depends testFirstRun
*/
function testSecondRun() {
$request = new TestRequest();
$response = $request->execute();
$this->assertTrue(
strpos($response->getContent(), 'DokuWiki') >= 0,
'DokuWiki was not a word in the output'
);
}

/**
* two requests within the same test case should be possible
*/
function testMultipleRequests() {
$request = new TestRequest();
$response = $request->execute();
$this->assertTrue(
strpos($response->getContent(), 'DokuWiki') >= 0,
'DokuWiki was not a word in the output'
);

$request = new TestRequest();
$response = $request->execute();
$this->assertTrue(
strpos($response->getContent(), 'DokuWiki') >= 0,
'DokuWiki was not a word in the output'
);
}
}

0 comments on commit 1101eda

Please sign in to comment.