diff options
author | Sergio Bertolin <sbertolin@solidgear.es> | 2015-12-02 17:29:42 +0000 |
---|---|---|
committer | Sergio Bertolin <sbertolin@solidgear.es> | 2015-12-02 17:29:42 +0000 |
commit | e01e894b985d3c8ee88da755abf7d5c139787705 (patch) | |
tree | 3204a887966ed4b3e8e3c5f3ac57b7beeb29b793 /build/integration/features/bootstrap/CapabilitiesContext.php | |
parent | df5872ec50a68de5d99bd6b5cf17ceb94f2ef833 (diff) | |
download | nextcloud-server-e01e894b985d3c8ee88da755abf7d5c139787705.tar.gz nextcloud-server-e01e894b985d3c8ee88da755abf7d5c139787705.zip |
Added capabilities context and tests
Diffstat (limited to 'build/integration/features/bootstrap/CapabilitiesContext.php')
-rw-r--r-- | build/integration/features/bootstrap/CapabilitiesContext.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/build/integration/features/bootstrap/CapabilitiesContext.php b/build/integration/features/bootstrap/CapabilitiesContext.php new file mode 100644 index 00000000000..a1a14aa3bb3 --- /dev/null +++ b/build/integration/features/bootstrap/CapabilitiesContext.php @@ -0,0 +1,45 @@ +<?php + +use Behat\Behat\Context\Context; +use Behat\Behat\Context\SnippetAcceptingContext; +use GuzzleHttp\Client; +use GuzzleHttp\Message\ResponseInterface; + +require __DIR__ . '/../../vendor/autoload.php'; + +/** + * Capabilities context. + */ +class CapabilitiesContext implements Context, SnippetAcceptingContext { + + use BasicStructure; + use Provisioning; + use Sharing; + + /** + * @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'] === ''){ + $answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature']; + if ( !$answeredValue === $row['value_or_subfeature']){ + PHPUnit_Framework_Assert::fail("Answered value $answeredValue is different to expected " . $row['value_or_subfeature']); + } + } else{ + $answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature']->$row['value']; + if ( !$answeredValue === $row['value']){ + PHPUnit_Framework_Assert::fail("Answered value $answeredValue is different to expected " . $row['value']); + } + } + } + } + +} |