aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2013-05-17 01:29:47 +0200
committerAndreas Fischer <bantu@phpbb.com>2013-05-17 01:29:47 +0200
commit555e89755eef444d9b8a6ed1b840b98dfb9d3813 (patch)
tree0014c4b4128f134f23be2cae29769f06cf352c91
parentf2fd0031f4ee9b254d2281ae8b9ce36c3ad26143 (diff)
parentac8e8a156a771cabcd73859f1c2235c89257e76b (diff)
downloadforums-555e89755eef444d9b8a6ed1b840b98dfb9d3813.tar
forums-555e89755eef444d9b8a6ed1b840b98dfb9d3813.tar.gz
forums-555e89755eef444d9b8a6ed1b840b98dfb9d3813.tar.bz2
forums-555e89755eef444d9b8a6ed1b840b98dfb9d3813.tar.xz
forums-555e89755eef444d9b8a6ed1b840b98dfb9d3813.zip
Merge remote-tracking branch 'marc1706/ticket/11544' into develop-olympus
* marc1706/ticket/11544: [ticket/11544] Add admin_login() method to 3.0 functional test case
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 83c931f924..b1352b247e 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -299,6 +299,50 @@ class phpbb_functional_test_case extends phpbb_test_case
}
}
+ /**
+ * Login to the ACP
+ * You must run login() before calling this.
+ */
+ protected function admin_login($username = 'admin')
+ {
+ $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)
+ {
+ $crawler = $this->client->submit($form, array('username' => $username, $field => $username));
+ $this->assert_response_success();
+ $this->assertContains($this->lang('LOGIN_ADMIN_SUCCESS'), $crawler->filter('html')->text());
+
+ $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))