1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Dedipanel project |
5
|
|
|
* |
6
|
|
|
* (c) 2010-2015 Dedipanel <http://www.dedicated-panel.net> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace DP\Core\CoreBundle\Behat; |
13
|
|
|
|
14
|
|
|
class AdminContext extends DefaultContext |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @Then /^I should be on the page of ([^""(w)]*) "([^""]*)"$/ |
18
|
|
|
* @Then /^I should still be on the page of ([^""(w)]*) "([^""]*)"$/ |
19
|
|
|
*/ |
20
|
|
|
public function iShouldBeOnTheResourcePageByName($type, $name) |
21
|
|
|
{ |
22
|
|
|
$this->iShouldBeOnTheResourcePage($type, 'name', $name); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @When /^I (?:click|press|follow) "([^"]*)" near "([^"]*)"$/ |
27
|
|
|
*/ |
28
|
|
View Code Duplication |
public function iClickNear($button, $value) |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$selector = sprintf('table tbody tr:contains("%s")', $value); |
31
|
|
|
$tr = $this->assertSession()->elementExists('css', $selector); |
32
|
|
|
|
33
|
|
|
$locator = sprintf('button:contains("%s")', $button); |
34
|
|
|
|
35
|
|
|
if ($tr->has('css', $locator)) { |
36
|
|
|
$tr->find('css', $locator)->press(); |
37
|
|
|
} else { |
38
|
|
|
$tr->clickLink($button); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @Then /^I should see "([^"]*)" near "([^"]*)"$/ |
44
|
|
|
*/ |
45
|
|
|
public function iShouldSeeNear($text, $value) |
46
|
|
|
{ |
47
|
|
|
$selector = sprintf('*:contains("%s") + td', $value); |
48
|
|
|
|
49
|
|
|
$this->assertSession()->elementContains('css', $selector, $text); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @Then /^I should see the dedipanel version "(?<version>[^"]+)"$/ |
54
|
|
|
*/ |
55
|
|
|
public function iShouldSeeTheDedipanelVersion($version) |
56
|
|
|
{ |
57
|
|
|
$this->assertSession()->elementContains('css', 'footer p', sprintf('DediPanel v%s', $version)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @Then /^I should see "(?<value>[^"]+)" selected in "(?<select>[^"]+)"$/ |
62
|
|
|
*/ |
63
|
|
|
public function iShouldSeeSelectedIn($select, $value) |
64
|
|
|
{ |
65
|
|
|
$locator = sprintf('//select[@name="%s"]/option[@selected]', $select, $value); |
66
|
|
|
|
67
|
|
|
$this->assertSession()->elementsCount('xpath', $locator, 1); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.