Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CapabilitiesContext.php « bootstrap « features « integration « build - github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a1a14aa3bb30c97b93b9906f94438f09fff24ff6 (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
<?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']);
				}
			}
		}
	}

}