From b7b0b0ccc3fbf92324948e8c5e616a3e06343600 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 May 2013 13:43:53 +0200 Subject: [ticket/11538] Make sure group color can't exceed maximum of 6 characters In order to prevent future issues with this, a basic set of functional tests for the UCP groups manage page have been added. PHPBB3-11538 --- tests/functional/ucp_groups_test.php | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/functional/ucp_groups_test.php (limited to 'tests/functional') diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php new file mode 100644 index 0000000000..010727cb55 --- /dev/null +++ b/tests/functional/ucp_groups_test.php @@ -0,0 +1,61 @@ +login(); + $this->add_lang(array('ucp', 'acp/groups')); + + $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['group_colour']->setValue('#AA0000'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $values = $form->getValues(); + $this->assertContains('AA0000', $values['group_colour']); + $form['group_colour']->setValue('AA0000'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $values = $form->getValues(); + $this->assertContains('AA0000', $values['group_colour']); + $form['group_colour']->setValue('AA0000v'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $values = $form->getValues(); + $this->assertContains('AA0000', $values['group_colour']); + $form['group_colour']->setValue('vAA0000'); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + + $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $values = $form->getValues(); + $this->assertContains('vAA000', $values['group_colour']); + } +} -- cgit v1.2.1 From a547ba3f9d569410107574a151af9a2f301bb68e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 May 2013 19:44:55 +0200 Subject: [ticket/11538] Use regex for testing color value and improve tests We are now using a regex with preg_match() in order to properly check if the entered color value is in hex color format or not. A proper error message is triggered if an incorrect color value is entered and the prepended '#' is removed if necessary. PHPBB3-11538 --- tests/functional/ucp_groups_test.php | 57 +++++++++++++----------------------- 1 file changed, 20 insertions(+), 37 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 010727cb55..f570c6af8d 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -12,50 +12,33 @@ */ class phpbb_functional_ucp_groups_test extends phpbb_functional_test_case { - public function test_groups_manage() + public function groups_manage_test_data() + { + return array( + array('#AA0000', 'GROUP_UPDATED'), + array('AA0000', 'GROUP_UPDATED'), + array('AA0000v', 'COLOUR_INVALID'), + array('vAA0000', 'COLOUR_INVALID'), + array('AAG000', 'COLOUR_INVALID'), + array('#a00', 'GROUP_UPDATED'), + array('ag0', 'COLOUR_INVALID'), + array('#ag0', 'COLOUR_INVALID'), + ); + } + + /** + * @dataProvider groups_manage_test_data + */ + public function test_groups_manage($input, $expected) { - $values = array(); $this->login(); $this->add_lang(array('ucp', 'acp/groups')); $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); $this->assert_response_success(); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['group_colour']->setValue('#AA0000'); - $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); - - $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $values = $form->getValues(); - $this->assertContains('AA0000', $values['group_colour']); - $form['group_colour']->setValue('AA0000'); - $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); - - $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $values = $form->getValues(); - $this->assertContains('AA0000', $values['group_colour']); - $form['group_colour']->setValue('AA0000v'); + $form['group_colour']->setValue($input); $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); - - $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $values = $form->getValues(); - $this->assertContains('AA0000', $values['group_colour']); - $form['group_colour']->setValue('vAA0000'); - $crawler = $this->client->submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); - - $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $values = $form->getValues(); - $this->assertContains('vAA000', $values['group_colour']); + $this->assertContains($this->lang($expected), $crawler->text()); } } -- cgit v1.2.1 From 1fae7720e43c8ff853225e16d0de54395d9ab051 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 May 2013 21:27:25 +0200 Subject: [ticket/11538] Fix incorrect regex and test for duplicate # in color string PHPBB3-11538 --- tests/functional/ucp_groups_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/functional') diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index f570c6af8d..d5ac6f697e 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -23,6 +23,7 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_test_case array('#a00', 'GROUP_UPDATED'), array('ag0', 'COLOUR_INVALID'), array('#ag0', 'COLOUR_INVALID'), + array('##bcc', 'COLOUR_INVALID'), ); } -- cgit v1.2.1 From deefe5c0e48534cea1327cf685255d109d9d7e2c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 May 2013 22:39:33 +0200 Subject: [ticket/11538] Simplify colour value check and remove support for '#' The input length for the hex color is now limited to 6 characters and the support for colors starting with a '#' has been dropped. The allowed input length of 7 in prosilver seems to have been a relict from old ages of phpBB3. In order to have proper support for correct checking of the colour value, the new code was also ported to the ACP groups manage page. The tests have been modified to reflect the changes to the behavior of the color check. Tests for the ACP will follow. PHPBB3-11538 --- tests/functional/ucp_groups_test.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index d5ac6f697e..7a315c2018 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -15,15 +15,14 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_test_case public function groups_manage_test_data() { return array( - array('#AA0000', 'GROUP_UPDATED'), + array('#AA0000', 'WRONG_DATA_COLOUR'), array('AA0000', 'GROUP_UPDATED'), - array('AA0000v', 'COLOUR_INVALID'), - array('vAA0000', 'COLOUR_INVALID'), - array('AAG000', 'COLOUR_INVALID'), - array('#a00', 'GROUP_UPDATED'), - array('ag0', 'COLOUR_INVALID'), - array('#ag0', 'COLOUR_INVALID'), - array('##bcc', 'COLOUR_INVALID'), + array('AA0000v', 'WRONG_DATA_COLOUR'), + array('vAA0000', 'WRONG_DATA_COLOUR'), + array('AAG000','WRONG_DATA_COLOUR'), + array('a00', 'GROUP_UPDATED'), + array('ag0', 'WRONG_DATA_COLOUR'), + array('#aa0', 'WRONG_DATA_COLOUR'), ); } -- cgit v1.2.1 From cbe4a3c3b6a2b21aeff179ee8452fb705d05369b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 May 2013 22:50:17 +0200 Subject: [ticket/11538] Add tests for acp group manage page This will currently test if the colour check properly works. PHPBB3-11538 --- tests/functional/acp_groups_test.php | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/functional/acp_groups_test.php (limited to 'tests/functional') diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php new file mode 100644 index 0000000000..152f05c7a7 --- /dev/null +++ b/tests/functional/acp_groups_test.php @@ -0,0 +1,45 @@ +login(); + $this->admin_login(); + $this->add_lang(array('ucp', 'acp/groups')); + + $crawler = $this->request('GET', 'adm/index.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['group_colour']->setValue($input); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang($expected), $crawler->text()); + } +} -- cgit v1.2.1 From 204cdb21640aead9f7560034bb8e686c17707476 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 15 May 2013 12:30:05 +0200 Subject: [ticket/11538] Make sure regex doesn't allow multiple color values This will now make sure that 'AAFF00' will be matched but strings like 'AAFF00 AABB00' will not. PHPBB3-11538 --- tests/functional/acp_groups_test.php | 3 +++ tests/functional/ucp_groups_test.php | 3 +++ 2 files changed, 6 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php index 152f05c7a7..9a85e9ec67 100644 --- a/tests/functional/acp_groups_test.php +++ b/tests/functional/acp_groups_test.php @@ -23,6 +23,9 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_test_case array('a00', 'GROUP_UPDATED'), array('ag0', 'WRONG_DATA_COLOUR'), array('#aa0', 'WRONG_DATA_COLOUR'), + array('AA0000 ', 'GROUP_UPDATED'), + array('AA0000 abf', 'WRONG_DATA_COLOUR'), + array('AA0000 AA0000', 'WRONG_DATA_COLOUR'), ); } diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 7a315c2018..ae568e8182 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -23,6 +23,9 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_test_case array('a00', 'GROUP_UPDATED'), array('ag0', 'WRONG_DATA_COLOUR'), array('#aa0', 'WRONG_DATA_COLOUR'), + array('AA0000 ', 'GROUP_UPDATED'), + array('AA0000 abf', 'WRONG_DATA_COLOUR'), + array('AA0000 AA0000', 'WRONG_DATA_COLOUR'), ); } -- cgit v1.2.1 From 0a5988ec1f3d72afb17b87d6cd74f60b646bae42 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 17 May 2013 12:32:09 +0200 Subject: [ticket/11538] Use abstract class for functional test cases for group colour PHPBB3-11538 --- tests/functional/acp_groups_test.php | 37 ++++-------------------- tests/functional/common_groups_test.php | 50 +++++++++++++++++++++++++++++++++ tests/functional/ucp_groups_test.php | 36 ++++-------------------- 3 files changed, 60 insertions(+), 63 deletions(-) create mode 100644 tests/functional/common_groups_test.php (limited to 'tests/functional') diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php index 9a85e9ec67..8b45bea7a6 100644 --- a/tests/functional/acp_groups_test.php +++ b/tests/functional/acp_groups_test.php @@ -7,42 +7,15 @@ * */ +require_once dirname(__FILE__) . '/common_groups_test.php'; + /** * @group functional */ -class phpbb_functional_acp_groups_test extends phpbb_functional_test_case +class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test { - public function groups_manage_test_data() + protected function get_url() { - return array( - array('#AA0000', 'WRONG_DATA_COLOUR'), - array('AA0000', 'GROUP_UPDATED'), - array('AA0000v', 'WRONG_DATA_COLOUR'), - array('vAA0000', 'WRONG_DATA_COLOUR'), - array('AAG000','WRONG_DATA_COLOUR'), - array('a00', 'GROUP_UPDATED'), - array('ag0', 'WRONG_DATA_COLOUR'), - array('#aa0', 'WRONG_DATA_COLOUR'), - array('AA0000 ', 'GROUP_UPDATED'), - array('AA0000 abf', 'WRONG_DATA_COLOUR'), - array('AA0000 AA0000', 'WRONG_DATA_COLOUR'), - ); - } - - /** - * @dataProvider groups_manage_test_data - */ - public function test_groups_manage($input, $expected) - { - $this->login(); - $this->admin_login(); - $this->add_lang(array('ucp', 'acp/groups')); - - $crawler = $this->request('GET', 'adm/index.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['group_colour']->setValue($input); - $crawler = $this->client->submit($form); - $this->assertContains($this->lang($expected), $crawler->text()); + return 'adm/index.php?i=groups&mode=manage&action=edit&g=5'; } } diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php new file mode 100644 index 0000000000..3061bf7510 --- /dev/null +++ b/tests/functional/common_groups_test.php @@ -0,0 +1,50 @@ +login(); + $this->admin_login(); + $this->add_lang(array('ucp', 'acp/groups')); + + $crawler = $this->request('GET', $this->get_url() . '&sid=' . $this->sid); + $this->assert_response_success(); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['group_colour']->setValue($input); + $crawler = $this->client->submit($form); + $this->assertContains($this->lang($expected), $crawler->text()); + } +} diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index ae568e8182..8401cfdb09 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -7,41 +7,15 @@ * */ +require_once dirname(__FILE__) . '/common_groups_test.php'; + /** * @group functional */ -class phpbb_functional_ucp_groups_test extends phpbb_functional_test_case +class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test { - public function groups_manage_test_data() + protected function get_url() { - return array( - array('#AA0000', 'WRONG_DATA_COLOUR'), - array('AA0000', 'GROUP_UPDATED'), - array('AA0000v', 'WRONG_DATA_COLOUR'), - array('vAA0000', 'WRONG_DATA_COLOUR'), - array('AAG000','WRONG_DATA_COLOUR'), - array('a00', 'GROUP_UPDATED'), - array('ag0', 'WRONG_DATA_COLOUR'), - array('#aa0', 'WRONG_DATA_COLOUR'), - array('AA0000 ', 'GROUP_UPDATED'), - array('AA0000 abf', 'WRONG_DATA_COLOUR'), - array('AA0000 AA0000', 'WRONG_DATA_COLOUR'), - ); - } - - /** - * @dataProvider groups_manage_test_data - */ - public function test_groups_manage($input, $expected) - { - $this->login(); - $this->add_lang(array('ucp', 'acp/groups')); - - $crawler = $this->request('GET', 'ucp.php?i=groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assert_response_success(); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['group_colour']->setValue($input); - $crawler = $this->client->submit($form); - $this->assertContains($this->lang($expected), $crawler->text()); + return 'ucp.php?i=groups&mode=manage&action=edit&g=5'; } } -- cgit v1.2.1 From 8aea2b382dcb57f67704dec5194378d9a76c127e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 19 May 2013 11:44:26 +0200 Subject: [ticket/11538] Move group ID into abstract test class and add more test cases The group ID is defined in the abstract class now and additional test cases for hex colour values have been added. PHPBB3-11538 --- tests/functional/acp_groups_test.php | 2 +- tests/functional/common_groups_test.php | 6 +++++- tests/functional/ucp_groups_test.php | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php index 8b45bea7a6..3d8cabb086 100644 --- a/tests/functional/acp_groups_test.php +++ b/tests/functional/acp_groups_test.php @@ -16,6 +16,6 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te { protected function get_url() { - return 'adm/index.php?i=groups&mode=manage&action=edit&g=5'; + return 'adm/index.php?i=groups&mode=manage&action=edit'; } } diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php index 3061bf7510..985dbc9220 100644 --- a/tests/functional/common_groups_test.php +++ b/tests/functional/common_groups_test.php @@ -20,6 +20,7 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test array('#AA0000', 'WRONG_DATA_COLOUR'), array('AA0000', 'GROUP_UPDATED'), array('AA0000v', 'WRONG_DATA_COLOUR'), + array('AA00000', 'WRONG_DATA_COLOUR'), array('vAA0000', 'WRONG_DATA_COLOUR'), array('AAG000','WRONG_DATA_COLOUR'), array('a00', 'GROUP_UPDATED'), @@ -28,6 +29,8 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test array('AA0000 ', 'GROUP_UPDATED'), array('AA0000 abf', 'WRONG_DATA_COLOUR'), array('AA0000 AA0000', 'WRONG_DATA_COLOUR'), + array('000 ', 'GROUP_UPDATED'), + array('000000 ', 'GROUP_UPDATED'), ); } @@ -40,7 +43,8 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test $this->admin_login(); $this->add_lang(array('ucp', 'acp/groups')); - $crawler = $this->request('GET', $this->get_url() . '&sid=' . $this->sid); + // Manage Administrators group + $crawler = $this->request('GET', $this->get_url() . '&g=5&sid=' . $this->sid); $this->assert_response_success(); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form['group_colour']->setValue($input); diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 8401cfdb09..9c6b1edc5e 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -16,6 +16,6 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te { protected function get_url() { - return 'ucp.php?i=groups&mode=manage&action=edit&g=5'; + return 'ucp.php?i=groups&mode=manage&action=edit'; } } -- cgit v1.2.1 From e49b4543de7c18df7e9b5c70ef5064cc4de9934a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 19 May 2013 15:17:47 +0200 Subject: [ticket/11538] Modify test colour values PHPBB3-11538 --- tests/functional/common_groups_test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php index 985dbc9220..02a538d46e 100644 --- a/tests/functional/common_groups_test.php +++ b/tests/functional/common_groups_test.php @@ -29,8 +29,9 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test array('AA0000 ', 'GROUP_UPDATED'), array('AA0000 abf', 'WRONG_DATA_COLOUR'), array('AA0000 AA0000', 'WRONG_DATA_COLOUR'), - array('000 ', 'GROUP_UPDATED'), - array('000000 ', 'GROUP_UPDATED'), + array('', 'GROUP_UPDATED'), + array('000', 'GROUP_UPDATED'), + array('000000', 'GROUP_UPDATED'), ); } -- cgit v1.2.1