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