| @@ 353-406 (lines=54) @@ | ||
| 350 | )); |
|
| 351 | } |
|
| 352 | ||
| 353 | public function testSingleEntityManagerWithDefaultSecondLevelCacheConfiguration() |
|
| 354 | { |
|
| 355 | $container = $this->getContainer(); |
|
| 356 | $extension = new DoctrineExtension(); |
|
| 357 | ||
| 358 | $configurationArray = [ |
|
| 359 | [ |
|
| 360 | 'dbal' => [ |
|
| 361 | 'connections' => [ |
|
| 362 | 'default' => [ |
|
| 363 | 'password' => 'foo' |
|
| 364 | ] |
|
| 365 | ] |
|
| 366 | ], |
|
| 367 | 'orm' => [ |
|
| 368 | 'default_entity_manager' => 'default', |
|
| 369 | 'entity_managers' => [ |
|
| 370 | 'default' => [ |
|
| 371 | 'second_level_cache' => [ |
|
| 372 | 'region_cache_driver' => [ |
|
| 373 | 'type' => 'memcache'], |
|
| 374 | 'regions' => [ |
|
| 375 | 'hour_region' => [ |
|
| 376 | 'lifetime' => 3600 |
|
| 377 | ] |
|
| 378 | ] |
|
| 379 | ], |
|
| 380 | 'mappings' => [ |
|
| 381 | 'YamlBundle' => [] |
|
| 382 | ] |
|
| 383 | ] |
|
| 384 | ] |
|
| 385 | ] |
|
| 386 | ] |
|
| 387 | ]; |
|
| 388 | $extension->load($configurationArray, $container); |
|
| 389 | $this->compileContainer($container); |
|
| 390 | ||
| 391 | $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); |
|
| 392 | $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); |
|
| 393 | if (method_exists($definition, 'getFactory')) { |
|
| 394 | $this->assertEquals(array('%doctrine.orm.entity_manager.class%', 'create'), $definition->getFactory()); |
|
| 395 | } else { |
|
| 396 | $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); |
|
| 397 | $this->assertEquals('create', $definition->getFactoryMethod()); |
|
| 398 | } |
|
| 399 | ||
| 400 | $this->assertDICConstructorArguments($definition, array( |
|
| 401 | new Reference('doctrine.dbal.default_connection'), new Reference('doctrine.orm.default_configuration'), |
|
| 402 | )); |
|
| 403 | ||
| 404 | $slcDefinition = $container->getDefinition('doctrine.orm.default_second_level_cache.default_cache_factory'); |
|
| 405 | $this->assertEquals('%doctrine.orm.second_level_cache.default_cache_factory.class%', $slcDefinition->getClass()); |
|
| 406 | } |
|
| 407 | ||
| 408 | public function testSingleEntityManagerWithCustomSecondLevelCacheConfiguration() |
|
| 409 | { |
|
| @@ 408-462 (lines=55) @@ | ||
| 405 | $this->assertEquals('%doctrine.orm.second_level_cache.default_cache_factory.class%', $slcDefinition->getClass()); |
|
| 406 | } |
|
| 407 | ||
| 408 | public function testSingleEntityManagerWithCustomSecondLevelCacheConfiguration() |
|
| 409 | { |
|
| 410 | $container = $this->getContainer(); |
|
| 411 | $extension = new DoctrineExtension(); |
|
| 412 | ||
| 413 | $configurationArray = [ |
|
| 414 | [ |
|
| 415 | 'dbal' => [ |
|
| 416 | 'connections' => [ |
|
| 417 | 'default' => [ |
|
| 418 | 'password' => 'foo' |
|
| 419 | ] |
|
| 420 | ] |
|
| 421 | ], |
|
| 422 | 'orm' => [ |
|
| 423 | 'default_entity_manager' => 'default', |
|
| 424 | 'entity_managers' => [ |
|
| 425 | 'default' => [ |
|
| 426 | 'second_level_cache' => [ |
|
| 427 | 'region_cache_driver' => [ |
|
| 428 | 'type' => 'memcache'], |
|
| 429 | 'regions' => [ |
|
| 430 | 'hour_region' => [ |
|
| 431 | 'lifetime' => 3600 |
|
| 432 | ] |
|
| 433 | ], |
|
| 434 | 'factory' => 'YamlBundle\Cache\MyCacheFactory', |
|
| 435 | ], |
|
| 436 | 'mappings' => [ |
|
| 437 | 'YamlBundle' => [] |
|
| 438 | ] |
|
| 439 | ] |
|
| 440 | ] |
|
| 441 | ] |
|
| 442 | ] |
|
| 443 | ]; |
|
| 444 | $extension->load($configurationArray, $container); |
|
| 445 | $this->compileContainer($container); |
|
| 446 | ||
| 447 | $definition = $container->getDefinition('doctrine.orm.default_entity_manager'); |
|
| 448 | $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getClass()); |
|
| 449 | if (method_exists($definition, 'getFactory')) { |
|
| 450 | $this->assertEquals(array('%doctrine.orm.entity_manager.class%', 'create'), $definition->getFactory()); |
|
| 451 | } else { |
|
| 452 | $this->assertEquals('%doctrine.orm.entity_manager.class%', $definition->getFactoryClass()); |
|
| 453 | $this->assertEquals('create', $definition->getFactoryMethod()); |
|
| 454 | } |
|
| 455 | ||
| 456 | $this->assertDICConstructorArguments($definition, array( |
|
| 457 | new Reference('doctrine.dbal.default_connection'), new Reference('doctrine.orm.default_configuration'), |
|
| 458 | )); |
|
| 459 | ||
| 460 | $slcDefinition = $container->getDefinition('doctrine.orm.default_second_level_cache.default_cache_factory'); |
|
| 461 | $this->assertEquals('YamlBundle\Cache\MyCacheFactory', $slcDefinition->getClass()); |
|
| 462 | } |
|
| 463 | ||
| 464 | public function testBundleEntityAliases() |
|
| 465 | { |
|