Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes a bug in the SymfonyLoaderAdapter

  • Loading branch information...
commit 33e8bd559e3af4fa3a0b79e98f614ff7e5412110 1 parent 4351bd9
Johannes schmittjoh authored
32 Tests/Translation/Loader/SymfonyLoaderAdapterTest.php
... ... @@ -0,0 +1,32 @@
  1 +<?php
  2 +
  3 +namespace JMS\TranslationBundle\Tests\Translation\Loader;
  4 +
  5 +use JMS\TranslationBundle\Translation\Loader\SymfonyLoaderAdapter;
  6 +use Symfony\Component\Translation\MessageCatalogue;
  7 +
  8 +class SymfonyLoaderAdapterTest extends \PHPUnit_Framework_TestCase
  9 +{
  10 + public function testLoad()
  11 + {
  12 + $symfonyCatalogue = new MessageCatalogue('en');
  13 + $symfonyCatalogue->add(array('foo' => 'bar'));
  14 +
  15 + $symfonyLoader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
  16 + $symfonyLoader->expects($this->once())
  17 + ->method('load')
  18 + ->with('foo', 'en', 'messages')
  19 + ->will($this->returnValue($symfonyCatalogue));
  20 +
  21 + $adapter = new SymfonyLoaderAdapter($symfonyLoader);
  22 + $bundleCatalogue = $adapter->load('foo', 'en', 'messages');
  23 + $this->assertInstanceOf('JMS\TranslationBundle\Model\MessageCatalogue', $bundleCatalogue);
  24 + $this->assertEquals('en', $bundleCatalogue->getLocale());
  25 + $this->assertTrue($bundleCatalogue->hasDomain('messages'));
  26 + $this->assertTrue($bundleCatalogue->getDomain('messages')->has('foo'));
  27 +
  28 + $message = $bundleCatalogue->getDomain('messages')->get('foo');
  29 + $this->assertEquals('bar', $message->getLocaleString());
  30 + $this->assertFalse($message->isNew());
  31 + }
  32 +}
4 Translation/Loader/LoaderInterface.php
@@ -2,7 +2,7 @@
2 2
3 3 namespace JMS\TranslationBundle\Translation\Loader;
4 4
5   -use JMS\TranslationBundle\Model\MessageCollection;
  5 +use JMS\TranslationBundle\Model\MessageCatalogue;
6 6
7 7 /**
8 8 * Loader Interface for the bundle.
@@ -21,7 +21,7 @@
21 21 * @param mixed $resource
22 22 * @param string $locale
23 23 * @param string $domain
24   - * @return MessageCollection
  24 + * @return MessageCatalogue
25 25 */
26 26 function load($resource, $locale, $domain = 'messages');
27 27 }
4 Translation/Loader/SymfonyLoaderAdapter.php
@@ -36,9 +36,9 @@ public function load($resource, $locale, $domain = 'messages')
36 36 $catalogue = new MessageCatalogue();
37 37 $catalogue->setLocale($locale);
38 38
39   - foreach ($this->loader->load($resource, 'en', $domain)->all() as $id => $message) {
  39 + foreach ($this->loader->load($resource, $locale, $domain)->all($domain) as $id => $message) {
40 40 $catalogue->add(
41   - Message::create($id, $domain->getName())
  41 + Message::create($id, $domain)
42 42 ->setLocaleString($message)
43 43 ->setNew(false)
44 44 );

0 comments on commit 33e8bd5

Please sign in to comment.
Something went wrong with that request. Please try again.