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:
50
tests/Integration/DownloadsTest.php
Normal file
50
tests/Integration/DownloadsTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration;
|
||||
|
||||
use Tests\Support\DatabaseSeeder;
|
||||
use Tests\Support\QdbTestCase;
|
||||
|
||||
final class DownloadsTest extends QdbTestCase
|
||||
{
|
||||
public function testExportTranslationsBundle(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'translations', null, ['exportBundle' => '1']);
|
||||
$this->assertRawOk($res, 'application/json');
|
||||
$decoded = json_decode($res['body'], true);
|
||||
$this->assertIsArray($decoded);
|
||||
}
|
||||
|
||||
public function testExportQuestionnairesBundle(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::SUPERVISOR_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'export', null, ['bundle' => '1']);
|
||||
$this->assertRawOk($res, 'application/json');
|
||||
$decoded = json_decode($res['body'], true);
|
||||
$this->assertIsArray($decoded);
|
||||
}
|
||||
|
||||
public function testExportAllZipAsAdmin(): void
|
||||
{
|
||||
if (!class_exists('ZipArchive')) {
|
||||
$this->markTestSkipped('php-zip extension not installed');
|
||||
}
|
||||
$this->submitFixtureQuestionnaire();
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$res = $this->api()->withToken($token, 'GET', 'export', null, ['exportAll' => '1']);
|
||||
$this->assertRawOk($res, 'application/zip');
|
||||
$this->assertStringStartsWith('PK', $res['body']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user