22
33use Behat \Behat \Context \Context ;
44use Behat \Behat \Hook \Scope \BeforeScenarioScope ;
5+ use Behat \Gherkin \Node \TableNode ;
56use Behat \MinkExtension \Context \MinkContext ;
67
78class ReplayContext implements Context
@@ -22,9 +23,9 @@ public function gatherContexts(BeforeScenarioScope $scope)
2223 }
2324
2425 /**
25- * @Given a replay is performed
26+ * @Given a replay of :arg is performed
2627 */
27- public function replay ()
28+ public function replay ($ name )
2829 {
2930 // Generate test databases
3031 echo "Preparing test schemas \n" ;
@@ -35,10 +36,28 @@ public function replay()
3536
3637 // Import the events.sql into middleware
3738 echo "Add events to test database \n" ;
38- FeatureContext::execCommand ("mysql -uroot -psecret middleware_test -h mariadb < ./fixtures/eventstream .sql " );
39+ FeatureContext::execCommand ("mysql -uroot -psecret middleware_test -h mariadb < ./fixtures/ " . $ name . " .sql " );
3940
4041 // Perform an event replay
4142 echo "Replaying event stream \n" ;
4243 FeatureContext::execCommand ("docker exec -t stepup-middleware-1 php bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -vvv " );
4344 }
45+
46+
47+ /**
48+ * @Given the database should not contain
49+ * @param TableNode $table
50+ */
51+ public function tempDataBaseDoesNotContains (TableNode $ table )
52+ {
53+ FeatureContext::execCommand ("mysqldump -h mariadb -u root -psecret --single-transaction --databases middleware_test gateway_test > temp.sql " );
54+ $ dataset = file_get_contents ('temp.sql ' );
55+
56+ $ hash = $ table ->getHash ();
57+ foreach ($ hash as $ row ) {
58+ if (str_contains ($ dataset , $ row ['value ' ])) {
59+ throw new RuntimeException (sprintf ("Data %s with value %s is still in the data set. " , $ row ['name ' ], $ row ['value ' ]));
60+ }
61+ }
62+ }
4463}
0 commit comments