aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2012-12-09 21:02:31 +0100
committerMarc Alexander <admin@m-a-styles.de>2012-12-09 21:02:31 +0100
commit1aae72961a3205a8487218b6d69361c43a1297d6 (patch)
tree3096a599c14c88084f782022f002ed84224ccf8b /tests/functional
parent26bde05a30c7111b57621a37d86425aa69d74263 (diff)
parent3fe381eed561e724700b21789e28ea3efb1f7ef9 (diff)
downloadforums-1aae72961a3205a8487218b6d69361c43a1297d6.tar
forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.gz
forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.bz2
forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.xz
forums-1aae72961a3205a8487218b6d69361c43a1297d6.zip
Merge branch 'develop' into feature/avatars
Conflicts: phpBB/install/database_update.php
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/browse_test.php3
-rw-r--r--tests/functional/extension_controller_test.php139
-rw-r--r--tests/functional/fileupload_form_test.php3
-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
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/routing.yml15
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/services.yml6
-rw-r--r--tests/functional/fixtures/ext/foo/bar/controller.php14
-rw-r--r--tests/functional/fixtures/ext/foo/bar/controller/controller.php35
-rw-r--r--tests/functional/fixtures/ext/foo/bar/ext.php2
-rw-r--r--tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foo_bar_body.html (renamed from tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html)4
-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
18 files changed, 137 insertions, 170 deletions
diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php
index 26c18c4c1f..b5748059c6 100644
--- a/tests/functional/browse_test.php
+++ b/tests/functional/browse_test.php
@@ -15,18 +15,21 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case
public function test_index()
{
$crawler = $this->request('GET', 'index.php');
+ $this->assert_response_success();
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
}
public function test_viewforum()
{
$crawler = $this->request('GET', 'viewforum.php?f=2');
+ $this->assert_response_success();
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
}
public function test_viewtopic()
{
$crawler = $this->request('GET', 'viewtopic.php?t=1');
+ $this->assert_response_success();
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
}
}
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index e9409d9d3f..f28b321942 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/styles/prosilver/template/foo_bar_body.html',
+ );
+
/**
* 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,11 @@ 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/',
+ $phpbb_root_path . 'ext/foo/bar/styles/prosilver/template',
);
foreach ($directories as $dir)
@@ -41,28 +45,34 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
}
}
- $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 (self::$fixtures as $fixture)
+ {
+ copy(
+ "tests/functional/fixtures/ext/$fixture",
+ "{$phpbb_root_path}ext/$fixture");
+ }
+ }
- foreach ($fixtures as $fixture)
+ /**
+ * 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 (!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture"))
- {
- echo 'Could not copy file ' . $fixture;
- }
+ unlink("{$phpbb_root_path}ext/$fixture");
}
+
+ 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");
}
public function setUp()
@@ -75,70 +85,67 @@ 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->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->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
+ $crawler = $this->request('GET', 'app.php?controller=foo/bar');
+ $this->assert_response_success();
+ $this->assertContains("foo/bar controller handle() method", $crawler->filter('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
+ * Check the output of a controller using the template system
*/
- public function test_error_class_name()
+ public function test_controller_with_template()
{
- $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');
+ $this->phpbb_extension_manager->enable('foo/bar');
+ $crawler = $this->request('GET', 'app.php?controller=foo/template');
+ $this->assert_response_success();
+ $this->assertContains("I am a variable", $crawler->filter('#content')->text());
+ $this->phpbb_extension_manager->purge('foo/bar');
}
/**
- * 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
+ * Check the error produced by calling a controller without a required
+ * argument.
*/
- public function test_error_class_type()
+ public function test_missing_argument()
{
- $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');
+ $this->phpbb_extension_manager->enable('foo/bar');
+ $crawler = $this->request('GET', 'app.php?controller=foo/baz');
+ $this->assertEquals(500, $this->client->getResponse()->getStatus());
+ $this->assertContains('Missing value for argument #1: test in class phpbb_ext_foo_bar_controller:baz', $crawler->filter('body')->text());
+ $this->phpbb_extension_manager->purge('foo/bar');
}
/**
- * Check the error produced by extension at ./ext/error/disabled that is (obviously)
- * a disabled extension
+ * Check the status code resulting from an exception thrown by a controller
*/
- public function test_error_ext_disabled()
+ public function test_exception_should_result_in_500_status_code()
{
- $crawler = $this->request('GET', 'index.php?ext=error/disabled');
- $this->assertContains("The extension error/disabled is not enabled", $crawler->filter('#message')->text());
+ $this->phpbb_extension_manager->enable('foo/bar');
+ $crawler = $this->request('GET', 'app.php?controller=foo/exception');
+ $this->assertEquals(500, $this->client->getResponse()->getStatus());
+ $this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
+ $this->phpbb_extension_manager->purge('foo/bar');
}
/**
- * 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?controller=does/not/exist');
+ $this->assertEquals(404, $this->client->getResponse()->getStatus());
+ $this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
}
}
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index f7267fa659..99afcfdc3d 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -64,6 +64,9 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
public function test_valid_file()
{
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
+ $this->assert_response_success();
+ // ensure there was no error message rendered
+ $this->assertNotContains('<h2>' . $this->lang('INFORMATION') . '</h2>', $this->client->getResponse()->getContent());
$this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->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 100644
index 0000000000..09a30a8c67
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
@@ -0,0 +1,15 @@
+foo_bar_controller:
+ pattern: /foo/bar
+ defaults: { _controller: foo_bar.controller:handle }
+
+foo_baz_controller:
+ pattern: /foo/baz
+ defaults: { _controller: foo_bar.controller:baz }
+
+foo_template_controller:
+ pattern: /foo/template
+ defaults: { _controller: foo_bar.controller:template }
+
+foo_exception_controller:
+ pattern: /foo/exception
+ defaults: { _controller: foo_bar.controller:exception }
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 100644
index 0000000000..33ced55af9
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml
@@ -0,0 +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.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 100644
index 0000000000..5a91b5f681
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
@@ -0,0 +1,35 @@
+<?php
+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);
+ }
+
+ public function baz($test)
+ {
+ 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');
+ }
+
+ public function exception()
+ {
+ throw new phpbb_controller_exception('Exception thrown from foo/exception route');
+ }
+}
diff --git a/tests/functional/fixtures/ext/foo/bar/ext.php b/tests/functional/fixtures/ext/foo/bar/ext.php
index 3a2068631e..74359d51ab 100644
--- a/tests/functional/fixtures/ext/foo/bar/ext.php
+++ b/tests/functional/fixtures/ext/foo/bar/ext.php
@@ -2,5 +2,5 @@
class phpbb_ext_foo_bar_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/foo_bar_body.html
index 4addf2666f..8fb6994d3d 100644
--- a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html
+++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foo_bar_body.html
@@ -1,5 +1,3 @@
<!-- INCLUDE overall_header.html -->
-
-<div id="welcome">This is for testing purposes.</div>
-
+<div id="content">{A_VARIABLE}</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 -->