diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 498c4a699..b45e4921b 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2270,6 +2270,10 @@ class UnitOfWork implements PropertyChangedListener */ public function lock($entity, $lockMode, $lockVersion = null) { + if ($entity === null) { + throw new \InvalidArgumentException("No entity passed to UnitOfWork#lock()."); + } + if ($this->getEntityState($entity, self::STATE_DETACHED) != self::STATE_MANAGED) { throw ORMInvalidArgumentException::entityNotManaged($entity); } diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 9a645d52e..97f60f859 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -220,6 +220,15 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase // This commit should not raise an E_NOTICE $this->_unitOfWork->commit(); } + + /** + * @group DDC-1984 + */ + public function testLockWithoutEntityThrowsException() + { + $this->setExpectedException('InvalidArgumentException'); + $this->_unitOfWork->lock(null, null, null); + } } /**