1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/10631] Functional acp_extensions test, cleanup

PHPBB3-10631
This commit is contained in:
Nathan Guse
2012-07-29 20:08:30 -05:00
committed by Unknown Bliss
parent 500879520c
commit 36465c9a20
8 changed files with 481 additions and 72 deletions

View File

@@ -252,6 +252,48 @@ class phpbb_functional_test_case extends phpbb_test_case
}
}
/**
* Login to the ACP
* You must run login() before calling this.
*/
protected function admin_login()
{
$this->add_lang('acp/common');
// Requires login first!
if (empty($this->sid))
{
$this->fail('$this->sid is empty. Make sure you call login() before admin_login()');
return;
}
$crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid);
$this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
foreach ($form->getValues() as $field => $value)
{
if (strpos($field, 'password_') === 0)
{
$login = $this->client->submit($form, array('username' => 'admin', $field => 'admin'));
$cookies = $this->cookieJar->all();
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
foreach ($cookies as $cookie);
{
if (substr($cookie->getName(), -4) == '_sid')
{
$this->sid = $cookie->getValue();
}
}
break;
}
}
}
protected function add_lang($lang_file)
{
if (is_array($lang_file))
@@ -288,4 +330,16 @@ class phpbb_functional_test_case extends phpbb_test_case
return call_user_func_array('sprintf', $args);
}
/**
* assertContains for language strings
*
* @param string $needle Search string
* @param string $haystack Search this
* @param string $message Optional failure message
*/
public function assertContainsLang($needle, $haystack, $message = null)
{
$this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
}
}