-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Added loaders and dumpers for nette database and Doctrine DBAL.
- Loading branch information
1 parent
2447a72
commit 0dbe3e8
Showing
5 changed files
with
131 additions
and
24 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
107 changes: 107 additions & 0 deletions
107
tests/KdybyTests/Translation/TranslationLoader.netteDb.phpt
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,107 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Kdyby\Translation\TranslationLoader. | ||
* | ||
* @testCase KdybyTests\Translation\TranslationLoaderNetteDbTest | ||
* @author Filip Procházka <[email protected]> | ||
* @package Kdyby\Translation | ||
*/ | ||
|
||
namespace KdybyTests\Translation; | ||
|
||
use Kdyby; | ||
use Kdyby\Translation\DI\Configuration; | ||
use Kdyby\Translation\Loader\NetteDbLoader; | ||
use Kdyby\Translation\MessageCatalogue; | ||
use Kdyby\Translation\Resource\DatabaseResource; | ||
use Kdyby\Translation\TranslationLoader; | ||
use Nette; | ||
use Symfony; | ||
use Tester; | ||
use Tester\Assert; | ||
use Doctrine; | ||
|
||
require_once __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
|
||
/** | ||
* @author Filip Procházka <[email protected]> | ||
*/ | ||
class TranslationLoaderNetteDbTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @var \Nette\Database\Context | ||
*/ | ||
private $db; | ||
|
||
/** | ||
* @var \Nette\DI\Container | ||
*/ | ||
private $container; | ||
|
||
|
||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
Tester\Environment::lock('db', dirname(TEMP_DIR)); | ||
$this->container = $this->createContainer('netteDb'); | ||
$this->db = $this->container->getByType('Nette\Database\Context'); | ||
Nette\Database\Helpers::loadFromFile($this->db->getConnection(), __DIR__ . '/../init.sql'); | ||
} | ||
|
||
|
||
|
||
public function tearDown() | ||
{ | ||
parent::tearDown(); | ||
Nette\Database\Helpers::loadFromFile($this->db->getConnection(), __DIR__ . '/../clear.sql'); | ||
} | ||
|
||
|
||
|
||
public function testAddLoaders() | ||
{ | ||
$loader = new TranslationLoader(); | ||
Assert::same(array(), $loader->getLoaders()); | ||
|
||
$loader->addLoader('database', $dbLoader = new NetteDbLoader($this->db, new Configuration())); | ||
Assert::same(array('database' => $dbLoader), $loader->getLoaders()); | ||
} | ||
|
||
|
||
|
||
public function testLoadResources() | ||
{ | ||
$loader = new TranslationLoader(); | ||
$loader->addLoader('database', $dbLoader = new NetteDbLoader($this->db, new Configuration())); | ||
|
||
$catalogue = new MessageCatalogue('cs_CZ'); | ||
$loader->loadResource('database', DatabaseResource::NETTE_DB, NULL, $catalogue); | ||
|
||
Assert::true($catalogue->defines('header', 'front')); | ||
Assert::true($catalogue->defines('hello', 'messages')); | ||
|
||
$catalogue = new MessageCatalogue('en'); | ||
$loader->loadResource('database', DatabaseResource::NETTE_DB, NULL, $catalogue); | ||
|
||
Assert::true($catalogue->defines('header', 'front')); | ||
Assert::true($catalogue->defines('hello', 'messages')); | ||
} | ||
|
||
|
||
|
||
public function testLoadLocales() | ||
{ | ||
$dbLoader = new NetteDbLoader($this->db, new Configuration()); | ||
Assert::same(array('cs_CZ' => 'cs_CZ', 'en' => 'en'), $dbLoader->getLocales()); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
\run(new TranslationLoaderNetteDbTest()); |