phpbb_ui_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;
        }
        self::$webDriver->manage()->deleteAllCookies();
        $this->visit('adm/index.php?sid=' . $this->sid);
        $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), self::$webDriver->getPageSource());
        self::find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username);
        self::find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username);
        self::find_element('cssSelector', 'input[name=login]')->click();
        $this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText());
        $cookies = self::$webDriver->manage()->getCookies();
        // 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['name'], -4) == '_sid') {
                $this->sid = $cookie['value'];
                break;
            }
        }
        $this->assertNotEmpty($this->sid);
    }