From 84c815a12e7c2c816035e3b05e8ea7c88f0f4534 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sat, 13 Apr 2013 11:24:47 -0400 Subject: [ticket/11458] Add functional test Since there is no test method to include extension language files, a functional test seems more appropriate. We add a permission mask 'acl_u_foo' with translation found in extenion 'bar' and confirm that the permission language file 'permissions_foo.php' from 'bar' was added by asserting that 'Can view foo' exists when viewing user permissions in acp PHPBB3-11458 --- .../functional/extension_permission_lang_test.php | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/functional/extension_permission_lang_test.php (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php new file mode 100644 index 0000000000..c3d136de49 --- /dev/null +++ b/tests/functional/extension_permission_lang_test.php @@ -0,0 +1,59 @@ +phpbb_extension_manager = $this->get_extension_manager(); + + $this->purge_cache(); + + $this->login(); + $this->admin_login(); + $this->add_lang('acp/permissions'); + } + + public function test_auto_include_permission_lang_from_extensions() + { + $this->phpbb_extension_manager->enable('foo/bar'); + + // User permissions + $crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid); + $this->assert_response_success(); + $this->assertContains('Can view foo', $this->client->getResponse()->getContent()); + } + + public function permissions_data() + { + return array( + // description + // permission type + // permission name + // mode + // object name + // object id + array( + 'user permission', + 'u_', + 'acl_u_foo', + 'setting_user_global', + 'user_id', + 2, + ), + ); + } +} -- cgit v1.2.1 From 2c910999b090502cf6a3ac2add68de763ea897ca Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sat, 13 Apr 2013 13:56:02 -0400 Subject: [ticket/11458] Fix test PHPBB-11458 --- tests/functional/extension_permission_lang_test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index c3d136de49..1368a628d8 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -34,7 +34,14 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t // User permissions $crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid); $this->assert_response_success(); - $this->assertContains('Can view foo', $this->client->getResponse()->getContent()); + + // Select admin + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $data = array('username[0]' => 'admin'); + $form->setValues($data); + $crawler = $this->client->submit($form); + $this->assert_response_success(); + $this->assertContains('Can view foo', $crawler->filter('body')->text()); } public function permissions_data() -- cgit v1.2.1 From 9e2acdab9aea7762761e81b3306a950ab627434d Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sun, 14 Apr 2013 17:53:38 -0400 Subject: [ticket/11458] Fix functional test again Add 'u_foo' to phpbb_acl_options Make sure extension and fixtures are added before running test PHPBB3-11458 --- .../functional/extension_permission_lang_test.php | 84 ++++++++++++++++------ 1 file changed, 64 insertions(+), 20 deletions(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 1368a628d8..234cbbbaf2 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -14,9 +14,73 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t { protected $phpbb_extension_manager; + static protected $fixtures = array( + 'foo/bar/language/en/permissions_foo.php', + ); + + /** + * 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() + { + global $phpbb_root_path; + parent::setUpBeforeClass(); + + $directories = array( + $phpbb_root_path . 'ext/foo/bar/', + $phpbb_root_path . 'ext/foo/bar/language/', + $phpbb_root_path . 'ext/foo/bar/language/en/', + ); + + foreach ($directories as $dir) + { + if (!is_dir($dir)) + { + mkdir($dir, 0777, true); + } + } + + foreach (self::$fixtures as $fixture) + { + copy( + "tests/functional/fixtures/ext/$fixture", + "{$phpbb_root_path}ext/$fixture"); + } + } + + /** + * This should only be called once after the tests are run. + * This is used to remove the fixtures from the phpBB install + */ + static public function tearDownAfterClass() + { + global $phpbb_root_path; + + foreach (self::$fixtures as $fixture) + { + unlink("{$phpbb_root_path}ext/$fixture"); + } + + rmdir("{$phpbb_root_path}ext/foo/bar/language/en"); + rmdir("{$phpbb_root_path}ext/foo/bar/language"); + rmdir("{$phpbb_root_path}ext/foo/bar"); + rmdir("{$phpbb_root_path}ext/foo"); + } + public function setUp() { parent::setUp(); + + $this->get_db(); + + $acl_ary = array( + 'auth_option' => 'u_foo', + 'is_global' => 1, + ); + + $sql = 'INSERT INTO phpbb_acl_options ' . $this->db->sql_build_array('INSERT', $acl_ary); + $this->db->sql_query($sql); $this->phpbb_extension_manager = $this->get_extension_manager(); @@ -43,24 +107,4 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $this->assert_response_success(); $this->assertContains('Can view foo', $crawler->filter('body')->text()); } - - public function permissions_data() - { - return array( - // description - // permission type - // permission name - // mode - // object name - // object id - array( - 'user permission', - 'u_', - 'acl_u_foo', - 'setting_user_global', - 'user_id', - 2, - ), - ); - } } -- cgit v1.2.1 From 109b1a3a952f8a590f6613c8d940e6d01b755af7 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Thu, 9 May 2013 23:12:19 -0400 Subject: [ticket/11458] Use helper to create/move/delete directories/files PHPBB3-11458 --- .../functional/extension_permission_lang_test.php | 51 ++++++++++++---------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 234cbbbaf2..6f1048279a 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -14,8 +14,12 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t { protected $phpbb_extension_manager; + static private $helper; + + static private $copied_files = array(); + static protected $fixtures = array( - 'foo/bar/language/en/permissions_foo.php', + 'foo/bar/language/en/', ); /** @@ -27,26 +31,21 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t global $phpbb_root_path; parent::setUpBeforeClass(); - $directories = array( - $phpbb_root_path . 'ext/foo/bar/', - $phpbb_root_path . 'ext/foo/bar/language/', - $phpbb_root_path . 'ext/foo/bar/language/en/', - ); + self::$helper = new phpbb_test_case_helpers(self); - foreach ($directories as $dir) - { - if (!is_dir($dir)) - { - mkdir($dir, 0777, true); - } - } + self::$copied_files = array(); - foreach (self::$fixtures as $fixture) + if (file_exists($phpbb_root_path . 'ext/')) { - copy( - "tests/functional/fixtures/ext/$fixture", - "{$phpbb_root_path}ext/$fixture"); + // First, move any extensions setup on the board to a temp directory + self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/'); + + // Then empty the ext/ directory on the board (for accurate test cases) + self::$helper->empty_dir($phpbb_root_path . 'ext/'); } + + // Copy our ext/ files from the test case to the board + self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture)); } /** @@ -56,16 +55,20 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static public function tearDownAfterClass() { global $phpbb_root_path; - - foreach (self::$fixtures as $fixture) + + if (file_exists($phpbb_root_path . 'store/temp_ext/')) { - unlink("{$phpbb_root_path}ext/$fixture"); + // Copy back the board installed extensions from the temp directory + self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/'); } - rmdir("{$phpbb_root_path}ext/foo/bar/language/en"); - rmdir("{$phpbb_root_path}ext/foo/bar/language"); - rmdir("{$phpbb_root_path}ext/foo/bar"); - rmdir("{$phpbb_root_path}ext/foo"); + // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext) + self::$helper->remove_files(self::$copied_files); + + if (file_exists($phpbb_root_path . 'store/temp_ext/')) + { + self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/'); + } } public function setUp() -- cgit v1.2.1 From 48e1be58db26ba09f7421082038f1f6353a38e91 Mon Sep 17 00:00:00 2001 From: OpenShift guest Date: Sat, 11 May 2013 02:38:40 -0400 Subject: [ticket/11458] Update functional test Show that the phpbb permission lanuage file is being included PHPBB3-11458 --- tests/functional/extension_permission_lang_test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 6f1048279a..26ec4d28a1 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -108,6 +108,11 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $form->setValues($data); $crawler = $this->client->submit($form); $this->assert_response_success(); + + // language from language/en/acp/permissions_phpbb.php + $this->assertContains('Can attach files', $crawler->filter('body')->text()); + + // language from ext/foo/bar/language/en/permissions_foo.php $this->assertContains('Can view foo', $crawler->filter('body')->text()); } } -- cgit v1.2.1 From 467c4d62c44a32a1a60bed2e2a2519b10cdebd33 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 28 May 2013 14:55:04 +0200 Subject: [ticket/develop/11568] Do not directly access $client from tests PHPBB3-11568 --- tests/functional/extension_permission_lang_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 26ec4d28a1..4e40b11560 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -106,7 +106,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $data = array('username[0]' => 'admin'); $form->setValues($data); - $crawler = $this->client->submit($form); + $crawler = $this->submit($form); $this->assert_response_success(); // language from language/en/acp/permissions_phpbb.php -- cgit v1.2.1 From f1523944a048e22207d6f200c6d152ecb9fdc136 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 28 May 2013 14:58:40 +0200 Subject: [ticket/develop/11568] Remove unneccessary calls to assert_response_success() PHPBB3-11568 --- tests/functional/extension_permission_lang_test.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 4e40b11560..c1ceae382d 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -100,14 +100,12 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t // User permissions $crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid); - $this->assert_response_success(); // Select admin $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $data = array('username[0]' => 'admin'); $form->setValues($data); $crawler = $this->submit($form); - $this->assert_response_success(); // language from language/en/acp/permissions_phpbb.php $this->assertContains('Can attach files', $crawler->filter('body')->text()); -- cgit v1.2.1 From 35064086377c3f3334e02ca153b008b0502fbdee Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 8 Jun 2013 15:26:35 +0200 Subject: [ticket/11550] Fix copying the fixtures in extension_permission_lang_test.php PHPBB3-11550 --- tests/functional/extension_permission_lang_test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 9a251e8645..04c3a9d497 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -45,7 +45,10 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t } // Copy our ext/ files from the test case to the board - self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture)); + foreach (self::$fixtures as $fixture) + { + self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture)); + } } /** -- cgit v1.2.1 From a61ab1e5e4bbe786d3f500438bb0dd6ca395989e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 8 Jun 2013 17:02:31 +0200 Subject: [ticket/11550] Use new functionality from the test case helpers Instead of duplicating the extension copy code, it is now in the helpers. So we remove the code from existing tests. PHPBB3-11550 --- .../functional/extension_permission_lang_test.php | 39 +++------------------- 1 file changed, 4 insertions(+), 35 deletions(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 04c3a9d497..fe8ea95cf0 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -16,8 +16,6 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static private $helper; - static private $copied_files = array(); - static protected $fixtures = array( 'foo/bar/language/en/', ); @@ -28,27 +26,10 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t */ static public function setUpBeforeClass() { - global $phpbb_root_path; parent::setUpBeforeClass(); self::$helper = new phpbb_test_case_helpers(self); - - self::$copied_files = array(); - - if (file_exists($phpbb_root_path . 'ext/')) - { - // First, move any extensions setup on the board to a temp directory - self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/'); - - // Then empty the ext/ directory on the board (for accurate test cases) - self::$helper->empty_dir($phpbb_root_path . 'ext/'); - } - - // Copy our ext/ files from the test case to the board - foreach (self::$fixtures as $fixture) - { - self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture)); - } + self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } /** @@ -57,21 +38,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t */ static public function tearDownAfterClass() { - global $phpbb_root_path; - - if (file_exists($phpbb_root_path . 'store/temp_ext/')) - { - // Copy back the board installed extensions from the temp directory - self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/'); - } - - // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext) - self::$helper->remove_files(self::$copied_files); - - if (file_exists($phpbb_root_path . 'store/temp_ext/')) - { - self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/'); - } + parent::tearDownAfterClass(); + + self::$helper->restore_original_ext_dir(); } public function setUp() -- cgit v1.2.1 From 68d15f0f14dfdc827e1169a73c194a9e30795605 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Jun 2013 11:14:24 +0200 Subject: [ticket/11550] Move comments to correct function PHPBB3-11550 --- tests/functional/extension_permission_lang_test.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index fe8ea95cf0..6c1720735c 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -20,10 +20,6 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t 'foo/bar/language/en/', ); - /** - * 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(); @@ -32,10 +28,6 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } - /** - * This should only be called once after the tests are run. - * This is used to remove the fixtures from the phpBB install - */ static public function tearDownAfterClass() { parent::tearDownAfterClass(); -- cgit v1.2.1 From e4a5ce307d49c215b08e35a79147ba2418f133ff Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 12:55:03 -0400 Subject: [ticket/11582] Test the event and and fix it. PHPBB3-11582 --- tests/functional/extension_permission_lang_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 6c1720735c..badbdbb057 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -75,6 +75,6 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $this->assertContains('Can attach files', $crawler->filter('body')->text()); // language from ext/foo/bar/language/en/permissions_foo.php - $this->assertContains('Can view foo', $crawler->filter('body')->text()); + $this->assertContains('Can view foobar', $crawler->filter('body')->text()); } } -- cgit v1.2.1 From d6a747fbd0f80e9f2c93f09aab6a0a89ec5afd26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jul 2013 17:27:15 +0200 Subject: [ticket/11582] Correctly add all required fixtures PHPBB3-11582 --- tests/functional/extension_permission_lang_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index badbdbb057..19adb89819 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -18,6 +18,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static protected $fixtures = array( 'foo/bar/language/en/', + 'foo/bar/event/', ); static public function setUpBeforeClass() -- cgit v1.2.1 From 4e2bb6ef535a5188aeda6d04286b6b9bb8825c72 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Nov 2013 00:14:53 +0100 Subject: [ticket/12017] Copy config/ dir so events work PHPBB3-12017 --- tests/functional/extension_permission_lang_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 19adb89819..e922abdaf1 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -17,8 +17,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static private $helper; static protected $fixtures = array( - 'foo/bar/language/en/', + 'foo/bar/config/', 'foo/bar/event/', + 'foo/bar/language/en/', ); static public function setUpBeforeClass() -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- tests/functional/extension_permission_lang_test.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/functional/extension_permission_lang_test.php') diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index e922abdaf1..92d8d596c7 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1