Skip to content

Commit

Permalink
add test for translation singular/plural
Browse files Browse the repository at this point in the history
  • Loading branch information
usu committed May 21, 2023
1 parent 5a71d56 commit f4baba3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions api/tests/Api/Camps/CreateCampTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,33 @@ public function testCreateCampReturnsProperDatesInTimezoneBehindUTC() {
]);
}

public function testCreateCampValidatesTooLongNameAndIncludesTranslationInfo() {
static::createClientWithCredentials()->request('POST', '/camps', ['json' => $this->getExampleWritePayload([
'name' => 'This camp name has 33 characters!',
])]);

$this->assertResponseStatusCodeSame(422);
$this->assertJsonContains([
'violations' => [
[
'i18n' => [
'key' => 'symfony.component.validator.constraints.length',
'parameters' => [
'value' => '"This camp name has 33 characters!"',
'limit' => '32',
],
'translations' => [
'en' => 'This value is too long. It should have 32 characters or less.',
'de' => 'Diese Zeichenkette ist zu lang. Sie sollte höchstens 32 Zeichen haben.',
'fr' => 'Cette chaîne est trop longue. Elle doit avoir au maximum 32 caractères.',
'it' => 'Questo valore è troppo lungo. Dovrebbe essere al massimo di 32 caratteri.',
],
],
],
],
]);
}

public function getExampleWritePayload($attributes = [], $except = []) {
return $this->getExamplePayload(Camp::class, Post::class, $attributes, [], $except);
}
Expand Down

0 comments on commit f4baba3

Please sign in to comment.