Skip to content

Commit

Permalink
fix(tests): Adjust users for test
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Nov 27, 2023
1 parent 6df04a9 commit 9e3ada5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions tests/Integration/Api/ApiV2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
use OCP\DB\QueryBuilder\IQueryBuilder;
use Test\TestCase;

/**
* @group DB
*/
class ApiV2Test extends TestCase {
/** @var GuzzleHttp\Client */
private $http;
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1017,7 +1027,7 @@ public function dataAddShare() {
'expected' => [
// 'formId' => Checked dynamically
'shareType' => 0,
'shareWith' => 'test',
'shareWith' => 'admin',
'permissions' => ['submit'],
'displayName' => 'Test Displayname'
]
Expand All @@ -1034,7 +1044,7 @@ public function testAddShare(array $expected) {
'json' => [
'formId' => $this->testForms[0]['id'],
'shareType' => 0,
'shareWith' => 'test',
'shareWith' => 'admin',
'permissions' => ['submit']
]
]);
Expand Down Expand Up @@ -1281,7 +1291,7 @@ public function testDeleteSubmissions(array $submissionsExpected) {
public function dataInsertSubmission() {
$submissionsExpected = $this->dataGetSubmissions()['getSubmissions']['expected'];
$submissionsExpected['submissions'][] = [
'userId' => 'test'
'userId' => 'admin'
];

return [
Expand Down Expand Up @@ -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' => [
Expand Down

0 comments on commit 9e3ada5

Please sign in to comment.