Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-09-05 17:13:03 +0300
committerJoas Schilling <coding@schilljs.com>2016-09-05 17:13:03 +0300
commit42535e19376f23c81fd0b401ffebf2214c5ffbb1 (patch)
tree7f7bb3f41d28e31044d27460da59c8e4068f046b /tests/Integration
parentf3c7a02db6175e981adbe39d0b592d9bab4eb2fc (diff)
Further cleanup for the integration tests
Diffstat (limited to 'tests/Integration')
-rw-r--r--tests/Integration/features/bootstrap/FeatureContext.php62
-rw-r--r--tests/Integration/features/delete-notifications.feature8
-rw-r--r--tests/Integration/features/statuscodes.feature6
3 files changed, 32 insertions, 44 deletions
diff --git a/tests/Integration/features/bootstrap/FeatureContext.php b/tests/Integration/features/bootstrap/FeatureContext.php
index c858aa2..e8c8c53 100644
--- a/tests/Integration/features/bootstrap/FeatureContext.php
+++ b/tests/Integration/features/bootstrap/FeatureContext.php
@@ -65,8 +65,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function hasNotifications($user) {
if ($user === 'test1') {
$response = $this->setTestingValue('POST', 'apps/notificationsintegrationtesting/notifications', null);
- PHPUnit_Framework_Assert::assertEquals(200, $response->getStatusCode());
- PHPUnit_Framework_Assert::assertEquals(200, (int) $this->getOCSResponse($response));
+ $this->assertStatusCode($response, 200);
}
}
@@ -79,8 +78,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function receiveNotification($user, \Behat\Gherkin\Node\TableNode $formData) {
if ($user === 'test1') {
$response = $this->setTestingValue('POST', 'apps/notificationsintegrationtesting/notifications', $formData);
- PHPUnit_Framework_Assert::assertEquals(200, $response->getStatusCode());
- PHPUnit_Framework_Assert::assertEquals(200, (int) $this->getOCSResponse($response));
+ $this->assertStatusCode($response, 200);
}
}
@@ -102,6 +100,16 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
+ * Parses the xml answer to get the array of users returned.
+ * @param ResponseInterface $response
+ * @return array
+ */
+ protected function getArrayOfNotificationsResponded(ResponseInterface $response) {
+ $jsonResponse = json_decode($response->getBody()->getContents(), 1);
+ return $jsonResponse['ocs']['data'];
+ }
+
+ /**
* @Then /^user "([^"]*)" has (\d+) notifications(| missing the last one| missing the first one)$/
*
* @param string $user
@@ -111,7 +119,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function userNumNotifications($user, $numNotifications, $missingLast) {
if ($user === 'test1') {
$this->sendingTo('GET', '/apps/notifications/api/v1/notifications?format=json');
- PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
+ $this->assertStatusCode($this->response, 200);
$previousNotificationIds = [];
if ($missingLast) {
@@ -138,6 +146,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/**
* @Then /^(first|last) notification matches$/
*
+ * @param string $notification
* @param \Behat\Gherkin\Node\TableNode|null $formData
*/
public function matchNotification($notification, $formData) {
@@ -149,7 +158,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
$this->sendingTo('GET', '/apps/notifications/api/v1/notifications/' . $notificationId . '?format=json');
- PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
+ $this->assertStatusCode($this->response, 200);
$response = json_decode($this->response->getBody()->getContents(), true);
foreach ($formData->getRowsHash() as $key => $value) {
@@ -175,24 +184,12 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
- * @Then /^status code is ([0-9]*) and ocs code ([0-9]*)$/
+ * @Then /^status code is ([0-9]*)$/
*
- * @param int $status
- * @param int $ocs
- */
- public function assertStatusCode($status, $ocs) {
- PHPUnit_Framework_Assert::assertEquals($status, $this->response->getStatusCode());
- PHPUnit_Framework_Assert::assertEquals($ocs, $this->getOCSResponse($this->response));
- }
-
- /**
- * Parses the xml answer to get the array of users returned.
- * @param ResponseInterface $resp
- * @return array
+ * @param int $statusCode
*/
- public function getArrayOfNotificationsResponded(ResponseInterface $resp) {
- $jsonResponse = json_decode($resp->getBody()->getContents(), 1);
- return $jsonResponse['ocs']['data'];
+ public function isStatusCode($statusCode) {
+ $this->assertStatusCode($this->response, $statusCode);
}
/**
@@ -201,8 +198,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
*/
public function clearNotifications() {
$response = $this->setTestingValue('DELETE', 'apps/notificationsintegrationtesting', null);
- PHPUnit_Framework_Assert::assertEquals(200, $response->getStatusCode());
- PHPUnit_Framework_Assert::assertEquals(200, (int) $this->getOCSResponse($response));
+ $this->assertStatusCode($response, 200);
}
/**
@@ -252,8 +248,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->createUser($user);
}
$response = $this->userExists($user);
- PHPUnit_Framework_Assert::assertEquals(200, $response->getStatusCode());
-
+ $this->assertStatusCode($response, 200);
}
private function userExists($user) {
@@ -352,18 +347,11 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
- * @Then /^the OCS status code should be "([^"]*)"$/
- * @param int $statusCode
- */
- public function theOCSStatusCodeShouldBe($statusCode) {
- PHPUnit_Framework_Assert::assertEquals($statusCode, $this->getOCSResponse($this->response));
- }
-
- /**
- * @Then /^the HTTP status code should be "([^"]*)"$/
+ * @param ResponseInterface $response
* @param int $statusCode
*/
- public function theHTTPStatusCodeShouldBe($statusCode) {
- PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode());
+ protected function assertStatusCode(ResponseInterface $response, $statusCode) {
+ PHPUnit_Framework_Assert::assertEquals($statusCode, $response->getStatusCode());
+ //PHPUnit_Framework_Assert::assertEquals($statusCode, $this->getOCSResponse($response));
}
}
diff --git a/tests/Integration/features/delete-notifications.feature b/tests/Integration/features/delete-notifications.feature
index f1d8aeb..85de512 100644
--- a/tests/Integration/features/delete-notifications.feature
+++ b/tests/Integration/features/delete-notifications.feature
@@ -9,7 +9,7 @@ Feature: delete-notifications
Given user "test1" has notifications
Then user "test1" has 3 notifications
And delete first notification
- And status code is 200 and ocs code 100
+ And status code is 200
And user "test1" has 2 notifications missing the first one
Scenario: Delete same notification twice
@@ -18,9 +18,9 @@ Feature: delete-notifications
Given user "test1" has notifications
When user "test1" has 3 notifications
And delete first notification
- And status code is 200 and ocs code 100
+ And status code is 200
And delete same notification
- And status code is 404 and ocs code 404
+ And status code is 404
And user "test1" has 2 notifications missing the first one
Scenario: Delete last notification
@@ -29,5 +29,5 @@ Feature: delete-notifications
Given user "test1" has notifications
Then user "test1" has 3 notifications
And delete last notification
- And status code is 200 and ocs code 100
+ And status code is 200
And user "test1" has 2 notifications missing the last one
diff --git a/tests/Integration/features/statuscodes.feature b/tests/Integration/features/statuscodes.feature
index 2a793ea..5530e1c 100644
--- a/tests/Integration/features/statuscodes.feature
+++ b/tests/Integration/features/statuscodes.feature
@@ -5,13 +5,13 @@ Feature: statuscodes
Scenario: Status code when reading notifications with notifiers and without notifications
When sending "GET" to "/apps/notifications/api/v1/notifications?format=json"
- Then the HTTP status code should be "200"
+ Then status code is 200
And list of notifications has 0 entries
Scenario: Status code when reading notifications with notifiers and notification
Given user "test1" has notifications
When sending "GET" to "/apps/notifications/api/v1/notifications?format=json"
- Then the HTTP status code should be "200"
+ Then status code is 200
And list of notifications has 1 entries
Scenario: Status code when reading notifications with notifiers and notifications
@@ -19,5 +19,5 @@ Feature: statuscodes
Given user "test1" has notifications
Given user "test1" has notifications
When sending "GET" to "/apps/notifications/api/v1/notifications?format=json"
- Then the HTTP status code should be "200"
+ Then status code is 200
And list of notifications has 3 entries