Fix inheritance of members

This commit is contained in:
Joas Schilling 2016-03-11 10:23:11 +01:00
parent 62b77d8ed0
commit 26e974d859
3 changed files with 31 additions and 13 deletions

View File

@ -15,8 +15,6 @@ require __DIR__ . '/../../vendor/autoload.php';
class CapabilitiesContext implements Context, SnippetAcceptingContext {
use BasicStructure;
use Provisioning;
use Sharing;
/**
* @Given /^parameter "([^"]*)" of app "([^"]*)" is set to "([^"]*)"$/

View File

@ -1,16 +1,12 @@
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use GuzzleHttp\Client;
use GuzzleHttp\Message\ResponseInterface;
require __DIR__ . '/../../vendor/autoload.php';
trait Provisioning {
/** @var int */
private $apiVersion = 1;
use BasicStructure;
/** @var array */
private $createdUsers = [];
@ -26,6 +22,7 @@ trait Provisioning {
/**
* @Given /^user "([^"]*)" exists$/
* @param string $user
*/
public function assureUserExists($user) {
try {
@ -43,6 +40,7 @@ trait Provisioning {
/**
* @Given /^user "([^"]*)" does not exist$/
* @param string $user
*/
public function userDoesNotExist($user) {
try {
@ -135,6 +133,8 @@ trait Provisioning {
/**
* @Then /^check that user "([^"]*)" belongs to group "([^"]*)"$/
* @param string $user
* @param string $group
*/
public function checkThatUserBelongsToGroup($user, $group) {
$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
@ -160,7 +160,6 @@ trait Provisioning {
}
$this->response = $client->get($fullUrl, $options);
$groups = array($group);
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
if (array_key_exists($group, $respondedArray)) {
@ -172,6 +171,8 @@ trait Provisioning {
/**
* @Given /^user "([^"]*)" belongs to group "([^"]*)"$/
* @param string $user
* @param string $group
*/
public function assureUserBelongsToGroup($user, $group){
if (!$this->userBelongsToGroup($user, $group)){
@ -186,6 +187,8 @@ trait Provisioning {
/**
* @Given /^user "([^"]*)" does not belong to group "([^"]*)"$/
* @param string $user
* @param string $group
*/
public function userDoesNotBelongToGroup($user, $group) {
$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user/groups";
@ -202,8 +205,9 @@ trait Provisioning {
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
}
/**
/**
* @When /^creating the group "([^"]*)"$/
* @param string $group
*/
public function creatingTheGroup($group) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups";
@ -227,6 +231,7 @@ trait Provisioning {
/**
* @When /^Deleting the user "([^"]*)"$/
* @param string $user
*/
public function deletingTheUser($user) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
@ -241,6 +246,7 @@ trait Provisioning {
/**
* @When /^Deleting the group "([^"]*)"$/
* @param string $group
*/
public function deletingTheGroup($group) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/$group";
@ -255,6 +261,8 @@ trait Provisioning {
/**
* @Given /^Add user "([^"]*)" to the group "([^"]*)"$/
* @param string $user
* @param string $group
*/
public function addUserToGroup($user, $group) {
$this->userExists($user);
@ -265,6 +273,8 @@ trait Provisioning {
/**
* @When /^User "([^"]*)" is added to the group "([^"]*)"$/
* @param string $user
* @param string $group
*/
public function addingUserToGroup($user, $group) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user/groups";
@ -293,6 +303,7 @@ trait Provisioning {
/**
* @Given /^group "([^"]*)" exists$/
* @param string $group
*/
public function assureGroupExists($group) {
try {
@ -309,6 +320,7 @@ trait Provisioning {
/**
* @Given /^group "([^"]*)" does not exist$/
* @param string $group
*/
public function groupDoesNotExist($group) {
try {
@ -332,6 +344,8 @@ trait Provisioning {
/**
* @Given /^user "([^"]*)" is subadmin of group "([^"]*)"$/
* @param string $user
* @param string $group
*/
public function userIsSubadminOfGroup($user, $group) {
$fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins";
@ -350,6 +364,8 @@ trait Provisioning {
/**
* @Given /^user "([^"]*)" is not a subadmin of group "([^"]*)"$/
* @param string $user
* @param string $group
*/
public function userIsNotSubadminOfGroup($user, $group) {
$fullUrl = $this->baseUrl . "v2.php/cloud/groups/$group/subadmins";
@ -477,6 +493,7 @@ trait Provisioning {
/**
* @Given /^app "([^"]*)" is disabled$/
* @param string $app
*/
public function appIsDisabled($app) {
$fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=disabled";
@ -494,6 +511,7 @@ trait Provisioning {
/**
* @Given /^app "([^"]*)" is enabled$/
* @param string $app
*/
public function appIsEnabled($app) {
$fullUrl = $this->baseUrl . "v2.php/cloud/apps?filter=enabled";
@ -511,6 +529,8 @@ trait Provisioning {
/**
* @Given user :user has a quota of :quota
* @param string $user
* @param string $quota
*/
public function userHasAQuotaOf($user, $quota)
{
@ -525,6 +545,7 @@ trait Provisioning {
/**
* @Given user :user has unlimited quota
* @param string $user
*/
public function userHasUnlimitedQuota($user)
{

View File

@ -1,7 +1,5 @@
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use GuzzleHttp\Client;
use GuzzleHttp\Message\ResponseInterface;
@ -10,6 +8,7 @@ require __DIR__ . '/../../vendor/autoload.php';
trait Sharing{
use Provisioning;
/** @var int */
private $sharingApiVersion = 1;
@ -113,7 +112,7 @@ trait Sharing{
* @When /^Adding expiration date to last share$/
*/
public function addingExpirationDate() {
$share_id = $this->lastShareData->data[0]->id;
$share_id = (string) $this->lastShareData->data[0]->id;
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id";
$client = new Client();
$options = [];
@ -133,7 +132,7 @@ trait Sharing{
* @param \Behat\Gherkin\Node\TableNode|null $body
*/
public function updatingLastShare($body) {
$share_id = $this->lastShareData->data[0]->id;
$share_id = (string) $this->lastShareData->data[0]->id;
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/$share_id";
$client = new Client();
$options = [];