Parcourir la source

[Translation] added some unit tests for the new YAML loader

Fabien Potencier il y a 14 ans
Parent
commit
519cc09488

+ 29 - 0
tests/Symfony/Tests/Component/Translation/Loader/YamlFileLoaderTest.php

@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Tests\Component\Translation\Loader;
+
+use Symfony\Component\Translation\Loader\YamlFileLoader;
+use Symfony\Component\Translation\Resource\FileResource;
+
+class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
+{
+    public function testLoad()
+    {
+        $loader = new YamlFileLoader();
+        $resource = __DIR__.'/../fixtures/resources.yml';
+        $catalogue = $loader->load($resource, 'en', 'domain1');
+
+        $this->assertEquals(array('foo' => 'bar'), $catalogue->getMessages('domain1'));
+        $this->assertEquals('en', $catalogue->getLocale());
+        $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
+    }
+}

+ 1 - 0
tests/Symfony/Tests/Component/Translation/fixtures/resources.yml

@@ -0,0 +1 @@
+foo: bar