diff options
| author | David King <imkingdavid@gmail.com> | 2012-09-01 16:38:47 -0400 |
|---|---|---|
| committer | David King <imkingdavid@gmail.com> | 2012-09-01 16:38:47 -0400 |
| commit | 7bf598954c452448c2807428f6517cd75d910f92 (patch) | |
| tree | 1a8ba768a01b36e8fb1159b996383d935fb8b352 /tests/test_framework/phpbb_functional_test_case.php | |
| parent | 43190ebecaeadbc8738da9dcb33b9163652fb9f3 (diff) | |
| parent | 81f7f28cc33d896973c2912097103ea84fa14114 (diff) | |
| download | forums-7bf598954c452448c2807428f6517cd75d910f92.tar forums-7bf598954c452448c2807428f6517cd75d910f92.tar.gz forums-7bf598954c452448c2807428f6517cd75d910f92.tar.bz2 forums-7bf598954c452448c2807428f6517cd75d910f92.tar.xz forums-7bf598954c452448c2807428f6517cd75d910f92.zip | |
Merge remote-tracking branch 'unknownbliss/ticket/10631' into develop
Diffstat (limited to 'tests/test_framework/phpbb_functional_test_case.php')
| -rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index fca66516ba..d002615e8c 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -125,6 +125,7 @@ class phpbb_functional_test_case extends phpbb_test_case { $this->extension_manager = new phpbb_extension_manager( $this->get_db(), + new phpbb_config(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", @@ -251,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)) @@ -287,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); + } } |
