Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[WIP] Removed extra event classes, made more similar to Commons 2.4 #248

Closed
wants to merge 2 commits into from

4 participants

@dantleech
Collaborator

This is really a PR to continue the discussion started at #246.

Here I have:

  • Removed the duplicated events and replaced them with ManagerEventArgs
  • Added getObject and getObjectManager in addition to getDocument and getDocumentmanager
lib/Doctrine/ODM/PHPCR/UnitOfWork.php
@@ -42,6 +41,7 @@
use PHPCR\UnsupportedRepositoryOperationException;
use PHPCR\RepositoryException;
use PHPCR\Util\UUIDHelper;
+use Doctrine\ODM\PHPCR\Event\ManagerEventArgs;
@stof
stof added a note

Where is this class ?

thus, you should put the use statement with the other ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...ctrine/ODM/PHPCR/Event/LoadClassMetadataEventArgs.php
@@ -66,4 +66,14 @@ public function getDocumentManager()
{
return $this->dm;
}
+
+ /**
+ * Retrieve associated ObjectManager.
+ *
+ * @return \Doctrine\PHPCR\ODM\ObjectManager
@dbu Collaborator
dbu added a note

even though its called ObjectManager, this is the DocumentManager. The ObjectManager is a class from commons

@dbu Collaborator
dbu added a note

here we should extend https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php (if we need to add anything, otherwise just drop the class)

@dantleech Collaborator

Do we want to have the getDocument and getDocumentManager methods? I am thinking "yes" and assuming that we will replace all Document/DocumentManager references in the ODM with Object/ObjectManager at some point .. is that the plan? /cc @stof, @lsmith77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/ODM/PHPCR/Event/LifecycleEventArgs.php
@@ -49,4 +49,20 @@ public function getDocumentManager()
{
return $this->dm;
}
+
+ /**
+ * @return object
+ */
+ public function getObject()
@dbu Collaborator
dbu added a note

i think we should at least deprecate getDocument and getDocumentManager methods. and drop them before we release 1.0. we don't want to carry a bag of legacy before we even have the first release :-)

@dbu Collaborator
dbu added a note

and we must extend the commons LifecycleEventArgs here. this will give us getObjectManager and getObject methods for free. https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dbu
Collaborator

in commons 2.4 there are base classes for LifecycleEventArgs and LoadClassMetadata - we should use those, or extend if we have additional things.

i merged the move events in #246 - can you rebase this branch on master and make those LifecycleEventArgs with additional getSourcePath and getTargetPath methods? then we would have getObject and getObjectManager for free again...

@lsmith77
Owner

ping

@dantleech
Collaborator

forgot about this - havn't got any time today but should be able to sort it out tomorrow.

@dantleech
Collaborator

updated. have rebased and extended the Doctrine commons events and added proxies for getDocument/getDocumentManager with deprecation comments.

@stof stof commented on the diff
lib/Doctrine/ODM/PHPCR/Event/LifecycleEventArgs.php
((26 lines not shown))
*/
public function getDocument()
{
- return $this->document;
@stof
stof added a note

@lsmith77 @dbu What do you think about triggering a E_USER_DEPRECATED (similar to what Symfony 2.2 does) ?

@dbu Collaborator
dbu added a note

i think it makes sense, as we will drop it in a month anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stof stof commented on the diff
lib/Doctrine/ODM/PHPCR/Event/LifecycleEventArgs.php
((26 lines not shown))
*/
public function getDocument()
{
- return $this->document;
+ return $this->getEntity();
@stof
stof added a note

This should be getObject, not getEntity

@dbu Collaborator
dbu added a note

depends if we require commons 2.4 or commons 2.3.

if we would know if orm 2.3 will be compatible with commons 2.4 i would go for that immediately. but if not, we would prevent using orm 2.3 in the same project with phpcr-odm which would be bad, given that it might take some while until orm 2.4 becomes stable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dbu
Collaborator
dbu commented

cool, thanks a lot. if @beberlei could shed some light on the orm 2.3 with commons 2.4 question, we can merge this (and #214 too if orm 2.3 is compatible with commons 2.4). if not, i suggest we implement a getObject method ourselves here until we drop commons 2.3 support.

@dantleech you tested and built against commons 2.3, right? did you ever try if it also works with the current master of commons?

@stof

If you want to keep the compatibility with Common 2.3, you should indeed implement getObject for 2.3 to be sure it is there (otherwise, people would not be able to use it). But be careful when implementing this forward compatibility method to avoid triggering some infinite loop in 2.4

@dantleech
Collaborator

@dbu I get an error about the Annotation class on commons/master:

phpcr-odm git:(event_class_refactor) ✗ phpunit -c tests/phpunit_jackrabbit.xml.dist tests/Doctrine/Tests/ODM/PHPCR/Event
PHP Fatal error:  Class 'Doctrine\Common\Annotations\AnnotationRegistry' .... ( not found )
@stof

@dantleech in master, the annotation library has been moved from Common to a separate repo (required by Common in composer.json). So be careful if you are not using composer. You will need to get the new repos too

@dbu
Collaborator
dbu commented

ah yes, they got refactored out into their own repository to be used independently of doctrine. lets see if benjamin can clarify about 2.4 before doing anything more.

@dbu dbu was assigned
@dbu
Collaborator

superseeded by #288

@dbu dbu closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
27 lib/Doctrine/ODM/PHPCR/Event/LifecycleEventArgs.php
@@ -19,34 +19,25 @@
namespace Doctrine\ODM\PHPCR\Event;
-class LifecycleEventArgs extends \Doctrine\Common\EventArgs
-{
- private $document;
-
- /**
- * @var \Doctrine\ODM\PHPCR\DocumentManager
- */
- private $dm;
-
- public function __construct($document, $dm)
- {
- $this->document = $document;
- $this->dm = $dm;
- }
+use Doctrine\Common\Persistence\Event\LifecycleEventArgs as BaseLifecycleEventArgs;
+class LifecycleEventArgs extends BaseLifecycleEventArgs
+{
/**
- * @return object
+ * @deprecated Will be dropped in favor of getObject in 1.0
+ * @return object
*/
public function getDocument()
{
- return $this->document;
@stof
stof added a note

@lsmith77 @dbu What do you think about triggering a E_USER_DEPRECATED (similar to what Symfony 2.2 does) ?

@dbu Collaborator
dbu added a note

i think it makes sense, as we will drop it in a month anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return $this->getEntity();
@stof
stof added a note

This should be getObject, not getEntity

@dbu Collaborator
dbu added a note

depends if we require commons 2.4 or commons 2.3.

if we would know if orm 2.3 will be compatible with commons 2.4 i would go for that immediately. but if not, we would prevent using orm 2.3 in the same project with phpcr-odm which would be bad, given that it might take some while until orm 2.4 becomes stable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
/**
- * @return \Doctrine\ODM\PHPCR\DocumentManager
+ * @deprecated Will be dropped in favor of getObjectManager in 1.0
+ * @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
- return $this->dm;
+ return $this->getObjectManager();
}
}
View
43 lib/Doctrine/ODM/PHPCR/Event/LoadClassMetadataEventArgs.php
@@ -19,51 +19,18 @@
namespace Doctrine\ODM\PHPCR\Event;
-use Doctrine\Common\EventArgs;
+use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs as BaseLoadClassMetadataEventArgs;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
use Doctrine\ODM\PHPCR\DocumentManager;
-class LoadClassMetadataEventArgs extends EventArgs
+class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs
{
/**
- * @var \Doctrine\PHPCR\ODM\Mapping\ClassMetadata
- */
- private $classMetadata;
-
- /**
- * @var \Doctrine\PHPCR\ODM\DocumentManager
- */
- private $dm;
-
- /**
- * Constructor.
- *
- * @param \Doctrine\PHPCR\ODM\Mapping\ClassMetadataInfo $classMetadata
- * @param \Doctrine\PHPCR\ODM\DocumentManager $dm
- */
- public function __construct(ClassMetadata $classMetadata, DocumentManager $dm)
- {
- $this->classMetadata = $classMetadata;
- $this->dm = $dm;
- }
-
- /**
- * Retrieve associated ClassMetadata.
- *
- * @return \Doctrine\PHPCR\ODM\Mapping\ClassMetadataInfo
- */
- public function getClassMetadata()
- {
- return $this->classMetadata;
- }
-
- /**
- * Retrieve associated DocumentManager.
- *
- * @return \Doctrine\PHPCR\ODM\DocumentManager
+ * @deprecated Will be dropped in favor of getObjectManager in 1.0
+ * @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
- return $this->dm;
+ return $this->getObjectManager();
}
}
View
23 ...rine/ODM/PHPCR/Event/OnClearEventArgs.php → ...rine/ODM/PHPCR/Event/ManagerEventArgs.php
@@ -19,28 +19,17 @@
namespace Doctrine\ODM\PHPCR\Event;
-use Doctrine\Common\EventArgs;
+use Doctrine\Common\Persistence\ObjectManager;
+use Doctrine\Common\Persistence\Event\ManagerEventArgs as BaseManagerEventArgs;
-class OnClearEventArgs extends EventArgs
+class ManagerEventArgs extends BaseManagerEventArgs
{
/**
- * @var \Doctrine\ODM\PHPCR\DocumentManager
- */
- private $dm;
-
- /**
- * @param \Doctrine\ODM\PHPCR\DocumentManager $dm
- */
- public function __construct($dm)
- {
- $this->dm = $dm;
- }
-
- /**
- * @return \Doctrine\ODM\PHPCR\DocumentManager
+ * @deprecated Will be dropped in favor of getObjectManager in 1.0
+ * @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
- return $this->dm;
+ return $this->getObjectManager();
}
}
View
36 lib/Doctrine/ODM/PHPCR/Event/MoveEventArgs.php
@@ -20,21 +20,10 @@
namespace Doctrine\ODM\PHPCR\Event;
-/**
- * MoveEventArgs
- */
-class MoveEventArgs extends \Doctrine\Common\EventArgs
-{
- /**
- * @var object
- */
- private $document;
-
- /**
- * @var \Doctrine\ODM\PHPCR\DocumentManager
- */
- private $dm;
+use Doctrine\Common\Persistence\ObjectManager;
+class MoveEventArgs extends LifecycleEventArgs
+{
/**
* @var string
*/
@@ -53,32 +42,29 @@ class MoveEventArgs extends \Doctrine\Common\EventArgs
* @param string $sourcePath The source path
* @param string $targetPath The target path
*/
- public function __construct($document, $dm, $sourcePath, $targetPath)
+ public function __construct($document, ObjectManager $om, $sourcePath, $targetPath)
{
- $this->document = $document;
- $this->dm = $dm;
+ parent::__construct($document, $om);
$this->sourcePath = $sourcePath;
$this->targetPath = $targetPath;
}
/**
- * Get the document
- *
- * @return object
+ * @deprecated Will be dropped in favor of getObject in 1.0
+ * @return object
*/
public function getDocument()
{
- return $this->document;
+ return $this->getEntity();
}
/**
- * Get the document manager
- *
- * @return \Doctrine\ODM\PHPCR\DocumentManager
+ * @deprecated Will be dropped in favor of getObjectManager in 1.0
+ * @return \Doctrine\ODM\PHPCR\DocumentManager
*/
public function getDocumentManager()
{
- return $this->dm;
+ return $this->getObjectManager();
}
/**
View
46 lib/Doctrine/ODM/PHPCR/Event/OnFlushEventArgs.php
@@ -1,46 +0,0 @@
-<?php
-/*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the MIT license. For more information, see
- * <http://www.doctrine-project.org>.
- */
-
-namespace Doctrine\ODM\PHPCR\Event;
-
-use Doctrine\Common\EventArgs;
-
-class OnFlushEventArgs extends EventArgs
-{
- /**
- * @var \Doctrine\ODM\PHPCR\DocumentManager
- */
- private $dm;
-
- /**
- * @param \Doctrine\ODM\PHPCR\DocumentManager $dm
- */
- public function __construct($dm)
- {
- $this->dm = $dm;
- }
-
- /**
- * @return \Doctrine\ODM\PHPCR\DocumentManager
- */
- public function getDocumentManager()
- {
- return $this->dm;
- }
-}
View
51 lib/Doctrine/ODM/PHPCR/Event/PostFlushEventArgs.php
@@ -1,51 +0,0 @@
-<?php
-/*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the MIT license. For more information, see
- * <http://www.doctrine-project.org>.
- */
-
-namespace Doctrine\ODM\PHPCR\Event;
-
-use Doctrine\Common\EventArgs;
-use Doctrine\ODM\PHPCR\DocumentManager;
-
-class PostFlushEventArgs extends EventArgs
-{
- /**
- * @var \Doctrine\ODM\PHPCR\DocumentManager
- */
- private $dm;
-
- /**
- * Constructor.
- *
- * @param \Doctrine\ODM\PHPCR\DocumentManager $em
- */
- public function __construct(DocumentManager $dm)
- {
- $this->dm = $dm;
- }
-
- /**
- * Retrieve associated DocumentManager.
- *
- * @return \Doctrine\ODM\PHPCR\DocumentManager
- */
- public function getDocumentManager()
- {
- return $this->dm;
- }
-}
View
46 lib/Doctrine/ODM/PHPCR/Event/PreFlushEventArgs.php
@@ -1,46 +0,0 @@
-<?php
-/*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the MIT license. For more information, see
- * <http://www.doctrine-project.org>.
- */
-
-namespace Doctrine\ODM\PHPCR\Event;
-
-use Doctrine\Common\EventArgs;
-
-class PreFlushEventArgs extends EventArgs
-{
- /**
- * @var \Doctrine\ODM\PHPCR\DocumentManager
- */
- private $dm;
-
- /**
- * @param \Doctrine\ODM\PHPCR\DocumentManager $dm
- */
- public function __construct($dm)
- {
- $this->dm = $dm;
- }
-
- /**
- * @return \Doctrine\ODM\PHPCR\DocumentManager
- */
- public function getDocumentManager()
- {
- return $this->dm;
- }
-}
View
12 lib/Doctrine/ODM/PHPCR/UnitOfWork.php
@@ -27,12 +27,12 @@
use Doctrine\ODM\PHPCR\Exception\MissingTranslationException;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
-use Doctrine\ODM\PHPCR\Event\LifecycleEventArgs;
use Doctrine\ODM\PHPCR\Event\OnFlushEventArgs;
+use Doctrine\ODM\PHPCR\Event\LifecycleEventArgs;
use Doctrine\ODM\PHPCR\Event\PreFlushEventArgs;
use Doctrine\ODM\PHPCR\Event\PostFlushEventArgs;
-use Doctrine\ODM\PHPCR\Event\OnClearEventArgs;
use Doctrine\ODM\PHPCR\Event\MoveEventArgs;
+use Doctrine\ODM\PHPCR\Event\ManagerEventArgs;
use Doctrine\ODM\PHPCR\Proxy\Proxy;
use Jackalope\Session as JackalopeSession;
@@ -1615,7 +1615,7 @@ public function commit($document = null)
{
// Raise preFlush
if ($this->evm->hasListeners(Event::preFlush)) {
- $this->evm->dispatchEvent(Event::preFlush, new PreFlushEventArgs($this->dm));
+ $this->evm->dispatchEvent(Event::preFlush, new ManagerEventArgs($this->dm));
}
if ($document === null) {
@@ -1629,7 +1629,7 @@ public function commit($document = null)
}
if ($this->evm->hasListeners(Event::onFlush)) {
- $this->evm->dispatchEvent(Event::onFlush, new OnFlushEventArgs($this->dm));
+ $this->evm->dispatchEvent(Event::onFlush, new ManagerEventArgs($this->dm));
}
try {
@@ -1680,7 +1680,7 @@ public function commit($document = null)
// Raise postFlush
if ($this->evm->hasListeners(Event::postFlush)) {
- $this->evm->dispatchEvent(Event::postFlush, new PostFlushEventArgs($this->dm));
+ $this->evm->dispatchEvent(Event::postFlush, new ManagerEventArgs($this->dm));
}
$this->documentTranslations =
@@ -2507,7 +2507,7 @@ public function clear()
$this->documentVersion = array();
if ($this->evm->hasListeners(Event::onClear)) {
- $this->evm->dispatchEvent(Event::onClear, new OnClearEventArgs($this->dm));
+ $this->evm->dispatchEvent(Event::onClear, new ManagerEventArgs($this->dm));
}
$this->session->refresh(false);
View
32 tests/Doctrine/Tests/ODM/PHPCR/Event/LifecycleEventArgsTest.php
@@ -0,0 +1,32 @@
+<?php
+
+use Doctrine\ODM\PHPCR\Event\LifecycleEventArgs;
+
+class LifecycleEventArgsTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->dm = $this->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->object = new \stdClass;
+
+ $this->eventArgs = new LifecycleEventArgs(
+ $this->object,
+ $this->dm
+ );
+ }
+
+ public function testGetDocumentManager()
+ {
+ $res = $this->eventArgs->getDocumentManager();
+ $this->assertSame($this->dm, $res);
+ }
+
+ public function testGetDocument()
+ {
+ $res = $this->eventArgs->getDocument();
+ $this->assertSame($this->object, $res);
+ }
+}
+
View
1  tests/Doctrine/Tests/ODM/PHPCR/Event/LoadClassMetadataEventTest.php
@@ -2,7 +2,6 @@
use Doctrine\ODM\PHPCR\Event\LoadClassMetadataEventArgs;
-
class LoadClassMetadataEventArgsTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
View
13 ...DM/PHPCR/Event/PostFlushEventArgsTest.php → .../ODM/PHPCR/Event/ManagerEventArgsTest.php
@@ -1,16 +1,15 @@
<?php
-use Doctrine\ODM\PHPCR\Event\PostFlushEventArgs;
+use Doctrine\ODM\PHPCR\Event\ManagerEventArgs;
-
-class PostFlushEventArgsTest extends \PHPUnit_Framework_TestCase
+class ManagerEventArgsTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->dm = $this->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
->disableOriginalConstructor()
->getMock();
- $this->postFlushEventArgs = new PostFlushEventArgs($this->dm);
+ $this->postFlushEventArgs = new ManagerEventArgs($this->dm);
}
public function testGetDocumentManager()
@@ -18,4 +17,10 @@ public function testGetDocumentManager()
$res = $this->postFlushEventArgs->getDocumentManager();
$this->assertSame($this->dm, $res);
}
+
+ public function testGetObjectManager()
+ {
+ $res = $this->postFlushEventArgs->getObjectManager();
+ $this->assertSame($this->dm, $res);
+ }
}
View
46 tests/Doctrine/Tests/ODM/PHPCR/Event/MoveEventArgsTest.php
@@ -0,0 +1,46 @@
+<?php
+
+use Doctrine\ODM\PHPCR\Event\MoveEventArgs;
+
+class MoveEventArgsTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->dm = $this->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->object = new \stdClass;
+
+ $this->eventArgs = new MoveEventArgs(
+ $this->object,
+ $this->dm,
+ 'source/path',
+ 'target/path'
+ );
+ }
+
+ public function testGetDocumentManager()
+ {
+ $res = $this->eventArgs->getDocumentManager();
+ $this->assertSame($this->dm, $res);
+ }
+
+ public function testGetDocument()
+ {
+ $res = $this->eventArgs->getDocument();
+ $this->assertSame($this->object, $res);
+ }
+
+ public function testGetSourcePath()
+ {
+ $path = $this->eventArgs->getSourcePath();
+ $this->assertEquals('source/path', $path);
+ }
+
+ public function testGetTargetPath()
+ {
+ $path = $this->eventArgs->getTargetPath();
+ $this->assertEquals('target/path', $path);
+ }
+}
+
View
21 tests/Doctrine/Tests/ODM/PHPCR/Event/PreFlushEventArgsTest.php
@@ -1,21 +0,0 @@
-<?php
-
-use Doctrine\ODM\PHPCR\Event\PreFlushEventArgs;
-
-
-class PreFlushEventArgsTest extends \PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- $this->dm = $this->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
- ->disableOriginalConstructor()
- ->getMock();
- $this->preFlushEventArgs = new PreFlushEventArgs($this->dm);
- }
-
- public function testGetDocumentManager()
- {
- $res = $this->preFlushEventArgs->getDocumentManager();
- $this->assertSame($this->dm, $res);
- }
-}
View
7 tests/Doctrine/Tests/ODM/PHPCR/Functional/EventManagerTest.php
@@ -7,8 +7,7 @@
use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase;
use Doctrine\Tests\Models\CMS\CmsPage;
use Doctrine\Tests\Models\CMS\CmsItem;
-use Doctrine\ODM\PHPCR\Event\PostFlushEventArgs;
-use Doctrine\ODM\PHPCR\Event\PreFlushEventArgs;
+use Doctrine\ODM\PHPCR\Event\ManagerEventArgs;
class EventManagerTest extends PHPCRFunctionalTestCase
{
@@ -213,12 +212,12 @@ public function onFlush(EventArgs $e)
$this->onFlush = true;
}
- public function postFlush(PostFlushEventArgs $e)
+ public function postFlush(ManagerEventArgs $e)
{
$this->postFlush = true;
}
- public function preFlush(PreFlushEventArgs $e)
+ public function preFlush(ManagerEventArgs $e)
{
$this->preFlush = true;
}
Something went wrong with that request. Please try again.