Skip to content
Browse files

fixes a bug in the SymfonyLoaderAdapter

  • Loading branch information...
1 parent 4351bd9 commit 33e8bd559e3af4fa3a0b79e98f614ff7e5412110 @schmittjoh schmittjoh committed Nov 20, 2011
View
32 Tests/Translation/Loader/SymfonyLoaderAdapterTest.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace JMS\TranslationBundle\Tests\Translation\Loader;
+
+use JMS\TranslationBundle\Translation\Loader\SymfonyLoaderAdapter;
+use Symfony\Component\Translation\MessageCatalogue;
+
+class SymfonyLoaderAdapterTest extends \PHPUnit_Framework_TestCase
+{
+ public function testLoad()
+ {
+ $symfonyCatalogue = new MessageCatalogue('en');
+ $symfonyCatalogue->add(array('foo' => 'bar'));
+
+ $symfonyLoader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
+ $symfonyLoader->expects($this->once())
+ ->method('load')
+ ->with('foo', 'en', 'messages')
+ ->will($this->returnValue($symfonyCatalogue));
+
+ $adapter = new SymfonyLoaderAdapter($symfonyLoader);
+ $bundleCatalogue = $adapter->load('foo', 'en', 'messages');
+ $this->assertInstanceOf('JMS\TranslationBundle\Model\MessageCatalogue', $bundleCatalogue);
+ $this->assertEquals('en', $bundleCatalogue->getLocale());
+ $this->assertTrue($bundleCatalogue->hasDomain('messages'));
+ $this->assertTrue($bundleCatalogue->getDomain('messages')->has('foo'));
+
+ $message = $bundleCatalogue->getDomain('messages')->get('foo');
+ $this->assertEquals('bar', $message->getLocaleString());
+ $this->assertFalse($message->isNew());
+ }
+}
View
4 Translation/Loader/LoaderInterface.php
@@ -2,7 +2,7 @@
namespace JMS\TranslationBundle\Translation\Loader;
-use JMS\TranslationBundle\Model\MessageCollection;
+use JMS\TranslationBundle\Model\MessageCatalogue;
/**
* Loader Interface for the bundle.
@@ -21,7 +21,7 @@
* @param mixed $resource
* @param string $locale
* @param string $domain
- * @return MessageCollection
+ * @return MessageCatalogue
*/
function load($resource, $locale, $domain = 'messages');
}
View
4 Translation/Loader/SymfonyLoaderAdapter.php
@@ -36,9 +36,9 @@ public function load($resource, $locale, $domain = 'messages')
$catalogue = new MessageCatalogue();
$catalogue->setLocale($locale);
- foreach ($this->loader->load($resource, 'en', $domain)->all() as $id => $message) {
+ foreach ($this->loader->load($resource, $locale, $domain)->all($domain) as $id => $message) {
$catalogue->add(
- Message::create($id, $domain->getName())
+ Message::create($id, $domain)
->setLocaleString($message)
->setNew(false)
);

0 comments on commit 33e8bd5

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