1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright 2018 Arnaud Bienvenu |
4
|
|
|
* |
5
|
|
|
* This file is part of Kyela. |
6
|
|
|
|
7
|
|
|
* Kyela is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
|
12
|
|
|
* Kyela is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with Kyela. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Abienvenu\KyelaBundle\Tests\Behat\Context; |
23
|
|
|
|
24
|
|
|
use Behat\Behat\Context\Context; |
25
|
|
|
use Behat\Behat\Context\Environment\InitializedContextEnvironment; |
26
|
|
|
use Behat\Behat\Hook\Scope\BeforeScenarioScope; |
27
|
|
|
use Behat\Mink\Driver\Selenium2Driver; |
28
|
|
|
use Behat\MinkExtension\Context\MinkContext; |
29
|
|
|
use Behatch\Context\BaseContext; |
30
|
|
|
|
31
|
|
|
class KyelaContext extends BaseContext |
32
|
|
|
{ |
33
|
|
|
/** @var MinkContext $minkContext */ |
34
|
|
|
protected $minkContext; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @BeforeScenario |
38
|
|
|
*/ |
39
|
|
|
public function gatherContexts(BeforeScenarioScope $scope) |
40
|
|
|
{ |
41
|
|
|
/** @var InitializedContextEnvironment $environment */ |
42
|
|
|
$environment = $scope->getEnvironment(); |
43
|
|
|
$this->minkContext = $environment->getContext('Behat\MinkExtension\Context\MinkContext'); |
44
|
|
|
|
45
|
|
|
if ($this->minkContext->getSession()->getDriver() instanceof Selenium2Driver) |
46
|
|
|
{ |
47
|
|
|
$this->minkContext->getSession()->getDriver()->resizeWindow(1440, 1800); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @When I wait for the participation to update |
53
|
|
|
*/ |
54
|
|
|
public function iWaitForTheParticipationToUpdate() |
55
|
|
|
{ |
56
|
|
|
$this->minkContext->getSession()->wait(2000, "!$('.ajaxloader').is(':visible')"); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @Then the :colIndex column of the footer should contain :text |
61
|
|
|
*/ |
62
|
|
|
public function theColumnOfTheFooterInTheTableShouldContain($colIndex, $text) |
63
|
|
|
{ |
64
|
|
|
$row = $this->minkContext->getSession()->getPage()->findAll('css', ".table tfoot tr th"); |
65
|
|
|
if (!isset($row[$colIndex - 1])) |
66
|
|
|
{ |
67
|
|
|
throw new \Exception("The col $colIndex was not found in the footer"); |
68
|
|
|
} |
69
|
|
|
$actual = $row[$colIndex - 1]->getText(); |
70
|
|
|
|
71
|
|
|
$this->assertContains($text, $actual); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @Then /^I press the (?P<index>\d+)(?:st|nd|rd|th) button containing a "(?P<icon>[^"]*)" icon$/ |
76
|
|
|
*/ |
77
|
|
|
public function iPressTheButtonContainingIcon($index, $glyphicon) |
78
|
|
|
{ |
79
|
|
|
$page = $this->minkContext->getSession()->getPage(); |
80
|
|
|
$icons = $page->findAll('css', ".glyphicon-$glyphicon"); |
81
|
|
|
$icons[$index - 1]->getParent()->click(); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|