mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 08:47:45 +02:00
[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
This commit is contained in:
@@ -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');
|
||||
$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('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']);
|
||||
$this->assertContains($this->lang($expected), $crawler->text());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user