You are here

public function PotxTestCase::testDrupal8CustomYml in Translation template extractor 7.3

Same name and namespace in other branches
  1. 6.3 tests/potx.test \PotxTestCase::testDrupal8CustomYml()
  2. 7.2 tests/potx.test \PotxTestCase::testDrupal8CustomYml()

Test parsing of custom yaml files.

File

tests/potx.test, line 372
Tests to ensure that the template extractor works as intended.

Class

PotxTestCase
@file Tests to ensure that the template extractor works as intended.

Code

public function testDrupal8CustomYml() {
  $files = _potx_explore_dir(__DIR__ . '/potx_test_8/', '*', POTX_API_8);
  _potx_init_yaml_translation_patterns();
  $this
    ->parseFile($files[0], POTX_API_8);
  $this
    ->assertMsgID('Test custom yaml translatable');
  $this
    ->assertMsgIDContext('Test custom yaml translatable with context', 'Yaml translatable context');

  // Test that translation patterns for a module won't be used for extracting
  // translatable strings for another module.
  potx_finish_processing('_potx_save_string', POTX_API_8);
  $files = _potx_explore_dir(__DIR__ . '/potx_test_yml/', '*', POTX_API_8);
  $this
    ->parseFile(__DIR__ . '/potx_test_yml/potx_test_8.test2.yml', POTX_API_8);
  $this
    ->assertNoMsgID('Not translatable string');
  $this
    ->assertMsgID('Translatable string');
  $this
    ->assertMsgIDContext('Test custom yaml translatable field with context', 'Yaml translatable context');

  // Test that custom translation patterns are extracted from subfolders.
  $this
    ->parseFile(__DIR__ . '/potx_test_yml/test_folder/potx_test_8.test3.yml', POTX_API_8);
  $this
    ->assertMsgID('Translatable string inside directory');
}