[2931] | 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) { |
---|
[2984] | 50 | $session_name = $this->getSubcontext('db')->getSessionName($this->parameters); |
---|
| 51 | |
---|
[2931] | 52 | $this->iAmLoggedInAsWithPassword($username, $password, true); |
---|
[2984] | 53 | $this->getMink()->assertSession()->cookieExists($session_name); |
---|
[2931] | 54 | $this->getMink()->assertSession()->cookieExists('dc_admin'); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | /** |
---|
| 58 | * @When /^I restart my browser$/ |
---|
| 59 | */ |
---|
| 60 | public function iRestartMyBrowser() { |
---|
[2985] | 61 | $session_name = $this->getSubcontext('db')->getSessionName($this->parameters); |
---|
| 62 | $this->getMink()->assertSession()->cookieExists($session_name); |
---|
[2931] | 63 | } |
---|
| 64 | } |
---|