18
18
namespace Feature ;
19
19
20
20
use Behat \Gherkin \Node \TableNode ;
21
- use Behat \ MinkExtension \ Context \ MinkContext ;
22
- use Documents \ Event ;
21
+ use Conticket \ ApiBundle \ Document \ Event ;
22
+ use PHPUnit_Framework_Assert as Assert ;
23
23
24
24
/**
25
25
* Event Context.
26
26
*
27
27
* @author Jefersson Nathan <[email protected] >
28
28
*/
29
- class EventContext extends MinkContext
29
+ class EventContext extends AbstractContext
30
30
{
31
31
/**
32
32
* @Given /^application has following events:$/
@@ -35,7 +35,16 @@ class EventContext extends MinkContext
35
35
*/
36
36
public function applicationHasFollowingEvents (TableNode $ table )
37
37
{
38
- //TODO: fill database with data
38
+ $ this ->getDocumentManager ()
39
+ ->getSchemaManager ()
40
+ ->dropDocumentCollection (Event::class);
41
+
42
+ foreach ($ table ->getHash () as $ row ) {
43
+ $ event = new Event ($ row ['name ' ], $ row ['description ' ], $ row ['banner ' ]);
44
+
45
+ $ this ->getDocumentManager ()->persist ($ event );
46
+ $ this ->getDocumentManager ()->flush ();
47
+ }
39
48
}
40
49
41
50
/**
@@ -49,8 +58,19 @@ public function iDoARequestToEventListPage()
49
58
/**
50
59
* @Then /^I should see (\d+) event listed$/
51
60
*/
52
- public function iShouldSeeEventListed ()
61
+ public function iShouldSeeEventListed ($ amount )
62
+ {
63
+ Assert::assertSame (
64
+ (int ) $ amount ,
65
+ count (json_decode ($ this ->getSession ()->getPage ()->getContent ()))
66
+ );
67
+ }
68
+
69
+ /**
70
+ * @Given /^I should see "([^"]*)" on json response$/
71
+ */
72
+ public function iShouldSeeOnJsonResponse ($ text )
53
73
{
54
- echo $ this ->getSession ()->getPage ()->getContent ();
74
+ Assert:: assertContains ( $ text , $ this ->getSession ()->getPage ()->getContent () );
55
75
}
56
76
}
0 commit comments