Added capabilities context and tests

This commit is contained in:
Sergio Bertolin 2015-12-02 17:29:42 +00:00
Родитель df5872ec50
Коммит e01e894b98
4 изменённых файлов: 91 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,34 @@
Feature: capabilities
Background:
Given using api version "1"
Scenario: getting capabilities with admin user
Given As an "admin"
When sending "GET" to "/cloud/capabilities"
Then the HTTP status code should be "200"
And fields of capabilities match with
| capability | feature | value_or_subfeature | value |
| core | pollinterval | 60 | |
| core | webdav-root | remote.php/webdav | |
| files_sharing | api_enabled | 1 | |
| files_sharing | public | enabled | 1 |
| files_sharing | public | password | 1 |
| files_sharing | public | expire_date | 1 |
| files_sharing | public | send_mail | 1 |
| files_sharing | public | upload | 1 |
| files_sharing | resharing | 1 | |
| files_sharing | federation | outgoing | 1 |
| files_sharing | federation | incoming | 1 |
| files | bigfilechunking | 1 | |
| files | undelete | 1 | |
| files | versioning | 1 | |

Просмотреть файл

@ -14,7 +14,7 @@ default:
regular_user_password: 123456
federation:
paths:
- %paths.base%/../federation
- %paths.base%/../federation_features
contexts:
- FederationContext:
baseUrl: http://localhost:8080/ocs/
@ -22,6 +22,17 @@ default:
- admin
- admin
regular_user_password: 123456
capabilities:
paths:
- %paths.base%/../capabilities_features
contexts:
- CapabilitiesContext:
baseUrl: http://localhost:8080/ocs/
admin:
- admin
- admin
regular_user_password: 123456
extensions:

Просмотреть файл

@ -0,0 +1,45 @@
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use GuzzleHttp\Client;
use GuzzleHttp\Message\ResponseInterface;
require __DIR__ . '/../../vendor/autoload.php';
/**
* Capabilities context.
*/
class CapabilitiesContext implements Context, SnippetAcceptingContext {
use BasicStructure;
use Provisioning;
use Sharing;
/**
* @Then /^fields of capabilities match with$/
* @param \Behat\Gherkin\Node\TableNode|null $formData
*/
public function checkCapabilitiesResponse($formData){
if ($formData instanceof \Behat\Gherkin\Node\TableNode) {
$fd = $formData->getHash();
}
$capabilitiesXML = $this->response->xml()->data->capabilities;
foreach ($fd as $row) {
if ($row['value'] === ''){
$answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature'];
if ( !$answeredValue === $row['value_or_subfeature']){
PHPUnit_Framework_Assert::fail("Answered value $answeredValue is different to expected " . $row['value_or_subfeature']);
}
} else{
$answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature']->$row['value'];
if ( !$answeredValue === $row['value']){
PHPUnit_Framework_Assert::fail("Answered value $answeredValue is different to expected " . $row['value']);
}
}
}
}
}