summaryrefslogtreecommitdiffstats
path: root/build/integration/features/bootstrap/CapabilitiesContext.php
blob: 1b0015dce733f7b8a2e8a8867384a1ffa435494b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;

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']
				);
			}
		}
	}

}