|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverStripe\AssetAdmin\Tests\Behat\Context; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Framework\Test\Behaviour\FeatureContext as BaseFeatureContext; |
|
6
|
|
|
|
|
7
|
|
|
class FeatureContext extends BaseFeatureContext |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Initializes context. |
|
11
|
|
|
* Every scenario gets it's own context object. |
|
12
|
|
|
* |
|
13
|
|
|
* @param array $parameters Context parameters (set them up through behat.yml) |
|
14
|
|
|
*/ |
|
15
|
|
|
public function __construct(array $parameters) { |
|
16
|
|
|
parent::__construct($parameters); |
|
17
|
|
|
|
|
18
|
|
|
// Override existing fixture context with more specific one |
|
19
|
|
|
$fixtureContext = new FixtureContext($parameters); |
|
20
|
|
|
$fixtureContext->setFixtureFactory($this->getFixtureFactory()); |
|
21
|
|
|
$this->useContext('FixtureContext', $fixtureContext); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @Then /^I should see a history list$/ |
|
26
|
|
|
*/ |
|
27
|
|
|
public function iShouldSeeAHistoryList() |
|
28
|
|
|
{ |
|
29
|
|
|
$page = $this->getSession()->getPage(); |
|
30
|
|
|
|
|
31
|
|
|
$form = $page->find('css', '.file-history__list'); |
|
32
|
|
|
assertNotNull($form, 'I should see a history list'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @Given /^I click on the latest history item$/ |
|
37
|
|
|
*/ |
|
38
|
|
|
public function iClickOnTheLatestHistoryItem() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->getSession()->wait( |
|
41
|
|
|
5000, |
|
42
|
|
|
"window.jQuery && window.jQuery('.file-history__list li').size() > 0" |
|
43
|
|
|
); |
|
44
|
|
|
|
|
45
|
|
|
$page = $this->getSession()->getPage(); |
|
46
|
|
|
|
|
47
|
|
|
$elements = $page->find('css', '.file-history__list li'); |
|
48
|
|
|
|
|
49
|
|
|
if (null === $elements) { |
|
50
|
|
|
throw new \InvalidArgumentException(sprintf('Could not find list item')); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$elements->click(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @Then /^I should see the history form$/ |
|
58
|
|
|
*/ |
|
59
|
|
|
public function iShouldSeeTheHistoryForm() |
|
60
|
|
|
{ |
|
61
|
|
|
$this->getSession()->wait( |
|
62
|
|
|
5000, |
|
63
|
|
|
"window.jQuery && window.jQuery('#Form_FileHistoryForm').size() > 0" |
|
64
|
|
|
); |
|
65
|
|
|
|
|
66
|
|
|
$page = $this->getSession()->getPage(); |
|
67
|
|
|
|
|
68
|
|
|
$form = $page->find('css', '#Form_FileHistoryForm'); |
|
69
|
|
|
assertNotNull($form, 'I should see a history list'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @Then /^the latest history item should contain "([^"]*)"$/ |
|
74
|
|
|
*/ |
|
75
|
|
|
public function theLatestHistoryItemShouldContain($arg1) |
|
76
|
|
|
{ |
|
77
|
|
|
$page = $this->getSession()->getPage(); |
|
78
|
|
|
|
|
79
|
|
|
$element = $page->find('css', '.file-history__list li'); |
|
80
|
|
|
|
|
81
|
|
|
if (null === $element) { |
|
82
|
|
|
throw new \InvalidArgumentException(sprintf('Could not find list item')); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
foreach($element as $li) { |
|
|
|
|
|
|
86
|
|
|
$text = $element[0]->getText(); |
|
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
assertElementContains($element, $arg1); |
|
89
|
|
|
|
|
90
|
|
|
break; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @When /^I click the "([^"]*)" tab$/ |
|
96
|
|
|
*/ |
|
97
|
|
|
public function iClickTheTab($tab) { |
|
98
|
|
|
$this->getSession()->wait( |
|
99
|
|
|
5000, |
|
100
|
|
|
"window.jQuery && window.jQuery('.nav-tabs').size() > 0" |
|
101
|
|
|
); |
|
102
|
|
|
|
|
103
|
|
|
$page = $this->getSession()->getPage(); |
|
104
|
|
|
$tabsets = $page->findAll('css', '.nav-tabs'); |
|
105
|
|
|
assertNotNull($tabsets, 'CMS tabs not found'); |
|
106
|
|
|
|
|
107
|
|
|
$tab_element = null; |
|
108
|
|
|
foreach($tabsets as $tabset) { |
|
109
|
|
|
if($tab_element) continue; |
|
110
|
|
|
$tab_element = $tabset->find('named', array('link_or_button', "'$tab'")); |
|
111
|
|
|
} |
|
112
|
|
|
assertNotNull($tab_element, sprintf('%s tab not found', $tab)); |
|
113
|
|
|
|
|
114
|
|
|
$tab_element->click(); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|