|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +use Contributte\Tester\Toolkit; |
| 4 | +use Contributte\Tester\Utils\ContainerBuilder; |
| 5 | +use Contributte\Tester\Utils\Neonkit; |
| 6 | +use Doctrine\ORM\EntityManager; |
| 7 | +use Nette\DI\Compiler; |
| 8 | +use Nettrine\DBAL\DI\DbalExtension; |
| 9 | +use Nettrine\ORM\DI\OrmExtension; |
| 10 | +use Tester\Assert; |
| 11 | +use Tests\Toolkit\Tests; |
| 12 | + |
| 13 | +require_once __DIR__ . '/../../bootstrap.php'; |
| 14 | + |
| 15 | +// Schema Ignore Classes default empty array |
| 16 | +Toolkit::test(function (): void { |
| 17 | + $container = ContainerBuilder::of() |
| 18 | + ->withCompiler(function (Compiler $compiler): void { |
| 19 | + $compiler->addExtension('nettrine.dbal', new DbalExtension()); |
| 20 | + $compiler->addExtension('nettrine.orm', new OrmExtension()); |
| 21 | + $compiler->addConfig([ |
| 22 | + 'parameters' => [ |
| 23 | + 'tempDir' => Tests::TEMP_PATH, |
| 24 | + 'fixturesDir' => Tests::FIXTURES_PATH, |
| 25 | + ], |
| 26 | + ]); |
| 27 | + $compiler->addConfig(Neonkit::load( |
| 28 | + <<<'NEON' |
| 29 | + nettrine.dbal: |
| 30 | + connections: |
| 31 | + default: |
| 32 | + driver: pdo_sqlite |
| 33 | + password: test |
| 34 | + user: test |
| 35 | + path: ":memory:" |
| 36 | + nettrine.orm: |
| 37 | + managers: |
| 38 | + default: |
| 39 | + connection: default |
| 40 | + NEON |
| 41 | + )); |
| 42 | + }) |
| 43 | + ->build(); |
| 44 | + |
| 45 | + /** @var EntityManager $entityManager */ |
| 46 | + $entityManager = $container->getService('nettrine.orm.managers.default.entityManager'); |
| 47 | + Assert::same([], $entityManager->getConfiguration()->getSchemaIgnoreClasses()); |
| 48 | +}); |
| 49 | + |
| 50 | +// Schema Ignore Classes empty array |
| 51 | +Toolkit::test(function (): void { |
| 52 | + $container = ContainerBuilder::of() |
| 53 | + ->withCompiler(function (Compiler $compiler): void { |
| 54 | + $compiler->addExtension('nettrine.dbal', new DbalExtension()); |
| 55 | + $compiler->addExtension('nettrine.orm', new OrmExtension()); |
| 56 | + $compiler->addConfig([ |
| 57 | + 'parameters' => [ |
| 58 | + 'tempDir' => Tests::TEMP_PATH, |
| 59 | + 'fixturesDir' => Tests::FIXTURES_PATH, |
| 60 | + ], |
| 61 | + ]); |
| 62 | + $compiler->addConfig(Neonkit::load( |
| 63 | + <<<'NEON' |
| 64 | + nettrine.dbal: |
| 65 | + connections: |
| 66 | + default: |
| 67 | + driver: pdo_sqlite |
| 68 | + password: test |
| 69 | + user: test |
| 70 | + path: ":memory:" |
| 71 | + nettrine.orm: |
| 72 | + managers: |
| 73 | + default: |
| 74 | + schemaIgnoreClasses: [] |
| 75 | + connection: default |
| 76 | + NEON |
| 77 | + )); |
| 78 | + }) |
| 79 | + ->build(); |
| 80 | + |
| 81 | + /** @var EntityManager $entityManager */ |
| 82 | + $entityManager = $container->getService('nettrine.orm.managers.default.entityManager'); |
| 83 | + Assert::same([], $entityManager->getConfiguration()->getSchemaIgnoreClasses()); |
| 84 | +}); |
| 85 | + |
| 86 | +// Schema Ignore Classes one class |
| 87 | +Toolkit::test(function (): void { |
| 88 | + $container = ContainerBuilder::of() |
| 89 | + ->withCompiler(function (Compiler $compiler): void { |
| 90 | + $compiler->addExtension('nettrine.dbal', new DbalExtension()); |
| 91 | + $compiler->addExtension('nettrine.orm', new OrmExtension()); |
| 92 | + $compiler->addConfig([ |
| 93 | + 'parameters' => [ |
| 94 | + 'tempDir' => Tests::TEMP_PATH, |
| 95 | + 'fixturesDir' => Tests::FIXTURES_PATH, |
| 96 | + ], |
| 97 | + ]); |
| 98 | + $compiler->addConfig(Neonkit::load( |
| 99 | + <<<'NEON' |
| 100 | + nettrine.dbal: |
| 101 | + connections: |
| 102 | + default: |
| 103 | + driver: pdo_sqlite |
| 104 | + password: test |
| 105 | + user: test |
| 106 | + path: ":memory:" |
| 107 | + nettrine.orm: |
| 108 | + managers: |
| 109 | + default: |
| 110 | + connection: default |
| 111 | + schemaIgnoreClasses: |
| 112 | + - Tests\Mocks\Entity\DummyEntity |
| 113 | + NEON |
| 114 | + )); |
| 115 | + }) |
| 116 | + ->build(); |
| 117 | + |
| 118 | + /** @var EntityManager $entityManager */ |
| 119 | + $entityManager = $container->getService('nettrine.orm.managers.default.entityManager'); |
| 120 | + Assert::same(['Tests\Mocks\Entity\DummyEntity'], $entityManager->getConfiguration()->getSchemaIgnoreClasses()); |
| 121 | +}); |
0 commit comments