1
0
mirror of synced 2025-02-03 05:49:25 +03:00

Fix some code style issues in tests

This commit is contained in:
Luís Cobucci 2017-05-31 07:59:04 +02:00
parent c0c08d92ba
commit 043ca69f0b
No known key found for this signature in database
GPG Key ID: EC61C5F01750ED3C
39 changed files with 373 additions and 331 deletions

View File

@ -7,12 +7,14 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
class NegativeToPositiveType extends Type class NegativeToPositiveType extends Type
{ {
const NAME = 'negative_to_positive';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getName() public function getName()
{ {
return 'negative_to_positive'; return self::NAME;
} }
/** /**

View File

@ -7,12 +7,14 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
class UpperCaseStringType extends StringType class UpperCaseStringType extends StringType
{ {
const NAME = 'upper_case_string';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getName() public function getName()
{ {
return 'upper_case_string'; return self::NAME;
} }
/** /**

View File

@ -727,7 +727,6 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
*/ */
public function testNewAssociatedEntityDuringFlushThrowsException() public function testNewAssociatedEntityDuringFlushThrowsException()
{ {
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$user = new CmsUser(); $user = new CmsUser();
$user->username = "beberlei"; $user->username = "beberlei";
$user->name = "Benjamin E."; $user->name = "Benjamin E.";

View File

@ -2,16 +2,16 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Proxy\Proxy; use Doctrine\ORM\Proxy\Proxy;
use Doctrine\Tests\Models\Company\CompanyPerson, use Doctrine\Tests\Models\Company\CompanyAuction;
Doctrine\Tests\Models\Company\CompanyEmployee, use Doctrine\Tests\Models\Company\CompanyEmployee;
Doctrine\Tests\Models\Company\CompanyManager, use Doctrine\Tests\Models\Company\CompanyEvent;
Doctrine\Tests\Models\Company\CompanyOrganization, use Doctrine\Tests\Models\Company\CompanyManager;
Doctrine\Tests\Models\Company\CompanyAuction, use Doctrine\Tests\Models\Company\CompanyOrganization;
Doctrine\Tests\Models\Company\CompanyRaffle; use Doctrine\Tests\Models\Company\CompanyPerson;
use Doctrine\Tests\Models\Company\CompanyRaffle;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/** /**
@ -24,8 +24,8 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
$this->useModelSet('company'); $this->useModelSet('company');
parent::setUp(); parent::setUp();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
} }
public function testCRUD() public function testCRUD()
@ -47,7 +47,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery("select p from Doctrine\Tests\Models\Company\CompanyPerson p order by p.name desc"); $query = $this->_em->createQuery('select p from ' . CompanyPerson::class . ' p order by p.name desc');
$entities = $query->getResult(); $entities = $query->getResult();
@ -62,7 +62,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery("select p from Doctrine\Tests\Models\Company\CompanyEmployee p"); $query = $this->_em->createQuery('select p from ' . CompanyEmployee::class . ' p');
$entities = $query->getResult(); $entities = $query->getResult();
@ -80,7 +80,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery("update Doctrine\Tests\Models\Company\CompanyEmployee p set p.name = ?1, p.department = ?2 where p.name='Guilherme Blanco' and p.salary = ?3"); $query = $this->_em->createQuery("update " . CompanyEmployee::class . " p set p.name = ?1, p.department = ?2 where p.name='Guilherme Blanco' and p.salary = ?3");
$query->setParameter(1, 'NewName', 'string'); $query->setParameter(1, 'NewName', 'string');
$query->setParameter(2, 'NewDepartment'); $query->setParameter(2, 'NewDepartment');
$query->setParameter(3, 100000); $query->setParameter(3, 100000);
@ -88,12 +88,13 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$numUpdated = $query->execute(); $numUpdated = $query->execute();
$this->assertEquals(1, $numUpdated); $this->assertEquals(1, $numUpdated);
$query = $this->_em->createQuery("delete from Doctrine\Tests\Models\Company\CompanyPerson p"); $query = $this->_em->createQuery('delete from ' . CompanyPerson::class . ' p');
$numDeleted = $query->execute(); $numDeleted = $query->execute();
$this->assertEquals(2, $numDeleted); $this->assertEquals(2, $numDeleted);
} }
public function testMultiLevelUpdateAndFind() { public function testMultiLevelUpdateAndFind()
{
$manager = new CompanyManager; $manager = new CompanyManager;
$manager->setName('Roman S. Borschel'); $manager->setName('Roman S. Borschel');
$manager->setSalary(100000); $manager->setSalary(100000);
@ -119,7 +120,8 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->assertTrue(is_numeric($manager->getId())); $this->assertTrue(is_numeric($manager->getId()));
} }
public function testFindOnBaseClass() { public function testFindOnBaseClass()
{
$manager = new CompanyManager; $manager = new CompanyManager;
$manager->setName('Roman S. Borschel'); $manager->setName('Roman S. Borschel');
$manager->setSalary(100000); $manager->setSalary(100000);
@ -139,7 +141,8 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->assertTrue(is_numeric($person->getId())); $this->assertTrue(is_numeric($person->getId()));
} }
public function testSelfReferencingOneToOne() { public function testSelfReferencingOneToOne()
{
$manager = new CompanyManager; $manager = new CompanyManager;
$manager->setName('John Smith'); $manager->setName('John Smith');
$manager->setSalary(100000); $manager->setSalary(100000);
@ -155,16 +158,10 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->persist($manager); $this->_em->persist($manager);
$this->_em->persist($wife); $this->_em->persist($wife);
$this->_em->flush(); $this->_em->flush();
//var_dump($this->_em->getConnection()->fetchAll('select * from company_persons'));
//var_dump($this->_em->getConnection()->fetchAll('select * from company_employees'));
//var_dump($this->_em->getConnection()->fetchAll('select * from company_managers'));
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery('select p, s from Doctrine\Tests\Models\Company\CompanyPerson p join p.spouse s where p.name=\'Mary Smith\''); $query = $this->_em->createQuery('select p, s from ' . CompanyPerson::class . ' p join p.spouse s where p.name=\'Mary Smith\'');
$result = $query->getResult(); $result = $query->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
@ -196,7 +193,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery('select p, f from Doctrine\Tests\Models\Company\CompanyPerson p join p.friends f where p.name=?1'); $query = $this->_em->createQuery('select p, f from ' . CompanyPerson::class . ' p join p.friends f where p.name=?1');
$query->setParameter(1, 'Roman'); $query->setParameter(1, 'Roman');
$result = $query->getResult(); $result = $query->getResult();
@ -247,7 +244,6 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
} }
} }
public function testLazyLoading2() public function testLazyLoading2()
{ {
$org = new CompanyOrganization; $org = new CompanyOrganization;
@ -259,16 +255,16 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyEvent a where a.id = ?1'); $q = $this->_em->createQuery('select a from ' . CompanyEvent::class . ' a where a.id = ?1');
$q->setParameter(1, $event1->getId()); $q->setParameter(1, $event1->getId());
$result = $q->getResult(); $result = $q->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf(CompanyAuction::class, $result[0], sprintf("Is of class %s",get_class($result[0]))); $this->assertInstanceOf(CompanyAuction::class, $result[0], sprintf("Is of class %s", get_class($result[0])));
$this->_em->clear(); $this->_em->clear();
$q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyOrganization a where a.id = ?1'); $q = $this->_em->createQuery('select a from ' . CompanyOrganization::class . ' a where a.id = ?1');
$q->setParameter(1, $org->getId()); $q->setParameter(1, $org->getId());
$result = $q->getResult(); $result = $q->getResult();
@ -287,8 +283,8 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
*/ */
public function testBulkUpdateIssueDDC368() public function testBulkUpdateIssueDDC368()
{ {
$dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1'; $this->_em->createQuery('UPDATE ' . CompanyEmployee::class . ' AS p SET p.salary = 1')
$this->_em->createQuery($dql)->execute(); ->execute();
$this->assertTrue(count($this->_em->createQuery( $this->assertTrue(count($this->_em->createQuery(
'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1') 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')
@ -300,12 +296,10 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
*/ */
public function testBulkUpdateNonScalarParameterDDC1341() public function testBulkUpdateNonScalarParameterDDC1341()
{ {
$dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.startDate = ?0 WHERE p.department = ?1'; $this->_em->createQuery('UPDATE ' . CompanyEmployee::class . ' AS p SET p.startDate = ?0 WHERE p.department = ?1')
$query = $this->_em->createQuery($dql)
->setParameter(0, new \DateTime()) ->setParameter(0, new \DateTime())
->setParameter(1, 'IT'); ->setParameter(1, 'IT')
->execute();
$result = $query->execute();
} }
@ -314,8 +308,6 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
*/ */
public function testDeleteJoinTableRecords() public function testDeleteJoinTableRecords()
{ {
#$this->markTestSkipped('Nightmare! friends adds both ID 6-7 and 7-6 into two rows of the join table. How to detect this?');
$employee1 = new CompanyEmployee(); $employee1 = new CompanyEmployee();
$employee1->setName('gblanco'); $employee1->setName('gblanco');
$employee1->setSalary(0); $employee1->setSalary(0);
@ -361,8 +353,9 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m WHERE m.spouse = ?1"; $dqlManager = $this->_em->createQuery('SELECT m FROM ' . CompanyManager::class . ' m WHERE m.spouse = ?1')
$dqlManager = $this->_em->createQuery($dql)->setParameter(1, $person->getId())->getSingleResult(); ->setParameter(1, $person->getId())
->getSingleResult();
$this->assertEquals($manager->getId(), $dqlManager->getId()); $this->assertEquals($manager->getId(), $dqlManager->getId());
$this->assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); $this->assertEquals($person->getId(), $dqlManager->getSpouse()->getId());

View File

@ -23,7 +23,8 @@ class DetachedEntityTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
} }
public function testSimpleDetachMerge() { public function testSimpleDetachMerge()
{
$user = new CmsUser; $user = new CmsUser;
$user->name = 'Roman'; $user->name = 'Roman';
$user->username = 'romanb'; $user->username = 'romanb';
@ -33,13 +34,10 @@ class DetachedEntityTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
// $user is now detached // $user is now detached
$this->assertFalse($this->_em->contains($user)); $this->assertFalse($this->_em->contains($user));
$user->name = 'Roman B.'; $user->name = 'Roman B.';
//$this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_em->getUnitOfWork()->getEntityState($user));
$user2 = $this->_em->merge($user); $user2 = $this->_em->merge($user);
$this->assertFalse($user === $user2); $this->assertFalse($user === $user2);
@ -49,7 +47,6 @@ class DetachedEntityTest extends OrmFunctionalTestCase
public function testSerializeUnserializeModifyMerge() public function testSerializeUnserializeModifyMerge()
{ {
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$user = new CmsUser; $user = new CmsUser;
$user->name = 'Guilherme'; $user->name = 'Guilherme';
$user->username = 'gblanco'; $user->username = 'gblanco';
@ -173,7 +170,7 @@ class DetachedEntityTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->detach($user); $this->_em->detach($user);
$dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; $dql = 'SELECT u FROM ' . CmsUser::class . ' u WHERE u.id = ?1';
$query = $this->_em->createQuery($dql); $query = $this->_em->createQuery($dql);
$query->setParameter(1, $user); $query->setParameter(1, $user);
@ -216,7 +213,7 @@ class DetachedEntityTest extends OrmFunctionalTestCase
$this->_em->detach($article); $this->_em->detach($article);
$sql = "UPDATE cms_articles SET version = version+1 WHERE id = " . $article->id; $sql = 'UPDATE cms_articles SET version = version + 1 WHERE id = ' . $article->id;
$this->_em->getConnection()->executeUpdate($sql); $this->_em->getConnection()->executeUpdate($sql);
$this->expectException(OptimisticLockException::class); $this->expectException(OptimisticLockException::class);

View File

@ -19,6 +19,7 @@ class LockTest extends OrmFunctionalTestCase
{ {
$this->useModelSet('cms'); $this->useModelSet('cms');
parent::setUp(); parent::setUp();
$this->handles = []; $this->handles = [];
} }
@ -26,7 +27,8 @@ class LockTest extends OrmFunctionalTestCase
* @group DDC-178 * @group DDC-178
* @group locking * @group locking
*/ */
public function testLockVersionedEntity() { public function testLockVersionedEntity()
{
$article = new CmsArticle(); $article = new CmsArticle();
$article->text = "my article"; $article->text = "my article";
$article->topic = "Hello"; $article->topic = "Hello";
@ -41,7 +43,8 @@ class LockTest extends OrmFunctionalTestCase
* @group DDC-178 * @group DDC-178
* @group locking * @group locking
*/ */
public function testLockVersionedEntity_MismatchThrowsException() { public function testLockVersionedEntity_MismatchThrowsException()
{
$article = new CmsArticle(); $article = new CmsArticle();
$article->text = "my article"; $article->text = "my article";
$article->topic = "Hello"; $article->topic = "Hello";
@ -58,7 +61,8 @@ class LockTest extends OrmFunctionalTestCase
* @group DDC-178 * @group DDC-178
* @group locking * @group locking
*/ */
public function testLockUnversionedEntity_ThrowsException() { public function testLockUnversionedEntity_ThrowsException()
{
$user = new CmsUser(); $user = new CmsUser();
$user->name = "foo"; $user->name = "foo";
$user->status = "active"; $user->status = "active";
@ -76,11 +80,12 @@ class LockTest extends OrmFunctionalTestCase
* @group DDC-178 * @group DDC-178
* @group locking * @group locking
*/ */
public function testLockUnmanagedEntity_ThrowsException() { public function testLockUnmanagedEntity_ThrowsException()
{
$article = new CmsArticle(); $article = new CmsArticle();
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Entity Doctrine\Tests\Models\CMS\CmsArticle'); $this->expectExceptionMessage('Entity ' . CmsArticle::class);
$this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1);
} }
@ -89,7 +94,8 @@ class LockTest extends OrmFunctionalTestCase
* @group DDC-178 * @group DDC-178
* @group locking * @group locking
*/ */
public function testLockPessimisticRead_NoTransaction_ThrowsException() { public function testLockPessimisticRead_NoTransaction_ThrowsException()
{
$article = new CmsArticle(); $article = new CmsArticle();
$article->text = "my article"; $article->text = "my article";
$article->topic = "Hello"; $article->topic = "Hello";
@ -106,7 +112,8 @@ class LockTest extends OrmFunctionalTestCase
* @group DDC-178 * @group DDC-178
* @group locking * @group locking
*/ */
public function testLockPessimisticWrite_NoTransaction_ThrowsException() { public function testLockPessimisticWrite_NoTransaction_ThrowsException()
{
$article = new CmsArticle(); $article = new CmsArticle();
$article->text = "my article"; $article->text = "my article";
$article->topic = "Hello"; $article->topic = "Hello";
@ -171,6 +178,7 @@ class LockTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->beginTransaction(); $this->_em->beginTransaction();
try { try {
$this->_em->lock($article, LockMode::PESSIMISTIC_READ); $this->_em->lock($article, LockMode::PESSIMISTIC_READ);
$this->_em->commit(); $this->_em->commit();
@ -179,8 +187,9 @@ class LockTest extends OrmFunctionalTestCase
throw $e; throw $e;
} }
$query = array_pop( $this->_sqlLoggerStack->queries ); array_pop($this->_sqlLoggerStack->queries);
$query = array_pop( $this->_sqlLoggerStack->queries ); $query = array_pop($this->_sqlLoggerStack->queries);
$this->assertContains($readLockSql, $query['sql']); $this->assertContains($readLockSql, $query['sql']);
} }
@ -189,13 +198,13 @@ class LockTest extends OrmFunctionalTestCase
*/ */
public function testLockOptimisticNonVersionedThrowsExceptionInDQL() public function testLockOptimisticNonVersionedThrowsExceptionInDQL()
{ {
$dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'"; $dql = "SELECT u FROM " . CmsUser::class . " u WHERE u.username = 'gblanco'";
$this->expectException(OptimisticLockException::class); $this->expectException(OptimisticLockException::class);
$this->expectExceptionMessage('The optimistic lock on an entity failed.'); $this->expectExceptionMessage('The optimistic lock on an entity failed.');
$sql = $this->_em->createQuery($dql)->setHint( $this->_em->createQuery($dql)
Query::HINT_LOCK_MODE, LockMode::OPTIMISTIC ->setHint(Query::HINT_LOCK_MODE, LockMode::OPTIMISTIC)
)->getSQL(); ->getSQL();
} }
} }

View File

@ -25,6 +25,7 @@ class OptimisticTest extends OrmFunctionalTestCase
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }
$this->_conn = $this->_em->getConnection(); $this->_conn = $this->_em->getConnection();
} }
@ -168,7 +169,6 @@ class OptimisticTest extends OrmFunctionalTestCase
public function testLockWorksWithProxy() public function testLockWorksWithProxy()
{ {
$test = new OptimisticStandard(); $test = new OptimisticStandard();
$test->name = 'test'; $test->name = 'test';
$this->_em->persist($test); $this->_em->persist($test);

View File

@ -35,6 +35,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->useModelSet('cms'); $this->useModelSet('cms');
$this->useModelSet('company'); $this->useModelSet('company');
parent::setUp(); parent::setUp();
$this->platform = $this->_em->getConnection()->getDatabasePlatform(); $this->platform = $this->_em->getConnection()->getDatabasePlatform();
} }
@ -426,9 +427,9 @@ class NativeQueryTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository(CmsUser::class); $repository = $this->_em->getRepository(CmsUser::class);
$result = $repository->createNativeNamedQuery('fetchIdAndUsernameWithResultClass') $result = $repository->createNativeNamedQuery('fetchIdAndUsernameWithResultClass')
->setParameter(1, 'FabioBatSilva')->getResult(); ->setParameter(1, 'FabioBatSilva')
->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf(CmsUser::class, $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);
@ -439,9 +440,9 @@ class NativeQueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$result = $repository->createNativeNamedQuery('fetchAllColumns') $result = $repository->createNativeNamedQuery('fetchAllColumns')
->setParameter(1, 'FabioBatSilva')->getResult(); ->setParameter(1, 'FabioBatSilva')
->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf(CmsUser::class, $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);
@ -468,19 +469,16 @@ class NativeQueryTest extends OrmFunctionalTestCase
$addr->zip = 10827; $addr->zip = 10827;
$addr->city = 'São Paulo'; $addr->city = 'São Paulo';
$user->setAddress($addr); $user->setAddress($addr);
$this->_em->persist($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository(CmsUser::class); $result = $this->_em->getRepository(CmsUser::class)
->createNativeNamedQuery('fetchJoinedAddress')
->setParameter(1, 'FabioBatSilva')
$result = $repository->createNativeNamedQuery('fetchJoinedAddress') ->getResult();
->setParameter(1, 'FabioBatSilva')->getResult();
$this->assertEquals(1, count($result)); $this->assertEquals(1, count($result));
$this->assertInstanceOf(CmsUser::class, $result[0]); $this->assertInstanceOf(CmsUser::class, $result[0]);

View File

@ -16,6 +16,7 @@ class PersistentObjectTest extends OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
@ -23,8 +24,8 @@ class PersistentObjectTest extends OrmFunctionalTestCase
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
} }
PersistentObject::setObjectManager($this->_em); PersistentObject::setObjectManager($this->_em);
} }

View File

@ -26,6 +26,7 @@ class QueryTest extends OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
$this->useModelSet('cms'); $this->useModelSet('cms');
parent::setUp(); parent::setUp();
} }
@ -93,7 +94,7 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a ORDER BY a.topic"); $query = $this->_em->createQuery('select u, a from ' . CmsUser::class . ' u join u.articles a ORDER BY a.topic');
$users = $query->getResult(); $users = $query->getResult();
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
$this->assertInstanceOf(CmsUser::class, $users[0]); $this->assertInstanceOf(CmsUser::class, $users[0]);
@ -112,7 +113,7 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?0'); $q = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u WHERE u.username = ?0');
$q->setParameter(0, 'jwage'); $q->setParameter(0, 'jwage');
$user = $q->getSingleResult(); $user = $q->getSingleResult();
@ -124,7 +125,7 @@ class QueryTest extends OrmFunctionalTestCase
$this->expectException(QueryException::class); $this->expectException(QueryException::class);
$this->expectExceptionMessage('Invalid parameter: token 2 is not defined in the query.'); $this->expectExceptionMessage('Invalid parameter: token 2 is not defined in the query.');
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1'); $q = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u WHERE u.name = ?1');
$q->setParameter(2, 'jwage'); $q->setParameter(2, 'jwage');
$user = $q->getSingleResult(); $user = $q->getSingleResult();
} }
@ -134,7 +135,7 @@ class QueryTest extends OrmFunctionalTestCase
$this->expectException(QueryException::class); $this->expectException(QueryException::class);
$this->expectExceptionMessage('Too many parameters: the query defines 1 parameters and you bound 2'); $this->expectExceptionMessage('Too many parameters: the query defines 1 parameters and you bound 2');
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1'); $q = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u WHERE u.name = ?1');
$q->setParameter(1, 'jwage'); $q->setParameter(1, 'jwage');
$q->setParameter(2, 'jwage'); $q->setParameter(2, 'jwage');
@ -146,38 +147,35 @@ class QueryTest extends OrmFunctionalTestCase
$this->expectException(QueryException::class); $this->expectException(QueryException::class);
$this->expectExceptionMessage('Too few parameters: the query defines 1 parameters but you only bound 0'); $this->expectExceptionMessage('Too few parameters: the query defines 1 parameters but you only bound 0');
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1'); $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u WHERE u.name = ?1')
->getSingleResult();
$user = $q->getSingleResult();
} }
public function testInvalidInputParameterThrowsException() public function testInvalidInputParameterThrowsException()
{ {
$this->expectException(QueryException::class); $this->expectException(QueryException::class);
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?'); $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u WHERE u.name = ?')
$q->setParameter(1, 'jwage'); ->setParameter(1, 'jwage')
$user = $q->getSingleResult(); ->getSingleResult();
} }
public function testSetParameters() public function testSetParameters()
{ {
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1 AND u.status = ?2');
$parameters = new ArrayCollection(); $parameters = new ArrayCollection();
$parameters->add(new Parameter(1, 'jwage')); $parameters->add(new Parameter(1, 'jwage'));
$parameters->add(new Parameter(2, 'active')); $parameters->add(new Parameter(2, 'active'));
$q->setParameters($parameters); $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u WHERE u.name = ?1 AND u.status = ?2')
$users = $q->getResult(); ->setParameters($parameters)
->getResult();
} }
public function testSetParametersBackwardsCompatible() public function testSetParametersBackwardsCompatible()
{ {
$q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1 AND u.status = ?2'); $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u WHERE u.name = ?1 AND u.status = ?2')
$q->setParameters([1 => 'jwage', 2 => 'active']); ->setParameters([1 => 'jwage', 2 => 'active'])
->getResult();
$users = $q->getResult();
} }
/** /**
@ -200,18 +198,29 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$articleId = $article1->id; $articleId = $article1->id;
$query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = ?1"); $query = $this->_em->createQuery('select a from ' . CmsArticle::class . ' a WHERE a.topic = ?1');
$articles = $query->iterate(new ArrayCollection([new Parameter(1, 'Doctrine 2')]), Query::HYDRATE_ARRAY); $articles = $query->iterate(new ArrayCollection([new Parameter(1, 'Doctrine 2')]), Query::HYDRATE_ARRAY);
$found = []; $found = [];
foreach ($articles AS $article) { foreach ($articles AS $article) {
$found[] = $article; $found[] = $article;
} }
$this->assertEquals(1, count($found)); $this->assertEquals(1, count($found));
$this->assertEquals( $this->assertEquals(
[ [
[['id' => $articleId, 'topic' => 'Doctrine 2', 'text' => 'This is an introduction to Doctrine 2.', 'version' => 1]] [
], $found); [
'id' => $articleId,
'topic' => 'Doctrine 2',
'text' => 'This is an introduction to Doctrine 2.',
'version' => 1,
],
],
],
$found
);
} }
public function testIterateResult_IterativelyBuildUpUnitOfWork() public function testIterateResult_IterativelyBuildUpUnitOfWork()
@ -230,11 +239,12 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); $query = $this->_em->createQuery('select a from ' . CmsArticle::class . ' a');
$articles = $query->iterate(); $articles = $query->iterate();
$iteratedCount = 0; $iteratedCount = 0;
$topics = []; $topics = [];
foreach($articles AS $row) { foreach($articles AS $row) {
$article = $row[0]; $article = $row[0];
$topics[] = $article->topic; $topics[] = $article->topic;
@ -294,7 +304,7 @@ class QueryTest extends OrmFunctionalTestCase
*/ */
public function testIterateResult_FetchJoinedCollection_ThrowsException() public function testIterateResult_FetchJoinedCollection_ThrowsException()
{ {
$query = $this->_em->createQuery("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a"); $query = $this->_em->createQuery("SELECT u, a FROM ' . CmsUser::class . ' u JOIN u.articles a");
$articles = $query->iterate(); $articles = $query->iterate();
} }
@ -360,7 +370,7 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') $data = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u')
->setFirstResult(1) ->setFirstResult(1)
->setMaxResults(2) ->setMaxResults(2)
->getResult(); ->getResult();
@ -369,7 +379,7 @@ class QueryTest extends OrmFunctionalTestCase
$this->assertEquals('gblanco1', $data[0]->username); $this->assertEquals('gblanco1', $data[0]->username);
$this->assertEquals('gblanco2', $data[1]->username); $this->assertEquals('gblanco2', $data[1]->username);
$data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') $data = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u')
->setFirstResult(3) ->setFirstResult(3)
->setMaxResults(2) ->setMaxResults(2)
->getResult(); ->getResult();
@ -378,7 +388,7 @@ class QueryTest extends OrmFunctionalTestCase
$this->assertEquals('gblanco3', $data[0]->username); $this->assertEquals('gblanco3', $data[0]->username);
$this->assertEquals('gblanco4', $data[1]->username); $this->assertEquals('gblanco4', $data[1]->username);
$data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') $data = $this->_em->createQuery('SELECT u FROM ' . CmsUser::class . ' u')
->setFirstResult(3) ->setFirstResult(3)
->setMaxResults(2) ->setMaxResults(2)
->getScalarResult(); ->getScalarResult();
@ -472,13 +482,13 @@ class QueryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); $query = $this->_em->createQuery("select u from " . CmsUser::class . " u where u.username = 'gblanco'");
$fetchedUser = $query->getOneOrNullResult(); $fetchedUser = $query->getOneOrNullResult();
$this->assertInstanceOf(CmsUser::class, $fetchedUser); $this->assertInstanceOf(CmsUser::class, $fetchedUser);
$this->assertEquals('gblanco', $fetchedUser->username); $this->assertEquals('gblanco', $fetchedUser->username);
$query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); $query = $this->_em->createQuery("select u.username from " . CmsUser::class . " u where u.username = 'gblanco'");
$fetchedUsername = $query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR); $fetchedUsername = $query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR);
$this->assertEquals('gblanco', $fetchedUsername); $this->assertEquals('gblanco', $fetchedUsername);
} }

View File

@ -14,7 +14,7 @@ class SequenceGeneratorTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
if (!$this->_em->getConnection()->getDatabasePlatform()->supportsSequences()) { if ( ! $this->_em->getConnection()->getDatabasePlatform()->supportsSequences()) {
$this->markTestSkipped('Only working for Databases that support sequences.'); $this->markTestSkipped('Only working for Databases that support sequences.');
} }
@ -25,7 +25,6 @@ class SequenceGeneratorTest extends OrmFunctionalTestCase
] ]
); );
} catch(\Exception $e) { } catch(\Exception $e) {
} }
} }
@ -35,6 +34,7 @@ class SequenceGeneratorTest extends OrmFunctionalTestCase
$e = new SequenceEntity(); $e = new SequenceEntity();
$this->_em->persist($e); $this->_em->persist($e);
} }
$this->_em->flush(); $this->_em->flush();
} }
} }
@ -48,7 +48,7 @@ class SequenceEntity
* @Id * @Id
* @column(type="integer") * @column(type="integer")
* @GeneratedValue(strategy="SEQUENCE") * @GeneratedValue(strategy="SEQUENCE")
* @SequenceGenerator(allocationSize=5,sequenceName="person_id_seq") * @SequenceGenerator(allocationSize=5, sequenceName="person_id_seq")
*/ */
public $id; public $id;
} }

View File

@ -8,10 +8,10 @@ namespace Doctrine\Tests\ORM\Functional\Ticket;
*/ */
class DDC1113Test extends \Doctrine\Tests\OrmFunctionalTestCase class DDC1113Test extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
@ -22,7 +22,6 @@ class DDC1113Test extends \Doctrine\Tests\OrmFunctionalTestCase
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
} }
} }

View File

@ -21,7 +21,8 @@ class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
private $translation; private $translation;
private $articleDetails; private $articleDetails;
protected function setUp() { protected function setUp()
{
$this->useModelSet('ddc117'); $this->useModelSet('ddc117');
parent::setUp(); parent::setUp();
@ -63,7 +64,7 @@ class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT r, s FROM Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE r.source = ?1"; $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE r.source = ?1';
$dqlRef = $this->_em->createQuery($dql)->setParameter(1, 1)->getSingleResult(); $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 1)->getSingleResult();
$this->assertInstanceOf(DDC117Reference::class, $mapRef); $this->assertInstanceOf(DDC117Reference::class, $mapRef);
@ -73,7 +74,7 @@ class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT r, s FROM Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE s.title = ?1';
$dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult();
$this->assertInstanceOf(DDC117Reference::class, $dqlRef); $this->assertInstanceOf(DDC117Reference::class, $dqlRef);
@ -81,7 +82,7 @@ class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertInstanceOf(DDC117Article::class, $dqlRef->source()); $this->assertInstanceOf(DDC117Article::class, $dqlRef->source());
$this->assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria)); $this->assertSame($dqlRef, $this->_em->find(DDC117Reference::class, $idCriteria));
$dql = "SELECT r, s FROM Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; $dql = 'SELECT r, s FROM ' . DDC117Reference::class . ' r JOIN r.source s WHERE s.title = ?1';
$dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult();
$this->_em->contains($dqlRef); $this->_em->contains($dqlRef);
@ -265,12 +266,11 @@ class DDC117Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testOneToOneCascadePersist() public function testOneToOneCascadePersist()
{ {
if (!$this->_em->getConnection()->getDatabasePlatform()->prefersSequences()) { if ( ! $this->_em->getConnection()->getDatabasePlatform()->prefersSequences()) {
$this->markTestSkipped('Test only works with databases that prefer sequences as ID strategy.'); $this->markTestSkipped('Test only works with databases that prefer sequences as ID strategy.');
} }
$this->article1 = new DDC117Article("Foo"); $this->article1 = new DDC117Article("Foo");
$this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text"); $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text");
$this->_em->persist($this->article1); $this->_em->persist($this->article1);

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Functional\Ticket; namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsPhonenumber;
@ -13,6 +14,7 @@ class DDC1306Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function setUp() public function setUp()
{ {
$this->useModelSet('cms'); $this->useModelSet('cms');
parent::setUp(); parent::setUp();
} }
@ -25,7 +27,7 @@ class DDC1306Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($phone); $this->_em->persist($phone);
$this->_em->flush(); $this->_em->flush();
$address = new \Doctrine\Tests\Models\CMS\CmsAddress(); $address = new CmsAddress();
$address->city = "bonn"; $address->city = "bonn";
$address->country = "Germany"; $address->country = "Germany";
$address->street = "somestreet!"; $address->street = "somestreet!";

View File

@ -48,15 +48,14 @@ class DDC1400Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($userState1); $this->_em->persist($userState1);
$this->_em->persist($userState2); $this->_em->persist($userState2);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$user1 = $this->_em->getReference(DDC1400User::class, $user1->id); $user1 = $this->_em->getReference(DDC1400User::class, $user1->id);
$q = $this->_em->createQuery("SELECT a, s FROM ".__NAMESPACE__."\DDC1400Article a JOIN a.userStates s WITH s.user = :activeUser"); $this->_em->createQuery('SELECT a, s FROM ' . DDC1400Article::class . ' a JOIN a.userStates s WITH s.user = :activeUser')
$q->setParameter('activeUser', $user1); ->setParameter('activeUser', $user1)
$articles = $q->getResult(); ->getResult();
$this->_em->flush(); $this->_em->flush();
} }

View File

@ -8,7 +8,6 @@ class DDC144Test extends OrmFunctionalTestCase
{ {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
@ -24,10 +23,10 @@ class DDC144Test extends OrmFunctionalTestCase
*/ */
public function testIssue() public function testIssue()
{ {
$operand = new DDC144Operand; $operand = new DDC144Operand;
$operand->property = 'flowValue'; $operand->property = 'flowValue';
$operand->operandProperty = 'operandValue'; $operand->operandProperty = 'operandValue';
$this->_em->persist($operand); $this->_em->persist($operand);
$this->_em->flush(); $this->_em->flush();
@ -41,23 +40,30 @@ class DDC144Test extends OrmFunctionalTestCase
* @DiscriminatorColumn(type="string", name="discr") * @DiscriminatorColumn(type="string", name="discr")
* @DiscriminatorMap({"flowelement" = "DDC144FlowElement", "operand" = "DDC144Operand"}) * @DiscriminatorMap({"flowelement" = "DDC144FlowElement", "operand" = "DDC144Operand"})
*/ */
class DDC144FlowElement { class DDC144FlowElement
{
/** /**
* @Id @Column(type="integer") @GeneratedValue * @Id @Column(type="integer") @GeneratedValue
* @var int * @var int
*/ */
public $id; public $id;
/** @Column */ /** @Column */
public $property; public $property;
} }
abstract class DDC144Expression extends DDC144FlowElement { abstract class DDC144Expression extends DDC144FlowElement
abstract function method(); {
abstract public function method();
} }
/** @Entity @Table(name="ddc144_operands") */ /** @Entity @Table(name="ddc144_operands") */
class DDC144Operand extends DDC144Expression { class DDC144Operand extends DDC144Expression
{
/** @Column */ /** @Column */
public $operandProperty; public $operandProperty;
function method() {}
public function method()
{
}
} }

View File

@ -19,7 +19,6 @@ class DDC1454Test extends \Doctrine\Tests\OrmFunctionalTestCase
] ]
); );
} catch (\Exception $ignored) { } catch (\Exception $ignored) {
} }
} }
@ -36,7 +35,6 @@ class DDC1454Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
class DDC1454Picture extends DDC1454File class DDC1454Picture extends DDC1454File
{ {
} }
/** /**
@ -53,14 +51,16 @@ class DDC1454File
*/ */
public $fileId; public $fileId;
public function __construct() { public function __construct()
{
$this->fileId = rand(); $this->fileId = rand();
} }
/** /**
* Get fileId * Get fileId
*/ */
public function getFileId() { public function getFileId()
{
return $this->fileId; return $this->fileId;
} }

View File

@ -21,16 +21,18 @@ class DDC1925Test extends \Doctrine\Tests\OrmFunctionalTestCase
$user = new DDC1925User(); $user = new DDC1925User();
$user->setTitle("Test User"); $user->setTitle("Test User");
$this->_em->persist($user);
$product = new DDC1925Product(); $product = new DDC1925Product();
$product->setTitle("Test product"); $product->setTitle("Test product");
$this->_em->persist($user);
$this->_em->persist($product); $this->_em->persist($product);
$this->_em->flush(); $this->_em->flush();
$product->addBuyer($user); $product->addBuyer($user);
$this->_em->getUnitOfWork()->computeChangeSets(); $this->_em->getUnitOfWork()
->computeChangeSets();
$this->_em->persist($product); $this->_em->persist($product);
$this->_em->flush(); $this->_em->flush();
@ -104,15 +106,7 @@ class DDC1925Product
} }
/** /**
* @param string $buyers * @return ArrayCollection
*/
public function setBuyers($buyers)
{
$this->buyers = $buyers;
}
/**
* @return string
*/ */
public function getBuyers() public function getBuyers()
{ {

View File

@ -4,6 +4,9 @@ namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/**
* @group DDC-192
*/
class DDC192Test extends OrmFunctionalTestCase class DDC192Test extends OrmFunctionalTestCase
{ {
public function testSchemaCreation() public function testSchemaCreation()
@ -17,14 +20,15 @@ class DDC192Test extends OrmFunctionalTestCase
} }
} }
/** /**
* @Entity @Table(name="ddc192_users") * @Entity
* @Table(name="ddc192_users")
*/ */
class DDC192User class DDC192User
{ {
/** /**
* @Id @Column(name="id", type="integer") * @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue(strategy="AUTO")
*/ */
public $id; public $id;
@ -37,12 +41,14 @@ class DDC192User
/** /**
* @Entity @Table(name="ddc192_phonenumbers") * @Entity
* @Table(name="ddc192_phonenumbers")
*/ */
class DDC192Phonenumber class DDC192Phonenumber
{ {
/** /**
* @Id @Column(name="phone", type="string", length=40) * @Id
* @Column(name="phone", type="string", length=40)
*/ */
protected $phone; protected $phone;
@ -54,14 +60,23 @@ class DDC192Phonenumber
protected $User; protected $User;
public function setPhone($value) { $this->phone = $value; } public function setPhone($value)
{
$this->phone = $value;
}
public function getPhone() { return $this->phone; } public function getPhone()
{
return $this->phone;
}
public function setUser(User $user) public function setUser(User $user)
{ {
$this->User = $user; $this->User = $user;
} }
public function getUser() { return $this->User; } public function getUser()
{
return $this->User;
}
} }

View File

@ -12,6 +12,7 @@ class DDC2106Test extends \Doctrine\Tests\OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(DDC2106Entity::class), $this->_em->getClassMetadata(DDC2106Entity::class),

View File

@ -13,6 +13,7 @@ class DDC2256Test extends \Doctrine\Tests\OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(DDC2256User::class), $this->_em->getClassMetadata(DDC2256User::class),
@ -55,8 +56,7 @@ class DDC2256Test extends \Doctrine\Tests\OrmFunctionalTestCase
// Test ResultSetMappingBuilder. // Test ResultSetMappingBuilder.
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('MyNamespace:DDC2256User', 'u'); $rsm->addRootEntityFromClassMetadata('MyNamespace:DDC2256User', 'u');
$rsm->addJoinedEntityFromClassMetadata('MyNamespace:DDC2256Group', 'g', 'u', 'group', ['id' => 'group_id', 'name' => 'group_name'] $rsm->addJoinedEntityFromClassMetadata('MyNamespace:DDC2256Group', 'g', 'u', 'group', ['id' => 'group_id', 'name' => 'group_name']);
);
$this->_em->createNativeQuery($sql, $rsm)->getResult(); $this->_em->createNativeQuery($sql, $rsm)->getResult();
} }

View File

@ -30,9 +30,8 @@ class DDC2775Test extends OrmFunctionalTestCase
*/ */
public function testIssueCascadeRemove() public function testIssueCascadeRemove()
{ {
$user = new User();
$role = new AdminRole(); $role = new AdminRole();
$user = new User();
$user->addRole($role); $user->addRole($role);
$authorization = new Authorization(); $authorization = new Authorization();

View File

@ -38,10 +38,9 @@ class DDC3170Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testIssue() public function testIssue()
{ {
// $this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
$productJoined = new DDC3170ProductJoined(); $productJoined = new DDC3170ProductJoined();
$productSingleTable = new DDC3170ProductSingleTable(); $productSingleTable = new DDC3170ProductSingleTable();
$this->_em->persist($productJoined); $this->_em->persist($productJoined);
$this->_em->persist($productSingleTable); $this->_em->persist($productSingleTable);
$this->_em->flush(); $this->_em->flush();

View File

@ -26,6 +26,5 @@ class DDC3711Test extends YamlMappingDriverTest
$this->assertEquals(['link_a_id1' => "id1", 'link_a_id2' => "id2"], $entityA->associationMappings['entityB']['relationToSourceKeyColumns']); $this->assertEquals(['link_a_id1' => "id1", 'link_a_id2' => "id2"], $entityA->associationMappings['entityB']['relationToSourceKeyColumns']);
$this->assertEquals(['link_b_id1' => "id1", 'link_b_id2' => "id2"], $entityA->associationMappings['entityB']['relationToTargetKeyColumns']); $this->assertEquals(['link_b_id1' => "id1", 'link_b_id2' => "id2"], $entityA->associationMappings['entityB']['relationToTargetKeyColumns']);
} }
} }

View File

@ -31,15 +31,18 @@ class DDC3785Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testOwningValueObjectIdIsCorrectlyTransformedWhenRemovingOrphanedChildEntities() public function testOwningValueObjectIdIsCorrectlyTransformedWhenRemovingOrphanedChildEntities()
{ {
$id = new DDC3785_AssetId("919609ba-57d9-4a13-be1d-d202521e858a"); $id = new DDC3785_AssetId('919609ba-57d9-4a13-be1d-d202521e858a');
$attributes = [ $attributes = [
$attribute1 = new DDC3785_Attribute("foo1", "bar1"), $attribute1 = new DDC3785_Attribute('foo1', 'bar1'),
$attribute2 = new DDC3785_Attribute("foo2", "bar2") $attribute2 = new DDC3785_Attribute('foo2', 'bar2')
]; ];
$this->_em->persist($asset = new DDC3785_Asset($id, $attributes)); $this->_em->persist($asset = new DDC3785_Asset($id, $attributes));
$this->_em->flush(); $this->_em->flush();
$asset->getAttributes()->removeElement($attribute1); $asset->getAttributes()
->removeElement($attribute1);
$this->_em->persist($asset); $this->_em->persist($asset);
$this->_em->flush(); $this->_em->flush();

View File

@ -13,6 +13,7 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
@ -22,7 +23,6 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
] ]
); );
} catch(\Exception $e) { } catch(\Exception $e) {
} }
} }
@ -43,7 +43,7 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$r = $this->_em->createQuery("select ca,c from ".get_class($cart)." ca join ca.customer c") $r = $this->_em->createQuery('select ca,c from ' . DDC522Cart::class . ' ca join ca.customer c')
->getResult(); ->getResult();
$this->assertInstanceOf(DDC522Cart::class, $r[0]); $this->assertInstanceOf(DDC522Cart::class, $r[0]);
@ -71,7 +71,7 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function testJoinColumnWithNullSameNameAssociationField() public function testJoinColumnWithNullSameNameAssociationField()
{ {
$fkCust = new DDC522ForeignKeyTest; $fkCust = new DDC522ForeignKeyTest;
$fkCust->name = "name"; $fkCust->name = 'name';
$fkCust->cart = null; $fkCust->cart = null;
$this->_em->persist($fkCust); $this->_em->persist($fkCust);
@ -83,21 +83,27 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
} }
/** @Entity */ /** @Entity */
class DDC522Customer { class DDC522Customer
{
/** @Id @Column(type="integer") @GeneratedValue */ /** @Id @Column(type="integer") @GeneratedValue */
public $id; public $id;
/** @Column */ /** @Column */
public $name; public $name;
/** @OneToOne(targetEntity="DDC522Cart", mappedBy="customer") */ /** @OneToOne(targetEntity="DDC522Cart", mappedBy="customer") */
public $cart; public $cart;
} }
/** @Entity */ /** @Entity */
class DDC522Cart { class DDC522Cart
{
/** @Id @Column(type="integer") @GeneratedValue */ /** @Id @Column(type="integer") @GeneratedValue */
public $id; public $id;
/** @Column(type="integer") */ /** @Column(type="integer") */
public $total; public $total;
/** /**
* @OneToOne(targetEntity="DDC522Customer", inversedBy="cart") * @OneToOne(targetEntity="DDC522Customer", inversedBy="cart")
* @JoinColumn(name="customer", referencedColumnName="id") * @JoinColumn(name="customer", referencedColumnName="id")
@ -106,11 +112,14 @@ class DDC522Cart {
} }
/** @Entity */ /** @Entity */
class DDC522ForeignKeyTest { class DDC522ForeignKeyTest
{
/** @Id @Column(type="integer") @GeneratedValue */ /** @Id @Column(type="integer") @GeneratedValue */
public $id; public $id;
/** @Column(type="integer", name="cart_id", nullable=true) */ /** @Column(type="integer", name="cart_id", nullable=true) */
public $cartId; public $cartId;
/** /**
* @OneToOne(targetEntity="DDC522Cart") * @OneToOne(targetEntity="DDC522Cart")
* @JoinColumn(name="cart_id", referencedColumnName="id") * @JoinColumn(name="cart_id", referencedColumnName="id")

View File

@ -7,6 +7,7 @@ class DDC588Test extends \Doctrine\Tests\OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
$this->_em->getClassMetadata(DDC588Site::class), $this->_em->getClassMetadata(DDC588Site::class),

View File

@ -64,9 +64,9 @@ class DDC742Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$user = $this->_em->find(get_class($user), $user->id); $user = $this->_em->find(DDC742User::class, $user->id);
$comment3 = $this->_em->find(get_class($comment3), $comment3->id); $user->favoriteComments->add($this->_em->find(DDC742Comment::class, $comment3->id));
$user->favoriteComments->add($comment3);
$this->_em->flush(); $this->_em->flush();
} }
} }
@ -86,11 +86,13 @@ class DDC742User
* @var int * @var int
*/ */
public $id; public $id;
/** /**
* @Column(length=100, type="string") * @Column(length=100, type="string")
* @var string * @var string
*/ */
public $title; public $title;
/** /**
* @ManyToMany(targetEntity="DDC742Comment", cascade={"persist"}, fetch="EAGER") * @ManyToMany(targetEntity="DDC742Comment", cascade={"persist"}, fetch="EAGER")
* @JoinTable( * @JoinTable(
@ -99,7 +101,7 @@ class DDC742User
* inverseJoinColumns={@JoinColumn(name="comment_id", referencedColumnName="id")} * inverseJoinColumns={@JoinColumn(name="comment_id", referencedColumnName="id")}
* ) * )
* *
* @var Doctrine\ORM\PersistentCollection * @var \Doctrine\ORM\PersistentCollection
*/ */
public $favoriteComments; public $favoriteComments;
} }
@ -119,6 +121,7 @@ class DDC742Comment
* @var int * @var int
*/ */
public $id; public $id;
/** /**
* @Column(length=100, type="string") * @Column(length=100, type="string")
* @var string * @var string

View File

@ -7,12 +7,15 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$platform = $this->_em->getConnection()->getDatabasePlatform(); $platform = $this->_em->getConnection()->getDatabasePlatform();
if ($platform->getName() == "oracle") {
if ($platform->getName() === 'oracle') {
$this->markTestSkipped('Doesnt run on Oracle.'); $this->markTestSkipped('Doesnt run on Oracle.');
} }
$this->_em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); $this->_em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
try { try {
$this->_schemaTool->createSchema( $this->_schemaTool->createSchema(
[ [
@ -22,7 +25,6 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
] ]
); );
} catch(\Exception $e) { } catch(\Exception $e) {
} }
} }
@ -30,6 +32,7 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
$platform = $this->_em->getConnection()->getDatabasePlatform(); $platform = $this->_em->getConnection()->getDatabasePlatform();
$sm = $this->_em->getConnection()->getSchemaManager(); $sm = $this->_em->getConnection()->getSchemaManager();
$sm->dropTable($platform->quoteIdentifier('TREE_INDEX')); $sm->dropTable($platform->quoteIdentifier('TREE_INDEX'));
$sm->dropTable($platform->quoteIdentifier('INDEX')); $sm->dropTable($platform->quoteIdentifier('INDEX'));
@ -41,11 +44,11 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testQuotedTableBasicUpdate() public function testQuotedTableBasicUpdate()
{ {
$like = new DDC832Like("test"); $like = new DDC832Like('test');
$this->_em->persist($like); $this->_em->persist($like);
$this->_em->flush(); $this->_em->flush();
$like->word = "test2"; $like->word = 'test2';
$this->_em->flush(); $this->_em->flush();
} }
@ -54,7 +57,7 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testQuotedTableBasicRemove() public function testQuotedTableBasicRemove()
{ {
$like = new DDC832Like("test"); $like = new DDC832Like('test');
$this->_em->persist($like); $this->_em->persist($like);
$this->_em->flush(); $this->_em->flush();
@ -67,11 +70,11 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testQuotedTableJoinedUpdate() public function testQuotedTableJoinedUpdate()
{ {
$index = new DDC832JoinedIndex("test"); $index = new DDC832JoinedIndex('test');
$this->_em->persist($index); $this->_em->persist($index);
$this->_em->flush(); $this->_em->flush();
$index->name = "asdf"; $index->name = 'asdf';
$this->_em->flush(); $this->_em->flush();
} }
@ -80,7 +83,7 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testQuotedTableJoinedRemove() public function testQuotedTableJoinedRemove()
{ {
$index = new DDC832JoinedIndex("test"); $index = new DDC832JoinedIndex('test');
$this->_em->persist($index); $this->_em->persist($index);
$this->_em->flush(); $this->_em->flush();
@ -93,11 +96,11 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testQuotedTableJoinedChildUpdate() public function testQuotedTableJoinedChildUpdate()
{ {
$index = new DDC832JoinedTreeIndex("test", 1, 2); $index = new DDC832JoinedTreeIndex('test', 1, 2);
$this->_em->persist($index); $this->_em->persist($index);
$this->_em->flush(); $this->_em->flush();
$index->name = "asdf"; $index->name = 'asdf';
$this->_em->flush(); $this->_em->flush();
} }
@ -106,7 +109,7 @@ class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
public function testQuotedTableJoinedChildRemove() public function testQuotedTableJoinedChildRemove()
{ {
$index = new DDC832JoinedTreeIndex("test", 1, 2); $index = new DDC832JoinedTreeIndex('test', 1, 2);
$this->_em->persist($index); $this->_em->persist($index);
$this->_em->flush(); $this->_em->flush();
@ -178,6 +181,7 @@ class DDC832JoinedTreeIndex extends DDC832JoinedIndex
{ {
/** @Column(type="integer") */ /** @Column(type="integer") */
public $lft; public $lft;
/** @Column(type="integer") */ /** @Column(type="integer") */
public $rgt; public $rgt;

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Functional\Ticket; namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\DBAL\LockMode;
use Doctrine\Tests\Models\Company\CompanyManager;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
class DDC933Test extends OrmFunctionalTestCase class DDC933Test extends OrmFunctionalTestCase
@ -9,6 +11,7 @@ class DDC933Test extends OrmFunctionalTestCase
public function setUp() public function setUp()
{ {
$this->useModelSet('company'); $this->useModelSet('company');
parent::setUp(); parent::setUp();
} }
@ -17,9 +20,7 @@ class DDC933Test extends OrmFunctionalTestCase
*/ */
public function testLockCTIClass() public function testLockCTIClass()
{ {
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); $manager = new CompanyManager();
$manager = new \Doctrine\Tests\Models\Company\CompanyManager();
$manager->setName('beberlei'); $manager->setName('beberlei');
$manager->setSalary(1234); $manager->setSalary(1234);
$manager->setTitle('Vice President of This Test'); $manager->setTitle('Vice President of This Test');
@ -29,7 +30,7 @@ class DDC933Test extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->beginTransaction(); $this->_em->beginTransaction();
$this->_em->lock($manager, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ); $this->_em->lock($manager, LockMode::PESSIMISTIC_READ);
$this->_em->rollback(); $this->_em->rollback();
} }
} }

View File

@ -15,6 +15,7 @@ class TypeTest extends OrmFunctionalTestCase
protected function setUp() protected function setUp()
{ {
$this->useModelSet('generic'); $this->useModelSet('generic');
parent::setUp(); parent::setUp();
} }
@ -28,7 +29,7 @@ class TypeTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT d FROM Doctrine\Tests\Models\Generic\DecimalModel d"; $dql = 'SELECT d FROM ' . DecimalModel::class . ' d';
$decimal = $this->_em->createQuery($dql)->getSingleResult(); $decimal = $this->_em->createQuery($dql)->getSingleResult();
$this->assertEquals(0.15, $decimal->decimal); $this->assertEquals(0.15, $decimal->decimal);
@ -48,7 +49,7 @@ class TypeTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true"; $dql = 'SELECT b FROM ' . BooleanModel::class . ' b WHERE b.booleanField = true';
$bool = $this->_em->createQuery($dql)->getSingleResult(); $bool = $this->_em->createQuery($dql)->getSingleResult();
$this->assertTrue($bool->booleanField); $this->assertTrue($bool->booleanField);
@ -58,7 +59,7 @@ class TypeTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false"; $dql = 'SELECT b FROM ' . BooleanModel::class . ' b WHERE b.booleanField = false';
$bool = $this->_em->createQuery($dql)->getSingleResult(); $bool = $this->_em->createQuery($dql)->getSingleResult();
$this->assertFalse($bool->booleanField); $this->assertFalse($bool->booleanField);
@ -74,7 +75,7 @@ class TypeTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT s FROM Doctrine\Tests\Models\Generic\SerializationModel s"; $dql = 'SELECT s FROM ' . SerializationModel::class . ' s';
$serialize = $this->_em->createQuery($dql)->getSingleResult(); $serialize = $this->_em->createQuery($dql)->getSingleResult();
$this->assertEquals(["foo" => "bar", "bar" => "baz"], $serialize->array); $this->assertEquals(["foo" => "bar", "bar" => "baz"], $serialize->array);
@ -89,7 +90,7 @@ class TypeTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$dql = "SELECT s FROM Doctrine\Tests\Models\Generic\SerializationModel s"; $dql = 'SELECT s FROM ' . SerializationModel::class . ' s';
$serialize = $this->_em->createQuery($dql)->getSingleResult(); $serialize = $this->_em->createQuery($dql)->getSingleResult();
$this->assertInstanceOf('stdClass', $serialize->object); $this->assertInstanceOf('stdClass', $serialize->object);
@ -106,7 +107,7 @@ class TypeTest extends OrmFunctionalTestCase
$dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id);
$this->assertInstanceOf('DateTime', $dateTimeDb->date); $this->assertInstanceOf(\DateTime::class, $dateTimeDb->date);
$this->assertEquals('2009-10-01', $dateTimeDb->date->format('Y-m-d')); $this->assertEquals('2009-10-01', $dateTimeDb->date->format('Y-m-d'));
} }
@ -121,12 +122,12 @@ class TypeTest extends OrmFunctionalTestCase
$dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id);
$this->assertInstanceOf('DateTime', $dateTimeDb->datetime); $this->assertInstanceOf(\DateTime::class, $dateTimeDb->datetime);
$this->assertEquals('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); $this->assertEquals('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s'));
$articles = $this->_em->getRepository( DateTimeModel::class )->findBy( ['datetime' => new \DateTime( "now" )] $articles = $this->_em->getRepository(DateTimeModel::class)
); ->findBy(['datetime' => new \DateTime()]);
$this->assertEquals( 0, count( $articles ) ); $this->assertEquals(0, count($articles));
} }
public function testDqlQueryBindDateTimeInstance() public function testDqlQueryBindDateTimeInstance()
@ -175,7 +176,7 @@ class TypeTest extends OrmFunctionalTestCase
$dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id); $dateTimeDb = $this->_em->find(DateTimeModel::class, $dateTime->id);
$this->assertInstanceOf('DateTime', $dateTime->time); $this->assertInstanceOf(\DateTime::class, $dateTimeDb->time);
$this->assertEquals('19:27:20', $dateTime->time->format('H:i:s')); $this->assertEquals('19:27:20', $dateTimeDb->time->format('H:i:s'));
} }
} }

View File

@ -3,6 +3,8 @@
namespace Doctrine\Tests\ORM\Functional; namespace Doctrine\Tests\ORM\Functional;
use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\DBAL\Types\Type as DBALType;
use Doctrine\Tests\DbalTypes\NegativeToPositiveType;
use Doctrine\Tests\DbalTypes\UpperCaseStringType;
use Doctrine\Tests\Models\CustomType\CustomTypeChild; use Doctrine\Tests\Models\CustomType\CustomTypeChild;
use Doctrine\Tests\Models\CustomType\CustomTypeParent; use Doctrine\Tests\Models\CustomType\CustomTypeParent;
use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase; use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase;
@ -12,16 +14,16 @@ class TypeValueSqlTest extends OrmFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
if (DBALType::hasType('upper_case_string')) { if (DBALType::hasType(UpperCaseStringType::NAME)) {
DBALType::overrideType('upper_case_string', '\Doctrine\Tests\DbalTypes\UpperCaseStringType'); DBALType::overrideType(UpperCaseStringType::NAME, UpperCaseStringType::class);
} else { } else {
DBALType::addType('upper_case_string', '\Doctrine\Tests\DbalTypes\UpperCaseStringType'); DBALType::addType(UpperCaseStringType::NAME, UpperCaseStringType::class);
} }
if (DBALType::hasType('negative_to_positive')) { if (DBALType::hasType(NegativeToPositiveType::NAME)) {
DBALType::overrideType('negative_to_positive', '\Doctrine\Tests\DbalTypes\NegativeToPositiveType'); DBALType::overrideType(NegativeToPositiveType::NAME, NegativeToPositiveType::class);
} else { } else {
DBALType::addType('negative_to_positive', '\Doctrine\Tests\DbalTypes\NegativeToPositiveType'); DBALType::addType(NegativeToPositiveType::NAME, NegativeToPositiveType::class);
} }
$this->useModelSet('customtype'); $this->useModelSet('customtype');

View File

@ -2,6 +2,7 @@
namespace Doctrine\Tests\ORM\Hydration; namespace Doctrine\Tests\ORM\Hydration;
use Doctrine\ORM\Internal\Hydration\ScalarHydrator;
use Doctrine\Tests\Mocks\HydratorMockStatement; use Doctrine\Tests\Mocks\HydratorMockStatement;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
@ -32,7 +33,7 @@ class ScalarHydratorTest extends HydrationTestCase
$stmt = new HydratorMockStatement($resultSet); $stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); $hydrator = new ScalarHydrator($this->_em);
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);
@ -63,7 +64,7 @@ class ScalarHydratorTest extends HydrationTestCase
]; ];
$stmt = new HydratorMockStatement($resultSet); $stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); $hydrator = new ScalarHydrator($this->_em);
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);
} }
@ -93,7 +94,7 @@ class ScalarHydratorTest extends HydrationTestCase
]; ];
$stmt = new HydratorMockStatement($resultSet); $stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); $hydrator = new ScalarHydrator($this->_em);
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);
} }

View File

@ -2,6 +2,8 @@
namespace Doctrine\Tests\ORM\Hydration; namespace Doctrine\Tests\ORM\Hydration;
use Doctrine\ORM\Internal\Hydration\SingleScalarHydrator;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\Tests\Mocks\HydratorMockStatement; use Doctrine\Tests\Mocks\HydratorMockStatement;
use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsUser;
@ -9,25 +11,26 @@ use Doctrine\Tests\Models\CMS\CmsUser;
class SingleScalarHydratorTest extends HydrationTestCase class SingleScalarHydratorTest extends HydrationTestCase
{ {
/** Result set provider for the HYDRATE_SINGLE_SCALAR tests */ /** Result set provider for the HYDRATE_SINGLE_SCALAR tests */
public static function singleScalarResultSetProvider() { public static function singleScalarResultSetProvider(): array
{
return [ return [
// valid // valid
[ 'valid' => [
'name' => 'result1', 'name' => 'result1',
'resultSet' => [ 'resultSet' => [
[ [
'u__name' => 'romanb' 'u__name' => 'romanb',
] ],
] ],
], ],
// valid // valid
[ [
'name' => 'result2', 'name' => 'result2',
'resultSet' => [ 'resultSet' => [
[ [
'u__id' => '1' 'u__id' => '1',
] ],
] ],
], ],
// invalid // invalid
[ [
@ -35,21 +38,21 @@ class SingleScalarHydratorTest extends HydrationTestCase
'resultSet' => [ 'resultSet' => [
[ [
'u__id' => '1', 'u__id' => '1',
'u__name' => 'romanb' 'u__name' => 'romanb',
] ],
] ],
], ],
// invalid // invalid
[ [
'name' => 'result4', 'name' => 'result4',
'resultSet' => [ 'resultSet' => [
[ [
'u__id' => '1' 'u__id' => '1',
], ],
[ [
'u__id' => '2' 'u__id' => '2',
] ],
] ],
], ],
]; ];
} }
@ -67,7 +70,7 @@ class SingleScalarHydratorTest extends HydrationTestCase
$rsm->addFieldResult('u', 'u__name', 'name'); $rsm->addFieldResult('u', 'u__name', 'name');
$stmt = new HydratorMockStatement($resultSet); $stmt = new HydratorMockStatement($resultSet);
$hydrator = new \Doctrine\ORM\Internal\Hydration\SingleScalarHydrator($this->_em); $hydrator = new SingleScalarHydrator($this->_em);
if ($name == 'result1') { if ($name == 'result1') {
$result = $hydrator->hydrateAll($stmt, $rsm); $result = $hydrator->hydrateAll($stmt, $rsm);

View File

@ -68,17 +68,10 @@ abstract class AbstractMappingDriverTest extends OrmTestCase
return $factory; return $factory;
} }
public function testLoadMapping() public function testEntityTableNameAndInheritance()
{ {
return $this->createClassMetadata(User::class); $class = $this->createClassMetadata(User::class);
}
/**
* @depends testLoadMapping
* @param ClassMetadata $class
*/
public function testEntityTableNameAndInheritance($class)
{
$this->assertEquals('cms_users', $class->getTableName()); $this->assertEquals('cms_users', $class->getTableName());
$this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType); $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType);
@ -274,14 +267,12 @@ abstract class AbstractMappingDriverTest extends OrmTestCase
/** /**
* @group #6129 * @group #6129
* *
* @depends testLoadMapping
*
* @param ClassMetadata $class
*
* @return ClassMetadata * @return ClassMetadata
*/ */
public function testBooleanValuesForOptionIsSetCorrectly(ClassMetadata $class) public function testBooleanValuesForOptionIsSetCorrectly()
{ {
$class = $this->createClassMetadata(User::class);
$this->assertInternalType('bool', $class->fieldMappings['id']['options']['unsigned']); $this->assertInternalType('bool', $class->fieldMappings['id']['options']['unsigned']);
$this->assertFalse($class->fieldMappings['id']['options']['unsigned']); $this->assertFalse($class->fieldMappings['id']['options']['unsigned']);

View File

@ -12,7 +12,6 @@ class StaticPHPMappingDriverTest extends AbstractMappingDriverTest
return new StaticPHPDriver(__DIR__ . DIRECTORY_SEPARATOR . 'php'); return new StaticPHPDriver(__DIR__ . DIRECTORY_SEPARATOR . 'php');
} }
/** /**
* All class with static::loadMetadata are entities for php driver * All class with static::loadMetadata are entities for php driver
* *