ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ConstraintViolationExceptionTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Tests\Refinery;
22
24use PHPUnit\Framework\TestCase;
25
27{
28 public function testTranslationOfMessage(): void
29 {
30 $callback = function (string $languageId): string {
31 $this->assertEquals('some_key', $languageId);
32 return 'Some text "%s" and "%s"';
33 };
34
35 try {
37 'This is an error message for developers',
38 'some_key',
39 'Value To Replace',
40 'Some important stuff'
41 );
42 } catch (ConstraintViolationException $exception) {
43 $this->assertEquals(
44 'Some text "Value To Replace" and "Some important stuff"',
45 $exception->getTranslatedMessage($callback)
46 );
47
48 $this->assertEquals(
49 'This is an error message for developers',
50 $exception->getMessage()
51 );
52 }
53 }
54}