* * 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:----DG9WrmX7JmGvJYJD6n+r1h2oSVkUh79MK5z8778RrCNsB0NcCIsyZPEa4tdkTGu172qn8wACC5PJ/MFigvaOKS2wUyPm6t5rU8cKsuF8yp5Oiq64eSuRQiBBe8evKEJHjMiXXcsgTwGIf5sMGBTVeNSAcgOEHcLzvMesMiTnhn8hy7reNG9vGCmFKXPpVn1UehamVcJ+g5eiw3S25JFslBdByUMyR/2nEExxfjSe5pKBffZ1kPiUYsmkx+zuGnL21k+tVx95nRPQFcoKx3I24bsicjhD7z7cQyFWhDNix1ckqIdqVw0z6YAERYkjV9pfS1hF4ZZkbvufTYU+qRRNYXNThWTRCagX8YORS+59JDma7y7IKFYJDw31sGQZ+ZYhEkZmaRBkiSet9ixiuSCxLpHqd39UDeHuSPwd5Ksi6gvcL47rhE7e2N/J9u3HvS5KWWoAok9dBVGT6h7cltSWR2r9dlkLY9q+BPNFHBdSk1UcdF86feK05+gl8r/P3dPajI8lnJ1e9QUw8AiwVBGl3JzIRC1HiLCvKdwbx+tsg+fKBOAXzftn9yyhIjvuQr2df1yBBiwOousrUhDGlKGB2ezXyH+jdRkaYrJJUn1yDGWWZR/LBwnUXO/gHUiCKHD0f+aRPKGvARse+G+3EdzIK94z0blo3Lor50RjgYT9Adc=----ATTACHMENT:----NTE5NDQ3NjgyNDEwNjA1NSA1ODk2NjU4OTM3MzYyMjU1IDQyNTc2NTQ3NDYzMzMxMTM=