|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ownCloud |
|
4
|
|
|
* |
|
5
|
|
|
* @author Artur Neumann <[email protected]> |
|
6
|
|
|
* @copyright 2017 Artur Neumann [email protected] |
|
7
|
|
|
* |
|
8
|
|
|
* This library is free software; you can redistribute it and/or |
|
9
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10
|
|
|
* License as published by the Free Software Foundation; either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This library is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public |
|
19
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
use Behat\Behat\Context\Context; |
|
24
|
|
|
use Behat\Behat\Hook\Scope\BeforeScenarioScope; |
|
25
|
|
|
use Behat\MinkExtension\Context\RawMinkContext; |
|
26
|
|
|
use Behat\Gherkin\Node\TableNode; |
|
27
|
|
|
use Page\OwncloudPage; |
|
28
|
|
|
use Page\LoginPage; |
|
29
|
|
|
|
|
30
|
|
|
require_once 'bootstrap.php'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Features context. |
|
34
|
|
|
*/ |
|
35
|
|
|
class FeatureContext extends RawMinkContext implements Context { |
|
36
|
|
|
|
|
37
|
|
|
use BasicStructure; |
|
38
|
|
|
|
|
39
|
|
|
private $owncloudPage; |
|
40
|
|
|
private $loginPage; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* |
|
44
|
|
|
* @param OwncloudPage $owncloudPage |
|
45
|
|
|
* @param LoginPage $loginPage |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct(OwncloudPage $owncloudPage, LoginPage $loginPage) { |
|
48
|
|
|
$this->owncloudPage = $owncloudPage; |
|
49
|
|
|
$this->loginPage = $loginPage; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @Then a notification should be displayed with the text :notificationText |
|
54
|
|
|
* @param string $notificationText |
|
55
|
|
|
* @return void |
|
56
|
|
|
* //TODO move this out from firewall |
|
57
|
|
|
*/ |
|
58
|
|
|
public function aNotificationShouldBeDisplayedWithTheText($notificationText) { |
|
59
|
|
|
PHPUnit_Framework_Assert::assertEquals( |
|
60
|
|
|
$notificationText, $this->owncloudPage->getNotificationText() |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @Then notifications should be displayed with the text |
|
66
|
|
|
* @param TableNode $table table of notifications |
|
67
|
|
|
* @return void |
|
68
|
|
|
* //TODO move this out from firewall |
|
69
|
|
|
*/ |
|
70
|
|
|
public function notificationsShouldBeDisplayedWithTheText(TableNode $table) { |
|
71
|
|
|
$notifications = $this->owncloudPage->getNotifications(); |
|
72
|
|
|
$tableRows = $table->getRows(); |
|
73
|
|
|
PHPUnit_Framework_Assert::assertEquals( |
|
74
|
|
|
count($tableRows), |
|
75
|
|
|
count($notifications) |
|
76
|
|
|
); |
|
77
|
|
|
|
|
78
|
|
|
$notificationCounter = 0; |
|
79
|
|
|
foreach ($tableRows as $row) { |
|
80
|
|
|
PHPUnit_Framework_Assert::assertEquals( |
|
81
|
|
|
$row[0], |
|
82
|
|
|
$notifications[$notificationCounter] |
|
83
|
|
|
); |
|
84
|
|
|
$notificationCounter++; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @Then I should be redirected to a page with the title :title |
|
90
|
|
|
* @param string $title |
|
91
|
|
|
* @return void |
|
92
|
|
|
*/ |
|
93
|
|
|
public function iShouldBeRedirectedToAPageWithTheTitle($title) { |
|
94
|
|
|
$this->owncloudPage->waitForOutstandingAjaxCalls($this->getSession()); |
|
95
|
|
|
$actualTitle = $this->getSession()->getPage()->find( |
|
96
|
|
|
'xpath', './/title' |
|
97
|
|
|
)->getHtml(); |
|
98
|
|
|
PHPUnit_Framework_Assert::assertEquals($title, trim($actualTitle)); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @BeforeScenario |
|
103
|
|
|
* @param BeforeScenarioScope $scope |
|
104
|
|
|
* @return void |
|
105
|
|
|
*/ |
|
106
|
|
|
public function setUpSuite(BeforeScenarioScope $scope) { |
|
107
|
|
|
$jobId = $this->getSessionId($scope); |
|
108
|
|
|
file_put_contents("/tmp/saucelabs_sessionid", $jobId); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* |
|
113
|
|
|
* @param BeforeScenarioScope $scope |
|
114
|
|
|
* @return mixed |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getSessionId(BeforeScenarioScope $scope) { |
|
117
|
|
|
$url = $this->getSession()->getDriver()->getWebDriverSession()->getUrl(); |
|
118
|
|
|
$parts = explode('/', $url); |
|
119
|
|
|
$sessionId = array_pop($parts); |
|
120
|
|
|
return $sessionId; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|