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 d439d94
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 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 Down Expand Up @@ -197,9 +200,24 @@ private function setTestForms() {
*/
public function setUp(): void {
parent::setUp();
$userManager = \OC::$server->getUserManager();
$user = $userManager->get('test');
if ($user === null) {
$user = $userManager->createUser('test', 'test');
}
$user->setDisplayName('Test Displayname');

foreach ([1, 2, 3] as $number) {
$user = $userManager->get("user$number");
if ($user === null) {
$user = $userManager->createUser("user$number", "user$number");
}
$user->setDisplayName("User No. $number");
}

$this->setTestForms();

$qb = TestCase::$realDatabase->getQueryBuilder();
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();

// Write our test forms into db
foreach ($this->testForms as $index => $form) {
Expand Down Expand Up @@ -302,7 +320,7 @@ public function setUp(): void {

/** Clean up database from testforms */
public function tearDown(): void {
$qb = TestCase::$realDatabase->getQueryBuilder();
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();

foreach ($this->testForms as $form) {
$qb->delete('forms_v2_forms')
Expand Down Expand Up @@ -1137,7 +1155,7 @@ public function dataGetSubmissions() {
[
// 'formId' => Checked dynamically
'userId' => 'user2',
'userDisplayName' => 'user2',
'userDisplayName' => 'User No. 2',
'timestamp' => 12345,
'answers' => [
[
Expand All @@ -1155,7 +1173,7 @@ public function dataGetSubmissions() {
[
// 'formId' => Checked dynamically
'userId' => 'user3',
'userDisplayName' => 'user3',
'userDisplayName' => 'User No. 3',
'timestamp' => 1234,
'answers' => [
[
Expand Down

0 comments on commit d439d94

Please sign in to comment.