You are here

public function PotxTest::testDrupal8ConstraintMessages in Translation template extractor 8

Test parsing Drupal 8 validation constraint messages.

File

tests/src/Kernel/PotxTest.php, line 596

Class

PotxTest
Ensure that the translation template extractor functions properly.

Namespace

Drupal\Tests\potx\Kernel

Code

public function testDrupal8ConstraintMessages() {
  $filename = 'TestConstraint.php';
  $file_content = "\n<?php\nclass TestConstraint {\n\n  public \$message = 'Test message';\n  public \$testMessage = 'Test message 2';\n  public \$testPluralMessage = '1 test message|@count test message';\n  public \$normalVar = 'Not a message for translation';\n}\n    ";
  $this
    ->parsePhpContent($file_content, $filename, POTX_API_8);
  $this
    ->assertMsgId('Test message');
  $this
    ->assertMsgId('Test message 2');
  $this
    ->assertPluralId('1 test message', '@count test message');
  $this
    ->assertNoMsgId('Not a message for translation');
  $this
    ->assertPotxErrors([]);
}