Dotclear

source: features/bootstrap/FeatureContext.php @ 2986:1e5a2d6a0074

Revision 2986:1e5a2d6a0074, 2.2 KB checked in by Nicolas <nikrou77@…>, 10 years ago (diff)

Fix #1647
Allow user to add the same word for severals blogs not necessary global.
Add behat tests for that feature.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13use Behat\MinkExtension\Context\MinkContext;
14use Behat\Behat\Exception\PendingException;
15use Behat\Gherkin\Node\TableNode;
16
17/**
18 * Features context.
19 */
20class FeatureContext extends MinkContext
21{
22    /**
23     * Initializes context.
24     * Every scenario gets its own context object.
25     *
26     * @param array $parameters context parameters (set them up through behat.yml)
27     */
28    public function __construct(array $parameters) {
29        $this->parameters = $parameters;
30
31        $this->useContext('db', new DbContext($parameters));
32    }
33
34    /**
35     * @Given /^I am logged in as "([^"]*)" with password "([^"]*)"$/
36     */
37    public function iAmLoggedInAsWithPassword($username, $password, $remember=false) {
38        $this->fillField('Username', $username);
39        $this->fillField('Password', $password);
40        if ($remember) {
41            $this->checkOption('user_remember');
42        }
43        $this->pressButton('log in');
44    }
45
46    /**
47     * @Given /^I am logged in as "([^"]*)" with password "([^"]*)" with remember me$/
48     */
49    public function iAmLoggedInAsWithPasswordWithRememberMe($username, $password) {
50        $session_name = $this->getSubcontext('db')->getSessionName($this->parameters);
51
52        $this->iAmLoggedInAsWithPassword($username, $password, true);
53        $this->getMink()->assertSession()->cookieExists($session_name);
54        $this->getMink()->assertSession()->cookieExists('dc_admin');
55    }
56
57    /**
58     * @When /^I restart my browser$/
59     */
60    public function iRestartMyBrowser() {
61        $session_name = $this->getSubcontext('db')->getSessionName($this->parameters);
62        $this->getMink()->assertSession()->cookieExists($session_name);
63    }
64
65    /**
66     * @When /^I switch to blog "([^"]*)"$/
67     */
68    public function iSwitchToBlog($blog_name) {
69        $this->selectOption('switchblog', $blog_name);
70        $this->pressButton('ok');
71    }
72}
Note: See TracBrowser for help on using the repository browser.

Sites map