CapabilitiesContext.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Sergio Bertolin <sbertolin@solidgear.es>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author John Molakvoæ <skjnldsv@protonmail.com>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Sergio Bertolin <sbertolin@solidgear.es>
  12. *
  13. * @license GNU AGPL version 3 or any later version
  14. *
  15. * This program is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License as
  17. * published by the Free Software Foundation, either version 3 of the
  18. * License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. *
  28. */
  29. use Behat\Behat\Context\Context;
  30. use Behat\Behat\Context\SnippetAcceptingContext;
  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->deleteServerConfig('core', 'shareapi_enabled');
  61. $this->deleteServerConfig('core', 'shareapi_allow_links');
  62. $this->deleteServerConfig('core', 'shareapi_allow_public_upload');
  63. $this->deleteServerConfig('core', 'shareapi_allow_resharing');
  64. $this->deleteServerConfig('files_sharing', 'outgoing_server2server_share_enabled');
  65. $this->deleteServerConfig('files_sharing', 'incoming_server2server_share_enabled');
  66. $this->deleteServerConfig('core', 'shareapi_enforce_links_password');
  67. $this->deleteServerConfig('core', 'shareapi_allow_public_notification');
  68. $this->deleteServerConfig('core', 'shareapi_default_expire_date');
  69. $this->deleteServerConfig('core', 'shareapi_enforce_expire_date');
  70. $this->deleteServerConfig('core', 'shareapi_allow_group_sharing');
  71. }
  72. }