Skip to content

Commit c0c59c7

Browse files
committed
Make behat replay logic more verbose
When provisioning the tests output the commands and stop when this fails. So you are aware if something is broken.
1 parent 64d9d85 commit c0c59c7

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

stepup/tests/behat/features/bootstrap/FeatureContext.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,47 @@ class FeatureContext implements Context
4444
*/
4545
private $institutionConfiguration;
4646

47+
private static function execCommand(string $command): void
48+
{
49+
$output = [];
50+
$returnCode = -1;
51+
$result = exec($command, $output, $returnCode);
52+
53+
if($result === false) {
54+
echo "Failed executing command\n";
55+
die();
56+
}
57+
58+
foreach ($output as $line) {
59+
echo $line."\n";
60+
}
61+
62+
if ($returnCode !== 0) {
63+
die();
64+
}
65+
}
66+
4767
/**
4868
* @BeforeFeature
4969
*/
5070
public static function setupDatabase(BeforeFeatureScope $scope)
5171
{
5272
// Generate test databases
5373
echo "Preparing test schemas\n";
54-
shell_exec("docker exec -t stepup-middleware-1 bin/console doctrine:schema:drop --env=smoketest --force");
55-
shell_exec("docker exec -t stepup-gateway-1 bin/console doctrine:schema:drop --env=smoketest --force");
56-
shell_exec("docker exec -t stepup-middleware-1 bin/console doctrine:schema:create --env=smoketest");
57-
shell_exec("docker exec -t stepup-gateway-1 bin/console doctrine:schema:create --env=smoketest");
74+
self::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:drop --em=middleware --env=smoketest --force');
75+
self::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:drop --em=gateway --env=smoketest --force');
76+
self::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:create --em=middleware --env=smoketest');
77+
self::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:create --em=gateway --env=smoketest');
5878

59-
echo "Replaying event stream\n";
6079
// Import the events.sql into middleware
61-
shell_exec("mysql -uroot -psecret middleware_test -h mariadb < ./fixtures/events.sql");
62-
shell_exec("./fixtures/middleware-push-config.sh");
80+
echo "Add events to test database\n";
81+
self::execCommand("mysql -uroot -psecret middleware_test -h mariadb < ./fixtures/events.sql");
82+
6383
// Perform an event replay
64-
shell_exec("docker exec -t stepup-middleware-1 bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -q");
84+
echo "Replaying event stream\n";
85+
self::execCommand("docker exec -t stepup-middleware-1 bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -vvv");
86+
// Push config
87+
self::execCommand("./fixtures/middleware-push-config.sh");
6588
}
6689

6790
/**

stepup/tests/behat/features/bootstrap/SecondFactorAuthContext.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,6 @@ public function authenticateWithIdentityProviderForWithStepup($userName)
387387
$this->minkContext->pressButton('Yes, continue');
388388
}
389389

390-
private function passTroughIdentityProviderAssertionConsumerService()
391-
{
392-
$this->minkContext->assertPageAddress('https://gateway.dev.openconext.local/authentication/consume-assertion');
393-
394-
$this->minkContext->assertPageNotContainsText('Incorrect username or password');
395-
$this->minkContext->pressButton('Submit');
396-
}
397-
398390
/**
399391
* @Then I am logged on the service provider
400392
*/

stepup/tests/behat/features/bootstrap/SelfServiceContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ private function getLastSentEmail()
508508
}
509509

510510
$messages = json_decode($response);
511-
if (!$messages) {
511+
if (!is_array($messages)) {
512512
throw new Exception(
513513
'Unable to parse mailcatcher response'
514514
);

0 commit comments

Comments
 (0)