summaryrefslogtreecommitdiffstats
path: root/build/integration/features/bootstrap/CapabilitiesContext.php
diff options
context:
space:
mode:
Diffstat (limited to 'build/integration/features/bootstrap/CapabilitiesContext.php')
-rw-r--r--build/integration/features/bootstrap/CapabilitiesContext.php49
1 files changed, 49 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..4e200bdf421
--- /dev/null
+++ b/build/integration/features/bootstrap/CapabilitiesContext.php
@@ -0,0 +1,49 @@
+<?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'];
+ PHPUnit_Framework_Assert::assertEquals(
+ $answeredValue,
+ $row['value_or_subfeature'],
+ "Failed field " . $row['capability'] . " " . $row['feature']
+ );
+ } else{
+ $answeredValue = (string)$capabilitiesXML->$row['capability']->$row['feature']->$row['value_or_subfeature'];
+ PHPUnit_Framework_Assert::assertEquals(
+ $answeredValue,
+ $row['value'],
+ "Failed field: " . $row['capability'] . " " . $row['feature'] . " " . $row['value_or_subfeature']
+ );
+ }
+ }
+ }
+
+}