diff options
Diffstat (limited to 'build/integration/features/bootstrap/CapabilitiesContext.php')
-rw-r--r-- | build/integration/features/bootstrap/CapabilitiesContext.php | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/build/integration/features/bootstrap/CapabilitiesContext.php b/build/integration/features/bootstrap/CapabilitiesContext.php index 9cdd98cc059..ee13db4bcba 100644 --- a/build/integration/features/bootstrap/CapabilitiesContext.php +++ b/build/integration/features/bootstrap/CapabilitiesContext.php @@ -14,30 +14,21 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext { use Provisioning; use Sharing; - private $apacheUser = NULL; - /** * @Given /^parameter "([^"]*)" of app "([^"]*)" is set to "([^"]*)"$/ */ public function serverParameterIsSetTo($parameter, $app, $value){ - if (!isset($this->apacheUser)){ - $this->apacheUser = $this->getOSApacheUser(); - } - $this->modifyServerConfig($this->apacheUser, $parameter, $app, $value); + $this->modifyServerConfig($app, $parameter, $value); } /** * @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(); - } - + public function checkCapabilitiesResponse(\Behat\Gherkin\Node\TableNode $formData){ $capabilitiesXML = $this->response->xml()->data->capabilities; - - foreach ($fd as $row) { + + foreach ($formData->getHash() as $row) { if ($row['value'] === ''){ $answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']; PHPUnit_Framework_Assert::assertEquals( @@ -47,7 +38,7 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext { ); } else{ $answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature']; - PHPUnit_Framework_Assert::assertEquals( + PHPUnit_Framework_Assert::assertEquals( $answeredValue, $row['value']==="EMPTY" ? '' : $row['value'], "Failed field: " . $row['capability'] . " " . $row['feature'] . " " . $row['value_or_subfeature'] @@ -56,36 +47,53 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext { } } - public static function modifyServerConfig($apacheUser, $parameter, $app, $value){ - $comando = 'sudo -u ' . $apacheUser . ' ../../occ config:app:set ' . $app . " " . $parameter . ' --value=' . $value; - $expectedAnswer = "Config value $parameter for app $app set to $value"; - $output = exec($comando); - PHPUnit_Framework_Assert::assertEquals( - $output, - $expectedAnswer, - "Failed setting $parameter to $value" - ); - - } - - public static function getOSApacheUser(){ - return exec('ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk \'END {if ($1) print $1}\''); + /** + * @BeforeScenario + */ + public function prepareParameters(){ + $this->modifyServerConfig('core', 'shareapi_allow_public_upload', 'yes'); } /** - * @BeforeSuite + * @AfterScenario */ - public static function prepareParameters(){ - $apacheUser = self::getOSApacheUser(); - self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes"); + public function undoChangingParameters(){ + $this->modifyServerConfig('core', 'shareapi_allow_public_upload', 'yes'); } /** - * @AfterSuite + * @param string $app + * @param string $parameter + * @param string $value */ - public static function undoChangingParameters(){ - $apacheUser = self::getOSApacheUser(); - self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes"); + protected function modifyServerConfig($app, $parameter, $value) { + $user = $this->currentUser; + + $this->currentUser = 'admin'; + + $this->setStatusTestingApp(true); + + $body = new \Behat\Gherkin\Node\TableNode([['value', $value]]); + $this->sendingToWith('post', "/apps/testing/api/v1/app/{$app}/{$parameter}", $body); + $this->theHTTPStatusCodeShouldBe('200'); + $this->theOCSStatusCodeShouldBe('100'); + + $this->setStatusTestingApp(false); + + $this->currentUser = $user; } + protected function setStatusTestingApp($enabled) { + $this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing'); + $this->theHTTPStatusCodeShouldBe('200'); + $this->theOCSStatusCodeShouldBe('100'); + + $this->sendingTo('get', '/cloud/apps?filter=enabled'); + $this->theHTTPStatusCodeShouldBe('200'); + if ($enabled) { + PHPUnit_Framework_Assert::assertContains('testing', $this->response->getBody()->getContents()); + } else { + PHPUnit_Framework_Assert::assertNotContains('testing', $this->response->getBody()->getContents()); + } + } } |