|
4 | 4 |
|
5 | 5 | use Doctrine\ODM\MongoDB\DocumentManager; |
6 | 6 | use FOS\ElasticaBundle\DependencyInjection\FOSElasticaExtension; |
| 7 | +use FOS\ElasticaBundle\Doctrine\Listener; |
7 | 8 | use FOS\ElasticaBundle\Doctrine\RegisterListenersService; |
8 | 9 | use FOS\ElasticaBundle\Doctrine\MongoDBPagerProvider; |
9 | 10 | use FOS\ElasticaBundle\Doctrine\ORMPagerProvider; |
@@ -521,4 +522,72 @@ public function testShouldRegisterPagerPersisterRegisterService() |
521 | 522 | $this->assertSame(PagerPersisterRegistry::class, $listener->getClass()); |
522 | 523 | $this->assertSame([], $listener->getArgument(0)); |
523 | 524 | } |
| 525 | + |
| 526 | + public function testShouldRegisterDoctrineORMListener() |
| 527 | + { |
| 528 | + $container = new ContainerBuilder(); |
| 529 | + $container->setParameter('kernel.debug', true); |
| 530 | + |
| 531 | + $extension = new FOSElasticaExtension(); |
| 532 | + $extension->load([ |
| 533 | + 'fos_elastica' => [ |
| 534 | + 'clients' => [ |
| 535 | + 'default' => ['host' => 'a_host', 'port' => 'a_port'], |
| 536 | + ], |
| 537 | + 'indexes' => [ |
| 538 | + 'acme_index' => [ |
| 539 | + 'types' => [ |
| 540 | + 'acme_type' => [ |
| 541 | + 'properties' => ['text' => null], |
| 542 | + 'persistence' => [ |
| 543 | + 'driver' => 'orm', |
| 544 | + 'model' => 'theModelClass', |
| 545 | + 'provider' => ['pager_provider' => true], |
| 546 | + 'listener' => null, |
| 547 | + 'finder' => null, |
| 548 | + ] |
| 549 | + ] |
| 550 | + ] |
| 551 | + ] |
| 552 | + ] |
| 553 | + ] |
| 554 | + ], $container); |
| 555 | + |
| 556 | + $this->assertTrue($container->hasDefinition('fos_elastica.listener.acme_index.acme_type')); |
| 557 | + } |
| 558 | + |
| 559 | + public function testShouldNotRegisterDoctrineORMListenerIfDisabled() |
| 560 | + { |
| 561 | + $container = new ContainerBuilder(); |
| 562 | + $container->setParameter('kernel.debug', true); |
| 563 | + |
| 564 | + $extension = new FOSElasticaExtension(); |
| 565 | + $extension->load([ |
| 566 | + 'fos_elastica' => [ |
| 567 | + 'clients' => [ |
| 568 | + 'default' => ['host' => 'a_host', 'port' => 'a_port'], |
| 569 | + ], |
| 570 | + 'indexes' => [ |
| 571 | + 'acme_index' => [ |
| 572 | + 'types' => [ |
| 573 | + 'acme_type' => [ |
| 574 | + 'properties' => ['text' => null], |
| 575 | + 'persistence' => [ |
| 576 | + 'driver' => 'orm', |
| 577 | + 'model' => 'theModelClass', |
| 578 | + 'provider' => ['pager_provider' => true], |
| 579 | + 'listener' => [ |
| 580 | + 'enabled' => false, |
| 581 | + ], |
| 582 | + 'finder' => null, |
| 583 | + ] |
| 584 | + ] |
| 585 | + ] |
| 586 | + ] |
| 587 | + ] |
| 588 | + ] |
| 589 | + ], $container); |
| 590 | + |
| 591 | + $this->assertFalse($container->hasDefinition('fos_elastica.listener.acme_index.acme_type')); |
| 592 | + } |
524 | 593 | } |
0 commit comments