#6017 moving tests around clear()
into the EntityManager
tests
`UnitOfWork` assumptions are OK, since we don't want to clutter the API even more down there
This commit is contained in:
parent
49333867f8
commit
92274124f9
@ -3,15 +3,20 @@
|
||||
namespace Doctrine\Tests\ORM;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
use Doctrine\ORM\Configuration;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\ORM\ORMInvalidArgumentException;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\Tests\Models\GeoNames\Country;
|
||||
use Doctrine\Tests\OrmTestCase;
|
||||
|
||||
class EntityManagerTest extends OrmTestCase
|
||||
{
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $_em;
|
||||
|
||||
function setUp()
|
||||
@ -217,4 +222,60 @@ class EntityManagerTest extends OrmTestCase
|
||||
$config->setMetadataDriverImpl($this->createMock(MappingDriver::class));
|
||||
EntityManager::create(1, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 6017
|
||||
*/
|
||||
public function testClearManagerWithObject()
|
||||
{
|
||||
$entity = new Country(456, 'United Kingdom');
|
||||
|
||||
$this->expectException(ORMInvalidArgumentException::class);
|
||||
|
||||
$this->_em->clear($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 6017
|
||||
*/
|
||||
public function testClearManagerWithUnknownEntityName()
|
||||
{
|
||||
$this->expectException(MappingException::class);
|
||||
|
||||
$this->_em->clear(uniqid('nonExisting', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 6017
|
||||
*/
|
||||
public function testClearManagerWithProxyClassName()
|
||||
{
|
||||
$proxy = $this->_em->getReference(Country::class, ['id' => random_int(457, 100000)]);
|
||||
|
||||
$entity = new Country(456, 'United Kingdom');
|
||||
|
||||
$this->_em->persist($entity);
|
||||
|
||||
$this->assertTrue($this->_em->contains($entity));
|
||||
|
||||
$this->_em->clear(get_class($proxy));
|
||||
|
||||
$this->assertFalse($this->_em->contains($entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 6017
|
||||
*/
|
||||
public function testClearManagerWithNullValue()
|
||||
{
|
||||
$entity = new Country(456, 'United Kingdom');
|
||||
|
||||
$this->_em->persist($entity);
|
||||
|
||||
$this->assertTrue($this->_em->contains($entity));
|
||||
|
||||
$this->_em->clear(null);
|
||||
|
||||
$this->assertFalse($this->_em->contains($entity));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user