CapabilitiesContext.php 3.0 KB

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