Skip to content

Commit

Permalink
fix empty metadata (annotation driver)
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag authored and janatjak committed Jan 17, 2018
2 parents 6adb732 + 017b50a commit 8734376
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/Kdyby/Doctrine/DI/OrmExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ protected function processEntityManager($name, array $defaults)
if (empty($config['metadata'])) {
$metadataDriver->addSetup('setDefaultDriver', [
new Statement($this->metadataDriverClasses[self::ANNOTATION_DRIVER], [
[$builder->expand('%appDir%')],
2 => $this->prefix('@cache.' . $name . '.metadata')
'@' . Doctrine\Common\Annotations\Reader::class,
[Nette\DI\Helpers::expand('%appDir%', $builder->parameters)]
])
]);
}
Expand Down Expand Up @@ -623,7 +623,7 @@ protected function processMetadataDriver(Nette\DI\ServiceDefinition $metadataDri

if ($impl === self::ANNOTATION_DRIVER) {
$driver->arguments = [
'@' . self::ANNOTATION_DRIVER . '.reader',
'@' . Doctrine\Common\Annotations\Reader::class,
Nette\Utils\Arrays::flatten($driver->arguments)
];
}
Expand Down
15 changes: 15 additions & 0 deletions tests/KdybyTests/Doctrine/Extension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ class ExtensionTest extends Tester\TestCase



public function testMetadataEmpty()
{
$container = $this->createContainer('metadata-empty');

/** @var Kdyby\Doctrine\EntityManager $default */
$default = $container->getByType(\Kdyby\Doctrine\EntityManager::class);
$entityClasses = array_map(function (ClassMetadata $class) {
return $class->getName();
}, $default->getMetadataFactory()->getAllMetadata());

Assert::contains(\KdybyTests\Doctrine\Models2\Foo::class, $entityClasses);
}



public function testProxyAutoloading()
{
$env = $_ENV + ['TEMP_DIR' => $scriptTempDir = TEMP_DIR . '/script'];
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Doctrine/config/metadata-empty.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
appDir: %wwwDir%/Doctrine/models2 # appDir replacing required - AnnotationDriver::getAllClassNames() require problem

kdyby.doctrine:
driver: pdo_sqlite
memory: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
console:
kdyby.console:
disabled: true

kdyby.doctrine:
Expand Down
8 changes: 4 additions & 4 deletions tests/KdybyTests/nette-reset.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ php:


extensions:
events: Kdyby\Events\DI\EventsExtension
console: Kdyby\Console\DI\ConsoleExtension
annotations: Kdyby\Annotations\DI\AnnotationsExtension
kdyby.events: Kdyby\Events\DI\EventsExtension
kdyby.console: Kdyby\Console\DI\ConsoleExtension
kdyby.annotations: Kdyby\Annotations\DI\AnnotationsExtension
kdyby.doctrine: Kdyby\Doctrine\DI\OrmExtension


Expand All @@ -16,7 +16,7 @@ kdyby.doctrine:
hydrationCache: array


console:
kdyby.console:
url: http://www.kdyby.org/


Expand Down

0 comments on commit 8734376

Please sign in to comment.