This repository has been archived by the owner on Aug 18, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added translator instance from 'handler' config option
- Loading branch information
Showing
5 changed files
with
371 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace Xinax\LaravelGettext\Test; | ||
|
||
use \Mockery as m; | ||
use \Xinax\LaravelGettext\LaravelGettext; | ||
use \Xinax\LaravelGettext\Config\ConfigManager; | ||
use \Xinax\LaravelGettext\Adapters\LaravelAdapter; | ||
use \Xinax\LaravelGettext\FileSystem; | ||
use Xinax\LaravelGettext\Translators\Symfony; | ||
|
||
class LaravelGettextTest extends BaseTestCase | ||
{ | ||
/** | ||
* Gettext wrapper | ||
* @var \Xinax\LaravelGettext\Gettext | ||
*/ | ||
protected $gettext; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$config = ConfigManager::create(); | ||
$adapter = new LaravelAdapter; | ||
|
||
$fileSystem = new FileSystem($config->get(), app_path(), storage_path()); | ||
|
||
$translator = new Symfony( | ||
$config->get(), | ||
$adapter, | ||
$fileSystem | ||
); | ||
|
||
$this->gettext = $translator; | ||
} | ||
|
||
/** | ||
* Test setting locale. | ||
*/ | ||
public function testSetLocale() | ||
{ | ||
$response = $this->gettext->setLocale('en_US'); | ||
|
||
$this->assertEquals('en_US', $response); | ||
} | ||
|
||
/** | ||
* Test getting locale. | ||
* It should receive locale from mocked config. | ||
*/ | ||
public function testGetLocale() | ||
{ | ||
$response = $this->gettext->getLocale(); | ||
|
||
$this->assertEquals('en_US', $response); | ||
} | ||
|
||
public function testIsLocaleSupported() | ||
{ | ||
$this->assertTrue($this->gettext->isLocaleSupported('en_US')); | ||
} | ||
|
||
/** | ||
* Test dumping locale to string | ||
*/ | ||
public function testToString() | ||
{ | ||
$response = $this->gettext->__toString(); | ||
|
||
$this->assertEquals('en_US', $response); | ||
} | ||
|
||
public function testGetEncoding() | ||
{ | ||
$response = $this->gettext->getEncoding(); | ||
$this->assertNotEmpty($response); | ||
$this->assertEquals('UTF-8', $response); | ||
} | ||
|
||
public function testSetEncoding() | ||
{ | ||
$response = $this->gettext->setEncoding('UTF-8'); | ||
$this->assertNotEmpty($response); | ||
$this->assertInstanceOf('Xinax\LaravelGettext\Gettext', $response); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
m::close(); | ||
} | ||
} |
Oops, something went wrong.