-
Notifications
You must be signed in to change notification settings - Fork 2
/
FeatureContext.php
65 lines (58 loc) · 2.04 KB
/
FeatureContext.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Gherkin\Node\TableNode;
use TravisCarden\BehatTableComparison\TableEqualityAssertion;
/**
* Defines application features from the specific context.
*/
class FeatureContext implements Context
{
/**
* @Given I am :author
* @Given I am writing :work
*/
public function doNothing()
{
}
/**
* @Then I should include the following :items in :group
*/
public function iShouldIncludeTheFollowingIn($group, TableNode $expected)
{
switch ($group) {
case 'The Lord of the Rings series':
$actual = new TableNode([
['The Fellowship of the Ring'],
['The Two Towers'],
['The Return of the King'],
]);
(new TableEqualityAssertion($expected, $actual))
->setMissingRowsLabel('Missing books')
->setUnexpectedRowsLabel('Unexpected books')
->assert();
break;
case 'the Company of the Ring':
$actual = new TableNode([
['Frodo Baggins', 'Hobbit'],
['Samwise "Sam" Gamgee', 'Hobbit'],
['Gandalf the Grey', 'Wizard'],
['Legolas', 'Elf'],
['Gimli', 'Dwarf'],
['Aragorn (Strider)', 'Man'],
['Boromir', 'Man'],
['Meriadoc "Merry" Brandybuck', 'Hobbit'],
['Peregrin "Pippin" Took', 'Hobbit'],
]);
(new TableEqualityAssertion($expected, $actual))
->expectHeader(['name', 'race'])
->ignoreRowOrder()
->setMissingRowsLabel('Missing characters')
->setUnexpectedRowsLabel('Unexpected characters')
->assert();
break;
default:
throw new PendingException();
}
}
}