diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-05-14 19:44:55 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-05-14 19:44:55 +0200 |
commit | a547ba3f9d569410107574a151af9a2f301bb68e (patch) | |
tree | 215f6f6bd13471a09f0ff3d55e3bccb174700f5f /tests/functional | |
parent | b7b0b0ccc3fbf92324948e8c5e616a3e06343600 (diff) | |
download | forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar.gz forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar.bz2 forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar.xz forums-a547ba3f9d569410107574a151af9a2f301bb68e.zip |
[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
Diffstat (limited to 'tests/functional')
-rw-r--r-- | tests/functional/ucp_groups_test.php | 57 |
1 files changed, 20 insertions, 37 deletions
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()); } } |