aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/extension_controller_test.php
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/functional/extension_controller_test.php
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/functional/extension_controller_test.php')
-rw-r--r--tests/functional/extension_controller_test.php129
1 files changed, 47 insertions, 82 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());
}
}