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 { class CapabilitiesContext implements Context, SnippetAcceptingContext {
use BasicStructure; use BasicStructure;
use Provisioning;
use Sharing;
/** /**
* @Given /^parameter "([^"]*)" of app "([^"]*)" is set to "([^"]*)"$/ * @Given /^parameter "([^"]*)" of app "([^"]*)" is set to "([^"]*)"$/

View File

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

View File

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