[2.0][DDC-350] Fixed. Patch provided by Christian Heinrich.
This commit is contained in:
parent
ac62e4d9bb
commit
96eaf67e0f
@ -356,10 +356,13 @@ class EntityManager
|
|||||||
*
|
*
|
||||||
* @param object $object The instance to make managed and persistent.
|
* @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->_errorIfClosed();
|
||||||
$this->_unitOfWork->persist($object);
|
$this->_unitOfWork->persist($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -372,6 +375,9 @@ class EntityManager
|
|||||||
*/
|
*/
|
||||||
public function remove($entity)
|
public function remove($entity)
|
||||||
{
|
{
|
||||||
|
if ( ! is_object($entity)) {
|
||||||
|
throw new \InvalidArgumentException(gettype($entity));
|
||||||
|
}
|
||||||
$this->_errorIfClosed();
|
$this->_errorIfClosed();
|
||||||
$this->_unitOfWork->remove($entity);
|
$this->_unitOfWork->remove($entity);
|
||||||
}
|
}
|
||||||
@ -384,6 +390,9 @@ class EntityManager
|
|||||||
*/
|
*/
|
||||||
public function refresh($entity)
|
public function refresh($entity)
|
||||||
{
|
{
|
||||||
|
if ( ! is_object($entity)) {
|
||||||
|
throw new \InvalidArgumentException(gettype($entity));
|
||||||
|
}
|
||||||
$this->_errorIfClosed();
|
$this->_errorIfClosed();
|
||||||
$this->_unitOfWork->refresh($entity);
|
$this->_unitOfWork->refresh($entity);
|
||||||
}
|
}
|
||||||
@ -399,6 +408,9 @@ class EntityManager
|
|||||||
*/
|
*/
|
||||||
public function detach($entity)
|
public function detach($entity)
|
||||||
{
|
{
|
||||||
|
if ( ! is_object($entity)) {
|
||||||
|
throw new \InvalidArgumentException(gettype($entity));
|
||||||
|
}
|
||||||
$this->_unitOfWork->detach($entity);
|
$this->_unitOfWork->detach($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,6 +424,9 @@ class EntityManager
|
|||||||
*/
|
*/
|
||||||
public function merge($entity)
|
public function merge($entity)
|
||||||
{
|
{
|
||||||
|
if ( ! is_object($entity)) {
|
||||||
|
throw new \InvalidArgumentException(gettype($entity));
|
||||||
|
}
|
||||||
$this->_errorIfClosed();
|
$this->_errorIfClosed();
|
||||||
return $this->_unitOfWork->merge($entity);
|
return $this->_unitOfWork->merge($entity);
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,26 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
$this->assertEquals('SELECT 1', $q->getDql());
|
$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()
|
static public function dataAffectedByErrorIfClosedException()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user