Permalink
Browse files

Remove EventListener

  • Loading branch information...
1 parent c6f8ef2 commit d265ac19510a2dcdb069b36baa1ad9ec0c1302d0 @Baachi Baachi committed Mar 20, 2013
View
45 lib/Doctrine/Search/Listener/MongoDBSearchListener.php
@@ -1,45 +0,0 @@
-<?php
-namespace Doctrine\Search\Listener;
-
-use Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs;
-use Doctrine\Search\SearchManager;
-use Doctrine\Search\Mapping\ClassMetadata;
-
-/**
- * Listener for MongoDB Events
- *
- * @todo: add SearchListenerInterface
- *
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
- * @author Mike Lohmann <mike.h.lohmann@googlemail.com>
- */
-
-class MongoDBSearchListener
-{
- private $searchManager;
-
- public function __construct(SearchManager $sm = null)
- {
- $this->searchManager = $sm ? : new SearchManager();
- }
-
- /**
- *
- * @param \Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs $eventargs
- * @return void
- */
- public function loadClassMetadata(LoadClassMetadataEventArgs $eventargs)
- {
- $this->searchManager->setObjectManager($eventargs->getDocumentManager());
- $reflClass = $eventargs->getClassMetadata()->getReflectionClass();
- $this->searchManager->loadClassMetadata($reflClass->getName());
- }
-
- /**
- * @return \Doctrine\Search\SearchManager
- */
- public function getSearchManager()
- {
- return $this->searchManager;
- }
-}
View
121 tests/Doctrine/Tests/Search/Listener/MongoDBSearchListenerTest.php
@@ -1,121 +0,0 @@
-<?php
-namespace Doctrine\Tests\Search\Listener;
-
-use Doctrine\ODM\MongoDB\Events;
-use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
-use Doctrine\Search\Mapping\Annotations as SEARCH;
-use Doctrine\ODM\MongoDB\Tests\BaseTest;
-use Doctrine\Search\Listener\MongoDBSearchListener;
-
-/**
- * Test class for MongoDBSearchListener.
- * Generated by PHPUnit on 2011-12-02 at 08:29:38.
- */
-class MongoDBSearchListenerTest extends \Doctrine\ODM\MongoDB\Tests\BaseTest
-{
-
-
- /**
- * @todo: Mock the whole thing and get rid of BaseTest
- * @return Doctrine\ODM\MongoDB\DocumentManager
- */
- private function getDocumentManager()
- {
- /*$dm = $this->getMock('Doctrine\ODM\MongoDB\DocumentManager');
- $config = $this->getMock('Doctrine\ODM\MongoDB\Configuration');
- $reader = $this->getMock('Doctrine\Common\Annotations\AnnotationReader');
- $driver = $this->getMock('DDoctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver');
-
- $config->expects($this->once())
- ->method('getProxyDir')
- ->will($this->returnValue(__DIR__ . '/../../../../Proxies'));
-
- $config->expects($this->once())
- ->method('getHydratorDir')
- ->will($this->returnValue(__DIR__ . '/../../../../Hydrators'));
-
- $config->expects($this->once())
- ->method('getHydratorNamespace')
- ->will($this->returnValue('Hydrators'));
-
- $config->expects($this->once())
- ->method('getProxyNamespace')
- ->will($this->returnValue('Proxies'));
-
- $config->expects($this->once())
- ->method('getDefaultDB')
- ->will($this->returnValue('doctrine_odm_tests'));*/
-
-
-
- $this->listener = new MongoDBSearchListener();
- $evm = $this->dm->getEventManager();
- $events = array(
- Events::loadClassMetadata
- );
- $evm->addEventListener($events, $this->listener);
- return $this->dm;
- }
-
-
- public function testLoadClassMetadata()
- {
- $dm = $this->getDocumentManager();
-
- $test = new TestBlogPost();
- $test->name = 'TestBlogPost';
- $dm->persist($test);
- //$dm->flush();
-
- $sm = $this->listener->getSearchManager();
- $mdf = $sm->getClassMetadataFactory();
-
- $this->assertTrue($mdf->hasMetadataFor('Doctrine\Tests\Search\Listener\TestBlogPost'));
-
- }
-
- /**
- * overwrite BaseTest::tearDown, because we don't have a connection
- * @return void
- */
- public function tearDown()
- {
-
- }
-}
-
-
-
-/**
- * @ODM\Document
- * @SEARCH\ElasticSearchable(numberOfShards=1, numberOfReplicas=1)
- * @SEARCH\Searchable(index="blog", type="post")
- *
- */
-class TestBlogPost
-{
- /** @ODM\Id */
- public $id;
-
- /**
- * @ODM\String
- * @SEARCH\Field(boost=2.0)
- */
- public $name;
-
- /**
- * @ODM\String
- * @SEARCH\Field(boost=2.0)
- */
- public $title;
-
- public function __construct($name = null)
- {
- $this->name = $name;
- }
-
- public function getName()
- {
- return $this->name;
- }
-}

0 comments on commit d265ac1

Please sign in to comment.