1
0

CapabilitiesContext.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. *
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. * @author Sergio Bertolin <sbertolin@solidgear.es>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. use Behat\Behat\Context\Context;
  26. use Behat\Behat\Context\SnippetAcceptingContext;
  27. use Behat\Behat\Hook\Scope\AfterScenarioScope;
  28. use Behat\Behat\Hook\Scope\BeforeScenarioScope;
  29. use GuzzleHttp\Client;
  30. use GuzzleHttp\Message\ResponseInterface;
  31. use PHPUnit\Framework\Assert;
  32. require __DIR__ . '/../../vendor/autoload.php';
  33. /**
  34. * Capabilities context.
  35. */
  36. class CapabilitiesContext implements Context, SnippetAcceptingContext {
  37. use BasicStructure;
  38. use AppConfiguration;
  39. /**
  40. * @Then /^fields of capabilities match with$/
  41. * @param \Behat\Gherkin\Node\TableNode|null $formData
  42. */
  43. public function checkCapabilitiesResponse(\Behat\Gherkin\Node\TableNode $formData){
  44. $capabilitiesXML = simplexml_load_string($this->response->getBody())->data->capabilities;
  45. foreach ($formData->getHash() as $row) {
  46. $path_to_element = explode('@@@', $row['path_to_element']);
  47. $answeredValue = $capabilitiesXML->{$row['capability']};
  48. for ($i = 0; $i < count($path_to_element); $i++){
  49. $answeredValue = $answeredValue->{$path_to_element[$i]};
  50. }
  51. $answeredValue = (string)$answeredValue;
  52. Assert::assertEquals(
  53. $row['value']==="EMPTY" ? '' : $row['value'],
  54. $answeredValue,
  55. "Failed field " . $row['capability'] . " " . $row['path_to_element']
  56. );
  57. }
  58. }
  59. protected function resetAppConfigs() {
  60. $this->modifyServerConfig('core', 'shareapi_enabled', 'yes');
  61. $this->modifyServerConfig('core', 'shareapi_allow_links', 'yes');
  62. $this->modifyServerConfig('core', 'shareapi_allow_public_upload', 'yes');
  63. $this->modifyServerConfig('core', 'shareapi_allow_resharing', 'yes');
  64. $this->modifyServerConfig('files_sharing', 'outgoing_server2server_share_enabled', 'yes');
  65. $this->modifyServerConfig('files_sharing', 'incoming_server2server_share_enabled', 'yes');
  66. $this->modifyServerConfig('core', 'shareapi_enforce_links_password', 'no');
  67. $this->modifyServerConfig('core', 'shareapi_allow_public_notification', 'no');
  68. $this->modifyServerConfig('core', 'shareapi_default_expire_date', 'no');
  69. $this->modifyServerConfig('core', 'shareapi_enforce_expire_date', 'no');
  70. $this->modifyServerConfig('core', 'shareapi_allow_group_sharing', 'yes');
  71. }
  72. }