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 <nickvergessen@owncloud.com>2016-05-02 17:42:21 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2016-05-03 09:55:18 +0300
commitb5eba36d7ca8590c649ae01bdee8359dc9abc779 (patch)
treea1f8f55ec4454f3afdc84aa63ac73d53a963666f /tests/Integration
parentd68f691eeacc5a13d6b63c575fd457f344ca56f5 (diff)
PSR-4 for the Notifications app
Diffstat (limited to 'tests/Integration')
-rw-r--r--tests/Integration/app/appinfo/app.php33
-rw-r--r--tests/Integration/app/appinfo/info.xml19
-rw-r--r--tests/Integration/app/appinfo/routes.php38
-rw-r--r--tests/Integration/app/controller.php75
-rw-r--r--tests/Integration/app/notifier.php45
-rw-r--r--tests/Integration/composer.json8
-rw-r--r--tests/Integration/config/behat.yml14
-rw-r--r--tests/Integration/features/bootstrap/FeatureContext.php338
-rw-r--r--tests/Integration/features/delete-notifications.feature20
-rw-r--r--tests/Integration/features/notifications-content.feature42
-rw-r--r--tests/Integration/features/statuscodes.feature23
-rw-r--r--tests/Integration/run.sh29
12 files changed, 684 insertions, 0 deletions
diff --git a/tests/Integration/app/appinfo/app.php b/tests/Integration/app/appinfo/app.php
new file mode 100644
index 0000000..9b71e91
--- /dev/null
+++ b/tests/Integration/app/appinfo/app.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\NotificationsIntegrationTesting\AppInfo;
+
+use OCA\NotificationsIntegrationTesting\Notifier;
+
+\OC::$server->getNotificationManager()->registerNotifier(function() {
+ return new Notifier();
+}, function() {
+ return [
+ 'id' => 'testing',
+ 'name' => 'testing',
+ ];
+});
diff --git a/tests/Integration/app/appinfo/info.xml b/tests/Integration/app/appinfo/info.xml
new file mode 100644
index 0000000..4eda6d8
--- /dev/null
+++ b/tests/Integration/app/appinfo/info.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<info>
+ <id>notificationsintegrationtesting</id>
+ <name>Notifications Integration Testing</name>
+ <description/>
+
+ <licence>AGPL</licence>
+ <author>Joas Schilling</author>
+ <version>0.2.3</version>
+
+ <types>
+ <logging/>
+ </types>
+
+ <dependencies>
+ <owncloud min-version="9.0" />
+ <owncloud max-version="9.0" />
+ </dependencies>
+</info>
diff --git a/tests/Integration/app/appinfo/routes.php b/tests/Integration/app/appinfo/routes.php
new file mode 100644
index 0000000..20a3be9
--- /dev/null
+++ b/tests/Integration/app/appinfo/routes.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+$controller = new \OCA\NotificationsIntegrationTesting\Controller(
+ 'notificationsintegrationtesting',
+ \OC::$server->getRequest(),
+ \OC::$server->getNotificationManager()
+);
+\OCP\API::register(
+ 'delete',
+ '/apps/notificationsintegrationtesting',
+ [$controller, 'deleteNotifications'],
+ 'notifications'
+);
+\OCP\API::register(
+ 'post',
+ '/apps/notificationsintegrationtesting/notifications',
+ [$controller, 'addNotification'],
+ 'notifications'
+);
diff --git a/tests/Integration/app/controller.php b/tests/Integration/app/controller.php
new file mode 100644
index 0000000..afdd642
--- /dev/null
+++ b/tests/Integration/app/controller.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\NotificationsIntegrationTesting;
+
+use OCP\AppFramework\Http;
+use OCP\IRequest;
+use OCP\Notification\IManager;
+
+class Controller extends \OCP\AppFramework\Controller {
+
+ /** @var IManager */
+ private $manager;
+
+ /**
+ * @param string $appName
+ * @param IRequest $request
+ * @param IManager $manager
+ */
+ public function __construct($appName, IRequest $request, IManager $manager) {
+ parent::__construct($appName, $request);
+
+ $this->manager = $manager;
+ }
+
+ /**
+ * @NoCSRFRequired
+ *
+ * @return \OC_OCS_Result
+ */
+ public function addNotification() {
+ $notification = $this->manager->createNotification();
+ $notification->setApp($this->request->getParam('app', 'notificationsintegrationtesting'))
+ ->setDateTime(\DateTime::createFromFormat('U', $this->request->getParam('timestamp', 1449585176))) // 2015-12-08T14:32:56+00:00
+ ->setUser($this->request->getParam('user', 'test1'))
+ ->setSubject($this->request->getParam('subject', 'testing'))
+ ->setLink($this->request->getParam('link', 'https://www.owncloud.org/'))
+ ->setMessage($this->request->getParam('message', 'message'))
+ ->setObject($this->request->getParam('object_type', 'object'), $this->request->getParam('object_id', 23));
+
+ $this->manager->notify($notification);
+
+ return new \OC_OCS_Result();
+ }
+
+ /**
+ * @NoCSRFRequired
+ *
+ * @return \OC_OCS_Result
+ */
+ public function deleteNotifications() {
+ $notification = $this->manager->createNotification();
+ $this->manager->markProcessed($notification);
+
+ return new \OC_OCS_Result();
+ }
+}
diff --git a/tests/Integration/app/notifier.php b/tests/Integration/app/notifier.php
new file mode 100644
index 0000000..14eea74
--- /dev/null
+++ b/tests/Integration/app/notifier.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\NotificationsIntegrationTesting;
+
+
+use OCP\Notification\INotification;
+use OCP\Notification\INotifier;
+
+class Notifier implements INotifier {
+
+ /**
+ * @param INotification $notification
+ * @param string $languageCode The code of the language that should be used to prepare the notification
+ * @return INotification
+ * @throws \InvalidArgumentException When the notification was not prepared by a notifier
+ */
+ public function prepare(INotification $notification, $languageCode) {
+ if ($notification->getApp() === 'notificationsintegrationtesting') {
+ $notification->setParsedSubject($notification->getSubject());
+ $notification->setParsedMessage($notification->getMessage());
+ return $notification;
+ }
+
+ throw new \InvalidArgumentException();
+ }
+}
diff --git a/tests/Integration/composer.json b/tests/Integration/composer.json
new file mode 100644
index 0000000..dc8e8d7
--- /dev/null
+++ b/tests/Integration/composer.json
@@ -0,0 +1,8 @@
+{
+ "require-dev": {
+ "phpunit/phpunit": "~4.8",
+ "behat/behat": "^3.0",
+ "guzzlehttp/guzzle": "~5.0",
+ "jarnaiz/behat-junit-formatter": "^1.3"
+ }
+}
diff --git a/tests/Integration/config/behat.yml b/tests/Integration/config/behat.yml
new file mode 100644
index 0000000..0fcead7
--- /dev/null
+++ b/tests/Integration/config/behat.yml
@@ -0,0 +1,14 @@
+default:
+ autoload:
+ '': %paths.base%/../features/bootstrap
+ suites:
+ default:
+ paths:
+ - %paths.base%/../features
+ contexts:
+ - FeatureContext
+
+ extensions:
+ jarnaiz\JUnitFormatter\JUnitFormatterExtension:
+ filename: report.xml
+ outputDir: %paths.base%/../output/
diff --git a/tests/Integration/features/bootstrap/FeatureContext.php b/tests/Integration/features/bootstrap/FeatureContext.php
new file mode 100644
index 0000000..8594d30
--- /dev/null
+++ b/tests/Integration/features/bootstrap/FeatureContext.php
@@ -0,0 +1,338 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+require __DIR__ . '/../../vendor/autoload.php';
+
+use Behat\Behat\Context\Context;
+use Behat\Behat\Context\SnippetAcceptingContext;
+use GuzzleHttp\Client;
+use GuzzleHttp\Message\ResponseInterface;
+
+/**
+ * Defines application features from the specific context.
+ */
+class FeatureContext implements Context, SnippetAcceptingContext {
+
+ /** @var array[] */
+ protected $notificationIds;
+
+ /** @var int */
+ protected $deletedNotification;
+
+ /** @var string */
+ protected $currentUser;
+
+ /** @var ResponseInterface */
+ private $response = null;
+
+ /** @var \GuzzleHttp\Cookie\CookieJar */
+ private $cookieJar;
+
+ /**
+ * FeatureContext constructor.
+ */
+ public function __construct() {
+ $this->cookieJar = new \GuzzleHttp\Cookie\CookieJar();
+ $this->baseUrl = getenv('TEST_SERVER_URL');
+ }
+
+ /**
+ * @Given /^user "([^"]*)" has notifications$/
+ *
+ * @param string $user
+ */
+ 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));
+ }
+ }
+
+ /**
+ * @Given /^user "([^"]*)" receives notification with$/
+ *
+ * @param string $user
+ * @param \Behat\Gherkin\Node\TableNode|null $formData
+ */
+ 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));
+ }
+ }
+
+ /**
+ * @Then /^list of notifications has (\d+) entries$/
+ *
+ * @param int $numNotifications
+ */
+ public function checkNumNotifications($numNotifications) {
+ $notifications = $this->getArrayOfNotificationsResponded($this->response);
+ PHPUnit_Framework_Assert::assertCount((int) $numNotifications, $notifications);
+
+ $notificationIds = [];
+ foreach ($notifications as $notification) {
+ $notificationIds[] = (int) $notification['notification_id'];
+ }
+
+ $this->notificationIds[] = $notificationIds;
+ }
+
+ /**
+ * @Then /^user "([^"]*)" has (\d+) notifications(| missing the last one| missing the first one)$/
+ *
+ * @param string $user
+ * @param int $numNotifications
+ * @param string $missingLast
+ */
+ 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());
+
+ $previousNotificationIds = [];
+ if ($missingLast) {
+ PHPUnit_Framework_Assert::assertNotEmpty($this->notificationIds);
+ $previousNotificationIds = end($this->notificationIds);
+ }
+
+ $this->checkNumNotifications((int) $numNotifications);
+
+ if ($missingLast) {
+ $now = end($this->notificationIds);
+ if ($missingLast === ' missing the last one') {
+ array_unshift($now, $this->deletedNotification);
+ } else {
+ $now[] = $this->deletedNotification;
+ }
+
+ PHPUnit_Framework_Assert::assertEquals($previousNotificationIds, $now);
+ }
+
+ }
+ }
+
+ /**
+ * @Then /^(first|last) notification matches$/
+ *
+ * @param \Behat\Gherkin\Node\TableNode|null $formData
+ */
+ public function matchNotification($notification, $formData) {
+ $lastNotifications = end($this->notificationIds);
+ if ($notification === 'first') {
+ $notificationId = reset($lastNotifications);
+ } else/* if ($notification === 'last')*/ {
+ $notificationId = end($lastNotifications);
+ }
+
+ $this->sendingTo('GET', '/apps/notifications/api/v1/notifications/' . $notificationId . '?format=json');
+ PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
+ $response = json_decode($this->response->getBody()->getContents(), true);
+
+ foreach ($formData->getRowsHash() as $key => $value) {
+ PHPUnit_Framework_Assert::assertArrayHasKey($key, $response['ocs']['data']);
+ PHPUnit_Framework_Assert::assertEquals($value, $response['ocs']['data'][$key]);
+ }
+ }
+
+ /**
+ * @Then /^delete (first|last) notification$/
+ *
+ * @param string $firstOrLast
+ */
+ public function deleteNotification($firstOrLast) {
+ PHPUnit_Framework_Assert::assertNotEmpty($this->notificationIds);
+ $lastNotificationIds = end($this->notificationIds);
+ if ($firstOrLast === 'first') {
+ $this->deletedNotification = end($lastNotificationIds);
+ } else {
+ $this->deletedNotification = reset($lastNotificationIds);
+ }
+ $this->sendingTo('DELETE', '/apps/notifications/api/v1/notifications/' . $this->deletedNotification);
+ }
+
+ /**
+ * Parses the xml answer to get the array of users returned.
+ * @param ResponseInterface $resp
+ * @return array
+ */
+ public function getArrayOfNotificationsResponded(ResponseInterface $resp) {
+ $jsonResponse = json_decode($resp->getBody()->getContents(), 1);
+ return $jsonResponse['ocs']['data'];
+ }
+
+ /**
+ * @BeforeScenario
+ * @AfterScenario
+ */
+ 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));
+ }
+
+ /**
+ * @param $verb
+ * @param $url
+ * @param $body
+ * @return \GuzzleHttp\Message\FutureResponse|ResponseInterface|null
+ */
+ protected function setTestingValue($verb, $url, $body) {
+ $fullUrl = $this->baseUrl . 'ocs/v2.php/' . $url;
+ $client = new Client();
+ $options = [
+ 'auth' => ['admin', 'admin'],
+ ];
+ if ($body instanceof \Behat\Gherkin\Node\TableNode) {
+ $fd = $body->getRowsHash();
+ $options['body'] = $fd;
+ }
+
+ try {
+ return $client->send($client->createRequest($verb, $fullUrl, $options));
+ } catch (\GuzzleHttp\Exception\ClientException $ex) {
+ return $ex->getResponse();
+ }
+ }
+
+ /*
+ * User management
+ */
+
+ /**
+ * @Given /^As user "([^"]*)"$/
+ * @param string $user
+ */
+ public function setCurrentUser($user) {
+ $this->currentUser = $user;
+ }
+
+ /**
+ * @Given /^user "([^"]*)" exists$/
+ * @param string $user
+ */
+ public function assureUserExists($user) {
+ try {
+ $this->userExists($user);
+ } catch (\GuzzleHttp\Exception\ClientException $ex) {
+ $this->createUser($user);
+ }
+ $this->userExists($user);
+ PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
+
+ }
+
+ private function userExists($user) {
+ $client = new Client();
+ $options = ['auth' => ['admin', 'admin']];
+ $this->response = $client->get($this->baseUrl . 'ocs/v2.php/cloud/users/' . $user, $options);
+ }
+
+ private function createUser($user) {
+ $previous_user = $this->currentUser;
+ $this->currentUser = "admin";
+
+ $userProvisioningUrl = $this->baseUrl . 'ocs/v2.php/cloud/users';
+ $client = new Client();
+ $options = [
+ 'auth' => ['admin', 'admin'],
+ 'body' => [
+ 'userid' => $user,
+ 'password' => '123456'
+ ],
+ ];
+ $this->response = $client->send($client->createRequest('POST', $userProvisioningUrl, $options));
+
+ //Quick hack to login once with the current user
+ $options2 = ['auth' => [$user, '123456']];
+ $client->send($client->createRequest('GET', $userProvisioningUrl . '/' . $user, $options2));
+
+ $this->currentUser = $previous_user;
+ }
+
+ /*
+ * Requests
+ */
+
+ /**
+ * @When /^sending "([^"]*)" to "([^"]*)"$/
+ * @param string $verb
+ * @param string $url
+ */
+ public function sendingTo($verb, $url) {
+ $this->sendingToWith($verb, $url, null);
+ }
+
+ /**
+ * @When /^sending "([^"]*)" to "([^"]*)" with$/
+ * @param string $verb
+ * @param string $url
+ * @param \Behat\Gherkin\Node\TableNode $body
+ */
+ public function sendingToWith($verb, $url, $body) {
+ $fullUrl = $this->baseUrl . 'ocs/v2.php' . $url;
+ $client = new Client();
+ $options = [];
+ if ($this->currentUser === 'admin') {
+ $options['auth'] = ['admin', 'admin'];
+ } else {
+ $options['auth'] = [$this->currentUser, '123456'];
+ }
+ if ($body instanceof \Behat\Gherkin\Node\TableNode) {
+ $fd = $body->getRowsHash();
+ $options['body'] = $fd;
+ }
+
+ try {
+ $this->response = $client->send($client->createRequest($verb, $fullUrl, $options));
+ } catch (\GuzzleHttp\Exception\ClientException $ex) {
+ $this->response = $ex->getResponse();
+ }
+ }
+
+ /**
+ * Parses the xml answer to get ocs response which doesn't match with
+ * http one in v1 of the api.
+ * @param ResponseInterface $response
+ * @return string
+ */
+ private function getOCSResponse($response) {
+ return $response->xml()->meta[0]->statuscode;
+ }
+
+ /**
+ * @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 int $statusCode
+ */
+ public function theHTTPStatusCodeShouldBe($statusCode) {
+ PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode());
+ }
+}
diff --git a/tests/Integration/features/delete-notifications.feature b/tests/Integration/features/delete-notifications.feature
new file mode 100644
index 0000000..c2cccb3
--- /dev/null
+++ b/tests/Integration/features/delete-notifications.feature
@@ -0,0 +1,20 @@
+Feature: delete-notifications
+ Background:
+ Given user "test1" exists
+ Given As user "test1"
+
+ Scenario: Delete first notification
+ Given user "test1" has notifications
+ Given user "test1" has notifications
+ Given user "test1" has notifications
+ Then user "test1" has 3 notifications
+ And delete first notification
+ And user "test1" has 2 notifications missing the first one
+
+ Scenario: Delete last notification
+ Given user "test1" has notifications
+ Given user "test1" has notifications
+ Given user "test1" has notifications
+ Then user "test1" has 3 notifications
+ And delete last notification
+ And user "test1" has 2 notifications missing the last one
diff --git a/tests/Integration/features/notifications-content.feature b/tests/Integration/features/notifications-content.feature
new file mode 100644
index 0000000..1366eb4
--- /dev/null
+++ b/tests/Integration/features/notifications-content.feature
@@ -0,0 +1,42 @@
+Feature: notifications-content
+ Background:
+ Given user "test1" exists
+ Given As user "test1"
+
+ Scenario: Create notification
+ Given user "test1" receives notification with
+ | app | notificationsintegrationtesting |
+ | timestamp | 144958517 |
+ | subject | Integration testing |
+ | link | https://owncloud.org/blog/about-activities-and-notifications-in-owncloud/ |
+ | message | About Activities and Notifications in ownCloud |
+ | object_type | blog |
+ | object_id | 9483 |
+ Then user "test1" has 1 notifications
+ And last notification matches
+ | app | notificationsintegrationtesting |
+ | datetime | 1974-08-05T18:15:17+00:00 |
+ | subject | Integration testing |
+ | link | https://owncloud.org/blog/about-activities-and-notifications-in-owncloud/ |
+ | message | About Activities and Notifications in ownCloud |
+ | object_type | blog |
+ | object_id | 9483 |
+
+ Scenario: Create different notification
+ Given user "test1" receives notification with
+ | app | notificationsintegrationtesting |
+ | timestamp | 144958515 |
+ | subject | Testing integration |
+ | link | https://github.com/owncloud/notifications/blob/master/docs/ocs-endpoint-v1.md |
+ | message | Reading and deleting notifications as a Client |
+ | object_type | repo |
+ | object_id | notifications |
+ Then user "test1" has 1 notifications
+ And last notification matches
+ | app | notificationsintegrationtesting |
+ | datetime | 1974-08-05T18:15:15+00:00 |
+ | subject | Testing integration |
+ | link | https://github.com/owncloud/notifications/blob/master/docs/ocs-endpoint-v1.md |
+ | message | Reading and deleting notifications as a Client |
+ | object_type | repo |
+ | object_id | notifications |
diff --git a/tests/Integration/features/statuscodes.feature b/tests/Integration/features/statuscodes.feature
new file mode 100644
index 0000000..c9a68d3
--- /dev/null
+++ b/tests/Integration/features/statuscodes.feature
@@ -0,0 +1,23 @@
+Feature: statuscodes
+ Background:
+ Given user "test1" exists
+ Given As user "test1"
+
+ 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"
+ 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"
+ And list of notifications has 1 entries
+
+ Scenario: Status code when reading notifications with notifiers and notifications
+ Given user "test1" has notifications
+ 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"
+ And list of notifications has 3 entries
diff --git a/tests/Integration/run.sh b/tests/Integration/run.sh
new file mode 100644
index 0000000..6d51763
--- /dev/null
+++ b/tests/Integration/run.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+APP_NAME=notifications
+
+APP_INTEGRATION_DIR=$PWD
+ROOT_DIR=${APP_INTEGRATION_DIR}/../../../..
+
+#cd ${ROOT_DIR}/build/integration
+composer install
+#cd ${APP_INTEGRATION_DIR}
+
+php -S localhost:8080 -t ${ROOT_DIR} &
+PHPPID=$!
+echo $PHPPID
+
+cp -R ./app ../../../notificationsintegrationtesting
+${ROOT_DIR}/occ app:enable notifications
+${ROOT_DIR}/occ app:enable notificationsintegrationtesting
+
+export TEST_SERVER_URL="http://localhost:8080/"
+${APP_INTEGRATION_DIR}/vendor/bin/behat -f junit -f pretty
+RESULT=$?
+
+kill $PHPPID
+
+${ROOT_DIR}/occ app:disable notificationsintegrationtesting
+rm -rf ../../../notificationsintegrationtesting
+
+exit $RESULT