diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 7bd5b443b6bc..fe575ca884d0 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -22,6 +22,7 @@ */ use rdx\behatvars\BehatVariablesContext; +use TestHelpers\OcsApiHelper; require_once 'bootstrap.php'; @@ -41,4 +42,28 @@ protected function resetAppConfigs() { // Set the required starting values for testing $this->setCapabilities($this->getCommonSharingConfigs()); } + + /** + * @Given the administrator has set the last login date for user :user to :days days ago + * @When the administrator sets the last login date for user :user to :days days ago using the testing API + * + * @param string $user + * @param string $days + * + * @return void + */ + public function theAdministratorSetsTheLastLoginDateForUserToDaysAgoUsingTheTestingApi($user, $days) { + $adminUser = $this->getAdminUsername(); + $baseUrl = "/apps/testing/api/v1/lastlogindate/{$user}"; + $response = OcsApiHelper::sendRequest( + $this->getBaseUrl(), + $adminUser, + $this->getAdminPassword(), + 'POST', + $baseUrl, + ['days' => $days], + $this->getOcsApiVersion() + ); + $this->setResponse($response); + } }