aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
authorDavid King <imkingdavid@gmail.com>2012-11-16 11:41:05 -0500
committerDavid King <imkingdavid@gmail.com>2012-11-16 17:06:01 -0500
commit5b013ddf5c48e71166dcefd6d384aea1d801698a (patch)
tree4a3a99c5fa0844ee1a521b33977c78c3b14e100c /tests/functional
parentba1acdca0364a9cd54c705d946fbae2144c59554 (diff)
downloadforums-5b013ddf5c48e71166dcefd6d384aea1d801698a.tar
forums-5b013ddf5c48e71166dcefd6d384aea1d801698a.tar.gz
forums-5b013ddf5c48e71166dcefd6d384aea1d801698a.tar.bz2
forums-5b013ddf5c48e71166dcefd6d384aea1d801698a.tar.xz
forums-5b013ddf5c48e71166dcefd6d384aea1d801698a.zip
[feature/controller] Add controller functional test with template
PHPBB3-10864
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/extension_controller_test.php32
-rwxr-xr-xtests/functional/fixtures/ext/foo/bar/config/routing.yml4
-rwxr-xr-xtests/functional/fixtures/ext/foo/bar/config/services.yml3
-rwxr-xr-xtests/functional/fixtures/ext/foo/bar/controller/controller.php15
-rw-r--r--tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foo_bar_body.html3
5 files changed, 52 insertions, 5 deletions
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 65a9c80df6..9cc2e0e32f 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -18,7 +18,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
'foo/bar/config/routing.yml',
'foo/bar/config/services.yml',
'foo/bar/controller/controller.php',
- 'foo/bar/ext.php',
+ 'foo/bar/styles/prosilver/template/foo_bar_body.html',
);
/**
@@ -34,6 +34,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$phpbb_root_path . 'ext/foo/bar/',
$phpbb_root_path . 'ext/foo/bar/config/',
$phpbb_root_path . 'ext/foo/bar/controller/',
+ $phpbb_root_path . 'ext/foo/bar/styles/prosilver/template',
);
foreach ($directories as $dir)
@@ -43,10 +44,12 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
mkdir($dir, 0777, true);
}
}
-
+
foreach (self::$fixtures as $fixture)
{
- copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture");
+ copy(
+ "tests/functional/fixtures/ext/$fixture",
+ "{$phpbb_root_path}ext/$fixture");
}
}
@@ -57,6 +60,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
static public function tearDownAfterClass()
{
global $phpbb_root_path;
+
foreach (self::$fixtures as $fixture)
{
unlink("{$phpbb_root_path}ext/$fixture");
@@ -64,6 +68,9 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
rmdir("{$phpbb_root_path}ext/foo/bar/config");
rmdir("{$phpbb_root_path}ext/foo/bar/controller");
+ rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver/template");
+ rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver");
+ rmdir("{$phpbb_root_path}ext/foo/bar/styles");
rmdir("{$phpbb_root_path}ext/foo/bar");
rmdir("{$phpbb_root_path}ext/foo");
}
@@ -78,7 +85,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
}
/**
- * Check a controller for extension foo/bar
+ * Check a controller for extension foo/bar.
*/
public function test_foo_bar()
{
@@ -88,6 +95,21 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$this->phpbb_extension_manager->purge('foo/bar');
}
+ /**
+ * Check the output of a controller using the template system
+ */
+ public function test_controller_with_template()
+ {
+ $this->phpbb_extension_manager->enable('foo/bar');
+ $crawler = $this->request('GET', 'app.php/foo/template');
+ $this->assertContains("I am a variable", $crawler->filter('#content')->text());
+ $this->phpbb_extension_manager->purge('foo/bar');
+ }
+
+ /**
+ * Check the error produced by calling a controller without a required
+ * argument.
+ */
public function test_missing_argument()
{
$this->phpbb_extension_manager->enable('foo/bar');
@@ -97,7 +119,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
}
/**
- * Check the error produced by extension at ./ext/does/not/exist
+ * 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,
diff --git a/tests/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
index 945ef51366..123f5f1b73 100755
--- a/tests/functional/fixtures/ext/foo/bar/config/routing.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
@@ -5,3 +5,7 @@ foo_bar_controller:
foo_baz_controller:
pattern: /foo/baz
defaults: { _controller: foo_bar.controller:baz }
+
+foo_template_controller:
+ pattern: /foo/template
+ defaults: { _controller: foo_bar.controller:template }
diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml
index d1db6fcb1d..33ced55af9 100755
--- a/tests/functional/fixtures/ext/foo/bar/config/services.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml
@@ -1,3 +1,6 @@
services:
foo_bar.controller:
class: phpbb_ext_foo_bar_controller
+ arguments:
+ - @controller.helper
+ - @template
diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
index def5184e8c..50ea5d034b 100755
--- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php
+++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
@@ -3,6 +3,14 @@ use Symfony\Component\HttpFoundation\Response;
class phpbb_ext_foo_bar_controller
{
+ protected $template;
+
+ public function __construct(phpbb_controller_helper $helper, phpbb_template $template)
+ {
+ $this->template = $template;
+ $this->helper = $helper;
+ }
+
public function handle()
{
return new Response('foo/bar controller handle() method', 200);
@@ -12,4 +20,11 @@ class phpbb_ext_foo_bar_controller
{
return new Response('Value of "test" URL argument is: ' . $test);
}
+
+ public function template()
+ {
+ $this->template->assign_var('A_VARIABLE', 'I am a variable');
+
+ return $this->helper->render('foo_bar_body.html');
+ }
}
diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foo_bar_body.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foo_bar_body.html
new file mode 100644
index 0000000000..8fb6994d3d
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foo_bar_body.html
@@ -0,0 +1,3 @@
+<!-- INCLUDE overall_header.html -->
+<div id="content">{A_VARIABLE}</div>
+<!-- INCLUDE overall_footer.html -->