phpbb_functional_test_case::admin_login PHP Method

admin_login() protected method

Login to the ACP You must run login() before calling this.
protected admin_login ( $username = 'admin' )
    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 = self::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 = self::submit($form, array('username' => $username, $field => $username . $username));
                $this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
                $cookies = self::$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;
            }
        }
    }