Skip to content

Commit

Permalink
Merge pull request #644 from coudenysj/1.2
Browse files Browse the repository at this point in the history
Allow changeset computations of removed documents
  • Loading branch information
lsmith77 committed Jul 3, 2015
2 parents 67fb147 + fb77d60 commit 92f4aea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Doctrine/ODM/PHPCR/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,8 @@ public function isScheduledForInsert($document)
public function computeSingleDocumentChangeSet($document)
{
$state = $this->getDocumentState($document);
if ($state !== self::STATE_MANAGED) {

if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) {
throw new InvalidArgumentException('Document has to be managed for single computation '.self::objToStr($document, $this->dm));
}

Expand Down
16 changes: 16 additions & 0 deletions tests/Doctrine/Tests/ODM/PHPCR/UnitOfWorkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ public function testUuid()
$uow = new UnitOfWork($dm);
$this->assertEquals('like-a-uuid', $method->invoke($uow));
}

/**
* @see https://github.com/doctrine/phpcr-odm/issues/637
* @covers Doctrine\ODM\PHPCR\UnitOfWork::computeSingleDocumentChangeSet
*/
public function testComputeSingleDocumentChangeSetForRemovedDocument()
{
$object = new UoWUser();
$object->username = "bar";
$object->id = '/somepath';

$this->uow->scheduleRemove($object);

// Should not throw "InvalidArgumentException: Document has to be managed for single computation"
$this->uow->computeSingleDocumentChangeSet($object);
}
}

class UoWUser
Expand Down
2 changes: 1 addition & 1 deletion tests/travis_doctrine_dbal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ fi
mysql -e 'create database IF NOT EXISTS phpcr_odm_tests;' -u root

cp ${SCRIPT_DIR}/../cli-config.doctrine_dbal.php.dist ${SCRIPT_DIR}/../cli-config.php
${SCRIPT_DIR}/../bin/phpcrodm jackalope:init:dbal
${SCRIPT_DIR}/../bin/phpcrodm jackalope:init:dbal --force
${SCRIPT_DIR}/../bin/phpcrodm doctrine:phpcr:register-system-node-types

0 comments on commit 92f4aea

Please sign in to comment.