added unit tests
This commit is contained in:
49
tests/Integration/AppQuestionnairesTest.php
Normal file
49
tests/Integration/AppQuestionnairesTest.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration;
|
||||
|
||||
use Tests\Support\DatabaseSeeder;
|
||||
use Tests\Support\QdbTestCase;
|
||||
|
||||
final class AppQuestionnairesTest extends QdbTestCase
|
||||
{
|
||||
public function testCoachSubmitsQuestionnaire(): void
|
||||
{
|
||||
$res = $this->submitFixtureQuestionnaire();
|
||||
$this->assertApiOk($res);
|
||||
$this->assertTrue($res['data']['submitted'] ?? false);
|
||||
}
|
||||
|
||||
public function testCoachLoadsQuestionnaireDefinition(): void
|
||||
{
|
||||
$login = $this->api()->loginMobileAndGetToken(
|
||||
DatabaseSeeder::COACH_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
);
|
||||
$res = $this->api()->withMobileToken($login['token'], 'GET', 'app_questionnaires', null, [
|
||||
'id' => $this->fixture()->questionnaireId,
|
||||
]);
|
||||
$this->assertApiOk($res);
|
||||
$this->assertNotEmpty($res['data']['questions']);
|
||||
}
|
||||
|
||||
public function testCoachListsAssignedClients(): void
|
||||
{
|
||||
$this->submitFixtureQuestionnaire();
|
||||
$login = $this->api()->loginMobileAndGetToken(
|
||||
DatabaseSeeder::COACH_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
);
|
||||
$res = $this->api()->withMobileToken($login['token'], 'GET', 'app_questionnaires', null, [
|
||||
'clients' => '1',
|
||||
]);
|
||||
$this->assertApiOk($res);
|
||||
$this->assertTrue($res['data']['encrypted'] ?? false);
|
||||
$plain = qdb_decrypt_sensitive_envelope($res['data'], $login['token']);
|
||||
$payload = json_decode($plain, true, 512, JSON_THROW_ON_ERROR);
|
||||
$codes = array_column($payload['clients'], 'clientCode');
|
||||
$this->assertContains($this->fixture()->clientCode, $codes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user