aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework/phpbb_functional_test_case.php
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-07-29 20:08:30 -0500
committerUnknown Bliss <m@michaelcullum.com>2012-09-01 15:05:49 +0100
commit36465c9a205c356b0662e45b4fded79c4b476547 (patch)
tree5be0d398e3e29fe2b701fb8c9f79c4a959aa485b /tests/test_framework/phpbb_functional_test_case.php
parent500879520c40a71f0b83799ab3e59c86c12a801a (diff)
downloadforums-36465c9a205c356b0662e45b4fded79c4b476547.tar
forums-36465c9a205c356b0662e45b4fded79c4b476547.tar.gz
forums-36465c9a205c356b0662e45b4fded79c4b476547.tar.bz2
forums-36465c9a205c356b0662e45b4fded79c4b476547.tar.xz
forums-36465c9a205c356b0662e45b4fded79c4b476547.zip
[ticket/10631] Functional acp_extensions test, cleanup
PHPBB3-10631
Diffstat (limited to 'tests/test_framework/phpbb_functional_test_case.php')
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index a1deeb2b63..6b4c0b6883 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -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);
+ }
}