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 | |
---|
13 | use Behat\MinkExtension\Context\MinkContext; |
---|
14 | use Behat\Behat\Exception\PendingException; |
---|
15 | use Behat\Gherkin\Node\TableNode; |
---|
16 | |
---|
17 | /** |
---|
18 | * Features context. |
---|
19 | */ |
---|
20 | class 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 | } |
---|