summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-08-06 15:47:21 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-09-29 13:42:32 +0200
commitd26aab7e05cde33265fe857b92a1d0faa80ea6d9 (patch)
tree56963b467ec0b710cdc03f7fb9a57462e34c0edd /build
parent631303c1e74cb10a63fa46f99e3111067ec2f010 (diff)
downloadnextcloud-server-d26aab7e05cde33265fe857b92a1d0faa80ea6d9.tar.gz
nextcloud-server-d26aab7e05cde33265fe857b92a1d0faa80ea6d9.zip
Adding missing files
Diffstat (limited to 'build')
-rw-r--r--build/integration/.gitignore3
-rw-r--r--build/integration/features/bootstrap/FeatureContext.php91
2 files changed, 94 insertions, 0 deletions
diff --git a/build/integration/.gitignore b/build/integration/.gitignore
new file mode 100644
index 00000000000..18b981bf7ed
--- /dev/null
+++ b/build/integration/.gitignore
@@ -0,0 +1,3 @@
+vendor
+output
+composer.lock
diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php
new file mode 100644
index 00000000000..e1185debbc5
--- /dev/null
+++ b/build/integration/features/bootstrap/FeatureContext.php
@@ -0,0 +1,91 @@
+<?php
+
+use Behat\Behat\Context\BehatContext;
+use GuzzleHttp\Client;
+use GuzzleHttp\Message\ResponseInterface;
+
+//
+// Require 3rd-party libraries here:
+//
+// require_once 'PHPUnit/Autoload.php';
+// require_once 'PHPUnit/Framework/Assert/Functions.php';
+//
+
+/**
+ * Features context.
+ */
+class FeatureContext extends BehatContext {
+
+ /** @var string */
+ private $baseUrl = '';
+
+ /** @var ResponseInterface */
+ private $response = null;
+
+ /** @var string */
+ private $currentUser = '';
+
+ /** @var int */
+ private $apiVersion = 1;
+
+ /**
+ * Initializes context.
+ * Every scenario gets it's own context object.
+ *
+ * @param array $parameters context parameters (set them up through behat.yml)
+ */
+ public function __construct(array $parameters) {
+
+ // Initialize your context here
+ $this->baseUrl = $parameters['baseUrl'];
+ $this->adminUser = $parameters['admin'];
+ }
+
+ /**
+ * @When /^sending "([^"]*)" to "([^"]*)"$/
+ */
+ public function sendingTo($verb, $url) {
+ $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php" . $url;
+ $client = new Client();
+ // TODO: get admin user from config
+ $options = [];
+ if ($this->currentUser === 'admin') {
+ $options['auth'] = $this->adminUser;
+ }
+
+ try {
+ $this->response = $client->send($client->createRequest($verb, $fullUrl, $options));
+ } catch (\GuzzleHttp\Exception\ClientException $ex) {
+ $this->response = $ex->getResponse();
+ }
+ }
+
+ /**
+ * @Then /^the status code should be "([^"]*)"$/
+ */
+ public function theStatusCodeShouldBe($statusCode) {
+ PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode());
+ }
+
+ /**
+ * @Given /^As an "([^"]*)"$/
+ */
+ public function asAn($user) {
+ $this->currentUser = $user;
+ }
+
+ /**
+ * @Given /^using api version "([^"]*)"$/
+ */
+ public function usingApiVersion($version) {
+ $this->apiVersion = $version;
+ }
+
+ /**
+ * @Given /^user "([^"]*)" exists$/
+ */
+ public function userExists($user) {
+ throw new \Behat\Behat\Exception\PendingException();
+ }
+
+}