-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from andrew72ru/develop
Develop
- Loading branch information
Showing
13 changed files
with
192 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
vendor | ||
composer.lock | ||
.phpunit.result.cache | ||
var/* | ||
tests/output |
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
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
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,47 @@ | ||
<?php | ||
/** | ||
* 23.03.2020 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Creative\DbI18nBundle\Tests; | ||
|
||
use Creative\DbI18nBundle\DbI18nBundle; | ||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Component\HttpKernel\Kernel as BaseKernel; | ||
|
||
class Kernel extends BaseKernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function registerBundles() | ||
{ | ||
return [ | ||
new FrameworkBundle(), | ||
new DoctrineBundle(), | ||
new DbI18nBundle(), | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function configureRoutes(\Symfony\Component\Routing\RouteCollectionBuilder $routes) | ||
{ | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function configureContainer(\Symfony\Component\DependencyInjection\ContainerBuilder $c, \Symfony\Component\Config\Loader\LoaderInterface $loader) | ||
{ | ||
$loader->load(__DIR__ . '/doctrine.yaml'); | ||
$loader->load(__DIR__ . '/../src/Resources/config', 'glob'); | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
/** | ||
* 23.03.2020 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Creative\DbI18nBundle\Tests\Loader; | ||
|
||
use Creative\DbI18nBundle\Entity\Translation; | ||
use Creative\DbI18nBundle\Loader\DbLoader; | ||
use Doctrine\ORM\EntityManager; | ||
use Doctrine\ORM\Tools\SchemaTool; | ||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
use Symfony\Component\Translation\MessageCatalogue; | ||
|
||
class DbLoaderTest extends KernelTestCase | ||
{ | ||
public function testIsServiceConfigured(): void | ||
{ | ||
self::bootKernel(); | ||
$this->assertInstanceOf(DbLoader::class, self::$container->get('translation.loader.db')); | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
self::bootKernel(); | ||
$doctrine = self::$container->get('doctrine'); | ||
/** @var EntityManager $em */ | ||
$em = $doctrine->getManager(); | ||
|
||
$schemaTool = new SchemaTool($em); | ||
|
||
$schemaTool->dropSchema([$em->getClassMetadata(Translation::class)]); | ||
$schemaTool->updateSchema([$em->getClassMetadata(Translation::class)]); | ||
|
||
$item = (new Translation()) | ||
->setDomain('db_messages') | ||
->setKey('translatable.key') | ||
->setLocale('en') | ||
->setTranslation('This is a translation of key'); | ||
$doctrine = self::$container->get('doctrine'); | ||
$em = $doctrine->getManager(); | ||
$em->persist($item); | ||
$em->flush(); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testLoadCatalogue(): void | ||
{ | ||
$service = self::$container->get('translation.loader.db'); | ||
$cat = $service->load(null, 'en', 'db_messages'); | ||
$this->assertInstanceOf(MessageCatalogue::class, $cat); | ||
$this->assertSame('This is a translation of key', $cat->get('translatable.key', 'db_messages')); | ||
} | ||
} |
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,21 @@ | ||
parameters: | ||
env(DATABASE_URL): '' | ||
|
||
doctrine: | ||
dbal: | ||
url: 'sqlite:///%kernel.cache_dir%/../../app.db' | ||
driver: 'pdo_sqlite' | ||
charset: utf8 | ||
types: | ||
uuid: Ramsey\Uuid\Doctrine\UuidType | ||
orm: | ||
auto_generate_proxy_classes: true | ||
naming_strategy: doctrine.orm.naming_strategy.underscore | ||
auto_mapping: true | ||
mappings: | ||
App: | ||
is_bundle: false | ||
type: annotation | ||
dir: '%kernel.project_dir%/src/Entity' | ||
prefix: 'App\Entity' | ||
alias: App |