public function setDomain($domain) { $this->translator->setDomain($domain); return $this; }
/** * @expectedException \Xinax\LaravelGettext\Exceptions\UndefinedDomainException */ public function testTranslations() { /** @var \Xinax\LaravelGettext\Session\SessionHandler|\Mockery\MockInterface $session */ $session = m::mock('Xinax\\LaravelGettext\\Session\\SessionHandler'); $session->shouldReceive('get')->andReturn('es_AR'); $session->shouldReceive('set'); /** @var \Xinax\LaravelGettext\Adapters\LaravelAdapter|\Mockery\MockInterface $adapter */ $adapter = m::mock('Xinax\\LaravelGettext\\Adapters\\LaravelAdapter'); $adapter->shouldReceive('setLocale'); $adapter->shouldReceive('getApplicationPath')->andReturn(dirname(__FILE__)); $config = $this->configManager->get(); // Static traslation files $config->setTranslationsPath("translations"); $gettext = new Gettext($config, $session, $adapter, $this->fileSystem); $laravelGettext = new LaravelGettext($gettext); $laravelGettext->setLocale("es_AR"); $this->assertSame("Cadena general con echo de php", _("general string with php echo")); $laravelGettext->setDomain("backend"); $this->assertSame("backend", $laravelGettext->getDomain()); $this->assertSame("Cadena en el backend con echo de php", _("Backend string with php echo")); $laravelGettext->setDomain("frontend"); $this->assertSame("frontend", $laravelGettext->getDomain()); $this->assertSame("Cadena de controlador", _("Controller string")); $this->assertSame("Cadena de frontend con echo de php", _("Frontend string with php echo")); $laravelGettext->setLocale("en_US"); $this->assertSame("Frontend string with php echo", _("Frontend string with php echo")); // Expected exception $laravelGettext->setDomain("wrong-domain"); }