Skip to content

Commit

Permalink
Revert "implement getDocumentId (#733)"
Browse files Browse the repository at this point in the history
This reverts commit 1bd5744.

This change is a BC break and should have gone into the 2.0 branch only.
  • Loading branch information
dbu committed Feb 9, 2017
1 parent a3ac1d3 commit 2fe2c55
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 65 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,4 @@ public function getNodeForDocument($document)
{
return $this->wrapped->getNodeForDocument($document);
}

/**
* {@inheritDoc}
*/
public function getDocumentId($document)
{
return $this->wrapped->getDocumentId($document);
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/ODM/PHPCR/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,4 @@ public function getNodeForDocument($document)

return $this->session->getNode($path);
}

/**
* {@inheritdoc}
*/
public function getDocumentId($document)
{
return $this->unitOfWork->getDocumentId($document);
}
}
11 changes: 0 additions & 11 deletions lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -21,15 +19,11 @@ 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);

$this->assertEquals($dmMethods, $dmiMethods);
$this->assertEquals($dmMethods, $dmdMethods);
}
}

class OwnDocumentManager extends DocumentManagerDecorator
{
}
31 changes: 1 addition & 30 deletions tests/Doctrine/Tests/ODM/PHPCR/DocumentManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,7 +47,7 @@ public function testFindTranslation()

$this->assertNull($nonExistent);
}

/**
* @covers Doctrine\ODM\PHPCR\DocumentManager::create
* @covers Doctrine\ODM\PHPCR\DocumentManager::getConfiguration
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2fe2c55

Please sign in to comment.