From 637d8eabe76907ce4a1e810d8b6bd964acb1b303 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 21 Aug 2011 19:26:15 +0200 Subject: [feature/functional-tests] Implementing functional test framework with goutte PHPBB3-10414 --- tests/functional/browse_test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/functional/browse_test.php (limited to 'tests/functional') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php new file mode 100644 index 0000000000..9c1d04f35d --- /dev/null +++ b/tests/functional/browse_test.php @@ -0,0 +1,26 @@ +request('GET', 'index.php'); + $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); + } + + public function test_viewforum() + { + $crawler = $this->request('GET', 'viewforum.php?f=2'); + $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); + } +} -- cgit v1.2.1 From 66c50f6b30400b729d3fea4fb06dad5eb559aa51 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 2 Jan 2012 17:14:00 +0000 Subject: [ticket/9916] Updating license in non-distributed files PHPBB3-9916 --- tests/functional/browse_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 9c1d04f35d..723cf93232 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -3,7 +3,7 @@ * * @package testing * @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From 401de113f9a0cec57c9648a079303d30fdb23666 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 19 Feb 2012 15:26:20 -0500 Subject: [ticket/10586] test stuff. does not work yet, still need to put phpBB objects in bootstrap.php --- tests/functional/extension_controller_test.php | 96 ++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/functional/extension_controller_test.php (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php new file mode 100644 index 0000000000..7f0bccc485 --- /dev/null +++ b/tests/functional/extension_controller_test.php @@ -0,0 +1,96 @@ +enable('foobar'); + $phpbb_extension_manager->enable('foo_bar'); + $phpbb_extension_manager->enable('error_class'); + $phpbb_extension_manager->enable('error_classtype'); + } + + public function tearDown() + { + global $db, $cache; + $phpbb_extension_manager = new phpbb_extension_manager($db, 'phpbb_ext', '.php', $cache, '_cache'); + + $phpbb_extension_manager->purge('foobar'); + $phpbb_extension_manager->purge('foo_bar'); + $phpbb_extension_manager->purge('error_class'); + $phpbb_extension_manager->purge('error_classtype'); + } + + /** + * Check an extension at ./ext/foobar/ which should have the class + * phpbb_ext_foobar_controller + */ + public function test_foobar() + { + $crawler = $this->request('GET', 'index.php?ext=foobar'); + $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + } + + /** + * Check an extension at ./ext/foo/bar/ which should have the class + * phpbb_ext_foo_bar_controller + */ + public function test_foo_bar() + { + $crawler = $this->request('GET', 'index.php?ext=foo/bar'); + $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + } + + /** + * Check the error produced by extension at ./ext/error/class which has class + * phpbb_ext_foobar_controller + */ + public function test_error_class_name() + { + $crawler = $this->request('GET', 'index.php?ext=error/class'); + $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_class is missing a controller class and cannot be accessed through the front-end.")')->count()); + } + + /** + * 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() + { + $crawler = $this->request('GET', 'index.php?ext=error/classtype'); + $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.")')->count()); + } + + /** + * 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->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_classtype is not enabled.")')->count()); + } + + /** + * Check the error produced by extension at ./ext/error/404 that is (obviously) + * not existant + */ + public function test_error_ext_missing() + { + $crawler = $this->request('GET', 'index.php?ext=error/404'); + $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_404 does not exist.")')->count()); + } +} -- cgit v1.2.1 From 9212466626a3d80a90cab1f23cf423a1c4e20655 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 09:38:53 -0500 Subject: [ticket/10586] some bootstrap additions and test changes to try and make it work PHPBB3-10586 --- tests/functional/extension_controller_test.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 7f0bccc485..430d93f9bf 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -14,8 +14,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { public function setUp() { - global $db, $cache; - $phpbb_extension_manager = new phpbb_extension_manager($db, 'phpbb_ext', '.php', $cache, '_cache'); + global $phpbb_extension_manager; $phpbb_extension_manager->enable('foobar'); $phpbb_extension_manager->enable('foo_bar'); @@ -25,8 +24,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function tearDown() { - global $db, $cache; - $phpbb_extension_manager = new phpbb_extension_manager($db, 'phpbb_ext', '.php', $cache, '_cache'); + global $phpbb_extension_manager; $phpbb_extension_manager->purge('foobar'); $phpbb_extension_manager->purge('foo_bar'); -- cgit v1.2.1 From a37a28b48546afc880446db7e4b2fd87c70a6cda Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 10:53:22 -0500 Subject: [ticket/10586] Now tests run, but fail. But here is what I have. PHPBB3-10586 --- tests/functional/extension_controller_test.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 430d93f9bf..7e50eb7d91 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -14,7 +14,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { public function setUp() { - global $phpbb_extension_manager; + parent::setUp(); + $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->enable('foobar'); $phpbb_extension_manager->enable('foo_bar'); @@ -24,7 +25,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function tearDown() { - global $phpbb_extension_manager; + parent::tearDown(); + $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->purge('foobar'); $phpbb_extension_manager->purge('foo_bar'); -- cgit v1.2.1 From d235262bc21657f0693501ac1154e1443578d507 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 11:17:21 -0500 Subject: [ticket/10586] Adding the extensions used by the tests PHPBB3-10586 --- .../functional/fixtures/ext/error/class/controller.php | 17 +++++++++++++++++ tests/functional/fixtures/ext/error/class/ext.php | 6 ++++++ .../fixtures/ext/error/classtype/controller.php | 17 +++++++++++++++++ tests/functional/fixtures/ext/error/classtype/ext.php | 6 ++++++ .../fixtures/ext/error/disabled/controller.php | 17 +++++++++++++++++ tests/functional/fixtures/ext/error/disabled/ext.php | 6 ++++++ tests/functional/fixtures/ext/foo/bar/controller.php | 17 +++++++++++++++++ tests/functional/fixtures/ext/foo/bar/ext.php | 6 ++++++ .../foo/bar/styles/prosilver/template/index_body.html | 5 +++++ tests/functional/fixtures/ext/foobar/controller.php | 17 +++++++++++++++++ tests/functional/fixtures/ext/foobar/ext.php | 6 ++++++ .../foobar/styles/prosilver/template/index_body.html | 5 +++++ 12 files changed, 125 insertions(+) create mode 100644 tests/functional/fixtures/ext/error/class/controller.php create mode 100644 tests/functional/fixtures/ext/error/class/ext.php create mode 100644 tests/functional/fixtures/ext/error/classtype/controller.php create mode 100644 tests/functional/fixtures/ext/error/classtype/ext.php create mode 100644 tests/functional/fixtures/ext/error/disabled/controller.php create mode 100644 tests/functional/fixtures/ext/error/disabled/ext.php create mode 100644 tests/functional/fixtures/ext/foo/bar/controller.php create mode 100644 tests/functional/fixtures/ext/foo/bar/ext.php create mode 100644 tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html create mode 100644 tests/functional/fixtures/ext/foobar/controller.php create mode 100644 tests/functional/fixtures/ext/foobar/ext.php create mode 100644 tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/error/class/controller.php b/tests/functional/fixtures/ext/error/class/controller.php new file mode 100644 index 0000000000..eb2ae362a6 --- /dev/null +++ b/tests/functional/fixtures/ext/error/class/controller.php @@ -0,0 +1,17 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/error/class/'); + + $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 new file mode 100644 index 0000000000..f97ad2b838 --- /dev/null +++ b/tests/functional/fixtures/ext/error/class/ext.php @@ -0,0 +1,6 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/error/classtype/'); + + $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 new file mode 100644 index 0000000000..35b1cd15a2 --- /dev/null +++ b/tests/functional/fixtures/ext/error/classtype/ext.php @@ -0,0 +1,6 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/error/disabled/'); + + $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 new file mode 100644 index 0000000000..aec8051848 --- /dev/null +++ b/tests/functional/fixtures/ext/error/disabled/ext.php @@ -0,0 +1,6 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/foo/bar/'); + + $template->set_filenames(array( + 'body' => 'index_body.html' + )); + + page_header('Test extension'); + page_footer(); + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/ext.php b/tests/functional/fixtures/ext/foo/bar/ext.php new file mode 100644 index 0000000000..3a2068631e --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/ext.php @@ -0,0 +1,6 @@ + + +
This is for testing purposes.
+ + diff --git a/tests/functional/fixtures/ext/foobar/controller.php b/tests/functional/fixtures/ext/foobar/controller.php new file mode 100644 index 0000000000..c3ef29ffef --- /dev/null +++ b/tests/functional/fixtures/ext/foobar/controller.php @@ -0,0 +1,17 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/foobar/'); + + $template->set_filenames(array( + 'body' => 'index_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 new file mode 100644 index 0000000000..7b3f37cbfb --- /dev/null +++ b/tests/functional/fixtures/ext/foobar/ext.php @@ -0,0 +1,6 @@ + + +
This is for testing purposes.
+ + -- cgit v1.2.1 From 7b44d6f21a5a8be289bf6810f2c38d580647581e Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 16 Mar 2012 15:35:01 -0400 Subject: [ticket/10586] initial work on copying fixtures. Note that this depends on 10706 PHPBB3-10586 --- tests/functional/extension_controller_test.php | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 7e50eb7d91..b52174bbd5 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -12,6 +12,39 @@ */ class phpbb_functional_extension_controller_test extends phpbb_functional_test_case { + /** + * This should only be called once before the tests are run. + * This is used to copy the fixtures to the phpBB install + */ + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + // When you add new tests that require new fixtures, add them to the array. + $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/index_body.html', + 'foobar/controller.php', + 'foobar/ext.php', + 'foobar/styles/prosilver/template/index_body.html', + ); + + foreach ($fixtures as $fixture) + { + // we have to use self::$config['phpbb_functional_url'] because $this->root_url is not available in static classes + if(!copy("tests/functional/fixtures/ext/$fixture", self::$config['phpbb_functional_url'] . "/ext/$fixture")) + { + echo 'Could not copy file ' . $fixture; + } + } + } + public function setUp() { parent::setUp(); -- cgit v1.2.1 From 66b45318efea886ac6afc1f332cc94ee2af1c494 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 16 Mar 2012 16:42:29 -0400 Subject: [ticket/10586] browse tests now work, but mine dont. at least we are making progress PHPBB3-10586 --- tests/functional/browse_test.php | 11 +++++++++++ tests/functional/extension_controller_test.php | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 723cf93232..d119787d13 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -12,6 +12,17 @@ */ class phpbb_functional_browse_test extends phpbb_functional_test_case { + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + $f_path = self::$config['phpbb_functional_path']; + // we cannot run these tests correctly if the install directory is present + if (is_dir($f_path . 'install/')) + { + rename($f_path . 'install/', $f_path . 'install_/'); + } + // NOTE: this will need to be renamed back again later if you wish to test again + } public function test_index() { $crawler = $this->request('GET', 'index.php'); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index b52174bbd5..50710d0347 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -19,7 +19,27 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c static public function setUpBeforeClass() { parent::setUpBeforeClass(); + $f_path = self::$config['phpbb_functional_path']; + + // these directories need to be created before the files can be copied + $directories = array( + $f_path . 'ext/error/class/', + $f_path . 'ext/error/classtype/', + $f_path . 'ext/error/disabled/', + $f_path . 'ext/foo/bar/', + $f_path . 'ext/foo/bar/styles/prosilver/template/', + $f_path . 'ext/foobar/', + $f_path . 'ext/foobar/styles/prosilver/template/', + ); // When you add new tests that require new fixtures, add them to the array. + foreach ($directories as $dir) + { + if (!is_dir($dir)) + { + mkdir($dir, 0777, true); + } + } + $fixtures = array( 'error/class/controller.php', 'error/class/ext.php', @@ -38,7 +58,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c foreach ($fixtures as $fixture) { // we have to use self::$config['phpbb_functional_url'] because $this->root_url is not available in static classes - if(!copy("tests/functional/fixtures/ext/$fixture", self::$config['phpbb_functional_url'] . "/ext/$fixture")) + if(!copy("tests/functional/fixtures/ext/$fixture", "{$f_path}ext/$fixture")) { echo 'Could not copy file ' . $fixture; } -- cgit v1.2.1 From e78585c973d260651dd8487d586facd2ab9e1e51 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 16 Mar 2012 17:18:08 -0400 Subject: [ticket/10586] Rename install directory back to install/ after tests PHPBB3-10586 --- tests/functional/extension_controller_test.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 50710d0347..f137a49bf4 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -65,6 +65,17 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c } } + public static function tearDownAfterClass() + { + $f_path = self::$config['phpbb_functional_path']; + // first we rename the install_ directory back to install + rename($f_path . 'install_/', $f_path . 'install/'); + + // @todo delete the fixtures from the $f_path board + // Note that it might be best to find a public domain function + // and port it into here instead of writing it from scratch + } + public function setUp() { parent::setUp(); -- cgit v1.2.1 From 4100b312bb0eb7246e9057461b6f8f3c66fdad60 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 17 Mar 2012 22:12:50 -0400 Subject: [ticket/10586] Tests are coming along, just a little more to go PHPBB3-10586 --- tests/functional/extension_controller_test.php | 56 ++++++++++------------ .../functional/fixtures/ext/foo/bar/controller.php | 2 +- .../bar/styles/prosilver/template/foobar_body.html | 5 ++ .../bar/styles/prosilver/template/index_body.html | 5 -- .../functional/fixtures/ext/foobar/controller.php | 2 +- .../styles/prosilver/template/foobar_body.html | 5 ++ .../styles/prosilver/template/index_body.html | 5 -- 7 files changed, 38 insertions(+), 42 deletions(-) create mode 100644 tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html delete mode 100644 tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html create mode 100644 tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html delete mode 100644 tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index f137a49bf4..cb27511be1 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -49,10 +49,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c 'error/disabled/ext.php', 'foo/bar/controller.php', 'foo/bar/ext.php', - 'foo/bar/styles/prosilver/template/index_body.html', + 'foo/bar/styles/prosilver/template/foobar_body.html', 'foobar/controller.php', 'foobar/ext.php', - 'foobar/styles/prosilver/template/index_body.html', + 'foobar/styles/prosilver/template/foobar_body.html', ); foreach ($fixtures as $fixture) @@ -76,36 +76,20 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c // and port it into here instead of writing it from scratch } - public function setUp() - { - parent::setUp(); - $phpbb_extension_manager = $this->get_ext_manager(); - - $phpbb_extension_manager->enable('foobar'); - $phpbb_extension_manager->enable('foo_bar'); - $phpbb_extension_manager->enable('error_class'); - $phpbb_extension_manager->enable('error_classtype'); - } - - public function tearDown() - { - parent::tearDown(); - $phpbb_extension_manager = $this->get_ext_manager(); - - $phpbb_extension_manager->purge('foobar'); - $phpbb_extension_manager->purge('foo_bar'); - $phpbb_extension_manager->purge('error_class'); - $phpbb_extension_manager->purge('error_classtype'); - } - /** * Check an extension at ./ext/foobar/ which should have the class * phpbb_ext_foobar_controller */ public function test_foobar() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('foobar'); $crawler = $this->request('GET', 'index.php?ext=foobar'); - $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) + { + $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); + } + $phpbb_extension_manager->purge('foobar'); } /** @@ -114,8 +98,14 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_foo_bar() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('foo/bar'); $crawler = $this->request('GET', 'index.php?ext=foo/bar'); - $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) + { + $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); + } + $phpbb_extension_manager->purge('foo_bar'); } /** @@ -124,8 +114,11 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_name() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('error/class'); $crawler = $this->request('GET', 'index.php?ext=error/class'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_class is missing a controller class and cannot be accessed through the front-end.")')->count()); + $this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text()); + $phpbb_extension_manager->purge('error_class'); } /** @@ -134,8 +127,11 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_type() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('error/classtype'); $crawler = $this->request('GET', 'index.php?ext=error/classtype'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.")')->count()); + $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()); + $phpbb_extension_manager->purge('error_classtype'); } /** @@ -145,7 +141,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function test_error_ext_disabled() { $crawler = $this->request('GET', 'index.php?ext=error/disabled'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_classtype is not enabled.")')->count()); + $this->assertContains("The extension error/disabled is not enabled", $crawler->filter('#message')->text()); } /** @@ -155,6 +151,6 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function test_error_ext_missing() { $crawler = $this->request('GET', 'index.php?ext=error/404'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_404 does not exist.")')->count()); + $this->assertContains("The extension error/404 does not exist.", $crawler->filter('#message')->text()); } } diff --git a/tests/functional/fixtures/ext/foo/bar/controller.php b/tests/functional/fixtures/ext/foo/bar/controller.php index 93d1f099c9..24d218c412 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller.php @@ -8,7 +8,7 @@ class phpbb_ext_foo_bar_controller implements phpbb_extension_controller_interfa $template->set_ext_dir_prefix($phpbb_root_path . 'ext/foo/bar/'); $template->set_filenames(array( - 'body' => 'index_body.html' + 'body' => 'foobar_body.html' )); page_header('Test extension'); 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 new file mode 100644 index 0000000000..4addf2666f --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html @@ -0,0 +1,5 @@ + + +
This is for testing purposes.
+ + diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html deleted file mode 100644 index 4addf2666f..0000000000 --- a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html +++ /dev/null @@ -1,5 +0,0 @@ - - -
This is for testing purposes.
- - diff --git a/tests/functional/fixtures/ext/foobar/controller.php b/tests/functional/fixtures/ext/foobar/controller.php index c3ef29ffef..bf8d8139ae 100644 --- a/tests/functional/fixtures/ext/foobar/controller.php +++ b/tests/functional/fixtures/ext/foobar/controller.php @@ -8,7 +8,7 @@ class phpbb_ext_foobar_controller implements phpbb_extension_controller_interfac $template->set_ext_dir_prefix($phpbb_root_path . 'ext/foobar/'); $template->set_filenames(array( - 'body' => 'index_body.html' + 'body' => 'foobar_body.html' )); page_header('Test extension'); 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 new file mode 100644 index 0000000000..4addf2666f --- /dev/null +++ b/tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html @@ -0,0 +1,5 @@ + + +
This is for testing purposes.
+ + diff --git a/tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html b/tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html deleted file mode 100644 index 4addf2666f..0000000000 --- a/tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html +++ /dev/null @@ -1,5 +0,0 @@ - - -
This is for testing purposes.
- - -- cgit v1.2.1 From 7d1e4bca334dc9fcef3eb6e62cb412226ebc7ca4 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 18 Mar 2012 14:44:37 -0400 Subject: [ticket/10586] more work on getting tests to pass PHPBB3-10586 --- tests/functional/extension_controller_test.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index cb27511be1..46f3dc6f96 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -85,10 +85,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->enable('foobar'); $crawler = $this->request('GET', 'index.php?ext=foobar'); - if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) - { - $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); - } + $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text()); $phpbb_extension_manager->purge('foobar'); } @@ -101,11 +98,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->enable('foo/bar'); $crawler = $this->request('GET', 'index.php?ext=foo/bar'); - if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) - { - $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); - } - $phpbb_extension_manager->purge('foo_bar'); + $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text()); + $phpbb_extension_manager->purge('foo/bar'); } /** @@ -118,7 +112,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $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()); - $phpbb_extension_manager->purge('error_class'); + $phpbb_extension_manager->purge('error/class'); } /** @@ -131,7 +125,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $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()); - $phpbb_extension_manager->purge('error_classtype'); + $phpbb_extension_manager->purge('error/classtype'); } /** -- cgit v1.2.1 From 76e61951942048e3e98dbe60a3683d5269a4fa0e Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 18 Mar 2012 16:50:41 -0400 Subject: [ticket/10586] trying to get tests to work PHPBB3-10586 --- tests/functional/extension_controller_test.php | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 46f3dc6f96..4123853151 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -12,6 +12,7 @@ */ class phpbb_functional_extension_controller_test extends phpbb_functional_test_case { + protected $phpbb_extension_manager; /** * This should only be called once before the tests are run. * This is used to copy the fixtures to the phpBB install @@ -76,17 +77,23 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c // and port it into here instead of writing it from scratch } + public function setUp() + { + parent::setUp(); + $this->phpbb_extension_manager = !($this->phpbb_extension_manager instanceof phpbb_extension_manager) ? $this->get_ext_manager() : $this->phpbb_extension_manager; + $this->cache->purge('_ext'); + } + /** * Check an extension at ./ext/foobar/ which should have the class * phpbb_ext_foobar_controller */ public function test_foobar() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('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()); - $phpbb_extension_manager->purge('foobar'); + $this->phpbb_extension_manager->purge('foobar'); } /** @@ -95,11 +102,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_foo_bar() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('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()); - $phpbb_extension_manager->purge('foo/bar'); + $this->phpbb_extension_manager->purge('foo/bar'); } /** @@ -108,11 +114,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_name() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('error/class'); + $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()); - $phpbb_extension_manager->purge('error/class'); + $this->phpbb_extension_manager->purge('error/class'); } /** @@ -121,11 +126,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_type() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('error/classtype'); + $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()); - $phpbb_extension_manager->purge('error/classtype'); + $this->phpbb_extension_manager->purge('error/classtype'); } /** -- cgit v1.2.1 From 1bbb32a5cffeff4875c4ed0566999cbee8919c86 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 18 Mar 2012 22:57:37 +0100 Subject: [ticket/10586] Correctly purge board cache and don't rename install directory PHPBB3-10586 --- tests/functional/browse_test.php | 11 ----------- tests/functional/extension_controller_test.php | 8 ++++---- tests/functional/fixtures/ext/foobar/ext.php | 4 ++-- 3 files changed, 6 insertions(+), 17 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index d119787d13..723cf93232 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -12,17 +12,6 @@ */ class phpbb_functional_browse_test extends phpbb_functional_test_case { - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - $f_path = self::$config['phpbb_functional_path']; - // we cannot run these tests correctly if the install directory is present - if (is_dir($f_path . 'install/')) - { - rename($f_path . 'install/', $f_path . 'install_/'); - } - // NOTE: this will need to be renamed back again later if you wish to test again - } public function test_index() { $crawler = $this->request('GET', 'index.php'); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 4123853151..dd8aa1181b 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -69,8 +69,6 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public static function tearDownAfterClass() { $f_path = self::$config['phpbb_functional_path']; - // first we rename the install_ directory back to install - rename($f_path . 'install_/', $f_path . 'install/'); // @todo delete the fixtures from the $f_path board // Note that it might be best to find a public domain function @@ -80,8 +78,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function setUp() { parent::setUp(); - $this->phpbb_extension_manager = !($this->phpbb_extension_manager instanceof phpbb_extension_manager) ? $this->get_ext_manager() : $this->phpbb_extension_manager; - $this->cache->purge('_ext'); + + $this->phpbb_extension_manager = $this->get_extension_manager(); + + $this->purge_cache(); } /** diff --git a/tests/functional/fixtures/ext/foobar/ext.php b/tests/functional/fixtures/ext/foobar/ext.php index 7b3f37cbfb..7cf443d369 100644 --- a/tests/functional/fixtures/ext/foobar/ext.php +++ b/tests/functional/fixtures/ext/foobar/ext.php @@ -1,6 +1,6 @@ Date: Mon, 19 Mar 2012 09:56:48 -0400 Subject: [ticket/10586] Tests finally work (thanks naderman) PHPBB3-10586 --- tests/functional/extension_controller_test.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index dd8aa1181b..263d48c034 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -19,20 +19,20 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ static public function setUpBeforeClass() { + global $phpbb_root_path; parent::setUpBeforeClass(); - $f_path = self::$config['phpbb_functional_path']; // these directories need to be created before the files can be copied $directories = array( - $f_path . 'ext/error/class/', - $f_path . 'ext/error/classtype/', - $f_path . 'ext/error/disabled/', - $f_path . 'ext/foo/bar/', - $f_path . 'ext/foo/bar/styles/prosilver/template/', - $f_path . 'ext/foobar/', - $f_path . 'ext/foobar/styles/prosilver/template/', + $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/', ); - // When you add new tests that require new fixtures, add them to the array. + foreach ($directories as $dir) { if (!is_dir($dir)) @@ -58,8 +58,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c foreach ($fixtures as $fixture) { - // we have to use self::$config['phpbb_functional_url'] because $this->root_url is not available in static classes - if(!copy("tests/functional/fixtures/ext/$fixture", "{$f_path}ext/$fixture")) + if(!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture")) { echo 'Could not copy file ' . $fixture; } @@ -68,9 +67,9 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public static function tearDownAfterClass() { - $f_path = self::$config['phpbb_functional_path']; + $phpbb_root_path = self::$config['phpbb_functional_path']; - // @todo delete the fixtures from the $f_path board + // @todo delete the fixtures from the $phpbb_root_path board // Note that it might be best to find a public domain function // and port it into here instead of writing it from scratch } -- cgit v1.2.1 From 7c3ebcc3ff16950f76f857381222070c36a76fc3 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 28 Mar 2012 15:34:24 -0400 Subject: [ticket/10586] Added space in if statement PHPBB3-10586 --- tests/functional/extension_controller_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 263d48c034..4ee0e68718 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -58,7 +58,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c foreach ($fixtures as $fixture) { - if(!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture")) + if (!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture")) { echo 'Could not copy file ' . $fixture; } -- cgit v1.2.1 From 35805a27408f4d25987c3f8df5c9bf54b15a19f3 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 28 Mar 2012 16:48:16 -0400 Subject: [ticket/10586] Moved some loading stuff below extension controller, updated tests PHPBB3-10586 --- tests/functional/fixtures/ext/error/class/controller.php | 7 +++---- tests/functional/fixtures/ext/error/disabled/controller.php | 7 +++---- tests/functional/fixtures/ext/foo/bar/controller.php | 7 +++---- tests/functional/fixtures/ext/foobar/controller.php | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/error/class/controller.php b/tests/functional/fixtures/ext/error/class/controller.php index eb2ae362a6..99849584bc 100644 --- a/tests/functional/fixtures/ext/error/class/controller.php +++ b/tests/functional/fixtures/ext/error/class/controller.php @@ -1,13 +1,12 @@ set_ext_dir_prefix($phpbb_root_path . 'ext/error/class/'); + $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/error/class/'); - $template->set_filenames(array( + $this->template->set_filenames(array( 'body' => 'index_body.html' )); diff --git a/tests/functional/fixtures/ext/error/disabled/controller.php b/tests/functional/fixtures/ext/error/disabled/controller.php index b83a949020..ef2edda3de 100644 --- a/tests/functional/fixtures/ext/error/disabled/controller.php +++ b/tests/functional/fixtures/ext/error/disabled/controller.php @@ -1,13 +1,12 @@ set_ext_dir_prefix($phpbb_root_path . 'ext/error/disabled/'); + $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/error/disabled/'); - $template->set_filenames(array( + $this->template->set_filenames(array( 'body' => 'index_body.html' )); diff --git a/tests/functional/fixtures/ext/foo/bar/controller.php b/tests/functional/fixtures/ext/foo/bar/controller.php index 24d218c412..1910a4da88 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller.php @@ -1,13 +1,12 @@ set_ext_dir_prefix($phpbb_root_path . 'ext/foo/bar/'); + $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/foo/bar/'); - $template->set_filenames(array( + $this->template->set_filenames(array( 'body' => 'foobar_body.html' )); diff --git a/tests/functional/fixtures/ext/foobar/controller.php b/tests/functional/fixtures/ext/foobar/controller.php index bf8d8139ae..5161b28fe8 100644 --- a/tests/functional/fixtures/ext/foobar/controller.php +++ b/tests/functional/fixtures/ext/foobar/controller.php @@ -1,13 +1,12 @@ set_ext_dir_prefix($phpbb_root_path . 'ext/foobar/'); + $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/foobar/'); - $template->set_filenames(array( + $this->template->set_filenames(array( 'body' => 'foobar_body.html' )); -- cgit v1.2.1 From caf47f8e19da9e725702fe5a6c09f10be23dd473 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 28 Mar 2012 20:21:54 -0400 Subject: [ticket/10586] Removed incorrect method call PHPBB3-10586 --- tests/functional/fixtures/ext/error/class/controller.php | 2 -- tests/functional/fixtures/ext/error/classtype/controller.php | 2 -- tests/functional/fixtures/ext/error/disabled/controller.php | 4 +--- tests/functional/fixtures/ext/foo/bar/controller.php | 2 -- tests/functional/fixtures/ext/foobar/controller.php | 2 -- 5 files changed, 1 insertion(+), 11 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/error/class/controller.php b/tests/functional/fixtures/ext/error/class/controller.php index 99849584bc..74bbbee540 100644 --- a/tests/functional/fixtures/ext/error/class/controller.php +++ b/tests/functional/fixtures/ext/error/class/controller.php @@ -4,8 +4,6 @@ class phpbb_ext_foobar_controller extends phpbb_extension_controller { public function handle() { - $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/error/class/'); - $this->template->set_filenames(array( 'body' => 'index_body.html' )); diff --git a/tests/functional/fixtures/ext/error/classtype/controller.php b/tests/functional/fixtures/ext/error/classtype/controller.php index 2276548b55..55ac651bdf 100644 --- a/tests/functional/fixtures/ext/error/classtype/controller.php +++ b/tests/functional/fixtures/ext/error/classtype/controller.php @@ -5,8 +5,6 @@ class phpbb_ext_error_classtype_controller public function handle() { global $template; - $template->set_ext_dir_prefix($phpbb_root_path . 'ext/error/classtype/'); - $template->set_filenames(array( 'body' => 'index_body.html' )); diff --git a/tests/functional/fixtures/ext/error/disabled/controller.php b/tests/functional/fixtures/ext/error/disabled/controller.php index ef2edda3de..57b913f377 100644 --- a/tests/functional/fixtures/ext/error/disabled/controller.php +++ b/tests/functional/fixtures/ext/error/disabled/controller.php @@ -3,9 +3,7 @@ class phpbb_ext_error_disabled_controller extends phpbb_extension_controller { public function handle() - { - $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/error/disabled/'); - + { $this->template->set_filenames(array( 'body' => 'index_body.html' )); diff --git a/tests/functional/fixtures/ext/foo/bar/controller.php b/tests/functional/fixtures/ext/foo/bar/controller.php index 1910a4da88..3375e317b3 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller.php @@ -4,8 +4,6 @@ class phpbb_ext_foo_bar_controller extends phpbb_extension_controller { public function handle() { - $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/foo/bar/'); - $this->template->set_filenames(array( 'body' => 'foobar_body.html' )); diff --git a/tests/functional/fixtures/ext/foobar/controller.php b/tests/functional/fixtures/ext/foobar/controller.php index 5161b28fe8..ff35f12ee0 100644 --- a/tests/functional/fixtures/ext/foobar/controller.php +++ b/tests/functional/fixtures/ext/foobar/controller.php @@ -4,8 +4,6 @@ class phpbb_ext_foobar_controller extends phpbb_extension_controller { public function handle() { - $this->template->set_ext_dir_prefix($this->phpbb_root_path . 'ext/foobar/'); - $this->template->set_filenames(array( 'body' => 'foobar_body.html' )); -- cgit v1.2.1 From 2aa994b5ad76941689e7993707509e48438c500b Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sat, 21 Apr 2012 04:37:57 -0500 Subject: [ticket/10492] Backporting functional tests PHPBB3-10492 --- tests/functional/browse_test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/functional/browse_test.php (limited to 'tests/functional') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php new file mode 100644 index 0000000000..d056003578 --- /dev/null +++ b/tests/functional/browse_test.php @@ -0,0 +1,26 @@ +request('GET', 'index.php'); + $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); + } + + public function test_viewforum() + { + $crawler = $this->request('GET', 'viewforum.php?f=2'); + $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); + } +} -- cgit v1.2.1 From 6293bbf09949335bb8101bcef8f043750d756dc9 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Sat, 21 Apr 2012 05:24:57 -0500 Subject: [ticket/10492] Fix line endings PHPBB3-10492 --- tests/functional/browse_test.php | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index d056003578..723cf93232 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -1,26 +1,26 @@ -request('GET', 'index.php'); - $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); - } - - public function test_viewforum() - { - $crawler = $this->request('GET', 'viewforum.php?f=2'); - $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); - } -} +request('GET', 'index.php'); + $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); + } + + public function test_viewforum() + { + $crawler = $this->request('GET', 'viewforum.php?f=2'); + $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); + } +} -- cgit v1.2.1 From 8cf0b79a4746b416e66264cc3313f46d995b1783 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 23 Apr 2012 17:16:16 -0400 Subject: [task/functional] Increase code coverage for functional tests PHPBB3-10758 --- tests/functional/auth_test.php | 40 ++++++++++++++++++++++++++++++++++++++++ tests/functional/browse_test.php | 6 ++++++ tests/functional/lang_test.php | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/functional/auth_test.php create mode 100644 tests/functional/lang_test.php (limited to 'tests/functional') diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php new file mode 100644 index 0000000000..e955dcb4df --- /dev/null +++ b/tests/functional/auth_test.php @@ -0,0 +1,40 @@ +login(); + + // check for logout link + $crawler = $this->request('GET', 'index.php'); + $this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text()); + } + + /** + * @depends test_login + */ + public function test_logout() + { + $this->login(); + $this->add_lang('ucp'); + + // logout + $crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); + $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); + + // look for a register link, which should be visible only when logged out + $crawler = $this->request('GET', 'index.php'); + $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); + } +} diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 723cf93232..26c18c4c1f 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -23,4 +23,10 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'viewforum.php?f=2'); $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); } + + public function test_viewtopic() + { + $crawler = $this->request('GET', 'viewtopic.php?t=1'); + $this->assertGreaterThan(0, $crawler->filter('.postbody')->count()); + } } diff --git a/tests/functional/lang_test.php b/tests/functional/lang_test.php new file mode 100644 index 0000000000..f77dd511a3 --- /dev/null +++ b/tests/functional/lang_test.php @@ -0,0 +1,37 @@ +assertEquals('Board index', $this->lang('FORUM_INDEX')); + } + + public function test_add_lang() + { + $this->add_lang('ucp'); + + // Test a language string present only in the UCP language file + $this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE')); + } + + public function test_add_langs() + { + $this->add_lang(array('groups', 'memberlist')); + + // Test a language string from each UCP and memberlist + $this->assertEquals('The selected group is already your default group.', $this->lang('ALREADY_DEFAULT_GROUP')); + $this->assertEquals('Profile', $this->lang('ABOUT_USER')); + } +} -- cgit v1.2.1 From b82c77b38f69aa2d8030ee848042a0169592878b Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 24 Apr 2012 14:10:50 -0400 Subject: [task/functional] Make sure missing language values are handled properly PHPBB3-10758 --- tests/functional/lang_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/lang_test.php b/tests/functional/lang_test.php index f77dd511a3..053806a431 100644 --- a/tests/functional/lang_test.php +++ b/tests/functional/lang_test.php @@ -18,6 +18,14 @@ class phpbb_functional_lang_test extends phpbb_functional_test_case $this->assertEquals('Board index', $this->lang('FORUM_INDEX')); } + /** + * @expectedException RuntimeException + */ + public function test_lang_missing() + { + $this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE')); + } + public function test_add_lang() { $this->add_lang('ucp'); -- cgit v1.2.1 From 5b96b5fce7283ebd52f88ef6daa3c8233a7df1ec Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 7 May 2012 10:39:49 -0400 Subject: [ticket/10837] Removed tearDownAfterClass() from extension_controller_test.php PHPBB3-10837 --- tests/functional/extension_controller_test.php | 9 --------- 1 file changed, 9 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 4ee0e68718..e9409d9d3f 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -65,15 +65,6 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c } } - public static function tearDownAfterClass() - { - $phpbb_root_path = self::$config['phpbb_functional_path']; - - // @todo delete the fixtures from the $phpbb_root_path board - // Note that it might be best to find a public domain function - // and port it into here instead of writing it from scratch - } - public function setUp() { parent::setUp(); -- cgit v1.2.1 From 5693036bf9237ad54e62425faf6ab16907cc7ea9 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Fri, 22 Jun 2012 18:39:02 +0100 Subject: [ticket/10941] Added functional tests for the fileupload class NOTE: test_form_upload() is broken. Uploading files via Symfony fails to retain $_FILES['fileupload']['type'] even if it set explicitely. This appears to be a bug in Symfony. Since the current version of filespec::is_image() relies on the mimetype, these tests will __fail__. filespec::is_image() has been fixed in https://github.com/phpbb/phpbb3/pull/833 however. PHPBB3-10941 --- tests/functional/fileupload_test.php | 86 +++++++++++++++++++++ tests/functional/fixtures/files/empty.png | 0 .../fixtures/files/illegal-extension.bif | Bin 0 -> 519 bytes tests/functional/fixtures/files/too-large.png | Bin 0 -> 284717 bytes tests/functional/fixtures/files/valid.jpg | Bin 0 -> 554 bytes 5 files changed, 86 insertions(+) create mode 100644 tests/functional/fileupload_test.php create mode 100644 tests/functional/fixtures/files/empty.png create mode 100644 tests/functional/fixtures/files/illegal-extension.bif create mode 100644 tests/functional/fixtures/files/too-large.png create mode 100644 tests/functional/fixtures/files/valid.jpg (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php new file mode 100644 index 0000000000..ff62bad7bd --- /dev/null +++ b/tests/functional/fileupload_test.php @@ -0,0 +1,86 @@ +add_lang('posting'); + $this->login(); + + // Test 1: Invalid extension + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($path . 'illegal-extension.bif'); + $crawler = $this->client->submit($form); + $this->assertEquals(1, $crawler->filter('p.error')->count()); + + // Test 2: Empty file + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($path . 'empty.png'); + $crawler = $this->client->submit($form); + $this->assertEquals(1, $crawler->filter('p.error')->count()); + + // Test 3: File too large + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($path . 'too-large.png'); + $crawler = $this->client->submit($form); + $this->assertEquals(1, $crawler->filter('div#message')->count()); + + // Test 4: Valid file + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($path . 'valid.jpg'); + $crawler = $this->client->submit($form); + $this->assertEquals(0, $crawler->filter('p.error')->count()); + $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text()); + } + + public function test_remote_upload() + { + // Only doing this within the functional framework because we need a + // URL + global $config; + + if (!is_array($config)) + { + $config = array(); + } + + $config['rand_seed'] = ''; + $config['rand_seed_last_update'] = time() + 600; + + // Test 1: Invalid extension + $upload = new fileupload('', array('jpg'), 100); + $file = $upload->remote_upload('http://example.com/image.gif'); + $this->assertEquals(1, sizeof($file->error)); + + // Test 2: Non-existant file + $upload = new fileupload('', array('jpg'), 100); + $file = $upload->remote_upload('http://example.com/image.jpg'); + $this->assertEquals(1, sizeof($file->error)); + + // Test 3: File too large + $upload = new fileupload('', array('gif'), 100); + $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $this->assertEquals(1, sizeof($file->error)); + + // Test 4: Successful upload + $upload = new fileupload('', array('gif'), 1000); + $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $this->assertEquals(0, sizeof($file->error)); + $this->assertTrue(file_exists($file->filename)); + } +} diff --git a/tests/functional/fixtures/files/empty.png b/tests/functional/fixtures/files/empty.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/functional/fixtures/files/illegal-extension.bif b/tests/functional/fixtures/files/illegal-extension.bif new file mode 100644 index 0000000000..3cd5038e38 Binary files /dev/null and b/tests/functional/fixtures/files/illegal-extension.bif differ diff --git a/tests/functional/fixtures/files/too-large.png b/tests/functional/fixtures/files/too-large.png new file mode 100644 index 0000000000..ed4b0abd80 Binary files /dev/null and b/tests/functional/fixtures/files/too-large.png differ diff --git a/tests/functional/fixtures/files/valid.jpg b/tests/functional/fixtures/files/valid.jpg new file mode 100644 index 0000000000..95a87ddbdf Binary files /dev/null and b/tests/functional/fixtures/files/valid.jpg differ -- cgit v1.2.1 From 1233544c4a280e4392af448df654b5263e8c35db Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 25 Jun 2012 00:23:02 +0100 Subject: [ticket/10941] Marked broken test as incomplete PHPBB3-10941 --- tests/functional/fileupload_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php index ff62bad7bd..c06f7d94d7 100644 --- a/tests/functional/fileupload_test.php +++ b/tests/functional/fileupload_test.php @@ -14,6 +14,7 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case { public function test_form_upload() { + $this->markTestIncomplete(); $path = __DIR__ . '/fixtures/files/'; $this->add_lang('posting'); $this->login(); -- cgit v1.2.1 From 82ca2c8b08ca8c21b358ee8c862c639a5944977d Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sat, 30 Jun 2012 10:41:54 +0100 Subject: [ticket/10941] Minor adjustments as per PR comments Added some comments clarifying globals and lowercased fixture filenames PHPBB3-10941 --- tests/functional/fileupload_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php index c06f7d94d7..bbcc0c37c9 100644 --- a/tests/functional/fileupload_test.php +++ b/tests/functional/fileupload_test.php @@ -51,8 +51,14 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case public function test_remote_upload() { + // Note: we cannot check for the actual value of the error messages + // since they are passed through the translator which will result in + // blank strings within this test framework. + // Only doing this within the functional framework because we need a // URL + + // Global $config required by unique_id global $config; if (!is_array($config)) @@ -83,5 +89,7 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->filename)); + + $config = array(); } } -- cgit v1.2.1 From 59a7b10f1471ccd652d152578b6d027dcbc3fa7f Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 2 Jul 2012 22:44:33 +0100 Subject: [ticket/10941] Added a comment explaining the incomplete test PHPBB3-10941 --- tests/functional/fileupload_test.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php index bbcc0c37c9..1c40041cc5 100644 --- a/tests/functional/fileupload_test.php +++ b/tests/functional/fileupload_test.php @@ -14,7 +14,13 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case { public function test_form_upload() { + // This test is marked as incomplete due to an apparent bug in the + // symfony framework which causes it to lose the mimetype of any file + // uploaded. Since filespec::is_image() relies on the mimetype, all + // image uploads fail. filespec::is_image() is fixed in: + // https://github.com/phpbb/phpbb3/pull/833 $this->markTestIncomplete(); + $path = __DIR__ . '/fixtures/files/'; $this->add_lang('posting'); $this->login(); -- cgit v1.2.1 From 19405a7f47ea6d63eaf1cde3053c6b158c7b4dba Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 3 Jul 2012 00:32:50 +0100 Subject: [ticket/10941] Now actually checks for the value of errors. Uses phpbb_mock_lang to return the key used when setting errors to allow that key to be checked for during tests rather than just checking if any error was set. PHPBB3-10941 --- tests/functional/fileupload_test.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php index 1c40041cc5..ee89836c45 100644 --- a/tests/functional/fileupload_test.php +++ b/tests/functional/fileupload_test.php @@ -57,15 +57,12 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case public function test_remote_upload() { - // Note: we cannot check for the actual value of the error messages - // since they are passed through the translator which will result in - // blank strings within this test framework. - // Only doing this within the functional framework because we need a // URL // Global $config required by unique_id - global $config; + // Global $user required by fileupload::remote_upload + global $config, $user; if (!is_array($config)) { @@ -75,20 +72,23 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + // Test 1: Invalid extension $upload = new fileupload('', array('jpg'), 100); $file = $upload->remote_upload('http://example.com/image.gif'); - $this->assertEquals(1, sizeof($file->error)); + $this->assertEquals('URL_INVALID',$file->error[0]); // Test 2: Non-existant file $upload = new fileupload('', array('jpg'), 100); $file = $upload->remote_upload('http://example.com/image.jpg'); - $this->assertEquals(1, sizeof($file->error)); + $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); // Test 3: File too large $upload = new fileupload('', array('gif'), 100); $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); - $this->assertEquals(1, sizeof($file->error)); + $this->assertEquals('WRONG_FILESIZE', $file->error[0]); // Test 4: Successful upload $upload = new fileupload('', array('gif'), 1000); @@ -97,5 +97,6 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case $this->assertTrue(file_exists($file->filename)); $config = array(); + $user = null; } } -- cgit v1.2.1 From 61d74007a4b728f67c672561a8dd907e64de3070 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Tue, 3 Jul 2012 02:03:26 +0100 Subject: [ticket/10941] Minor typo fixes Removed superfluous $user = null; that was left over from refactoring. PHPBB3-10941 --- tests/functional/fileupload_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php index ee89836c45..44bb22da8f 100644 --- a/tests/functional/fileupload_test.php +++ b/tests/functional/fileupload_test.php @@ -78,7 +78,7 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case // Test 1: Invalid extension $upload = new fileupload('', array('jpg'), 100); $file = $upload->remote_upload('http://example.com/image.gif'); - $this->assertEquals('URL_INVALID',$file->error[0]); + $this->assertEquals('URL_INVALID', $file->error[0]); // Test 2: Non-existant file $upload = new fileupload('', array('jpg'), 100); -- cgit v1.2.1 From a4717ef525969427aac77eb077f28ee2d587126c Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sun, 8 Jul 2012 00:46:09 +0100 Subject: [ticket/10941] Removed the incomplete mark as is_image is fixed Had to remove one of the tests due to a small limitation with the functional testing framework. May mark the test as incomplete again pending further comments. PHPBB3-10941 --- tests/functional/fileupload_test.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php index 44bb22da8f..2abf81c457 100644 --- a/tests/functional/fileupload_test.php +++ b/tests/functional/fileupload_test.php @@ -14,13 +14,6 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case { public function test_form_upload() { - // This test is marked as incomplete due to an apparent bug in the - // symfony framework which causes it to lose the mimetype of any file - // uploaded. Since filespec::is_image() relies on the mimetype, all - // image uploads fail. filespec::is_image() is fixed in: - // https://github.com/phpbb/phpbb3/pull/833 - $this->markTestIncomplete(); - $path = __DIR__ . '/fixtures/files/'; $this->add_lang('posting'); $this->login(); @@ -30,21 +23,23 @@ class phpbb_functional_fileupload_test extends phpbb_functional_test_case $form = $crawler->selectButton('add_file')->form(); $form['fileupload']->upload($path . 'illegal-extension.bif'); $crawler = $this->client->submit($form); - $this->assertEquals(1, $crawler->filter('p.error')->count()); + $this->assertEquals('The extension bif is not allowed.', $crawler->filter('p.error')->text()); // Test 2: Empty file $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); $form = $crawler->selectButton('add_file')->form(); $form['fileupload']->upload($path . 'empty.png'); $crawler = $this->client->submit($form); - $this->assertEquals(1, $crawler->filter('p.error')->count()); + $this->assertEquals('The image file you tried to attach is invalid.', $crawler->filter('div#message p')->text()); // Test 3: File too large - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + // Cannot be tested by an admin account which this functional framework + // provides + /*$crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); $form = $crawler->selectButton('add_file')->form(); $form['fileupload']->upload($path . 'too-large.png'); $crawler = $this->client->submit($form); - $this->assertEquals(1, $crawler->filter('div#message')->count()); + $this->assertEquals(1, $crawler->filter('div#message')->count());*/ // Test 4: Valid file $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); -- cgit v1.2.1 From b65f08dd95de07405ed7f19fd980ca7d09925406 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sun, 8 Jul 2012 01:22:26 +0100 Subject: [ticket/10941] Rearranged tests into their own classes or methods PHPBB3-10941 --- tests/functional/fileupload_test.php | 97 ----------------------------- tests/functional/fileupload_test_form.php | 62 ++++++++++++++++++ tests/functional/fileupload_test_remote.php | 71 +++++++++++++++++++++ 3 files changed, 133 insertions(+), 97 deletions(-) delete mode 100644 tests/functional/fileupload_test.php create mode 100644 tests/functional/fileupload_test_form.php create mode 100644 tests/functional/fileupload_test_remote.php (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test.php b/tests/functional/fileupload_test.php deleted file mode 100644 index 2abf81c457..0000000000 --- a/tests/functional/fileupload_test.php +++ /dev/null @@ -1,97 +0,0 @@ -add_lang('posting'); - $this->login(); - - // Test 1: Invalid extension - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($path . 'illegal-extension.bif'); - $crawler = $this->client->submit($form); - $this->assertEquals('The extension bif is not allowed.', $crawler->filter('p.error')->text()); - - // Test 2: Empty file - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($path . 'empty.png'); - $crawler = $this->client->submit($form); - $this->assertEquals('The image file you tried to attach is invalid.', $crawler->filter('div#message p')->text()); - - // Test 3: File too large - // Cannot be tested by an admin account which this functional framework - // provides - /*$crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($path . 'too-large.png'); - $crawler = $this->client->submit($form); - $this->assertEquals(1, $crawler->filter('div#message')->count());*/ - - // Test 4: Valid file - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($path . 'valid.jpg'); - $crawler = $this->client->submit($form); - $this->assertEquals(0, $crawler->filter('p.error')->count()); - $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text()); - } - - public function test_remote_upload() - { - // Only doing this within the functional framework because we need a - // URL - - // Global $config required by unique_id - // Global $user required by fileupload::remote_upload - global $config, $user; - - if (!is_array($config)) - { - $config = array(); - } - - $config['rand_seed'] = ''; - $config['rand_seed_last_update'] = time() + 600; - - $user = new phpbb_mock_user(); - $user->lang = new phpbb_mock_lang(); - - // Test 1: Invalid extension - $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.gif'); - $this->assertEquals('URL_INVALID', $file->error[0]); - - // Test 2: Non-existant file - $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.jpg'); - $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); - - // Test 3: File too large - $upload = new fileupload('', array('gif'), 100); - $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); - $this->assertEquals('WRONG_FILESIZE', $file->error[0]); - - // Test 4: Successful upload - $upload = new fileupload('', array('gif'), 1000); - $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); - $this->assertEquals(0, sizeof($file->error)); - $this->assertTrue(file_exists($file->filename)); - - $config = array(); - $user = null; - } -} diff --git a/tests/functional/fileupload_test_form.php b/tests/functional/fileupload_test_form.php new file mode 100644 index 0000000000..48fa75ca4b --- /dev/null +++ b/tests/functional/fileupload_test_form.php @@ -0,0 +1,62 @@ +path = __DIR__ . '/fixtures/files/'; + $this->add_lang('posting'); + $this->login(); + } + + public function test_empty_file() + { + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($this->path . 'empty.png'); + $crawler = $this->client->submit($form); + $this->assertEquals('The image file you tried to attach is invalid.', $crawler->filter('div#message p')->text()); + } + + public function test_invalid_extension() + { + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($this->path . 'illegal-extension.bif'); + $crawler = $this->client->submit($form); + $this->assertEquals('The extension bif is not allowed.', $crawler->filter('p.error')->text()); + } + + public function test_too_large() + { + // Cannot be tested by an admin account which this functional framework + // provides + /*$crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($path . 'too-large.png'); + $crawler = $this->client->submit($form); + $this->assertEquals(1, $crawler->filter('div#message')->count());*/ + } + + public function test_valid_file() + { + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($this->path . 'valid.jpg'); + $crawler = $this->client->submit($form); + $this->assertEquals(0, $crawler->filter('p.error')->count()); + $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text()); + } +} diff --git a/tests/functional/fileupload_test_remote.php b/tests/functional/fileupload_test_remote.php new file mode 100644 index 0000000000..ac55a078d4 --- /dev/null +++ b/tests/functional/fileupload_test_remote.php @@ -0,0 +1,71 @@ +lang = new phpbb_mock_lang(); + } + + protected function tearDown() + { + global $config, $user; + $user = null; + $config = array(); + } + + public function test_invalid_extension() + { + $upload = new fileupload('', array('jpg'), 100); + $file = $upload->remote_upload('http://example.com/image.gif'); + $this->assertEquals('URL_INVALID', $file->error[0]); + } + + public function test_non_existant() + { + $upload = new fileupload('', array('jpg'), 100); + $file = $upload->remote_upload('http://example.com/image.jpg'); + $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); + } + + public function test_successful_upload() + { + $upload = new fileupload('', array('gif'), 1000); + $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $this->assertEquals(0, sizeof($file->error)); + $this->assertTrue(file_exists($file->filename)); + } + + public function test_too_large() + { + $upload = new fileupload('', array('gif'), 100); + $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $this->assertEquals('WRONG_FILESIZE', $file->error[0]); + } +} -- cgit v1.2.1 From 9f3a02d4755409407a26bf75324ac0a8a15d87e2 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 9 Jul 2012 00:10:41 +0100 Subject: [ticket/10941] Removed manual includes of mock classes Also marked a test as incomplete even though this appears to be ignored when actually running the tests. PHPBB3-10941 --- tests/functional/fileupload_test_form.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test_form.php b/tests/functional/fileupload_test_form.php index 48fa75ca4b..87979e6a68 100644 --- a/tests/functional/fileupload_test_form.php +++ b/tests/functional/fileupload_test_form.php @@ -43,11 +43,12 @@ class phpbb_functional_fileupload_test_form extends phpbb_functional_test_case { // Cannot be tested by an admin account which this functional framework // provides - /*$crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $this->markTestIncomplete(); + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); $form = $crawler->selectButton('add_file')->form(); $form['fileupload']->upload($path . 'too-large.png'); $crawler = $this->client->submit($form); - $this->assertEquals(1, $crawler->filter('div#message')->count());*/ + $this->assertEquals(1, $crawler->filter('div#message')->count()); } public function test_valid_file() -- cgit v1.2.1 From 6a1c686025067bc570921bf2618415a2f284b647 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 9 Jul 2012 00:36:03 +0100 Subject: [ticket/10941] Moved comment into markTestIncomplete parameter PHPBB3-10941 --- tests/functional/fileupload_test_form.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_test_form.php b/tests/functional/fileupload_test_form.php index 87979e6a68..2413cd01d2 100644 --- a/tests/functional/fileupload_test_form.php +++ b/tests/functional/fileupload_test_form.php @@ -41,9 +41,7 @@ class phpbb_functional_fileupload_test_form extends phpbb_functional_test_case public function test_too_large() { - // Cannot be tested by an admin account which this functional framework - // provides - $this->markTestIncomplete(); + $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.'); $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); $form = $crawler->selectButton('add_file')->form(); $form['fileupload']->upload($path . 'too-large.png'); -- cgit v1.2.1 From e0b63df6a4bb7d039e414ac3548ac9fb2e3a8358 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 9 Jul 2012 01:18:04 +0100 Subject: [ticket/10941] Renamed classes and filenames so that tests run Also fixed some minor issues that weren't flagged before because the tests were being ignored. PHPBB3-10941 --- tests/functional/fileupload_form_test.php | 62 +++++++++++++++++++++++++ tests/functional/fileupload_remote_test.php | 72 +++++++++++++++++++++++++++++ tests/functional/fileupload_test_form.php | 61 ------------------------ tests/functional/fileupload_test_remote.php | 71 ---------------------------- 4 files changed, 134 insertions(+), 132 deletions(-) create mode 100644 tests/functional/fileupload_form_test.php create mode 100644 tests/functional/fileupload_remote_test.php delete mode 100644 tests/functional/fileupload_test_form.php delete mode 100644 tests/functional/fileupload_test_remote.php (limited to 'tests/functional') diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php new file mode 100644 index 0000000000..3e1ba71a71 --- /dev/null +++ b/tests/functional/fileupload_form_test.php @@ -0,0 +1,62 @@ +path = __DIR__ . '/fixtures/files/'; + $this->add_lang('posting'); + $this->login(); + } + + public function test_empty_file() + { + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($this->path . 'empty.png'); + $crawler = $this->client->submit($form); + $this->assertEquals('The image file you tried to attach is invalid.', $crawler->filter('div#message p')->text()); + } + + public function test_invalid_extension() + { + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($this->path . 'illegal-extension.bif'); + $crawler = $this->client->submit($form); + $this->assertEquals('The extension bif is not allowed.', $crawler->filter('p.error')->text()); + } + + public function test_too_large() + { + $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.'); + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($path . 'too-large.png'); + $crawler = $this->client->submit($form); + $this->assertEquals(1, $crawler->filter('div#message')->count()); + } + + public function test_valid_file() + { + $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); + $form = $crawler->selectButton('add_file')->form(); + $form['fileupload']->upload($this->path . 'valid.jpg'); + $crawler = $this->client->submit($form); + $this->assertEquals(0, $crawler->filter('p.error')->count()); + $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text()); + } +} diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php new file mode 100644 index 0000000000..0deb79acf6 --- /dev/null +++ b/tests/functional/fileupload_remote_test.php @@ -0,0 +1,72 @@ +lang = new phpbb_mock_lang(); + } + + public function tearDown() + { + global $config, $user; + $user = null; + $config = array(); + } + + public function test_invalid_extension() + { + $upload = new fileupload('', array('jpg'), 100); + $file = $upload->remote_upload('http://example.com/image.gif'); + $this->assertEquals('URL_INVALID', $file->error[0]); + } + + public function test_non_existant() + { + $upload = new fileupload('', array('jpg'), 100); + $file = $upload->remote_upload('http://example.com/image.jpg'); + $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); + } + + public function test_successful_upload() + { + $upload = new fileupload('', array('gif'), 1000); + $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $this->assertEquals(0, sizeof($file->error)); + $this->assertTrue(file_exists($file->filename)); + } + + public function test_too_large() + { + $upload = new fileupload('', array('gif'), 100); + $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $this->assertEquals('WRONG_FILESIZE', $file->error[0]); + } +} diff --git a/tests/functional/fileupload_test_form.php b/tests/functional/fileupload_test_form.php deleted file mode 100644 index 2413cd01d2..0000000000 --- a/tests/functional/fileupload_test_form.php +++ /dev/null @@ -1,61 +0,0 @@ -path = __DIR__ . '/fixtures/files/'; - $this->add_lang('posting'); - $this->login(); - } - - public function test_empty_file() - { - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($this->path . 'empty.png'); - $crawler = $this->client->submit($form); - $this->assertEquals('The image file you tried to attach is invalid.', $crawler->filter('div#message p')->text()); - } - - public function test_invalid_extension() - { - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($this->path . 'illegal-extension.bif'); - $crawler = $this->client->submit($form); - $this->assertEquals('The extension bif is not allowed.', $crawler->filter('p.error')->text()); - } - - public function test_too_large() - { - $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.'); - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($path . 'too-large.png'); - $crawler = $this->client->submit($form); - $this->assertEquals(1, $crawler->filter('div#message')->count()); - } - - public function test_valid_file() - { - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($this->path . 'valid.jpg'); - $crawler = $this->client->submit($form); - $this->assertEquals(0, $crawler->filter('p.error')->count()); - $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text()); - } -} diff --git a/tests/functional/fileupload_test_remote.php b/tests/functional/fileupload_test_remote.php deleted file mode 100644 index ac55a078d4..0000000000 --- a/tests/functional/fileupload_test_remote.php +++ /dev/null @@ -1,71 +0,0 @@ -lang = new phpbb_mock_lang(); - } - - protected function tearDown() - { - global $config, $user; - $user = null; - $config = array(); - } - - public function test_invalid_extension() - { - $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.gif'); - $this->assertEquals('URL_INVALID', $file->error[0]); - } - - public function test_non_existant() - { - $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.jpg'); - $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); - } - - public function test_successful_upload() - { - $upload = new fileupload('', array('gif'), 1000); - $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); - $this->assertEquals(0, sizeof($file->error)); - $this->assertTrue(file_exists($file->filename)); - } - - public function test_too_large() - { - $upload = new fileupload('', array('gif'), 100); - $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif'); - $this->assertEquals('WRONG_FILESIZE', $file->error[0]); - } -} -- cgit v1.2.1 From 8d43a6e851bb6caceed6ab3b8a66ffb106c7317d Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 9 Jul 2012 01:24:29 +0100 Subject: [ticket/10941] Replaced use of English with language system PHPBB3-10941 --- tests/functional/fileupload_form_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index 3e1ba71a71..abccd6f987 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -28,7 +28,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $form = $crawler->selectButton('add_file')->form(); $form['fileupload']->upload($this->path . 'empty.png'); $crawler = $this->client->submit($form); - $this->assertEquals('The image file you tried to attach is invalid.', $crawler->filter('div#message p')->text()); + $this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $crawler->filter('div#message p')->text()); } public function test_invalid_extension() @@ -37,7 +37,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $form = $crawler->selectButton('add_file')->form(); $form['fileupload']->upload($this->path . 'illegal-extension.bif'); $crawler = $this->client->submit($form); - $this->assertEquals('The extension bif is not allowed.', $crawler->filter('p.error')->text()); + $this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text()); } public function test_too_large() -- cgit v1.2.1 From c8059cf7e70ab19f0fad21a7d42d1720392883a7 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 9 Jul 2012 01:29:56 +0100 Subject: [ticket/10941] Fixed form test test_too_large PHPBB3-10941 --- tests/functional/fileupload_form_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index abccd6f987..6ba55eeba7 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -45,9 +45,9 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.'); $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($path . 'too-large.png'); + $form['fileupload']->upload($this->path . 'too-large.png'); $crawler = $this->client->submit($form); - $this->assertEquals(1, $crawler->filter('div#message')->count()); + $this->assertEquals($this->lang('WRONG_FILESIZE', '256', 'KiB'), $crawler->filter('p.error')->text()); } public function test_valid_file() -- cgit v1.2.1 From 91050356d3b8322098650bf660c07f8a49ddb02d Mon Sep 17 00:00:00 2001 From: Fyorl Date: Thu, 12 Jul 2012 18:38:20 +0100 Subject: [ticket/10992] Modified upload tests to work with new version PHPBB3-10992 --- tests/functional/fileupload_form_test.php | 41 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index 6ba55eeba7..9c7bed359c 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -22,41 +22,48 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $this->login(); } + private function upload_file($filename, $mimetype) + { + $file = array( + 'tmp_name' => $this->path . $filename, + 'name' => $filename, + 'type' => $mimetype, + 'size' => filesize($this->path . $filename), + 'error' => UPLOAD_ERR_OK, + ); + + $crawler = $this->client->request( + 'POST', + 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid, + array('add_file' => $this->lang('ADD_FILE')), + array('fileupload' => $file) + ); + + return $crawler; + } + public function test_empty_file() { - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($this->path . 'empty.png'); - $crawler = $this->client->submit($form); + $crawler = $this->upload_file('empty.jpg', 'image/jpeg'); $this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $crawler->filter('div#message p')->text()); } public function test_invalid_extension() { - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($this->path . 'illegal-extension.bif'); - $crawler = $this->client->submit($form); + $crawler = $this->upload_file('illegal-extension.bif', 'application/octetstream'); $this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text()); } public function test_too_large() { $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.'); - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($this->path . 'too-large.png'); - $crawler = $this->client->submit($form); + $crawler = $this->upload_file('too-large.png', 'image/png'); $this->assertEquals($this->lang('WRONG_FILESIZE', '256', 'KiB'), $crawler->filter('p.error')->text()); } public function test_valid_file() { - $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid); - $form = $crawler->selectButton('add_file')->form(); - $form['fileupload']->upload($this->path . 'valid.jpg'); - $crawler = $this->client->submit($form); - $this->assertEquals(0, $crawler->filter('p.error')->count()); + $crawler = $this->upload_file('valid.jpg', 'image/jpeg'); $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text()); } } -- cgit v1.2.1 From e9a1189bfc75609de912bc5cb8c733f3323e58c6 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Fri, 13 Jul 2012 20:43:11 +0100 Subject: [ticket/10992] test_empty_file() now tries to upload the correct file PHPBB3-10992 --- tests/functional/fileupload_form_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index 9c7bed359c..00ff303591 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -44,7 +44,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case public function test_empty_file() { - $crawler = $this->upload_file('empty.jpg', 'image/jpeg'); + $crawler = $this->upload_file('empty.png', 'image/png'); $this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $crawler->filter('div#message p')->text()); } -- cgit v1.2.1 From fa4eaeb30668ada5d81aa8dcbac3246a3f59d05c Mon Sep 17 00:00:00 2001 From: Fyorl Date: Fri, 13 Jul 2012 20:09:11 +0100 Subject: [ticket/10992] Changed octetstream to octet-stream PHPBB3-10992 --- tests/functional/fileupload_form_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index 00ff303591..f7267fa659 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -50,7 +50,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case public function test_invalid_extension() { - $crawler = $this->upload_file('illegal-extension.bif', 'application/octetstream'); + $crawler = $this->upload_file('illegal-extension.bif', 'application/octet-stream'); $this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text()); } -- cgit v1.2.1 From 7cffebbd4997f8a41a871f8ea6fe12dc0abc08c8 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 19 Aug 2012 17:24:38 -0400 Subject: [task/functional] Added posting tests (reply and new topic) PHPBB-10758 --- tests/functional/posting_test.php | 110 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tests/functional/posting_test.php (limited to 'tests/functional') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php new file mode 100644 index 0000000000..8d722361e0 --- /dev/null +++ b/tests/functional/posting_test.php @@ -0,0 +1,110 @@ +login(); + $this->add_lang('posting'); + + $crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid); + $this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text()); + + $hidden_fields = array(); + $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) { + return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value')); + }); + + $test_message = 'This is a test topic posted by the testing framework.'; + $form_data = array( + 'subject' => 'Test Topic 1', + 'message' => $test_message, + 'post' => true, + 'f' => 2, + 'mode' => 'post', + 'sid' => $this->sid, + ); + + foreach ($hidden_fields as $fields) + { + foreach($fields as $field) + { + $form_data[$field['name']] = $field['value']; + } + } + + // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) + // is not at least 2 seconds before submission, cancel the form + $form_data['lastclick'] = 0; + + // The add_form_key()/check_form_key() safeguards present a challenge because they require + // the timestamp created in add_form_key() to be sent as-is to check_form_key() but in check_form_key() + // it won't allow the current time to be the same as the timestamp it requires. + // As such, automated scripts like this one have to somehow bypass this without being able to change + // the timestamp. The only way I can think to do so is using sleep() + sleep(1); + + // I use a request because the form submission method does not allow you to send data that is not + // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) + // Instead, I send it as a request with the submit button "post" set to true. + $crawler = $this->client->request('POST', 'posting.php', $form_data); + $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + + $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid); + $this->assertContains($test_message, $crawler->filter('html')->text()); + } + + public function test_post_reply() + { + $this->login(); + $this->add_lang('posting'); + + $crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid); + $this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text()); + + $hidden_fields = array(); + $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) { + return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value')); + }); + + $test_message = 'This is a test post posted by the testing framework.'; + $form_data = array( + 'subject' => 'Re: Test Topic 1', + 'message' => $test_message, + 'post' => true, + 't' => 2, + 'f' => 2, + 'mode' => 'reply', + 'sid' => $this->sid, + ); + + foreach ($hidden_fields as $fields) + { + foreach($fields as $field) + { + $form_data[$field['name']] = $field['value']; + } + } + + // For reasoning behind the following two commands, see the test_post_new_topic() test + $form_data['lastclick'] = 0; + sleep(1); + + // Submit the post + $crawler = $this->client->request('POST', 'posting.php', $form_data); + $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + + $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid); + $this->assertContains($test_message, $crawler->filter('html')->text()); + } +} -- cgit v1.2.1 From 7dfe26dd781e7bd0438041058e2a1d95176e7836 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 1 Sep 2012 10:35:46 -0400 Subject: [task/functional] Allow tests to bypass certain restrictions with DEBUG_TEST PHPBB3-10758 --- tests/functional/posting_test.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 8d722361e0..f54a3591b2 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -47,13 +47,6 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case // is not at least 2 seconds before submission, cancel the form $form_data['lastclick'] = 0; - // The add_form_key()/check_form_key() safeguards present a challenge because they require - // the timestamp created in add_form_key() to be sent as-is to check_form_key() but in check_form_key() - // it won't allow the current time to be the same as the timestamp it requires. - // As such, automated scripts like this one have to somehow bypass this without being able to change - // the timestamp. The only way I can think to do so is using sleep() - sleep(1); - // I use a request because the form submission method does not allow you to send data that is not // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) // Instead, I send it as a request with the submit button "post" set to true. @@ -96,9 +89,8 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case } } - // For reasoning behind the following two commands, see the test_post_new_topic() test + // For reasoning behind the following command, see the test_post_new_topic() test $form_data['lastclick'] = 0; - sleep(1); // Submit the post $crawler = $this->client->request('POST', 'posting.php', $form_data); -- cgit v1.2.1