From d4a08f7ab76658e38a93d7705ad2881f911aecbd Mon Sep 17 00:00:00 2001 From: Stefan Kleff Date: Thu, 19 Sep 2013 14:16:33 +0200 Subject: [PATCH] Added unit test --- .../ORM/Functional/Ticket/DDC2692Test.php | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php new file mode 100644 index 000000000..2cdbfb0fe --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -0,0 +1,65 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2692Foo'), + )); + } catch(\Exception $e) { + return; + } + $this->_em->clear(); + } + + public function testListenerCalledOneOnPreFlush() + { + $listener = $this->getMock('Doctrine\Tests\ORM\Functional\Ticket\Listener', array('preFlush')); + $listener->expects($this->once())->method('preFlush'); + + $this->_em->getEventManager()->addEventSubscriber($listener); + + $this->_em->persist(new DDC2692Foo); + $this->_em->persist(new DDC2692Foo); + + $this->_em->flush(); + $this->_em->clear(); + } +} +/** + * @Entity @Table(name="ddc_2692_foo") + */ +class DDC2692Foo +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; +} + +class Listener implements EventSubscriber { + + public function getSubscribedEvents() { + return array(\Doctrine\ORM\Events::preFlush); + } + + public function preFlush(PreFlushEventArgs $args) { + } +} + +