From 9e3ada5e341b089eebbb136dd28931f3f141a541 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 27 Nov 2023 23:36:20 +0100 Subject: [PATCH] fix(tests): Adjust users for test Signed-off-by: Ferdinand Thiessen --- tests/Integration/Api/ApiV2Test.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/Integration/Api/ApiV2Test.php b/tests/Integration/Api/ApiV2Test.php index b6dc23bbc..ac69709d7 100644 --- a/tests/Integration/Api/ApiV2Test.php +++ b/tests/Integration/Api/ApiV2Test.php @@ -33,6 +33,9 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use Test\TestCase; +/** + * @group DB + */ class ApiV2Test extends TestCase { /** @var GuzzleHttp\Client */ private $http; @@ -53,7 +56,7 @@ private function setTestForms() { 'hash' => 'abcdefg', 'title' => 'Title of a Form', 'description' => 'Just a simple form.', - 'owner_id' => 'test', + 'owner_id' => 'admin', 'access_json' => [ 'permitAllUsers' => false, 'showToAllUsers' => false @@ -197,6 +200,13 @@ private function setTestForms() { */ public function setUp(): void { parent::setUp(); + $userManager = \OC::$server->getUserManager(); + foreach (['user1', 'user2', 'user3'] as $user) { + if (!$userManager->userExists($user)) { + $userManager->createUser($user, $user); + } + } + $this->setTestForms(); $qb = TestCase::$realDatabase->getQueryBuilder(); @@ -292,7 +302,7 @@ public function setUp(): void { // Set up http Client $this->http = new Client([ 'base_uri' => 'http://localhost:8080/ocs/v2.php/apps/forms/', - 'auth' => ['test', 'test'], + 'auth' => ['admin', 'admin'], 'headers' => [ 'OCS-ApiRequest' => 'true', 'Accept' => 'application/json' @@ -458,7 +468,7 @@ public function dataGetNewForm() { // 'hash' => Some random, cannot be checked. 'title' => '', 'description' => '', - 'ownerId' => 'test', + 'ownerId' => 'admin', // 'created' => time() can not be checked exactly 'access' => [ 'permitAllUsers' => false, @@ -514,7 +524,7 @@ public function dataGetFullForm() { 'hash' => 'abcdefg', 'title' => 'Title of a Form', 'description' => 'Just a simple form.', - 'ownerId' => 'test', + 'ownerId' => 'admin', 'created' => 12345, 'access' => [ 'permitAllUsers' => false, @@ -1017,7 +1027,7 @@ public function dataAddShare() { 'expected' => [ // 'formId' => Checked dynamically 'shareType' => 0, - 'shareWith' => 'test', + 'shareWith' => 'admin', 'permissions' => ['submit'], 'displayName' => 'Test Displayname' ] @@ -1034,7 +1044,7 @@ public function testAddShare(array $expected) { 'json' => [ 'formId' => $this->testForms[0]['id'], 'shareType' => 0, - 'shareWith' => 'test', + 'shareWith' => 'admin', 'permissions' => ['submit'] ] ]); @@ -1281,7 +1291,7 @@ public function testDeleteSubmissions(array $submissionsExpected) { public function dataInsertSubmission() { $submissionsExpected = $this->dataGetSubmissions()['getSubmissions']['expected']; $submissionsExpected['submissions'][] = [ - 'userId' => 'test' + 'userId' => 'admin' ]; return [ @@ -1330,7 +1340,7 @@ public function testInsertSubmission(array $submissionsExpected) { unset($data['submissions'][0]['timestamp']); $this->assertEquals([ - 'userId' => 'test', + 'userId' => 'admin', 'userDisplayName' => 'Test Displayname', 'formId' => $this->testForms[0]['id'], 'answers' => [