2015-12-02 20:29:42 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Behat\Behat\Context\Context;
|
|
|
|
use Behat\Behat\Context\SnippetAcceptingContext;
|
|
|
|
|
|
|
|
require __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capabilities context.
|
|
|
|
*/
|
|
|
|
class CapabilitiesContext implements Context, SnippetAcceptingContext {
|
|
|
|
|
|
|
|
use BasicStructure;
|
|
|
|
use Provisioning;
|
|
|
|
use Sharing;
|
|
|
|
|
2015-12-09 13:27:30 +03:00
|
|
|
private $apacheUser = NULL;
|
2015-12-04 17:08:16 +03:00
|
|
|
|
|
|
|
/**
|
2015-12-09 13:27:30 +03:00
|
|
|
* @Given /^parameter "([^"]*)" of app "([^"]*)" is set to "([^"]*)"$/
|
2015-12-04 17:08:16 +03:00
|
|
|
*/
|
2015-12-09 13:27:30 +03:00
|
|
|
public function serverParameterIsSetTo($parameter, $app, $value){
|
|
|
|
if (!isset($this->apacheUser)){
|
|
|
|
$this->apacheUser = $this->getOSApacheUser();
|
|
|
|
}
|
|
|
|
$this->modifyServerConfig($this->apacheUser, $parameter, $app, $value);
|
2015-12-04 17:08:16 +03:00
|
|
|
}
|
|
|
|
|
2015-12-02 20:29:42 +03:00
|
|
|
/**
|
|
|
|
* @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'] === ''){
|
2015-12-03 15:54:44 +03:00
|
|
|
$answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature'];
|
|
|
|
PHPUnit_Framework_Assert::assertEquals(
|
|
|
|
$answeredValue,
|
|
|
|
$row['value_or_subfeature'],
|
|
|
|
"Failed field " . $row['capability'] . " " . $row['feature']
|
|
|
|
);
|
2015-12-02 20:29:42 +03:00
|
|
|
} else{
|
2015-12-03 15:54:44 +03:00
|
|
|
$answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature'];
|
|
|
|
PHPUnit_Framework_Assert::assertEquals(
|
|
|
|
$answeredValue,
|
2015-12-09 13:27:30 +03:00
|
|
|
$row['value']==="EMPTY" ? '' : $row['value'],
|
2015-12-03 15:54:44 +03:00
|
|
|
"Failed field: " . $row['capability'] . " " . $row['feature'] . " " . $row['value_or_subfeature']
|
|
|
|
);
|
2015-12-02 20:29:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-09 13:27:30 +03:00
|
|
|
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}\'');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @BeforeSuite
|
|
|
|
*/
|
|
|
|
public static function prepareParameters(){
|
|
|
|
$apacheUser = self::getOSApacheUser();
|
|
|
|
self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @AfterSuite
|
|
|
|
*/
|
|
|
|
public static function undoChangingParameters(){
|
|
|
|
$apacheUser = self::getOSApacheUser();
|
|
|
|
self::modifyServerConfig($apacheUser, "shareapi_allow_public_upload", "core", "yes");
|
|
|
|
}
|
|
|
|
|
2015-12-02 20:29:42 +03:00
|
|
|
}
|