aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid King <imkingdavid@gmail.com>2012-11-16 09:23:57 -0500
committerDavid King <imkingdavid@gmail.com>2012-11-16 17:05:54 -0500
commit76917558832b0102716448770f365585aac224e9 (patch)
tree755d75d1dbe9221b8a228970df45df038c64410a /tests
parentc9588572c9f40223de3445a211ca85b18f5294a4 (diff)
downloadforums-76917558832b0102716448770f365585aac224e9.tar
forums-76917558832b0102716448770f365585aac224e9.tar.gz
forums-76917558832b0102716448770f365585aac224e9.tar.bz2
forums-76917558832b0102716448770f365585aac224e9.tar.xz
forums-76917558832b0102716448770f365585aac224e9.zip
[feature/controller] Adapt functional tests given new controller framework
PHPBB3-10864
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/extension_controller_test.php129
-rw-r--r--tests/functional/fixtures/ext/error/class/controller.php14
-rw-r--r--tests/functional/fixtures/ext/error/class/ext.php6
-rw-r--r--tests/functional/fixtures/ext/error/classtype/controller.php15
-rw-r--r--tests/functional/fixtures/ext/error/classtype/ext.php6
-rw-r--r--tests/functional/fixtures/ext/error/disabled/controller.php14
-rw-r--r--tests/functional/fixtures/ext/error/disabled/ext.php6
-rwxr-xr-xtests/functional/fixtures/ext/foo/bar/config/routing.yml3
-rwxr-xr-xtests/functional/fixtures/ext/foo/bar/config/services.yml3
-rw-r--r--tests/functional/fixtures/ext/foo/bar/controller.php14
-rwxr-xr-xtests/functional/fixtures/ext/foo/bar/controller/controller.php10
-rwxr-xr-x[-rw-r--r--]tests/functional/fixtures/ext/foo/bar/ext.php12
-rw-r--r--tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html5
-rw-r--r--tests/functional/fixtures/ext/foobar/controller.php14
-rw-r--r--tests/functional/fixtures/ext/foobar/ext.php6
-rw-r--r--tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html5
16 files changed, 69 insertions, 193 deletions
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index d92a830365..2f07c8a70f 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -13,6 +13,14 @@
class phpbb_functional_extension_controller_test extends phpbb_functional_test_case
{
protected $phpbb_extension_manager;
+
+ static protected $fixtures = array(
+ 'foo/bar/config/routing.yml',
+ 'foo/bar/config/services.yml',
+ 'foo/bar/controller/controller.php',
+ 'foo/bar/ext.php',
+ );
+
/**
* This should only be called once before the tests are run.
* This is used to copy the fixtures to the phpBB install
@@ -22,15 +30,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
global $phpbb_root_path;
parent::setUpBeforeClass();
- // these directories need to be created before the files can be copied
$directories = array(
- $phpbb_root_path . 'ext/error/class/',
- $phpbb_root_path . 'ext/error/classtype/',
- $phpbb_root_path . 'ext/error/disabled/',
$phpbb_root_path . 'ext/foo/bar/',
- $phpbb_root_path . 'ext/foo/bar/styles/prosilver/template/',
- $phpbb_root_path . 'ext/foobar/',
- $phpbb_root_path . 'ext/foobar/styles/prosilver/template/',
+ $phpbb_root_path . 'ext/foo/bar/config/',
+ $phpbb_root_path . 'ext/foo/bar/controller/',
);
foreach ($directories as $dir)
@@ -40,23 +43,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
mkdir($dir, 0777, true);
}
}
-
- $fixtures = array(
- 'error/class/controller.php',
- 'error/class/ext.php',
- 'error/classtype/controller.php',
- 'error/classtype/ext.php',
- 'error/disabled/controller.php',
- 'error/disabled/ext.php',
- 'foo/bar/controller.php',
- 'foo/bar/ext.php',
- 'foo/bar/styles/prosilver/template/foobar_body.html',
- 'foobar/controller.php',
- 'foobar/ext.php',
- 'foobar/styles/prosilver/template/foobar_body.html',
- );
-
- foreach ($fixtures as $fixture)
+
+ foreach (self::$fixtures as $fixture)
{
if (!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture"))
{
@@ -65,6 +53,27 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
}
}
+ /**
+ * This should only be called once after the tests are run.
+ * This is used to remove the fixtures from the phpBB install
+ */
+ static public function tearDownAfterClass()
+ {
+ global $phpbb_root_path;
+ foreach (self::$fixtures as $fixture)
+ {
+ if (!unlink("{$phpbb_root_path}ext/$fixture"))
+ {
+ echo 'Could not delete file ' . $fixture;
+ }
+ }
+
+ rmdir("{$phpbb_root_path}ext/foo/bar/config");
+ rmdir("{$phpbb_root_path}ext/foo/bar/controller");
+ rmdir("{$phpbb_root_path}ext/foo/bar");
+ rmdir("{$phpbb_root_path}ext/foo");
+ }
+
public function setUp()
{
parent::setUp();
@@ -75,72 +84,28 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
}
/**
- * Check an extension at ./ext/foobar/ which should have the class
- * phpbb_ext_foobar_controller
- */
- public function test_foobar()
- {
- $this->phpbb_extension_manager->enable('foobar');
- $crawler = $this->request('GET', 'index.php?ext=foobar');
- $this->assert_response_success();
- $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
- $this->phpbb_extension_manager->purge('foobar');
- }
-
- /**
- * Check an extension at ./ext/foo/bar/ which should have the class
- * phpbb_ext_foo_bar_controller
+ * Check a controller for extension foo/bar
*/
public function test_foo_bar()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = $this->request('GET', 'index.php?ext=foo/bar');
- $this->assert_response_success();
- $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
- $this->phpbb_extension_manager->purge('foo/bar');
- }
-
- /**
- * Check the error produced by extension at ./ext/error/class which has class
- * phpbb_ext_foobar_controller
- */
- public function test_error_class_name()
- {
- $this->phpbb_extension_manager->enable('error/class');
- $crawler = $this->request('GET', 'index.php?ext=error/class');
- $this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text());
- $this->phpbb_extension_manager->purge('error/class');
- }
-
- /**
- * Check the error produced by extension at ./ext/error/classtype which has class
- * phpbb_ext_error_classtype_controller but does not implement phpbb_extension_controller_interface
- */
- public function test_error_class_type()
- {
- $this->phpbb_extension_manager->enable('error/classtype');
- $crawler = $this->request('GET', 'index.php?ext=error/classtype');
- $this->assertContains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.", $crawler->filter('#message')->text());
- $this->phpbb_extension_manager->purge('error/classtype');
- }
-
- /**
- * Check the error produced by extension at ./ext/error/disabled that is (obviously)
- * a disabled extension
- */
- public function test_error_ext_disabled()
- {
- $crawler = $this->request('GET', 'index.php?ext=error/disabled');
- $this->assertContains("The extension error/disabled is not enabled", $crawler->filter('#message')->text());
+ $crawler = $this->request('GET', 'app.php/foo/bar');
+ $this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text());
+ $this->phpbb_extension_manager->purge('foobar');
}
/**
- * Check the error produced by extension at ./ext/error/404 that is (obviously)
- * not existant
+ * Check the error produced by extension at ./ext/does/not/exist
+ *
+ * If an extension is disabled, its routes are not loaded. Because we
+ * are not looking for a controller based on a specified extension,
+ * we don't know the difference between a route in a disabled
+ * extension and a route that is not defined anyway; it is the same
+ * error message.
*/
- public function test_error_ext_missing()
+ public function test_error_ext_disabled_or_404()
{
- $crawler = $this->request('GET', 'index.php?ext=error/404');
- $this->assertContains("The extension error/404 does not exist.", $crawler->filter('#message')->text());
+ $crawler = $this->request('GET', 'app.php/does/not/exist');
+ $this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
}
}
diff --git a/tests/functional/fixtures/ext/error/class/controller.php b/tests/functional/fixtures/ext/error/class/controller.php
deleted file mode 100644
index 74bbbee540..0000000000
--- a/tests/functional/fixtures/ext/error/class/controller.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-class phpbb_ext_foobar_controller extends phpbb_extension_controller
-{
- public function handle()
- {
- $this->template->set_filenames(array(
- 'body' => 'index_body.html'
- ));
-
- page_header('Test extension');
- page_footer();
- }
-}
diff --git a/tests/functional/fixtures/ext/error/class/ext.php b/tests/functional/fixtures/ext/error/class/ext.php
deleted file mode 100644
index f97ad2b838..0000000000
--- a/tests/functional/fixtures/ext/error/class/ext.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-class phpbb_ext_error_class_ext extends phpbb_extension_base
-{
-
-}
diff --git a/tests/functional/fixtures/ext/error/classtype/controller.php b/tests/functional/fixtures/ext/error/classtype/controller.php
deleted file mode 100644
index 55ac651bdf..0000000000
--- a/tests/functional/fixtures/ext/error/classtype/controller.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-class phpbb_ext_error_classtype_controller
-{
- public function handle()
- {
- global $template;
- $template->set_filenames(array(
- 'body' => 'index_body.html'
- ));
-
- page_header('Test extension');
- page_footer();
- }
-}
diff --git a/tests/functional/fixtures/ext/error/classtype/ext.php b/tests/functional/fixtures/ext/error/classtype/ext.php
deleted file mode 100644
index 35b1cd15a2..0000000000
--- a/tests/functional/fixtures/ext/error/classtype/ext.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-class phpbb_ext_error_classtype_ext extends phpbb_extension_base
-{
-
-}
diff --git a/tests/functional/fixtures/ext/error/disabled/controller.php b/tests/functional/fixtures/ext/error/disabled/controller.php
deleted file mode 100644
index 57b913f377..0000000000
--- a/tests/functional/fixtures/ext/error/disabled/controller.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-class phpbb_ext_error_disabled_controller extends phpbb_extension_controller
-{
- public function handle()
- {
- $this->template->set_filenames(array(
- 'body' => 'index_body.html'
- ));
-
- page_header('Test extension');
- page_footer();
- }
-}
diff --git a/tests/functional/fixtures/ext/error/disabled/ext.php b/tests/functional/fixtures/ext/error/disabled/ext.php
deleted file mode 100644
index aec8051848..0000000000
--- a/tests/functional/fixtures/ext/error/disabled/ext.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-class phpbb_ext_error_disabled_ext extends phpbb_extension_base
-{
-
-}
diff --git a/tests/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
new file mode 100755
index 0000000000..7ecaba9e71
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
@@ -0,0 +1,3 @@
+foo_bar_controller:
+ pattern: /foo/bar
+ defaults: { _controller: foo_bar.controller:handle }
diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml
new file mode 100755
index 0000000000..d1db6fcb1d
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml
@@ -0,0 +1,3 @@
+services:
+ foo_bar.controller:
+ class: phpbb_ext_foo_bar_controller
diff --git a/tests/functional/fixtures/ext/foo/bar/controller.php b/tests/functional/fixtures/ext/foo/bar/controller.php
deleted file mode 100644
index 3375e317b3..0000000000
--- a/tests/functional/fixtures/ext/foo/bar/controller.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-class phpbb_ext_foo_bar_controller extends phpbb_extension_controller
-{
- public function handle()
- {
- $this->template->set_filenames(array(
- 'body' => 'foobar_body.html'
- ));
-
- page_header('Test extension');
- page_footer();
- }
-}
diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
new file mode 100755
index 0000000000..4c5274951f
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
@@ -0,0 +1,10 @@
+<?php
+use Symfony\Component\HttpFoundation\Response;
+
+class phpbb_ext_foo_bar_controller
+{
+ public function handle()
+ {
+ return new Response('foo/bar controller handle() method', 200);
+ }
+}
diff --git a/tests/functional/fixtures/ext/foo/bar/ext.php b/tests/functional/fixtures/ext/foo/bar/ext.php
index 3a2068631e..b50f95990e 100644..100755
--- a/tests/functional/fixtures/ext/foo/bar/ext.php
+++ b/tests/functional/fixtures/ext/foo/bar/ext.php
@@ -1,6 +1,6 @@
-<?php
-
-class phpbb_ext_foo_bar_ext extends phpbb_extension_base
-{
-
-}
+<?php
+
+class phpbb_ext_foobar_ext extends phpbb_extension_base
+{
+
+}
diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html
deleted file mode 100644
index 4addf2666f..0000000000
--- a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<!-- INCLUDE overall_header.html -->
-
-<div id="welcome">This is for testing purposes.</div>
-
-<!-- INCLUDE overall_footer.html -->
diff --git a/tests/functional/fixtures/ext/foobar/controller.php b/tests/functional/fixtures/ext/foobar/controller.php
deleted file mode 100644
index ff35f12ee0..0000000000
--- a/tests/functional/fixtures/ext/foobar/controller.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-class phpbb_ext_foobar_controller extends phpbb_extension_controller
-{
- public function handle()
- {
- $this->template->set_filenames(array(
- 'body' => 'foobar_body.html'
- ));
-
- page_header('Test extension');
- page_footer();
- }
-}
diff --git a/tests/functional/fixtures/ext/foobar/ext.php b/tests/functional/fixtures/ext/foobar/ext.php
deleted file mode 100644
index 7cf443d369..0000000000
--- a/tests/functional/fixtures/ext/foobar/ext.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-class phpbb_ext_foobar_ext extends phpbb_extension_base
-{
-
-}
diff --git a/tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html b/tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html
deleted file mode 100644
index 4addf2666f..0000000000
--- a/tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<!-- INCLUDE overall_header.html -->
-
-<div id="welcome">This is for testing purposes.</div>
-
-<!-- INCLUDE overall_footer.html -->