Completed
Push — master ( 2bb842...c59813 )
by Rudie
02:18
created

SimpleFeatureContext::valuesAndAnd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
use Behat\Behat\Context\Context;
4
use Behat\Behat\Context\SnippetAcceptingContext;
5
use Behat\Behat\Tester\Exception\PendingException;
6
use Behat\Gherkin\Node\PyStringNode;
7
use Behat\Gherkin\Node\TableNode;
8
use rdx\behatvars\BehatVariablesDatabase;
9
10
class SimpleFeatureContext implements Context, SnippetAcceptingContext {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
12
	/**
13
	 * @Given a value :value
14
	 */
15
	public function aValue($value) {
16
		return $value;
17
	}
18
19
	/**
20
	 * @Given values :value1 and :value2
21
	 */
22
	public function valuesAnd($value1, $value2) {
23
		return [$value1, $value2];
24
	}
25
26
	/**
27
	 * @Given values :value1 and :value2 and :value3
28
	 */
29
	public function valuesAndAnd($value1, $value2, $value3) {
30
		return [$value1, $value2, $value3];
31
	}
32
33
	/**
34
	 * @Then :a should equal :b
35
	 */
36
	public function shouldEqual($a, $b) {
37
		if ($a != $b) {
38
			throw new \Exception("a ($a) does not equal b ($b)");
39
		}
40
	}
41
42
	/**
43
	 * @Then the database should contain:
44
	 */
45
	public function theDatabaseShouldContain(PyStringNode $string) {
46
		// Convert database to TableNode, to compare against test string
47
		$table = array();
48
		foreach (BehatVariablesDatabase::all() as $name => $value) {
49
			$table[] = array($name, $value);
50
		}
51
52
		$table = new TableNode($table);
53
		$table = trim($table);
54
55
		if (trim($string) != $table) {
56
			throw new \Exception("Database contents are wrong:\n$table");
57
		}
58
	}
59
60
}
61