summaryrefslogtreecommitdiff
path: root/_test/tests/test
diff options
context:
space:
mode:
authorTobias Sarnowski <sarnowski@cosmocode.de>2012-04-18 12:08:28 +0200
committerTobias Sarnowski <sarnowski@cosmocode.de>2012-04-18 12:08:28 +0200
commitf8369d7d6e37248d6523fdac6e1d760fca4f1b52 (patch)
tree0848c213ffc191a23b55f07bd2ec55e777ea79ca /_test/tests/test
parentd59108b91e9bf9fd56dc2e697cf31f9bbc7f9cd4 (diff)
downloadrpg-f8369d7d6e37248d6523fdac6e1d760fca4f1b52.tar.gz
rpg-f8369d7d6e37248d6523fdac6e1d760fca4f1b52.tar.bz2
moved _testing to _test
Diffstat (limited to '_test/tests/test')
-rw-r--r--_test/tests/test/basic.test.php22
-rw-r--r--_test/tests/test/globals.test.php49
-rw-r--r--_test/tests/test/hooks.test.php24
-rw-r--r--_test/tests/test/phpquery.test.php18
-rw-r--r--_test/tests/test/plugins.test.php32
-rw-r--r--_test/tests/test/plugins_defaults.test.php24
-rw-r--r--_test/tests/test/reset.test.php39
-rw-r--r--_test/tests/test/scope.test.php49
8 files changed, 257 insertions, 0 deletions
diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php
new file mode 100644
index 000000000..ca788a91d
--- /dev/null
+++ b/_test/tests/test/basic.test.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsBasicTest extends DokuWikiTest {
+ /**
+ * Execute the simplest possible request and expect
+ * a dokuwiki page which obviously has the word "DokuWiki"
+ * in it somewhere.
+ */
+ function testSimpleRun() {
+ $request = new TestRequest();
+
+ $response = $request->execute();
+
+ $this->assertTrue(
+ strpos($response->getContent(), 'DokuWiki') >= 0,
+ 'DokuWiki was not a word in the output'
+ );
+ }
+}
diff --git a/_test/tests/test/globals.test.php b/_test/tests/test/globals.test.php
new file mode 100644
index 000000000..b45b2bf83
--- /dev/null
+++ b/_test/tests/test/globals.test.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsGlobalsTest extends DokuWikiTest {
+
+ /**
+ * every request should be with its own variables
+ */
+ function testFirstRun() {
+ global $EVENT_HANDLER;
+
+ $request = new TestRequest();
+ $request->setServer('testvar', true);
+
+ $self = $this;
+ $EVENT_HANDLER->register_hook('TPL_CONTENT_DISPLAY', 'AFTER', null,
+ function() use ($self) {
+ $self->assertTrue($_SERVER['testvar'], 'Server variable not set correctly: testvar');
+ $self->assertEquals('87.142.120.6', $_SERVER['REMOTE_ADDR'], 'Server variable not set correctly: REMOTE_ADDR');
+ $_SERVER['tmpvar'] = true;
+ }
+ );
+
+ $request->execute();
+ }
+
+ /**
+ * @depends testFirstRun
+ */
+ function testSecondRun() {
+ global $EVENT_HANDLER;
+
+ $request = new TestRequest();
+ $request->setServer('testvar', false);
+
+ $self = $this;
+ $EVENT_HANDLER->register_hook('TPL_CONTENT_DISPLAY', 'AFTER', null,
+ function() use ($self) {
+ $self->assertFalse($_SERVER['testvar'], 'Server variable not set correctly: testvar');
+ $self->assertEquals('87.142.120.6', $_SERVER['REMOTE_ADDR'], 'Server variable not set correctly: REMOTE_ADDR');
+ $self->assertFalse(isset($_SERVER['tmpvar']));
+ }
+ );
+
+ $request->execute();
+ }
+}
diff --git a/_test/tests/test/hooks.test.php b/_test/tests/test/hooks.test.php
new file mode 100644
index 000000000..621b9f9b8
--- /dev/null
+++ b/_test/tests/test/hooks.test.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsHooksTest extends DokuWikiTest {
+
+ function testHookTriggering() {
+ global $EVENT_HANDLER;
+
+ $request = new TestRequest();
+ $hookTriggered = false;
+
+ $EVENT_HANDLER->register_hook('TPL_CONTENT_DISPLAY', 'AFTER', null,
+ function() use (&$hookTriggered) {
+ $hookTriggered = true;
+ }
+ );
+
+ $request->execute();
+
+ $this->assertTrue($hookTriggered, 'Hook was not triggered as expected!');
+ }
+}
diff --git a/_test/tests/test/phpquery.test.php b/_test/tests/test/phpquery.test.php
new file mode 100644
index 000000000..188d834cb
--- /dev/null
+++ b/_test/tests/test/phpquery.test.php
@@ -0,0 +1,18 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsPHPQueryTest extends DokuWikiTest {
+ /**
+ * Execute the simplest possible request and check the
+ * meta generator tag is set to "DokuWiki"
+ */
+ function testSimpleRun() {
+ $request = new TestRequest();
+
+ $response = $request->execute();
+
+ $this->assertEquals('DokuWiki', $response->queryHTML('meta[name="generator"]')->attr('content') );
+ }
+}
diff --git a/_test/tests/test/plugins.test.php b/_test/tests/test/plugins.test.php
new file mode 100644
index 000000000..ac6d1ee45
--- /dev/null
+++ b/_test/tests/test/plugins.test.php
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsPluginsTest extends DokuWikiTest {
+
+ function setUp() {
+ $this->pluginsEnabled = array(
+ 'testing'
+ );
+
+ parent::setUp();
+ }
+
+ function testTestingPluginEnabled() {
+ global $EVENT_HANDLER;
+
+ $request = new TestRequest();
+ $hookTriggered = false;
+
+ $EVENT_HANDLER->register_hook('TESTING_PLUGIN_INSTALLED', 'AFTER', null,
+ function() use (&$hookTriggered) {
+ $hookTriggered = true;
+ }
+ );
+
+ $request->execute();
+
+ $this->assertTrue($hookTriggered, 'Testing plugin did not trigger!');
+ }
+}
diff --git a/_test/tests/test/plugins_defaults.test.php b/_test/tests/test/plugins_defaults.test.php
new file mode 100644
index 000000000..a96dac931
--- /dev/null
+++ b/_test/tests/test/plugins_defaults.test.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsPluginsDefaultTest extends DokuWikiTest {
+
+ function testTestingPluginDisabledDefault() {
+ global $EVENT_HANDLER;
+
+ $request = new TestRequest();
+ $hookTriggered = false;
+
+ $EVENT_HANDLER->register_hook('TESTING_PLUGIN_INSTALLED', 'AFTER', null,
+ function() use (&$hookTriggered) {
+ $hookTriggered = true;
+ }
+ );
+
+ $request->execute();
+
+ $this->assertFalse($hookTriggered, 'Testing plugin did trigger!');
+ }
+}
diff --git a/_test/tests/test/reset.test.php b/_test/tests/test/reset.test.php
new file mode 100644
index 000000000..7c5978543
--- /dev/null
+++ b/_test/tests/test/reset.test.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsScopeTest extends DokuWikiTest {
+
+ public $triggered = false;
+
+ function testFirstRun(){
+ global $conf;
+ $conf['foo'] = 'bar';
+
+ global $EVENT_HANDLER;
+ $self = $this;
+ $EVENT_HANDLER->register_hook('DOKUWIKI_STARTED', 'AFTER', null,
+ function() use ($self) {
+ $self->triggered = true;
+ }
+ );
+ $request = new TestRequest();
+ $request->execute();
+ $this->assertTrue($this->triggered);
+ }
+
+ /**
+ * @depends testFirstRun
+ */
+ function testSecondRun(){
+ global $conf;
+ $this->assertFalse(isset($conf['foo']), 'conf setting');
+
+ $request = new TestRequest();
+ $request->execute();
+
+ $this->assertFalse($this->triggered, 'trigger');
+ }
+
+}
diff --git a/_test/tests/test/scope.test.php b/_test/tests/test/scope.test.php
new file mode 100644
index 000000000..9341ecef8
--- /dev/null
+++ b/_test/tests/test/scope.test.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @group integration
+ */
+class InttestsResetTest extends DokuWikiTest {
+ /**
+ * 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'
+ );
+ }
+}