initial prototype based on nat-as-server
Some checks failed
PHPUnit / test (push) Has been cancelled
Some checks failed
PHPUnit / test (push) Has been cancelled
This commit is contained in:
94
tests/Integration/CatalogApiTest.php
Normal file
94
tests/Integration/CatalogApiTest.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration;
|
||||
|
||||
use Tests\Support\DatabaseSeeder;
|
||||
use Tests\Support\QdbTestCase;
|
||||
|
||||
final class CatalogApiTest extends QdbTestCase
|
||||
{
|
||||
public function testListLanguages(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'translations', null, ['languages' => '1']);
|
||||
$this->assertApiOk($res);
|
||||
$this->assertIsArray($res['data']['languages']);
|
||||
}
|
||||
|
||||
public function testListQuestionsForQuestionnaire(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$f = $this->fixture();
|
||||
$res = $this->api()->withToken($token, 'GET', 'questions', null, [
|
||||
'questionnaireID' => $f->questionnaireId,
|
||||
]);
|
||||
$this->assertApiOk($res);
|
||||
$ids = array_column($res['data']['questions'], 'questionID');
|
||||
$this->assertContains($f->questionId, $ids);
|
||||
}
|
||||
|
||||
public function testListAnswerOptions(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'answer_options', null, [
|
||||
'questionID' => $this->fixture()->questionId,
|
||||
]);
|
||||
$this->assertApiOk($res);
|
||||
$this->assertNotEmpty($res['data']['answerOptions']);
|
||||
}
|
||||
|
||||
public function testListCoachesForSupervisor(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::SUPERVISOR_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'coaches');
|
||||
$this->assertApiOk($res);
|
||||
$coachIds = array_column($res['data']['coaches'], 'coachID');
|
||||
$this->assertContains($this->fixture()->coachId, $coachIds);
|
||||
}
|
||||
|
||||
public function testTranslationsAllDashboard(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'translations', null, ['all' => '1']);
|
||||
$this->assertApiOk($res);
|
||||
$this->assertArrayHasKey('questionnaires', $res['data']);
|
||||
$this->assertArrayHasKey('entries', $res['data']);
|
||||
}
|
||||
|
||||
public function testTranslationsForQuestionnaire(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'translations', null, [
|
||||
'questionnaireID' => $this->fixture()->questionnaireId,
|
||||
]);
|
||||
$this->assertApiOk($res);
|
||||
$this->assertArrayHasKey('entries', $res['data']);
|
||||
}
|
||||
|
||||
public function testAppTranslationsPublicNoAuth(): void
|
||||
{
|
||||
$res = $this->api()->request('GET', 'app_questionnaires', null, [], ['translations' => '1']);
|
||||
$this->assertApiOk($res);
|
||||
$this->assertArrayHasKey('translations', $res['data']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user