From 2fe2c55e73c3a0b609ae8b24b6a32336382d5607 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 9 Feb 2017 13:13:23 +0100 Subject: [PATCH] Revert "implement getDocumentId (#733)" This reverts commit 1bd57448c0353eb587ca299e88338b288d8ac8c7. This change is a BC break and should have gone into the 2.0 branch only. --- CHANGELOG.md | 1 - .../Decorator/DocumentManagerDecorator.php | 8 ----- lib/Doctrine/ODM/PHPCR/DocumentManager.php | 8 ----- .../ODM/PHPCR/DocumentManagerInterface.php | 11 ------- .../DocumentManagerDecoratorTest.php | 8 +---- .../Tests/ODM/PHPCR/DocumentManagerTest.php | 31 +------------------ 6 files changed, 2 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8fbb8cb9..ffa4cbd93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ Changelog ----- * **2017-01-31** [Bugfix] Don't override ID generator when persisting children -* **2017-01-15** [Feature] `DocumentManager::getDocumentId()` to get the id of a managed document 1.4.0 ----- diff --git a/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php b/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php index 6d9a4bb0c..11225f791 100644 --- a/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php +++ b/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php @@ -452,12 +452,4 @@ public function getNodeForDocument($document) { return $this->wrapped->getNodeForDocument($document); } - - /** - * {@inheritDoc} - */ - public function getDocumentId($document) - { - return $this->wrapped->getDocumentId($document); - } } diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManager.php b/lib/Doctrine/ODM/PHPCR/DocumentManager.php index 0d46ec039..66b9ae8f3 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManager.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManager.php @@ -925,12 +925,4 @@ public function getNodeForDocument($document) return $this->session->getNode($path); } - - /** - * {@inheritdoc} - */ - public function getDocumentId($document) - { - return $this->unitOfWork->getDocumentId($document); - } } diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php index a41128131..67b492dc4 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php @@ -525,15 +525,4 @@ public function close(); * @throws PHPCRException if $document is not managed */ public function getNodeForDocument($document); - - /** - * Get the document identifier phpcr-odm is using. - * - * @param object $document A managed document - * - * @return string - * - * @throws PHPCRException if $document is not managed - */ - public function getDocumentId($document); } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Decorator/DocumentManagerDecoratorTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Decorator/DocumentManagerDecoratorTest.php index a215111a3..de4e5c012 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Decorator/DocumentManagerDecoratorTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Decorator/DocumentManagerDecoratorTest.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\ODM\PHPCR\Decorator; -use Doctrine\ODM\PHPCR\Decorator\DocumentManagerDecorator; -use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\Tests\ODM\PHPCR\PHPCRTestCase; /** @@ -21,7 +19,7 @@ public function testCheckIfAllPublicMethodsAreDecorated() $dmiMethods = array_diff($dmiMethods, array('__construct')); sort($dmiMethods); - $dmdMethods = get_class_methods('\Doctrine\Tests\ODM\PHPCR\Decorator\OwnDocumentManager'); + $dmdMethods = get_class_methods('Doctrine\ODM\PHPCR\\Decorator\DocumentManagerDecorator'); $dmdMethods = array_diff($dmdMethods, array('__construct')); sort($dmdMethods); @@ -29,7 +27,3 @@ public function testCheckIfAllPublicMethodsAreDecorated() $this->assertEquals($dmMethods, $dmdMethods); } } - -class OwnDocumentManager extends DocumentManagerDecorator -{ -} diff --git a/tests/Doctrine/Tests/ODM/PHPCR/DocumentManagerTest.php b/tests/Doctrine/Tests/ODM/PHPCR/DocumentManagerTest.php index efae4ab4a..e28d7a0b0 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/DocumentManagerTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/DocumentManagerTest.php @@ -4,7 +4,6 @@ use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; -use Doctrine\ODM\PHPCR\PHPCRException; use PHPCR\SessionInterface; use PHPCR\Transaction\UserTransactionInterface; use PHPCR\UnsupportedRepositoryOperationException; @@ -48,7 +47,7 @@ public function testFindTranslation() $this->assertNull($nonExistent); } - + /** * @covers Doctrine\ODM\PHPCR\DocumentManager::create * @covers Doctrine\ODM\PHPCR\DocumentManager::getConfiguration @@ -166,34 +165,6 @@ public function testCreateQueryBuilder() $qb = $dm->createQueryBuilder(); $this->assertInstanceOf('Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder', $qb); } - - public function testGetDocumentIdReturnsValueOfUnitOfWork() - { - $session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock(); - - $dm = DocumentManager::create($session); - - $obj = new \stdClass; - $uow = $dm->getUnitOfWork(); - - $reflectionProperty = new \ReflectionProperty($uow, 'documentIds'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($uow, array(spl_object_hash($obj) => '/foo')); - $reflectionProperty->setAccessible(false); - - $this->assertEquals('/foo', $dm->getDocumentId($obj)); - } - - /** - * @expectedException \Doctrine\ODM\PHPCR\PHPCRException - */ - public function testGetDocumentIdForNonManagedDocumentsReturnsNull() - { - $session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock(); - $dm = DocumentManager::create($session); - $obj = new \stdClass; - $dm->getDocumentId($obj); - } } class DocumentManagerGetClassMetadata extends DocumentManager