diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-05-17 12:22:27 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-05-17 12:22:27 +0200 |
commit | 30e0b694e606792c772de553ba708d4cc409b416 (patch) | |
tree | 6d9bc66564aac9af9f075d1f31fafb8cb3011fff /tests/test_framework/phpbb_functional_test_case.php | |
parent | 1715619fda2aebd7ebae960e5fcbdf4b24ce4dca (diff) | |
parent | 37a334c187e382fcbaee717bc3df91ef9ce82e10 (diff) | |
download | forums-30e0b694e606792c772de553ba708d4cc409b416.tar forums-30e0b694e606792c772de553ba708d4cc409b416.tar.gz forums-30e0b694e606792c772de553ba708d4cc409b416.tar.bz2 forums-30e0b694e606792c772de553ba708d4cc409b416.tar.xz forums-30e0b694e606792c772de553ba708d4cc409b416.zip |
Merge branch 'develop-olympus' of https://github.com/phpbb/phpbb3 into ticket/11538
Diffstat (limited to 'tests/test_framework/phpbb_functional_test_case.php')
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 44 |
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)) |