/** * @AfterScenario * * Reset the values after the last scenario of the feature and disable the testing app * @param AfterScenarioScope $event */ public function undoChangingParameters(AfterScenarioScope $event) { $scenarios = $event->getFeature()->getScenarios(); if ($event->getScenario() === end($scenarios)) { $user = $this->currentUser; $this->currentUser = '******'; $this->resetAppConfigs(); $this->setStatusTestingApp(false); $this->currentUser = $user; } }
/** * @AfterScenario */ public function takeDatabaseDumpAfterFailedStep(AfterScenarioScope $scope) { if ($this->screenshot_dir && TestResult::FAILED === $scope->getTestResult()->getResultCode()) { $feature = $scope->getFeature(); $scenario = $scope->getScenario(); $filename = basename($feature->getFile(), '.feature') . '-' . $scenario->getLine(); $filepath = $this->screenshot_dir . $filename . '.sql'; try { $dump = new Mysqldump('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD); $dump->start($filepath); } catch (\Exception $e) { echo 'mysqldump-php error: ' . $e->getMessage(); } } }
/** * @AfterScenario * * Delete any tempusers that were created outside of 'Given users'. */ public function deleteTempUsers(AfterScenarioScope $scope) { if ($scope->getScenario()->hasTag('deleteTempUsers')) { // Get all users that start with tempUser* $results = db_query("SELECT uid from users where name like 'tempuser%%'"); foreach ($results as $user) { user_delete($user->uid); } } }