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 28, 2023
1 parent 2d2e281 commit 058fc4d
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 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,23 @@ 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');

// We also have user2 and user3 but those accounts are "deleted"
$user = $userManager->get("user1");
if ($user === null) {
$user = $userManager->createUser("user1", "user1");
}
$user->setDisplayName("User No. 1");

$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 +319,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 +1154,7 @@ public function dataGetSubmissions() {
[
// 'formId' => Checked dynamically
'userId' => 'user2',
'userDisplayName' => 'user2',
'userDisplayName' => 'User No. 2',
'timestamp' => 12345,
'answers' => [
[
Expand All @@ -1155,7 +1172,7 @@ public function dataGetSubmissions() {
[
// 'formId' => Checked dynamically
'userId' => 'user3',
'userDisplayName' => 'user3',
'userDisplayName' => 'User No. 3',
'timestamp' => 1234,
'answers' => [
[
Expand Down

0 comments on commit 058fc4d

Please sign in to comment.