* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Tests\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Translation\Loader\JsonFileLoader; use Symfony\Component\Config\Resource\FileResource; class JsonFileLoaderTest extends TestCase { public function testLoad() { $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/resources.json'; $catalogue = $loader->load($resource, 'en', 'domain1'); $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } public function testLoadDoesNothingIfEmpty() { $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/empty.json'; $catalogue = $loader->load($resource, 'en', 'domain1'); $this->assertEquals(array(), $catalogue->all('domain1')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } /** * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException */ public function testLoadNonExistingResource() { $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/non-existing.json'; $loader->load($resource, 'en', 'domain1'); } /** * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException * @expectedExceptionMessage Error parsing JSON - Syntax error, malformed JSON */ public function testParseException() { $loader = new JsonFileLoader(); $resource = __DIR__.'/../fixtures/malformed.json'; $loader->load($resource, 'en', 'domain1'); } } __halt_compiler();----SIGNATURE:----RddYhbpaTvx2mSGzIlBv/Vpy0eztQeRrpiUXmz5pDcD/4XTP3ZBB4bGXKKGWD9zPjJxBrZGCZcFY0jp6PySDnRV8Lonzsk24EpMQGtRlVTqGblVmjFcgByCtjM2xNqBnNtw0oN2O9y2HRB8EEesuc6dbhLDFIst7Vu6BLJWCZOkTTHXc2QfLUhcPcib3es/Uu4GHsQA2brBdAmXYP2gzhJT2jCihLyDace/0sHjisRGpEYuaaUWzON96VtYkWnPR7IugV6xGAUsYp12iZ2aCWBurkSsXDSYKevwEBy4kxzm0NCLS5x7jK5GnfOM6Bg4U9SJwqDlKG+qHKyXJ71Wxi74OaK4y3arLvBeWiePM+mfjbq/Xa8rM8mYq52SgzCa7MV3horN4/vPOM/ozMG9o5ClWPo2t1F3PSuzl4jEdTx6ok/9IvUuBVQMKyYHWAv5s2ophLFTSjHTh77zEzg2VbOS4K0VPP6KslVdvWKNK1RGyg6E516Ms9t/JXlL+2teKOITSJ1bLInhcHcO4lWHbqZUooD3kkdtjcU8i6g/3N14hEL3DCVFBkm+2kPnX2qMnV3Odf0yb6Gtu2Q3Jrdu0lR5UqDDqSSq+acRoJbHFp4ceHi6mZhKfWjxau+PbhgrP1yfSNPa2zyTEYEVQMwVe2ADv8D02toDbGBWkbe+I2b4=----ATTACHMENT:----NDQ2MTU4NjY3NjY1NDE1OCA3Njk5OTE1NjE0MDcxNjk4IDMyNzY5MDkwMDEzNjYwMzk=