Commit 96eaf67e authored by romanb's avatar romanb

[2.0][DDC-350] Fixed. Patch provided by Christian Heinrich.

parent ac62e4d9
......@@ -356,10 +356,13 @@ class EntityManager
*
* @param object $object The instance to make managed and persistent.
*/
public function persist($object)
public function persist($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->_errorIfClosed();
$this->_unitOfWork->persist($object);
$this->_unitOfWork->persist($entity);
}
/**
......@@ -372,6 +375,9 @@ class EntityManager
*/
public function remove($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->_errorIfClosed();
$this->_unitOfWork->remove($entity);
}
......@@ -384,6 +390,9 @@ class EntityManager
*/
public function refresh($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->_errorIfClosed();
$this->_unitOfWork->refresh($entity);
}
......@@ -399,6 +408,9 @@ class EntityManager
*/
public function detach($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->_unitOfWork->detach($entity);
}
......@@ -412,6 +424,9 @@ class EntityManager
*/
public function merge($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->_errorIfClosed();
return $this->_unitOfWork->merge($entity);
}
......
......@@ -83,6 +83,26 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('SELECT 1', $q->getDql());
}
static public function dataMethodsAffectedByNoObjectArguments()
{
return array(
array('persist'),
array('remove'),
array('merge'),
array('refresh'),
array('detach')
);
}
/**
* @dataProvider dataMethodsAffectedByNoObjectArguments
* @expectedException \InvalidArgumentException
* @param string $methodName
*/
public function testThrowsExceptionOnNonObjectValues($methodName) {
$this->_em->$methodName(null);
}
static public function dataAffectedByErrorIfClosedException()
{
return array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment