This commit is contained in:
@ -80,4 +80,51 @@ final class TranslationsImportExportTest extends QdbTestCase
|
||||
$codes = array_column($langs['data']['languages'], 'languageCode');
|
||||
$this->assertNotContains('it', $codes);
|
||||
}
|
||||
|
||||
public function testDeleteAllTranslationsRequiresPhrase(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
|
||||
$bad = $this->api()->withToken($token, 'POST', 'translations', [
|
||||
'action' => 'deleteAll',
|
||||
'confirmPhrase' => 'wrong phrase',
|
||||
]);
|
||||
$this->assertApiError($bad, 'CONFIRMATION_REQUIRED', 400);
|
||||
}
|
||||
|
||||
public function testDeleteAllTranslationsRemovesNonGerman(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$f = $this->fixture();
|
||||
|
||||
$this->api()->withToken($token, 'PUT', 'translations', [
|
||||
'type' => 'language',
|
||||
'languageCode' => 'es',
|
||||
'name' => 'Spanish',
|
||||
]);
|
||||
$this->api()->withToken($token, 'PUT', 'translations', [
|
||||
'type' => 'question',
|
||||
'id' => $f->questionId,
|
||||
'languageCode' => 'es',
|
||||
'text' => 'Consentimiento',
|
||||
]);
|
||||
|
||||
$del = $this->api()->withToken($token, 'POST', 'translations', [
|
||||
'action' => 'deleteAll',
|
||||
'confirmPhrase' => 'DELETE ALL TRANSLATIONS',
|
||||
]);
|
||||
$this->assertApiOk($del);
|
||||
$this->assertGreaterThan(0, $del['data']['question'] ?? 0);
|
||||
|
||||
$langs = $this->api()->withToken($token, 'GET', 'translations', null, ['languages' => '1']);
|
||||
$codes = array_column($langs['data']['languages'], 'languageCode');
|
||||
$this->assertContains('de', $codes);
|
||||
$this->assertNotContains('es', $codes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user