QtFileDumperTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Tests\Dumper;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Translation\Dumper\QtFileDumper;
  13. use Symfony\Component\Translation\MessageCatalogue;
  14. class QtFileDumperTest extends TestCase
  15. {
  16. public function testFormatCatalogue()
  17. {
  18. $catalogue = new MessageCatalogue('en');
  19. $catalogue->add(['foo' => 'bar', 'foo_bar' => 'foobar', 'bar_foo' => 'barfoo'], 'resources');
  20. $catalogue->setMetadata('foo_bar', [
  21. 'comments' => [
  22. 'Comment 1',
  23. 'Comment 2',
  24. ],
  25. 'flags' => [
  26. 'fuzzy',
  27. 'another',
  28. ],
  29. 'sources' => [
  30. 'src/file_1',
  31. 'src/file_2:50',
  32. ],
  33. ], 'resources');
  34. $catalogue->setMetadata('bar_foo', [
  35. 'comments' => 'Comment',
  36. 'flags' => 'fuzzy',
  37. 'sources' => 'src/file_1',
  38. ], 'resources');
  39. $dumper = new QtFileDumper();
  40. $this->assertStringEqualsFile(__DIR__.'/../fixtures/resources.ts', $dumper->formatCatalogue($catalogue, 'resources'));
  41. }
  42. }