From f06f383a385449093fa9342ac6ce2adcdebc357e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Sat, 12 Mar 2016 01:24:56 +0000 Subject: [PATCH 001/144] Cleanup no longer used coveralls settings --- .coveralls.yml | 4 ---- README.md | 8 ++++---- composer.json | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) delete mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index b086fff7a..000000000 --- a/.coveralls.yml +++ /dev/null @@ -1,4 +0,0 @@ -# for php-coveralls -service_name: travis-ci -src_dir: lib -coverage_clover: build/logs/clover*.xml diff --git a/README.md b/README.md index 6c46f637c..96862eea2 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ without requiring unnecessary code duplication. [Master image]: https://img.shields.io/travis/doctrine/doctrine2/master.svg?style=flat-square [Master]: https://travis-ci.org/doctrine/doctrine2 - [Master coverage image]: https://img.shields.io/coveralls/doctrine/doctrine2/master.svg?style=flat-square - [Master coverage]: https://coveralls.io/r/doctrine/doctrine2?branch=master + [Master coverage image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/doctrine2/master.svg?style=flat-square + [Master coverage]: https://scrutinizer-ci.com/g/doctrine/doctrine2/?branch=master [2.5 image]: https://img.shields.io/travis/doctrine/doctrine2/2.5.svg?style=flat-square [2.5]: https://github.com/doctrine/doctrine2/tree/2.5 - [2.5 coverage image]: https://img.shields.io/coveralls/doctrine/doctrine2/2.5.svg?style=flat-square - [2.5 coverage]: https://coveralls.io/r/doctrine/doctrine2?branch=2.5 + [2.5 coverage image]: https://img.shields.io/scrutinizer/coverage/g/doctrine/doctrine2/2.5.svg?style=flat-square + [2.5 coverage]: https://scrutinizer-ci.com/g/doctrine/doctrine2/?branch=2.5 diff --git a/composer.json b/composer.json index cd1f81ade..ee12f7779 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,6 @@ } }, "archive": { - "exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar", "vendor/satooshi", "lib/vendor", "*.swp", "*coveralls.yml"] + "exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar", "vendor/satooshi", "lib/vendor", "*.swp"] } } From 01e53ba44a6645eb9b6a066e8f2af5d1f7f23a23 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 21 Mar 2016 14:16:07 +0200 Subject: [PATCH 002/144] Fix typo --- bin/doctrine-pear.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/doctrine-pear.php b/bin/doctrine-pear.php index 10ce1dd88..b7c6ba3dc 100644 --- a/bin/doctrine-pear.php +++ b/bin/doctrine-pear.php @@ -31,7 +31,7 @@ $helperSet = null; if (file_exists($configFile)) { if ( ! is_readable($configFile)) { trigger_error( - 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR + 'Configuration file [' . $configFile . '] does not have read permission.', E_USER_ERROR ); } From 6c2463b90555759d7c8348dcc9f26a236223843e Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Tue, 12 Apr 2016 15:05:16 +0800 Subject: [PATCH 003/144] Remove note on findBy not supporting entity --- docs/en/reference/working-with-objects.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 4e11341a3..8368c9f13 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -699,8 +699,6 @@ You can also load by owning side associations through the repository: $number = $em->find('MyProject\Domain\Phonenumber', 1234); $user = $em->getRepository('MyProject\Domain\User')->findOneBy(array('phone' => $number->getId())); -Be careful that this only works by passing the ID of the associated entity, not yet by passing the associated entity itself. - The ``EntityRepository#findBy()`` method additionally accepts orderings, limit and offset as second to fourth parameters: .. code-block:: php From 56daa67f940eae9368ae2c0202ca2c28648bbbf4 Mon Sep 17 00:00:00 2001 From: Jean Carlo Machado Date: Mon, 9 May 2016 22:19:28 -0300 Subject: [PATCH 004/144] add embedded and embeddable annotations in annotations reference index --- docs/en/reference/annotations-reference.rst | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index 5979939ea..19e9e8b70 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -39,6 +39,8 @@ Index - :ref:`@ChangeTrackingPolicy ` - :ref:`@DiscriminatorColumn ` - :ref:`@DiscriminatorMap ` +- :ref:`@Embeddable ` +- :ref:`@Embedded ` - :ref:`@Entity ` - :ref:`@EntityResult ` - :ref:`@FieldResult ` @@ -282,6 +284,67 @@ depending on whether the classes are in the namespace or not. // ... } + +.. _annref_embeddable: + +@Embeddable +~~~~~~~~~~~~~~~~~~~~~ + +The embeddable is required on an entity targed to be embeddable inside +another. It works together with the :ref:`@Embedded ` +annotation to establish the relationship between two entities. + +.. code-block:: php + + Date: Wed, 11 May 2016 01:55:12 +0700 Subject: [PATCH 005/144] Optimize imports. Remove full qualified class names --- lib/Doctrine/ORM/AbstractQuery.php | 1 - lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 1 - lib/Doctrine/ORM/Cache/EntityCacheEntry.php | 2 +- lib/Doctrine/ORM/EntityRepository.php | 1 - .../ORM/Internal/Hydration/ObjectHydrator.php | 3 - .../Hydration/SimpleObjectHydrator.php | 1 - .../Collection/ManyToManyPersister.php | 3 +- .../Collection/OneToManyPersister.php | 1 - .../Entity/JoinedSubclassPersister.php | 1 - lib/Doctrine/ORM/Query/Parser.php | 2 +- .../ORM/Query/ResultSetMappingBuilder.php | 1 - .../Pagination/LimitSubqueryOutputWalker.php | 9 -- .../Tools/Pagination/LimitSubqueryWalker.php | 1 - lib/Doctrine/ORM/UnitOfWork.php | 3 +- .../Tests/Mocks/ClassMetadataMock.php | 4 +- tests/Doctrine/Tests/Mocks/ConnectionMock.php | 3 +- .../Tests/Mocks/DatabasePlatformMock.php | 4 +- .../Tests/Mocks/DriverConnectionMock.php | 4 +- tests/Doctrine/Tests/Mocks/DriverMock.php | 15 +- .../Tests/Mocks/EntityManagerMock.php | 13 +- .../Tests/Mocks/EntityPersisterMock.php | 6 +- .../Tests/Mocks/HydratorMockStatement.php | 4 +- .../Tests/Mocks/MetadataDriverMock.php | 7 +- tests/Doctrine/Tests/Mocks/MockTreeWalker.php | 4 +- .../Tests/Mocks/SchemaManagerMock.php | 7 +- tests/Doctrine/Tests/Mocks/SequenceMock.php | 3 +- tests/Doctrine/Tests/Mocks/StatementMock.php | 4 +- tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php | 4 +- .../Tests/Models/DDC3579/DDC3579Admin.php | 2 - .../Models/DDC753/DDC753InvalidRepository.php | 2 - .../Tests/Models/DDC964/DDC964Admin.php | 2 - .../Tests/Models/DDC964/DDC964Guest.php | 2 - .../Tests/Models/Legacy/LegacyCar.php | 2 - .../Tests/Models/StockExchange/Bond.php | 3 +- .../Tests/Models/StockExchange/Stock.php | 2 - .../Doctrine/Tests/ORM/Cache/CacheKeyTest.php | 3 +- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 6 +- .../Tests/ORM/Cache/DefaultRegionTest.php | 5 +- .../Tests/ORM/Cache/MultiGetRegionTest.php | 2 - .../AbstractCollectionPersisterTest.php | 3 +- .../Tests/ORM/CommitOrderCalculatorTest.php | 3 +- .../Doctrine/Tests/ORM/ConfigurationTest.php | 1 - .../Decorator/EntityManagerDecoratorTest.php | 2 - .../Tests/ORM/Entity/ConstructorTest.php | 4 +- .../Doctrine/Tests/ORM/EntityManagerTest.php | 9 +- .../ORM/Functional/AdvancedDqlQueryTest.php | 1 - .../ORM/Functional/BasicFunctionalTest.php | 2 - .../Functional/ClassTableInheritanceTest.php | 4 +- .../ORM/Functional/DetachedEntityTest.php | 1 - .../ORM/Functional/EntityRepositoryTest.php | 1 - .../ORM/Functional/HydrationCacheTest.php | 3 +- .../Functional/Locking/GearmanLockTest.php | 9 +- .../Tests/ORM/Functional/Locking/LockTest.php | 3 +- .../ORM/Functional/Locking/OptimisticTest.php | 7 +- .../MergeVersionedManyToOneTest.php | 5 +- .../Functional/OneToManyOrphanRemovalTest.php | 1 - .../Functional/OneToOneOrphanRemovalTest.php | 3 +- .../OneToOneSingleTableInheritanceTest.php | 4 - .../Functional/ProxiesLikeEntitiesTest.php | 4 +- .../Tests/ORM/Functional/QueryCacheTest.php | 1 - .../Tests/ORM/Functional/QueryTest.php | 1 - .../Tests/ORM/Functional/SQLFilterTest.php | 2 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 2 +- .../SchemaTool/MySqlSchemaToolTest.php | 6 +- .../SchemaTool/PostgreSqlSchemaToolTest.php | 3 +- .../ORM/Functional/SchemaValidatorTest.php | 1 - .../SecondLevelCacheOneToOneTest.php | 2 - .../ORM/Functional/Ticket/DDC1040Test.php | 4 +- .../ORM/Functional/Ticket/DDC1041Test.php | 7 +- .../ORM/Functional/Ticket/DDC1043Test.php | 7 +- .../ORM/Functional/Ticket/DDC1050Test.php | 7 +- .../ORM/Functional/Ticket/DDC1080Test.php | 4 +- .../ORM/Functional/Ticket/DDC1113Test.php | 2 - .../ORM/Functional/Ticket/DDC1129Test.php | 2 - .../ORM/Functional/Ticket/DDC1181Test.php | 4 +- .../ORM/Functional/Ticket/DDC1193Test.php | 5 +- .../ORM/Functional/Ticket/DDC1209Test.php | 4 +- .../ORM/Functional/Ticket/DDC1225Test.php | 3 - .../ORM/Functional/Ticket/DDC1228Test.php | 3 - .../ORM/Functional/Ticket/DDC1238Test.php | 3 - .../ORM/Functional/Ticket/DDC1250Test.php | 3 - .../ORM/Functional/Ticket/DDC1276Test.php | 1 - .../ORM/Functional/Ticket/DDC1306Test.php | 2 - .../ORM/Functional/Ticket/DDC1335Test.php | 2 - .../ORM/Functional/Ticket/DDC1360Test.php | 2 +- .../ORM/Functional/Ticket/DDC1383Test.php | 1 - .../ORM/Functional/Ticket/DDC1400Test.php | 2 - .../ORM/Functional/Ticket/DDC1436Test.php | 1 - .../ORM/Functional/Ticket/DDC144Test.php | 4 +- .../ORM/Functional/Ticket/DDC1452Test.php | 1 - .../ORM/Functional/Ticket/DDC1454Test.php | 2 - .../ORM/Functional/Ticket/DDC1458Test.php | 6 +- .../ORM/Functional/Ticket/DDC1461Test.php | 4 - .../ORM/Functional/Ticket/DDC1509Test.php | 2 - .../ORM/Functional/Ticket/DDC1514Test.php | 1 - .../ORM/Functional/Ticket/DDC1545Test.php | 3 - .../ORM/Functional/Ticket/DDC1594Test.php | 4 - .../ORM/Functional/Ticket/DDC1757Test.php | 4 +- .../ORM/Functional/Ticket/DDC1884Test.php | 4 +- .../ORM/Functional/Ticket/DDC192Test.php | 4 +- .../ORM/Functional/Ticket/DDC199Test.php | 4 +- .../ORM/Functional/Ticket/DDC2106Test.php | 1 - .../ORM/Functional/Ticket/DDC211Test.php | 4 +- .../ORM/Functional/Ticket/DDC2182Test.php | 2 - .../ORM/Functional/Ticket/DDC2230Test.php | 4 +- .../ORM/Functional/Ticket/DDC2256Test.php | 4 +- .../ORM/Functional/Ticket/DDC2306Test.php | 4 +- .../ORM/Functional/Ticket/DDC2346Test.php | 4 +- .../ORM/Functional/Ticket/DDC2359Test.php | 2 - .../ORM/Functional/Ticket/DDC258Test.php | 5 +- .../ORM/Functional/Ticket/DDC2660Test.php | 5 +- .../ORM/Functional/Ticket/DDC2692Test.php | 4 +- .../ORM/Functional/Ticket/DDC2759Test.php | 4 +- .../ORM/Functional/Ticket/DDC2825Test.php | 4 +- .../ORM/Functional/Ticket/DDC2996Test.php | 3 - .../ORM/Functional/Ticket/DDC309Test.php | 5 +- .../ORM/Functional/Ticket/DDC3170Test.php | 4 +- .../ORM/Functional/Ticket/DDC331Test.php | 9 -- .../ORM/Functional/Ticket/DDC3699Test.php | 2 - .../ORM/Functional/Ticket/DDC381Test.php | 2 - .../ORM/Functional/Ticket/DDC4003Test.php | 5 +- .../ORM/Functional/Ticket/DDC448Test.php | 5 +- .../ORM/Functional/Ticket/DDC501Test.php | 2 - .../ORM/Functional/Ticket/DDC512Test.php | 5 +- .../ORM/Functional/Ticket/DDC522Test.php | 2 - .../ORM/Functional/Ticket/DDC618Test.php | 2 - .../ORM/Functional/Ticket/DDC633Test.php | 2 - .../ORM/Functional/Ticket/DDC656Test.php | 2 - .../ORM/Functional/Ticket/DDC698Test.php | 2 - .../ORM/Functional/Ticket/DDC748Test.php | 1 - .../ORM/Functional/Ticket/DDC758Test.php | 1 - .../ORM/Functional/Ticket/DDC767Test.php | 1 - .../ORM/Functional/Ticket/DDC809Test.php | 4 - .../ORM/Functional/Ticket/DDC832Test.php | 4 - .../ORM/Functional/Ticket/DDC849Test.php | 1 - .../ORM/Functional/Ticket/DDC933Test.php | 6 +- .../ORM/Functional/Ticket/DDC949Test.php | 4 +- .../ORM/Functional/Ticket/DDC960Test.php | 4 +- .../ManyToManyCompositeIdForeignKeyTest.php | 1 - .../ManyToManyCompositeIdTest.php | 1 - .../ManyToManyExtraLazyTest.php | 1 - .../ValueConversionType/ManyToManyTest.php | 1 - .../OneToManyCompositeIdForeignKeyTest.php | 1 - .../OneToManyCompositeIdTest.php | 1 - .../ValueConversionType/OneToManyTest.php | 1 - .../OneToOneCompositeIdForeignKeyTest.php | 1 - .../OneToOneCompositeIdTest.php | 1 - .../ValueConversionType/OneToOneTest.php | 1 - .../Tests/ORM/Hydration/HydrationTestCase.php | 1 - .../ORM/Hydration/ObjectHydratorTest.php | 4 - .../Tests/ORM/Id/AssignedGeneratorTest.php | 8 +- .../Tests/ORM/Id/SequenceGeneratorTest.php | 3 +- .../Tests/ORM/LazyCriteriaCollectionTest.php | 4 +- .../ORM/Mapping/AbstractMappingDriverTest.php | 18 +-- .../ORM/Mapping/AnnotationDriverTest.php | 28 ++-- .../ORM/Mapping/AnsiQuoteStrategyTest.php | 3 +- .../Mapping/BasicInheritanceMappingTest.php | 3 +- .../ORM/Mapping/ClassMetadataBuilderTest.php | 6 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 9 +- .../Mapping/ClassMetadataLoadEventTest.php | 7 +- .../Tests/ORM/Mapping/ClassMetadataTest.php | 13 +- .../Mapping/EntityListenerResolverTest.php | 3 +- .../Tests/ORM/Mapping/FieldBuilderTest.php | 3 +- .../Tests/ORM/Mapping/NamingStrategyTest.php | 3 +- .../ORM/Mapping/PHPMappingDriverTest.php | 3 +- .../Tests/ORM/Mapping/QuoteStrategyTest.php | 11 +- .../Mapping/Symfony/AbstractDriverTest.php | 14 -- .../ORM/Mapping/XmlMappingDriverTest.php | 3 +- .../ORM/Mapping/YamlMappingDriverTest.php | 4 +- .../Tests/ORM/Performance/DDC2602Test.php | 3 +- .../Performance/HydrationPerformanceTest.php | 20 +-- .../InheritancePersisterPerformanceTest.php | 16 ++- .../ORM/Performance/InsertPerformanceTest.php | 6 +- .../Performance/PersisterPerformanceTest.php | 7 +- .../ORM/Performance/ProxyPerformanceTest.php | 1 - .../Performance/UnitOfWorkPerformanceTest.php | 3 +- .../Tests/ORM/PersistentCollectionTest.php | 1 - ...tyPersisterCompositeTypeParametersTest.php | 3 +- ...sicEntityPersisterCompositeTypeSqlTest.php | 8 +- .../BasicEntityPersisterTypeValueSqlTest.php | 3 +- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 7 +- .../ORM/Query/CustomTreeWalkersJoinTest.php | 3 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 3 +- .../ORM/Query/DeleteSqlGenerationTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 3 +- .../Tests/ORM/Query/FilterCollectionTest.php | 5 +- .../ORM/Query/LanguageRecognitionTest.php | 6 +- tests/Doctrine/Tests/ORM/Query/LexerTest.php | 3 +- .../ORM/Query/ParameterTypeInfererTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/ParserTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 3 +- .../ORM/Query/SelectSqlGenerationTest.php | 128 ++++++++++-------- .../ORM/Query/UpdateSqlGenerationTest.php | 3 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 3 +- .../ConvertDoctrine1SchemaCommandTest.php | 3 +- .../Tools/Console/Command/InfoCommandTest.php | 1 - .../ORM/Tools/ConvertDoctrine1SchemaTest.php | 11 +- .../Tests/ORM/Tools/EntityGeneratorTest.php | 5 +- .../Tools/EntityRepositoryGeneratorTest.php | 3 +- .../AbstractClassMetadataExporterTest.php | 11 +- .../Pagination/CountOutputWalkerTest.php | 2 +- .../ORM/Tools/Pagination/CountWalkerTest.php | 2 +- .../LimitSubqueryOutputWalkerTest.php | 3 +- .../Pagination/LimitSubqueryWalkerTest.php | 2 +- .../Tools/Pagination/WhereInWalkerTest.php | 2 +- .../Tools/ResolveTargetEntityListenerTest.php | 3 +- .../Tests/ORM/Tools/SchemaToolTest.php | 3 +- .../Tests/ORM/Tools/SchemaValidatorTest.php | 4 +- tests/Doctrine/Tests/ORM/Tools/SetupTest.php | 6 +- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 8 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 26 ++-- tests/Doctrine/Tests/OrmTestCase.php | 15 +- 212 files changed, 471 insertions(+), 515 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index b5a8902fd..0b2b0663c 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -28,7 +28,6 @@ use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\ORM\Cache; -use Doctrine\ORM\Query\QueryException; /** * Base contract for ORM queries. Base class for Query and NativeQuery. diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 83fc0d946..07c9d8f43 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -234,7 +234,6 @@ class DefaultQueryCache implements QueryCache $data = array(); $entityName = reset($rsm->aliasMap); $hasRelation = ( ! empty($rsm->relationMap)); - $metadata = $this->em->getClassMetadata($entityName); $persister = $this->uow->getEntityPersister($entityName); if ( ! ($persister instanceof CachedPersister)) { diff --git a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php index 3c552073d..155618be9 100644 --- a/lib/Doctrine/ORM/Cache/EntityCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/EntityCacheEntry.php @@ -71,7 +71,7 @@ class EntityCacheEntry implements CacheEntry /** * Retrieves the entity data resolving cache entries * - * @param \Doctrine\ORM\EntityManagerInterfac $em + * @param \Doctrine\ORM\EntityManagerInterface $em * * @return array */ diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 6a60d5050..08b2ff193 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -19,7 +19,6 @@ namespace Doctrine\ORM; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\Common\Collections\Selectable; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 3cedaada0..8e45117ab 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -24,9 +24,6 @@ use PDO; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Query; -use Doctrine\ORM\Events; -use Doctrine\ORM\Event\LifecycleEventArgs; -use Doctrine\ORM\Event\PostLoadEventDispatcher; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Proxy\Proxy; diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 1c21369e3..92c77ddd3 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -20,7 +20,6 @@ namespace Doctrine\ORM\Internal\Hydration; use PDO; -use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; diff --git a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php index 25c03a450..525ab34b3 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php @@ -21,7 +21,6 @@ namespace Doctrine\ORM\Persisters\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Persisters\SqlExpressionVisitor; use Doctrine\ORM\Persisters\SqlValueVisitor; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Query; @@ -740,7 +739,7 @@ class ManyToManyPersister extends AbstractCollectionPersister $valueVisitor->dispatch($expression); - list($values, $types) = $valueVisitor->getParamsAndTypes(); + list(, $types) = $valueVisitor->getParamsAndTypes(); return $types; } diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index d4213f15d..0e2fda868 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -20,7 +20,6 @@ namespace Doctrine\ORM\Persisters\Collection; use Doctrine\Common\Collections\Criteria; -use Doctrine\Common\Proxy\Proxy; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\Utility\PersisterHelper; diff --git a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php index 072407405..0975cf56e 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/JoinedSubclassPersister.php @@ -20,7 +20,6 @@ namespace Doctrine\ORM\Persisters\Entity; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Types\Type; diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 8b6feaf83..7619359ce 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -2953,7 +2953,7 @@ class Parser /** * EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression * - * @return \Doctrine\ORM\Query\AST\SingleValuedAssociationPathExpression | + * @return \Doctrine\ORM\Query\AST\PathExpression | * \Doctrine\ORM\Query\AST\SimpleEntityExpression */ public function EntityExpression() diff --git a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php index 97bfb4709..73eb5ae5a 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php +++ b/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php @@ -19,7 +19,6 @@ namespace Doctrine\ORM\Query; -use Doctrine\DBAL\Types\Type; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index fc431227f..92386e46d 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -18,18 +18,9 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Platforms\SQLServerPlatform; -use Doctrine\ORM\Query\AST\ArithmeticExpression; -use Doctrine\ORM\Query\AST\ArithmeticFactor; -use Doctrine\ORM\Query\AST\ArithmeticTerm; -use Doctrine\ORM\Query\AST\Literal; use Doctrine\ORM\Query\AST\OrderByClause; -use Doctrine\ORM\Query\AST\OrderByItem; use Doctrine\ORM\Query\AST\PartialObjectExpression; -use Doctrine\ORM\Query\AST\PathExpression; use Doctrine\ORM\Query\AST\SelectExpression; -use Doctrine\ORM\Query\AST\SimpleArithmeticExpression; -use Doctrine\ORM\Query\Expr\OrderBy; -use Doctrine\ORM\Query\Expr\Select; use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Query\AST\SelectStatement; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index d65ab6cfe..fd51fb46b 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -20,7 +20,6 @@ namespace Doctrine\ORM\Tools\Pagination; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadataInfo; -use Doctrine\ORM\ORMException; use Doctrine\ORM\Query; use Doctrine\ORM\Query\TreeWalkerAdapter; use Doctrine\ORM\Query\AST\Functions\IdentityFunction; diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 7d7da9754..a66d7b462 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -49,7 +49,6 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister; use Doctrine\ORM\Persisters\Collection\OneToManyPersister; use Doctrine\ORM\Persisters\Collection\ManyToManyPersister; use Doctrine\ORM\Utility\IdentifierFlattener; -use Doctrine\ORM\Cache\AssociationCacheEntry; /** * The UnitOfWork is responsible for tracking changes to objects during an @@ -1281,7 +1280,7 @@ class UnitOfWork implements PropertyChangedListener $extraUpdate = array($entity, $changeset); if (isset($this->extraUpdates[$oid])) { - list($ignored, $changeset2) = $this->extraUpdates[$oid]; + list(, $changeset2) = $this->extraUpdates[$oid]; $extraUpdate = array($entity, $changeset + $changeset2); } diff --git a/tests/Doctrine/Tests/Mocks/ClassMetadataMock.php b/tests/Doctrine/Tests/Mocks/ClassMetadataMock.php index deab5239a..599c4996f 100644 --- a/tests/Doctrine/Tests/Mocks/ClassMetadataMock.php +++ b/tests/Doctrine/Tests/Mocks/ClassMetadataMock.php @@ -2,10 +2,12 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\ORM\Mapping\ClassMetadata; + /** * Mock class for ClassMetadata. */ -class ClassMetadataMock extends \Doctrine\ORM\Mapping\ClassMetadata +class ClassMetadataMock extends ClassMetadata { /* Mock API */ diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index 5cf9dae4d..49ca3e4ea 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -1,11 +1,12 @@ _schemaManagerMock == null) { return new SchemaManagerMock($conn); @@ -55,7 +60,7 @@ class DriverMock implements \Doctrine\DBAL\Driver * * @return void */ - public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) + public function setDatabasePlatform(AbstractPlatform $platform) { $this->_platformMock = $platform; } @@ -65,7 +70,7 @@ class DriverMock implements \Doctrine\DBAL\Driver * * @return void */ - public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm) + public function setSchemaManager(AbstractSchemaManager $sm) { $this->_schemaManagerMock = $sm; } @@ -81,7 +86,7 @@ class DriverMock implements \Doctrine\DBAL\Driver /** * {@inheritdoc} */ - public function getDatabase(\Doctrine\DBAL\Connection $conn) + public function getDatabase(Connection $conn) { return; } diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php index 74f4efcf0..24ecb59ef 100644 --- a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -21,12 +21,14 @@ namespace Doctrine\Tests\Mocks; -use Doctrine\ORM\Proxy\ProxyFactory; +use Doctrine\Common\EventManager; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; /** * Special EntityManager mock used for testing purposes. */ -class EntityManagerMock extends \Doctrine\ORM\EntityManager +class EntityManagerMock extends EntityManager { /** * @var \Doctrine\ORM\UnitOfWork|null @@ -83,17 +85,16 @@ class EntityManagerMock extends \Doctrine\ORM\EntityManager * * {@inheritdoc} */ - public static function create($conn, \Doctrine\ORM\Configuration $config = null, - \Doctrine\Common\EventManager $eventManager = null) + public static function create($conn, Configuration $config = null, EventManager $eventManager = null) { if (null === $config) { - $config = new \Doctrine\ORM\Configuration(); + $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true)); } if (null === $eventManager) { - $eventManager = new \Doctrine\Common\EventManager(); + $eventManager = new EventManager(); } return new EntityManagerMock($conn, $config, $eventManager); diff --git a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php index 761ec4bc1..6130f58f3 100644 --- a/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php @@ -3,11 +3,13 @@ namespace Doctrine\Tests\Mocks; use Doctrine\Common\Collections\Criteria; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; /** * EntityPersister implementation used for mocking during tests. */ -class EntityPersisterMock extends \Doctrine\ORM\Persisters\Entity\BasicEntityPersister +class EntityPersisterMock extends BasicEntityPersister { /** * @var array @@ -52,7 +54,7 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\Entity\BasicEntityPer public function addInsert($entity) { $this->inserts[] = $entity; - if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY + if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->class->isIdGeneratorIdentity()) { $id = $this->identityColumnValueCounter++; $this->postInsertIds[] = array( diff --git a/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php b/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php index 5930db12c..7afec2c60 100644 --- a/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php +++ b/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php @@ -2,13 +2,15 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\DBAL\Driver\Statement; + /** * This class is a mock of the Statement interface that can be passed in to the Hydrator * to test the hydration standalone with faked result sets. * * @author Roman Borschel */ -class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement +class HydratorMockStatement implements \IteratorAggregate, Statement { /** * @var array diff --git a/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php b/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php index 21339c5f9..b691ec02c 100644 --- a/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php +++ b/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php @@ -2,15 +2,18 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; + /** * Mock class for MappingDriver. */ -class MetadataDriverMock implements \Doctrine\Common\Persistence\Mapping\Driver\MappingDriver +class MetadataDriverMock implements MappingDriver { /** * {@inheritdoc} */ - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadata $metadata) { } diff --git a/tests/Doctrine/Tests/Mocks/MockTreeWalker.php b/tests/Doctrine/Tests/Mocks/MockTreeWalker.php index fd6c81815..0edb8581a 100644 --- a/tests/Doctrine/Tests/Mocks/MockTreeWalker.php +++ b/tests/Doctrine/Tests/Mocks/MockTreeWalker.php @@ -2,10 +2,12 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\ORM\Query\TreeWalkerAdapter; + /** * Mock class for TreeWalker. */ -class MockTreeWalker extends \Doctrine\ORM\Query\TreeWalkerAdapter +class MockTreeWalker extends TreeWalkerAdapter { /** * {@inheritdoc} diff --git a/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php b/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php index 02c7c0a79..5de33a049 100644 --- a/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php @@ -2,15 +2,18 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Schema\AbstractSchemaManager; + /** * Mock class for AbstractSchemaManager. */ -class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager +class SchemaManagerMock extends AbstractSchemaManager { /** * @param \Doctrine\DBAL\Connection $conn */ - public function __construct(\Doctrine\DBAL\Connection $conn) + public function __construct(Connection $conn) { parent::__construct($conn); } diff --git a/tests/Doctrine/Tests/Mocks/SequenceMock.php b/tests/Doctrine/Tests/Mocks/SequenceMock.php index 4f5123004..fc6c10f41 100644 --- a/tests/Doctrine/Tests/Mocks/SequenceMock.php +++ b/tests/Doctrine/Tests/Mocks/SequenceMock.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\Mocks; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Id\SequenceGenerator; /** * Mock class for SequenceGenerator. */ -class SequenceMock extends \Doctrine\ORM\Id\SequenceGenerator +class SequenceMock extends SequenceGenerator { /** * @var int diff --git a/tests/Doctrine/Tests/Mocks/StatementMock.php b/tests/Doctrine/Tests/Mocks/StatementMock.php index 40ad1f3e5..8107ff1be 100644 --- a/tests/Doctrine/Tests/Mocks/StatementMock.php +++ b/tests/Doctrine/Tests/Mocks/StatementMock.php @@ -2,12 +2,14 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\DBAL\Driver\Statement; + /** * This class is a mock of the Statement interface. * * @author Alexander */ -class StatementMock implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement +class StatementMock implements \IteratorAggregate, Statement { /** * {@inheritdoc} diff --git a/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php b/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php index c846bca1c..3d7361e7f 100644 --- a/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php +++ b/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php @@ -2,10 +2,12 @@ namespace Doctrine\Tests\Mocks; +use Doctrine\ORM\UnitOfWork; + /** * Mock class for UnitOfWork. */ -class UnitOfWorkMock extends \Doctrine\ORM\UnitOfWork +class UnitOfWorkMock extends UnitOfWork { /** * @var array diff --git a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php index cc9803d44..effedc3c4 100644 --- a/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php +++ b/tests/Doctrine/Tests/Models/DDC3579/DDC3579Admin.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\Models\DDC3579; -use Doctrine\Common\Collections\ArrayCollection; - /** * @Entity * @AssociationOverrides({ diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php index 9f0937aa1..decc07078 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php @@ -20,8 +20,6 @@ namespace Doctrine\Tests\Models\DDC753; -use Doctrine\ORM\EntityRepository; - class DDC753InvalidRepository { diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php index 464471b31..110326b2c 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Admin.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\Models\DDC964; -use Doctrine\Common\Collections\ArrayCollection; - /** * @Entity * @AssociationOverrides({ diff --git a/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php b/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php index 935ee59c0..cb64d15fa 100644 --- a/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php +++ b/tests/Doctrine/Tests/Models/DDC964/DDC964Guest.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\Models\DDC964; -use Doctrine\Common\Collections\ArrayCollection; - /** * @Entity * @AttributeOverrides({ diff --git a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php index ac3834145..4b955be91 100644 --- a/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php +++ b/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\Models\Legacy; -use Doctrine\Common\Collections\ArrayCollection; - /** * @Entity * @Table(name="legacy_cars") diff --git a/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/tests/Doctrine/Tests/Models/StockExchange/Bond.php index a93586f5e..a0d37bfe8 100644 --- a/tests/Doctrine/Tests/Models/StockExchange/Bond.php +++ b/tests/Doctrine/Tests/Models/StockExchange/Bond.php @@ -1,7 +1,6 @@ 'foo')); - $region1 = new DefaultRegion('region1', new \Doctrine\Common\Cache\ApcCache()); - $region2 = new DefaultRegion('region2', new \Doctrine\Common\Cache\ApcCache()); + $region1 = new DefaultRegion('region1', new ApcCache()); + $region2 = new DefaultRegion('region2', new ApcCache()); $this->assertFalse($region1->contains($key)); $this->assertFalse($region2->contains($key)); diff --git a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php index 091ec672a..65d21b93f 100644 --- a/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/MultiGetRegionTest.php @@ -2,12 +2,10 @@ namespace Doctrine\Tests\ORM\Cache; -use Doctrine\Common\Cache\ArrayCache; use Doctrine\Tests\Mocks\CacheEntryMock; use Doctrine\Tests\Mocks\CacheKeyMock; use Doctrine\ORM\Cache\Region\DefaultMultiGetRegion; use Doctrine\ORM\Cache\CollectionCacheEntry; -use Doctrine\ORM\Cache\EntityCacheKey; /** * @author Asmir Mustafic diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php index 0d767aca9..e93924d4a 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Cache\Persister\Collection; +use Doctrine\ORM\PersistentCollection; use Doctrine\Tests\OrmTestCase; use Doctrine\ORM\Cache\Region; @@ -101,7 +102,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase $em = $this->em; $class = $class ?: $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\State'); $assoc = $assoc ?: $class->associationMappings['cities']; - $coll = new \Doctrine\ORM\PersistentCollection($em, $class, $elements ?: new ArrayCollection); + $coll = new PersistentCollection($em, $class, $elements ?: new ArrayCollection); $coll->setOwner($owner, $assoc); $coll->setInitialized(true); diff --git a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php index e9bf04459..770ec7deb 100644 --- a/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php +++ b/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM; use Doctrine\ORM\Internal\CommitOrderCalculator; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\Tests\OrmTestCase; /** * Tests of the commit order calculation. @@ -12,7 +13,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; * can have many valid orderings, so you may want to build a graph that has only * 1 valid order to simplify your tests. */ -class CommitOrderCalculatorTest extends \Doctrine\Tests\OrmTestCase +class CommitOrderCalculatorTest extends OrmTestCase { private $_calc; diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index cb9ec66be..0431eff39 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -6,7 +6,6 @@ use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\Common\Cache\ArrayCache; use Doctrine\ORM\Mapping as AnnotationNamespace; use Doctrine\ORM\Configuration; -use Doctrine\ORM\ORMException; use ReflectionClass; use PHPUnit_Framework_TestCase; diff --git a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php index 849f579fa..fb2c4ea42 100644 --- a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php +++ b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\ORM\Decorator; -use Doctrine\ORM\Decorator\EntityManagerDecorator; -use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\ResultSetMapping; class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php index 4cf98ec5e..117525eca 100644 --- a/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php +++ b/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php @@ -2,7 +2,9 @@ namespace Doctrine\Tests\ORM\Entity; -class ConstructorTest extends \Doctrine\Tests\OrmTestCase +use Doctrine\Tests\OrmTestCase; + +class ConstructorTest extends OrmTestCase { public function testFieldInitializationInConstructor() { diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 37a444a60..797e60173 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -2,7 +2,10 @@ namespace Doctrine\Tests\ORM; -class EntityManagerTest extends \Doctrine\Tests\OrmTestCase +use Doctrine\ORM\Query\ResultSetMapping; +use Doctrine\Tests\OrmTestCase; + +class EntityManagerTest extends OrmTestCase { private $_em; @@ -54,7 +57,7 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase public function testCreateNativeQuery() { - $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); + $rsm = new ResultSetMapping(); $query = $this->_em->createNativeQuery('SELECT foo', $rsm); $this->assertSame('SELECT foo', $query->getSql()); @@ -65,7 +68,7 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase */ public function testCreateNamedNativeQuery() { - $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); + $rsm = new ResultSetMapping(); $this->_em->getConfiguration()->addNamedNativeQuery('foo', 'SELECT foo', $rsm); $query = $this->_em->createNamedNativeQuery('foo'); diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php index 7302a1d6f..67038a781 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\Company\CompanyEmployee, Doctrine\Tests\Models\Company\CompanyManager, - Doctrine\Tests\Models\Company\CompanyPerson, Doctrine\Tests\Models\Company\CompanyCar; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 29f8fab85..42a75be14 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -2,12 +2,10 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Query; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsComment; diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index 9fa1cb8af..f8dd3b7a5 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -6,10 +6,8 @@ use Doctrine\Tests\Models\Company\CompanyPerson, Doctrine\Tests\Models\Company\CompanyEmployee, Doctrine\Tests\Models\Company\CompanyManager, Doctrine\Tests\Models\Company\CompanyOrganization, - Doctrine\Tests\Models\Company\CompanyEvent, Doctrine\Tests\Models\Company\CompanyAuction, - Doctrine\Tests\Models\Company\CompanyRaffle, - Doctrine\Tests\Models\Company\CompanyCar; + Doctrine\Tests\Models\Company\CompanyRaffle; use Doctrine\Common\Collections\Criteria; diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index 85d588880..bc6c0cdd7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -6,7 +6,6 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsArticle; -use Doctrine\ORM\UnitOfWork; /** * Description of DetachedEntityTest diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 705802306..8e20d570a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsAddress; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\ArrayCollection; diff --git a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php index 9dc556d4b..dc84ac4ed 100644 --- a/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php @@ -1,4 +1,5 @@ name = "Benjamin"; $user->username = "beberlei"; $user->status = 'active'; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php index c7bdf6bf8..e69d3ee6a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -2,15 +2,14 @@ namespace Doctrine\Tests\ORM\Functional\Locking; -use Doctrine\Tests\Models\CMS\CmsArticle, - Doctrine\Tests\Models\CMS\CmsUser, - Doctrine\DBAL\LockMode, - Doctrine\ORM\EntityManager; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\DBAL\LockMode; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group locking_functional */ -class GearmanLockTest extends \Doctrine\Tests\OrmFunctionalTestCase +class GearmanLockTest extends OrmFunctionalTestCase { private $gearman = null; private $maxRunTime = 0; diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index c2d3c7315..1face5f31 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -4,8 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Locking; use Doctrine\Tests\Models\CMS\CmsArticle, Doctrine\Tests\Models\CMS\CmsUser, - Doctrine\DBAL\LockMode, - Doctrine\ORM\EntityManager; + Doctrine\DBAL\LockMode; /** * @group locking diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php index df55bd798..e4cad5171 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -2,15 +2,12 @@ namespace Doctrine\Tests\ORM\Functional\Locking; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\OptimisticLockException; -use Doctrine\Common\EventManager; -use Doctrine\ORM\Mapping\ClassMetadataFactory; -use Doctrine\Tests\TestUtil; use Doctrine\DBAL\LockMode; use DateTime; +use Doctrine\Tests\OrmFunctionalTestCase; -class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OptimisticTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php index b534a5cb4..43af6720c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeVersionedManyToOneTest.php @@ -2,15 +2,14 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\ORM\OptimisticLockException; -use Doctrine\ORM\ORMException; use Doctrine\Tests\Models\VersionedManyToOne\Article; use Doctrine\Tests\Models\VersionedManyToOne\Category; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group MergeVersionedOneToMany */ -class MergeVersionedManyToOneTest extends \Doctrine\Tests\OrmFunctionalTestCase +class MergeVersionedManyToOneTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php index e10c1f923..345d6190c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -3,7 +3,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\CMS\CmsUser, - Doctrine\Tests\Models\CMS\CmsAddress, Doctrine\Tests\Models\CMS\CmsPhonenumber; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php index 98e307800..528bf56b3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php @@ -4,8 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsEmail, - Doctrine\Tests\Models\CMS\CmsAddress, - Doctrine\Tests\Models\CMS\CmsPhonenumber; + Doctrine\Tests\Models\CMS\CmsAddress; /** * Tests a bidirectional one-to-one association mapping with orphan removal. diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php index af9379327..b677df624 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSingleTableInheritanceTest.php @@ -2,10 +2,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\Tests\Models\ECommerce\ECommerceProduct; -use Doctrine\Tests\Models\ECommerce\ECommerceShipping; -use Doctrine\ORM\Mapping\AssociationMapping; -use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; use Doctrine\Tests\Models\OneToOneSingleTableInheritance\Cat; use Doctrine\Tests\Models\OneToOneSingleTableInheritance\LitterBox; diff --git a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php index 592706588..1528404df 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\Common\Util\ClassUtils; use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Test that Doctrine ORM correctly works with proxy instances exactly like with ordinary Entities @@ -13,7 +13,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; * b) __initialized__ = false and identifier set in proxy and in property * @todo All other cases would cause lazy loading */ -class ProxiesLikeEntitiesTest extends \Doctrine\Tests\OrmFunctionalTestCase +class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase { /** * @var CmsUser diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php index 039bb1655..f84147374 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -2,7 +2,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Common\Cache\ArrayCache; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 2e6dbc3c6..922c463a9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -4,7 +4,6 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\DBAL\Connection; use Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsArticle, Doctrine\Tests\Models\CMS\CmsPhonenumber; diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 831d0b564..bbf688c46 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\Query\Filter\SQLFilter; -use Doctrine\ORM\Mapping\ClassMetaData; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Common\Cache\ArrayCache; use Doctrine\ORM\Mapping\ClassMetadataInfo; diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 0c76edf73..8887a0751 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -10,7 +10,7 @@ class DBAL483Test extends \Doctrine\Tests\OrmFunctionalTestCase { parent::setUp(); - $conn = $this->_em->getConnection(); + $this->_em->getConnection(); $this->schemaTool = new Tools\SchemaTool($this->_em); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php index 4df6032d0..a923c40fc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -2,10 +2,10 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\ORM\Tools\SchemaTool, - Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Tools\SchemaTool; +use Doctrine\Tests\OrmFunctionalTestCase; -class MySqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase +class MySqlSchemaToolTest extends OrmFunctionalTestCase { protected function setUp() { parent::setUp(); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 52151e4ba..66e990688 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -2,8 +2,7 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; -use Doctrine\ORM\Tools\SchemaTool, - Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Tools\SchemaTool; class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase { diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php index 948aad2ef..c09f336c9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php @@ -2,7 +2,6 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\DBAL\Types\Type as DBALType; use Doctrine\ORM\Tools\SchemaValidator; /** diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php index e84be7e07..316620f82 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php @@ -2,10 +2,8 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\Tests\Models\Cache\Action; use Doctrine\Tests\Models\Cache\Address; use Doctrine\Tests\Models\Cache\Client; -use Doctrine\Tests\Models\Cache\ComplexAction; use Doctrine\Tests\Models\Cache\Person; use Doctrine\Tests\Models\Cache\Token; use Doctrine\Tests\Models\Cache\Traveler; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php index 1b7c5b521..988e8ba99 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php @@ -2,14 +2,14 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-1040 */ -class DDC1040Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC1040Test extends OrmFunctionalTestCase { public function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php index 0cf14aecc..ee1218187 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -2,12 +2,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Tests\Models\Company\CompanyFixContract; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-1041 */ -class DDC1041Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC1041Test extends OrmFunctionalTestCase { public function setUp() { @@ -17,7 +18,7 @@ class DDC1041Test extends \Doctrine\Tests\OrmFunctionalTestCase public function testGrabWrongSubtypeReturnsNull() { - $fix = new \Doctrine\Tests\Models\Company\CompanyFixContract(); + $fix = new CompanyFixContract(); $fix->setFixPrice(2000); $this->_em->persist($fix); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php index babb43844..f3e255042 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php @@ -2,12 +2,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-1043 */ -class DDC1043Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC1043Test extends OrmFunctionalTestCase { public function setUp() { @@ -17,7 +18,7 @@ class DDC1043Test extends \Doctrine\Tests\OrmFunctionalTestCase public function testChangeSetPlusWeirdPHPCastingIntCastingRule() { - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user = new CmsUser(); $user->name = "John Galt"; $user->username = "jgalt"; $user->status = "+44"; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php index d95605425..98de7ee38 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php @@ -2,12 +2,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-1050 */ -class DDC1050Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC1050Test extends OrmFunctionalTestCase { public function setUp() { @@ -21,7 +22,7 @@ class DDC1050Test extends \Doctrine\Tests\OrmFunctionalTestCase public function testPerformance() { for ($i = 2; $i < 10000; ++$i) { - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user = new CmsUser(); $user->status = 'developer'; $user->username = 'jwage'+$i; $user->name = 'Jonathan'; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index 500b4e1e1..cd678d5f1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -2,10 +2,12 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; +use Doctrine\Tests\OrmFunctionalTestCase; + /** * @group DDC-1080 */ -class DDC1080Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC1080Test extends OrmFunctionalTestCase { public function testHydration() { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php index 335c89dce..e40f27994 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Collections\ArrayCollection; - /** * @group DDC-1113 * @group DDC-1306 diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php index 70d2e9fea..1f59d07ba 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Collections\ArrayCollection; - /** * @group DDC-1129 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php index 5a6d2e599..b6d82816c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -2,7 +2,9 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -class DDC1181Test extends \Doctrine\Tests\OrmFunctionalTestCase +use Doctrine\Tests\OrmFunctionalTestCase; + +class DDC1181Test extends OrmFunctionalTestCase { public function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php index 8e77ff0a3..a4ecf5d39 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -1,9 +1,10 @@ markTestSkipped("PostgreSQL only test."); } - $sql = $this->_schemaTool->getCreateSchemaSQL(array( + $sql = $this->_schemaTool->getCreateSchemaSql(array( $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1360DoubleQuote') )); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php index ad5fc4317..fb6ae25e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php @@ -1,7 +1,6 @@ _schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php index 949091f77..42aeca43e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2256Test.php @@ -10,9 +10,9 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; */ class DDC2256Test extends \Doctrine\Tests\OrmFunctionalTestCase { - protected function setup() + protected function setUp() { - parent::setup(); + parent::setUp(); $this->_schemaTool->createSchema(array( $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2256User'), $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2256Group') diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php index 6a4066c19..ca3ee1a50 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2306Test.php @@ -12,9 +12,9 @@ class DDC2306Test extends \Doctrine\Tests\OrmFunctionalTestCase /** * {@inheritDoc} */ - protected function setup() + protected function setUp() { - parent::setup(); + parent::setUp(); $this->_schemaTool->createSchema(array( $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2306Zone'), diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 8832b0f50..3d2781763 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -18,9 +18,9 @@ class DDC2346Test extends \Doctrine\Tests\OrmFunctionalTestCase /** * {@inheritDoc} */ - protected function setup() + protected function setUp() { - parent::setup(); + parent::setUp(); $this->_schemaTool->createSchema(array( $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2346Foo'), diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index c1189d797..324e5e7eb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -2,8 +2,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Mapping\ClassMetadataFactory; - /** * @group DDC-2359 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php index 39b918d26..d9dca3752 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -1,7 +1,10 @@ _schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index 94c3d60f0..d52953d60 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -13,9 +13,9 @@ class DDC2692Test extends \Doctrine\Tests\OrmFunctionalTestCase /** * {@inheritDoc} */ - protected function setup() + protected function setUp() { - parent::setup(); + parent::setUp(); try { $this->_schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php index a071d4c0c..6198663e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -10,9 +10,9 @@ class DDC2759Test extends \Doctrine\Tests\OrmFunctionalTestCase /** * {@inheritDoc} */ - protected function setup() + protected function setUp() { - parent::setup(); + parent::setUp(); try { $this->_schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index 0ba50564f..87c94cb84 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -16,9 +16,9 @@ class DDC2825Test extends \Doctrine\Tests\OrmFunctionalTestCase /** * {@inheritDoc} */ - protected function setup() + protected function setUp() { - parent::setup(); + parent::setUp(); $platform = $this->_em->getConnection()->getDatabasePlatform(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php index 30724b2c7..09d7415d2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php @@ -2,9 +2,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\ORM\Event\LifecycleEventArgs; - /** * @group DDC-2996 */ diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php index af1fcdc87..402c4374a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -1,7 +1,10 @@ _schemaTool->createSchema( array( diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php index 88da3268f..92df8d22f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php @@ -2,15 +2,6 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\Tests\Models\Company\CompanyPerson, - Doctrine\Tests\Models\Company\CompanyEmployee, - Doctrine\Tests\Models\Company\CompanyManager, - Doctrine\Tests\Models\Company\CompanyOrganization, - Doctrine\Tests\Models\Company\CompanyEvent, - Doctrine\Tests\Models\Company\CompanyAuction, - Doctrine\Tests\Models\Company\CompanyRaffle, - Doctrine\Tests\Models\Company\CompanyCar; - /** * Functional tests for the Class Table Inheritance mapping strategy. * diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php index a2eff6b57..b33f9a448 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3699Test.php @@ -1,7 +1,5 @@ _assignedGen->generate($this->_em, $entity); $this->fail('Assigned generator did not throw exception even though ID was missing.'); - } catch (\Doctrine\ORM\ORMException $expected) {} + } catch (ORMException $expected) {} try { $entity = new AssignedCompositeIdEntity; $this->_assignedGen->generate($this->_em, $entity); $this->fail('Assigned generator did not throw exception even though ID was missing.'); - } catch (\Doctrine\ORM\ORMException $expected) {} + } catch (ORMException $expected) {} } public function testCorrectIdGeneration() diff --git a/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php index 413384971..5d7f7a59b 100644 --- a/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php @@ -3,13 +3,14 @@ namespace Doctrine\Tests\ORM\Id; use Doctrine\ORM\Id\SequenceGenerator; +use Doctrine\Tests\OrmTestCase; /** * Description of SequenceGeneratorTest * * @author robo */ -class SequenceGeneratorTest extends \Doctrine\Tests\OrmTestCase +class SequenceGeneratorTest extends OrmTestCase { private $_em; private $_seqGen; diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 92da34cda..03f8bf154 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -4,16 +4,14 @@ namespace Doctrine\Tests\ORM; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\LazyCriteriaCollection; -use Doctrine\Tests\Mocks\ConnectionMock; use stdClass; -use PHPUnit_Framework_TestCase; /** * @author Marco Pivetta * * @covers \Doctrine\ORM\LazyCriteriaCollection */ -class LazyCriteriaCollectionTest extends PHPUnit_Framework_TestCase +class LazyCriteriaCollectionTest extends \PHPUnit_Framework_TestCase { /** * @var \Doctrine\ORM\Persisters\Entity\EntityPersister|\PHPUnit_Framework_MockObject_MockObject diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 7410979e0..f3f0506b1 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -2,19 +2,21 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; +use Doctrine\ORM\EntityManager; use Doctrine\ORM\Events; -use Doctrine\ORM\Event\LifecycleEventArgs; +use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\Id; -use Doctrine\Tests\Models\Company\CompanyFixContract; -use Doctrine\Tests\Models\Company\CompanyFlexContract; +use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\Tests\Models\Cache\City; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable; use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName; +use Doctrine\Tests\OrmTestCase; -abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase +abstract class AbstractMappingDriverTest extends OrmTestCase { abstract protected function _loadDriver(); @@ -23,7 +25,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase $mappingDriver = $this->_loadDriver(); $class = new ClassMetadata($entityClassName); - $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $class->initializeReflection(new RuntimeReflectionService()); $mappingDriver->loadMetadataForClass($entityClassName, $class); return $class; @@ -33,11 +35,11 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase * @param \Doctrine\ORM\EntityManager $entityClassName * @return \Doctrine\ORM\Mapping\ClassMetadataFactory */ - protected function createClassMetadataFactory(\Doctrine\ORM\EntityManager $em = null) + protected function createClassMetadataFactory(EntityManager $em = null) { $driver = $this->_loadDriver(); $em = $em ?: $this->_getTestEntityManager(); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $em->getConfiguration()->setMetadataDriverImpl($driver); $factory->setEntityManager($em); @@ -488,7 +490,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase $this->assertInstanceOf('Doctrine\ORM\Mapping\DefaultNamingStrategy', $em->getConfiguration()->getNamingStrategy()); - $em->getConfiguration()->setNamingStrategy(new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy(CASE_UPPER)); + $em->getConfiguration()->setNamingStrategy(new UnderscoreNamingStrategy(CASE_UPPER)); $this->assertInstanceOf('Doctrine\ORM\Mapping\UnderscoreNamingStrategy', $em->getConfiguration()->getNamingStrategy()); $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index e1838dfe8..4b44d1d41 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -2,10 +2,11 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\ClassMetadata; -use Doctrine\ORM\Events; -use Doctrine\Tests\Models\DDC2825\ExplicitSchemaAndTable; -use Doctrine\Tests\Models\DDC2825\SchemaAndTableInTableName; +use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\ORM\Mapping\Driver\AnnotationDriver; class AnnotationDriverTest extends AbstractMappingDriverTest { @@ -15,9 +16,9 @@ class AnnotationDriverTest extends AbstractMappingDriverTest public function testLoadMetadataForNonEntityThrowsException() { $cm = new ClassMetadata('stdClass'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); - $reader = new \Doctrine\Common\Annotations\AnnotationReader(); - $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader); + $cm->initializeReflection(new RuntimeReflectionService()); + $reader = new AnnotationReader(); + $annotationDriver = new AnnotationDriver($reader); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); $annotationDriver->loadMetadataForClass('stdClass', $cm); @@ -42,7 +43,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest public function testColumnWithMissingTypeDefaultsToString() { $cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ColumnWithoutType'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->initializeReflection(new RuntimeReflectionService()); $annotationDriver = $this->_loadDriver(); $annotationDriver->loadMetadataForClass('Doctrine\Tests\ORM\Mapping\InvalidColumn', $cm); @@ -134,7 +135,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $em = $this->_getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); $classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File'); @@ -153,7 +154,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $em = $this->_getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', @@ -171,7 +172,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $em = $this->_getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', @@ -187,10 +188,9 @@ class AnnotationDriverTest extends AbstractMappingDriverTest { $annotationDriver = $this->_loadDriver(); - $cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\AnnotationChild'); $em = $this->_getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\AnnotationChild'); @@ -209,7 +209,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $em = $this->_getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\ChildEntity'); @@ -221,7 +221,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $em = $this->_getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); $this->setExpectedException('Doctrine\Common\Annotations\AnnotationException', diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php index 8cec99717..d5f2a9738 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnsiQuoteStrategyTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\AnsiQuoteStrategy; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\OrmTestCase; @@ -39,7 +40,7 @@ class AnsiQuoteStrategyTest extends OrmTestCase private function createClassMetadata($className) { $class = new ClassMetadata($className); - $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $class->initializeReflection(new RuntimeReflectionService()); return $class; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 5a5f64277..977c1fa26 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -6,8 +6,9 @@ use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\Tests\Models\DDC869\DDC869Payment; +use Doctrine\Tests\OrmTestCase; -class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase +class BasicInheritanceMappingTest extends OrmTestCase { /** * @var ClassMetadataFactory diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index d8824e767..58ee64a42 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -19,13 +19,15 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; +use Doctrine\Tests\OrmTestCase; /** * @group DDC-659 */ -class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase +class ClassMetadataBuilderTest extends OrmTestCase { /** * @var ClassMetadata @@ -39,7 +41,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase public function setUp() { $this->cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $this->cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->cm->initializeReflection(new RuntimeReflectionService()); $this->builder = new ClassMetadataBuilder($this->cm); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 4cabaec88..71dc598a8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -3,6 +3,8 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\Common\EventManager; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; +use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; use Doctrine\ORM\Events; @@ -13,8 +15,9 @@ use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\MetadataDriverMock; +use Doctrine\Tests\OrmTestCase; -class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase +class ClassMetadataFactoryTest extends OrmTestCase { public function testGetMetadataForSingleClass() { @@ -219,7 +222,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase protected function _createEntityManager($metadataDriver, $conn = null) { $driverMock = new DriverMock(); - $config = new \Doctrine\ORM\Configuration(); + $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../../Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $eventManager = new EventManager(); @@ -251,7 +254,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase { // Self-made metadata $cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1'); - $cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm1->initializeReflection(new RuntimeReflectionService()); $cm1->setPrimaryTable(array('name' => '`group`')); // Add a mapped field $cm1->mapField(array('fieldName' => 'name', 'type' => 'string')); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index 2d949aeef..04cea3894 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -2,10 +2,11 @@ namespace Doctrine\Tests\ORM\Mapping; -use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Event\LoadClassMetadataEventArgs; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmTestCase; -class ClassMetadataLoadEventTest extends \Doctrine\Tests\OrmTestCase +class ClassMetadataLoadEventTest extends OrmTestCase { /** * @group DDC-1610 @@ -22,7 +23,7 @@ class ClassMetadataLoadEventTest extends \Doctrine\Tests\OrmTestCase $this->assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); } - public function loadClassMetadata(\Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs) + public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $classMetadata = $eventArgs->getClassMetadata(); $field = array( diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 2a7b65002..e324c3729 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -7,10 +7,13 @@ use Doctrine\Common\Persistence\Mapping\StaticReflectionService; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\DefaultNamingStrategy; +use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; +use Doctrine\Tests\OrmTestCase; +use Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser; require_once __DIR__ . '/../../Models/Global/GlobalNamespaceModel.php'; -class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase +class ClassMetadataTest extends OrmTestCase { public function testClassMetadataInstanceSerialization() { @@ -329,7 +332,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase */ public function testUnderscoreNamingStrategyDefaults() { - $namingStrategy = new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy(CASE_UPPER); + $namingStrategy = new UnderscoreNamingStrategy(CASE_UPPER); $oneToOneMetadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy); $manyToManyMetadata = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', $namingStrategy); @@ -724,8 +727,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $metadata = new ClassMetadata('Doctrine\Tests\Models\Company\CompanyContract'); $metadata->initializeReflection(new RuntimeReflectionService()); - $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler'); - $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); + $metadata->addEntityListener(Events::prePersist, 'CompanyContractListener', 'prePersistHandler'); + $metadata->addEntityListener(Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); $serialize = serialize($metadata); $unserialize = unserialize($serialize); @@ -814,7 +817,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase */ public function testClassCaseSensitivity() { - $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user = new CmsUser(); $cm = new ClassMetadata('DOCTRINE\TESTS\MODELS\CMS\CMSUSER'); $cm->initializeReflection(new RuntimeReflectionService()); diff --git a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php index 64007b031..bef03b9ba 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/EntityListenerResolverTest.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\ORM\Mapping\DefaultEntityListenerResolver; +use Doctrine\Tests\OrmTestCase; /** * @group DDC-1955 */ -class EntityListenerResolverTest extends \Doctrine\Tests\OrmTestCase +class EntityListenerResolverTest extends OrmTestCase { /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php index f882dacc4..3d759aade 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php @@ -21,8 +21,9 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\Tests\OrmTestCase; -class FieldBuilderTest extends \Doctrine\Tests\OrmTestCase +class FieldBuilderTest extends OrmTestCase { public function testCustomIdGeneratorCanBeSet() { diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php index 16f0fe576..6274a1468 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategyTest.php @@ -6,11 +6,12 @@ use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\ORM\Mapping\DefaultNamingStrategy; use Doctrine\ORM\Mapping\NamingStrategy; use Doctrine\Tests\ORM\Mapping\NamingStrategy\JoinColumnClassNamingStrategy; +use Doctrine\Tests\OrmTestCase; /** * @group DDC-559 */ -class NamingStrategyTest extends \Doctrine\Tests\OrmTestCase +class NamingStrategyTest extends OrmTestCase { /** * @return DefaultNamingStrategy diff --git a/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php index 142455542..cfc7f0cc8 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php @@ -3,8 +3,7 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\Common\Persistence\Mapping\Driver\PHPDriver, - Doctrine\ORM\Tools\Export\ClassMetadataExporter; + Doctrine\Common\Persistence\Mapping\Driver\PHPDriver; class PHPMappingDriverTest extends AbstractMappingDriverTest { diff --git a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php index 0cb60fde4..0b736dd0b 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/QuoteStrategyTest.php @@ -2,14 +2,15 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\DefaultQuoteStrategy; -use Doctrine\ORM\Mapping\QuoteStrategy; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\Tests\OrmTestCase; /** * @group DDC-1845 */ -class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase +class QuoteStrategyTest extends OrmTestCase { /** @@ -37,7 +38,7 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase private function createClassMetadata($className) { $cm = new ClassMetadata($className); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->initializeReflection(new RuntimeReflectionService()); return $cm; } @@ -73,7 +74,7 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals('"cms_user"' ,$this->strategy->getTableName($cm, $this->platform)); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->initializeReflection(new RuntimeReflectionService()); $cm->setPrimaryTable(array('name'=>'cms_user')); $this->assertEquals('cms_user' ,$this->strategy->getTableName($cm, $this->platform)); } @@ -189,7 +190,7 @@ class QuoteStrategyTest extends \Doctrine\Tests\OrmTestCase } } -class MyQuoteStrategy extends \Doctrine\ORM\Mapping\DefaultQuoteStrategy +class MyQuoteStrategy extends DefaultQuoteStrategy { } diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php index 99e436ae8..2056c1da0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php @@ -96,18 +96,4 @@ abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase abstract protected function getFileExtension(); abstract protected function getDriver(array $paths = array()); - - private function setField($obj, $field, $value) - { - $ref = new \ReflectionProperty($obj, $field); - $ref->setAccessible(true); - $ref->setValue($obj, $value); - } - - private function invoke($obj, $method, array $args = array()) { - $ref = new \ReflectionMethod($obj, $method); - $ref->setAccessible(true); - - return $ref->invokeArgs($obj, $args); - } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index c2822f178..735c16ed5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\Driver\XmlDriver; @@ -19,7 +20,7 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest $mappingDriver = $this->_loadDriver(); $class = new ClassMetadata($className); - $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $class->initializeReflection(new RuntimeReflectionService()); $mappingDriver->loadMetadataForClass($className, $class); $expectedMap = array( diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index 95d6c7f9a..c752c6a82 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -3,8 +3,8 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Mapping\Driver\XmlDriver, Doctrine\ORM\Mapping\Driver\YamlDriver; +use Doctrine\ORM\Mapping\ClassMetadataFactory; class YamlMappingDriverTest extends AbstractMappingDriverTest { @@ -29,7 +29,7 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest $em = $this->_getTestEntityManager(); $em->getConfiguration()->setMetadataDriverImpl($yamlDriver); - $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); $classPage = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\File'); diff --git a/tests/Doctrine/Tests/ORM/Performance/DDC2602Test.php b/tests/Doctrine/Tests/ORM/Performance/DDC2602Test.php index 5b307eba1..210f72c80 100644 --- a/tests/Doctrine/Tests/ORM/Performance/DDC2602Test.php +++ b/tests/Doctrine/Tests/ORM/Performance/DDC2602Test.php @@ -5,12 +5,13 @@ namespace Doctrine\Tests\ORM\Performance; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmPerformanceTestCase; /** * @group performance * @group DDC-2602 */ -class DDC2602Test extends \Doctrine\Tests\OrmPerformanceTestCase +class DDC2602Test extends OrmPerformanceTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php index ab6e3259c..e4d65e1e7 100644 --- a/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php @@ -2,9 +2,13 @@ namespace Doctrine\Tests\ORM\Performance; +use Doctrine\ORM\Internal\Hydration\ArrayHydrator; +use Doctrine\ORM\Internal\Hydration\ObjectHydrator; +use Doctrine\ORM\Internal\Hydration\ScalarHydrator; use Doctrine\Tests\Mocks\HydratorMockStatement, Doctrine\ORM\Query\ResultSetMapping, Doctrine\ORM\Query; +use Doctrine\Tests\OrmPerformanceTestCase; /** * Tests to prevent serious performance regressions. @@ -15,7 +19,7 @@ use Doctrine\Tests\Mocks\HydratorMockStatement, * @author robo * @group performance */ -class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase +class HydrationPerformanceTest extends OrmPerformanceTestCase { /** * Times for comparison: @@ -66,7 +70,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase } $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); + $hydrator = new ScalarHydrator($this->_em); $this->setMaxRunningTime(1); $s = microtime(true); @@ -124,7 +128,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase } $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $hydrator = new ArrayHydrator($this->_em); $this->setMaxRunningTime(2); $s = microtime(true); @@ -198,7 +202,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase } $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $hydrator = new ArrayHydrator($this->_em); $this->setMaxRunningTime(3); $s = microtime(true); @@ -254,7 +258,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase } $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $hydrator = new ObjectHydrator($this->_em); $this->setMaxRunningTime(3); $s = microtime(true); @@ -310,7 +314,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase } $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $hydrator = new ObjectHydrator($this->_em); $this->setMaxRunningTime(5); $s = microtime(true); @@ -382,7 +386,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase } $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $hydrator = new ObjectHydrator($this->_em); $this->setMaxRunningTime(1); $s = microtime(true); @@ -447,7 +451,7 @@ class HydrationPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase } $stmt = new HydratorMockStatement($resultSet); - $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $hydrator = new ObjectHydrator($this->_em); $this->setMaxRunningTime(1); $s = microtime(true); diff --git a/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php index b18fe2850..2104587ae 100644 --- a/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php @@ -2,13 +2,17 @@ namespace Doctrine\Tests\ORM\Performance; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Query; +use Doctrine\Tests\Models\Company\CompanyEmployee; +use Doctrine\Tests\Models\Company\CompanyFixContract; +use Doctrine\Tests\Models\Company\CompanyFlexContract; +use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group performance */ -class InheritancePersisterPerformanceTest extends \Doctrine\Tests\OrmFunctionalTestCase +class InheritancePersisterPerformanceTest extends OrmFunctionalTestCase { protected function setUp() { @@ -18,27 +22,27 @@ class InheritancePersisterPerformanceTest extends \Doctrine\Tests\OrmFunctionalT public function testCompanyContract() { - $person = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $person = new CompanyEmployee(); $person->setName('Poor Sales Guy'); $person->setDepartment('Sales'); $person->setSalary(100); $this->_em->persist($person); for ($i = 0; $i < 33; $i++) { - $fix = new \Doctrine\Tests\Models\Company\CompanyFixContract(); + $fix = new CompanyFixContract(); $fix->setFixPrice(1000); $fix->setSalesPerson($person); $fix->markCompleted(); $this->_em->persist($fix); - $flex = new \Doctrine\Tests\Models\Company\CompanyFlexContract(); + $flex = new CompanyFlexContract(); $flex->setSalesPerson($person); $flex->setHoursWorked(100); $flex->setPricePerHour(100); $flex->markCompleted(); $this->_em->persist($flex); - $ultra = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); + $ultra = new CompanyFlexUltraContract(); $ultra->setSalesPerson($person); $ultra->setHoursWorked(150); $ultra->setPricePerHour(150); diff --git a/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php index f387d1d23..db5455b06 100644 --- a/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Performance; use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmPerformanceTestCase; /** * Description of InsertPerformanceTest @@ -10,9 +11,10 @@ use Doctrine\Tests\Models\CMS\CmsUser; * @author robo * @group performance */ -class InsertPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase +class InsertPerformanceTest extends OrmPerformanceTestCase { - protected function setUp() { + protected function setUp() + { $this->useModelSet('cms'); parent::setUp(); } diff --git a/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php index 21be1abad..db5d0f8ef 100644 --- a/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php @@ -2,19 +2,16 @@ namespace Doctrine\Tests\ORM\Performance; -use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Query; use Doctrine\Tests\Models\CMS\CmsUser; -use Doctrine\Tests\Models\CMS\CmsPhonenumber; -use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsArticle; -use Doctrine\Tests\Models\CMS\CmsComment; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group performance */ -class PersisterPerformanceTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PersisterPerformanceTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php index a43907f9e..ffe621eef 100644 --- a/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php @@ -20,7 +20,6 @@ namespace Doctrine\Tests\ORM\Performance; use Doctrine\Tests\OrmPerformanceTestCase; -use Doctrine\Common\Proxy\Proxy; use Doctrine\ORM\EntityManager; use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\Proxy\ProxyFactory; diff --git a/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php index f2aeda714..934933635 100644 --- a/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Performance; use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmPerformanceTestCase; /** * Description of InsertPerformanceTest @@ -10,7 +11,7 @@ use Doctrine\Tests\Models\CMS\CmsUser; * @author robo * @group performance */ -class UnitOfWorkPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase +class UnitOfWorkPerformanceTest extends OrmPerformanceTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index 5b1ffce62..4956e5648 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -3,7 +3,6 @@ namespace Doctrine\Tests\ORM; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Collections\Collection; use Doctrine\ORM\PersistentCollection; use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php index 76daadc3f..74d72856e 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php @@ -6,8 +6,9 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; use Doctrine\Tests\Models\GeoNames\Admin1; use Doctrine\Tests\Models\GeoNames\Country; +use Doctrine\Tests\OrmTestCase; -class BasicEntityPersisterCompositeTypeParametersTest extends \Doctrine\Tests\OrmTestCase +class BasicEntityPersisterCompositeTypeParametersTest extends OrmTestCase { /** * @var BasicEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php index 54b1a2351..e788826d4 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeSqlTest.php @@ -2,15 +2,11 @@ namespace Doctrine\Tests\ORM\Persisters; -use Doctrine\Common\Collections\Criteria; -use Doctrine\DBAL\Types\Type as DBALType; -use Doctrine\ORM\EntityManager; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; -use Doctrine\Tests\Models\CustomType\CustomTypeParent; -use Doctrine\Tests\Models\CustomType\CustomTypeChild; use Doctrine\Common\Collections\Expr\Comparison; +use Doctrine\Tests\OrmTestCase; -class BasicEntityPersisterCompositeTypeSqlTest extends \Doctrine\Tests\OrmTestCase +class BasicEntityPersisterCompositeTypeSqlTest extends OrmTestCase { /** * @var BasicEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php index d51e40555..b617d14da 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -9,8 +9,9 @@ use Doctrine\Tests\Models\CustomType\CustomTypeParent; use Doctrine\Tests\Models\CustomType\CustomTypeChild; use Doctrine\Tests\Models\CustomType\CustomTypeFriend; use Doctrine\Common\Collections\Expr\Comparison; +use Doctrine\Tests\OrmTestCase; -class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase +class BasicEntityPersisterTypeValueSqlTest extends OrmTestCase { /** * @var BasicEntityPersister diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index a8a2adaba..39fab08b9 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -2,21 +2,22 @@ namespace Doctrine\Tests\ORM\Proxy; +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Proxy\ProxyFactory; -use Doctrine\Common\Proxy\ProxyGenerator; use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Common\Proxy\AbstractProxyFactory; +use Doctrine\Tests\OrmTestCase; /** * Test the proxy generator. Its work is generating on-the-fly subclasses of a given model, which implement the Proxy pattern. * @author Giorgio Sironi */ -class ProxyFactoryTest extends \Doctrine\Tests\OrmTestCase +class ProxyFactoryTest extends OrmTestCase { /** * @var ConnectionMock @@ -75,7 +76,7 @@ class ProxyFactoryTest extends \Doctrine\Tests\OrmTestCase public function testSkipAbstractClassesOnGeneration() { $cm = new ClassMetadata(__NAMESPACE__ . '\\AbstractClass'); - $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->initializeReflection(new RuntimeReflectionService()); $this->assertNotNull($cm->reflClass); $num = $this->proxyFactory->generateProxyClasses(array($cm)); diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php index 60545d4f9..284cc1adc 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php @@ -20,6 +20,7 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query; +use Doctrine\Tests\OrmTestCase; /** * Test case for custom AST walking and adding new joins. @@ -28,7 +29,7 @@ use Doctrine\ORM\Query; * @license MIT * @link http://www.doctrine-project.org */ -class CustomTreeWalkersJoinTest extends \Doctrine\Tests\OrmTestCase +class CustomTreeWalkersJoinTest extends OrmTestCase { private $em; diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index 574b37ae7..dffcd481a 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -20,6 +20,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Query; +use Doctrine\Tests\OrmTestCase; /** * Test case for custom AST walking and modification. @@ -29,7 +30,7 @@ use Doctrine\ORM\Query; * @link http://www.doctrine-project.org * @since 2.0 */ -class CustomTreeWalkersTest extends \Doctrine\Tests\OrmTestCase +class CustomTreeWalkersTest extends OrmTestCase { private $_em; diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index 21679c894..0bae052d8 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -20,6 +20,7 @@ */ namespace Doctrine\Tests\ORM\Query; +use Doctrine\Tests\OrmTestCase; /** * Test case for testing the saving and referencing of query identifiers. @@ -35,7 +36,7 @@ namespace Doctrine\Tests\ORM\Query; * testcases later since we'll have a lot of them and we might want to have special SQL * generation tests for some dbms specific SQL syntaxes. */ -class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase +class DeleteSqlGenerationTest extends OrmTestCase { private $_em; diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index d64fed335..4974f2d7a 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -21,6 +21,7 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query; +use Doctrine\Tests\OrmTestCase; /** * Test case for the DQL Expr class used for generating DQL snippets through @@ -32,7 +33,7 @@ use Doctrine\ORM\Query; * @since 2.0 * @version $Revision$ */ -class ExprTest extends \Doctrine\Tests\OrmTestCase +class ExprTest extends OrmTestCase { private $_em; diff --git a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php index 455949de0..7a50516a7 100644 --- a/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/FilterCollectionTest.php @@ -2,15 +2,16 @@ namespace Doctrine\Tests\ORM\Query; -use Doctrine\ORM\Mapping\ClassMetaData, +use Doctrine\ORM\Mapping\ClassMetadata, Doctrine\ORM\Query\Filter\SQLFilter; +use Doctrine\Tests\OrmTestCase; /** * Test case for FilterCollection * * @author Guilherme Blanco */ -class FilterCollectionTest extends \Doctrine\Tests\OrmTestCase +class FilterCollectionTest extends OrmTestCase { /** * @var \Doctrine\ORM\EntityManager diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index b90047e19..daec446bb 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -1,11 +1,13 @@ setHint($key, $value); } - $parser = new \Doctrine\ORM\Query\Parser($query); + $parser = new Query\Parser($query); // We do NOT test SQL output here. That only unnecessarily slows down the tests! $parser->setCustomOutputTreeWalker('Doctrine\Tests\Mocks\MockTreeWalker'); diff --git a/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/tests/Doctrine/Tests/ORM/Query/LexerTest.php index 5c9828731..9c4a889f0 100644 --- a/tests/Doctrine/Tests/ORM/Query/LexerTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -3,8 +3,9 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query\Lexer; +use Doctrine\Tests\OrmTestCase; -class LexerTest extends \Doctrine\Tests\OrmTestCase +class LexerTest extends OrmTestCase { //private $_lexer; diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index 4e00bbc88..d10c78c9c 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -21,9 +21,10 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query\ParameterTypeInferer; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type; +use Doctrine\Tests\OrmTestCase; use PDO; -class ParameterTypeInfererTest extends \Doctrine\Tests\OrmTestCase +class ParameterTypeInfererTest extends OrmTestCase { public function providerParameterTypeInferer() diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Doctrine/Tests/ORM/Query/ParserTest.php index 1bc7f5dfb..097f9ec88 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserTest.php @@ -5,8 +5,9 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; +use Doctrine\Tests\OrmTestCase; -class ParserTest extends \Doctrine\Tests\OrmTestCase +class ParserTest extends OrmTestCase { /** diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index 2618af1db..d59c93b07 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -9,8 +9,9 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\Query\Parameter; use Doctrine\Tests\Mocks\DriverConnectionMock; use Doctrine\Tests\Mocks\StatementArrayMock; +use Doctrine\Tests\OrmTestCase; -class QueryTest extends \Doctrine\Tests\OrmTestCase +class QueryTest extends OrmTestCase { /** @var EntityManager */ protected $_em = null; diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 1aabaa78b..fa12a3e33 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -2,10 +2,24 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\DBAL\LockMode; +use Doctrine\DBAL\Platforms\MySqlPlatform; +use Doctrine\DBAL\Platforms\OraclePlatform; +use Doctrine\DBAL\Platforms\PostgreSqlPlatform; +use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Types\Type as DBALType; -use Doctrine\ORM\Query; +use Doctrine\ORM\Query as ORMQuery; +use Doctrine\ORM\Query\AST\Functions\FunctionNode; +use Doctrine\ORM\Query\Lexer; +use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\SqlWalker; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\OrmTestCase; -class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase +class SelectSqlGenerationTest extends OrmTestCase { private $_em; @@ -31,7 +45,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $query->setParameter($name, $value); } - $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) + $query->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true) ->useQueryCache(false); foreach ($queryHints AS $name => $value) { @@ -70,7 +84,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $query->setParameter($name, $value); } - $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) + $query->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true) ->useQueryCache(false); foreach ($queryHints AS $name => $value) { @@ -92,7 +106,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT c.id FROM Doctrine\Tests\Models\Company\CompanyPerson c JOIN Doctrine\Tests\Models\Company\CompanyPerson r WHERE c.spouse = r AND r.id = 42', 'SELECT c0_.id AS id_0 FROM company_persons c0_ INNER JOIN company_persons c1_ WHERE c0_.spouse_id = c1_.id AND c1_.id = 42', - array(Query::HINT_FORCE_PARTIAL_LOAD => true) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => true) ); } @@ -109,7 +123,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT c.id FROM Doctrine\Tests\Models\Company\CompanyPerson c JOIN Doctrine\Tests\Models\Company\CompanyPerson r WHERE c.spouse = r AND r.id = 42', 'SELECT c0_.id AS id_0 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id INNER JOIN company_persons c3_ LEFT JOIN company_managers c4_ ON c3_.id = c4_.id LEFT JOIN company_employees c5_ ON c3_.id = c5_.id WHERE c0_.spouse_id = c3_.id AND c3_.id = 42', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -299,7 +313,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $connMock = $this->_em->getConnection(); $orgPlatform = $connMock->getDatabasePlatform(); - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); + $connMock->setDatabasePlatform(new MySqlPlatform()); $this->assertSqlGeneration( 'SELECT COUNT(CONCAT(u.id, u.name)) FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id', @@ -514,7 +528,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase { $this->assertInvalidSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\CMS\CmsUser", - "Doctrine\ORM\Query\QueryException" + "Doctrine\\ORM\\Query\\QueryException" ); } @@ -601,7 +615,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $connMock = $this->_em->getConnection(); $orgPlatform = $connMock->getDatabasePlatform(); - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); + $connMock->setDatabasePlatform(new MySqlPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, 's') = ?" @@ -611,7 +625,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT CONCAT(c0_.id, c0_.name) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?" ); - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); + $connMock->setDatabasePlatform(new PostgreSqlPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE c0_.name || 's' = ?" @@ -647,9 +661,9 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase { // "Get all users who have $phone as a phonenumber." (*cough* doesnt really make sense...) $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $phone = new \Doctrine\Tests\Models\CMS\CmsPhonenumber; + $phone = new CmsPhonenumber(); $phone->phonenumber = 101; $q->setParameter('param', $phone); @@ -663,9 +677,9 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase { // "Get all users who are members of $group." $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.groups'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $group = new \Doctrine\Tests\Models\CMS\CmsGroup; + $group = new CmsGroup(); $group->id = 101; $q->setParameter('param', $group); @@ -678,11 +692,11 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase public function testSupportsMemberOfExpressionManyToManyParameterArray() { $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.groups'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); - $group = new \Doctrine\Tests\Models\CMS\CmsGroup; + $group = new CmsGroup(); $group->id = 101; - $group2 = new \Doctrine\Tests\Models\CMS\CmsGroup; + $group2 = new CmsGroup(); $group2->id = 105; $q->setParameter('param', array($group, $group2)); @@ -697,7 +711,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase // "Get all persons who have $person as a friend." // Tough one: Many-many self-referencing ("friends") with class table inheritance $q = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p WHERE :param MEMBER OF p.friends'); - $person = new \Doctrine\Tests\Models\Company\CompanyPerson; + $person = new CompanyPerson(); $this->_em->getClassMetadata(get_class($person))->setIdentifierValues($person, array('id' => 101)); $q->setParameter('param', $person); $this->assertEquals( @@ -731,21 +745,21 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase public function testSupportsCurrentDateFunction() { $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_date()'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_DATE', $q->getSql()); } public function testSupportsCurrentTimeFunction() { $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.time > current_time()'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_time > CURRENT_TIME', $q->getSql()); } public function testSupportsCurrentTimestampFunction() { $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_timestamp()'); - $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $q->setHint(ORMQuery::HINT_FORCE_PARTIAL_LOAD, true); $this->assertEquals('SELECT d0_.id AS id_0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_TIMESTAMP', $q->getSql()); } @@ -884,7 +898,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase public function testBooleanLiteralInWhereOnSqlite() { $oldPlat = $this->_em->getConnection()->getDatabasePlatform(); - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SqlitePlatform); + $this->_em->getConnection()->setDatabasePlatform(new SqlitePlatform()); $this->assertSqlGeneration( "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true", @@ -902,7 +916,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase public function testBooleanLiteralInWhereOnPostgres() { $oldPlat = $this->_em->getConnection()->getDatabasePlatform(); - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); + $this->_em->getConnection()->setDatabasePlatform(new PostgreSqlPlatform()); $this->assertSqlGeneration( "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true", @@ -1024,7 +1038,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase */ public function testPessimisticWriteLockQueryHint() { - if ($this->_em->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { + if ($this->_em->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { $this->markTestSkipped('SqLite does not support Row locking at all.'); } @@ -1032,7 +1046,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ". "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) + array(ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_WRITE) ); } @@ -1042,14 +1056,14 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase */ public function testPessimisticReadLockQueryHintPostgreSql() { - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); + $this->_em->getConnection()->setDatabasePlatform(new PostgreSqlPlatform()); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ". "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR SHARE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) - ); + array(ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ) + ); } /** @@ -1062,8 +1076,8 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ". "FROM cms_users c0_ WHERE c0_.username = 'gblanco'", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::NONE) - ); + array(ORMQuery::HINT_LOCK_MODE => LockMode::NONE) + ); } /** @@ -1083,13 +1097,13 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase */ public function testPessimisticReadLockQueryHintMySql() { - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); + $this->_em->getConnection()->setDatabasePlatform(new MySqlPlatform()); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "SELECT c0_.id AS id_0, c0_.status AS status_1, c0_.username AS username_2, c0_.name AS name_3 ". "FROM cms_users c0_ WHERE c0_.username = 'gblanco' LOCK IN SHARE MODE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) + array(ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ) ); } @@ -1099,13 +1113,13 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase */ public function testPessimisticReadLockQueryHintOracle() { - $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\OraclePlatform); + $this->_em->getConnection()->setDatabasePlatform(new OraclePlatform()); $this->assertSqlGeneration( "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", "SELECT c0_.id AS ID_0, c0_.status AS STATUS_1, c0_.username AS USERNAME_2, c0_.name AS NAME_3 ". "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", - array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) + array(ORMQuery::HINT_LOCK_MODE => LockMode::PESSIMISTIC_READ) ); } @@ -1426,7 +1440,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c1_.car_id AS car_id_8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -1438,7 +1452,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.discr AS discr_2 FROM company_persons c0_', - array(Query::HINT_FORCE_PARTIAL_LOAD => true) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => true) ); } @@ -1450,7 +1464,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -1462,7 +1476,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c0_.discr AS discr_5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => true) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => true) ); } @@ -1474,7 +1488,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6, c0_.spouse_id AS spouse_id_7, c2_.car_id AS car_id_8 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -1486,7 +1500,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', 'SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.salary AS salary_2, c1_.department AS department_3, c1_.startDate AS startDate_4, c2_.title AS title_5, c0_.discr AS discr_6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id', - array(Query::HINT_FORCE_PARTIAL_LOAD => true) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => true) ); } @@ -1498,7 +1512,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6, c0_.salesPerson_id AS salesPerson_id_7 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -1510,7 +1524,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.fixPrice AS fixPrice_2, c0_.hoursWorked AS hoursWorked_3, c0_.pricePerHour AS pricePerHour_4, c0_.maxPrice AS maxPrice_5, c0_.discr AS discr_6 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => true) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => true) ); } @@ -1522,7 +1536,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -1534,7 +1548,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => true) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => true) ); } @@ -1546,7 +1560,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5, c0_.salesPerson_id AS salesPerson_id_6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -1558,7 +1572,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', "SELECT c0_.id AS id_0, c0_.completed AS completed_1, c0_.hoursWorked AS hoursWorked_2, c0_.pricePerHour AS pricePerHour_3, c0_.maxPrice AS maxPrice_4, c0_.discr AS discr_5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", - array(Query::HINT_FORCE_PARTIAL_LOAD => true) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => true) ); } @@ -1570,7 +1584,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT p, pp FROM Doctrine\Tests\Models\Company\CompanyPerson p JOIN p.spouse pp', "SELECT c0_.id AS id_0, c0_.name AS name_1, c1_.title AS title_2, c2_.salary AS salary_3, c2_.department AS department_4, c2_.startDate AS startDate_5, c3_.id AS id_6, c3_.name AS name_7, c4_.title AS title_8, c5_.salary AS salary_9, c5_.department AS department_10, c5_.startDate AS startDate_11, c0_.discr AS discr_12, c0_.spouse_id AS spouse_id_13, c1_.car_id AS car_id_14, c3_.discr AS discr_15, c3_.spouse_id AS spouse_id_16, c4_.car_id AS car_id_17 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id INNER JOIN company_persons c3_ ON c0_.spouse_id = c3_.id LEFT JOIN company_managers c4_ ON c3_.id = c4_.id LEFT JOIN company_employees c5_ ON c3_.id = c5_.id", - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -2051,7 +2065,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $connMock = $this->_em->getConnection(); $orgPlatform = $connMock->getDatabasePlatform(); - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); + $connMock->setDatabasePlatform(new MySqlPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE CONCAT(c0_.name, c0_.status, 's') = ?" @@ -2061,7 +2075,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT CONCAT(c0_.id, c0_.name, c0_.status) AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?" ); - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); + $connMock->setDatabasePlatform(new PostgreSqlPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE c0_.name || c0_.status || 's' = ?" @@ -2071,7 +2085,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase "SELECT c0_.id || c0_.name || c0_.status AS sclr_0 FROM cms_users c0_ WHERE c0_.id = ?" ); - $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SQLServerPlatform()); + $connMock->setDatabasePlatform(new SQLServerPlatform()); $this->assertSqlGeneration( "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1", "SELECT c0_.id AS id_0 FROM cms_users c0_ WHERE (c0_.name + c0_.status + 's') = ?" @@ -2145,7 +2159,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $this->assertSqlGeneration( 'SELECT e.id FROM Doctrine\Tests\Models\Company\CompanyOrganization o JOIN o.events e WITH e.id = ?1', 'SELECT c0_.id AS id_0 FROM company_organizations c1_ INNER JOIN (company_events c0_ LEFT JOIN company_auctions c2_ ON c0_.id = c2_.id LEFT JOIN company_raffles c3_ ON c0_.id = c3_.id) ON c1_.id = c0_.org_id AND (c0_.id = ?)', - array(Query::HINT_FORCE_PARTIAL_LOAD => false) + array(ORMQuery::HINT_FORCE_PARTIAL_LOAD => false) ); } @@ -2294,14 +2308,14 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase } } -class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode +class MyAbsFunction extends FunctionNode { public $simpleArithmeticExpression; /** * @override */ - public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + public function getSql(SqlWalker $sqlWalker) { return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) . ')'; } @@ -2309,16 +2323,16 @@ class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode /** * @override */ - public function parse(\Doctrine\ORM\Query\Parser $parser) + public function parse(Parser $parser) { $lexer = $parser->getLexer(); - $parser->match(\Doctrine\ORM\Query\Lexer::T_IDENTIFIER); - $parser->match(\Doctrine\ORM\Query\Lexer::T_OPEN_PARENTHESIS); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); - $parser->match(\Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS); + $parser->match(Lexer::T_CLOSE_PARENTHESIS); } } /** diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index de71ba9b7..5dae79b3d 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -22,6 +22,7 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\DBAL\Types\Type as DBALType; +use Doctrine\Tests\OrmTestCase; /** * Test case for testing the saving and referencing of query identifiers. @@ -37,7 +38,7 @@ use Doctrine\DBAL\Types\Type as DBALType; * testcases later since we'll have a lot of them and we might want to have special SQL * generation tests for some dbms specific SQL syntaxes. */ -class UpdateSqlGenerationTest extends \Doctrine\Tests\OrmTestCase +class UpdateSqlGenerationTest extends OrmTestCase { private $_em; diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index abe602a53..318eb2a2f 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -27,6 +27,7 @@ use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Parameter; use Doctrine\ORM\Query\ParameterTypeInferer; +use Doctrine\Tests\OrmTestCase; /** * Test case for the QueryBuilder class used to build DQL query string in a @@ -36,7 +37,7 @@ use Doctrine\ORM\Query\ParameterTypeInferer; * @author Roman Borschel setProxyDir(__DIR__ . '/../../Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $eventManager = new EventManager(); $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager); - $mockDriver = new MetadataDriverMock(); $config->setMetadataDriverImpl($metadataDriver); return EntityManagerMock::create($conn, $config, $eventManager); @@ -74,7 +75,7 @@ class ConvertDoctrine1SchemaTest extends \Doctrine\Tests\OrmTestCase $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml')); $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml')); - $metadataDriver = new \Doctrine\ORM\Mapping\Driver\YamlDriver(__DIR__ . '/convert'); + $metadataDriver = new YamlDriver(__DIR__ . '/convert'); $em = $this->_createEntityManager($metadataDriver); $cmf = new DisconnectedClassMetadataFactory(); $cmf->setEntityManager($em); diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index 9fdf3b88a..7c09cdf86 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataInfo; @@ -264,9 +265,9 @@ class EntityGeneratorTest extends OrmTestCase $comment = new EntityGeneratorComment(); $this->assertInstanceOf($metadata->name, $book->addComment($comment)); $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $book->getComments()); - $this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array($comment)), $book->getComments()); + $this->assertEquals(new ArrayCollection(array($comment)), $book->getComments()); $this->assertInternalType('boolean', $book->removeComment($comment)); - $this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array()), $book->getComments()); + $this->assertEquals(new ArrayCollection(array()), $book->getComments()); $this->newInstance($isbnMetadata); $isbn = new $isbnMetadata->name(); diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php index 02d6ed5a1..8a4b6ad5f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php @@ -5,8 +5,9 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\ORM\Tools\EntityGenerator; use Doctrine\ORM\Tools\EntityRepositoryGenerator; use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\Tests\OrmTestCase; -class EntityRepositoryGeneratorTest extends \Doctrine\Tests\OrmTestCase +class EntityRepositoryGeneratorTest extends OrmTestCase { /** * @var EntityGenerator diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php index 0743a89d6..d712730ff 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php @@ -21,17 +21,19 @@ namespace Doctrine\Tests\ORM\Tools\Export; +use Doctrine\ORM\Configuration; use Doctrine\ORM\Tools\Export\ClassMetadataExporter; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Tools\EntityGenerator; use Doctrine\Tests\Mocks\MetadataDriverMock; -use Doctrine\Tests\Mocks\DatabasePlatformMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Common\EventManager; use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\Tests\OrmTestCase; +use Symfony\Component\Yaml\Parser; /** * Test case for ClassMetadataExporter @@ -43,7 +45,7 @@ use Doctrine\ORM\Mapping\ClassMetadataFactory; * @since 2.0 * @version $Revision$ */ -abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTestCase +abstract class AbstractClassMetadataExporterTest extends OrmTestCase { protected $_extension; @@ -52,12 +54,11 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest protected function _createEntityManager($metadataDriver) { $driverMock = new DriverMock(); - $config = new \Doctrine\ORM\Configuration(); + $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../../Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies'); $eventManager = new EventManager(); $conn = new ConnectionMock(array(), $driverMock, $config, $eventManager); - $mockDriver = new MetadataDriverMock(); $config->setMetadataDriverImpl($metadataDriver); return EntityManagerMock::create($conn, $config, $eventManager); @@ -376,7 +377,7 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest $this->assertEquals('cascade-all', $nodes[0]->getName()); } else if ($type == 'yaml') { - $yaml = new \Symfony\Component\Yaml\Parser(); + $yaml = new Parser(); $value = $yaml->parse(file_get_contents(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.yml')); $this->assertTrue(isset($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'])); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php index a9bb02da4..f6c63f752 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php @@ -14,7 +14,7 @@ class CountOutputWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, c1_.id AS id_1, a2_.id AS id_2, a2_.name AS name_3, b0_.author_id AS author_id_4, b0_.category_id AS category_id_5 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id) dctrn_result) dctrn_table", $query->getSql() + "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, c1_.id AS id_1, a2_.id AS id_2, a2_.name AS name_3, b0_.author_id AS author_id_4, b0_.category_id AS category_id_5 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id) dctrn_result) dctrn_table", $query->getSQL() ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index e44248926..b8d1b41a6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -19,7 +19,7 @@ class CountWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSql() + "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSQL() ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 897e3531e..b30ef51fc 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Tests\ORM\Tools\Pagination; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; -use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\ORM\Query; class LimitSubqueryOutputWalkerTest extends PaginationTestCase @@ -19,7 +18,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $this->assertEquals( - "SELECT DISTINCT id_0 FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, m0_.author_id AS author_id_5, m0_.category_id AS category_id_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result", $limitQuery->getSql() + "SELECT DISTINCT id_0 FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, m0_.author_id AS author_id_5, m0_.category_id AS category_id_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result", $limitQuery->getSQL() ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php index 597ec1350..fb11feb7a 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php @@ -19,7 +19,7 @@ class LimitSubqueryWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id", - $limitQuery->getSql() + $limitQuery->getSQL() ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php index 41152dc5d..5f9a3430f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -20,7 +20,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?)", $whereInQuery->getSql() + "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE u0_.id IN (?)", $whereInQuery->getSQL() ); } diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index 2934693f8..28753078d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -5,8 +5,9 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Tools\ResolveTargetEntityListener; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmTestCase; -class ResolveTargetEntityListenerTest extends \Doctrine\Tests\OrmTestCase +class ResolveTargetEntityListenerTest extends OrmTestCase { /** * @var \Doctrine\ORM\EntityManager diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index fd2cd20f7..bc54744b9 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -6,8 +6,9 @@ use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\ToolEvents; use Doctrine\ORM\Tools\Event\GenerateSchemaTableEventArgs; use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; +use Doctrine\Tests\OrmTestCase; -class SchemaToolTest extends \Doctrine\Tests\OrmTestCase +class SchemaToolTest extends OrmTestCase { public function testAddUniqueIndexForUniqueFieldAnnotation() { diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 57305818b..a17d92e7f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -2,9 +2,11 @@ namespace Doctrine\Tests\ORM\Tools; +use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\SchemaValidator; +use Doctrine\Tests\OrmTestCase; -class SchemaValidatorTest extends \Doctrine\Tests\OrmTestCase +class SchemaValidatorTest extends OrmTestCase { /** * @var EntityManager diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index 20ad5ee0a..407baab3e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -4,15 +4,17 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\ORM\Tools\Setup; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\ORM\Version; +use Doctrine\Tests\OrmTestCase; -class SetupTest extends \Doctrine\Tests\OrmTestCase +class SetupTest extends OrmTestCase { private $originalAutoloaderCount; private $originalIncludePath; public function setUp() { - if (strpos(\Doctrine\ORM\Version::VERSION, "DEV") === false) { + if (strpos(Version::VERSION, "DEV") === false) { $this->markTestSkipped("Test only runs in a dev-installation from Github"); } diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index d855c7817..eb8bf3a5c 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -12,14 +12,16 @@ use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\EntityPersisterMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\Forum\ForumAvatar; use Doctrine\Tests\Models\Forum\ForumUser; +use Doctrine\Tests\OrmTestCase; use stdClass; /** * UnitOfWork tests. */ -class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase +class UnitOfWorkTest extends OrmTestCase { /** * SUT @@ -198,7 +200,7 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber')); $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\CMS\CmsPhonenumber', $persister); - $ph = new \Doctrine\Tests\Models\CMS\CmsPhonenumber(); + $ph = new CmsPhonenumber(); $ph->phonenumber = '12345'; $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($ph)); @@ -210,7 +212,7 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase $this->_unitOfWork->registerManaged($ph, array('phonenumber' => '12345'), array()); $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_unitOfWork->getEntityState($ph)); $this->assertFalse($persister->isExistsCalled()); - $ph2 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber(); + $ph2 = new CmsPhonenumber(); $ph2->phonenumber = '12345'; $this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); $this->assertFalse($persister->isExistsCalled()); diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index d40b31082..a03031a16 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -2,7 +2,15 @@ namespace Doctrine\Tests; +use Doctrine\Common\Cache\ArrayCache; +use Doctrine\DBAL\Driver\PDOSqlite\Driver as SqliteDriver; +use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Cache\CacheConfiguration; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Tools\DebugUnitOfWorkListener; +use Doctrine\ORM\Tools\SchemaTool; use Doctrine\Tests\EventListener\CacheMetadataListener; use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger; use Doctrine\ORM\Cache\DefaultCacheFactory; @@ -599,7 +607,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase if ( ! isset(static::$_sharedConn)) { static::$_sharedConn = TestUtil::getConnection(); - if (static::$_sharedConn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) { + if (static::$_sharedConn->getDriver() instanceof SqliteDriver) { $forceCreateTables = true; } } @@ -614,7 +622,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase if ( ! $this->_em) { $this->_em = $this->_getEntityManager(); - $this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em); + $this->_schemaTool = new SchemaTool($this->_em); } $classes = array(); @@ -652,20 +660,20 @@ abstract class OrmFunctionalTestCase extends OrmTestCase if (isset($GLOBALS['DOCTRINE_CACHE_IMPL'])) { self::$_metadataCacheImpl = new $GLOBALS['DOCTRINE_CACHE_IMPL']; } else { - self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + self::$_metadataCacheImpl = new ArrayCache(); } } if (is_null(self::$_queryCacheImpl)) { - self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + self::$_queryCacheImpl = new ArrayCache(); } - $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); + $this->_sqlLoggerStack = new DebugStack(); $this->_sqlLoggerStack->enabled = false; //FIXME: two different configs! $conn and the created entity manager have // different configs. - $config = new \Doctrine\ORM\Configuration(); + $config = new Configuration(); $config->setMetadataCacheImpl(self::$_metadataCacheImpl); $config->setQueryCacheImpl(self::$_queryCacheImpl); $config->setProxyDir(__DIR__ . '/Proxies'); @@ -675,7 +683,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase if ($this->isSecondLevelCacheEnabled || $enableSecondLevelCache) { - $cacheConfig = new \Doctrine\ORM\Cache\CacheConfiguration(); + $cacheConfig = new CacheConfiguration(); $cache = $this->getSharedSecondLevelCacheDriverImpl(); $factory = new DefaultCacheFactory($cacheConfig->getRegionsConfiguration(), $cache); @@ -721,10 +729,10 @@ abstract class OrmFunctionalTestCase extends OrmTestCase } if (isset($GLOBALS['debug_uow_listener'])) { - $evm->addEventListener(array('onFlush'), new \Doctrine\ORM\Tools\DebugUnitOfWorkListener()); + $evm->addEventListener(array('onFlush'), new DebugUnitOfWorkListener()); } - return \Doctrine\ORM\EntityManager::create($conn, $config); + return EntityManager::create($conn, $config); } /** diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index 7cc9c0580..200f53450 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -5,7 +5,12 @@ namespace Doctrine\Tests; use Doctrine\Common\Annotations; use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Version; +use Doctrine\DBAL\DriverManager; +use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\DefaultCacheFactory; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\Mapping\Driver\AnnotationDriver; +use Doctrine\Tests\Mocks\EntityManagerMock; /** * Base testcase class for all ORM testcases. @@ -93,7 +98,7 @@ abstract class OrmTestCase extends DoctrineTestCase Annotations\AnnotationRegistry::registerFile(__DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); - return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths); + return new AnnotationDriver($reader, (array) $paths); } /** @@ -117,7 +122,7 @@ abstract class OrmTestCase extends DoctrineTestCase ? self::getSharedMetadataCacheImpl() : new ArrayCache(); - $config = new \Doctrine\ORM\Configuration(); + $config = new Configuration(); $config->setMetadataCacheImpl($metadataCache); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true)); @@ -130,7 +135,7 @@ abstract class OrmTestCase extends DoctrineTestCase if ($this->isSecondLevelCacheEnabled) { - $cacheConfig = new \Doctrine\ORM\Cache\CacheConfiguration(); + $cacheConfig = new CacheConfiguration(); $cache = $this->getSharedSecondLevelCacheDriverImpl(); $factory = new DefaultCacheFactory($cacheConfig->getRegionsConfiguration(), $cache); @@ -151,10 +156,10 @@ abstract class OrmTestCase extends DoctrineTestCase } if (is_array($conn)) { - $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager); + $conn = DriverManager::getConnection($conn, $config, $eventManager); } - return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager); + return EntityManagerMock::create($conn, $config, $eventManager); } protected function enableSecondLevelCache($log = true) From b173763bbb9b55d9de33e6ae8d22eb222b36d5b5 Mon Sep 17 00:00:00 2001 From: Mikhail Shamin Date: Wed, 11 May 2016 02:41:26 +0700 Subject: [PATCH 006/144] Remove full qualified class names in tests --- .../EventListener/CacheMetadataListener.php | 4 +- .../Tests/Models/DDC2504/DDC2504RootClass.php | 2 +- .../Tests/Models/DDC3293/DDC3293User.php | 2 +- .../Models/DDC3293/DDC3293UserPrefixed.php | 2 +- .../AbstractManyToManyAssociationTestCase.php | 3 +- .../Functional/AdvancedAssociationTest.php | 12 +++-- .../ORM/Functional/AdvancedDqlQueryTest.php | 3 +- .../ORM/Functional/BasicFunctionalTest.php | 43 ++++++++------- .../ORM/Functional/CascadeRemoveOrderTest.php | 3 +- .../Functional/ClassTableInheritanceTest.php | 8 +-- .../Functional/ClassTableInheritanceTest2.php | 21 +++++--- .../Tests/ORM/Functional/ClearEventTest.php | 7 +-- .../Functional/CompositePrimaryKeyTest.php | 3 +- ...ompositePrimaryKeyWithAssociationsTest.php | 3 +- .../ORM/Functional/DatabaseDriverTest.php | 19 +++---- .../ORM/Functional/DatabaseDriverTestCase.php | 5 +- .../ORM/Functional/DefaultValuesTest.php | 6 ++- .../ORM/Functional/DetachedEntityTest.php | 6 ++- .../ORM/Functional/EntityListenersTest.php | 3 +- .../EntityRepositoryCriteriaTest.php | 3 +- .../ORM/Functional/EntityRepositoryTest.php | 18 ++++--- .../Functional/ExtraLazyCollectionTest.php | 52 ++++++++++--------- .../Tests/ORM/Functional/FlushEventTest.php | 6 ++- .../Tests/ORM/Functional/IdentityMapTest.php | 14 ++--- .../ORM/Functional/IndexByAssociationTest.php | 5 +- .../ORM/Functional/LifecycleCallbackTest.php | 28 ++++++---- .../Functional/Locking/LockAgentWorker.php | 13 +++-- .../Tests/ORM/Functional/Locking/LockTest.php | 26 ++++++---- .../ManyToManyBasicAssociationTest.php | 8 +-- .../ORM/Functional/ManyToManyEventTest.php | 3 +- .../ORM/Functional/MappedSuperclassTest.php | 11 ++-- .../Functional/MergeCompositeToOneKeyTest.php | 3 +- .../Tests/ORM/Functional/NativeQueryTest.php | 8 +-- .../Tests/ORM/Functional/NewOperatorTest.php | 3 +- .../Tests/ORM/Functional/NotifyPolicyTest.php | 13 +++-- .../OneToManyBidirectionalAssociationTest.php | 3 +- .../Functional/OneToManyOrphanRemovalTest.php | 3 +- ...neToManySelfReferentialAssociationTest.php | 3 +- ...OneToManyUnidirectionalAssociationTest.php | 3 +- .../OneToOneBidirectionalAssociationTest.php | 5 +- .../Functional/OneToOneEagerLoadingTest.php | 9 ++-- .../Functional/OneToOneOrphanRemovalTest.php | 3 +- ...OneToOneSelfReferentialAssociationTest.php | 3 +- .../OneToOneUnidirectionalAssociationTest.php | 3 +- .../ORM/Functional/OrderedCollectionTest.php | 3 +- ...edJoinedTableInheritanceCollectionTest.php | 6 ++- .../Tests/ORM/Functional/PaginationTest.php | 3 +- .../PersistentCollectionCriteriaTest.php | 3 +- .../Functional/PersistentCollectionTest.php | 6 ++- .../ORM/Functional/PersistentObjectTest.php | 3 +- .../ORM/Functional/PostFlushEventTest.php | 3 +- .../ORM/Functional/PostLoadEventTest.php | 3 +- .../Tests/ORM/Functional/QueryCacheTest.php | 3 +- .../ORM/Functional/QueryDqlFunctionTest.php | 3 +- .../Tests/ORM/Functional/QueryTest.php | 10 ++-- .../Tests/ORM/Functional/ReadOnlyTest.php | 3 +- .../ORM/Functional/ReferenceProxyTest.php | 8 +-- .../Tests/ORM/Functional/ResultCacheTest.php | 9 ++-- .../Tests/ORM/Functional/SQLFilterTest.php | 14 ++--- .../SchemaTool/CompanySchemaTest.php | 3 +- .../ORM/Functional/SchemaTool/DBAL483Test.php | 3 +- .../ORM/Functional/SchemaTool/DDC214Test.php | 6 ++- .../SchemaTool/PostgreSqlSchemaToolTest.php | 3 +- .../ORM/Functional/SchemaValidatorTest.php | 3 +- .../SecondLevelCacheConcurrentTest.php | 6 ++- .../SecondLevelCacheQueryCacheTest.php | 3 +- .../SequenceEmulatedIdentityStrategyTest.php | 3 +- .../ORM/Functional/SequenceGeneratorTest.php | 3 +- .../Functional/SingleTableInheritanceTest.php | 27 ++++++---- .../StandardEntityPersisterTest.php | 5 +- .../ORM/Functional/Ticket/DDC1050Test.php | 2 +- .../ORM/Functional/Ticket/DDC1080Test.php | 2 +- .../ORM/Functional/Ticket/DDC1643Test.php | 2 +- .../ORM/Functional/Ticket/DDC1707Test.php | 8 +-- .../ORM/Functional/Ticket/DDC1778Test.php | 4 +- .../ORM/Functional/Ticket/DDC331Test.php | 2 +- .../ORM/Functional/Ticket/DDC656Test.php | 4 +- .../ORM/Functional/Ticket/DDC758Test.php | 2 +- .../Tests/ORM/Functional/TypeTest.php | 3 +- .../Tests/ORM/Functional/TypeValueSqlTest.php | 3 +- .../ORM/Functional/UUIDGeneratorTest.php | 3 +- .../Functional/UnitOfWorkLifecycleTest.php | 3 +- .../Tests/ORM/Functional/ValueObjectsTest.php | 3 +- .../ORM/Functional/VersionedOneToOneTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/ExprTest.php | 26 +++++----- .../ORM/Query/LanguageRecognitionTest.php | 2 +- tests/Doctrine/Tests/ORM/Query/QueryTest.php | 4 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 10 ++-- .../GenerateRepositoriesCommandTest.php | 2 +- .../Tools/EntityRepositoryGeneratorTest.php | 2 +- .../Pagination/CountOutputWalkerTest.php | 6 +-- .../ORM/Tools/Pagination/CountWalkerTest.php | 12 ++--- .../LimitSubqueryOutputWalkerTest.php | 22 ++++---- .../Pagination/LimitSubqueryWalkerTest.php | 10 ++-- .../Tools/Pagination/WhereInWalkerTest.php | 18 +++---- 95 files changed, 417 insertions(+), 290 deletions(-) diff --git a/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php b/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php index 7a7caf18e..f27e38c47 100644 --- a/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php +++ b/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php @@ -40,7 +40,7 @@ class CacheMetadataListener * * @return bool */ - private function isVisited(ClassMetaData $metadata) + private function isVisited(ClassMetadata $metadata) { return isset($this->enabledItems[$metadata->getName()]); } @@ -48,7 +48,7 @@ class CacheMetadataListener /** * @param ClassMetadata $metadata */ - private function recordVisit(ClassMetaData $metadata) + private function recordVisit(ClassMetadata $metadata) { $this->enabledItems[$metadata->getName()] = true; } diff --git a/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php b/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php index 18edd75a3..22828b016 100644 --- a/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php +++ b/tests/Doctrine/Tests/Models/DDC2504/DDC2504RootClass.php @@ -20,7 +20,7 @@ class DDC2504RootClass public $id; /** - * @var Doctrine\Tests\Models\DDC\DDC2504OtherClass + * @var \Doctrine\Tests\Models\DDC2504\DDC2504OtherClass * * @ManyToOne(targetEntity="DDC2504OtherClass", inversedBy="childClasses") */ diff --git a/tests/Doctrine/Tests/Models/DDC3293/DDC3293User.php b/tests/Doctrine/Tests/Models/DDC3293/DDC3293User.php index 25ed140ea..4df5f9b68 100644 --- a/tests/Doctrine/Tests/Models/DDC3293/DDC3293User.php +++ b/tests/Doctrine/Tests/Models/DDC3293/DDC3293User.php @@ -10,7 +10,7 @@ class DDC3293User protected $id; /** - * @var Doctrine\Tests\Models\DDC3293\DDC3293Address + * @var \Doctrine\Tests\Models\DDC3293\DDC3293Address */ protected $address; } diff --git a/tests/Doctrine/Tests/Models/DDC3293/DDC3293UserPrefixed.php b/tests/Doctrine/Tests/Models/DDC3293/DDC3293UserPrefixed.php index a70b26756..d83da15af 100644 --- a/tests/Doctrine/Tests/Models/DDC3293/DDC3293UserPrefixed.php +++ b/tests/Doctrine/Tests/Models/DDC3293/DDC3293UserPrefixed.php @@ -10,7 +10,7 @@ class DDC3293UserPrefixed protected $id; /** - * @var Doctrine\Tests\Models\DDC3293\DDC3293Address + * @var \Doctrine\Tests\Models\DDC3293\DDC3293Address */ protected $address; } diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php index d6dd12e8b..37f0fcd29 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\Collection; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Base class for testing a many-to-many association mapping (without inheritance). */ -class AbstractManyToManyAssociationTestCase extends \Doctrine\Tests\OrmFunctionalTestCase +class AbstractManyToManyAssociationTestCase extends OrmFunctionalTestCase { protected $_firstField; protected $_secondField; diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php index 6847d01c3..5546b285e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -2,14 +2,16 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Query; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Functional tests for the Single Table Inheritance mapping strategy. * * @author robo */ -class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class AdvancedAssociationTest extends OrmFunctionalTestCase { protected function setUp() { parent::setUp(); @@ -151,7 +153,7 @@ class Lemma { private $types; public function __construct() { - $this->types = new \Doctrine\Common\Collections\ArrayCollection(); + $this->types = new ArrayCollection(); } @@ -257,7 +259,7 @@ class Type { private $lemmas; public function __construct(){ - $this->lemmas = new \Doctrine\Common\Collections\ArrayCollection(); + $this->lemmas = new ArrayCollection(); } /** @@ -372,7 +374,7 @@ class Phrase { private $definitions; public function __construct() { - $this->definitions = new \Doctrine\Common\Collections\ArrayCollection; + $this->definitions = new ArrayCollection; } /** @@ -464,7 +466,7 @@ class PhraseType { private $phrases; public function __construct() { - $this->phrases = new \Doctrine\Common\Collections\ArrayCollection; + $this->phrases = new ArrayCollection; } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php index 67038a781..a7c35412b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php @@ -5,13 +5,14 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\Company\CompanyEmployee, Doctrine\Tests\Models\Company\CompanyManager, Doctrine\Tests\Models\Company\CompanyCar; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Functional Query tests. * * @author Benjamin */ -class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase +class AdvancedDqlQueryTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 42a75be14..2046d59a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -2,14 +2,19 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\DBAL\Logging\DebugStack; +use Doctrine\ORM\EntityNotFoundException; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; +use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsComment; +use Doctrine\Tests\OrmFunctionalTestCase; -class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase +class BasicFunctionalTest extends OrmFunctionalTestCase { protected function setUp() { @@ -65,9 +70,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($user)); $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph2)); + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user)); + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph)); + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($ph2)); } public function testOneToManyAssociationModification() @@ -146,15 +151,15 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $user->username = 'gblanco'; $user->status = 'developer'; - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); $this->_em->persist($user); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_MANAGED"); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_MANAGED"); $this->_em->remove($user); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); $this->_em->persist($user); $this->_em->flush(); @@ -162,10 +167,10 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->remove($user); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_REMOVED, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_REMOVED"); + $this->assertEquals(UnitOfWork::STATE_REMOVED, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_REMOVED"); $this->_em->flush(); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_em->getUnitOfWork()->getEntityState($user), "State should be UnitOfWork::STATE_NEW"); $this->assertNull($this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $id)); } @@ -565,7 +570,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->persist($user); - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article = new CmsArticle(); $article->text = "Lorem ipsum dolor sunt."; $article->topic = "A Test Article!"; $article->setAuthor($user); @@ -608,7 +613,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $address->user = $user; $user->address = $address; - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article = new CmsArticle(); $article->text = "Lorem ipsum dolor sunt."; $article->topic = "A Test Article!"; $article->setAuthor($user); @@ -628,7 +633,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address); $oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); - $debugStack = new \Doctrine\DBAL\Logging\DebugStack; + $debugStack = new DebugStack(); $this->_em->getConnection()->getConfiguration()->setSQLLogger($debugStack); $this->_em->flush(); @@ -938,7 +943,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase try { $this->_em->merge($user); $this->fail(); - } catch (\Doctrine\ORM\EntityNotFoundException $enfe) {} + } catch (EntityNotFoundException $enfe) {} } /** @@ -995,7 +1000,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.id = ?1"; $article = $this->_em->createQuery($dql) ->setParameter(1, $article->id) - ->setFetchMode('Doctrine\Tests\Models\CMS\CmsArticle', 'user', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER) + ->setFetchMode('Doctrine\Tests\Models\CMS\CmsArticle', 'user', ClassMetadata::FETCH_EAGER) ->getSingleResult(); $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $article->user, "It IS a proxy, ..."); $this->assertTrue($article->user->__isInitialized__, "...but its initialized!"); @@ -1041,14 +1046,14 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->clear('Doctrine\Tests\Models\CMS\CmsUser'); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article2)); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); + $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); + $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article1)); + $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($article2)); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); $this->_em->clear(); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); + $this->assertEquals(UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); } public function testFlushManyExplicitEntities() diff --git a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php index 9fd1648e0..a2392a3e8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CascadeRemoveOrderTest.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group CascadeRemoveOrderTest */ -class CascadeRemoveOrderTest extends \Doctrine\Tests\OrmFunctionalTestCase +class CascadeRemoveOrderTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index f8dd3b7a5..697f568ff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -10,15 +10,17 @@ use Doctrine\Tests\Models\Company\CompanyPerson, Doctrine\Tests\Models\Company\CompanyRaffle; use Doctrine\Common\Collections\Criteria; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Functional tests for the Class Table Inheritance mapping strategy. * * @author robo */ -class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase +class ClassTableInheritanceTest extends OrmFunctionalTestCase { - protected function setUp() { + protected function setUp() + { $this->useModelSet('company'); parent::setUp(); //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); @@ -80,7 +82,7 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase $query->setParameter(1, 'NewName', 'string'); $query->setParameter(2, 'NewDepartment'); $query->setParameter(3, 100000); - $query->getSql(); + $query->getSQL(); $numUpdated = $query->execute(); $this->assertEquals(1, $numUpdated); diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php index 9c50a1496..5682bffe1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php @@ -1,15 +1,18 @@ _schemaTool->createSchema(array( @@ -156,19 +159,23 @@ class CTIRelated2 private $ctiChildren; - public function __construct() { - $this->ctiChildren = new \Doctrine\Common\Collections\ArrayCollection; + public function __construct() + { + $this->ctiChildren = new ArrayCollection(); } - public function getId() { + public function getId() + { return $this->id; } - public function addCTIChild(CTIChild $child) { + public function addCTIChild(CTIChild $child) + { $this->ctiChildren->add($child); } - public function getCTIChildren() { + public function getCTIChildren() + { return $this->ctiChildren; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php index 389b09a54..8c234c0f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php @@ -4,18 +4,15 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Event\OnClearEventArgs; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmFunctionalTestCase; /** * ClearEventTest * * @author Michael Ridgway */ -class ClearEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +class ClearEventTest extends OrmFunctionalTestCase { - protected function setUp() { - parent::setUp(); - } - public function testEventIsCalledOnClear() { $listener = new OnClearListener; diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index 2e1cedb39..835328d75 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -6,8 +6,9 @@ use Doctrine\Tests\Models\Navigation\NavPointOfInterest; use Doctrine\Tests\Models\Navigation\NavTour; use Doctrine\Tests\Models\Navigation\NavPhotos; use Doctrine\Tests\Models\Navigation\NavUser; +use Doctrine\Tests\OrmFunctionalTestCase; -class CompositePrimaryKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase +class CompositePrimaryKeyTest extends OrmFunctionalTestCase { public function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php index 6ded5bb49..b735925e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php @@ -5,8 +5,9 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\GeoNames\Country; use Doctrine\Tests\Models\GeoNames\Admin1; use Doctrine\Tests\Models\GeoNames\Admin1AlternateName; +use Doctrine\Tests\OrmFunctionalTestCase; -class CompositePrimaryKeyWithAssociationsTest extends \Doctrine\Tests\OrmFunctionalTestCase +class CompositePrimaryKeyWithAssociationsTest extends OrmFunctionalTestCase { public function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index 29d718560..37149abfd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Platforms\SQLServerPlatform; +use Doctrine\DBAL\Schema\Table; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; @@ -30,10 +31,10 @@ class DatabaseDriverTest extends DatabaseDriverTestCase $this->markTestSkipped('Platform does not support foreign keys.'); } - $user = new \Doctrine\DBAL\Schema\Table("ddc2059_user"); + $user = new Table("ddc2059_user"); $user->addColumn('id', 'integer'); $user->setPrimaryKey(array('id')); - $project = new \Doctrine\DBAL\Schema\Table("ddc2059_project"); + $project = new Table("ddc2059_project"); $project->addColumn('id', 'integer'); $project->addColumn('user_id', 'integer'); $project->addColumn('user', 'string'); @@ -52,7 +53,7 @@ class DatabaseDriverTest extends DatabaseDriverTestCase $this->markTestSkipped('Platform does not support foreign keys.'); } - $table = new \Doctrine\DBAL\Schema\Table("dbdriver_foo"); + $table = new Table("dbdriver_foo"); $table->addColumn('id', 'integer'); $table->setPrimaryKey(array('id')); $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 200)); @@ -83,13 +84,13 @@ class DatabaseDriverTest extends DatabaseDriverTestCase $this->markTestSkipped('Platform does not support foreign keys.'); } - $tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar"); + $tableB = new Table("dbdriver_bar"); $tableB->addColumn('id', 'integer'); $tableB->setPrimaryKey(array('id')); $this->_sm->dropAndCreateTable($tableB); - $tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz"); + $tableA = new Table("dbdriver_baz"); $tableA->addColumn('id', 'integer'); $tableA->setPrimaryKey(array('id')); $tableA->addColumn('bar_id', 'integer'); @@ -133,15 +134,15 @@ class DatabaseDriverTest extends DatabaseDriverTestCase public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails() { - $tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar"); + $tableB = new Table("dbdriver_bar"); $tableB->addColumn('id', 'integer'); $tableB->setPrimaryKey(array('id')); - $tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz"); + $tableA = new Table("dbdriver_baz"); $tableA->addColumn('id', 'integer'); $tableA->setPrimaryKey(array('id')); - $tableMany = new \Doctrine\DBAL\Schema\Table("dbdriver_bar_baz"); + $tableMany = new Table("dbdriver_bar_baz"); $tableMany->addColumn('bar_id', 'integer'); $tableMany->addColumn('baz_id', 'integer'); $tableMany->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id')); @@ -157,7 +158,7 @@ class DatabaseDriverTest extends DatabaseDriverTestCase $this->markTestSkipped('Platform does not support foreign keys.'); } - $table = new \Doctrine\DBAL\Schema\Table("dbdriver_foo"); + $table = new Table("dbdriver_foo"); $table->addColumn('id', 'integer', array('unsigned' => true)); $table->setPrimaryKey(array('id')); diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php index 35fd8b20c..03902c40c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTestCase.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Mapping\Driver\DatabaseDriver; use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\ORM\Mapping\ClassMetadataInfo; @@ -13,7 +14,7 @@ abstract class DatabaseDriverTestCase extends OrmFunctionalTestCase protected function convertToClassMetadata(array $entityTables, array $manyTables = array()) { $sm = $this->_em->getConnection()->getSchemaManager(); - $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($sm); + $driver = new DatabaseDriver($sm); $driver->setTables($entityTables, $manyTables); $metadatas = array(); @@ -36,7 +37,7 @@ abstract class DatabaseDriverTestCase extends OrmFunctionalTestCase $metadatas = array(); $sm = $this->_em->getConnection()->getSchemaManager(); - $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($sm); + $driver = new DatabaseDriver($sm); foreach ($driver->getAllClassNames() as $className) { if (!in_array(strtolower($className), $classNames)) { diff --git a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php index b1f7cda9c..e81bd7f8a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -1,15 +1,17 @@ _schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index bc6c0cdd7..c78d25859 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -6,15 +6,17 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Description of DetachedEntityTest * * @author robo */ -class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase +class DetachedEntityTest extends OrmFunctionalTestCase { - protected function setUp() { + protected function setUp() + { $this->useModelSet('cms'); parent::setUp(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php index 584795263..89901be19 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityListenersTest.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\Company\CompanyFixContract; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-1955 */ -class EntityListenersTest extends \Doctrine\Tests\OrmFunctionalTestCase +class EntityListenersTest extends OrmFunctionalTestCase { /** diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php index 6a626b3f4..45f552d59 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php @@ -23,11 +23,12 @@ use Doctrine\Tests\Models\Generic\DateTimeModel; use Doctrine\Common\Collections\Criteria; use Doctrine\Tests\Models\Tweet\Tweet; use Doctrine\Tests\Models\Tweet\User; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @author Josiah */ -class EntityRepositoryCriteriaTest extends \Doctrine\Tests\OrmFunctionalTestCase +class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 8e20d570a..685478f35 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -2,18 +2,22 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\LockMode; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @author robo */ -class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase +class EntityRepositoryTest extends OrmFunctionalTestCase { - protected function setUp() { + protected function setUp() + { $this->useModelSet('cms'); parent::setUp(); } @@ -290,7 +294,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ); + ->find(1, LockMode::PESSIMISTIC_READ); } /** @@ -302,7 +306,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE); + ->find(1, LockMode::PESSIMISTIC_WRITE); } /** @@ -314,7 +318,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') - ->find(1, \Doctrine\DBAL\LockMode::OPTIMISTIC); + ->find(1, LockMode::OPTIMISTIC); } /** @@ -335,7 +339,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); - $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId, \Doctrine\DBAL\LockMode::OPTIMISTIC); + $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId, LockMode::OPTIMISTIC); } /** @@ -670,7 +674,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase $query = array_pop($this->_sqlLoggerStack->queries); $this->assertEquals(array(1,2,3), $query['params'][0]); - $this->assertEquals(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY, $query['types'][0]); + $this->assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php index 731a0826d..c8af5bd85 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -3,6 +3,10 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsGroup; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\DDC2504\DDC2504ChildClass; use Doctrine\Tests\Models\DDC2504\DDC2504OtherClass; use Doctrine\Tests\Models\Tweet\Tweet; @@ -99,7 +103,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase { $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $newGroup = new CmsGroup(); $newGroup->name = "Test4"; $user->addGroup($newGroup); @@ -277,7 +281,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); // Test One to Many existence with state new - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article = new CmsArticle(); $article->topic = "Testnew"; $article->text = "blub"; @@ -295,7 +299,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); // Test One to Many existence with state managed - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article = new CmsArticle(); $article->topic = "How to not fail anymore on tests"; $article->text = "That is simple! Just write more tests!"; @@ -414,7 +418,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); // Test Many to Many existence with state new - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group = new CmsGroup(); $group->name = "A New group!"; $queryCount = $this->getCurrentQueryCount(); @@ -434,7 +438,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); // Test Many to Many existence with state managed - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group = new CmsGroup(); $group->name = "My managed group"; $this->_em->persist($group); @@ -461,7 +465,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertEquals($queryCount+1, $this->getCurrentQueryCount(), "Checking for contains of managed entity should cause one query to be executed."); $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - $newUser = new \Doctrine\Tests\Models\CMS\CmsUser(); + $newUser = new CmsUser(); $newUser->name = "A New group!"; $queryCount = $this->getCurrentQueryCount(); @@ -488,7 +492,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertEquals($queryCount, $this->getCurrentQueryCount()); // Test One to Many removal with Entity state as new - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article = new CmsArticle(); $article->topic = "Testnew"; $article->text = "blub"; @@ -510,7 +514,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); // Test One to Many removal with Entity state as managed - $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article = new CmsArticle(); $article->topic = "How to not fail anymore on tests"; $article->text = "That is simple! Just write more tests!"; @@ -642,7 +646,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); // Test Many to Many removal with Entity state as new - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group = new CmsGroup(); $group->name = "A New group!"; $queryCount = $this->getCurrentQueryCount(); @@ -664,7 +668,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); // Test Many to Many removal with Entity state as managed - $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group = new CmsGroup(); $group->name = "A New group!"; $this->_em->persist($group); @@ -693,7 +697,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a managed entity should cause one query to be executed."); $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); - $newUser = new \Doctrine\Tests\Models\CMS\CmsUser(); + $newUser = new CmsUser(); $newUser->name = "A New group!"; $queryCount = $this->getCurrentQueryCount(); @@ -711,7 +715,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase { $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $newGroup = new CmsGroup(); $newGroup->name = "Test4"; $user->addGroup($newGroup); @@ -735,7 +739,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); /* @var $user CmsUser */ - $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $newGroup = new CmsGroup(); $newGroup->name = "Test4"; $user->addGroup($newGroup); @@ -947,22 +951,22 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase private function loadFixture() { - $user1 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user1 = new CmsUser(); $user1->username = "beberlei"; $user1->name = "Benjamin"; $user1->status = "active"; - $user2 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user2 = new CmsUser(); $user2->username = "jwage"; $user2->name = "Jonathan"; $user2->status = "active"; - $user3 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user3 = new CmsUser(); $user3->username = "romanb"; $user3->name = "Roman"; $user3->status = "active"; - $user4 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user4 = new CmsUser(); $user4->username = "gblanco"; $user4->name = "Guilherme"; $user4->status = "active"; @@ -972,13 +976,13 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->_em->persist($user3); $this->_em->persist($user4); - $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group1 = new CmsGroup(); $group1->name = "Test1"; - $group2 = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group2 = new CmsGroup(); $group2->name = "Test2"; - $group3 = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group3 = new CmsGroup(); $group3->name = "Test3"; $user1->addGroup($group1); @@ -993,12 +997,12 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->_em->persist($group2); $this->_em->persist($group3); - $article1 = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article1 = new CmsArticle(); $article1->topic = "Test1"; $article1->text = "Test1"; $article1->setAuthor($user1); - $article2 = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article2 = new CmsArticle(); $article2->topic = "Test2"; $article2->text = "Test2"; $article2->setAuthor($user1); @@ -1006,10 +1010,10 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase $this->_em->persist($article1); $this->_em->persist($article2); - $phonenumber1 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber(); + $phonenumber1 = new CmsPhonenumber(); $phonenumber1->phonenumber = '12345'; - $phonenumber2 = new \Doctrine\Tests\Models\CMS\CmsPhonenumber(); + $phonenumber2 = new CmsPhonenumber(); $phonenumber2->phonenumber = '67890'; $this->_em->persist($phonenumber1); diff --git a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php index bd3a33002..b9298e3dc 100644 --- a/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -6,15 +6,17 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\ORM\Event\OnFlushEventArgs; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmFunctionalTestCase; /** * FlushEventTest * * @author robo */ -class FlushEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +class FlushEventTest extends OrmFunctionalTestCase { - protected function setUp() { + protected function setUp() + { $this->useModelSet('cms'); parent::setUp(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php index b79f9f3cb..94a11dab4 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -2,10 +2,11 @@ namespace Doctrine\Tests\ORM\Functional; -use Doctrine\Tests\Models\CMS\CmsUser, - Doctrine\Tests\Models\CMS\CmsAddress, - Doctrine\Tests\Models\CMS\CmsPhonenumber, - Doctrine\ORM\Query; +use Doctrine\ORM\Query; +use Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmFunctionalTestCase; /** * IdentityMapTest @@ -15,9 +16,10 @@ use Doctrine\Tests\Models\CMS\CmsUser, * * @author Roman Borschel */ -class IdentityMapTest extends \Doctrine\Tests\OrmFunctionalTestCase +class IdentityMapTest extends OrmFunctionalTestCase { - protected function setUp() { + protected function setUp() + { $this->useModelSet('cms'); parent::setUp(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php index e5a4d1d9e..9dac4155d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php @@ -5,14 +5,15 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\StockExchange\Stock; use Doctrine\Tests\Models\StockExchange\Market; use Doctrine\Tests\Models\StockExchange\Bond; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-250 */ -class IndexByAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class IndexByAssociationTest extends OrmFunctionalTestCase { /** - * @var Doctrine\Tests\Models\StockExchange\Market + * @var Market */ private $market; diff --git a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php index 9b60c43b2..508645927 100644 --- a/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -1,12 +1,18 @@ _schemaTool->createSchema(array( @@ -470,7 +476,7 @@ class LifecycleCallbackCascader public function __construct() { - $this->entities = new \Doctrine\Common\Collections\ArrayCollection(); + $this->entities = new ArrayCollection(); } /** @PostLoad */ @@ -516,7 +522,7 @@ class LifecycleCallbackEventArgEntity /** * @PostPersist */ - public function postPersistHandler(\Doctrine\ORM\Event\LifecycleEventArgs $event) + public function postPersistHandler(LifecycleEventArgs $event) { $this->calls[__FUNCTION__] = $event; } @@ -524,7 +530,7 @@ class LifecycleCallbackEventArgEntity /** * @PrePersist */ - public function prePersistHandler(\Doctrine\ORM\Event\LifecycleEventArgs $event) + public function prePersistHandler(LifecycleEventArgs $event) { $this->calls[__FUNCTION__] = $event; } @@ -532,7 +538,7 @@ class LifecycleCallbackEventArgEntity /** * @PostUpdate */ - public function postUpdateHandler(\Doctrine\ORM\Event\LifecycleEventArgs $event) + public function postUpdateHandler(LifecycleEventArgs $event) { $this->calls[__FUNCTION__] = $event; } @@ -540,7 +546,7 @@ class LifecycleCallbackEventArgEntity /** * @PreUpdate */ - public function preUpdateHandler(\Doctrine\ORM\Event\PreUpdateEventArgs $event) + public function preUpdateHandler(PreUpdateEventArgs $event) { $this->calls[__FUNCTION__] = $event; } @@ -548,7 +554,7 @@ class LifecycleCallbackEventArgEntity /** * @PostRemove */ - public function postRemoveHandler(\Doctrine\ORM\Event\LifecycleEventArgs $event) + public function postRemoveHandler(LifecycleEventArgs $event) { $this->calls[__FUNCTION__] = $event; } @@ -556,7 +562,7 @@ class LifecycleCallbackEventArgEntity /** * @PreRemove */ - public function preRemoveHandler(\Doctrine\ORM\Event\LifecycleEventArgs $event) + public function preRemoveHandler(LifecycleEventArgs $event) { $this->calls[__FUNCTION__] = $event; } @@ -564,7 +570,7 @@ class LifecycleCallbackEventArgEntity /** * @PreFlush */ - public function preFlushHandler(\Doctrine\ORM\Event\PreFlushEventArgs $event) + public function preFlushHandler(PreFlushEventArgs $event) { $this->calls[__FUNCTION__] = $event; } @@ -572,7 +578,7 @@ class LifecycleCallbackEventArgEntity /** * @PostLoad */ - public function postLoadHandler(\Doctrine\ORM\Event\LifecycleEventArgs $event) + public function postLoadHandler(LifecycleEventArgs $event) { $this->calls[__FUNCTION__] = $event; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php index 4cd8dfec0..0ca10460f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php @@ -2,6 +2,11 @@ namespace Doctrine\Tests\ORM\Functional\Locking; +use Doctrine\Common\Cache\ArrayCache; +use Doctrine\DBAL\Logging\EchoSQLLogger; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManager; + class LockAgentWorker { private $em; @@ -88,7 +93,7 @@ class LockAgentWorker protected function createEntityManager($conn) { - $config = new \Doctrine\ORM\Configuration(); + $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../../../Proxies'); $config->setProxyNamespace('MyProject\Proxies'); $config->setAutoGenerateProxyClasses(true); @@ -96,12 +101,12 @@ class LockAgentWorker $annotDriver = $config->newDefaultAnnotationDriver(array(__DIR__ . '/../../../Models/'), true); $config->setMetadataDriverImpl($annotDriver); - $cache = new \Doctrine\Common\Cache\ArrayCache(); + $cache = new ArrayCache(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); - $config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); + $config->setSQLLogger(new EchoSQLLogger()); - $em = \Doctrine\ORM\EntityManager::create($conn, $config); + $em = EntityManager::create($conn, $config); return $em; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index 1face5f31..e3c3b5b5c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -2,15 +2,19 @@ namespace Doctrine\Tests\ORM\Functional\Locking; -use Doctrine\Tests\Models\CMS\CmsArticle, - Doctrine\Tests\Models\CMS\CmsUser, - Doctrine\DBAL\LockMode; +use Doctrine\DBAL\LockMode; +use Doctrine\ORM\Query; +use Doctrine\Tests\Models\CMS\CmsArticle; +use Doctrine\Tests\Models\CMS\CmsUser; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group locking */ -class LockTest extends \Doctrine\Tests\OrmFunctionalTestCase { - protected function setUp() { +class LockTest extends OrmFunctionalTestCase +{ + protected function setUp() + { $this->useModelSet('cms'); parent::setUp(); $this->handles = array(); @@ -111,8 +115,9 @@ class LockTest extends \Doctrine\Tests\OrmFunctionalTestCase { * @group DDC-178 * @group locking */ - public function testLockPessimisticWrite() { - $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSql(); + public function testLockPessimisticWrite() + { + $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSQL(); if (strlen($writeLockSql) == 0) { $this->markTestSkipped('Database Driver has no Write Lock support.'); } @@ -141,8 +146,9 @@ class LockTest extends \Doctrine\Tests\OrmFunctionalTestCase { /** * @group DDC-178 */ - public function testLockPessimisticRead() { - $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSql(); + public function testLockPessimisticRead() + { + $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSQL(); if (strlen($readLockSql) == 0) { $this->markTestSkipped('Database Driver has no Write Lock support.'); } @@ -177,7 +183,7 @@ class LockTest extends \Doctrine\Tests\OrmFunctionalTestCase { $this->setExpectedException('Doctrine\ORM\OptimisticLockException', 'The optimistic lock on an entity failed.'); $sql = $this->_em->createQuery($dql)->setHint( - \Doctrine\ORM\Query::HINT_LOCK_MODE, \Doctrine\DBAL\LockMode::OPTIMISTIC + Query::HINT_LOCK_MODE, LockMode::OPTIMISTIC )->getSQL(); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php index da4d30077..2d051b688 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -3,10 +3,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\Criteria; +use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Models\CMS\CmsTag; use Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsGroup, Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Basic many-to-many association tests. @@ -14,7 +16,7 @@ use Doctrine\Tests\Models\CMS\CmsUser, * * @author robo */ -class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase { protected function setUp() { @@ -53,8 +55,8 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa $groups = $result[0]->getGroups(); $this->assertEquals('Developers_0', $groups[0]->getName()); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); - $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0])); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0])); $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups); $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups[0]->getUsers()); diff --git a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php index 105ba095c..87283ec4b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php @@ -5,13 +5,14 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmFunctionalTestCase; /** * ManyToManyEventTest * * @author Francisco Facioni */ -class ManyToManyEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +class ManyToManyEventTest extends OrmFunctionalTestCase { /** * @var PostUpdateListener diff --git a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php index 700340766..fb7f0a724 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php @@ -1,13 +1,16 @@ useModelSet('directorytree'); @@ -16,15 +19,15 @@ class MappedSuperclassTest extends \Doctrine\Tests\OrmFunctionalTestCase public function testCRUD() { - $root = new \Doctrine\Tests\Models\DirectoryTree\Directory(); + $root = new Directory(); $root->setName('Root'); $root->setPath('/root'); - $directory = new \Doctrine\Tests\Models\DirectoryTree\Directory($root); + $directory = new Directory($root); $directory->setName('TestA'); $directory->setPath('/root/dir'); - $file = new \Doctrine\Tests\Models\DirectoryTree\File($directory); + $file = new File($directory); $file->setName('test-b.html'); $this->_em->persist($root); diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php index 6c6198520..9b3b338a0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeCompositeToOneKeyTest.php @@ -4,8 +4,9 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\MixedToOneIdentity\CompositeToOneKeyState; use Doctrine\Tests\Models\MixedToOneIdentity\Country; +use Doctrine\Tests\OrmFunctionalTestCase; -class MergeCompositeToOneKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase +class MergeCompositeToOneKeyTest extends OrmFunctionalTestCase { /** * {@inheritDoc} diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 281846503..6c460684d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -13,17 +13,19 @@ use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyPerson; +use Doctrine\Tests\OrmFunctionalTestCase; /** * NativeQueryTest * * @author robo */ -class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase +class NativeQueryTest extends OrmFunctionalTestCase { private $platform = null; - protected function setUp() { + protected function setUp() + { $this->useModelSet('cms'); $this->useModelSet('company'); parent::setUp(); @@ -197,7 +199,7 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase $rsm = new ResultSetMapping; $q = $this->_em->createNativeQuery('SELECT id, name, status, phonenumber FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', $rsm); - $q2 = $q->setSql('foo', $rsm) + $q2 = $q->setSQL('foo') ->setResultSetMapping($rsm) ->expireResultCache(true) ->setHint('foo', 'bar') diff --git a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php index e8c0e300f..37067aec0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NewOperatorTest.php @@ -7,11 +7,12 @@ use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-1574 */ -class NewOperatorTest extends \Doctrine\Tests\OrmFunctionalTestCase +class NewOperatorTest extends OrmFunctionalTestCase { /** * @var array diff --git a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php index ab6aa61cf..ecebc28d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -1,18 +1,21 @@ _schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php index c904a1474..8327142fd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -5,11 +5,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\Tests\Models\ECommerce\ECommerceFeature; use Doctrine\Common\Collections\Criteria; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a bidirectional one-to-one association mapping (without inheritance). */ -class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase { private $product; private $firstFeature; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php index 345d6190c..d22dbd4e2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -4,11 +4,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a bidirectional one-to-many association mapping with orphan removal. */ -class OneToManyOrphanRemovalTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToManyOrphanRemovalTest extends OrmFunctionalTestCase { protected $userId; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php index ab077fe4a..3d6c688bd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php @@ -5,11 +5,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\ECommerce\ECommerceCategory; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a bidirectional one-to-one association mapping (without inheritance). */ -class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToManySelfReferentialAssociationTest extends OrmFunctionalTestCase { private $parent; private $firstChild; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php index b4db3b90e..e2c663118 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php @@ -5,11 +5,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\Routing\RoutingRoute; use Doctrine\Tests\Models\Routing\RoutingLocation; use Doctrine\Tests\Models\Routing\RoutingLeg; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a bidirectional one-to-one association mapping (without inheritance). */ -class OneToManyUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToManyUnidirectionalAssociationTest extends OrmFunctionalTestCase { protected $locations = array(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php index 4ecfd5f90..6d42e7634 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php @@ -6,11 +6,12 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCart; use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a bidirectional one-to-one association mapping (without inheritance). */ -class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase { private $customer; private $cart; @@ -88,7 +89,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional $customer = $result[0]; $this->assertNull($customer->getMentor()); - $this->assertInstanceOF('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getCart()); $this->assertEquals('paypal', $customer->getCart()->getPayment()); } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php index fb6ed5ab7..522a009eb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -1,16 +1,19 @@ _em); + $schemaTool = new SchemaTool($this->_em); try { $schemaTool->createSchema(array( $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Train'), @@ -248,7 +251,7 @@ class Train public function __construct(TrainOwner $owner) { - $this->waggons = new \Doctrine\Common\Collections\ArrayCollection(); + $this->waggons = new ArrayCollection(); $this->setOwner($owner); } diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php index 528bf56b3..34bbc8c55 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php @@ -5,11 +5,12 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsEmail, Doctrine\Tests\Models\CMS\CmsAddress; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a bidirectional one-to-one association mapping with orphan removal. */ -class OneToOneOrphanRemovalTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToOneOrphanRemovalTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php index 4d173f3dc..cad28d4c3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\ECommerce\ECommerceCustomer; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a self referential one-to-one association mapping (without inheritance). @@ -13,7 +14,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; * for receiving support. * Inverse side is not present. */ -class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase { private $customer; private $mentor; diff --git a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php index 61bb8c611..60b5b3656 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -7,12 +7,13 @@ use Doctrine\Tests\Models\ECommerce\ECommerceShipping; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests a unidirectional one-to-one association mapping (without inheritance). * Inverse side is not present. */ -class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OneToOneUnidirectionalAssociationTest extends OrmFunctionalTestCase { private $product; private $shipping; diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php index d85357bac..c4e5dca70 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php @@ -6,8 +6,9 @@ use Doctrine\Tests\Models\Routing\RoutingRoute; use Doctrine\Tests\Models\Routing\RoutingLocation; use Doctrine\Tests\Models\Routing\RoutingLeg; use Doctrine\Tests\Models\Routing\RoutingRouteBooking; +use Doctrine\Tests\OrmFunctionalTestCase; -class OrderedCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OrderedCollectionTest extends OrmFunctionalTestCase { protected $locations = array(); diff --git a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php index cef464574..b3d85340e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -3,15 +3,17 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Query; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Functional tests for the Single Table Inheritance mapping strategy. * * @author Benjamin Eberlei */ -class OrderedJoinedTableInheritanceCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase +class OrderedJoinedTableInheritanceCollectionTest extends OrmFunctionalTestCase { - protected function setUp() { + protected function setUp() + { parent::setUp(); try { $this->_schemaTool->createSchema(array( diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index eea2e8375..07c3d664a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -13,12 +13,13 @@ use Doctrine\Tests\Models\Pagination\Company; use Doctrine\Tests\Models\Pagination\Department; use Doctrine\Tests\Models\Pagination\Logo; use Doctrine\Tests\Models\Pagination\User1; +use Doctrine\Tests\OrmFunctionalTestCase; use ReflectionMethod; /** * @group DDC-1613 */ -class PaginationTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PaginationTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php index b6e58246f..e38574b7c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php @@ -23,11 +23,12 @@ use Doctrine\Tests\Models\Quote\Group; use Doctrine\Tests\Models\Quote\User as QuoteUser; use Doctrine\Tests\Models\Tweet\Tweet; use Doctrine\Tests\Models\Tweet\User as TweetUser; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @author Michaël Gallego */ -class PersistentCollectionCriteriaTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PersistentCollectionCriteriaTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php index c2181b8b1..c6cb20e23 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php @@ -2,12 +2,14 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Persistence\PersistentObject; +use Doctrine\Tests\OrmFunctionalTestCase; /** */ -class PersistentCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PersistentCollectionTest extends OrmFunctionalTestCase { protected function setUp() { @@ -114,7 +116,7 @@ class PersistentCollectionHolder extends PersistentObject public function __construct() { - $this->collection = new \Doctrine\Common\Collections\ArrayCollection(); + $this->collection = new ArrayCollection(); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php index 88e54ae2e..861b29225 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Persistence\PersistentObject; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Test that Doctrine ORM correctly works with the ObjectManagerAware and PersistentObject @@ -10,7 +11,7 @@ use Doctrine\Common\Persistence\PersistentObject; * * @group DDC-1448 */ -class PersistentObjectTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PersistentObjectTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php index e23038e69..12e2c4080 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php @@ -5,13 +5,14 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\ORM\Event\PostFlushEventArgs; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmFunctionalTestCase; /** * PostFlushEventTest * * @author Daniel Freudenberger */ -class PostFlushEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PostFlushEventTest extends OrmFunctionalTestCase { /** * @var PostFlushListener diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index 9dcff9cb6..7a5adbe7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -8,13 +8,14 @@ use Doctrine\Tests\Models\CMS\CmsAddress; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\ORM\Event\LifecycleEventArgs; use Doctrine\ORM\Events; +use Doctrine\Tests\OrmFunctionalTestCase; /** * PostLoadEventTest * * @author Guilherme Blanco */ -class PostLoadEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PostLoadEventTest extends OrmFunctionalTestCase { /** * @var integer diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php index f84147374..c6d3ebe10 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -3,13 +3,14 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\Tests\OrmFunctionalTestCase; /** * QueryCacheTest * * @author robo */ -class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase +class QueryCacheTest extends OrmFunctionalTestCase { /** * @var \ReflectionProperty diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index b0a4905ac..764b213dd 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -3,13 +3,14 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Tests\Models\Company\CompanyManager; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Functional Query tests. * * @author robo */ -class QueryDqlFunctionTest extends \Doctrine\Tests\OrmFunctionalTestCase +class QueryDqlFunctionTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index 922c463a9..ea150e7b2 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -4,19 +4,21 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\UnexpectedResultException; use Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsArticle, Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Parameter; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Functional Query tests. * * @author robo */ -class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase +class QueryTest extends OrmFunctionalTestCase { protected function setUp() { @@ -390,7 +392,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase try { $query = $this->_em->createQuery('UPDATE CMS:CmsUser u SET u.name = ?1'); - $this->assertEquals('UPDATE cms_users SET name = ?', $query->getSql()); + $this->assertEquals('UPDATE cms_users SET name = ?', $query->getSQL()); $query->free(); } catch (\Exception $e) { $this->fail($e->getMessage()); @@ -753,7 +755,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase try { $this->_em->createQuery($dql)->getSingleResult(); $this->fail('Expected exception "\Doctrine\ORM\NoResultException".'); - } catch (\Doctrine\ORM\UnexpectedResultException $exc) { + } catch (UnexpectedResultException $exc) { $this->assertInstanceOf('\Doctrine\ORM\NoResultException', $exc); } @@ -766,7 +768,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase try { $this->_em->createQuery($dql)->getSingleResult(); $this->fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".'); - } catch (\Doctrine\ORM\UnexpectedResultException $exc) { + } catch (UnexpectedResultException $exc) { $this->assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php index 0cfbdc16e..dd8a23ff3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -1,13 +1,14 @@ * @author Benjamin Eberlei */ -class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase +class ReferenceProxyTest extends OrmFunctionalTestCase { protected function setUp() { @@ -230,9 +232,9 @@ class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase { $id = $this->createProduct(); - /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + /* @var $entity ECommerceProduct */ $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); - $className = \Doctrine\Common\Util\ClassUtils::getClass($entity); + $className = ClassUtils::getClass($entity); $this->assertInstanceOf('Doctrine\Common\Persistence\Proxy', $entity); $this->assertFalse($entity->__isInitialized()); diff --git a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php index 580473476..e1bd93ed7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -2,16 +2,19 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Query; +use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\Tests\OrmFunctionalTestCase; /** * ResultCacheTest * * @author robo */ -class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase +class ResultCacheTest extends OrmFunctionalTestCase { /** * @var \ReflectionProperty @@ -133,7 +136,7 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase public function testNativeQueryResultCaching() { $cache = new ArrayCache(); - $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); + $rsm = new ResultSetMapping(); $rsm->addScalarResult('id', 'u', 'integer'); @@ -190,7 +193,7 @@ class ResultCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase $cache = $query->getResultCacheDriver(); $cacheCount = $this->getCacheSize($cache); - $this->assertNotEquals(\Doctrine\ORM\Query::HYDRATE_ARRAY, $query->getHydrationMode()); + $this->assertNotEquals(Query::HYDRATE_ARRAY, $query->getHydrationMode()); $query->getArrayResult(); $this->assertEquals($cacheCount, $this->getCacheSize($cache)); diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index bbf688c46..5fccc0bdb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Types\Type as DBALType; +use Doctrine\ORM\Configuration; use Doctrine\ORM\Query\Filter\SQLFilter; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Common\Cache\ArrayCache; @@ -21,6 +22,7 @@ use Doctrine\Tests\Models\Company\CompanyAuction; use Doctrine\Tests\Models\Company\CompanyFlexContract; use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests SQLFilter functionality. @@ -29,7 +31,7 @@ use Doctrine\Tests\Models\Company\CompanyFlexUltraContract; * * @group non-cacheable */ -class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase +class SQLFilterTest extends OrmFunctionalTestCase { private $userId, $userId2, $articleId, $articleId2; private $groupId, $groupId2; @@ -54,7 +56,7 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase public function testConfigureFilter() { - $config = new \Doctrine\ORM\Configuration(); + $config = new Configuration(); $config->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); @@ -69,7 +71,7 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase // Enable an existing filter $filter = $em->getFilters()->enable("locale"); - $this->assertTrue($filter instanceof \Doctrine\Tests\ORM\Functional\MyLocaleFilter); + $this->assertTrue($filter instanceof MyLocaleFilter); // Enable the filter again $filter2 = $em->getFilters()->enable("locale"); @@ -223,7 +225,7 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase ->with($this->equalTo('en')) ->will($this->returnValue("'en'")); - $em = $this->getMockEntityManager($conn); + $em = $this->getMockEntityManager(); $em->expects($this->once()) ->method('getConnection') ->will($this->returnValue($conn)); @@ -249,7 +251,7 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase // Setup mock connection $conn = $this->getMockConnection(); - $em = $this->getMockEntityManager($conn); + $em = $this->getMockEntityManager(); $em->expects($this->once()) ->method('getConnection') ->will($this->returnValue($conn)); @@ -271,7 +273,7 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase ->with($this->equalTo('en')) ->will($this->returnValue("'en'")); - $em = $this->getMockEntityManager($conn); + $em = $this->getMockEntityManager(); $em->expects($this->once()) ->method('getConnection') ->will($this->returnValue($conn)); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php index 5e9fcda37..32c75d25d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -3,13 +3,14 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; use Doctrine\DBAL\Schema\Schema; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Functional tests for the Class Table Inheritance mapping strategy. * * @author robo */ -class CompanySchemaTest extends \Doctrine\Tests\OrmFunctionalTestCase +class CompanySchemaTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php index 8887a0751..22debe962 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DBAL483Test.php @@ -3,8 +3,9 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; use Doctrine\ORM\Tools; +use Doctrine\Tests\OrmFunctionalTestCase; -class DBAL483Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DBAL483Test extends OrmFunctionalTestCase { public function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php index 22d2b1f8e..4b4d0328d 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -2,12 +2,14 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; +use Doctrine\DBAL\Schema\Comparator; use Doctrine\ORM\Tools; +use Doctrine\Tests\OrmFunctionalTestCase; /** * WARNING: This test should be run as last test! It can affect others very easily! */ -class DDC214Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC214Test extends OrmFunctionalTestCase { private $classes = array(); private $schemaTool = null; @@ -78,7 +80,7 @@ class DDC214Test extends \Doctrine\Tests\OrmFunctionalTestCase $fromSchema = $sm->createSchema(); $toSchema = $this->schemaTool->getSchemaFromMetadata($classMetadata); - $comparator = new \Doctrine\DBAL\Schema\Comparator(); + $comparator = new Comparator(); $schemaDiff = $comparator->compare($fromSchema, $toSchema); $sql = $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php index 66e990688..f98fe4beb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -3,8 +3,9 @@ namespace Doctrine\Tests\ORM\Functional\SchemaTool; use Doctrine\ORM\Tools\SchemaTool; +use Doctrine\Tests\OrmFunctionalTestCase; -class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase +class PostgreSqlSchemaToolTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php index c09f336c9..06eb67a2e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php @@ -3,13 +3,14 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Tools\SchemaValidator; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Test the validity of all modelsets * * @group DDC-1601 */ -class SchemaValidatorTest extends \Doctrine\Tests\OrmFunctionalTestCase +class SchemaValidatorTest extends OrmFunctionalTestCase { static public function dataValidateModelSets() { diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php index 6b177562f..f4d8e6b76 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheConcurrentTest.php @@ -2,9 +2,11 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\Cache\DefaultCacheFactory; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\Mocks\ConcurrentRegionMock; use Doctrine\ORM\Cache\Region\DefaultRegion; +use Doctrine\Tests\Mocks\TimestampRegionMock; use Doctrine\Tests\Models\Cache\Country; use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\EntityCacheKey; @@ -126,7 +128,7 @@ class SecondLevelCacheConcurrentTest extends SecondLevelCacheAbstractTest } } -class CacheFactorySecondLevelCacheConcurrentTest extends \Doctrine\ORM\Cache\DefaultCacheFactory +class CacheFactorySecondLevelCacheConcurrentTest extends DefaultCacheFactory { public function __construct(Cache $cache) { @@ -143,6 +145,6 @@ class CacheFactorySecondLevelCacheConcurrentTest extends \Doctrine\ORM\Cache\Def public function getTimestampRegion() { - return new \Doctrine\Tests\Mocks\TimestampRegionMock(); + return new TimestampRegionMock(); } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 995c1d07f..f5e1df0a8 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\AbstractQuery; use Doctrine\Tests\Models\Cache\Country; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\Models\Cache\State; @@ -716,7 +717,7 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest $this->secondLevelCacheLogger->clearStats(); $this->_em->clear(); - $getHash = function(\Doctrine\ORM\AbstractQuery $query){ + $getHash = function(AbstractQuery $query){ $method = new \ReflectionMethod($query, 'getHash'); $method->setAccessible(true); diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php index 38a6e4d2d..02c891e75 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceEmulatedIdentityStrategyTest.php @@ -3,8 +3,9 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Schema\Sequence; +use Doctrine\Tests\OrmFunctionalTestCase; -class SequenceEmulatedIdentityStrategyTest extends \Doctrine\Tests\OrmFunctionalTestCase +class SequenceEmulatedIdentityStrategyTest extends OrmFunctionalTestCase { /** * {@inheritdoc} diff --git a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php index 6cb00f686..2fcd6a1b9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -1,13 +1,14 @@ salesPerson = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $this->salesPerson = new CompanyEmployee(); $this->salesPerson->setName('Poor Sales Guy'); $this->salesPerson->setDepartment('Sales'); $this->salesPerson->setSalary(100); - $engineer1 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer1 = new CompanyEmployee(); $engineer1->setName('Roman B.'); $engineer1->setDepartment('IT'); $engineer1->setSalary(100); $this->engineers[] = $engineer1; - $engineer2 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer2 = new CompanyEmployee(); $engineer2->setName('Jonathan W.'); $engineer2->setDepartment('IT'); $engineer2->setSalary(100); $this->engineers[] = $engineer2; - $engineer3 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer3 = new CompanyEmployee(); $engineer3->setName('Benjamin E.'); $engineer3->setDepartment('IT'); $engineer3->setSalary(100); $this->engineers[] = $engineer3; - $engineer4 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer4 = new CompanyEmployee(); $engineer4->setName('Guilherme B.'); $engineer4->setDepartment('IT'); $engineer4->setSalary(100); @@ -61,14 +66,14 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase { $this->persistRelatedEmployees(); - $this->fix = new \Doctrine\Tests\Models\Company\CompanyFixContract(); + $this->fix = new CompanyFixContract(); $this->fix->setFixPrice(1000); $this->fix->setSalesPerson($this->salesPerson); $this->fix->addEngineer($this->engineers[0]); $this->fix->addEngineer($this->engineers[1]); $this->fix->markCompleted(); - $this->flex = new \Doctrine\Tests\Models\Company\CompanyFlexContract(); + $this->flex = new CompanyFlexContract(); $this->flex->setSalesPerson($this->salesPerson); $this->flex->setHoursWorked(100); $this->flex->setPricePerHour(100); @@ -77,7 +82,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->flex->addEngineer($this->engineers[3]); $this->flex->markCompleted(); - $this->ultra = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); + $this->ultra = new CompanyFlexUltraContract(); $this->ultra->setSalesPerson($this->salesPerson); $this->ultra->setHoursWorked(150); $this->ultra->setPricePerHour(150); @@ -96,7 +101,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase { $this->persistRelatedEmployees(); - $fixContract = new \Doctrine\Tests\Models\Company\CompanyFixContract(); + $fixContract = new CompanyFixContract(); $fixContract->setFixPrice(1000); $fixContract->setSalesPerson($this->salesPerson); @@ -115,7 +120,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase { $this->persistRelatedEmployees(); - $ultraContract = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); + $ultraContract = new CompanyFlexUltraContract(); $ultraContract->setSalesPerson($this->salesPerson); $ultraContract->setHoursWorked(100); $ultraContract->setPricePerHour(50); diff --git a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php index 31f28db3b..a335b234e 100644 --- a/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php @@ -8,12 +8,13 @@ use Doctrine\Tests\Models\ECommerce\ECommerceCart, Doctrine\Tests\Models\ECommerce\ECommerceProduct; use Doctrine\ORM\Mapping\AssociationMapping; +use Doctrine\Tests\OrmFunctionalTestCase; /** * Tests capabilities of the persister. * @author Giorgio Sironi */ -class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase +class StandardEntityPersisterTest extends OrmFunctionalTestCase { protected function setUp() { @@ -56,7 +57,7 @@ class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase $p = new ECommerceProduct; $p->addFeature($f1); - $p->addfeature($f2); + $p->addFeature($f2); $this->_em->persist($p); $this->_em->flush(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php index 98de7ee38..fccb0fd4c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php @@ -24,7 +24,7 @@ class DDC1050Test extends OrmFunctionalTestCase for ($i = 2; $i < 10000; ++$i) { $user = new CmsUser(); $user->status = 'developer'; - $user->username = 'jwage'+$i; + $user->username = 'jwage'.$i; $user->name = 'Jonathan'; $this->_em->persist($user); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php index cd678d5f1..9369ca4c9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -57,7 +57,7 @@ class DDC1080Test extends OrmFunctionalTestCase $this->_em->flush(); $this->_em->clear(); - $foo = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC1080Foo', $foo1->getFooId()); + $foo = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC1080Foo', $foo1->getFooID()); $fooBars = $foo->getFooBars(); $this->assertEquals(3, count($fooBars), "Should return three foobars."); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php index 53d6bb6e2..fda168246 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -105,7 +105,7 @@ class DDC1643Test extends \Doctrine\Tests\OrmFunctionalTestCase $user2->groups = $user1->groups; $user2->groups->add($group3); - $this->assertEQuals(1, count($user1->groups->getInsertDiff())); + $this->assertCount(1, $user1->groups->getInsertDiff()); $this->_em->persist($group3); $this->_em->flush(); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php index c6c23b991..5e587c4df 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1707Test.php @@ -2,12 +2,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; -use Doctrine\ORM\Event\LifecycleEventArgs; +use Doctrine\ORM\Events; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group DDC-1707 */ -class DDC1707Test extends \Doctrine\Tests\OrmFunctionalTestCase +class DDC1707Test extends OrmFunctionalTestCase { public function setUp() { @@ -27,9 +28,8 @@ class DDC1707Test extends \Doctrine\Tests\OrmFunctionalTestCase { $class = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1707Child'); $entity = new DDC1707Child(); - $event = new LifecycleEventArgs($entity, $this->_em); - $class->invokeLifecycleCallbacks(\Doctrine\ORM\Events::postLoad, $entity, $event); + $class->invokeLifecycleCallbacks(Events::postLoad, $entity); $this->assertTrue($entity->postLoad); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php index aebc6422c..b2e02c26b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php @@ -23,9 +23,9 @@ class DDC1778Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->user->name = "Benjamin"; $this->user->status = "active"; - $this->phone = new CmsPhoneNumber(); + $this->phone = new CmsPhonenumber(); $this->phone->phonenumber = '0123456789'; - $this->user->addPhoneNumber($this->phone); + $this->user->addPhonenumber($this->phone); $this->_em->persist($this->user); $this->_em->persist($this->phone); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php index 92df8d22f..5ec8ad730 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php @@ -22,7 +22,7 @@ class DDC331Test extends \Doctrine\Tests\OrmFunctionalTestCase $q = $this->_em->createQuery('SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e'); $this->assertEquals( strtolower('SELECT c0_.name AS name_0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id LEFT JOIN company_managers c2_ ON c1_.id = c2_.id'), - strtolower($q->getSql()) + strtolower($q->getSQL()) ); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php index cb265dada..eb368cd89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -24,10 +24,10 @@ class DDC656Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->persist($entity); $this->_em->getUnitOfWork()->computeChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); - $data1 = $this->_em->getUnitOfWork()->getEntityChangeset($entity); + $data1 = $this->_em->getUnitOfWork()->getEntityChangeSet($entity); $entity->setType('type2'); $this->_em->getUnitOfWork()->recomputeSingleEntityChangeSet($this->_em->getClassMetadata(get_class($entity)), $entity); - $data2 = $this->_em->getUnitOfWork()->getEntityChangeset($entity); + $data2 = $this->_em->getUnitOfWork()->getEntityChangeSet($entity); $this->assertEquals(array_keys($data1), array_keys($data2)); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php index 174726d5a..295542aab 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php @@ -22,7 +22,7 @@ class DDC758Test extends \Doctrine\Tests\OrmFunctionalTestCase */ private function setCascadeMergeFor($class) { - $metadata = $this->_em->getMetadataFactory()->getMetaDataFor($class); + $metadata = $this->_em->getMetadataFactory()->getMetadataFor($class); foreach ($metadata->associationMappings as $key => $associationMapping) { $metadata->associationMappings[$key]["isCascadePersist"] = false; $metadata->associationMappings[$key]["isCascadeMerge"] = true; diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php index 47064d5e2..c27e0dee6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -9,8 +9,9 @@ use Doctrine\Tests\Models\Generic\SerializationModel; use Doctrine\ORM\Mapping\AssociationMapping; use Doctrine\DBAL\Types\Type as DBALType; +use Doctrine\Tests\OrmFunctionalTestCase; -class TypeTest extends \Doctrine\Tests\OrmFunctionalTestCase +class TypeTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php index aae0fbc71..8e305d1f1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php @@ -6,8 +6,9 @@ use Doctrine\Tests\Models\CustomType\CustomTypeChild; use Doctrine\Tests\Models\CustomType\CustomTypeParent; use Doctrine\Tests\Models\CustomType\CustomTypeUpperCase; use Doctrine\DBAL\Types\Type as DBALType; +use Doctrine\Tests\OrmFunctionalTestCase; -class TypeValueSqlTest extends \Doctrine\Tests\OrmFunctionalTestCase +class TypeValueSqlTest extends OrmFunctionalTestCase { protected function setUp() { diff --git a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php index 5fa237ee4..d5d559a4f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php @@ -1,10 +1,11 @@ assertEquals('1 = 1 AND 2 = 2', (string) $this->_expr->andx((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2))); + $this->assertEquals('1 = 1 AND 2 = 2', (string) $this->_expr->andX((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2))); } public function testIntelligentParenthesisPreventionAndExpr() { $this->assertEquals( '1 = 1 AND 2 = 2', - (string) $this->_expr->andx($this->_expr->orx($this->_expr->andx($this->_expr->eq(1, 1))), (string) $this->_expr->eq(2, 2)) + (string) $this->_expr->andX($this->_expr->orX($this->_expr->andX($this->_expr->eq(1, 1))), (string) $this->_expr->eq(2, 2)) ); } public function testOrExpr() { - $this->assertEquals('1 = 1 OR 2 = 2', (string) $this->_expr->orx((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2))); + $this->assertEquals('1 = 1 OR 2 = 2', (string) $this->_expr->orX((string) $this->_expr->eq(1, 1), (string) $this->_expr->eq(2, 2))); } public function testAbsExpr() @@ -311,11 +311,11 @@ class ExprTest extends OrmTestCase public function testAndxOrxExpr() { - $andExpr = $this->_expr->andx(); + $andExpr = $this->_expr->andX(); $andExpr->add($this->_expr->eq(1, 1)); $andExpr->add($this->_expr->lt(1, 5)); - $orExpr = $this->_expr->orx(); + $orExpr = $this->_expr->orX(); $orExpr->add($andExpr); $orExpr->add($this->_expr->eq(1, 1)); @@ -324,7 +324,7 @@ class ExprTest extends OrmTestCase public function testOrxExpr() { - $orExpr = $this->_expr->orx(); + $orExpr = $this->_expr->orX(); $orExpr->add($this->_expr->eq(1, 1)); $orExpr->add($this->_expr->lt(1, 5)); @@ -356,7 +356,7 @@ class ExprTest extends OrmTestCase */ public function testAddThrowsException() { - $orExpr = $this->_expr->orx(); + $orExpr = $this->_expr->orX(); $orExpr->add($this->_expr->quot(5, 2)); } @@ -433,15 +433,17 @@ class ExprTest extends OrmTestCase $this->assertEquals(array('foo', 'bar'), $select->getParts()); } - public function testAddEmpty() { - $andExpr = $this->_expr->andx(); - $andExpr->add($this->_expr->andx()); + public function testAddEmpty() + { + $andExpr = $this->_expr->andX(); + $andExpr->add($this->_expr->andX()); $this->assertEquals(0, $andExpr->count()); } - public function testAddNull() { - $andExpr = $this->_expr->andx(); + public function testAddNull() + { + $andExpr = $this->_expr->andX(); $andExpr->add(null); $this->assertEquals(0, $andExpr->count()); diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index daec446bb..145b591e7 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -50,7 +50,7 @@ class LanguageRecognitionTest extends OrmTestCase { $query = $this->_em->createQuery($dql); $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); - $query->setDql($dql); + $query->setDQL($dql); foreach ($hints as $key => $value) { $query->setHint($key, $value); diff --git a/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/tests/Doctrine/Tests/ORM/Query/QueryTest.php index d59c93b07..7a3687c52 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -74,7 +74,7 @@ class QueryTest extends OrmTestCase $cloned = clone $query; - $this->assertEquals($dql, $cloned->getDql()); + $this->assertEquals($dql, $cloned->getDQL()); $this->assertEquals(0, count($cloned->getParameters())); $this->assertFalse($cloned->getHint('foo')); } @@ -92,7 +92,7 @@ class QueryTest extends OrmTestCase ->setParameters(new ArrayCollection(array(new Parameter(2, 'baz')))) ->setResultCacheDriver(null) ->setResultCacheId('foo') - ->setDql('foo') + ->setDQL('foo') ->setFirstResult(10) ->setMaxResults(10); diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 318eb2a2f..655b86a6a 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -51,7 +51,7 @@ class QueryBuilderTest extends OrmTestCase protected function assertValidQueryBuilder(QueryBuilder $qb, $expectedDql) { - $dql = $qb->getDql(); + $dql = $qb->getDQL(); $q = $qb->getQuery(); $this->assertEquals($expectedDql, $dql); @@ -632,7 +632,7 @@ class QueryBuilderTest extends OrmTestCase $qb = $this->_em->createQueryBuilder(); $qb->select('u') ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') - ->where($qb->expr()->orx('u.username = :username', 'u.username = :username2')); + ->where($qb->expr()->orX('u.username = :username', 'u.username = :username2')); $parameters = new ArrayCollection(); $parameters->add(new Parameter('username', 'jwage')); @@ -788,7 +788,7 @@ class QueryBuilderTest extends OrmTestCase $q1 = $qb->getQuery(); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name', $q1->getDql()); + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name', $q1->getDQL()); $this->assertEquals(1, count($q1->getParameters())); // add another condition and construct a second query @@ -797,7 +797,7 @@ class QueryBuilderTest extends OrmTestCase $q2 = $qb->getQuery(); - $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name AND u.id = :id', $q2->getDql()); + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :name AND u.id = :id', $q2->getDQL()); $this->assertTrue($q1 !== $q2); // two different, independent queries $this->assertEquals(2, count($q2->getParameters())); $this->assertEquals(1, count($q1->getParameters())); // $q1 unaffected @@ -843,7 +843,7 @@ class QueryBuilderTest extends OrmTestCase $this->assertEquals('u.username = ?1', (string)$qb->getDQLPart('where')); $this->assertEquals(1, count($qb->getDQLPart('orderBy'))); - $qb->resetDqlPart('where')->resetDqlPart('orderBy'); + $qb->resetDQLPart('where')->resetDQLPart('orderBy'); $this->assertNull($qb->getDQLPart('where')); $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php index 4dde04862..08ade2999 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/GenerateRepositoriesCommandTest.php @@ -62,7 +62,7 @@ class GenerateRepositoriesCommandTest extends OrmFunctionalTestCase if ($file->isFile()) { \unlink($file->getPathname()); } elseif ($file->getBasename() === '.') { - $dirs[] = $file->getRealpath(); + $dirs[] = $file->getRealPath(); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php index 8a4b6ad5f..bcb16a3d6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityRepositoryGeneratorTest.php @@ -55,7 +55,7 @@ class EntityRepositoryGeneratorTest extends OrmTestCase if ($file->isFile()) { \unlink($file->getPathname()); } elseif ($file->getBasename() === '.') { - $dirs[] = $file->getRealpath(); + $dirs[] = $file->getRealPath(); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php index f6c63f752..691b8ef20 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php @@ -26,7 +26,7 @@ class CountOutputWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result) dctrn_table", $query->getSql() + "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result) dctrn_table", $query->getSQL() ); } @@ -38,7 +38,7 @@ class CountOutputWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_1 FROM (SELECT count(u0_.id) AS sclr_0, g1_.id AS id_1, u0_.id AS id_2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr_0 > 0) dctrn_result) dctrn_table", $query->getSql() + "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_1 FROM (SELECT count(u0_.id) AS sclr_0, g1_.id AS id_1, u0_.id AS id_2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr_0 > 0) dctrn_result) dctrn_table", $query->getSQL() ); } @@ -55,7 +55,7 @@ class CountOutputWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_) dctrn_result) dctrn_table", - $query->getSql() + $query->getSQL() ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index b8d1b41a6..888861582 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -32,7 +32,7 @@ class CountWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT count(DISTINCT a0_.id) AS sclr_0 FROM Author a0_", $query->getSql() + "SELECT count(DISTINCT a0_.id) AS sclr_0 FROM Author a0_", $query->getSQL() ); } @@ -45,7 +45,7 @@ class CountWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ GROUP BY b0_.id", $query->getSql() + "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ GROUP BY b0_.id", $query->getSQL() ); } @@ -58,7 +58,7 @@ class CountWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSql() + "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSQL() ); } @@ -71,7 +71,7 @@ class CountWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSql() + "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ INNER JOIN Category c1_ ON b0_.category_id = c1_.id INNER JOIN Author a2_ ON b0_.author_id = a2_.id", $query->getSQL() ); } @@ -88,7 +88,7 @@ class CountWalkerTest extends PaginationTestCase 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' ); - $query->getSql(); + $query->getSQL(); } /** @@ -103,7 +103,7 @@ class CountWalkerTest extends PaginationTestCase $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( - "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ LEFT JOIN Category c1_ ON (b0_.category_id = c1_.id)", $query->getSql() + "SELECT count(DISTINCT b0_.id) AS sclr_0 FROM BlogPost b0_ LEFT JOIN Category c1_ ON (b0_.category_id = c1_.id)", $query->getSQL() ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index b30ef51fc..78fd38e9a 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -33,7 +33,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $this->assertEquals( - "SELECT DISTINCT id_0, MIN(sclr_5) AS dctrn_minrownum FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS sclr_5, m0_.author_id AS author_id_6, m0_.category_id AS category_id_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC", $limitQuery->getSql() + "SELECT DISTINCT id_0, MIN(sclr_5) AS dctrn_minrownum FROM (SELECT m0_.id AS id_0, m0_.title AS title_1, c1_.id AS id_2, a2_.id AS id_3, a2_.name AS name_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS sclr_5, m0_.author_id AS author_id_6, m0_.category_id AS category_id_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY id_0 ORDER BY dctrn_minrownum ASC", $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -52,7 +52,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -71,7 +71,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -90,7 +90,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT id_1, MIN(sclr_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS sclr_0, u1_.id AS id_1, g0_.id AS id_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS sclr_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY id_1 ORDER BY dctrn_minrownum ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -118,7 +118,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $this->assertEquals( - "SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS SCLR_5, m0_.author_id AS AUTHOR_ID_6, m0_.category_id AS CATEGORY_ID_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC", $limitQuery->getSql() + "SELECT DISTINCT ID_0, MIN(SCLR_5) AS dctrn_minrownum FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, ROW_NUMBER() OVER(ORDER BY m0_.title ASC) AS SCLR_5, m0_.author_id AS AUTHOR_ID_6, m0_.category_id AS CATEGORY_ID_7 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result GROUP BY ID_0 ORDER BY dctrn_minrownum ASC", $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -138,7 +138,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -158,7 +158,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT ID_1, MIN(SCLR_3) AS dctrn_minrownum FROM (SELECT COUNT(g0_.id) AS SCLR_0, u1_.id AS ID_1, g0_.id AS ID_2, ROW_NUMBER() OVER(ORDER BY COUNT(g0_.id) ASC, u1_.id DESC) AS SCLR_3 FROM User u1_ INNER JOIN user_group u2_ ON u1_.id = u2_.user_id INNER JOIN groups g0_ ON g0_.id = u2_.group_id) dctrn_result GROUP BY ID_1 ORDER BY dctrn_minrownum ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -176,7 +176,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $this->assertEquals( - "SELECT DISTINCT ID_0 FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, m0_.author_id AS AUTHOR_ID_5, m0_.category_id AS CATEGORY_ID_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result", $limitQuery->getSql() + "SELECT DISTINCT ID_0 FROM (SELECT m0_.id AS ID_0, m0_.title AS TITLE_1, c1_.id AS ID_2, a2_.id AS ID_3, a2_.name AS NAME_4, m0_.author_id AS AUTHOR_ID_5, m0_.category_id AS CATEGORY_ID_6 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) dctrn_result", $limitQuery->getSQL() ); $this->entityManager->getConnection()->setDatabasePlatform($odp); @@ -190,7 +190,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $this->assertEquals( - "SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result", $limitQuery->getSql() + "SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_) dctrn_result", $limitQuery->getSQL() ); } @@ -285,7 +285,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase $this->assertEquals( 'SELECT DISTINCT id_0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_) dctrn_result ORDER BY name_2 DESC', - $query->getSql() + $query->getSQL() ); } @@ -374,7 +374,7 @@ ORDER BY b.id DESC' */ public function testLimitSubqueryOrderBySubSelectOrderByExpression() { - $this->entityManager->getConnection()->setDatabasePlatform(new MysqlPlatform()); + $this->entityManager->getConnection()->setDatabasePlatform(new MySqlPlatform()); $query = $this->entityManager->createQuery( 'SELECT a, diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php index fb11feb7a..30da25789 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php @@ -33,7 +33,7 @@ class LimitSubqueryWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); } @@ -47,7 +47,7 @@ class LimitSubqueryWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT a0_.id AS id_0, sum(a0_.name) AS sclr_1 FROM Author a0_", - $limitQuery->getSql() + $limitQuery->getSQL() ); } @@ -64,7 +64,7 @@ class LimitSubqueryWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT m0_.id AS id_0, m0_.author_id AS sclr_1 FROM MyBlogPost m0_ ORDER BY m0_.author_id ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); } @@ -81,7 +81,7 @@ class LimitSubqueryWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT m0_.id AS id_0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id)", - $limitQuery->getSql() + $limitQuery->getSQL() ); } @@ -95,7 +95,7 @@ class LimitSubqueryWalkerTest extends PaginationTestCase $this->assertEquals( "SELECT DISTINCT m0_.id AS id_0, m0_.title AS title_1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON (m0_.category_id = c1_.id) ORDER BY m0_.title ASC", - $limitQuery->getSql() + $limitQuery->getSQL() ); } } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php index 5f9a3430f..f89ea5704 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -34,7 +34,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_ WHERE a0_.id IN (?)", $whereInQuery->getSql() + "SELECT a0_.id AS id_0, a0_.name AS name_1, sum(a0_.name) AS sclr_2 FROM Author a0_ WHERE a0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -48,7 +48,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?)", $whereInQuery->getSql() + "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND u0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -62,7 +62,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?)", $whereInQuery->getSql() + "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE 1 = 1 AND 2 = 2 AND u0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -76,7 +76,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?)", $whereInQuery->getSql() + "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND u0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -90,7 +90,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?)", $whereInQuery->getSql() + "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 OR 2 = 2) AND 3 = 3 AND u0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -104,7 +104,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?)", $whereInQuery->getSql() + "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (1 = 1 AND 2 = 2 OR 3 = 3) AND u0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -118,7 +118,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?)", $whereInQuery->getSql() + "SELECT u0_.id AS id_0, g1_.id AS id_1 FROM User u0_ INNER JOIN user_group u2_ ON u0_.id = u2_.user_id INNER JOIN groups g1_ ON g1_.id = u2_.group_id WHERE (NOT 1 = 2) AND u0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -134,7 +134,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE b0_.id IN (?)", $whereInQuery->getSql() + "SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE b0_.id IN (?)", $whereInQuery->getSQL() ); } @@ -147,7 +147,7 @@ class WhereInWalkerTest extends PaginationTestCase $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); $this->assertEquals( - "SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE 1 = 1 AND b0_.id IN (?)", $whereInQuery->getSql() + "SELECT b0_.id AS id_0, b0_.author_id AS author_id_1, b0_.category_id AS category_id_2 FROM BlogPost b0_ INNER JOIN Category c1_ ON (b0_.category_id = c1_.id) WHERE 1 = 1 AND b0_.id IN (?)", $whereInQuery->getSQL() ); } } From 964d510357d8680759bb8a81d9ab386e4b1901e7 Mon Sep 17 00:00:00 2001 From: Primoz Cigler Date: Wed, 11 May 2016 09:11:55 +0200 Subject: [PATCH 007/144] Added missing - in the in getting started docs. --- docs/en/tutorials/getting-started.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 0a40218ac..c9e75d4f4 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -344,7 +344,7 @@ Now that we have defined our first entity, let's update the database: $ vendor/bin/doctrine orm:schema-tool:update --force --dump-sql -Specifying both flags ``--force`` and ``-dump-sql`` prints and executes the DDL +Specifying both flags ``--force`` and ``--dump-sql`` prints and executes the DDL statements. Now create a new script that will insert products into the database: From a6eb7f7c96e2d04faf8248bb37103d1b052ed21a Mon Sep 17 00:00:00 2001 From: Jonny Schmid Date: Wed, 25 May 2016 10:23:03 +0100 Subject: [PATCH 008/144] Use constant consistently --- docs/en/cookbook/mysql-enums.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/cookbook/mysql-enums.rst b/docs/en/cookbook/mysql-enums.rst index fcc04517b..1d8df9259 100644 --- a/docs/en/cookbook/mysql-enums.rst +++ b/docs/en/cookbook/mysql-enums.rst @@ -98,7 +98,7 @@ For example for the previous enum type: public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { - return "ENUM('visible', 'invisible') COMMENT '(DC2Type:enumvisibility)'"; + return sprintf("ENUM('visible', 'invisible') COMMENT '(DC2Type:%s)'", self::ENUM_VISIBILITY); } public function convertToPHPValue($value, AbstractPlatform $platform) From 2c1818d5139b817e773eed4b3623e6431cfde273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Ot=C3=A1vio=20Cobucci=20Oblonczyk?= Date: Sun, 5 Jun 2016 12:12:27 +0200 Subject: [PATCH 009/144] Fix typo --- lib/Doctrine/ORM/Cache/DefaultCacheFactory.php | 4 ++-- tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php index 82843d359..98ece43c7 100644 --- a/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php +++ b/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php @@ -217,8 +217,8 @@ class DefaultCacheFactory implements CacheFactory if ( ! $this->fileLockRegionDirectory) { throw new \LogicException( - 'If you what to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, ' . - 'The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you what to use it please provide a valid directory, DefaultCacheFactory#setFileLockRegionDirectory(). ' + 'If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, ' . + 'The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory, DefaultCacheFactory#setFileLockRegionDirectory(). ' ); } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index cd41726d5..499914270 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -252,7 +252,7 @@ class DefaultCacheFactoryTest extends OrmTestCase /** * @expectedException LogicException - * @expectedExceptionMessage If you what to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you what to use it please provide a valid directory + * @expectedExceptionMessage If you want to use a "READ_WRITE" cache an implementation of "Doctrine\ORM\Cache\ConcurrentRegion" is required, The default implementation provided by doctrine is "Doctrine\ORM\Cache\Region\FileLockRegion" if you want to use it please provide a valid directory */ public function testInvalidFileLockRegionDirectoryException() { From 70603ee3db1afd985d89d56350bd21eedddb03c0 Mon Sep 17 00:00:00 2001 From: Rico Humme Date: Fri, 3 Jun 2016 13:48:05 +0200 Subject: [PATCH 010/144] Clear entityInsertions for specific entityName --- lib/Doctrine/ORM/UnitOfWork.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index a66d7b462..0b71372e3 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2401,6 +2401,13 @@ class UnitOfWork implements PropertyChangedListener $this->doDetach($entity, $visited, false); } } + + foreach ($this->entityInsertions as $hash => $entity) { + if (get_class($entity) != $entityName) { + continue; + } + unset($this->entityInsertions[$hash]); + } } if ($this->evm->hasListeners(Events::onClear)) { From 3df494ddc8f3f8e3e502c13847856cd6146e12e0 Mon Sep 17 00:00:00 2001 From: Rico Humme Date: Fri, 3 Jun 2016 16:13:52 +0200 Subject: [PATCH 011/144] Test Case for Clear entityInsertions for specific entityName --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index eb8bf3a5c..c4dd4adae 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -323,6 +323,27 @@ class UnitOfWorkTest extends OrmTestCase $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); } + public function testPersistedEntityAndClearManager() + { + $entity1 = new ForumUser(); + $entity1->id = 123; + + $entity2 = new ForumAvatar(); + $entity2->id = 456; + + $this->_unitOfWork->persist($entity1); + $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); + + $this->_unitOfWork->persist($entity2); + $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); + + $this->_unitOfWork->clear(ForumAvatar::class); + $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); + $this->assertFalse($this->_unitOfWork->isInIdentityMap($entity2)); + $this->assertTrue($this->_unitOfWork->isScheduledForInsert($entity1)); + $this->assertFalse($this->_unitOfWork->isScheduledForInsert($entity2)); + } + /** * Data Provider * From 4d48781e2bd9aa3aa7b0b3652a1c875321e99bf4 Mon Sep 17 00:00:00 2001 From: Rico Humme Date: Fri, 3 Jun 2016 16:27:27 +0200 Subject: [PATCH 012/144] Split of functionality in separate functions --- lib/Doctrine/ORM/UnitOfWork.php | 50 +++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 0b71372e3..31260b15a 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2390,24 +2390,8 @@ class UnitOfWork implements PropertyChangedListener $this->visitedCollections = $this->orphanRemovals = array(); } else { - $visited = array(); - - foreach ($this->identityMap as $className => $entities) { - if ($className !== $entityName) { - continue; - } - - foreach ($entities as $entity) { - $this->doDetach($entity, $visited, false); - } - } - - foreach ($this->entityInsertions as $hash => $entity) { - if (get_class($entity) != $entityName) { - continue; - } - unset($this->entityInsertions[$hash]); - } + $this->clearIdentityMap($entityName); + $this->clearIdentityInsertions($entityName); } if ($this->evm->hasListeners(Events::onClear)) { @@ -3470,4 +3454,34 @@ class UnitOfWork implements PropertyChangedListener { $this->hydrationCompleteHandler->hydrationComplete(); } + + /** + * @param $entityName + */ + private function clearIdentityMap($entityName) + { + $visited = array(); + + foreach ($this->identityMap as $className => $entities) { + if ($className !== $entityName) { + continue; + } + + foreach ($entities as $entity) { + $this->doDetach($entity, $visited, false); + } + } + } + + /** + * @param $entityName + */ + private function clearIdentityInsertions($entityName) + { + foreach ($this->entityInsertions as $hash => $entity) { + if (get_class($entity) === $entityName) { + unset($this->entityInsertions[$hash]); + } + } + } } From beb26414926757a63e65a7b860fd0f1b77121dcf Mon Sep 17 00:00:00 2001 From: Rico Humme Date: Fri, 3 Jun 2016 16:31:35 +0200 Subject: [PATCH 013/144] Correct naming convention of function. Was confusing otherwise --- lib/Doctrine/ORM/UnitOfWork.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 31260b15a..13e329c51 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2391,7 +2391,7 @@ class UnitOfWork implements PropertyChangedListener $this->orphanRemovals = array(); } else { $this->clearIdentityMap($entityName); - $this->clearIdentityInsertions($entityName); + $this->clearEntityInsertions($entityName); } if ($this->evm->hasListeners(Events::onClear)) { @@ -3476,7 +3476,7 @@ class UnitOfWork implements PropertyChangedListener /** * @param $entityName */ - private function clearIdentityInsertions($entityName) + private function clearEntityInsertions($entityName) { foreach ($this->entityInsertions as $hash => $entity) { if (get_class($entity) === $entityName) { From 313e4a33e54b34015aedc3bf6c286dd1cbca7e5a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 5 Jun 2016 23:54:16 +0200 Subject: [PATCH 014/144] #5849 #5850 adding group annotations to the newly introduced test case --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index c4dd4adae..2d5b6a883 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -323,6 +323,10 @@ class UnitOfWorkTest extends OrmTestCase $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); } + /** + * @group 5849 + * @group 5850 + */ public function testPersistedEntityAndClearManager() { $entity1 = new ForumUser(); From 34d8e00df72803908ee77f567bc6a9f2dd93fbda Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 00:08:26 +0200 Subject: [PATCH 015/144] #5849 #5850 correcting test scenario: identity map could not be built with auto-generated identities+persist --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 2d5b6a883..8755a4eaa 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -15,6 +15,8 @@ use Doctrine\Tests\Mocks\UnitOfWorkMock; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\Forum\ForumAvatar; use Doctrine\Tests\Models\Forum\ForumUser; +use Doctrine\Tests\Models\GeoNames\City; +use Doctrine\Tests\Models\GeoNames\Country; use Doctrine\Tests\OrmTestCase; use stdClass; @@ -329,11 +331,8 @@ class UnitOfWorkTest extends OrmTestCase */ public function testPersistedEntityAndClearManager() { - $entity1 = new ForumUser(); - $entity1->id = 123; - - $entity2 = new ForumAvatar(); - $entity2->id = 456; + $entity1 = new City(123, 'London'); + $entity2 = new Country(456, 'United Kingdom'); $this->_unitOfWork->persist($entity1); $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); @@ -341,7 +340,7 @@ class UnitOfWorkTest extends OrmTestCase $this->_unitOfWork->persist($entity2); $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity2)); - $this->_unitOfWork->clear(ForumAvatar::class); + $this->_unitOfWork->clear(Country::class); $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity1)); $this->assertFalse($this->_unitOfWork->isInIdentityMap($entity2)); $this->assertTrue($this->_unitOfWork->isScheduledForInsert($entity1)); From 14e080029316819de5d9f2be106affa4933072cd Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 00:10:18 +0200 Subject: [PATCH 016/144] #5849 #5850 renamed `clearIdentityMap` to `clearIdentityMapForEntityName`, for clarity --- lib/Doctrine/ORM/UnitOfWork.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 13e329c51..5c943297d 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2390,7 +2390,7 @@ class UnitOfWork implements PropertyChangedListener $this->visitedCollections = $this->orphanRemovals = array(); } else { - $this->clearIdentityMap($entityName); + $this->clearIdentityMapForEntityName($entityName); $this->clearEntityInsertions($entityName); } @@ -3456,9 +3456,9 @@ class UnitOfWork implements PropertyChangedListener } /** - * @param $entityName + * @param string $entityName */ - private function clearIdentityMap($entityName) + private function clearIdentityMapForEntityName($entityName) { $visited = array(); From 20d86c5b27b8af6c567aefe7baaf7e66d13c4b95 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 00:11:19 +0200 Subject: [PATCH 017/144] #5849 #5850 refactored `clearIdentityMapForEntityName` to remove useless looping --- lib/Doctrine/ORM/UnitOfWork.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 5c943297d..0876740da 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -3460,16 +3460,14 @@ class UnitOfWork implements PropertyChangedListener */ private function clearIdentityMapForEntityName($entityName) { - $visited = array(); + if (! isset($this->identityMap[$entityName])) { + return; + } - foreach ($this->identityMap as $className => $entities) { - if ($className !== $entityName) { - continue; - } + $visited = []; - foreach ($entities as $entity) { - $this->doDetach($entity, $visited, false); - } + foreach ($this->identityMap[$entityName] as $entity) { + $this->doDetach($entity, $visited, false); } } From b9b952ce8a5bb4abce188dbfeef62c827edcfcb9 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 00:13:39 +0200 Subject: [PATCH 018/144] #5849 #5850 renamed `clearEntityInsertions` to `clearEntityInsertionsForEntityName`, for clarity --- lib/Doctrine/ORM/UnitOfWork.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 0876740da..8efeb9e8f 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2391,7 +2391,7 @@ class UnitOfWork implements PropertyChangedListener $this->orphanRemovals = array(); } else { $this->clearIdentityMapForEntityName($entityName); - $this->clearEntityInsertions($entityName); + $this->clearEntityInsertionsForEntityName($entityName); } if ($this->evm->hasListeners(Events::onClear)) { @@ -3472,9 +3472,9 @@ class UnitOfWork implements PropertyChangedListener } /** - * @param $entityName + * @param string $entityName */ - private function clearEntityInsertions($entityName) + private function clearEntityInsertionsForEntityName($entityName) { foreach ($this->entityInsertions as $hash => $entity) { if (get_class($entity) === $entityName) { From 68c5d761a8ccf90a6cb463036483ebb7f05aecd5 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 00:25:48 +0200 Subject: [PATCH 019/144] #5849 #5850 minor performance optimization - avoiding `get_class()` calls on all entity insertions --- lib/Doctrine/ORM/UnitOfWork.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 8efeb9e8f..7044ce57e 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -3477,7 +3477,8 @@ class UnitOfWork implements PropertyChangedListener private function clearEntityInsertionsForEntityName($entityName) { foreach ($this->entityInsertions as $hash => $entity) { - if (get_class($entity) === $entityName) { + // note: performance optimization - `instanceof` is much faster than a function call + if ($entity instanceof $entityName && get_class($entity) === $entityName) { unset($this->entityInsertions[$hash]); } } From 741da7806c5d01796e243de9a122590151cb0c90 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 8 Jun 2016 10:29:39 +0300 Subject: [PATCH 020/144] change switch/case to if/else --- lib/Doctrine/ORM/EntityManager.php | 44 ++++++++++++++---------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index d66f454e7..a38ebecbf 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -22,6 +22,7 @@ namespace Doctrine\ORM; use Exception; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\LockMode; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Proxy\ProxyFactory; @@ -420,14 +421,14 @@ use Doctrine\Common\Util\ClassUtils; return null; } - switch (true) { - case LockMode::OPTIMISTIC === $lockMode: + switch ($lockMode) { + case LockMode::OPTIMISTIC: $this->lock($entity, $lockMode, $lockVersion); break; - case LockMode::NONE === $lockMode: - case LockMode::PESSIMISTIC_READ === $lockMode: - case LockMode::PESSIMISTIC_WRITE === $lockMode: + case LockMode::NONE: + case LockMode::PESSIMISTIC_READ: + case LockMode::PESSIMISTIC_WRITE: $persister = $unitOfWork->getEntityPersister($class->name); $persister->refresh($sortedId, $entity, $lockMode); break; @@ -438,8 +439,8 @@ use Doctrine\Common\Util\ClassUtils; $persister = $unitOfWork->getEntityPersister($class->name); - switch (true) { - case LockMode::OPTIMISTIC === $lockMode: + switch ($lockMode) { + case LockMode::OPTIMISTIC: if ( ! $class->isVersioned) { throw OptimisticLockException::notVersioned($class->name); } @@ -450,8 +451,8 @@ use Doctrine\Common\Util\ClassUtils; return $entity; - case LockMode::PESSIMISTIC_READ === $lockMode: - case LockMode::PESSIMISTIC_WRITE === $lockMode: + case LockMode::PESSIMISTIC_READ: + case LockMode::PESSIMISTIC_WRITE: if ( ! $this->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } @@ -835,21 +836,16 @@ use Doctrine\Common\Util\ClassUtils; throw ORMException::missingMappingDriverImpl(); } - switch (true) { - case (is_array($conn)): - $conn = \Doctrine\DBAL\DriverManager::getConnection( - $conn, $config, ($eventManager ?: new EventManager()) - ); - break; - - case ($conn instanceof Connection): - if ($eventManager !== null && $conn->getEventManager() !== $eventManager) { - throw ORMException::mismatchedEventManager(); - } - break; - - default: - throw new \InvalidArgumentException("Invalid argument: " . $conn); + if (is_array($conn)) { + $conn = DriverManager::getConnection( + $conn, $config, ($eventManager ?: new EventManager()) + ); + } elseif ($conn instanceof Connection) { + if ($eventManager !== null && $conn->getEventManager() !== $eventManager) { + throw ORMException::mismatchedEventManager(); + } + } else { + throw new \InvalidArgumentException("Invalid argument: " . $conn); } return new EntityManager($conn, $config, $conn->getEventManager()); From fadd0a338fa4b2a680b6edefafc7c6b9f3240017 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 8 Jun 2016 10:58:44 +0300 Subject: [PATCH 021/144] add createConnection static method --- lib/Doctrine/ORM/EntityManager.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index a38ebecbf..ba882df80 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -836,19 +836,38 @@ use Doctrine\Common\Util\ClassUtils; throw ORMException::missingMappingDriverImpl(); } + $conn = static::createConnection($conn, $config, $eventManager); + + return new EntityManager($conn, $config, $conn->getEventManager()); + } + + /** + * Factory method to create Connection instances. + * + * @param mixed $conn An array with the connection parameters or an existing Connection instance. + * @param Configuration $config The Configuration instance to use. + * @param EventManager $eventManager The EventManager instance to use. + * + * @return Connection + * + * @throws ORMException + * @throws \Doctrine\DBAL\DBALException + */ + protected static function createConnection($conn, Configuration $config, EventManager $eventManager = null) + { if (is_array($conn)) { $conn = DriverManager::getConnection( $conn, $config, ($eventManager ?: new EventManager()) ); } elseif ($conn instanceof Connection) { if ($eventManager !== null && $conn->getEventManager() !== $eventManager) { - throw ORMException::mismatchedEventManager(); + throw ORMException::mismatchedEventManager(); } } else { throw new \InvalidArgumentException("Invalid argument: " . $conn); } - return new EntityManager($conn, $config, $conn->getEventManager()); + return $conn; } /** From 0b5b7190d73b5e030df99aab961d7938342917a5 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 8 Jun 2016 11:29:43 +0300 Subject: [PATCH 022/144] not check EventManager --- lib/Doctrine/ORM/EntityManager.php | 23 +++++++++-------------- lib/Doctrine/ORM/ORMException.php | 8 -------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index ba882df80..cadd0e014 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -821,9 +821,9 @@ use Doctrine\Common\Util\ClassUtils; /** * Factory method to create EntityManager instances. * - * @param mixed $conn An array with the connection parameters or an existing Connection instance. - * @param Configuration $config The Configuration instance to use. - * @param EventManager $eventManager The EventManager instance to use. + * @param array|Connection $conn An array with the connection parameters or an existing Connection instance. + * @param Configuration $config The Configuration instance to use. + * @param EventManager $eventManager The EventManager instance to use. * * @return EntityManager The created EntityManager. * @@ -844,26 +844,21 @@ use Doctrine\Common\Util\ClassUtils; /** * Factory method to create Connection instances. * - * @param mixed $conn An array with the connection parameters or an existing Connection instance. - * @param Configuration $config The Configuration instance to use. - * @param EventManager $eventManager The EventManager instance to use. + * @param array|Connection $conn An array with the connection parameters or an existing Connection instance. + * @param Configuration $config The Configuration instance to use. + * @param EventManager $eventManager The EventManager instance to use. * * @return Connection * - * @throws ORMException - * @throws \Doctrine\DBAL\DBALException + * @throws \InvalidArgumentException */ protected static function createConnection($conn, Configuration $config, EventManager $eventManager = null) { if (is_array($conn)) { - $conn = DriverManager::getConnection( + return DriverManager::getConnection( $conn, $config, ($eventManager ?: new EventManager()) ); - } elseif ($conn instanceof Connection) { - if ($eventManager !== null && $conn->getEventManager() !== $eventManager) { - throw ORMException::mismatchedEventManager(); - } - } else { + } elseif ( ! $conn instanceof Connection) { throw new \InvalidArgumentException("Invalid argument: " . $conn); } diff --git a/lib/Doctrine/ORM/ORMException.php b/lib/Doctrine/ORM/ORMException.php index 6d8a6d631..286eb26e8 100644 --- a/lib/Doctrine/ORM/ORMException.php +++ b/lib/Doctrine/ORM/ORMException.php @@ -154,14 +154,6 @@ class ORMException extends Exception return new self("'$mode' is an invalid hydration mode."); } - /** - * @return ORMException - */ - public static function mismatchedEventManager() - { - return new self("Cannot use different EventManager instances for EntityManager and Connection."); - } - /** * @param string $methodName * From c0a87597fabf6dc0530e1ddde3b0203175e5687f Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 8 Jun 2016 11:47:09 +0300 Subject: [PATCH 023/144] correct code style --- lib/Doctrine/ORM/EntityManager.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index cadd0e014..97aab4f81 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -821,7 +821,7 @@ use Doctrine\Common\Util\ClassUtils; /** * Factory method to create EntityManager instances. * - * @param array|Connection $conn An array with the connection parameters or an existing Connection instance. + * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. * @param Configuration $config The Configuration instance to use. * @param EventManager $eventManager The EventManager instance to use. * @@ -830,21 +830,21 @@ use Doctrine\Common\Util\ClassUtils; * @throws \InvalidArgumentException * @throws ORMException */ - public static function create($conn, Configuration $config, EventManager $eventManager = null) + public static function create($connection, Configuration $config, EventManager $eventManager = null) { if ( ! $config->getMetadataDriverImpl()) { throw ORMException::missingMappingDriverImpl(); } - $conn = static::createConnection($conn, $config, $eventManager); + $connection = static::createConnection($connection, $config, $eventManager); - return new EntityManager($conn, $config, $conn->getEventManager()); + return new EntityManager($connection, $config, $connection->getEventManager()); } /** * Factory method to create Connection instances. * - * @param array|Connection $conn An array with the connection parameters or an existing Connection instance. + * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. * @param Configuration $config The Configuration instance to use. * @param EventManager $eventManager The EventManager instance to use. * @@ -852,17 +852,17 @@ use Doctrine\Common\Util\ClassUtils; * * @throws \InvalidArgumentException */ - protected static function createConnection($conn, Configuration $config, EventManager $eventManager = null) + protected static function createConnection($connection, Configuration $config, EventManager $eventManager = null) { - if (is_array($conn)) { - return DriverManager::getConnection( - $conn, $config, ($eventManager ?: new EventManager()) - ); - } elseif ( ! $conn instanceof Connection) { - throw new \InvalidArgumentException("Invalid argument: " . $conn); + if (is_array($connection)) { + return DriverManager::getConnection($connection, $config, $eventManager ?: new EventManager()); } - return $conn; + if ( ! $connection instanceof Connection) { + throw new \InvalidArgumentException("Invalid argument: " . $connection); + } + + return $connection; } /** From fa7799cec155b501e610ff0f941cf9eb4053cce5 Mon Sep 17 00:00:00 2001 From: Peter Gribanov Date: Wed, 8 Jun 2016 12:24:41 +0300 Subject: [PATCH 024/144] return check EventManager --- lib/Doctrine/ORM/EntityManager.php | 5 +++++ lib/Doctrine/ORM/ORMException.php | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 97aab4f81..c889f90c2 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -851,6 +851,7 @@ use Doctrine\Common\Util\ClassUtils; * @return Connection * * @throws \InvalidArgumentException + * @throws ORMException */ protected static function createConnection($connection, Configuration $config, EventManager $eventManager = null) { @@ -862,6 +863,10 @@ use Doctrine\Common\Util\ClassUtils; throw new \InvalidArgumentException("Invalid argument: " . $connection); } + if ($eventManager !== null && $connection->getEventManager() !== $eventManager) { + throw ORMException::mismatchedEventManager(); + } + return $connection; } diff --git a/lib/Doctrine/ORM/ORMException.php b/lib/Doctrine/ORM/ORMException.php index 286eb26e8..6d8a6d631 100644 --- a/lib/Doctrine/ORM/ORMException.php +++ b/lib/Doctrine/ORM/ORMException.php @@ -154,6 +154,14 @@ class ORMException extends Exception return new self("'$mode' is an invalid hydration mode."); } + /** + * @return ORMException + */ + public static function mismatchedEventManager() + { + return new self("Cannot use different EventManager instances for EntityManager and Connection."); + } + /** * @param string $methodName * From 649ff94b387201d0991c989965b0c97eeae7ed90 Mon Sep 17 00:00:00 2001 From: Thomas Ploch Date: Wed, 8 Jun 2016 12:08:50 +0200 Subject: [PATCH 025/144] Remove EOL PHP 5.4 from .travis.yml - Fixes #5862 --- .travis.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d54f4386..5ecefb6cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.4 - 5.5 - 5.6 - 7.0 @@ -28,10 +27,6 @@ after_script: matrix: include: - - php: 5.4 - env: DB=mariadb - addons: - mariadb: 5.5 - php: 5.5 env: DB=mariadb addons: @@ -49,10 +44,6 @@ matrix: addons: mariadb: 5.5 - - php: 5.4 - env: DB=mariadb - addons: - mariadb: 10.1 - php: 5.5 env: DB=mariadb addons: From 68b0060595fe42804cd5648cd60f8ae56907a943 Mon Sep 17 00:00:00 2001 From: Thomas Ploch Date: Wed, 8 Jun 2016 12:11:11 +0200 Subject: [PATCH 026/144] Fixing PHP version constraint in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd1f81ade..1a943b871 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ ], "minimum-stability": "dev", "require": { - "php": ">=5.4", + "php": ">=5.5", "ext-pdo": "*", "doctrine/collections": "~1.2", "doctrine/dbal": ">=2.5-dev,<2.7-dev", From 650d49ee818b3c56d8efc101c11ab2c4f87a9522 Mon Sep 17 00:00:00 2001 From: Thomas Ploch Date: Wed, 8 Jun 2016 12:19:31 +0200 Subject: [PATCH 027/144] Tightened PHP version constraint in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1a943b871..1313f7b1b 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ ], "minimum-stability": "dev", "require": { - "php": ">=5.5", + "php": "^5.5 || ^7.0", "ext-pdo": "*", "doctrine/collections": "~1.2", "doctrine/dbal": ">=2.5-dev,<2.7-dev", From ea788fb73487038ad37fc6b5ffcdee4b13215526 Mon Sep 17 00:00:00 2001 From: Thomas Ploch Date: Tue, 7 Jun 2016 17:33:29 +0200 Subject: [PATCH 028/144] Exporters should only inspect `joinColumns` for owning side in bi-directional OneToOne rebased commits: - Added test case for bi-directional OneToOne in YamlExporter - Only inspect joinColumns for owning side in bi-directional OneToOne in YamlExporter - Adding bi-directional test case without joinColumn to XmlExporter test - Same testcase also applied to PhpExporter - Fixing bi-directional issue in PhpExporter when inspecting joinColumns index - Implemented @Ocramius suggestions --- lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php | 2 +- .../ORM/Tools/Export/Driver/YamlExporter.php | 2 +- .../php/Doctrine.Tests.ORM.Tools.Export.User.php | 12 ++++++++++++ .../xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml | 6 ++++++ .../Doctrine.Tests.ORM.Tools.Export.User.dcm.yml | 4 ++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php index 29eb37afc..5d88901a5 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php @@ -117,7 +117,7 @@ class PhpExporter extends AbstractExporter $oneToOneMappingArray = array( 'mappedBy' => $associationMapping['mappedBy'], 'inversedBy' => $associationMapping['inversedBy'], - 'joinColumns' => $associationMapping['joinColumns'], + 'joinColumns' => $associationMapping['isOwningSide'] ? $associationMapping['joinColumns'] : [], 'orphanRemoval' => $associationMapping['orphanRemoval'], ); diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php index 177cebfab..7677ad950 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php @@ -163,7 +163,7 @@ class YamlExporter extends AbstractExporter } if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) { - $joinColumns = $associationMapping['joinColumns']; + $joinColumns = $associationMapping['isOwningSide'] ? $associationMapping['joinColumns'] : []; $newJoinColumns = array(); foreach ($joinColumns as $joinColumn) { diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php b/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php index 8dc8e874d..4a379f82e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php @@ -62,6 +62,18 @@ $metadata->mapOneToOne(array( 'orphanRemoval' => true, 'fetch' => ClassMetadataInfo::FETCH_EAGER, )); +$metadata->mapOneToOne(array( + 'fieldName' => 'cart', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Cart', + 'mappedBy' => 'user', + 'cascade' => + array( + 0 => 'persist', + ), + 'inversedBy' => NULL, + 'orphanRemoval' => false, + 'fetch' => ClassMetadataInfo::FETCH_EAGER, +)); $metadata->mapOneToMany(array( 'fieldName' => 'phonenumbers', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Phonenumber', diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml b/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml index 70b1a8dae..8d0c5d217 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml @@ -35,6 +35,12 @@ + + + + + + diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml b/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml index 76c3902d6..d52e94601 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml +++ b/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml @@ -34,6 +34,10 @@ Doctrine\Tests\ORM\Tools\Export\User: inversedBy: user orphanRemoval: true fetch: EAGER + cart: + targetEntity: Doctrine\Tests\ORM\Tools\Export\Cart + mappedBy: user + cascade: [ remove ] manyToOne: mainGroup: targetEntity: Doctrine\Tests\ORM\Tools\Export\Group From 6ac7480df4dddeb1c024785e4f6b67ec5184e9e6 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Tue, 14 Jun 2016 04:32:20 +0300 Subject: [PATCH 029/144] Update query-builder.rst Removed one brace --- docs/en/reference/query-builder.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index 57eee179f..6b868c653 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -113,7 +113,7 @@ suggested standard way to build queries: $qb->expr()->eq('u.id', '?1'), $qb->expr()->like('u.nickname', '?2') )) - ->orderBy('u.surname', 'ASC')); + ->orderBy('u.surname', 'ASC'); Here is a complete list of helper methods available in ``QueryBuilder``: From 288e3191ce7053d06fdc9c8c36480859d3b87791 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 01:15:59 +0200 Subject: [PATCH 030/144] #5854 - simple workaround to avoid populating SLC cache from DQL queries with multiple nested DQL aliases --- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 07c9d8f43..93363e996 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -261,6 +261,14 @@ class DefaultQueryCache implements QueryCache // @TODO - move to cache hydration components foreach ($rsm->relationMap as $alias => $name) { $metadata = $this->em->getClassMetadata($rsm->aliasMap[$rsm->parentAliasMap[$alias]]); + $className = $metadata->getName(); + + if (! $entity instanceof $className) { + // this alias is not the root alias, therefore we skip it. $entity is always the root of the selection here + // @TODO should actually cache all aliases + continue; + } + $assoc = $metadata->associationMappings[$name]; if (($assocValue = $metadata->getFieldValue($entity, $name)) === null || $assocValue instanceof Proxy) { From be090e2f75339a2815d026290569b71a4e7cc552 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 01:26:51 +0200 Subject: [PATCH 031/144] #5854 removing failure caused by a `ReflectionProperty` being instantiated against the wrong class name in a test --- ...nStrictReadWriteCachedEntityPersisterTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 6cf3fea3b..df1f6ac59 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -2,14 +2,14 @@ namespace Doctrine\Tests\ORM\Cache\Persister\Entity; +use Doctrine\ORM\Cache\EntityCacheEntry; +use Doctrine\ORM\Cache\EntityCacheKey; +use Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManager; -use Doctrine\Tests\Models\Cache\Country; -use Doctrine\ORM\Cache\EntityCacheKey; -use Doctrine\ORM\Cache\EntityCacheEntry; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Entity\EntityPersister; -use Doctrine\ORM\Cache\Persister\Entity\NonStrictReadWriteCachedEntityPersister; +use Doctrine\Tests\Models\Cache\Country; /** * @group DDC-2183 @@ -28,7 +28,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste { $entity = new Country("Foo"); $persister = $this->createPersisterDefault(); - $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); + $property = new \ReflectionProperty($persister, 'queuedCache'); $property->setAccessible(true); @@ -50,7 +50,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $entry = new EntityCacheEntry(Country::CLASSNAME, array('id'=>1, 'name'=>'Foo')); - $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); + $property = new \ReflectionProperty($persister, 'queuedCache'); $property->setAccessible(true); @@ -87,7 +87,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $entry = new EntityCacheEntry(Country::CLASSNAME, array('id'=>1, 'name'=>'Foo')); - $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); + $property = new \ReflectionProperty($persister, 'queuedCache'); $property->setAccessible(true); @@ -115,7 +115,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste $entity = new Country("Foo"); $persister = $this->createPersisterDefault(); $key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); - $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); + $property = new \ReflectionProperty($persister, 'queuedCache'); $property->setAccessible(true); From c834ccf3fafbddc40b338c455090ddbfd360c89f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 01:27:22 +0200 Subject: [PATCH 032/144] #5854 added PHP 7.1 to the build matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5ecefb6cc..ce6a24f6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 - hhvm env: From 163dac4a9172ca31d162c9ccb275934d532f665b Mon Sep 17 00:00:00 2001 From: FabioBatSilva Date: Thu, 16 Jun 2016 10:05:56 -0400 Subject: [PATCH 033/144] #5854 - Fix SLC queries with multiple nested DQL aliases --- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 197 +++++++++++++----- .../Tests/ORM/Cache/DefaultQueryCacheTest.php | 57 ++++- .../SecondLevelCacheQueryCacheTest.php | 92 +++++++- 3 files changed, 288 insertions(+), 58 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 93363e996..dabf1721e 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -233,6 +233,7 @@ class DefaultQueryCache implements QueryCache $data = array(); $entityName = reset($rsm->aliasMap); + $rootAlias = key($rsm->aliasMap); $hasRelation = ( ! empty($rsm->relationMap)); $persister = $this->uow->getEntityPersister($entityName); @@ -244,10 +245,11 @@ class DefaultQueryCache implements QueryCache foreach ($result as $index => $entity) { $identifier = $this->uow->getEntityIdentifier($entity); + $entityKey = new EntityCacheKey($entityName, $identifier); $data[$index]['identifier'] = $identifier; $data[$index]['associations'] = array(); - if (($key->cacheMode & Cache::MODE_REFRESH) || ! $region->contains($entityKey = new EntityCacheKey($entityName, $identifier))) { + if (($key->cacheMode & Cache::MODE_REFRESH) || ! $region->contains($entityKey)) { // Cancel put result if entity put fail if ( ! $persister->storeEntityCache($entity, $entityKey)) { return false; @@ -260,75 +262,170 @@ class DefaultQueryCache implements QueryCache // @TODO - move to cache hydration components foreach ($rsm->relationMap as $alias => $name) { - $metadata = $this->em->getClassMetadata($rsm->aliasMap[$rsm->parentAliasMap[$alias]]); - $className = $metadata->getName(); + $parentAlias = $rsm->parentAliasMap[$alias]; + $parentClass = $rsm->aliasMap[$parentAlias]; + $metadata = $this->em->getClassMetadata($parentClass); + $assoc = $metadata->associationMappings[$name]; + $assocValue = $this->getAssociationValue($rsm, $alias, $entity); - if (! $entity instanceof $className) { - // this alias is not the root alias, therefore we skip it. $entity is always the root of the selection here - // @TODO should actually cache all aliases + if ($assocValue === null) { continue; } - $assoc = $metadata->associationMappings[$name]; - - if (($assocValue = $metadata->getFieldValue($entity, $name)) === null || $assocValue instanceof Proxy) { - continue; - } - - $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); - $assocRegion = $assocPersister->getCacheRegion(); - $assocMetadata = $assocPersister->getClassMetadata(); - - // Handle *-to-one associations - if ($assoc['type'] & ClassMetadata::TO_ONE) { - - $assocIdentifier = $this->uow->getEntityIdentifier($assocValue); - - if (($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier))) { - - // Cancel put result if association entity put fail - if ( ! $assocPersister->storeEntityCache($assocValue, $entityKey)) { - return false; - } + // root entity association + if ($rootAlias === $parentAlias) { + // Cancel put result if association put fail + if ( ($assocInfo = $this->storeAssociationCache($key, $assoc, $assocValue)) === null) { + return false; } - $data[$index]['associations'][$name] = array( - 'targetEntity' => $assocMetadata->rootEntityName, - 'identifier' => $assocIdentifier, - 'type' => $assoc['type'] - ); + $data[$index]['associations'][$name] = $assocInfo; continue; } - // Handle *-to-many associations - $list = array(); - - foreach ($assocValue as $assocItemIndex => $assocItem) { - $assocIdentifier = $this->uow->getEntityIdentifier($assocItem); - - if (($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier))) { - - // Cancel put result if entity put fail - if ( ! $assocPersister->storeEntityCache($assocItem, $entityKey)) { - return false; - } + // store single nested association + if ( ! is_array($assocValue)) { + // Cancel put result if association put fail + if ($this->storeAssociationCache($key, $assoc, $assocValue) === null) { + return false; } - $list[$assocItemIndex] = $assocIdentifier; + continue; } - $data[$index]['associations'][$name] = array( - 'targetEntity' => $assocMetadata->rootEntityName, - 'type' => $assoc['type'], - 'list' => $list, - ); + // store array of nested association + foreach ($assocValue as $aVal) { + // Cancel put result if association put fail + if ($this->storeAssociationCache($key, $assoc, $aVal) === null) { + return false; + } + } } } return $this->region->put($key, new QueryCacheEntry($data)); } + /** + * @param \Doctrine\ORM\Cache\QueryCacheKey $key + * @param array $assoc + * @param mixed $assocValue + * + * @return array|null + */ + private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocValue) + { + $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']); + $assocMetadata = $assocPersister->getClassMetadata(); + $assocRegion = $assocPersister->getCacheRegion(); + + // Handle *-to-one associations + if ($assoc['type'] & ClassMetadata::TO_ONE) { + $assocIdentifier = $this->uow->getEntityIdentifier($assocValue); + $entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier); + + if ( ! $assocValue instanceof Proxy && ($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey)) { + // Entity put fail + if ( ! $assocPersister->storeEntityCache($assocValue, $entityKey)) { + return null; + } + } + + return array( + 'targetEntity' => $assocMetadata->rootEntityName, + 'identifier' => $assocIdentifier, + 'type' => $assoc['type'] + ); + } + + // Handle *-to-many associations + $list = array(); + + foreach ($assocValue as $assocItemIndex => $assocItem) { + $assocIdentifier = $this->uow->getEntityIdentifier($assocItem); + $entityKey = new EntityCacheKey($assocMetadata->rootEntityName, $assocIdentifier); + + if (($key->cacheMode & Cache::MODE_REFRESH) || ! $assocRegion->contains($entityKey)) { + // Entity put fail + if ( ! $assocPersister->storeEntityCache($assocItem, $entityKey)) { + return null; + } + } + + $list[$assocItemIndex] = $assocIdentifier; + } + + return array( + 'targetEntity' => $assocMetadata->rootEntityName, + 'type' => $assoc['type'], + 'list' => $list, + ); + } + + /** + * @param \Doctrine\ORM\Query\ResultSetMapping $rsm + * @param string $assocAlias + * @param object $entity + * + * @return array|object + */ + private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity) + { + $path = array(); + $alias = $assocAlias; + + while (isset($rsm->parentAliasMap[$alias])) { + $parent = $rsm->parentAliasMap[$alias]; + $field = $rsm->relationMap[$alias]; + $class = $rsm->aliasMap[$parent]; + + array_unshift($path, array( + 'field' => $field, + 'class' => $class + )); + + $alias = $parent; + } + + return $this->getAssociationPathValue($entity, $path); + } + + /** + * @param mixed $value + * @param array $path + * + * @return array|object|null + */ + private function getAssociationPathValue($value, array $path) + { + $mapping = array_shift($path); + $metadata = $this->em->getClassMetadata($mapping['class']); + $assoc = $metadata->associationMappings[$mapping['field']]; + $value = $metadata->getFieldValue($value, $mapping['field']); + + if ($value === null) { + return null; + } + + if (empty($path)) { + return $value; + } + + // Handle *-to-one associations + if ($assoc['type'] & ClassMetadata::TO_ONE) { + return $this->getAssociationPathValue($value, $path); + } + + $values = array(); + + foreach ($value as $item) { + $values[] = $this->getAssociationPathValue($item, $path); + } + + return $values; + } + /** * {@inheritdoc} */ diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index 2de9c6698..b183eaed4 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -12,6 +12,7 @@ use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\Tests\Models\Cache\Country; use Doctrine\Tests\Models\Cache\City; use Doctrine\Tests\Models\Cache\State; +use Doctrine\Tests\Models\Cache\Restaurant; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Tests\Models\Generic\BooleanModel; use Doctrine\ORM\Cache\EntityCacheEntry; @@ -67,7 +68,7 @@ class DefaultQueryCacheTest extends OrmTestCase { $this->assertSame($this->region, $this->queryCache->getRegion()); } - + public function testClearShouldEvictRegion() { $this->queryCache->clear(); @@ -176,13 +177,13 @@ class DefaultQueryCacheTest extends OrmTestCase $countryClass->setFieldValue($country, 'id', $i*3); $uow->registerManaged($country, array('id' => $country->getId()), array('name' => $country->getName())); - $uow->registerManaged($state, array('id' => $state->getId()), array('name' => $city->getName(), 'country' => $country)); + $uow->registerManaged($state, array('id' => $state->getId()), array('name' => $state->getName(), 'country' => $country)); $uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => $state)); } $this->assertTrue($this->queryCache->put($key, $rsm, $result)); $this->assertArrayHasKey('put', $this->region->calls); - $this->assertCount(9, $this->region->calls['put']); + $this->assertCount(13, $this->region->calls['put']); $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][0]['key']); $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][1]['key']); @@ -192,7 +193,11 @@ class DefaultQueryCacheTest extends OrmTestCase $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][5]['key']); $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][6]['key']); $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][7]['key']); - $this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][8]['key']); + $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][8]['key']); + $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][9]['key']); + $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][10]['key']); + $this->assertInstanceOf('Doctrine\ORM\Cache\EntityCacheKey', $this->region->calls['put'][11]['key']); + $this->assertInstanceOf('Doctrine\ORM\Cache\QueryCacheKey', $this->region->calls['put'][12]['key']); } public function testPutToOneAssociationNullQueryResult() @@ -482,6 +487,50 @@ class DefaultQueryCacheTest extends OrmTestCase $this->assertNull($this->queryCache->get($key, $rsm)); } + public function testGetAssociationValue() + { + $reflection = new \ReflectionMethod($this->queryCache, 'getAssociationValue'); + $rsm = new ResultSetMappingBuilder($this->em); + $key = new QueryCacheKey('query.key1', 0); + + $reflection->setAccessible(true); + + $germany = new Country("Germany"); + $bavaria = new State("Bavaria", $germany); + $wurzburg = new City("Würzburg", $bavaria); + $munich = new City("Munich", $bavaria); + + $bavaria->addCity($munich); + $bavaria->addCity($wurzburg); + + $munich->addAttraction(new Restaurant('Reinstoff', $munich)); + $munich->addAttraction(new Restaurant('Schneider Weisse', $munich)); + $wurzburg->addAttraction(new Restaurant('Fischers Fritz', $wurzburg)); + + $rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's'); + $rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', array( + 'id' => 'c_id', + 'name' => 'c_name' + )); + $rsm->addJoinedEntityFromClassMetadata(Restaurant::CLASSNAME, 'a', 'c', 'attractions', array( + 'id' => 'a_id', + 'name' => 'a_name' + )); + + $cities = $reflection->invoke($this->queryCache, $rsm, 'c', $bavaria); + $attractions = $reflection->invoke($this->queryCache, $rsm, 'a', $bavaria); + + $this->assertCount(2, $cities); + $this->assertCount(2, $attractions); + + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $cities); + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $attractions[0]); + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $attractions[1]); + + $this->assertCount(2, $attractions[0]); + $this->assertCount(1, $attractions[1]); + } + /** * @expectedException Doctrine\ORM\Cache\CacheException * @expectedExceptionMessage Second level cache does not support scalar results. diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index f5e1df0a8..97d8ce82a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -3,10 +3,11 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\AbstractQuery; -use Doctrine\Tests\Models\Cache\Country; use Doctrine\ORM\Query\ResultSetMapping; -use Doctrine\Tests\Models\Cache\State; use Doctrine\Tests\Models\Cache\City; +use Doctrine\Tests\Models\Cache\State; +use Doctrine\Tests\Models\Cache\Country; +use Doctrine\Tests\Models\Cache\Attraction; use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\ORM\Cache\EntityCacheKey; use Doctrine\ORM\Cache\EntityCacheEntry; @@ -189,7 +190,7 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest $countryId2 = $this->countries[1]->getId(); $countryName1 = $this->countries[0]->getName(); $countryName2 = $this->countries[1]->getName(); - + $key1 = new EntityCacheKey(Country::CLASSNAME, array('id'=>$countryId1)); $key2 = new EntityCacheKey(Country::CLASSNAME, array('id'=>$countryId2)); $entry1 = new EntityCacheEntry(Country::CLASSNAME, array('id'=>$countryId1, 'name'=>'outdated')); @@ -283,6 +284,89 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionMissCount($this->getDefaultQueryRegionName())); } + /** + * @group 5854 + */ + public function testMultipleNestedDQLAliases() + { + $this->loadFixturesCountries(); + $this->loadFixturesStates(); + $this->loadFixturesCities(); + $this->loadFixturesAttractions(); + + $queryRegionName = $this->getDefaultQueryRegionName(); + $cityRegionName = $this->getEntityRegion(City::CLASSNAME); + $stateRegionName = $this->getEntityRegion(State::CLASSNAME); + $attractionRegionName = $this->getEntityRegion(Attraction::CLASSNAME); + + $this->secondLevelCacheLogger->clearStats(); + $this->evictRegions(); + $this->_em->clear(); + + $queryCount = $this->getCurrentQueryCount(); + $dql = 'SELECT s, c, a FROM Doctrine\Tests\Models\Cache\State s JOIN s.cities c JOIN c.attractions a'; + $result1 = $this->_em->createQuery($dql) + ->setCacheable(true) + ->getResult(); + + $this->assertCount(2, $result1); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + + $this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[0]->getId())); + $this->assertTrue($this->cache->containsEntity(State::CLASSNAME, $this->states[1]->getId())); + + $this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId())); + $this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId())); + $this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[2]->getId())); + $this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId())); + + $this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[0]->getId())); + $this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[1]->getId())); + $this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[2]->getId())); + $this->assertTrue($this->cache->containsEntity(Attraction::CLASSNAME, $this->attractions[3]->getId())); + + $this->assertInstanceOf(State::CLASSNAME, $result1[0]); + $this->assertInstanceOf(State::CLASSNAME, $result1[1]); + + $this->assertCount(2, $result1[0]->getCities()); + $this->assertCount(2, $result1[1]->getCities()); + + $this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(0)); + $this->assertInstanceOf(City::CLASSNAME, $result1[0]->getCities()->get(1)); + $this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(0)); + $this->assertInstanceOf(City::CLASSNAME, $result1[1]->getCities()->get(1)); + + $this->assertCount(2, $result1[0]->getCities()->get(0)->getAttractions()); + $this->assertCount(2, $result1[0]->getCities()->get(1)->getAttractions()); + $this->assertCount(2, $result1[1]->getCities()->get(0)->getAttractions()); + $this->assertCount(1, $result1[1]->getCities()->get(1)->getAttractions()); + + $this->_em->clear(); + + $result2 = $this->_em->createQuery($dql) + ->setCacheable(true) + ->getResult(); + + $this->assertCount(2, $result2); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + + $this->assertInstanceOf(State::CLASSNAME, $result2[0]); + $this->assertInstanceOf(State::CLASSNAME, $result2[1]); + + $this->assertCount(2, $result2[0]->getCities()); + $this->assertCount(2, $result2[1]->getCities()); + + $this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(0)); + $this->assertInstanceOf(City::CLASSNAME, $result2[0]->getCities()->get(1)); + $this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(0)); + $this->assertInstanceOf(City::CLASSNAME, $result2[1]->getCities()->get(1)); + + $this->assertCount(2, $result2[0]->getCities()->get(0)->getAttractions()); + $this->assertCount(2, $result2[0]->getCities()->get(1)->getAttractions()); + $this->assertCount(2, $result2[1]->getCities()->get(0)->getAttractions()); + $this->assertCount(1, $result2[1]->getCities()->get(1)->getAttractions()); + } + public function testBasicQueryParams() { $this->evictRegions(); @@ -340,7 +424,7 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest $this->assertEquals($this->countries[1]->getId(), $result1[1]->getId()); $this->assertEquals($this->countries[0]->getName(), $result1[0]->getName()); $this->assertEquals($this->countries[1]->getName(), $result1[1]->getName()); - + $this->assertEquals(3, $this->secondLevelCacheLogger->getPutCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getMissCount()); $this->assertEquals(1, $this->secondLevelCacheLogger->getRegionPutCount($this->getDefaultQueryRegionName())); From 9da83cfae87f3d46ead8795628b0097d4d049c63 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sat, 18 Jun 2016 13:01:59 +0200 Subject: [PATCH 034/144] Make test suite compatible with PHPUnit 5.4. * Use createMock() and getMockBuilder() instead of getMock() * Use expectException() and expectExceptionMessage() instead of setExpectedException() --- composer.json | 2 +- .../Tests/ORM/Cache/CacheConfigTest.php | 11 ++- .../Tests/ORM/Cache/CacheLoggerChainTest.php | 3 +- .../ORM/Cache/DefaultCacheFactoryTest.php | 13 +-- .../Tests/ORM/Cache/DefaultRegionTest.php | 5 +- .../AbstractCollectionPersisterTest.php | 11 +-- ...ReadWriteCachedCollectionPersisterTest.php | 5 +- .../Entity/AbstractEntityPersisterTest.php | 11 +-- .../ReadWriteCachedEntityPersisterTest.php | 5 +- .../Doctrine/Tests/ORM/ConfigurationTest.php | 81 ++++++++++++------- .../Decorator/EntityManagerDecoratorTest.php | 3 +- .../Doctrine/Tests/ORM/EntityManagerTest.php | 14 +++- .../OnClassMetadataNotFoundEventArgsTest.php | 6 +- .../ORM/Functional/BasicFunctionalTest.php | 17 ++-- .../Functional/CompositePrimaryKeyTest.php | 14 +++- .../ORM/Functional/DetachedEntityTest.php | 5 +- .../ORM/Functional/EntityRepositoryTest.php | 35 +++++--- .../Tests/ORM/Functional/Locking/LockTest.php | 22 +++-- .../Tests/ORM/Functional/NativeQueryTest.php | 12 +-- .../Tests/ORM/Functional/PaginationTest.php | 21 ++--- .../ORM/Functional/PostLoadEventTest.php | 18 ++--- .../Tests/ORM/Functional/QueryCacheTest.php | 19 +++-- .../Tests/ORM/Functional/QueryTest.php | 25 +++--- .../Functional/SingleTableInheritanceTest.php | 5 +- .../ORM/Functional/Ticket/DDC1685Test.php | 4 +- .../ORM/Functional/Ticket/DDC2359Test.php | 31 ++++--- .../ORM/Functional/Ticket/DDC2692Test.php | 5 +- .../ORM/Functional/Ticket/DDC3123Test.php | 4 +- .../Functional/UnitOfWorkLifecycleTest.php | 21 +++-- .../Tests/ORM/Functional/ValueObjectsTest.php | 14 ++-- .../ORM/Hydration/ObjectHydratorTest.php | 13 ++- .../Internal/HydrationCompleteHandlerTest.php | 16 ++-- .../Tests/ORM/LazyCriteriaCollectionTest.php | 3 +- .../ORM/Mapping/AbstractMappingDriverTest.php | 8 +- .../ORM/Mapping/AnnotationDriverTest.php | 27 ++++--- .../Mapping/BasicInheritanceMappingTest.php | 12 +-- .../ORM/Mapping/ClassMetadataBuilderTest.php | 8 +- .../ORM/Mapping/ClassMetadataFactoryTest.php | 31 +++---- .../Tests/ORM/Mapping/ClassMetadataTest.php | 50 +++++++----- .../ReflectionPropertiesGetterTest.php | 4 +- .../Mapping/Symfony/AbstractDriverTest.php | 13 ++- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 8 +- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 5 +- .../ORM/Query/LanguageRecognitionTest.php | 2 +- .../Tests/ORM/Query/ParserResultTest.php | 3 +- tests/Doctrine/Tests/ORM/Query/ParserTest.php | 3 +- .../ORM/Query/SelectSqlGenerationTest.php | 5 +- tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 3 +- .../DefaultRepositoryFactoryTest.php | 12 +-- .../ConvertDoctrine1SchemaCommandTest.php | 6 +- .../Tests/ORM/Tools/EntityGeneratorTest.php | 12 ++- .../ORM/Tools/Pagination/CountWalkerTest.php | 6 +- tests/Doctrine/Tests/ORM/Tools/SetupTest.php | 5 +- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 6 +- .../Doctrine/Tests/OrmFunctionalTestCase.php | 2 +- 55 files changed, 443 insertions(+), 262 deletions(-) diff --git a/composer.json b/composer.json index 1313f7b1b..f8ebcbf15 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "require-dev": { "symfony/yaml": "~2.3|~3.0", - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^5.4" }, "suggest": { "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index 412d30207..321207c39 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -2,8 +2,11 @@ namespace Doctrine\Tests\ORM\Cache; -use Doctrine\Tests\DoctrineTestCase; use Doctrine\ORM\Cache\CacheConfiguration; +use Doctrine\ORM\Cache\CacheFactory; +use Doctrine\ORM\Cache\QueryCacheValidator; +use Doctrine\ORM\Cache\Logging\CacheLogger; +use Doctrine\Tests\DoctrineTestCase; /** * @group DDC-2183 @@ -42,7 +45,7 @@ class CacheConfigTest extends DoctrineTestCase public function testSetGetCacheLogger() { - $logger = $this->getMock('Doctrine\ORM\Cache\Logging\CacheLogger'); + $logger = $this->createMock(CacheLogger::class); $this->assertNull($this->config->getCacheLogger()); @@ -53,7 +56,7 @@ class CacheConfigTest extends DoctrineTestCase public function testSetGetCacheFactory() { - $factory = $this->getMock('Doctrine\ORM\Cache\CacheFactory'); + $factory = $this->createMock(CacheFactory::class); $this->assertNull($this->config->getCacheFactory()); @@ -64,7 +67,7 @@ class CacheConfigTest extends DoctrineTestCase public function testSetGetQueryValidator() { - $validator = $this->getMock('Doctrine\ORM\Cache\QueryCacheValidator'); + $validator = $this->createMock(QueryCacheValidator::class); $this->assertInstanceOf('Doctrine\ORM\Cache\TimestampQueryCacheValidator', $this->config->getQueryValidator()); diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php index 8f8c65c0f..0af90cb07 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Cache; +use Doctrine\ORM\Cache\Logging\CacheLogger; use Doctrine\ORM\Cache\Logging\CacheLoggerChain; use Doctrine\ORM\Cache\CollectionCacheKey; use Doctrine\ORM\Cache\EntityCacheKey; @@ -29,7 +30,7 @@ class CacheLoggerChainTest extends DoctrineTestCase parent::setUp(); $this->logger = new CacheLoggerChain(); - $this->mock = $this->getMock('Doctrine\ORM\Cache\Logging\CacheLogger'); + $this->mock = $this->createMock(CacheLogger::class); } public function testGetAndSetLogger() diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php index 499914270..40c997d42 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -2,6 +2,8 @@ namespace Doctrine\Tests\ORM\Cache; +use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Cache\CacheProvider; use \Doctrine\Tests\OrmTestCase; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Cache\DefaultCacheFactory; @@ -39,9 +41,10 @@ class DefaultCacheFactoryTest extends OrmTestCase $this->em = $this->_getTestEntityManager(); $this->regionsConfig = new RegionsConfiguration; $arguments = array($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); - $this->factory = $this->getMock('\Doctrine\ORM\Cache\DefaultCacheFactory', array( - 'getRegion' - ), $arguments); + $this->factory = $this->getMockBuilder(DefaultCacheFactory::class) + ->setMethods(array('getRegion')) + ->setConstructorArgs($arguments) + ->getMock(); } public function testImplementsCacheFactory() @@ -284,7 +287,7 @@ class DefaultCacheFactoryTest extends OrmTestCase public function testBuildsDefaultCacheRegionFromGenericCacheRegion() { /* @var $cache \Doctrine\Common\Cache\Cache */ - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + $cache = $this->createMock(Cache::class); $factory = new DefaultCacheFactory($this->regionsConfig, $cache); @@ -300,7 +303,7 @@ class DefaultCacheFactoryTest extends OrmTestCase public function testBuildsMultiGetCacheRegionFromGenericCacheRegion() { /* @var $cache \Doctrine\Common\Cache\CacheProvider */ - $cache = $this->getMockForAbstractClass('Doctrine\Common\Cache\CacheProvider'); + $cache = $this->getMockForAbstractClass(CacheProvider::class); $factory = new DefaultCacheFactory($this->regionsConfig, $cache); diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php index 94f17c1d1..2bcc1fc21 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultRegionTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Cache; use Doctrine\Common\Cache\ApcCache; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\Common\Cache\Cache; use Doctrine\ORM\Cache\CollectionCacheEntry; use Doctrine\ORM\Cache\Region\DefaultRegion; use Doctrine\Tests\Mocks\CacheEntryMock; @@ -66,11 +67,11 @@ class DefaultRegionTest extends AbstractRegionTest public function testEvictAllWithGenericCacheThrowsUnsupportedException() { /* @var $cache \Doctrine\Common\Cache\Cache */ - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + $cache = $this->createMock(Cache::class); $region = new DefaultRegion('foo', $cache); - $this->setExpectedException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $region->evictAll(); } diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php index e93924d4a..adc8ec0ba 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/AbstractCollectionPersisterTest.php @@ -80,10 +80,9 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase $this->em = $this->_getTestEntityManager(); $this->region = $this->createRegion(); - $this->collectionPersister = $this->getMock( - 'Doctrine\ORM\Persisters\Collection\CollectionPersister', - $this->collectionPersisterMockMethods - ); + $this->collectionPersister = $this->getMockBuilder(CollectionPersister::class) + ->setMethods($this->collectionPersisterMockMethods) + ->getMock(); } /** @@ -91,7 +90,9 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase */ protected function createRegion() { - return $this->getMock('Doctrine\ORM\Cache\Region', $this->regionMockMethods); + return $this->getMockBuilder(Region::class) + ->setMethods($this->regionMockMethods) + ->getMock(); } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php index 529da203f..b41d27ab1 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Collection/ReadWriteCachedCollectionPersisterTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Cache\Persister\Collection; +use Doctrine\ORM\Cache\ConcurrentRegion; use Doctrine\ORM\Cache\Lock; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManager; @@ -40,7 +41,9 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister */ protected function createRegion() { - return $this->getMock('Doctrine\ORM\Cache\ConcurrentRegion', $this->regionMockMethods); + return $this->getMockBuilder(ConcurrentRegion::class) + ->setMethods($this->regionMockMethods) + ->getMock(); } public function testDeleteShouldLockItem() diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php index bf94b1e46..83fd3ad85 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/AbstractEntityPersisterTest.php @@ -99,10 +99,9 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase $this->em = $this->_getTestEntityManager(); $this->region = $this->createRegion(); - $this->entityPersister = $this->getMock( - 'Doctrine\ORM\Persisters\Entity\EntityPersister', - $this->entityPersisterMockMethods - ); + $this->entityPersister = $this->getMockBuilder(EntityPersister::class) + ->setMethods($this->entityPersisterMockMethods) + ->getMock(); } /** @@ -110,7 +109,9 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase */ protected function createRegion() { - return $this->getMock('Doctrine\ORM\Cache\Region', $this->regionMockMethods); + return $this->getMockBuilder(Region::class) + ->setMethods($this->regionMockMethods) + ->getMock(); } /** diff --git a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 054bf951d..dc9fef43a 100644 --- a/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Cache\Persister\Entity; +use Doctrine\ORM\Cache\ConcurrentRegion; use Doctrine\ORM\Cache\Region; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Cache\Lock; @@ -41,7 +42,9 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest */ protected function createRegion() { - return $this->getMock('Doctrine\ORM\Cache\ConcurrentRegion', $this->regionMockMethods); + return $this->getMockBuilder(ConcurrentRegion::class) + ->setConstructorArgs($this->regionMockMethods) + ->getMock(); } public function testDeleteShouldLockItem() diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 0431eff39..d99d2b1e8 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -2,10 +2,18 @@ namespace Doctrine\Tests\ORM; +use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Mapping as AnnotationNamespace; use Doctrine\ORM\Configuration; +use Doctrine\ORM\Mapping\EntityListenerResolver; +use Doctrine\ORM\Mapping\NamingStrategy; +use Doctrine\ORM\Mapping\QuoteStrategy; +use Doctrine\ORM\ORMException; +use Doctrine\ORM\Query\ResultSetMapping; use ReflectionClass; use PHPUnit_Framework_TestCase; @@ -60,7 +68,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->assertSame(null, $this->configuration->getMetadataDriverImpl()); // defaults - $metadataDriver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $metadataDriver = $this->createMock(MappingDriver::class); $this->configuration->setMetadataDriverImpl($metadataDriver); $this->assertSame($metadataDriver, $this->configuration->getMetadataDriverImpl()); } @@ -94,14 +102,14 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $namespaces = array('OtherNamespace' => __NAMESPACE__); $this->configuration->setEntityNamespaces($namespaces); $this->assertSame($namespaces, $this->configuration->getEntityNamespaces()); - $this->setExpectedException('Doctrine\ORM\ORMException'); + $this->expectException(\Doctrine\ORM\ORMException::class); $this->configuration->getEntityNamespace('NonExistingNamespace'); } public function testSetGetQueryCacheImpl() { $this->assertSame(null, $this->configuration->getQueryCacheImpl()); // defaults - $queryCacheImpl = $this->getMock('Doctrine\Common\Cache\Cache'); + $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setQueryCacheImpl($queryCacheImpl); $this->assertSame($queryCacheImpl, $this->configuration->getQueryCacheImpl()); } @@ -109,7 +117,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase public function testSetGetHydrationCacheImpl() { $this->assertSame(null, $this->configuration->getHydrationCacheImpl()); // defaults - $queryCacheImpl = $this->getMock('Doctrine\Common\Cache\Cache'); + $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setHydrationCacheImpl($queryCacheImpl); $this->assertSame($queryCacheImpl, $this->configuration->getHydrationCacheImpl()); } @@ -117,7 +125,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase public function testSetGetMetadataCacheImpl() { $this->assertSame(null, $this->configuration->getMetadataCacheImpl()); // defaults - $queryCacheImpl = $this->getMock('Doctrine\Common\Cache\Cache'); + $queryCacheImpl = $this->createMock(Cache::class); $this->configuration->setMetadataCacheImpl($queryCacheImpl); $this->assertSame($queryCacheImpl, $this->configuration->getMetadataCacheImpl()); } @@ -127,19 +135,19 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $dql = 'SELECT u FROM User u'; $this->configuration->addNamedQuery('QueryName', $dql); $this->assertSame($dql, $this->configuration->getNamedQuery('QueryName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); + $this->expectException(\Doctrine\ORM\ORMException::class); $this->configuration->getNamedQuery('NonExistingQuery'); } public function testAddGetNamedNativeQuery() { $sql = 'SELECT * FROM user'; - $rsm = $this->getMock('Doctrine\ORM\Query\ResultSetMapping'); + $rsm = $this->createMock(ResultSetMapping::class); $this->configuration->addNamedNativeQuery('QueryName', $sql, $rsm); $fetched = $this->configuration->getNamedNativeQuery('QueryName'); $this->assertSame($sql, $fetched[0]); $this->assertSame($rsm, $fetched[1]); - $this->setExpectedException('Doctrine\ORM\ORMException'); + $this->expectException(\Doctrine\ORM\ORMException::class); $this->configuration->getNamedQuery('NonExistingQuery'); } @@ -152,7 +160,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_NEVER); - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + $cache = $this->createMock(Cache::class); if ('query' !== $skipCache) { $this->configuration->setQueryCacheImpl($cache); @@ -172,14 +180,20 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase public function testEnsureProductionSettingsQueryCache() { $this->setProductionSettings('query'); - $this->setExpectedException('Doctrine\ORM\ORMException', 'Query Cache is not configured.'); + + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Query Cache is not configured.'); + $this->configuration->ensureProductionSettings(); } public function testEnsureProductionSettingsMetadataCache() { $this->setProductionSettings('metadata'); - $this->setExpectedException('Doctrine\ORM\ORMException', 'Metadata Cache is not configured.'); + + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Metadata Cache is not configured.'); + $this->configuration->ensureProductionSettings(); } @@ -187,9 +201,10 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->setProductionSettings(); $this->configuration->setQueryCacheImpl(new ArrayCache()); - $this->setExpectedException( - 'Doctrine\ORM\ORMException', - 'Query Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.'); + + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Query Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.'); + $this->configuration->ensureProductionSettings(); } @@ -197,9 +212,10 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->setProductionSettings(); $this->configuration->setMetadataCacheImpl(new ArrayCache()); - $this->setExpectedException( - 'Doctrine\ORM\ORMException', - 'Metadata Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.'); + + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Metadata Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.'); + $this->configuration->ensureProductionSettings(); } @@ -207,7 +223,10 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->setProductionSettings(); $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_ALWAYS); - $this->setExpectedException('Doctrine\ORM\ORMException', 'Proxy Classes are always regenerating.'); + + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Proxy Classes are always regenerating.'); + $this->configuration->ensureProductionSettings(); } @@ -215,7 +234,10 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->setProductionSettings(); $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS); - $this->setExpectedException('Doctrine\ORM\ORMException', 'Proxy Classes are always regenerating.'); + + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Proxy Classes are always regenerating.'); + $this->configuration->ensureProductionSettings(); } @@ -223,7 +245,10 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->setProductionSettings(); $this->configuration->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_EVAL); - $this->setExpectedException('Doctrine\ORM\ORMException', 'Proxy Classes are always regenerating.'); + + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Proxy Classes are always regenerating.'); + $this->configuration->ensureProductionSettings(); } @@ -234,7 +259,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); $this->configuration->setCustomStringFunctions(array('OtherFunctionName' => __CLASS__)); $this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('OtherFunctionName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); + $this->expectException(\Doctrine\ORM\ORMException::class); $this->configuration->addCustomStringFunction('concat', __CLASS__); } @@ -245,7 +270,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); $this->configuration->setCustomNumericFunctions(array('OtherFunctionName' => __CLASS__)); $this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('OtherFunctionName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); + $this->expectException(\Doctrine\ORM\ORMException::class); $this->configuration->addCustomNumericFunction('abs', __CLASS__); } @@ -256,7 +281,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); $this->configuration->setCustomDatetimeFunctions(array('OtherFunctionName' => __CLASS__)); $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); - $this->setExpectedException('Doctrine\ORM\ORMException'); + $this->expectException(\Doctrine\ORM\ORMException::class); $this->configuration->addCustomDatetimeFunction('date_add', __CLASS__); } @@ -302,14 +327,14 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase $repositoryClass = 'Doctrine\Tests\Models\DDC753\DDC753CustomRepository'; $this->configuration->setDefaultRepositoryClassName($repositoryClass); $this->assertSame($repositoryClass, $this->configuration->getDefaultRepositoryClassName()); - $this->setExpectedException('Doctrine\ORM\ORMException'); + $this->expectException(\Doctrine\ORM\ORMException::class); $this->configuration->setDefaultRepositoryClassName(__CLASS__); } public function testSetGetNamingStrategy() { $this->assertInstanceOf('Doctrine\ORM\Mapping\NamingStrategy', $this->configuration->getNamingStrategy()); - $namingStrategy = $this->getMock('Doctrine\ORM\Mapping\NamingStrategy'); + $namingStrategy = $this->createMock(NamingStrategy::class); $this->configuration->setNamingStrategy($namingStrategy); $this->assertSame($namingStrategy, $this->configuration->getNamingStrategy()); } @@ -317,7 +342,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase public function testSetGetQuoteStrategy() { $this->assertInstanceOf('Doctrine\ORM\Mapping\QuoteStrategy', $this->configuration->getQuoteStrategy()); - $quoteStrategy = $this->getMock('Doctrine\ORM\Mapping\QuoteStrategy'); + $quoteStrategy = $this->createMock(QuoteStrategy::class); $this->configuration->setQuoteStrategy($quoteStrategy); $this->assertSame($quoteStrategy, $this->configuration->getQuoteStrategy()); } @@ -329,7 +354,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase { $this->assertInstanceOf('Doctrine\ORM\Mapping\EntityListenerResolver', $this->configuration->getEntityListenerResolver()); $this->assertInstanceOf('Doctrine\ORM\Mapping\DefaultEntityListenerResolver', $this->configuration->getEntityListenerResolver()); - $resolver = $this->getMock('Doctrine\ORM\Mapping\EntityListenerResolver'); + $resolver = $this->createMock(EntityListenerResolver::class); $this->configuration->setEntityListenerResolver($resolver); $this->assertSame($resolver, $this->configuration->getEntityListenerResolver()); } @@ -339,7 +364,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase */ public function testSetGetSecondLevelCacheConfig() { - $mockClass = $this->getMock('Doctrine\ORM\Cache\CacheConfiguration'); + $mockClass = $this->createMock(CacheConfiguration::class); $this->assertNull($this->configuration->getSecondLevelCacheConfiguration()); $this->configuration->setSecondLevelCacheConfiguration($mockClass); diff --git a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php index fb2c4ea42..c52ce550c 100644 --- a/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php +++ b/tests/Doctrine/Tests/ORM/Decorator/EntityManagerDecoratorTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Decorator; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\ResultSetMapping; class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase @@ -11,7 +12,7 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->wrapped = $this->getMock('Doctrine\ORM\EntityManagerInterface'); + $this->wrapped = $this->createMock(EntityManagerInterface::class); $this->decorator = $this->getMockBuilder('Doctrine\ORM\Decorator\EntityManagerDecorator') ->setConstructorArgs(array($this->wrapped)) ->setMethods(null) diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 797e60173..cf6fc99a4 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -2,6 +2,8 @@ namespace Doctrine\Tests\ORM; +use Doctrine\ORM\ORMException; +use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\Tests\OrmTestCase; @@ -142,8 +144,9 @@ class EntityManagerTest extends OrmTestCase * @dataProvider dataMethodsAffectedByNoObjectArguments */ public function testThrowsExceptionOnNonObjectValues($methodName) { - $this->setExpectedException('Doctrine\ORM\ORMInvalidArgumentException', - 'EntityManager#'.$methodName.'() expects parameter 1 to be an entity object, NULL given.'); + $this->expectException(ORMInvalidArgumentException::class); + $this->expectExceptionMessage('EntityManager#' . $methodName . '() expects parameter 1 to be an entity object, NULL given.'); + $this->_em->$methodName(null); } @@ -164,7 +167,8 @@ class EntityManagerTest extends OrmTestCase */ public function testAffectedByErrorIfClosedException($methodName) { - $this->setExpectedException('Doctrine\ORM\ORMException', 'closed'); + $this->expectException(ORMException::class); + $this->expectExceptionMessage('closed'); $this->_em->close(); $this->_em->$methodName(new \stdClass()); @@ -189,7 +193,9 @@ class EntityManagerTest extends OrmTestCase public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed() { - $this->setExpectedException('InvalidArgumentException', 'Expected argument of type "callable", got "object"'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Expected argument of type "callable", got "object"'); + $this->_em->transactional($this); } diff --git a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php index 3aad1c04c..54f2feb0d 100644 --- a/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php +++ b/tests/Doctrine/Tests/ORM/Event/OnClassMetadataNotFoundEventArgsTest.php @@ -2,6 +2,8 @@ namespace Doctrine\Tests\ORM; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\ObjectManager; use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; use PHPUnit_Framework_TestCase; @@ -15,7 +17,7 @@ class OnClassMetadataNotFoundEventArgsTest extends PHPUnit_Framework_TestCase public function testEventArgsMutability() { /* @var $objectManager \Doctrine\Common\Persistence\ObjectManager */ - $objectManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + $objectManager = $this->createMock(ObjectManager::class); $args = new OnClassMetadataNotFoundEventArgs('foo', $objectManager); @@ -25,7 +27,7 @@ class OnClassMetadataNotFoundEventArgsTest extends PHPUnit_Framework_TestCase $this->assertNull($args->getFoundMetadata()); /* @var $metadata \Doctrine\Common\Persistence\Mapping\ClassMetadata */ - $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $metadata = $this->createMock(ClassMetadata::class); $args->setFoundMetadata($metadata); diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php index 2046d59a0..bee055f84 100644 --- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Logging\DebugStack; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\Query; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Models\CMS\CmsUser; @@ -1118,7 +1119,9 @@ class BasicFunctionalTest extends OrmFunctionalTestCase $user->username = 'domnikl'; $user->status = 'developer'; - $this->setExpectedException('InvalidArgumentException', 'Entity has to be managed or scheduled for removal for single computation'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Entity has to be managed or scheduled for removal for single computation'); + $this->_em->flush($user); } @@ -1195,7 +1198,9 @@ class BasicFunctionalTest extends OrmFunctionalTestCase $article1->author = $user; $user->articles[] = $article1; - $this->setExpectedException('InvalidArgumentException', "A new entity was found through the relationship 'Doctrine\Tests\Models\CMS\CmsUser#articles'"); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage("A new entity was found through the relationship 'Doctrine\Tests\Models\CMS\CmsUser#articles'"); + $this->_em->flush($user); } @@ -1291,10 +1296,10 @@ class BasicFunctionalTest extends OrmFunctionalTestCase $user->status = 'developer'; $user->address = $user; - $this->setExpectedException( - 'Doctrine\ORM\ORMInvalidArgumentException', - 'Expected value of type "Doctrine\Tests\Models\CMS\CmsAddress" for association field ' - . '"Doctrine\Tests\Models\CMS\CmsUser#$address", got "Doctrine\Tests\Models\CMS\CmsUser" instead.' + $this->expectException(ORMInvalidArgumentException::class); + $this->expectExceptionMessage( + 'Expected value of type "Doctrine\Tests\Models\CMS\CmsAddress" for association field ' . + '"Doctrine\Tests\Models\CMS\CmsUser#$address", got "Doctrine\Tests\Models\CMS\CmsUser" instead.' ); $this->_em->persist($user); diff --git a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php index 835328d75..1df74636c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -1,6 +1,8 @@ setExpectedException('Doctrine\ORM\Query\QueryException', 'A single-valued association path expression to an entity with a composite primary key is not supported.'); + $this->expectException(QueryException::class); + $this->expectExceptionMessage('A single-valued association path expression to an entity with a composite primary key is not supported.'); + $sql = $this->_em->createQuery($dql)->getSQL(); } @@ -133,13 +137,17 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase public function testSpecifyUnknownIdentifierPrimaryKeyFails() { - $this->setExpectedException('Doctrine\ORM\ORMException', 'The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); + $this->expectException(ORMException::class); + $this->expectExceptionMessage('The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); + $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('key1' => 100)); } public function testUnrecognizedIdentifierFieldsOnGetReference() { - $this->setExpectedException('Doctrine\ORM\ORMException', "Unrecognized identifier fields: 'key1'"); + $this->expectException(ORMException::class); + $this->expectExceptionMessage("Unrecognized identifier fields: 'key1'"); + $poi = $this->_em->getReference('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 10, 'long' => 20, 'key1' => 100)); } diff --git a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php index c78d25859..d067836f7 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\OptimisticLockException; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsPhonenumber; use Doctrine\Tests\Models\CMS\CmsAddress; @@ -217,7 +218,9 @@ class DetachedEntityTest extends OrmFunctionalTestCase $sql = "UPDATE cms_articles SET version = version+1 WHERE id = " . $article->id; $this->_em->getConnection()->executeUpdate($sql); - $this->setExpectedException('Doctrine\ORM\OptimisticLockException', 'The optimistic lock failed, version 1 was expected, but is actually 2'); + $this->expectException(OptimisticLockException::class); + $this->expectExceptionMessage('The optimistic lock failed, version 1 was expected, but is actually 2'); + $this->_em->merge($article); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index 685478f35..ffca89ba0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -4,6 +4,9 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\DBAL\Connection; use Doctrine\DBAL\LockMode; +use Doctrine\ORM\OptimisticLockException; +use Doctrine\ORM\ORMException; +use Doctrine\ORM\TransactionRequiredException; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\CMS\CmsEmail; use Doctrine\Tests\Models\CMS\CmsAddress; @@ -291,7 +294,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testPessimisticReadLockWithoutTransaction_ThrowsException() { - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + $this->expectException(TransactionRequiredException::class); $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') ->find(1, LockMode::PESSIMISTIC_READ); @@ -303,7 +306,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testPessimisticWriteLockWithoutTransaction_ThrowsException() { - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + $this->expectException(TransactionRequiredException::class); $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') ->find(1, LockMode::PESSIMISTIC_WRITE); @@ -315,7 +318,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testOptimisticLockUnversionedEntity_ThrowsException() { - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); + $this->expectException(OptimisticLockException::class); $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') ->find(1, LockMode::OPTIMISTIC); @@ -338,7 +341,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); + $this->expectException(OptimisticLockException::class); + $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId, LockMode::OPTIMISTIC); } @@ -360,7 +364,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testInvalidMagicCall() { - $this->setExpectedException('BadMethodCallException'); + $this->expectException(\BadMethodCallException::class); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos->foo(); @@ -374,7 +378,9 @@ class EntityRepositoryTest extends OrmFunctionalTestCase list($userId, $addressId) = $this->loadAssociatedFixture(); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $this->setExpectedException('Doctrine\ORM\ORMException', "You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations."); + $this->expectException(ORMException::class); + $this->expectExceptionMessage("You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations."); + $user = $repos->findBy(array('address' => $addressId)); } @@ -460,7 +466,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase { $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $repos->createNamedQuery('invalidNamedQuery'); } @@ -658,7 +664,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testInvalidOrientation() { - $this->setExpectedException('Doctrine\ORM\ORMException', 'Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username'); + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username'); $repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repo->findBy(array('status' => 'test'), array('username' => 'INVALID')); @@ -918,7 +925,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testFindByFieldInjectionPrevented() { - $this->setExpectedException('Doctrine\ORM\ORMException', 'Unrecognized field: '); + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Unrecognized field: '); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository->findBy(array('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test')); @@ -929,7 +937,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testFindOneByFieldInjectionPrevented() { - $this->setExpectedException('Doctrine\ORM\ORMException', 'Unrecognized field: '); + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Unrecognized field: '); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository->findOneBy(array('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test')); @@ -940,7 +949,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testMatchingInjectionPrevented() { - $this->setExpectedException('Doctrine\ORM\ORMException', 'Unrecognized field: '); + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Unrecognized field: '); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $result = $repository->matching(new Criteria( @@ -956,7 +966,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase */ public function testFindInjectionPrevented() { - $this->setExpectedException('Doctrine\ORM\ORMException', 'Unrecognized identifier fields: '); + $this->expectException(ORMException::class); + $this->expectExceptionMessage('Unrecognized identifier fields: '); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository->find(array('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1)); diff --git a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php index e3c3b5b5c..421b075d9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -3,7 +3,9 @@ namespace Doctrine\Tests\ORM\Functional\Locking; use Doctrine\DBAL\LockMode; +use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\Query; +use Doctrine\ORM\TransactionRequiredException; use Doctrine\Tests\Models\CMS\CmsArticle; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; @@ -47,7 +49,8 @@ class LockTest extends OrmFunctionalTestCase $this->_em->persist($article); $this->_em->flush(); - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); + $this->expectException(OptimisticLockException::class); + $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); } @@ -64,7 +67,8 @@ class LockTest extends OrmFunctionalTestCase $this->_em->persist($user); $this->_em->flush(); - $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); + $this->expectException(OptimisticLockException::class); + $this->_em->lock($user, LockMode::OPTIMISTIC); } @@ -75,7 +79,9 @@ class LockTest extends OrmFunctionalTestCase public function testLockUnmanagedEntity_ThrowsException() { $article = new CmsArticle(); - $this->setExpectedException('InvalidArgumentException', 'Entity Doctrine\Tests\Models\CMS\CmsArticle'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Entity Doctrine\Tests\Models\CMS\CmsArticle'); + $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); } @@ -91,7 +97,8 @@ class LockTest extends OrmFunctionalTestCase $this->_em->persist($article); $this->_em->flush(); - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + $this->expectException(TransactionRequiredException::class); + $this->_em->lock($article, LockMode::PESSIMISTIC_READ); } @@ -107,7 +114,8 @@ class LockTest extends OrmFunctionalTestCase $this->_em->persist($article); $this->_em->flush(); - $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + $this->expectException(TransactionRequiredException::class); + $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); } @@ -181,7 +189,9 @@ class LockTest extends OrmFunctionalTestCase { $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'"; - $this->setExpectedException('Doctrine\ORM\OptimisticLockException', 'The optimistic lock on an entity failed.'); + $this->expectException(OptimisticLockException::class); + $this->expectExceptionMessage('The optimistic lock on an entity failed.'); + $sql = $this->_em->createQuery($dql)->setHint( Query::HINT_LOCK_MODE, LockMode::OPTIMISTIC )->getSQL(); diff --git a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php index 6c460684d..320aa357a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\Internal\Hydration\HydrationException; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\Query\Parameter; @@ -324,7 +325,9 @@ class NativeQueryTest extends OrmFunctionalTestCase */ public function testAbstractClassInSingleTableInheritanceSchemaWithRSMBuilderThrowsException() { - $this->setExpectedException('\InvalidArgumentException', 'ResultSetMapping builder does not currently support your inheritance scheme.'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('ResultSetMapping builder does not currently support your inheritance scheme.'); + $rsm = new ResultSetMappingBuilder($this->_em); $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\Company\CompanyContract', 'c'); } @@ -351,10 +354,9 @@ class NativeQueryTest extends OrmFunctionalTestCase $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); $query->setParameter(1, 'romanb'); - $this->setExpectedException( - "Doctrine\ORM\Internal\Hydration\HydrationException", - "The parent object of entity result with alias 'a' was not found. The parent alias is 'un'." - ); + $this->expectException(HydrationException::class); + $this->expectExceptionMessage("The parent object of entity result with alias 'a' was not found. The parent alias is 'un'."); + $users = $query->getResult(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index 07c3d664a..8afe9d332 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -74,10 +74,9 @@ class PaginationTest extends OrmFunctionalTestCase $paginator = new Paginator($query); $paginator->setUseOutputWalkers(false); - $this->setExpectedException( - 'RuntimeException', - 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' - ); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); + $this->assertCount(3, $paginator); } @@ -495,7 +494,9 @@ class PaginationTest extends OrmFunctionalTestCase public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromBothWithLimitWithoutOutputWalker() { - $this->setExpectedException("RuntimeException", "Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers."); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.'); + $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY c.name'; $dqlAsc = $dql . " ASC, d.name"; $dqlDesc = $dql . " DESC, d.name"; @@ -552,7 +553,9 @@ class PaginationTest extends OrmFunctionalTestCase public function testIterateWithFetchJoinOneToManyWithOrderByColumnFromJoinedWithLimitWithoutOutputWalker() { - $this->setExpectedException("RuntimeException", "Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers."); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.'); + $dql = 'SELECT c, d FROM Doctrine\Tests\Models\Pagination\Company c JOIN c.departments d ORDER BY d.name'; $this->iterateWithOrderAscWithLimit(false, true, $dql, "name"); @@ -595,10 +598,8 @@ class PaginationTest extends OrmFunctionalTestCase $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Query\SqlWalker'); $paginator = new Paginator($query); - $this->setExpectedException( - 'RuntimeException', - 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' - ); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); count($paginator); } diff --git a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php index 7a5adbe7a..b6fb57964 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php @@ -36,7 +36,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase public function testLoadedEntityUsingFindShouldTriggerEvent() { - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener @@ -53,7 +53,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase public function testLoadedEntityUsingQueryShouldTriggerEvent() { - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); // CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser $mockListener @@ -73,7 +73,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase public function testLoadedAssociationToOneShouldTriggerEvent() { - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); // CmsUser (root), CmsAddress (ToOne inverse side), CmsEmail (joined association) $mockListener @@ -93,7 +93,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase public function testLoadedAssociationToManyShouldTriggerEvent() { - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); // CmsUser (root), CmsAddress (ToOne inverse side), 2 CmsPhonenumber (joined association) $mockListener @@ -116,7 +116,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase $eventManager = $this->_em->getEventManager(); // Should not be invoked during getReference call - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); $mockListener ->expects($this->never()) @@ -130,7 +130,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase // Now deactivate original listener and attach new one $eventManager->removeEventListener(array(Events::postLoad), $mockListener); - $mockListener2 = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener2 = $this->createMock(PostLoadListener::class); $mockListener2 ->expects($this->exactly(2)) @@ -147,7 +147,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase $eventManager = $this->_em->getEventManager(); // Should not be invoked during getReference call - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); // CmsUser (partially loaded), CmsAddress (inverse ToOne), 2 CmsPhonenumber $mockListener @@ -167,7 +167,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase { $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); // CmsEmail (proxy) $mockListener @@ -188,7 +188,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase { $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); - $mockListener = $this->getMock('Doctrine\Tests\ORM\Functional\PostLoadListener'); + $mockListener = $this->createMock(PostLoadListener::class); // 2 CmsPhonenumber (proxy) $mockListener diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php index c6d3ebe10..a24445271 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -3,6 +3,10 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Cache\CacheProvider; +use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; +use Doctrine\ORM\Query\ParserResult; use Doctrine\Tests\OrmFunctionalTestCase; /** @@ -105,7 +109,7 @@ class QueryCacheTest extends OrmFunctionalTestCase $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); + $cache = $this->createMock(Cache::class); $query->setQueryCacheDriver($cache); @@ -123,18 +127,23 @@ class QueryCacheTest extends OrmFunctionalTestCase $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); - $sqlExecMock = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute')); + $sqlExecMock = $this->getMockBuilder(AbstractSqlExecutor::class) + ->setMethods(array('execute')) + ->getMock(); + $sqlExecMock->expects($this->once()) ->method('execute') ->will($this->returnValue( 10 )); - $parserResultMock = $this->getMock('Doctrine\ORM\Query\ParserResult'); + $parserResultMock = $this->createMock(ParserResult::class); $parserResultMock->expects($this->once()) ->method('getSqlExecutor') ->will($this->returnValue($sqlExecMock)); - $cache = $this->getMock('Doctrine\Common\Cache\CacheProvider', - array('doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats')); + $cache = $this->getMockBuilder(CacheProvider::class) + ->setMethods(array('doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats')) + ->getMock(); + $cache->expects($this->at(0))->method('doFetch')->will($this->returnValue(1)); $cache->expects($this->at(1)) ->method('doFetch') diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php index ea150e7b2..f23409506 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -4,6 +4,8 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\NonUniqueResultException; +use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\UnexpectedResultException; use Doctrine\Tests\Models\CMS\CmsUser, Doctrine\Tests\Models\CMS\CmsArticle, @@ -118,10 +120,8 @@ class QueryTest extends OrmFunctionalTestCase public function testUsingUnknownQueryParameterShouldThrowException() { - $this->setExpectedException( - "Doctrine\ORM\Query\QueryException", - "Invalid parameter: token 2 is not defined in the query." - ); + $this->expectException(QueryException::class); + $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->setParameter(2, 'jwage'); @@ -130,10 +130,8 @@ class QueryTest extends OrmFunctionalTestCase public function testTooManyParametersShouldThrowException() { - $this->setExpectedException( - "Doctrine\ORM\Query\QueryException", - "Too many parameters: the query defines 1 parameters and you bound 2" - ); + $this->expectException(QueryException::class); + $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->setParameter(1, 'jwage'); @@ -144,10 +142,8 @@ class QueryTest extends OrmFunctionalTestCase public function testTooFewParametersShouldThrowException() { - $this->setExpectedException( - "Doctrine\ORM\Query\QueryException", - "Too few parameters: the query defines 1 parameters but you only bound 0" - ); + $this->expectException(QueryException::class); + $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'); @@ -156,7 +152,7 @@ class QueryTest extends OrmFunctionalTestCase public function testInvalidInputParameterThrowsException() { - $this->setExpectedException("Doctrine\ORM\Query\QueryException"); + $this->expectException(QueryException::class); $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?'); $q->setParameter(1, 'jwage'); @@ -505,7 +501,8 @@ class QueryTest extends OrmFunctionalTestCase $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); - $this->setExpectedException('Doctrine\ORM\NonUniqueResultException'); + $this->expectException(NonUniqueResultException::class); + $fetchedUser = $query->getOneOrNullResult(); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index aa56eb604..72be4c4d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Common\Collections\Criteria; +use Doctrine\ORM\Persisters\PersisterException; use Doctrine\Tests\Models\Company\CompanyEmployee; use Doctrine\Tests\Models\Company\CompanyFixContract; use Doctrine\Tests\Models\Company\CompanyFlexContract; @@ -371,7 +372,9 @@ class SingleTableInheritanceTest extends OrmFunctionalTestCase $repository = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract"); - $this->setExpectedException('Doctrine\ORM\Persisters\PersisterException', 'annot match on Doctrine\Tests\Models\Company\CompanyContract::salesPerson with a non-object value.'); + $this->expectException(PersisterException::class); + $this->expectExceptionMessage('annot match on Doctrine\Tests\Models\Company\CompanyContract::salesPerson with a non-object value.'); + $contracts = $repository->matching(new Criteria( Criteria::expr()->eq('salesPerson', $this->salesPerson->getId()) )); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php index ee4c64a19..52e028394 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1685Test.php @@ -55,7 +55,9 @@ class DDC1685Test extends \Doctrine\Tests\OrmFunctionalTestCase { $this->paginator->setUseOutputWalkers(false); - $this->setExpectedException('RuntimeException', 'Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator.'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator.'); + foreach ($this->paginator as $ad) { $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', $ad); } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php index 324e5e7eb..12be3241a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -1,6 +1,13 @@ getMock('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver'); - $mockMetadata = $this->getMock('Doctrine\\ORM\\Mapping\\ClassMetadata', array(), array(), '', false); - $entityManager = $this->getMock('Doctrine\\ORM\\EntityManager', array(), array(), '', false); + $mockDriver = $this->createMock(MappingDriver::class); + $mockMetadata = $this->createMock(ClassMetadata::class); + $entityManager = $this->createMock(EntityManager::class); /* @var $metadataFactory \Doctrine\ORM\Mapping\ClassMetadataFactory|\PHPUnit_Framework_MockObject_MockObject */ - $metadataFactory = $this->getMock( - 'Doctrine\\ORM\\Mapping\\ClassMetadataFactory', - array('newClassMetadataInstance', 'wakeupReflection') - ); - - $configuration = $this->getMock('Doctrine\\ORM\\Configuration', array('getMetadataDriverImpl')); - $connection = $this->getMock('Doctrine\\DBAL\\Connection', array(), array(), '', false); + $metadataFactory = $this->getMockBuilder(ClassMetadataFactory::class) + ->setMethods(array('newClassMetadataInstance', 'wakeupReflection')) + ->getMock(); + + $configuration = $this->getMockBuilder(Configuration::class) + ->setMethods(array('getMetadataDriverImpl')) + ->getMock(); + + $connection = $this->createMock(Connection::class); $configuration ->expects($this->any()) @@ -37,7 +46,7 @@ class DDC2359Test extends \PHPUnit_Framework_TestCase $entityManager ->expects($this->any()) ->method('getEventManager') - ->will($this->returnValue($this->getMock('Doctrine\\Common\\EventManager'))); + ->will($this->returnValue($this->createMock(EventManager::class))); $metadataFactory->expects($this->any())->method('newClassMetadataInstance')->will($this->returnValue($mockMetadata)); $metadataFactory->expects($this->once())->method('wakeupReflection'); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php index d52953d60..437f89ffb 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php @@ -29,7 +29,10 @@ class DDC2692Test extends \Doctrine\Tests\OrmFunctionalTestCase public function testIsListenerCalledOnlyOnceOnPreFlush() { - $listener = $this->getMock('Doctrine\Tests\ORM\Functional\Ticket\DDC2692Listener', array('preFlush')); + $listener = $this->getMockBuilder(DDC2692Listener::class) + ->setMethods(array('preFlush')) + ->getMock(); + $listener->expects($this->once())->method('preFlush'); $this->_em->getEventManager()->addEventSubscriber($listener); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php index bb4f57f15..7f82e6c89 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php @@ -28,7 +28,9 @@ class DDC3123Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->persist($user); $uow->scheduleExtraUpdate($user, array('name' => 'changed name')); - $listener = $this->getMock('stdClass', array(Events::postFlush)); + $listener = $this->getMockBuilder(\stdClass::class) + ->setMethods(array(Events::postFlush)) + ->getMock(); $listener ->expects($this->once()) diff --git a/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php b/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php index 87d1464b5..3e8285e8f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Functional; +use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\OrmFunctionalTestCase; @@ -22,7 +23,9 @@ class UnitOfWorkLifecycleTest extends OrmFunctionalTestCase $this->_em->persist($user); $this->_em->flush(); - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "A managed+dirty entity Doctrine\Tests\Models\CMS\CmsUser"); + $this->expectException(ORMInvalidArgumentException::class); + $this->expectExceptionMessage('A managed+dirty entity Doctrine\Tests\Models\CMS\CmsUser'); + $this->_em->getUnitOfWork()->scheduleForInsert($user); } @@ -37,7 +40,9 @@ class UnitOfWorkLifecycleTest extends OrmFunctionalTestCase $this->_em->remove($user); - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Removed entity Doctrine\Tests\Models\CMS\CmsUser"); + $this->expectException(ORMInvalidArgumentException::class); + $this->expectExceptionMessage('Removed entity Doctrine\Tests\Models\CMS\CmsUser'); + $this->_em->getUnitOfWork()->scheduleForInsert($user); } @@ -50,7 +55,9 @@ class UnitOfWorkLifecycleTest extends OrmFunctionalTestCase $this->_em->getUnitOfWork()->scheduleForInsert($user); - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Entity Doctrine\Tests\Models\CMS\CmsUser"); + $this->expectException(ORMInvalidArgumentException::class); + $this->expectExceptionMessage('Entity Doctrine\Tests\Models\CMS\CmsUser'); + $this->_em->getUnitOfWork()->scheduleForInsert($user); } @@ -58,7 +65,9 @@ class UnitOfWorkLifecycleTest extends OrmFunctionalTestCase { $user = new CmsUser(); - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "The given entity of type 'Doctrine\Tests\Models\CMS\CmsUser' (Doctrine\Tests\Models\CMS\CmsUser@"); + $this->expectException(ORMInvalidArgumentException::class); + $this->expectExceptionMessage("The given entity of type 'Doctrine\Tests\Models\CMS\CmsUser' (Doctrine\Tests\Models\CMS\CmsUser@"); + $this->_em->getUnitOfWork()->registerManaged($user, array(), array()); } @@ -66,7 +75,9 @@ class UnitOfWorkLifecycleTest extends OrmFunctionalTestCase { $user = new CmsUser(); - $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Only managed entities can be marked or checked as read only. But Doctrine\Tests\Models\CMS\CmsUser@"); + $this->expectException(ORMInvalidArgumentException::class); + $this->expectExceptionMessage('Only managed entities can be marked or checked as read only. But Doctrine\Tests\Models\CMS\CmsUser@'); + $this->_em->getUnitOfWork()->markReadOnly($user); } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 448d80ff7..47e98d25c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -1,6 +1,8 @@ setExpectedException('Doctrine\ORM\Query\QueryException', 'no field or association named address.asdfasdf'); + $this->expectException(QueryException::class); + $this->expectExceptionMessage('no field or association named address.asdfasdf'); $this->_em->createQuery("SELECT p FROM " . __NAMESPACE__ . "\\DDC93Person p WHERE p.address.asdfasdf IS NULL") ->execute(); @@ -236,8 +239,9 @@ class ValueObjectsTest extends OrmFunctionalTestCase public function testPartialDqlWithNonExistentEmbeddableField() { - $this->setExpectedException('Doctrine\ORM\Query\QueryException', "no mapped field named 'address.asdfasdf'"); - + $this->expectException(QueryException::class); + $this->expectExceptionMessage("no mapped field named 'address.asdfasdf'"); + $this->_em->createQuery("SELECT PARTIAL p.{id,address.asdfasdf} FROM " . __NAMESPACE__ . "\\DDC93Person p") ->execute(); } @@ -297,8 +301,8 @@ class ValueObjectsTest extends OrmFunctionalTestCase */ public function testThrowsExceptionOnInfiniteEmbeddableNesting($embeddableClassName, $declaredEmbeddableClassName) { - $this->setExpectedException( - 'Doctrine\ORM\Mapping\MappingException', + $this->expectException(MappingException::class); + $this->expectExceptionMessage( sprintf( 'Infinite nesting detected for embedded property %s::nested. ' . 'You cannot embed an embeddable from the same type inside an embeddable.', diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index cbc27b903..22cf3b598 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Hydration; +use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\Tests\Mocks\HydratorMockStatement; use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Mapping\ClassMetadata; @@ -1004,7 +1005,11 @@ class ObjectHydratorTest extends HydrationTestCase $proxyInstance = new \Doctrine\Tests\Models\ECommerce\ECommerceShipping(); // mocking the proxy factory - $proxyFactory = $this->getMock('Doctrine\ORM\Proxy\ProxyFactory', array('getProxy'), array(), '', false, false, false); + $proxyFactory = $this->getMockBuilder(ProxyFactory::class) + ->setMethods(array('getProxy')) + ->disableOriginalConstructor() + ->getMock(); + $proxyFactory->expects($this->once()) ->method('getProxy') ->with($this->equalTo('Doctrine\Tests\Models\ECommerce\ECommerceShipping'), array('id' => 42)) @@ -1049,7 +1054,11 @@ class ObjectHydratorTest extends HydrationTestCase $proxyInstance = new \Doctrine\Tests\Models\ECommerce\ECommerceShipping(); // mocking the proxy factory - $proxyFactory = $this->getMock('Doctrine\ORM\Proxy\ProxyFactory', array('getProxy'), array(), '', false, false, false); + $proxyFactory = $this->getMockBuilder(ProxyFactory::class) + ->setMethods(array('getProxy')) + ->disableOriginalConstructor() + ->getMock(); + $proxyFactory->expects($this->once()) ->method('getProxy') ->with($this->equalTo('Doctrine\Tests\Models\ECommerce\ECommerceShipping'), array('id' => 42)) diff --git a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index b767bd225..1063b5aca 100644 --- a/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Doctrine/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -20,9 +20,11 @@ namespace Doctrine\Tests\ORM\Internal; use Doctrine\Common\Persistence\Event\LifecycleEventArgs; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\ListenersInvoker; use Doctrine\ORM\Events; use Doctrine\ORM\Internal\HydrationCompleteHandler; +use Doctrine\ORM\Mapping\ClassMetadata; use PHPUnit_Framework_TestCase; use stdClass; @@ -53,8 +55,8 @@ class HydrationCompleteHandlerTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->listenersInvoker = $this->getMock('Doctrine\ORM\Event\ListenersInvoker', array(), array(), '', false); - $this->entityManager = $this->getMock('Doctrine\ORM\EntityManagerInterface'); + $this->listenersInvoker = $this->createMock(ListenersInvoker::class); + $this->entityManager = $this->createMock(EntityManagerInterface::class); $this->handler = new HydrationCompleteHandler($this->listenersInvoker, $this->entityManager); } @@ -66,7 +68,7 @@ class HydrationCompleteHandlerTest extends PHPUnit_Framework_TestCase public function testDefersPostLoadOfEntity($listenersFlag) { /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadata */ - $metadata = $this->getMock('Doctrine\ORM\Mapping\ClassMetadata', array(), array(), '', false); + $metadata = $this->createMock(ClassMetadata::class); $entity = new stdClass(); $entityManager = $this->entityManager; @@ -104,7 +106,7 @@ class HydrationCompleteHandlerTest extends PHPUnit_Framework_TestCase public function testDefersPostLoadOfEntityOnlyOnce($listenersFlag) { /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadata */ - $metadata = $this->getMock('Doctrine\ORM\Mapping\ClassMetadata', array(), array(), '', false); + $metadata = $this->createMock(ClassMetadata::class); $entity = new stdClass(); $this @@ -131,8 +133,8 @@ class HydrationCompleteHandlerTest extends PHPUnit_Framework_TestCase { /* @var $metadata1 \Doctrine\ORM\Mapping\ClassMetadata */ /* @var $metadata2 \Doctrine\ORM\Mapping\ClassMetadata */ - $metadata1 = $this->getMock('Doctrine\ORM\Mapping\ClassMetadata', array(), array(), '', false); - $metadata2 = $this->getMock('Doctrine\ORM\Mapping\ClassMetadata', array(), array(), '', false); + $metadata1 = $this->createMock(ClassMetadata::class); + $metadata2 = $this->createMock(ClassMetadata::class); $entity1 = new stdClass(); $entity2 = new stdClass(); $entityManager = $this->entityManager; @@ -168,7 +170,7 @@ class HydrationCompleteHandlerTest extends PHPUnit_Framework_TestCase public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners() { /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadata */ - $metadata = $this->getMock('Doctrine\ORM\Mapping\ClassMetadata', array(), array(), '', false); + $metadata = $this->createMock(ClassMetadata::class); $entity = new stdClass(); $this diff --git a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php index 03f8bf154..512b21115 100644 --- a/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/LazyCriteriaCollectionTest.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\LazyCriteriaCollection; +use Doctrine\ORM\Persisters\Entity\EntityPersister; use stdClass; /** @@ -33,7 +34,7 @@ class LazyCriteriaCollectionTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->persister = $this->getMock('Doctrine\ORM\Persisters\Entity\EntityPersister'); + $this->persister = $this->createMock(EntityPersister::class); $this->criteria = new Criteria(); $this->lazyCriteriaCollection = new LazyCriteriaCollection($this->persister, $this->criteria); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index f3f0506b1..8d90931f9 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -8,6 +8,7 @@ use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\Tests\Models\Cache\City; use Doctrine\ORM\Mapping\ClassMetadata; @@ -520,7 +521,8 @@ abstract class AbstractMappingDriverTest extends OrmTestCase */ public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses() { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'Class "Doctrine\Tests\Models\DDC889\DDC889Class" sub class of "Doctrine\Tests\Models\DDC889\DDC889SuperClass" is not a valid entity or mapped super class.'); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('Class "Doctrine\Tests\Models\DDC889\DDC889Class" sub class of "Doctrine\Tests\Models\DDC889\DDC889SuperClass" is not a valid entity or mapped super class.'); $this->createClassMetadata('Doctrine\Tests\Models\DDC889\DDC889Class'); } @@ -532,7 +534,9 @@ abstract class AbstractMappingDriverTest extends OrmTestCase { $factory = $this->createClassMetadataFactory(); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'No identifier/primary key specified for Entity "Doctrine\Tests\Models\DDC889\DDC889Entity" sub class of "Doctrine\Tests\Models\DDC889\DDC889SuperClass". Every Entity must have an identifier/primary key.'); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('No identifier/primary key specified for Entity "Doctrine\Tests\Models\DDC889\DDC889Entity" sub class of "Doctrine\Tests\Models\DDC889\DDC889SuperClass". Every Entity must have an identifier/primary key.'); + $factory->getMetadataFor('Doctrine\Tests\Models\DDC889\DDC889Entity'); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index 4b44d1d41..ac17b63a2 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -2,11 +2,13 @@ namespace Doctrine\Tests\ORM\Mapping; +use Doctrine\Common\Annotations\AnnotationException; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; +use Doctrine\ORM\Mapping\MappingException; class AnnotationDriverTest extends AbstractMappingDriverTest { @@ -20,7 +22,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $reader = new AnnotationReader(); $annotationDriver = new AnnotationDriver($reader); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $annotationDriver->loadMetadataForClass('stdClass', $cm); } @@ -157,9 +159,12 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "It is illegal to put an inverse side one-to-many or many-to-many association on ". - "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'"); + $this->expectException(MappingException::class); + $this->expectExceptionMessage( + "It is illegal to put an inverse side one-to-many or many-to-many association on " . + "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'" + ); + $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\UsingInvalidMappedSuperClass'); } @@ -175,9 +180,12 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "It is not supported to define inheritance information on a mapped ". - "superclass 'Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'."); + $this->expectException(MappingException::class); + $this->expectExceptionMessage( + "It is not supported to define inheritance information on a mapped " . + "superclass 'Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'." + ); + $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'); } @@ -224,8 +232,9 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $factory = new ClassMetadataFactory(); $factory->setEntityManager($em); - $this->setExpectedException('Doctrine\Common\Annotations\AnnotationException', - '[Enum Error] Attribute "fetch" of @Doctrine\ORM\Mapping\OneToMany declared on property Doctrine\Tests\ORM\Mapping\InvalidFetchOption::$collection accept only [LAZY, EAGER, EXTRA_LAZY], but got eager.'); + $this->expectException(AnnotationException::class); + $this->expectExceptionMessage('[Enum Error] Attribute "fetch" of @Doctrine\ORM\Mapping\OneToMany declared on property Doctrine\Tests\ORM\Mapping\InvalidFetchOption::$collection accept only [LAZY, EAGER, EXTRA_LAZY], but got eager.'); + $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\InvalidFetchOption'); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php index 977c1fa26..be2bee9f5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\Mapping\ClassMetadataFactory; use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Mapping\MappingException; use Doctrine\Tests\Models\DDC869\DDC869Payment; use Doctrine\Tests\OrmTestCase; @@ -26,7 +27,7 @@ class BasicInheritanceMappingTest extends OrmTestCase public function testGetMetadataForTransientClassThrowsException() { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $this->cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TransientBaseClass'); } @@ -122,12 +123,13 @@ class BasicInheritanceMappingTest extends OrmTestCase */ public function testUnmappedEntityInHierarchy() { - $this->setExpectedException( - 'Doctrine\ORM\Mapping\MappingException', - 'Entity \'Doctrine\Tests\ORM\Mapping\HierarchyBEntity\' has to be part of the discriminator map' + $this->expectException(MappingException::class); + $this->expectExceptionMessage( + 'Entity \'Doctrine\Tests\ORM\Mapping\HierarchyBEntity\' has to be part of the discriminator map' . ' of \'Doctrine\Tests\ORM\Mapping\HierarchyBase\' to be properly mapped in the inheritance hierarchy.' . ' Alternatively you can make \'Doctrine\Tests\ORM\Mapping\HierarchyBEntity\' an abstract class to' - . ' avoid this exception from occurring.'); + . ' avoid this exception from occurring.' + ); $this->cmf->getMetadataFor(__NAMESPACE__ . '\\HierarchyE'); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 58ee64a42..996c40598 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -528,7 +528,7 @@ class ClassMetadataBuilderTest extends OrmTestCase public function testThrowsExceptionOnCreateOneToOneWithIdentityOnInverseSide() { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $this ->builder @@ -624,7 +624,7 @@ class ClassMetadataBuilderTest extends OrmTestCase public function testThrowsExceptionOnCreateManyToManyWithIdentity() { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $this->builder->createManyToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') ->makePrimaryKey() @@ -677,7 +677,7 @@ class ClassMetadataBuilderTest extends OrmTestCase public function testThrowsExceptionOnCreateOneToManyWithIdentity() { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $this->builder->createOneToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') ->makePrimaryKey() @@ -775,7 +775,7 @@ class ClassMetadataBuilderTest extends OrmTestCase public function testExceptionOnOrphanRemovalOnManyToOne() { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $this->builder ->createManyToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 71dc598a8..f40d657b5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -3,14 +3,19 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\Common\EventManager; +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; +use Doctrine\DBAL\Connection; use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Event\OnClassMetadataNotFoundEventArgs; use Doctrine\ORM\Events; use Doctrine\ORM\Id\AbstractIdGenerator; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\ORMException; use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\Mocks\EntityManagerMock; @@ -78,7 +83,7 @@ class ClassMetadataFactoryTest extends OrmTestCase $cm1->customGeneratorDefinition = array("class" => "NotExistingGenerator"); $cmf = $this->_createTestFactory(); $cmf->setMetadataForClass($cm1->name, $cm1); - $this->setExpectedException("Doctrine\ORM\ORMException"); + $this->expectException(ORMException::class); $actual = $cmf->getMetadataFor($cm1->name); } @@ -89,7 +94,7 @@ class ClassMetadataFactoryTest extends OrmTestCase $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cmf = $this->_createTestFactory(); $cmf->setMetadataForClass($cm1->name, $cm1); - $this->setExpectedException("Doctrine\ORM\ORMException"); + $this->expectException(ORMException::class); $actual = $cmf->getMetadataFor($cm1->name); } @@ -119,7 +124,7 @@ class ClassMetadataFactoryTest extends OrmTestCase public function testIsTransient() { $cmf = new ClassMetadataFactory(); - $driver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $driver = $this->createMock(MappingDriver::class); $driver->expects($this->at(0)) ->method('isTransient') ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) @@ -141,7 +146,7 @@ class ClassMetadataFactoryTest extends OrmTestCase public function testIsTransientEntityNamespace() { $cmf = new ClassMetadataFactory(); - $driver = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $driver = $this->createMock(MappingDriver::class); $driver->expects($this->at(0)) ->method('isTransient') ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) @@ -189,7 +194,7 @@ class ClassMetadataFactoryTest extends OrmTestCase // ClassMetadataFactory::addDefaultDiscriminatorMap shouldn't be called again, because the // discriminator map is already cached - $cmf = $this->getMock('Doctrine\ORM\Mapping\ClassMetadataFactory', array('addDefaultDiscriminatorMap')); + $cmf = $this->getMockBuilder(ClassMetadataFactory::class)->setMethods(array('addDefaultDiscriminatorMap'))->getMock(); $cmf->setEntityManager($em); $cmf->expects($this->never()) ->method('addDefaultDiscriminatorMap'); @@ -200,9 +205,7 @@ class ClassMetadataFactoryTest extends OrmTestCase public function testGetAllMetadataWorksWithBadConnection() { // DDC-3551 - $conn = $this->getMockBuilder('Doctrine\DBAL\Connection') - ->disableOriginalConstructor() - ->getMock(); + $conn = $this->createMock(Connection::class); $mockDriver = new MetadataDriverMock(); $em = $this->_createEntityManager($mockDriver, $conn); @@ -361,11 +364,11 @@ class ClassMetadataFactoryTest extends OrmTestCase { $test = $this; /* @var $metadata \Doctrine\Common\Persistence\Mapping\ClassMetadata */ - $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $metadata = $this->createMock(ClassMetadata::class); $cmf = new ClassMetadataFactory(); $mockDriver = new MetadataDriverMock(); $em = $this->_createEntityManager($mockDriver); - $listener = $this->getMock('stdClass', array('onClassMetadataNotFound')); + $listener = $this->getMockBuilder(\stdClass::class)->setMethods(array('onClassMetadataNotFound'))->getMock(); $eventManager = $em->getEventManager(); $cmf->setEntityManager($em); @@ -394,7 +397,7 @@ class ClassMetadataFactoryTest extends OrmTestCase $classMetadataFactory = new ClassMetadataFactory(); /* @var $entityManager EntityManager */ - $entityManager = $this->getMock('Doctrine\\ORM\\EntityManagerInterface'); + $entityManager = $this->createMock(EntityManagerInterface::class); $classMetadataFactory->setEntityManager($entityManager); @@ -419,10 +422,8 @@ class ClassMetadataFactoryTest extends OrmTestCase $cmf->setMetadataForClass($metadata->name, $metadata); - $this->setExpectedException( - 'Doctrine\ORM\Mapping\MappingException', - 'The embed mapping \'embedded\' misses the \'class\' attribute.' - ); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('The embed mapping \'embedded\' misses the \'class\' attribute.'); $cmf->getMetadataFor($metadata->name); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index e324c3729..44243e113 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -7,6 +7,7 @@ use Doctrine\Common\Persistence\Mapping\StaticReflectionService; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Events; use Doctrine\ORM\Mapping\DefaultNamingStrategy; +use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; use Doctrine\Tests\OrmTestCase; use Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser; @@ -182,7 +183,7 @@ class ClassMetadataTest extends OrmTestCase $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm->initializeReflection(new RuntimeReflectionService()); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->setVersionMapping($field); } @@ -192,7 +193,7 @@ class ClassMetadataTest extends OrmTestCase $cm->initializeReflection(new RuntimeReflectionService()); $cm->isIdentifierComposite = true; - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->getSingleIdentifierFieldName(); } @@ -205,7 +206,7 @@ class ClassMetadataTest extends OrmTestCase $a2 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'); $cm->addInheritedAssociationMapping($a1); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->addInheritedAssociationMapping($a2); } @@ -216,7 +217,7 @@ class ClassMetadataTest extends OrmTestCase $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->mapField(array('fieldName' => 'username', 'columnName' => 'name')); } @@ -227,7 +228,7 @@ class ClassMetadataTest extends OrmTestCase $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->setDiscriminatorColumn(array('name' => 'name')); } @@ -238,7 +239,7 @@ class ClassMetadataTest extends OrmTestCase $cm->setDiscriminatorColumn(array('name' => 'name')); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); } @@ -249,7 +250,7 @@ class ClassMetadataTest extends OrmTestCase $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); } @@ -260,7 +261,7 @@ class ClassMetadataTest extends OrmTestCase $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); } @@ -395,7 +396,9 @@ class ClassMetadataTest extends OrmTestCase $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm->initializeReflection(new RuntimeReflectionService()); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "No mapping found for field 'foo' on class 'Doctrine\Tests\Models\CMS\CmsUser'."); + $this->expectException(MappingException::class); + $this->expectExceptionMessage("No mapping found for field 'foo' on class 'Doctrine\Tests\Models\CMS\CmsUser'."); + $cm->getFieldMapping('foo'); } @@ -439,7 +442,9 @@ class ClassMetadataTest extends OrmTestCase $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); $cm->initializeReflection(new RuntimeReflectionService()); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'The orphan removal option is not allowed on an association that'); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('The orphan removal option is not allowed on an association that'); + $cm->mapOneToOne(array( 'fieldName' => 'article', 'id' => true, @@ -457,8 +462,9 @@ class ClassMetadataTest extends OrmTestCase $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); $cm->initializeReflection(new RuntimeReflectionService()); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('An inverse association is not allowed to be identifier in'); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'An inverse association is not allowed to be identifier in'); $cm->mapOneToOne(array( 'fieldName' => 'article', 'id' => true, @@ -476,8 +482,9 @@ class ClassMetadataTest extends OrmTestCase $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); $cm->initializeReflection(new RuntimeReflectionService()); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('Many-to-many or one-to-many associations are not allowed to be identifier in'); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'Many-to-many or one-to-many associations are not allowed to be identifier in'); $cm->mapManyToMany(array( 'fieldName' => 'article', 'id' => true, @@ -491,8 +498,9 @@ class ClassMetadataTest extends OrmTestCase */ public function testEmptyFieldNameThrowsException() { - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "The field or association mapping misses the 'fieldName' attribute in entity 'Doctrine\Tests\Models\CMS\CmsUser'."); + $this->expectException(MappingException::class); + $this->expectExceptionMessage("The field or association mapping misses the 'fieldName' attribute in entity 'Doctrine\Tests\Models\CMS\CmsUser'."); + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm->initializeReflection(new RuntimeReflectionService()); @@ -833,7 +841,9 @@ class ClassMetadataTest extends OrmTestCase $cm->initializeReflection(new RuntimeReflectionService()); $cm->addLifecycleCallback('notfound', 'postLoad'); - $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback."); + $this->expectException(MappingException::class); + $this->expectExceptionMessage("Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback."); + $cm->validateLifecycleCallbacks(new RuntimeReflectionService()); } @@ -846,7 +856,9 @@ class ClassMetadataTest extends OrmTestCase $cm->initializeReflection(new RuntimeReflectionService()); $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass')); - $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "The target-entity Doctrine\Tests\Models\CMS\UnknownClass cannot be found in 'Doctrine\Tests\Models\CMS\CmsUser#address'."); + $this->expectException(MappingException::class); + $this->expectExceptionMessage("The target-entity Doctrine\Tests\Models\CMS\UnknownClass cannot be found in 'Doctrine\Tests\Models\CMS\CmsUser#address'."); + $cm->validateAssociations(); } @@ -972,8 +984,8 @@ class ClassMetadataTest extends OrmTestCase $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm->initializeReflection(new RuntimeReflectionService()); - $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "You have specified invalid cascade options for Doctrine\Tests\Models\CMS\CmsUser::\$address: 'invalid'; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'"); - + $this->expectException(MappingException::class); + $this->expectExceptionMessage("You have specified invalid cascade options for Doctrine\Tests\Models\CMS\CmsUser::\$address: 'invalid'; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach'"); $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass', 'cascade' => array('invalid'))); } @@ -1080,7 +1092,7 @@ class ClassMetadataTest extends OrmTestCase $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); $cm->initializeReflection(new RuntimeReflectionService()); - $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $this->expectException(\Doctrine\ORM\Mapping\MappingException::class); $cm->setSequenceGeneratorDefinition(array()); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php b/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php index 7bc83df2e..1b18deb11 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Reflection/ReflectionPropertiesGetterTest.php @@ -90,7 +90,7 @@ class ReflectionPropertiesGetterTest extends PHPUnit_Framework_TestCase public function testPropertyGetterWillSkipPropertiesNotRetrievedByTheRuntimeReflectionService() { /* @var $reflectionService ReflectionService|\PHPUnit_Framework_MockObject_MockObject */ - $reflectionService = $this->getMock('Doctrine\Common\Persistence\Mapping\ReflectionService'); + $reflectionService = $this->createMock(ReflectionService::class); $reflectionService ->expects($this->exactly(2)) @@ -113,7 +113,7 @@ class ReflectionPropertiesGetterTest extends PHPUnit_Framework_TestCase public function testPropertyGetterWillSkipClassesNotRetrievedByTheRuntimeReflectionService() { /* @var $reflectionService ReflectionService|\PHPUnit_Framework_MockObject_MockObject */ - $reflectionService = $this->getMock('Doctrine\Common\Persistence\Mapping\ReflectionService'); + $reflectionService = $this->createMock(ReflectionService::class); $reflectionService ->expects($this->once()) diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php index 2056c1da0..e116c6763 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php @@ -18,6 +18,7 @@ */ namespace Doctrine\Tests\ORM\Mapping\Symfony; +use Doctrine\Common\Persistence\Mapping\MappingException; /** * @group DDC-1418 @@ -47,10 +48,8 @@ abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase public function testFindMappingFileNamespacedFoundFileNotFound() { - $this->setExpectedException( - 'Doctrine\Common\Persistence\Mapping\MappingException', - "No mapping file found named" - ); + $this->expectException(MappingException::class); + $this->expectExceptionMessage('No mapping file found named'); $driver = $this->getDriver(array( 'MyNamespace\MySubnamespace\Entity' => $this->dir, @@ -61,10 +60,8 @@ abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase public function testFindMappingNamespaceNotFound() { - $this->setExpectedException( - 'Doctrine\Common\Persistence\Mapping\MappingException', - "No mapping file found named 'Foo".$this->getFileExtension()."' for class 'MyOtherNamespace\MySubnamespace\Entity\Foo'." - ); + $this->expectException(MappingException::class); + $this->expectExceptionMessage("No mapping file found named 'Foo" . $this->getFileExtension() . "' for class 'MyOtherNamespace\MySubnamespace\Entity\Foo'."); $driver = $this->getDriver(array( 'MyNamespace\MySubnamespace\Entity' => $this->dir, diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index 39fab08b9..dd5b730f6 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Proxy; use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\EntityManagerMock; @@ -56,7 +57,8 @@ class ProxyFactoryTest extends OrmTestCase { $identifier = array('id' => 42); $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; - $persister = $this->getMock('Doctrine\ORM\Persisters\Entity\BasicEntityPersister', array('load'), array(), '', false); + $persister = $this->getMockBuilder(BasicEntityPersister::class)->setMethods(array('load'))->disableOriginalConstructor()->getMock(); + $this->uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); $proxy = $this->proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $identifier); @@ -89,7 +91,7 @@ class ProxyFactoryTest extends OrmTestCase */ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized() { - $persister = $this->getMock('Doctrine\ORM\Persisters\Entity\BasicEntityPersister', array('load'), array(), '', false); + $persister = $this->getMockBuilder(BasicEntityPersister::class)->setMethods(array('load'))->disableOriginalConstructor()->getMock(); $this->uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); /* @var $proxy \Doctrine\Common\Proxy\Proxy */ @@ -116,7 +118,7 @@ class ProxyFactoryTest extends OrmTestCase */ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized() { - $persister = $this->getMock('Doctrine\ORM\Persisters\Entity\BasicEntityPersister', array('load'), array(), '', false); + $persister = $this->getMockBuilder(BasicEntityPersister::class)->setMethods(array('load'))->disableOriginalConstructor()->getMock(); $this->uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); /* @var $proxy \Doctrine\Common\Proxy\Proxy */ diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index dffcd481a..af7d2bf55 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -20,6 +20,7 @@ namespace Doctrine\Tests\ORM\Functional; use Doctrine\ORM\Query; +use Doctrine\ORM\Query\QueryException; use Doctrine\Tests\OrmTestCase; /** @@ -90,7 +91,9 @@ class CustomTreeWalkersTest extends OrmTestCase public function testSetUnknownQueryComponentThrowsException() { - $this->setExpectedException("Doctrine\ORM\Query\QueryException", "Invalid query component given for DQL alias 'x', requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys."); + $this->expectException(QueryException::class); + $this->expectExceptionMessage("Invalid query component given for DQL alias 'x', requires 'metadata', 'parent', 'relation', 'map', 'nestingLevel' and 'token' keys."); + $this->generateSql( 'select u from Doctrine\Tests\Models\CMS\CmsUser u', array(), diff --git a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php index 145b591e7..fe12b3989 100644 --- a/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -84,7 +84,7 @@ class LanguageRecognitionTest extends OrmTestCase */ public function testRejectsInvalidDQL($dql) { - $this->setExpectedException('\Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $this->_em->getConfiguration()->setEntityNamespaces(array( 'Unknown' => 'Unknown', diff --git a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php index 64f3afb0f..086e1d43e 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\ORM\Query; +use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; use Doctrine\ORM\Query\ParserResult; class ParserResultTest extends \PHPUnit_Framework_TestCase @@ -25,7 +26,7 @@ class ParserResultTest extends \PHPUnit_Framework_TestCase { $this->assertNull($this->parserResult->getSqlExecutor()); - $executor = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute')); + $executor = $this->getMockBuilder(AbstractSqlExecutor::class)->setMethods(array('execute'))->getMock(); $this->parserResult->setSqlExecutor($executor); $this->assertSame($executor, $this->parserResult->getSqlExecutor()); } diff --git a/tests/Doctrine/Tests/ORM/Query/ParserTest.php b/tests/Doctrine/Tests/ORM/Query/ParserTest.php index 097f9ec88..fb320773e 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParserTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParserTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\QueryException; use Doctrine\Tests\OrmTestCase; class ParserTest extends OrmTestCase @@ -90,7 +91,7 @@ class ParserTest extends OrmTestCase */ public function testMatchFailure($expectedToken, $inputString) { - $this->setExpectedException('\Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $parser = $this->createParser($inputString); diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index fa12a3e33..707973495 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -13,6 +13,7 @@ use Doctrine\ORM\Query as ORMQuery; use Doctrine\ORM\Query\AST\Functions\FunctionNode; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\Parser; +use Doctrine\ORM\Query\QueryException; use Doctrine\ORM\Query\SqlWalker; use Doctrine\Tests\Models\CMS\CmsGroup; use Doctrine\Tests\Models\CMS\CmsPhonenumber; @@ -76,7 +77,7 @@ class SelectSqlGenerationTest extends OrmTestCase */ public function assertInvalidSqlGeneration($dqlToBeTested, $expectedException, array $queryHints = array(), array $queryParams = array()) { - $this->setExpectedException($expectedException); + $this->expectException($expectedException); $query = $this->_em->createQuery($dqlToBeTested); @@ -429,7 +430,7 @@ class SelectSqlGenerationTest extends OrmTestCase */ public function testJoinOnClause_NotYetSupported_ThrowsException() { - $this->setExpectedException('Doctrine\ORM\Query\QueryException'); + $this->expectException(QueryException::class); $sql = $this->_em->createQuery( "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a ON a.topic LIKE '%foo%'" diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 655b86a6a..7b1e38c30 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -1083,7 +1083,8 @@ class QueryBuilderTest extends OrmTestCase */ public function testWhereAppend() { - $this->setExpectedException('InvalidArgumentException', "Using \$append = true does not have an effect with 'where' or 'having' parts. See QueryBuilder#andWhere() for an example for correct usage."); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage("Using \$append = true does not have an effect with 'where' or 'having' parts. See QueryBuilder#andWhere() for an example for correct usage."); $qb = $this->_em->createQueryBuilder() ->add('where', 'u.foo = ?1') diff --git a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index bfe5179a0..bdccb4d7e 100644 --- a/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -2,6 +2,9 @@ namespace Doctrine\Tests\ORM\Repository; +use Doctrine\ORM\Configuration; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Repository\DefaultRepositoryFactory; use PHPUnit_Framework_TestCase; @@ -32,7 +35,7 @@ class DefaultRepositoryFactoryTest extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->configuration = $this->getMock('Doctrine\\ORM\\Configuration'); + $this->configuration = $this->createMock(Configuration::class); $this->entityManager = $this->createEntityManager(); $this->repositoryFactory = new DefaultRepositoryFactory(); @@ -122,10 +125,7 @@ class DefaultRepositoryFactoryTest extends PHPUnit_Framework_TestCase public function buildClassMetadata($className) { /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadata|\PHPUnit_Framework_MockObject_MockObject */ - $metadata = $this - ->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata') - ->disableOriginalConstructor() - ->getMock(); + $metadata = $this->createMock(ClassMetadata::class); $metadata->expects($this->any())->method('getName')->will($this->returnValue($className)); @@ -139,7 +139,7 @@ class DefaultRepositoryFactoryTest extends PHPUnit_Framework_TestCase */ private function createEntityManager() { - $entityManager = $this->getMock('Doctrine\\ORM\\EntityManagerInterface'); + $entityManager = $this->createMock(EntityManagerInterface::class); $entityManager ->expects($this->any()) diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php index f4052f8d3..af89c866d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php @@ -3,17 +3,19 @@ namespace Doctrine\Tests\ORM\Tools\Console\Command; use Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand; +use Doctrine\ORM\Tools\EntityGenerator; use Doctrine\Tests\OrmTestCase; +use Symfony\Component\Console\Output\OutputInterface; class ConvertDoctrine1SchemaCommandTest extends OrmTestCase { public function testExecution() { - $entityGenerator = $this->getMock('Doctrine\ORM\Tools\EntityGenerator'); + $entityGenerator = $this->createMock(EntityGenerator::class); $command = new ConvertDoctrine1SchemaCommand(); $command->setEntityGenerator($entityGenerator); - $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $output = $this->createMock(OutputInterface::class); $output->expects($this->once()) ->method('writeln') ->with($this->equalTo('No Metadata Classes to process.')); diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index 7c09cdf86..0cbae94d7 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -613,7 +613,9 @@ class EntityGeneratorTest extends OrmTestCase $this->assertEquals($expected, $actual); } - $this->setExpectedException('\InvalidArgumentException', 'Invalid provided InheritanceType: INVALID'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid provided InheritanceType: INVALID'); + $method->invoke($this->_generator, 'INVALID'); } @@ -640,7 +642,9 @@ class EntityGeneratorTest extends OrmTestCase $this->assertEquals($expected, $actual); } - $this->setExpectedException('\InvalidArgumentException', 'Invalid provided ChangeTrackingPolicy: INVALID'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid provided ChangeTrackingPolicy: INVALID'); + $method->invoke($this->_generator, 'INVALID'); } @@ -667,7 +671,9 @@ class EntityGeneratorTest extends OrmTestCase $this->assertEquals($expected, $actual); } - $this->setExpectedException('\InvalidArgumentException', 'Invalid provided IdGeneratorType: INVALID'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid provided IdGeneratorType: INVALID'); + $method->invoke($this->_generator, 'INVALID'); } diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index 888861582..a85a5f6f8 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -83,10 +83,8 @@ class CountWalkerTest extends PaginationTestCase $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); $query->setFirstResult(null)->setMaxResults(null); - $this->setExpectedException( - 'RuntimeException', - 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' - ); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); $query->getSQL(); } diff --git a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php index 407baab3e..06ef2a07a 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SetupTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\ORM\Tools\Setup; +use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\ArrayCache; use Doctrine\ORM\Version; use Doctrine\Tests\OrmTestCase; @@ -97,9 +98,7 @@ class SetupTest extends OrmTestCase */ public function testConfigureCacheCustomInstance() { - $cache = $this->getMock('Doctrine\Common\Cache\Cache'); - $cache->expects($this->never())->method('setNamespace'); - + $cache = $this->createMock(Cache::class); $config = Setup::createConfiguration(array(), true, $cache); $this->assertSame($cache, $config->getResultCacheImpl()); diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 8755a4eaa..9b0c6a8f5 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -248,7 +248,7 @@ class UnitOfWorkTest extends OrmTestCase */ public function testLockWithoutEntityThrowsException() { - $this->setExpectedException('InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->_unitOfWork->lock(null, null, null); } @@ -273,7 +273,7 @@ class UnitOfWorkTest extends OrmTestCase $user->username = 'John'; $user->avatar = $invalidValue; - $this->setExpectedException('Doctrine\ORM\ORMInvalidArgumentException'); + $this->expectException(\Doctrine\ORM\ORMInvalidArgumentException::class); $this->_unitOfWork->persist($user); } @@ -301,7 +301,7 @@ class UnitOfWorkTest extends OrmTestCase $user->username = 'John'; $user->avatar = $invalidValue; - $this->setExpectedException('Doctrine\ORM\ORMInvalidArgumentException'); + $this->expectException(\Doctrine\ORM\ORMInvalidArgumentException::class); $this->_unitOfWork->computeChangeSet($metadata, $user); } diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index a03031a16..d18b94965 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -742,7 +742,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase * * @throws \Exception */ - protected function onNotSuccessfulTest(\Exception $e) + protected function onNotSuccessfulTest($e) { if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { throw $e; From ed7f658437ae1518b9a4944fd116c5b8b616c11b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Jun 2016 08:41:00 +0200 Subject: [PATCH 035/144] Testing against PHP nightly, but allowing it to fail --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ce6a24f6d..3b16e5551 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ php: - 5.5 - 5.6 - 7.0 - - 7.1 + - nightly - hhvm env: @@ -64,6 +64,8 @@ matrix: exclude: - php: hhvm env: DB=pgsql # driver for PostgreSQL currently unsupported by HHVM, requires 3rd party dependency + allow_failures: + - php: nightly sudo: false From 1610d916a4137214385e21e9bc8dcc163feecf06 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Jun 2016 08:51:24 +0200 Subject: [PATCH 036/144] Stop testing against PHP 5.5 --- .travis.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b16e5551..5a9fb2dcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.5 - 5.6 - 7.0 - nightly @@ -28,10 +27,6 @@ after_script: matrix: include: - - php: 5.5 - env: DB=mariadb - addons: - mariadb: 5.5 - php: 5.6 env: DB=mariadb addons: @@ -45,10 +40,6 @@ matrix: addons: mariadb: 5.5 - - php: 5.5 - env: DB=mariadb - addons: - mariadb: 10.1 - php: 5.6 env: DB=mariadb addons: From e409c1020927b6f2d7343c6b8ddc9f068ec171e2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Jun 2016 08:51:48 +0200 Subject: [PATCH 037/144] Requiring at least PHP 5.6 as minimum installed PHP version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f8ebcbf15..ccf216c9a 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ ], "minimum-stability": "dev", "require": { - "php": "^5.5 || ^7.0", + "php": "^5.6 || ^7.0", "ext-pdo": "*", "doctrine/collections": "~1.2", "doctrine/dbal": ">=2.5-dev,<2.7-dev", From d00069e38b5563da0f7c8f0221c8086d8d1115b5 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Jun 2016 09:28:12 +0200 Subject: [PATCH 038/144] Reverting 741da7806c5d01796e243de9a122590151cb0c90, which was causing issues due to loose type checking See this example on why the revert is needed: https://3v4l.org/8T34v Code copied for reference: ```php lock($entity, $lockMode, $lockVersion); break; - case LockMode::NONE: - case LockMode::PESSIMISTIC_READ: - case LockMode::PESSIMISTIC_WRITE: + case LockMode::NONE === $lockMode: + case LockMode::PESSIMISTIC_READ === $lockMode: + case LockMode::PESSIMISTIC_WRITE === $lockMode: $persister = $unitOfWork->getEntityPersister($class->name); $persister->refresh($sortedId, $entity, $lockMode); break; @@ -439,8 +439,8 @@ use Doctrine\Common\Util\ClassUtils; $persister = $unitOfWork->getEntityPersister($class->name); - switch ($lockMode) { - case LockMode::OPTIMISTIC: + switch (true) { + case LockMode::OPTIMISTIC === $lockMode: if ( ! $class->isVersioned) { throw OptimisticLockException::notVersioned($class->name); } @@ -451,8 +451,8 @@ use Doctrine\Common\Util\ClassUtils; return $entity; - case LockMode::PESSIMISTIC_READ: - case LockMode::PESSIMISTIC_WRITE: + case LockMode::PESSIMISTIC_READ === $lockMode: + case LockMode::PESSIMISTIC_WRITE === $lockMode: if ( ! $this->getConnection()->isTransactionActive()) { throw TransactionRequiredException::transactionRequired(); } From 27f3bc1e2c5885f4a6b5281581ce2c48eb578d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Thu, 9 Jun 2016 19:46:37 +0000 Subject: [PATCH 039/144] Allow the usage of embedded objects on parent classes. The `ClassMetadataInfo` was always using the "current class" to fetch the reflection of a property even when a field is declared on the parent class (which causes `ReflectionProperty` to throw an exception). --- .../ORM/Mapping/ClassMetadataInfo.php | 9 ++- .../Tests/Models/DDC3303/DDC3303Address.php | 60 ++++++++++++++++++ .../Tests/Models/DDC3303/DDC3303Employee.php | 39 ++++++++++++ .../Tests/Models/DDC3303/DDC3303Person.php | 61 +++++++++++++++++++ .../ORM/Functional/Ticket/DDC3303Test.php | 32 ++++++++++ 5 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php create mode 100644 tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php create mode 100644 tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 90db1f8a6..5fa8f9e07 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -941,8 +941,13 @@ class ClassMetadataInfo implements ClassMetadata continue; } - $parentReflFields[$property] = $reflService->getAccessibleProperty($this->name, $property); - $this->reflFields[$property] = $reflService->getAccessibleProperty($this->name, $property); + $fieldRefl = $reflService->getAccessibleProperty( + isset($embeddedClass['declared']) ? $embeddedClass['declared'] : $this->name, + $property + ); + + $parentReflFields[$property] = $fieldRefl; + $this->reflFields[$property] = $fieldRefl; } foreach ($this->fieldMappings as $field => $mapping) { diff --git a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php new file mode 100644 index 000000000..c3b634abf --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php @@ -0,0 +1,60 @@ +street = $street; + $this->number = $number; + $this->city = $city; + } + + /** + * @return string + */ + public function getStreet() + { + return $this->street; + } + + /** + * @return mixed + */ + public function getNumber() + { + return $this->number; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } +} diff --git a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php new file mode 100644 index 000000000..334dc2052 --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php @@ -0,0 +1,39 @@ +company = $company; + } + + /** + * @return string + */ + public function getCompany() + { + return $this->company; + } + + /** + * @param string $company + */ + public function setCompany($company) + { + $this->company = $company; + } +} diff --git a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php new file mode 100644 index 000000000..da42d1c54 --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php @@ -0,0 +1,61 @@ +name = $name; + $this->address = $address; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return DDC3303Address + */ + public function getAddress() + { + return $this->address; + } +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php new file mode 100644 index 000000000..e6415d393 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -0,0 +1,32 @@ +_schemaTool->createSchema(array($this->_em->getClassMetadata(DDC3303Employee::class))); + } + + public function testEmbeddedObjectsAreAlsoInherited() + { + $employee = new DDC3303Employee( + 'John Doe', + new DDC3303Address('Somewhere', 123, 'Over the rainbow'), + 'Doctrine Inc' + ); + + $this->_em->persist($employee); + $this->_em->flush(); + $this->_em->clear(); + + $this->assertEquals($employee, $this->_em->find(DDC3303Employee::class, 1)); + } +} From aa8cf7bae992a389b79ce47c0dee7725c7843a81 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Jun 2016 12:42:49 +0200 Subject: [PATCH 040/144] #5867 simplifying test case by inlining all required models into the test case --- .../Tests/Models/DDC3303/DDC3303Address.php | 60 ---------------- .../Tests/Models/DDC3303/DDC3303Employee.php | 39 ----------- .../Tests/Models/DDC3303/DDC3303Person.php | 61 ----------------- .../ORM/Functional/Ticket/DDC3303Test.php | 68 ++++++++++++++++--- 4 files changed, 60 insertions(+), 168 deletions(-) delete mode 100644 tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php delete mode 100644 tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php delete mode 100644 tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php diff --git a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php deleted file mode 100644 index c3b634abf..000000000 --- a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Address.php +++ /dev/null @@ -1,60 +0,0 @@ -street = $street; - $this->number = $number; - $this->city = $city; - } - - /** - * @return string - */ - public function getStreet() - { - return $this->street; - } - - /** - * @return mixed - */ - public function getNumber() - { - return $this->number; - } - - /** - * @return string - */ - public function getCity() - { - return $this->city; - } -} diff --git a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php deleted file mode 100644 index 334dc2052..000000000 --- a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Employee.php +++ /dev/null @@ -1,39 +0,0 @@ -company = $company; - } - - /** - * @return string - */ - public function getCompany() - { - return $this->company; - } - - /** - * @param string $company - */ - public function setCompany($company) - { - $this->company = $company; - } -} diff --git a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php b/tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php deleted file mode 100644 index da42d1c54..000000000 --- a/tests/Doctrine/Tests/Models/DDC3303/DDC3303Person.php +++ /dev/null @@ -1,61 +0,0 @@ -name = $name; - $this->address = $address; - } - - /** - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return DDC3303Address - */ - public function getAddress() - { - return $this->address; - } -} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index e6415d393..b122d9df6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -1,18 +1,15 @@ _schemaTool->createSchema(array($this->_em->getClassMetadata(DDC3303Employee::class))); + parent::setUp(); + + $this->_schemaTool->createSchema([$this->_em->getClassMetadata(DDC3303Employee::class)]); } public function testEmbeddedObjectsAreAlsoInherited() @@ -27,6 +24,61 @@ class DDC3303Test extends OrmFunctionalTestCase $this->_em->flush(); $this->_em->clear(); - $this->assertEquals($employee, $this->_em->find(DDC3303Employee::class, 1)); + self::assertEquals($employee, $this->_em->find(DDC3303Employee::class, 'John Doe')); + } +} + +/** @MappedSuperclass */ +abstract class DDC3303Person +{ + /** @Id @GeneratedValue(strategy="NONE") @Column(type="string") @var string */ + private $name; + + /** @Embedded(class="DDC3303Address") @var DDC3303Address */ + private $address; + + public function __construct($name, DDC3303Address $address) + { + $this->name = $name; + $this->address = $address; + } +} + +/** + * @Embeddable + */ +class DDC3303Address +{ + /** @Column(type="string") @var string */ + private $street; + + /** @Column(type="integer") @var int */ + private $number; + + /** @Column(type="string") @var string */ + private $city; + + public function __construct($street, $number, $city) + { + $this->street = $street; + $this->number = $number; + $this->city = $city; + } +} + +/** + * @Entity + * @Table(name="ddc3303_employee") + */ +class DDC3303Employee extends DDC3303Person +{ + /** @Column(type="string") @var string */ + private $company; + + public function __construct($name, DDC3303Address $address, $company) + { + parent::__construct($name, $address); + + $this->company = $company; } } From 18e3cb4440cd27878b65af7f3cb863a37bc768e8 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 19 Jun 2016 12:44:19 +0200 Subject: [PATCH 041/144] #5867 `@group` annotations, describing scenario --- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php index b122d9df6..b40f99ff9 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php @@ -12,6 +12,13 @@ class DDC3303Test extends OrmFunctionalTestCase $this->_schemaTool->createSchema([$this->_em->getClassMetadata(DDC3303Employee::class)]); } + /** + * @group 4097 + * @group 4277 + * @group 5867 + * + * When using an embedded field in an inheritance, private properties should also be inherited. + */ public function testEmbeddedObjectsAreAlsoInherited() { $employee = new DDC3303Employee( From 56a6505294b1dd5dca62bb5c443daa28cbf99dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Potk=C3=A1ny?= Date: Sun, 19 Jun 2016 14:46:02 +0200 Subject: [PATCH 042/144] removed some unused variables --- lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php | 2 -- lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php index 12713e1a7..b14ddb534 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableDeleteExecutor.php @@ -118,8 +118,6 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor */ public function execute(Connection $conn, array $params, array $types) { - $numDeleted = 0; - // Create temporary id table $conn->executeUpdate($this->_createTempTableSql); diff --git a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php index b47ba1795..995f9cad1 100644 --- a/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/MultiTableUpdateExecutor.php @@ -163,8 +163,6 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor */ public function execute(Connection $conn, array $params, array $types) { - $numUpdated = 0; - // Create temporary id table $conn->executeUpdate($this->_createTempTableSql); From 76badc296a14576ca396761fdc8eced234723d75 Mon Sep 17 00:00:00 2001 From: Christopher Anciaux Date: Mon, 20 Jun 2016 14:20:36 +0200 Subject: [PATCH 043/144] Fix typo in PHPDoc block of QueryBuilder.php --- lib/Doctrine/ORM/QueryBuilder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 2dfbf800e..ca754d66d 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -469,14 +469,15 @@ class QueryBuilder * $qb = $em->createQueryBuilder() * ->select('u') * ->from('User', 'u') - * ->join('u.articles','a'; + * ->join('u.articles','a'); * * $qb->getAllAliases(); // array('u','a') * * @return array */ - public function getAllAliases() { - return array_merge($this->getRootAliases(),array_keys($this->joinRootAliases)); + public function getAllAliases() + { + return array_merge($this->getRootAliases(), array_keys($this->joinRootAliases)); } /** From 58d8b86bd54e90dc5957120b8a9f5bcfd458e6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=BChn?= Date: Mon, 20 Jun 2016 21:17:36 +0200 Subject: [PATCH 044/144] #5882 recommend using latest stable PHP version in the getting started guide --- docs/en/tutorials/getting-started.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index c9e75d4f4..6b5cb7294 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -17,7 +17,7 @@ This guide is designed for beginners that haven't worked with Doctrine ORM before. There are some prerequesites for the tutorial that have to be installed: -- PHP 5.4 or above +- PHP (latest stable version) - Composer Package Manager (`Install Composer `_) From 2ab752bfc312924771d422d8d805dc43d3492c1e Mon Sep 17 00:00:00 2001 From: radmax Date: Wed, 22 Jun 2016 17:06:16 +0200 Subject: [PATCH 045/144] typo --- docs/en/reference/security.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/security.rst b/docs/en/reference/security.rst index efc0989cf..bb5f0f876 100644 --- a/docs/en/reference/security.rst +++ b/docs/en/reference/security.rst @@ -32,7 +32,7 @@ You can consider the following APIs to be safe from SQL injection: - Queries through the Criteria API on ``Doctrine\ORM\PersistentCollection`` and ``Doctrine\ORM\EntityRepository``. -You are **NOT** save from SQL injection when using user input with: +You are **NOT** safe from SQL injection when using user input with: - Expression API of ``Doctrine\ORM\QueryBuilder`` - Concatenating user input into DQL SELECT, UPDATE or DELETE statements or From a3e9529c02d054ce962c2d826b8f5ca023e87993 Mon Sep 17 00:00:00 2001 From: Menno Holtkamp Date: Sat, 25 Jun 2016 17:29:04 +0200 Subject: [PATCH 046/144] Fixed typo (serves => servers) --- docs/en/cookbook/working-with-datetime.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/cookbook/working-with-datetime.rst b/docs/en/cookbook/working-with-datetime.rst index 660f2bbcf..98a1fb234 100644 --- a/docs/en/cookbook/working-with-datetime.rst +++ b/docs/en/cookbook/working-with-datetime.rst @@ -49,7 +49,7 @@ By default Doctrine assumes that you are working with a default timezone. Each D is created by Doctrine will be assigned the timezone that is currently the default, either through the ``date.timezone`` ini setting or by calling ``date_default_timezone_set()``. -This is very important to handle correctly if your application runs on different serves or is moved from one to another server +This is very important to handle correctly if your application runs on different servers or is moved from one to another server (with different timezone settings). You have to make sure that the timezone is the correct one on all this systems. From 015ec444c50abc7fb3999aa815cc298243da01f6 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Fri, 1 Jul 2016 01:17:25 +0300 Subject: [PATCH 047/144] use PHP common functions --- lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 8e45117ab..70d47655d 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -583,10 +583,7 @@ class ObjectHydrator extends AbstractHydrator parent::onClear($eventArgs); $aliases = array_keys($this->identifierMap); - $this->identifierMap = array(); - foreach ($aliases as $alias) { - $this->identifierMap[$alias] = array(); - } + $this->identifierMap = array_fill_keys($aliases, []); } } From 8eef0beacb5250d3776566b08f91471d04113553 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Fri, 1 Jul 2016 01:20:52 +0300 Subject: [PATCH 048/144] clear code --- lib/Doctrine/ORM/Query/Parser.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 7619359ce..6f8eda514 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -827,17 +827,13 @@ class Parser return; } - $foundRootEntity = false; - foreach ($this->identVariableExpressions as $dqlAlias => $expr) { if (isset($this->queryComponents[$dqlAlias]) && $this->queryComponents[$dqlAlias]['parent'] === null) { - $foundRootEntity = true; + return; } } - if ( ! $foundRootEntity) { - $this->semanticalError('Cannot select entity through identification variables without choosing at least one root entity alias.'); - } + $this->semanticalError('Cannot select entity through identification variables without choosing at least one root entity alias.'); } /** From 16cddd4693f50b88fb1320dc0590f5fd328d66cd Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 22:13:06 +0300 Subject: [PATCH 049/144] claar code from `Scrutinizer` --- lib/Doctrine/ORM/UnitOfWork.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 7044ce57e..b2c1c6f4b 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1796,7 +1796,7 @@ class UnitOfWork implements PropertyChangedListener * @throws ORMInvalidArgumentException If the entity instance is NEW. * @throws EntityNotFoundException */ - private function doMerge($entity, array &$visited, $prevManagedCopy = null, $assoc = null) + private function doMerge($entity, array &$visited, $prevManagedCopy = null, array $assoc = []) { $oid = spl_object_hash($entity); From 347d1625bcbd42325df31cf92953648446786f90 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 22:33:23 +0300 Subject: [PATCH 050/144] merge conditions --- lib/Doctrine/ORM/UnitOfWork.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index b2c1c6f4b..dfc8d9ce0 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1155,9 +1155,9 @@ class UnitOfWork implements PropertyChangedListener } $joinColumns = reset($assoc['joinColumns']); - $isNullable = isset($joinColumns['nullable']) ? $joinColumns['nullable'] : false; + $weight = (int)empty($joinColumns['nullable']); - $calc->addDependency($targetClass->name, $class->name, $isNullable ? 0 : 1); + $calc->addDependency($targetClass->name, $class->name, $weight); // If the target class has mapped subclasses, these share the same dependency. if ( ! $targetClass->subClasses) { From db6c593463f8b545a435c730fbb059e58a07af69 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 22:37:12 +0300 Subject: [PATCH 051/144] clear code --- lib/Doctrine/ORM/UnitOfWork.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index dfc8d9ce0..cbf9e08be 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1344,9 +1344,7 @@ class UnitOfWork implements PropertyChangedListener $this->removeFromIdentityMap($entity); - if (isset($this->entityUpdates[$oid])) { - unset($this->entityUpdates[$oid]); - } + unset($this->entityUpdates[$oid]); if ( ! isset($this->entityDeletions[$oid])) { $this->entityDeletions[$oid] = $entity; From c6675b0ce3584f435559ce167e0716c806da47f8 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 22:42:46 +0300 Subject: [PATCH 052/144] use ternary --- lib/Doctrine/ORM/UnitOfWork.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index cbf9e08be..609c191eb 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1566,11 +1566,9 @@ class UnitOfWork implements PropertyChangedListener { $stringIdHash = (string) $idHash; - if (isset($this->identityMap[$rootClassName][$stringIdHash])) { - return $this->identityMap[$rootClassName][$stringIdHash]; - } - - return false; + return isset($this->identityMap[$rootClassName][$stringIdHash]) + ? $this->identityMap[$rootClassName][$stringIdHash] + : false; } /** From 6bf6bae219041b2686d9b9cfd5d704d53f1bb14d Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 22:51:44 +0300 Subject: [PATCH 053/144] clear code --- lib/Doctrine/ORM/UnitOfWork.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 609c191eb..2089d3565 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2441,9 +2441,7 @@ class UnitOfWork implements PropertyChangedListener // TODO: if $coll is already scheduled for recreation ... what to do? // Just remove $coll from the scheduled recreations? - if (isset($this->collectionUpdates[$coid])) { - unset($this->collectionUpdates[$coid]); - } + unset($this->collectionUpdates[$coid]); $this->collectionDeletions[$coid] = $coll; } From a7c4ca82fd86d1eb1e786097085ecacd1baed5e3 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 22:59:16 +0300 Subject: [PATCH 054/144] use ternary --- lib/Doctrine/ORM/UnitOfWork.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 2089d3565..408d2c961 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2848,11 +2848,9 @@ class UnitOfWork implements PropertyChangedListener { $oid = spl_object_hash($entity); - if (isset($this->originalEntityData[$oid])) { - return $this->originalEntityData[$oid]; - } - - return array(); + return isset($this->originalEntityData[$oid]) + ? $this->originalEntityData[$oid] + : []; } /** From 52b2d9022a9d16b3d33d6760b8d058f07beaa234 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 23:00:40 +0300 Subject: [PATCH 055/144] use ternary --- lib/Doctrine/ORM/UnitOfWork.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 408d2c961..902ccd6d7 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2936,11 +2936,9 @@ class UnitOfWork implements PropertyChangedListener { $idHash = implode(' ', (array) $id); - if (isset($this->identityMap[$rootClassName][$idHash])) { - return $this->identityMap[$rootClassName][$idHash]; - } - - return false; + return isset($this->identityMap[$rootClassName][$idHash]) + ? $this->identityMap[$rootClassName][$idHash] + : false; } /** From c0fc4f115804f95a36d9c78714600d94e24bb6d9 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 23:02:13 +0300 Subject: [PATCH 056/144] use internal function --- lib/Doctrine/ORM/UnitOfWork.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 902ccd6d7..4c494831f 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2975,7 +2975,7 @@ class UnitOfWork implements PropertyChangedListener */ public function size() { - $countArray = array_map(function ($item) { return count($item); }, $this->identityMap); + $countArray = array_map('count', $this->identityMap); return array_sum($countArray); } From eccec87796d5437aed635e9f482ba1d7f4d35527 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 23:47:21 +0300 Subject: [PATCH 057/144] clear code --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 5fa8f9e07..1d618c2da 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1465,8 +1465,7 @@ class ClassMetadataInfo implements ClassMetadata $mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy - // unset optional indexBy attribute if its empty - if ( ! isset($mapping['indexBy']) || !$mapping['indexBy']) { + if (empty($mapping['indexBy'])) { unset($mapping['indexBy']); } From 2301fb3ff212bfb2265a65a09bbe7783c4f1201f Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 23:53:23 +0300 Subject: [PATCH 058/144] move common cascades --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 1d618c2da..49a4200a0 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1543,13 +1543,14 @@ class ClassMetadataInfo implements ClassMetadata // Cascades $cascades = isset($mapping['cascade']) ? array_map('strtolower', $mapping['cascade']) : array(); + $allCascades = array('remove', 'persist', 'refresh', 'merge', 'detach'); if (in_array('all', $cascades)) { - $cascades = array('remove', 'persist', 'refresh', 'merge', 'detach'); + $cascades = $allCascades; } - if (count($cascades) !== count(array_intersect($cascades, array('remove', 'persist', 'refresh', 'merge', 'detach')))) { + if (count($cascades) !== count(array_intersect($cascades, $allCascades))) { throw MappingException::invalidCascadeOption( - array_diff($cascades, array_intersect($cascades, array('remove', 'persist', 'refresh', 'merge', 'detach'))), + array_diff($cascades, array_intersect($cascades, $allCascades)), $this->name, $mapping['fieldName'] ); From f7317d700ce5f253d65e46d02a685e7ec41ae573 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sat, 2 Jul 2016 23:58:29 +0300 Subject: [PATCH 059/144] logical remove double condition --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 49a4200a0..3fc70c26c 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1546,11 +1546,9 @@ class ClassMetadataInfo implements ClassMetadata $allCascades = array('remove', 'persist', 'refresh', 'merge', 'detach'); if (in_array('all', $cascades)) { $cascades = $allCascades; - } - - if (count($cascades) !== count(array_intersect($cascades, $allCascades))) { + } elseif (count($cascades) !== count(array_intersect($cascades, $allCascades))) { throw MappingException::invalidCascadeOption( - array_diff($cascades, array_intersect($cascades, $allCascades)), + array_diff($cascades, $allCascades), $this->name, $mapping['fieldName'] ); From b108a2af52da928f5d55b30606eb1096f023b7b9 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:01:07 +0300 Subject: [PATCH 060/144] merge conditions --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 3fc70c26c..b3a545b69 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1583,7 +1583,7 @@ class ClassMetadataInfo implements ClassMetadata } if ($mapping['isOwningSide']) { - if ( ! isset($mapping['joinColumns']) || ! $mapping['joinColumns']) { + if (empty($mapping['joinColumns'])) { // Apply default join column $mapping['joinColumns'] = array( array( From a81458a0aaa2610a5b47d7c261d379b0dc074164 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:05:31 +0300 Subject: [PATCH 061/144] 1. merge conditions 2. convert `if` to `condition` --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index b3a545b69..9ba2a0447 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1597,8 +1597,8 @@ class ClassMetadataInfo implements ClassMetadata foreach ($mapping['joinColumns'] as &$joinColumn) { if ($mapping['type'] === self::ONE_TO_ONE && ! $this->isInheritanceTypeSingleTable()) { - if (count($mapping['joinColumns']) == 1) { - if ( ! isset($mapping['id']) || ! $mapping['id']) { + if (count($mapping['joinColumns']) === 1) { + if (empty($mapping['id'])) { $joinColumn['unique'] = true; } } else { @@ -1643,8 +1643,8 @@ class ClassMetadataInfo implements ClassMetadata $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']); } - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false; - $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove']; + $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; + $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; if ($mapping['orphanRemoval']) { unset($mapping['unique']); From 511b27517a4381ff9feef8db650d0297d09cea7a Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:10:43 +0300 Subject: [PATCH 062/144] refactoring: extract method --- .../ORM/Mapping/ClassMetadataInfo.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 9ba2a0447..2735bc7b5 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1679,11 +1679,7 @@ class ClassMetadataInfo implements ClassMetadata $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false; $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove']; - if (isset($mapping['orderBy'])) { - if ( ! is_array($mapping['orderBy'])) { - throw new InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy'])); - } - } + $this->assertMappingOrderBy($mapping); return $mapping; } @@ -1789,11 +1785,7 @@ class ClassMetadataInfo implements ClassMetadata $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false; - if (isset($mapping['orderBy'])) { - if ( ! is_array($mapping['orderBy'])) { - throw new InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy'])); - } - } + $this->assertMappingOrderBy($mapping); return $mapping; } @@ -3388,4 +3380,14 @@ class ClassMetadataInfo implements ClassMetadata return $sequencePrefix; } + + /** + * @param array $mapping + */ + private function assertMappingOrderBy(array $mapping) + { + if (isset($mapping['orderBy']) && !is_array($mapping['orderBy'])) { + throw new InvalidArgumentException("'orderBy' is expected to be an array, not " . gettype($mapping['orderBy'])); + } + } } From 0e8491a4747c5d555374b4b4498db1c0629f56d0 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:11:44 +0300 Subject: [PATCH 063/144] clear code --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 2735bc7b5..8c82ac155 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1676,8 +1676,8 @@ class ClassMetadataInfo implements ClassMetadata throw MappingException::oneToManyRequiresMappedBy($mapping['fieldName']); } - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false; - $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove']; + $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; + $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove']; $this->assertMappingOrderBy($mapping); From 1dba0b85454ca208f7f975f2cb2b8db45d67f408 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:14:33 +0300 Subject: [PATCH 064/144] clear code --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 8c82ac155..d828335ca 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1783,7 +1783,7 @@ class ClassMetadataInfo implements ClassMetadata } } - $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false; + $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval']; $this->assertMappingOrderBy($mapping); From 99b1eaaabbdac5cefd2204b0d988ada5f2d485c7 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:17:51 +0300 Subject: [PATCH 065/144] clear code - double condition after isset --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index d828335ca..53eedacca 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -2203,11 +2203,11 @@ class ClassMetadataInfo implements ClassMetadata $overrideMapping['id'] = $mapping['id']; } - if ( ! isset($overrideMapping['type']) || $overrideMapping['type'] === null) { + if ( ! isset($overrideMapping['type'])) { $overrideMapping['type'] = $mapping['type']; } - if ( ! isset($overrideMapping['fieldName']) || $overrideMapping['fieldName'] === null) { + if ( ! isset($overrideMapping['fieldName'])) { $overrideMapping['fieldName'] = $mapping['fieldName']; } From f7c16ab364bb4801f176eb20342adfe08f812bec Mon Sep 17 00:00:00 2001 From: ReenExe Date: Sun, 3 Jul 2016 00:21:00 +0300 Subject: [PATCH 066/144] remove `else` --- .../ORM/Mapping/ClassMetadataInfo.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 53eedacca..9e036b652 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -2943,17 +2943,17 @@ class ClassMetadataInfo implements ClassMetadata { if (isset($this->fieldNames[$columnName])) { return $this->fieldNames[$columnName]; - } else { - foreach ($this->associationMappings as $assocName => $mapping) { - if ($this->isAssociationWithSingleJoinColumn($assocName) && - $this->associationMappings[$assocName]['joinColumns'][0]['name'] == $columnName) { - - return $assocName; - } - } - - throw MappingException::noFieldNameFoundForColumn($this->name, $columnName); } + + foreach ($this->associationMappings as $assocName => $mapping) { + if ($this->isAssociationWithSingleJoinColumn($assocName) && + $this->associationMappings[$assocName]['joinColumns'][0]['name'] == $columnName) { + + return $assocName; + } + } + + throw MappingException::noFieldNameFoundForColumn($this->name, $columnName); } /** From bcc79839345ab476dd5912408bd0acacb88a30e8 Mon Sep 17 00:00:00 2001 From: ReenExe Date: Tue, 5 Jul 2016 19:15:47 +0300 Subject: [PATCH 067/144] after review --- lib/Doctrine/ORM/UnitOfWork.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 4c494831f..c54d97a0b 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1155,9 +1155,8 @@ class UnitOfWork implements PropertyChangedListener } $joinColumns = reset($assoc['joinColumns']); - $weight = (int)empty($joinColumns['nullable']); - $calc->addDependency($targetClass->name, $class->name, $weight); + $calc->addDependency($targetClass->name, $class->name, (int)empty($joinColumns['nullable'])); // If the target class has mapped subclasses, these share the same dependency. if ( ! $targetClass->subClasses) { From 1880cbd8b628cd59b7c6113deacaf45a895e8313 Mon Sep 17 00:00:00 2001 From: Tony Nelson Date: Tue, 5 Jul 2016 12:46:16 -0500 Subject: [PATCH 068/144] Update dql-doctrine-query-language.rst --- docs/en/reference/dql-doctrine-query-language.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/reference/dql-doctrine-query-language.rst b/docs/en/reference/dql-doctrine-query-language.rst index ae4ee11e8..6f9874411 100644 --- a/docs/en/reference/dql-doctrine-query-language.rst +++ b/docs/en/reference/dql-doctrine-query-language.rst @@ -909,7 +909,7 @@ An instance of the ``Doctrine\ORM\Query`` class represents a DQL query. You create a Query instance be calling ``EntityManager#createQuery($dql)``, passing the DQL query string. Alternatively you can create an empty ``Query`` instance and invoke -``Query#setDql($dql)`` afterwards. Here are some examples: +``Query#setDQL($dql)`` afterwards. Here are some examples: .. code-block:: php @@ -919,9 +919,9 @@ Alternatively you can create an empty ``Query`` instance and invoke // example1: passing a DQL string $q = $em->createQuery('select u from MyProject\Model\User u'); - // example2: using setDql + // example2: using setDQL $q = $em->createQuery(); - $q->setDql('select u from MyProject\Model\User u'); + $q->setDQL('select u from MyProject\Model\User u'); Query Result Formats ~~~~~~~~~~~~~~~~~~~~ From cd36407f28691dba06bcc6864d8d9c3b567d6cbc Mon Sep 17 00:00:00 2001 From: Tony Nelson Date: Tue, 5 Jul 2016 12:48:00 -0500 Subject: [PATCH 069/144] Update EntityManager.php --- lib/Doctrine/ORM/EntityManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 7a2e378fb..4de4932bc 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -290,7 +290,7 @@ use Doctrine\Common\Util\ClassUtils; $query = new Query($this); if ( ! empty($dql)) { - $query->setDql($dql); + $query->setDQL($dql); } return $query; @@ -311,7 +311,7 @@ use Doctrine\Common\Util\ClassUtils; { $query = new NativeQuery($this); - $query->setSql($sql); + $query->setSQL($sql); $query->setResultSetMapping($rsm); return $query; From 12789ee6cacc2cad32c9b244e8e41bef8b7b3529 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 19:27:49 +0200 Subject: [PATCH 070/144] Basic tests around `addToIdentityMap` with valid string identifiers (empty string allowed) --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 77 +++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 9b0c6a8f5..51823aa27 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -363,6 +363,43 @@ class UnitOfWorkTest extends OrmTestCase [new ArrayCollection()], ]; } + + /** + * @dataProvider entitiesWithValidIdentifiersProvider + * + * @param object $entity + * + * @return void + */ + public function testAddToIdentityMapValidIdentifiers($entity) + { + $this->_unitOfWork->registerManaged( + $entity, + $this->_emMock->getClassMetadata(get_class($entity))->getIdentifierValues($entity), + [] + ); + $this->_unitOfWork->addToIdentityMap($entity); + + self::assertInternalType('string', $this->_unitOfWork->getEntityIdentifier($entity)); + // note: cloning to avoid lookup by spl_object_hash() + self::assertTrue($this->_unitOfWork->isInIdentityMap(clone $entity)); + } + + public function entitiesWithValidIdentifiersProvider() + { + $emptyString = new EntityWithStringIdentifier(); + + $emptyString->id = ''; + + $nonEmptyString = new EntityWithStringIdentifier(); + + $nonEmptyString->id = uniqid('', true); + + return [ + 'empty string, single field' => [$emptyString], + 'non-empty string, single field' => [$nonEmptyString], + ]; + } } /** @@ -469,3 +506,43 @@ class VersionedAssignedIdentifierEntity */ public $version; } + +/** @Entity */ +class EntityWithStringIdentifier +{ + /** + * @Id @Column(type="string") + * + * @var string|null + */ + public $id; +} + +/** @Entity */ +class EntityWithBooleanIdentifier +{ + /** + * @Id @Column(type="boolean") + * + * @var bool|null + */ + public $id; +} + +/** @Entity */ +class EntityWithCompositeStringIdentifier +{ + /** + * @Id @Column(type="string") + * + * @var string|null + */ + public $id1; + + /** + * @Id @Column(type="string") + * + * @var string|null + */ + public $id2; +} From 549bfe127c79266f64b6534ffed81799570760f3 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 19:34:24 +0200 Subject: [PATCH 071/144] Correcting test case: expecting identifier hashes to support empty strings --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 51823aa27..b0b38b9e2 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -368,10 +368,11 @@ class UnitOfWorkTest extends OrmTestCase * @dataProvider entitiesWithValidIdentifiersProvider * * @param object $entity + * @param string $idHash * * @return void */ - public function testAddToIdentityMapValidIdentifiers($entity) + public function testAddToIdentityMapValidIdentifiers($entity, $idHash) { $this->_unitOfWork->registerManaged( $entity, @@ -380,9 +381,8 @@ class UnitOfWorkTest extends OrmTestCase ); $this->_unitOfWork->addToIdentityMap($entity); - self::assertInternalType('string', $this->_unitOfWork->getEntityIdentifier($entity)); // note: cloning to avoid lookup by spl_object_hash() - self::assertTrue($this->_unitOfWork->isInIdentityMap(clone $entity)); + self::assertSame($entity, $this->_unitOfWork->getByIdHash($idHash, get_class($entity))); } public function entitiesWithValidIdentifiersProvider() @@ -395,9 +395,15 @@ class UnitOfWorkTest extends OrmTestCase $nonEmptyString->id = uniqid('', true); + $emptyStrings = new EntityWithCompositeStringIdentifier(); + + $emptyStrings->id1 = ''; + $emptyStrings->id2 = ''; + return [ - 'empty string, single field' => [$emptyString], - 'non-empty string, single field' => [$nonEmptyString], + 'empty string, single field' => [$emptyString, ''], + 'non-empty string, single field' => [$nonEmptyString, $nonEmptyString->id], + 'empty strings, two fields' => [$emptyStrings, ' '], ]; } } From 29d9f344e88e9281345c799188919d5764c9217a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 19:35:39 +0200 Subject: [PATCH 072/144] Non-empty composite key identifiers should also be supported --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index b0b38b9e2..6b5f63a6f 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -393,17 +393,23 @@ class UnitOfWorkTest extends OrmTestCase $nonEmptyString = new EntityWithStringIdentifier(); - $nonEmptyString->id = uniqid('', true); + $nonEmptyString->id = uniqid('id', true); $emptyStrings = new EntityWithCompositeStringIdentifier(); $emptyStrings->id1 = ''; $emptyStrings->id2 = ''; + $nonEmptyStrings = new EntityWithCompositeStringIdentifier(); + + $nonEmptyStrings->id1 = uniqid('id1', true); + $nonEmptyStrings->id2 = uniqid('id2', true); + return [ 'empty string, single field' => [$emptyString, ''], 'non-empty string, single field' => [$nonEmptyString, $nonEmptyString->id], 'empty strings, two fields' => [$emptyStrings, ' '], + 'non-empty strings, two fields' => [$nonEmptyStrings, $nonEmptyStrings->id1 . ' ' . $nonEmptyStrings->id2], ]; } } From aa1fda6d5fb940b2ad888e40c13c30a52f69a3a8 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 19:38:48 +0200 Subject: [PATCH 073/144] Checking for boolean true/false identifiers --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 6b5f63a6f..b26fce19f 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -405,11 +405,21 @@ class UnitOfWorkTest extends OrmTestCase $nonEmptyStrings->id1 = uniqid('id1', true); $nonEmptyStrings->id2 = uniqid('id2', true); + $booleanTrue = new EntityWithBooleanIdentifier(); + + $booleanTrue->id = true; + + $booleanFalse = new EntityWithBooleanIdentifier(); + + $booleanFalse->id = false; + return [ 'empty string, single field' => [$emptyString, ''], 'non-empty string, single field' => [$nonEmptyString, $nonEmptyString->id], 'empty strings, two fields' => [$emptyStrings, ' '], 'non-empty strings, two fields' => [$nonEmptyStrings, $nonEmptyStrings->id1 . ' ' . $nonEmptyStrings->id2], + 'boolean true' => [$booleanTrue, '1'], + 'boolean false' => [$booleanTrue, ''], ]; } } From da7582d32976edd151ea76dd05fcee05067d9e41 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 19:43:03 +0200 Subject: [PATCH 074/144] Typo fix: s/$booleanTrue/$booleanFalse (C&P mistake) --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index b26fce19f..67121e1a4 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -419,7 +419,7 @@ class UnitOfWorkTest extends OrmTestCase 'empty strings, two fields' => [$emptyStrings, ' '], 'non-empty strings, two fields' => [$nonEmptyStrings, $nonEmptyStrings->id1 . ' ' . $nonEmptyStrings->id2], 'boolean true' => [$booleanTrue, '1'], - 'boolean false' => [$booleanTrue, ''], + 'boolean false' => [$booleanFalse, ''], ]; } } From 9abccba1093bbefbd4b08e676b74265ceaa8dbfa Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 19:58:43 +0200 Subject: [PATCH 075/144] When invalid (null) identifiers are provided, an exception should be thrown --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 67121e1a4..e94a187d7 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\NotifyPropertyChanged; use Doctrine\Common\PropertyChangedListener; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\ORMInvalidArgumentException; use Doctrine\ORM\UnitOfWork; use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; @@ -422,6 +423,61 @@ class UnitOfWorkTest extends OrmTestCase 'boolean false' => [$booleanFalse, ''], ]; } + + /** + * @dataProvider entitiesWithInvalidIdentifiersProvider + * + * @param object $entity + * + * @return void + */ + public function testAddToIdentityMapInvalidIdentifiers($entity) + { + $this->_unitOfWork->registerManaged( + $entity, + $this->_emMock->getClassMetadata(get_class($entity))->getIdentifierValues($entity), + [] + ); + + $this->expectException(ORMInvalidArgumentException::class); + + $this->_unitOfWork->addToIdentityMap($entity); + } + + + public function entitiesWithInvalidIdentifiersProvider() + { + $emptyString = new EntityWithStringIdentifier(); + + $emptyString->id = ''; + + $nonEmptyString = new EntityWithStringIdentifier(); + + $nonEmptyString->id = uniqid('id', true); + + $emptyStrings = new EntityWithCompositeStringIdentifier(); + + $emptyStrings->id1 = ''; + $emptyStrings->id2 = ''; + + $nonEmptyStrings = new EntityWithCompositeStringIdentifier(); + + $nonEmptyStrings->id1 = uniqid('id1', true); + $nonEmptyStrings->id2 = uniqid('id2', true); + + $booleanTrue = new EntityWithBooleanIdentifier(); + + $booleanTrue->id = true; + + $booleanFalse = new EntityWithBooleanIdentifier(); + + $booleanFalse->id = false; + + return [ + 'null string, single field' => [new EntityWithStringIdentifier()], + 'null strings, two fieldds' => [new EntityWithCompositeStringIdentifier()], + ]; + } } /** From 5b8b548bd4b91118ace8da96c6e01e5ed8aee445 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 20:08:24 +0200 Subject: [PATCH 076/144] When invalid (null) identifiers are provided, an exception should be thrown --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 32 ++++++--------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index e94a187d7..cab05d56d 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -447,35 +447,19 @@ class UnitOfWorkTest extends OrmTestCase public function entitiesWithInvalidIdentifiersProvider() { - $emptyString = new EntityWithStringIdentifier(); + $firstNullString = new EntityWithCompositeStringIdentifier(); - $emptyString->id = ''; + $firstNullString->id2 = uniqid('id2', true); - $nonEmptyString = new EntityWithStringIdentifier(); + $secondNullString = new EntityWithCompositeStringIdentifier(); - $nonEmptyString->id = uniqid('id', true); - - $emptyStrings = new EntityWithCompositeStringIdentifier(); - - $emptyStrings->id1 = ''; - $emptyStrings->id2 = ''; - - $nonEmptyStrings = new EntityWithCompositeStringIdentifier(); - - $nonEmptyStrings->id1 = uniqid('id1', true); - $nonEmptyStrings->id2 = uniqid('id2', true); - - $booleanTrue = new EntityWithBooleanIdentifier(); - - $booleanTrue->id = true; - - $booleanFalse = new EntityWithBooleanIdentifier(); - - $booleanFalse->id = false; + $secondNullString->id1 = uniqid('id1', true); return [ - 'null string, single field' => [new EntityWithStringIdentifier()], - 'null strings, two fieldds' => [new EntityWithCompositeStringIdentifier()], + 'null string, single field' => [new EntityWithStringIdentifier()], + 'null strings, two fields' => [new EntityWithCompositeStringIdentifier()], + 'first null string, two fields' => [$firstNullString], + 'second null string, two fields' => [$secondNullString], ]; } } From 282917426747fcb11d7beaf669af0eb571266402 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 20:28:21 +0200 Subject: [PATCH 077/144] Simplified test: invalid entities must make it in the `UnitOfWork` manually, via `registerManaged` --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 25 +++++++-------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index cab05d56d..4ecbdc3e0 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -375,11 +375,7 @@ class UnitOfWorkTest extends OrmTestCase */ public function testAddToIdentityMapValidIdentifiers($entity, $idHash) { - $this->_unitOfWork->registerManaged( - $entity, - $this->_emMock->getClassMetadata(get_class($entity))->getIdentifierValues($entity), - [] - ); + $this->_unitOfWork->persist($entity); $this->_unitOfWork->addToIdentityMap($entity); // note: cloning to avoid lookup by spl_object_hash() @@ -428,20 +424,15 @@ class UnitOfWorkTest extends OrmTestCase * @dataProvider entitiesWithInvalidIdentifiersProvider * * @param object $entity + * @param array $identifier * * @return void */ - public function testAddToIdentityMapInvalidIdentifiers($entity) + public function testAddToIdentityMapInvalidIdentifiers($entity, array $identifier) { - $this->_unitOfWork->registerManaged( - $entity, - $this->_emMock->getClassMetadata(get_class($entity))->getIdentifierValues($entity), - [] - ); - $this->expectException(ORMInvalidArgumentException::class); - $this->_unitOfWork->addToIdentityMap($entity); + $this->_unitOfWork->registerManaged($entity, $identifier, []); } @@ -456,10 +447,10 @@ class UnitOfWorkTest extends OrmTestCase $secondNullString->id1 = uniqid('id1', true); return [ - 'null string, single field' => [new EntityWithStringIdentifier()], - 'null strings, two fields' => [new EntityWithCompositeStringIdentifier()], - 'first null string, two fields' => [$firstNullString], - 'second null string, two fields' => [$secondNullString], + 'null string, single field' => [new EntityWithStringIdentifier(), ['id' => null]], + 'null strings, two fields' => [new EntityWithCompositeStringIdentifier(), ['id1' => null, 'id2' => null]], + 'first null string, two fields' => [$firstNullString, ['id1' => null, 'id2' => $firstNullString->id2]], + 'second null string, two fields' => [$secondNullString, ['id1' => $secondNullString->id1, 'id2' => null]], ]; } } From 1cb8d790b64f542406a576b878d67abe284e7275 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 20:29:00 +0200 Subject: [PATCH 078/144] Disallowing `null` as part of the entity identifier --- lib/Doctrine/ORM/UnitOfWork.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index c54d97a0b..23bee1401 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1398,12 +1398,13 @@ class UnitOfWork implements PropertyChangedListener public function addToIdentityMap($entity) { $classMetadata = $this->em->getClassMetadata(get_class($entity)); - $idHash = implode(' ', $this->entityIdentifiers[spl_object_hash($entity)]); + $identifier = $this->entityIdentifiers[spl_object_hash($entity)]; - if ($idHash === '') { + if (in_array(null, $identifier, true)) { throw ORMInvalidArgumentException::entityWithoutIdentity($classMetadata->name, $entity); } + $idHash = implode(' ', $identifier); $className = $classMetadata->rootEntityName; if (isset($this->identityMap[$className][$idHash])) { From 7544934158eabe248986551b3d25eabacecbcc9c Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 20:39:52 +0200 Subject: [PATCH 079/144] Removing note that is not valid anymore --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 4ecbdc3e0..6ccaa51e4 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -378,7 +378,6 @@ class UnitOfWorkTest extends OrmTestCase $this->_unitOfWork->persist($entity); $this->_unitOfWork->addToIdentityMap($entity); - // note: cloning to avoid lookup by spl_object_hash() self::assertSame($entity, $this->_unitOfWork->getByIdHash($idHash, get_class($entity))); } From 0d82128b2e59c9142f1297bae13ed616405996ee Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 20:57:02 +0200 Subject: [PATCH 080/144] Registering a managed entity with an empty identifier is to be disallowed --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 6ccaa51e4..6a2c882e8 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -419,6 +419,13 @@ class UnitOfWorkTest extends OrmTestCase ]; } + public function testRegisteringAManagedInstanceRequiresANonEmptyIdentifier() + { + $this->expectException(ORMInvalidArgumentException::class); + + $this->_unitOfWork->registerManaged(new EntityWithBooleanIdentifier(), [], []); + } + /** * @dataProvider entitiesWithInvalidIdentifiersProvider * From dbcdc1d42a53dd3fdec33c976cd5e73d1d76de8f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 20:57:49 +0200 Subject: [PATCH 081/144] Empty identifiers must be disallowed --- lib/Doctrine/ORM/UnitOfWork.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 23bee1401..7ac24cc60 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1400,7 +1400,7 @@ class UnitOfWork implements PropertyChangedListener $classMetadata = $this->em->getClassMetadata(get_class($entity)); $identifier = $this->entityIdentifiers[spl_object_hash($entity)]; - if (in_array(null, $identifier, true)) { + if (empty($identifier) || in_array(null, $identifier, true)) { throw ORMInvalidArgumentException::entityWithoutIdentity($classMetadata->name, $entity); } From 5d12593e70752af2ca23baafed83dec3b0d17690 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 21:29:10 +0200 Subject: [PATCH 082/144] Rewrote `ManyToOne` SLC tests to not rely on multi-level auto-generated identifiers Background: Test relied on an `A->B->C` association: * `A#id` being `B` * `B#id` being `C` * `C#id` being an auto-generated identifier (post-insert) This cannot work, because it breaks the UnitOfWork's identity map. Specifically, no entries for `A` and `B` can exist in the identity map until `C` entries are persisted (post-insert). That means that the identifier generator for `A` and `B` should not be an "assigned" generator, but should instead be a post-insert generator waiting for other entities to be persisted. We cannot fix this in ORM 2.x, but we'll need to invent something for 3.x in order to fix that (directed graph, or caching the order of operations in the metadata graph). --- tests/Doctrine/Tests/Models/Cache/Action.php | 9 ++------- .../Doctrine/Tests/Models/Cache/ComplexAction.php | 4 ++-- tests/Doctrine/Tests/Models/Cache/Token.php | 6 +++--- .../Functional/SecondLevelCacheManyToOneTest.php | 14 +++++++------- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/tests/Doctrine/Tests/Models/Cache/Action.php b/tests/Doctrine/Tests/Models/Cache/Action.php index 25609abed..d23ab494b 100644 --- a/tests/Doctrine/Tests/Models/Cache/Action.php +++ b/tests/Doctrine/Tests/Models/Cache/Action.php @@ -14,13 +14,8 @@ class Action /** * @Id - * @GeneratedValue - * @Column(type="integer") - */ - public $id; - - /** - * @Column + * @Column(type="string") + * @GeneratedValue(strategy="NONE") */ public $name; diff --git a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php index 46d0414d3..5f5faf6dd 100644 --- a/tests/Doctrine/Tests/Models/Cache/ComplexAction.php +++ b/tests/Doctrine/Tests/Models/Cache/ComplexAction.php @@ -20,14 +20,14 @@ class ComplexAction /** * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) - * @JoinColumn(name="action1_id", referencedColumnName="id") + * @JoinColumn(name="action1_name", referencedColumnName="name") */ public $action1; /** * @Id * @OneToOne(targetEntity="Action", cascade={"persist", "remove"}) - * @JoinColumn(name="action2_id", referencedColumnName="id") + * @JoinColumn(name="action2_name", referencedColumnName="name") */ public $action2; diff --git a/tests/Doctrine/Tests/Models/Cache/Token.php b/tests/Doctrine/Tests/Models/Cache/Token.php index f6c712e36..ba3fdb182 100644 --- a/tests/Doctrine/Tests/Models/Cache/Token.php +++ b/tests/Doctrine/Tests/Models/Cache/Token.php @@ -36,7 +36,7 @@ class Token /** * @ManyToOne(targetEntity="Action", cascade={"persist", "remove"}, inversedBy="tokens") - * @JoinColumn(name="action_id", referencedColumnName="id") + * @JoinColumn(name="action_name", referencedColumnName="name") * @var array */ public $action; @@ -44,8 +44,8 @@ class Token /** * @ManyToOne(targetEntity="ComplexAction", cascade={"persist", "remove"}, inversedBy="tokens") * @JoinColumns({ - * @JoinColumn(name="complex_action1_id", referencedColumnName="action1_id"), - * @JoinColumn(name="complex_action2_id", referencedColumnName="action2_id") + * @JoinColumn(name="complex_action1_name", referencedColumnName="action1_name"), + * @JoinColumn(name="complex_action2_name", referencedColumnName="action2_name") * }) * @var ComplexAction */ diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php index 00fa40973..57215f8e0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php @@ -193,7 +193,7 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest $this->_em->clear(); $this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token)); - $this->assertFalse($this->cache->containsEntity(Token::CLASSNAME, $action->id)); + $this->assertFalse($this->cache->containsEntity(Token::CLASSNAME, $action->name)); $queryCount = $this->getCurrentQueryCount(); $entity = $this->_em->find(Token::CLASSNAME, $token->token); @@ -204,7 +204,7 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest $this->assertInstanceOf(Action::CLASSNAME, $entity->getAction()); $this->assertEquals('exec', $entity->getAction()->name); - $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + $this->assertEquals($queryCount, $this->getCurrentQueryCount()); } public function testPutAndLoadNonCacheableCompositeManyToOne() @@ -231,9 +231,9 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest $this->_em->clear(); $this->assertTrue($this->cache->containsEntity(Token::CLASSNAME, $token->token)); - $this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action1->id)); - $this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action2->id)); - $this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action3->id)); + $this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action1->name)); + $this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action2->name)); + $this->assertFalse($this->cache->containsEntity(Action::CLASSNAME, $action3->name)); $queryCount = $this->getCurrentQueryCount(); /** @@ -255,8 +255,8 @@ class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals('login', $entity->getComplexAction()->getAction1()->name); - $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); $this->assertEquals('rememberme', $entity->getComplexAction()->getAction2()->name); - $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); } } \ No newline at end of file From d330da898fcce3696f760a3086d38c9bae56110b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 22:24:37 +0200 Subject: [PATCH 083/144] Correcting order of deletes: `cache_token` relies on `cache_complex_action` --- tests/Doctrine/Tests/OrmFunctionalTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index d18b94965..6e17a92ad 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -460,8 +460,8 @@ abstract class OrmFunctionalTestCase extends OrmTestCase $conn->executeUpdate('DELETE FROM cache_state'); $conn->executeUpdate('DELETE FROM cache_country'); $conn->executeUpdate('DELETE FROM cache_login'); - $conn->executeUpdate('DELETE FROM cache_complex_action'); $conn->executeUpdate('DELETE FROM cache_token'); + $conn->executeUpdate('DELETE FROM cache_complex_action'); $conn->executeUpdate('DELETE FROM cache_action'); $conn->executeUpdate('DELETE FROM cache_client'); } From 44feacd32764207e2394d9f42e1de57f3571b79d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 7 Jul 2016 23:46:09 +0200 Subject: [PATCH 084/144] Corrected SLC test expected query count: since the identity map is now consistently hashing identifiers --- tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php index 61b9c7ce7..774945c5a 100644 --- a/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/SecondLevelCacheTest.php @@ -101,7 +101,7 @@ class SecondLevelCacheTest extends OrmFunctionalTestCase $this->findEntityOneToMany($em, __FUNCTION__); - $this->assertEquals(487, $this->countQuery($em)); + $this->assertEquals(472, $this->countQuery($em)); } public function testQueryEntityWithoutCache() From da43aa2d49cf48dcd9ee740f56c8150e1513576f Mon Sep 17 00:00:00 2001 From: Greg Bell Date: Tue, 12 Jul 2016 16:05:20 +1000 Subject: [PATCH 085/144] Clarify language regarding ArrayCollections. See https://groups.google.com/forum/#!topic/doctrine-user/yJ8ABqBP5mI --- docs/en/tutorials/getting-started.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 6b5cb7294..ef4734317 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -616,12 +616,12 @@ domain model to match the requirements: } } -Whenever an entity is recreated from the database, an Collection -implementation of the type Doctrine is injected into your entity -instead of an array. Compared to the ArrayCollection this -implementation helps the Doctrine ORM understand the changes that -have happened to the collection which are noteworthy for -persistence. +You use Doctrine's ArrayCollections in your Doctrine models, rather +than plain PHP arrays, so that Doctrine can watch what happens with +them and act appropriately. Note that if you dump your entities, +you'll see a "PersistentCollection" in place of your ArrayCollection, +which is just an +internal Doctrine class with the same interface. .. warning:: From b785a8dc02c4f5961cbc3d017ca2ae28542d8e1b Mon Sep 17 00:00:00 2001 From: Erik van Velzen Date: Mon, 18 Jul 2016 18:16:34 +0200 Subject: [PATCH 086/144] Add @CustomIdGenerator to documentation --- docs/en/reference/annotations-reference.rst | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index 19e9e8b70..7b59aa678 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -37,6 +37,7 @@ Index - :ref:`@ColumnResult ` - :ref:`@Cache ` - :ref:`@ChangeTrackingPolicy ` +- :ref:`@CustomIdGenerator ` - :ref:`@DiscriminatorColumn ` - :ref:`@DiscriminatorMap ` - :ref:`@Embeddable ` @@ -233,6 +234,30 @@ Example: */ class User {} +.. _annref_customidgenerator: + +@CustomIdGenerator +~~~~~~~~~~~~~~~~~~~~~ + +This annotations allows you to specify a user-provided class to generate identifiers. This annotation only works when both :ref:`@Id ` and :ref:`@GeneratedValue(strategy="CUSTOM") ` are specified. + +Required attributes: + +- **class**: name of the class which should extend Doctrine\ORM\Id\AbstractIdGenerator + +Example: + +.. code-block:: php + + Date: Fri, 12 Aug 2016 16:26:08 +0200 Subject: [PATCH 087/144] Wrong return type of getResult() @see https://github.com/doctrine/doctrine2/issues/5971 --- lib/Doctrine/ORM/AbstractQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 0b2b0663c..581a99c42 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -718,7 +718,7 @@ abstract class AbstractQuery * * @param int $hydrationMode * - * @return array + * @return mixed */ public function getResult($hydrationMode = self::HYDRATE_OBJECT) { From 0da6669fac1d91e2489958cc47ea1a9e73d3a66a Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Sat, 3 Sep 2016 23:52:34 +0300 Subject: [PATCH 088/144] Fix functional test query logger DebugStack starts queries array from index 1 rather than 0 so the last query was never printed. Also array params caused an 'Array to string conversion' error --- tests/Doctrine/Tests/OrmFunctionalTestCase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 6e17a92ad..907c00617 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -750,10 +750,10 @@ abstract class OrmFunctionalTestCase extends OrmTestCase if(isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) { $queries = ""; - for($i = count($this->_sqlLoggerStack->queries)-1; $i > max(count($this->_sqlLoggerStack->queries)-25, 0) && isset($this->_sqlLoggerStack->queries[$i]); $i--) { - $query = $this->_sqlLoggerStack->queries[$i]; - $params = array_map(function($p) { if (is_object($p)) return get_class($p); else return "'".$p."'"; }, $query['params'] ?: array()); - $queries .= ($i+1).". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL; + $last25queries = array_slice(array_reverse($this->_sqlLoggerStack->queries, true), 0, 25, true); + foreach ($last25queries as $i => $query) { + $params = array_map(function($p) { if (is_object($p)) return get_class($p); else return var_export($p, true); }, $query['params'] ?: array()); + $queries .= $i.". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL; } $trace = $e->getTrace(); From 3bec698fed43756cdf808ec0bd13b1cccb6159c6 Mon Sep 17 00:00:00 2001 From: John Keller Date: Tue, 12 Apr 2016 13:43:45 -0700 Subject: [PATCH 089/144] add functional test and bug fix for issue #5762 --- .../ORM/Internal/Hydration/ObjectHydrator.php | 3 + .../ORM/Functional/Ticket/GH5762Test.php | 228 ++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 70d47655d..ebea42cac 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -329,6 +329,9 @@ class ObjectHydrator extends AbstractHydrator // Split the row data into chunks of class data. $rowData = $this->gatherRowData($row, $id, $nonemptyComponents); + // reset result pointers for each data row + $this->resultPointers = array(); + // Hydrate the data chunks foreach ($rowData['data'] as $dqlAlias => $data) { $entityName = $this->_rsm->aliasMap[$dqlAlias]; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php new file mode 100644 index 000000000..809417c04 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -0,0 +1,228 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\GH5762Driver'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\GH5762DriverRide'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\GH5762Car'), + )); + } + + public function testIssue() + { + $result = $this->fetchData(); + + $this->assertInstanceOf(__NAMESPACE__ . '\GH5762Driver', $result); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result->getDriverRides()); + $this->assertInstanceOf(__NAMESPACE__ . '\GH5762DriverRide', $result->getDriverRides()->get(0)); + $this->assertInstanceOf(__NAMESPACE__ . '\GH5762Car', $result->getDriverRides()->get(0)->getCar()); + + $cars = array(); + foreach ($result->getDriverRides() as $ride) { + $cars[] = $ride->getCar()->getBrand(); + } + $this->assertEquals(count($cars), count(array_unique($cars))); + + $this->assertContains('BMW', $cars); + $this->assertContains('Crysler', $cars); + $this->assertContains('Dodge', $cars); + $this->assertContains('Mercedes', $cars); + $this->assertContains('Volvo', $cars); + } + + private function fetchData() + { + $this->createData(); + + $qb = $this->_em->createQueryBuilder(); + $qb->select('d, dr, c') + ->from(__NAMESPACE__ . '\GH5762Driver', 'd') + ->leftJoin('d.driverRides', 'dr') + ->leftJoin('dr.car', 'c') + ->where('d.id = 1'); + + return $qb->getQuery()->getSingleResult(); + } + + private function createData() + { + $car1 = new GH5762Car('BMW', '7 Series'); + $car2 = new GH5762Car('Crysler', '300'); + $car3 = new GH5762Car('Dodge', 'Dart'); + $car4 = new GH5762Car('Mercedes', 'C-Class'); + $car5 = new GH5762Car('Volvo', 'XC90'); + + $driver = new GH5762Driver(1, 'John Doe'); + + $ride1 = new GH5762DriverRide($driver, $car1); + $ride2 = new GH5762DriverRide($driver, $car2); + $ride3 = new GH5762DriverRide($driver, $car3); + $ride4 = new GH5762DriverRide($driver, $car4); + $ride5 = new GH5762DriverRide($driver, $car5); + + $this->_em->persist($car1); + $this->_em->persist($car2); + $this->_em->persist($car3); + $this->_em->persist($car4); + $this->_em->persist($car5); + + $this->_em->persist($driver); + + $this->_em->persist($ride1); + $this->_em->persist($ride2); + $this->_em->persist($ride3); + $this->_em->persist($ride4); + $this->_em->persist($ride5); + + $this->_em->flush(); + $this->_em->clear(); + } +} + +/** + * @Entity + * @Table(name="driver") + */ +class GH5762Driver +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="NONE") + */ + private $id; + + /** + * @Column(type="string", length=255); + */ + private $name; + + /** + * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="driver") + */ + private $driverRides; + + function __construct($id, $name) + { + $this->driverRides = new ArrayCollection(); + $this->id = $id; + $this->name = $name; + } + + function getId() + { + return $this->id; + } + + function getName() + { + return $this->name; + } + + function getDriverRides() + { + return $this->driverRides; + } +} + +/** + * @Entity + * @Table(name="driver_ride") + */ +class GH5762DriverRide +{ + + /** + * @Id + * @ManyToOne(targetEntity="GH5762Driver", inversedBy="driverRides") + * @JoinColumn(name="driver_id", referencedColumnName="id") + */ + private $driver; + + /** + * @Id + * @ManyToOne(targetEntity="GH5762Car", inversedBy="carRides") + * @JoinColumn(name="car", referencedColumnName="brand") + */ + private $car; + + function __construct(GH5762Driver $driver, GH5762Car $car) + { + $this->driver = $driver; + $this->car = $car; + + $this->driver->getDriverRides()->add($this); + $this->car->getCarRides()->add($this); + } + + function getDriver() + { + return $this->driver; + } + + function getCar() + { + return $this->car; + } +} + +/** + * @Entity + * @Table(name="car") + */ +class GH5762Car +{ + + /** + * @Id + * @Column(type="string", length=25) + * @GeneratedValue(strategy="NONE") + */ + private $brand; + + /** + * @Column(type="string", length=255); + */ + private $model; + + /** + * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="car") + */ + private $carRides; + + function __construct($brand, $model) + { + $this->carRides = new ArrayCollection(); + $this->brand = $brand; + $this->model = $model; + } + + function getBrand() + { + return $this->brand; + } + + function getModel() + { + return $this->model; + } + + function getCarRides() + { + return $this->carRides; + } +} From c6ea8b1129fbd9cb720148123aa0c1c6ec28e127 Mon Sep 17 00:00:00 2001 From: Alexander Kurilo Date: Mon, 29 Aug 2016 23:17:24 +0300 Subject: [PATCH 090/144] Remove irrelevant accessors (#5762) --- .../ORM/Functional/Ticket/GH5762Test.php | 84 +++++-------------- 1 file changed, 21 insertions(+), 63 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index 809417c04..ff3dac7e6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -15,9 +15,9 @@ class GH5762Test extends \Doctrine\Tests\OrmFunctionalTestCase parent::setup(); $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\GH5762Driver'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\GH5762DriverRide'), - $this->_em->getClassMetadata(__NAMESPACE__ . '\GH5762Car'), + $this->_em->getClassMetadata(GH5762Driver::class), + $this->_em->getClassMetadata(GH5762DriverRide::class), + $this->_em->getClassMetadata(GH5762Car::class), )); } @@ -26,13 +26,13 @@ class GH5762Test extends \Doctrine\Tests\OrmFunctionalTestCase $result = $this->fetchData(); $this->assertInstanceOf(__NAMESPACE__ . '\GH5762Driver', $result); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result->getDriverRides()); - $this->assertInstanceOf(__NAMESPACE__ . '\GH5762DriverRide', $result->getDriverRides()->get(0)); - $this->assertInstanceOf(__NAMESPACE__ . '\GH5762Car', $result->getDriverRides()->get(0)->getCar()); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result->driverRides); + $this->assertInstanceOf(__NAMESPACE__ . '\GH5762DriverRide', $result->driverRides->get(0)); + $this->assertInstanceOf(__NAMESPACE__ . '\GH5762Car', $result->driverRides->get(0)->car); $cars = array(); - foreach ($result->getDriverRides() as $ride) { - $cars[] = $ride->getCar()->getBrand(); + foreach ($result->driverRides as $ride) { + $cars[] = $ride->car->brand; } $this->assertEquals(count($cars), count(array_unique($cars))); @@ -93,50 +93,34 @@ class GH5762Test extends \Doctrine\Tests\OrmFunctionalTestCase } /** - * @Entity + * @Entity * @Table(name="driver") */ class GH5762Driver { - /** * @Id * @Column(type="integer") * @GeneratedValue(strategy="NONE") */ - private $id; + public $id; /** * @Column(type="string", length=255); */ - private $name; + public $name; /** * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="driver") */ - private $driverRides; + public $driverRides; - function __construct($id, $name) + public function __construct($id, $name) { $this->driverRides = new ArrayCollection(); $this->id = $id; $this->name = $name; } - - function getId() - { - return $this->id; - } - - function getName() - { - return $this->name; - } - - function getDriverRides() - { - return $this->driverRides; - } } /** @@ -145,38 +129,27 @@ class GH5762Driver */ class GH5762DriverRide { - /** * @Id * @ManyToOne(targetEntity="GH5762Driver", inversedBy="driverRides") * @JoinColumn(name="driver_id", referencedColumnName="id") */ - private $driver; + public $driver; /** * @Id * @ManyToOne(targetEntity="GH5762Car", inversedBy="carRides") * @JoinColumn(name="car", referencedColumnName="brand") */ - private $car; + public $car; function __construct(GH5762Driver $driver, GH5762Car $car) { $this->driver = $driver; $this->car = $car; - $this->driver->getDriverRides()->add($this); - $this->car->getCarRides()->add($this); - } - - function getDriver() - { - return $this->driver; - } - - function getCar() - { - return $this->car; + $this->driver->driverRides->add($this); + $this->car->carRides->add($this); } } @@ -192,37 +165,22 @@ class GH5762Car * @Column(type="string", length=25) * @GeneratedValue(strategy="NONE") */ - private $brand; + public $brand; /** * @Column(type="string", length=255); */ - private $model; + public $model; /** * @OneToMany(targetEntity="GH5762DriverRide", mappedBy="car") */ - private $carRides; + public $carRides; - function __construct($brand, $model) + public function __construct($brand, $model) { $this->carRides = new ArrayCollection(); $this->brand = $brand; $this->model = $model; } - - function getBrand() - { - return $this->brand; - } - - function getModel() - { - return $this->model; - } - - function getCarRides() - { - return $this->carRides; - } } From 74ec055d577d71b477c7da7d6694ef636c51c8a6 Mon Sep 17 00:00:00 2001 From: Alexander Kurilo Date: Mon, 29 Aug 2016 22:29:41 +0300 Subject: [PATCH 091/144] Use ::class const instead of FQCN string (#5762) --- .../Tests/ORM/Functional/Ticket/GH5762Test.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index ff3dac7e6..a602921de 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -3,11 +3,13 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\PersistentCollection; +use Doctrine\Tests\OrmFunctionalTestCase; /** * @group GH-5762 */ -class GH5762Test extends \Doctrine\Tests\OrmFunctionalTestCase +class GH5762Test extends OrmFunctionalTestCase { protected function setup() @@ -25,10 +27,10 @@ class GH5762Test extends \Doctrine\Tests\OrmFunctionalTestCase { $result = $this->fetchData(); - $this->assertInstanceOf(__NAMESPACE__ . '\GH5762Driver', $result); - $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result->driverRides); - $this->assertInstanceOf(__NAMESPACE__ . '\GH5762DriverRide', $result->driverRides->get(0)); - $this->assertInstanceOf(__NAMESPACE__ . '\GH5762Car', $result->driverRides->get(0)->car); + $this->assertInstanceOf(GH5762Driver::class, $result); + $this->assertInstanceOf(PersistentCollection::class, $result->driverRides); + $this->assertInstanceOf(GH5762DriverRide::class, $result->driverRides->get(0)); + $this->assertInstanceOf(GH5762Car::class, $result->driverRides->get(0)->car); $cars = array(); foreach ($result->driverRides as $ride) { @@ -49,7 +51,7 @@ class GH5762Test extends \Doctrine\Tests\OrmFunctionalTestCase $qb = $this->_em->createQueryBuilder(); $qb->select('d, dr, c') - ->from(__NAMESPACE__ . '\GH5762Driver', 'd') + ->from(GH5762Driver::class, 'd') ->leftJoin('d.driverRides', 'dr') ->leftJoin('dr.car', 'c') ->where('d.id = 1'); From 140960ebb1f1b5568d7921e1a54381a5640501c7 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 7 Sep 2016 23:17:40 +0200 Subject: [PATCH 092/144] #5975 short array syntax --- lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index ebea42cac..14aed2a67 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -330,7 +330,7 @@ class ObjectHydrator extends AbstractHydrator $rowData = $this->gatherRowData($row, $id, $nonemptyComponents); // reset result pointers for each data row - $this->resultPointers = array(); + $this->resultPointers = []; // Hydrate the data chunks foreach ($rowData['data'] as $dqlAlias => $data) { From 50f321f2e9ad8133420e17ca61afa564d0b9b479 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 7 Sep 2016 23:18:39 +0200 Subject: [PATCH 093/144] #5975 minor test cleanups --- .../ORM/Functional/Ticket/GH5762Test.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php index a602921de..b42dd6534 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5762Test.php @@ -11,10 +11,9 @@ use Doctrine\Tests\OrmFunctionalTestCase; */ class GH5762Test extends OrmFunctionalTestCase { - - protected function setup() + protected function setUp() { - parent::setup(); + parent::setUp(); $this->_schemaTool->createSchema(array( $this->_em->getClassMetadata(GH5762Driver::class), @@ -27,22 +26,23 @@ class GH5762Test extends OrmFunctionalTestCase { $result = $this->fetchData(); - $this->assertInstanceOf(GH5762Driver::class, $result); - $this->assertInstanceOf(PersistentCollection::class, $result->driverRides); - $this->assertInstanceOf(GH5762DriverRide::class, $result->driverRides->get(0)); - $this->assertInstanceOf(GH5762Car::class, $result->driverRides->get(0)->car); + self::assertInstanceOf(GH5762Driver::class, $result); + self::assertInstanceOf(PersistentCollection::class, $result->driverRides); + self::assertInstanceOf(GH5762DriverRide::class, $result->driverRides->get(0)); + self::assertInstanceOf(GH5762Car::class, $result->driverRides->get(0)->car); $cars = array(); foreach ($result->driverRides as $ride) { $cars[] = $ride->car->brand; } - $this->assertEquals(count($cars), count(array_unique($cars))); - $this->assertContains('BMW', $cars); - $this->assertContains('Crysler', $cars); - $this->assertContains('Dodge', $cars); - $this->assertContains('Mercedes', $cars); - $this->assertContains('Volvo', $cars); + self::assertEquals(count($cars), count(array_unique($cars))); + + self::assertContains('BMW', $cars); + self::assertContains('Crysler', $cars); + self::assertContains('Dodge', $cars); + self::assertContains('Mercedes', $cars); + self::assertContains('Volvo', $cars); } private function fetchData() From a90035e81af2e9a424c0268a36101c3483e06571 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Fri, 2 Sep 2016 15:43:28 -0300 Subject: [PATCH 094/144] Expose `EntityPersister::count()` through `EntityRepository::count()` --- docs/en/reference/working-with-objects.rst | 54 +++++++++------- docs/en/tutorials/getting-started.rst | 62 +++++++++++-------- lib/Doctrine/ORM/EntityRepository.php | 35 +++++++++-- .../Entity/BasicEntityPersister.php | 2 +- .../ORM/Functional/EntityRepositoryTest.php | 24 +++++++ 5 files changed, 121 insertions(+), 56 deletions(-) diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 8368c9f13..bcc9bf185 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -41,7 +41,7 @@ headline "Hello World" with the ID 1234: find('CMS\Article', 1234); $article->setHeadline('Hello World dude!'); - + $article2 = $entityManager->find('CMS\Article', 1234); echo $article2->getHeadline(); @@ -93,25 +93,25 @@ from newly opened EntityManager. { /** @Id @Column(type="integer") @GeneratedValue */ private $id; - + /** @Column(type="string") */ private $headline; - + /** @ManyToOne(targetEntity="User") */ private $author; - + /** @OneToMany(targetEntity="Comment", mappedBy="article") */ private $comments; - + public function __construct() { $this->comments = new ArrayCollection(); } - + public function getAuthor() { return $this->author; } public function getComments() { return $this->comments; } } - + $article = $em->find('Article', 1); This code only retrieves the ``Article`` instance with id 1 executing @@ -132,22 +132,22 @@ your code. See the following code: find('Article', 1); - + // accessing a method of the user instance triggers the lazy-load echo "Author: " . $article->getAuthor()->getName() . "\n"; - + // Lazy Loading Proxies pass instanceof tests: if ($article->getAuthor() instanceof User) { // a User Proxy is a generated "UserProxy" class } - + // accessing the comments as an iterator triggers the lazy-load // retrieving ALL the comments of this article from the database // using a single SELECT statement foreach ($article->getComments() as $comment) { echo $comment->getText() . "\n\n"; } - + // Article::$comments passes instanceof tests for the Collection interface // But it will NOT pass for the ArrayCollection interface if ($article->getComments() instanceof \Doctrine\Common\Collections\Collection) { @@ -167,7 +167,7 @@ methods along the lines of the ``getName()`` method shown below: { // lazy loading code } - + public function getName() { $this->_load(); @@ -262,7 +262,7 @@ which means that its persistent state will be deleted once for and appear in query and collection results. See the section on :ref:`Database and UnitOfWork Out-Of-Sync ` for more information. - + Example: @@ -681,13 +681,13 @@ methods on a repository as follows: getRepository('MyProject\Domain\User')->findBy(array('age' => 20)); - + // All users that are 20 years old and have a surname of 'Miller' $users = $em->getRepository('MyProject\Domain\User')->findBy(array('age' => 20, 'surname' => 'Miller')); - + // A single user by its nickname $user = $em->getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); @@ -723,10 +723,18 @@ examples are equivalent: getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); - + // A single user by its nickname (__call magic) $user = $em->getRepository('MyProject\Domain\User')->findOneByNickname('romanb'); +Additionally, you can just count the result of the provided conditions when you don't really need the data: + +.. code-block:: php + + getRepository('MyProject\Domain\User')->count(array('nickname' => 'nonexistent')); + By Criteria ~~~~~~~~~~~ @@ -774,7 +782,7 @@ A DQL query is represented by an instance of the createQuery("select u from MyDomain\Model\User u where u.age >= 20 and u.age <= 30"); $users = $q->getResult(); @@ -817,18 +825,18 @@ in a central location. getRepository('MyDomain\Model\User')->getAllAdminUsers(); diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index ef4734317..5e0444246 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -103,7 +103,7 @@ Install Doctrine using the Composer Dependency Management tool, by calling: $ composer install This will install the packages Doctrine Common, Doctrine DBAL, Doctrine ORM, -Symfony YAML and Symfony Console into the `vendor` directory. The Symfony +Symfony YAML and Symfony Console into the `vendor` directory. The Symfony dependencies are not required by Doctrine but will be used in this tutorial. Add the following directories: @@ -131,22 +131,22 @@ step: // bootstrap.php use Doctrine\ORM\Tools\Setup; use Doctrine\ORM\EntityManager; - + require_once "vendor/autoload.php"; - + // Create a simple "default" Doctrine ORM configuration for Annotations $isDevMode = true; $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode); // or if you prefer yaml or XML //$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode); //$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode); - + // database configuration parameters $conn = array( 'driver' => 'pdo_sqlite', 'path' => __DIR__ . '/db.sqlite', ); - + // obtaining the entity manager $entityManager = EntityManager::create($conn, $config); @@ -185,7 +185,7 @@ doctrine command. Its a fairly simple file: getRepository('Product') + ->count(array('name' => $productName)); + Conclusion ---------- diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 08b2ff193..2b8c1cb51 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -196,16 +196,32 @@ class EntityRepository implements ObjectRepository, Selectable } /** - * Adds support for magic finders. + * Counts entities by a set of criteria. + * + * @todo Add this method to `ObjectRepository` interface in the next major release + * + * @param array $criteria + * + * @return int The quantity of objects that matches the criteria. + */ + public function count(array $criteria) + { + $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName); + + return $persister->count($criteria); + } + + /** + * Adds support for magic finders/counters. * * @param string $method * @param array $arguments * - * @return array|object The found entity/entities. + * @return array|object|int The found entity/entities or its resulting count. * * @throws ORMException - * @throws \BadMethodCallException If the method called is an invalid find* method - * or no find* method at all and therefore an invalid + * @throws \BadMethodCallException If the method called is an invalid find* or countBy method + * or no find* or countBy method at all and therefore an invalid * method call. */ public function __call($method, $arguments) @@ -221,6 +237,11 @@ class EntityRepository implements ObjectRepository, Selectable $method = 'findOneBy'; break; + case (0 === strpos($method, 'countBy')): + $by = substr($method, 7); + $method = 'count'; + break; + default: throw new \BadMethodCallException( "Undefined method '$method'. The method name must start with ". @@ -228,14 +249,16 @@ class EntityRepository implements ObjectRepository, Selectable ); } - if (empty($arguments)) { + $argsCount = count($arguments); + + if (0 === $argsCount) { throw ORMException::findByRequiresParameter($method . $by); } $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by)); if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) { - switch (count($arguments)) { + switch ($argsCount) { case 1: return $this->$method(array($fieldName => $arguments[0])); diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 3b2faf878..c62a10a12 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -822,7 +822,7 @@ class BasicEntityPersister implements EntityPersister ? $this->expandCriteriaParameters($criteria) : $this->expandParameters($criteria); - return $this->conn->executeQuery($sql, $params, $types)->fetchColumn(); + return (int) $this->conn->executeQuery($sql, $params, $types)->fetchColumn(); } /** diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php index ffca89ba0..e0b96387a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -272,6 +272,30 @@ class EntityRepositoryTest extends OrmFunctionalTestCase $this->assertEquals(4, count($users)); } + public function testCount() + { + $this->loadFixture(); + $repos = $this->_em->getRepository(CmsUser::class); + + $userCount = $repos->count(array()); + $this->assertSame(4, $userCount); + + $userCount = $repos->count(array('status' => 'dev')); + $this->assertSame(2, $userCount); + + $userCount = $repos->count(array('status' => 'nonexistent')); + $this->assertSame(0, $userCount); + } + + public function testCountBy() + { + $this->loadFixture(); + $repos = $this->_em->getRepository(CmsUser::class); + + $userCount = $repos->countByStatus('dev'); + $this->assertSame(2, $userCount); + } + /** * @expectedException \Doctrine\ORM\ORMException */ From bea3c653bc3e0780ca6ec170235953ef2a75842e Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Wed, 7 Sep 2016 17:39:51 -0300 Subject: [PATCH 095/144] Updated docs --- docs/en/reference/working-with-objects.rst | 48 +++++++++---------- docs/en/tutorials/getting-started.rst | 56 +++++++++++----------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index bcc9bf185..2b52fac41 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -41,7 +41,7 @@ headline "Hello World" with the ID 1234: find('CMS\Article', 1234); $article->setHeadline('Hello World dude!'); - + $article2 = $entityManager->find('CMS\Article', 1234); echo $article2->getHeadline(); @@ -93,25 +93,25 @@ from newly opened EntityManager. { /** @Id @Column(type="integer") @GeneratedValue */ private $id; - + /** @Column(type="string") */ private $headline; - + /** @ManyToOne(targetEntity="User") */ private $author; - + /** @OneToMany(targetEntity="Comment", mappedBy="article") */ private $comments; - + public function __construct() { $this->comments = new ArrayCollection(); } - + public function getAuthor() { return $this->author; } public function getComments() { return $this->comments; } } - + $article = $em->find('Article', 1); This code only retrieves the ``Article`` instance with id 1 executing @@ -132,22 +132,22 @@ your code. See the following code: find('Article', 1); - + // accessing a method of the user instance triggers the lazy-load echo "Author: " . $article->getAuthor()->getName() . "\n"; - + // Lazy Loading Proxies pass instanceof tests: if ($article->getAuthor() instanceof User) { // a User Proxy is a generated "UserProxy" class } - + // accessing the comments as an iterator triggers the lazy-load // retrieving ALL the comments of this article from the database // using a single SELECT statement foreach ($article->getComments() as $comment) { echo $comment->getText() . "\n\n"; } - + // Article::$comments passes instanceof tests for the Collection interface // But it will NOT pass for the ArrayCollection interface if ($article->getComments() instanceof \Doctrine\Common\Collections\Collection) { @@ -167,7 +167,7 @@ methods along the lines of the ``getName()`` method shown below: { // lazy loading code } - + public function getName() { $this->_load(); @@ -262,7 +262,7 @@ which means that its persistent state will be deleted once for and appear in query and collection results. See the section on :ref:`Database and UnitOfWork Out-Of-Sync ` for more information. - + Example: @@ -681,13 +681,13 @@ methods on a repository as follows: getRepository('MyProject\Domain\User')->findBy(array('age' => 20)); - + // All users that are 20 years old and have a surname of 'Miller' $users = $em->getRepository('MyProject\Domain\User')->findBy(array('age' => 20, 'surname' => 'Miller')); - + // A single user by its nickname $user = $em->getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); @@ -723,7 +723,7 @@ examples are equivalent: getRepository('MyProject\Domain\User')->findOneBy(array('nickname' => 'romanb')); - + // A single user by its nickname (__call magic) $user = $em->getRepository('MyProject\Domain\User')->findOneByNickname('romanb'); @@ -733,7 +733,7 @@ Additionally, you can just count the result of the provided conditions when you getRepository('MyProject\Domain\User')->count(array('nickname' => 'nonexistent')); + $availableNickname = 0 === $em->getRepository('MyProject\Domain\User')->count(['nickname' => 'nonexistent']); By Criteria ~~~~~~~~~~~ @@ -782,7 +782,7 @@ A DQL query is represented by an instance of the createQuery("select u from MyDomain\Model\User u where u.age >= 20 and u.age <= 30"); $users = $q->getResult(); @@ -825,18 +825,18 @@ in a central location. getRepository('MyDomain\Model\User')->getAllAdminUsers(); diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 5e0444246..05492b133 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -103,7 +103,7 @@ Install Doctrine using the Composer Dependency Management tool, by calling: $ composer install This will install the packages Doctrine Common, Doctrine DBAL, Doctrine ORM, -Symfony YAML and Symfony Console into the `vendor` directory. The Symfony +Symfony YAML and Symfony Console into the `vendor` directory. The Symfony dependencies are not required by Doctrine but will be used in this tutorial. Add the following directories: @@ -131,22 +131,22 @@ step: // bootstrap.php use Doctrine\ORM\Tools\Setup; use Doctrine\ORM\EntityManager; - + require_once "vendor/autoload.php"; - + // Create a simple "default" Doctrine ORM configuration for Annotations $isDevMode = true; $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode); // or if you prefer yaml or XML //$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode); //$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode); - + // database configuration parameters $conn = array( 'driver' => 'pdo_sqlite', 'path' => __DIR__ . '/db.sqlite', ); - + // obtaining the entity manager $entityManager = EntityManager::create($conn, $config); @@ -185,7 +185,7 @@ doctrine command. Its a fairly simple file: getRepository('Product') - ->count(array('name' => $productName)); + $productCount = $entityManager->getRepository(Product::class) + ->count(['name' => $productName]); Conclusion ---------- From 591bae0855c111d1c247eb204125643566b30868 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Wed, 7 Sep 2016 18:43:17 -0300 Subject: [PATCH 096/144] Swap logic from `EntityRespository::__call()` --- lib/Doctrine/ORM/EntityRepository.php | 106 ++++++++++++++------------ lib/Doctrine/ORM/ORMException.php | 15 ++++ 2 files changed, 71 insertions(+), 50 deletions(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 2b8c1cb51..39f8bf3bc 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -212,71 +212,34 @@ class EntityRepository implements ObjectRepository, Selectable } /** - * Adds support for magic finders/counters. + * Adds support for magic method calls. * * @param string $method * @param array $arguments * - * @return array|object|int The found entity/entities or its resulting count. + * @return mixed The returned value from the resolved method. * * @throws ORMException - * @throws \BadMethodCallException If the method called is an invalid find* or countBy method - * or no find* or countBy method at all and therefore an invalid - * method call. + * @throws \BadMethodCallException If the method called is invalid */ public function __call($method, $arguments) { - switch (true) { - case (0 === strpos($method, 'findBy')): - $by = substr($method, 6); - $method = 'findBy'; - break; - - case (0 === strpos($method, 'findOneBy')): - $by = substr($method, 9); - $method = 'findOneBy'; - break; - - case (0 === strpos($method, 'countBy')): - $by = substr($method, 7); - $method = 'count'; - break; - - default: - throw new \BadMethodCallException( - "Undefined method '$method'. The method name must start with ". - "either findBy or findOneBy!" - ); + if (0 === strpos($method, 'findBy')) { + return $this->resolveMagicCall('findBy', substr($method, 6), $arguments); } - $argsCount = count($arguments); - - if (0 === $argsCount) { - throw ORMException::findByRequiresParameter($method . $by); + if (0 === strpos($method, 'findOneBy')) { + return $this->resolveMagicCall('findOneBy', substr($method, 9), $arguments); } - $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by)); - - if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) { - switch ($argsCount) { - case 1: - return $this->$method(array($fieldName => $arguments[0])); - - case 2: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1]); - - case 3: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]); - - case 4: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]); - - default: - // Do nothing - } + if (0 === strpos($method, 'countBy')) { + return $this->resolveMagicCall('count', substr($method, 7), $arguments); } - throw ORMException::invalidFindByCall($this->_entityName, $fieldName, $method.$by); + throw new \BadMethodCallException( + "Undefined method '$method'. The method name must start with ". + "either findBy or findOneBy!" + ); } /** @@ -325,4 +288,47 @@ class EntityRepository implements ObjectRepository, Selectable return new LazyCriteriaCollection($persister, $criteria); } + + /** + * Resolves a magic method call to the proper existent method at `EntityRepository`. + * + * @param string $method The method to call + * @param string $by The property name used as condition + * @param array $arguments The arguments to pass at method call + * + * @throws ORMException If the method called is invalid. + * + * @return mixed + */ + private function resolveMagicCall($method, $by, array $arguments = []) + { + $argsCount = count($arguments); + + if (0 === $argsCount) { + throw ORMException::findByRequiresParameter($method . $by); + } + + $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by)); + + if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) { + switch ($argsCount) { + case 1: + return $this->$method(array($fieldName => $arguments[0])); + + case 2: + return $this->$method(array($fieldName => $arguments[0]), $arguments[1]); + + case 3: + return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]); + + case 4: + return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]); + + default: + // Do nothing + } + } + + throw ORMException::invalidMagicCall($this->_entityName, $fieldName, $method.$by); + } } diff --git a/lib/Doctrine/ORM/ORMException.php b/lib/Doctrine/ORM/ORMException.php index 6d8a6d631..919789d92 100644 --- a/lib/Doctrine/ORM/ORMException.php +++ b/lib/Doctrine/ORM/ORMException.php @@ -187,6 +187,21 @@ class ORMException extends Exception ); } + /** + * @param string $entityName + * @param string $fieldName + * @param string $method + * + * @return ORMException + */ + public static function invalidMagicCall($entityName, $fieldName, $method) + { + return new self( + "Entity '".$entityName."' has no field '".$fieldName."'. ". + "You can therefore not call '".$method."' on the entities' repository" + ); + } + /** * @param string $entityName * @param string $associationFieldName From 61f6b667c0026565f5cbfa9f0c4066266bdb61e9 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Wed, 7 Sep 2016 19:24:38 -0300 Subject: [PATCH 097/144] Remove `default` clause at `EntityRepository::resolveMagicCall()` --- lib/Doctrine/ORM/EntityRepository.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 39f8bf3bc..00e53c341 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -323,9 +323,6 @@ class EntityRepository implements ObjectRepository, Selectable case 4: return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]); - - default: - // Do nothing } } From 6f79a378d56101516ad379307794e4ada0a76caf Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:43:29 +0200 Subject: [PATCH 098/144] #6003 removed useless method parameter count checking duplication --- lib/Doctrine/ORM/EntityRepository.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 00e53c341..a3fcf0aff 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -310,22 +310,10 @@ class EntityRepository implements ObjectRepository, Selectable $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by)); - if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) { - switch ($argsCount) { - case 1: - return $this->$method(array($fieldName => $arguments[0])); - - case 2: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1]); - - case 3: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]); - - case 4: - return $this->$method(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]); - } + if (! ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName))) { + throw ORMException::invalidMagicCall($this->_entityName, $fieldName, $method . $by); } - throw ORMException::invalidMagicCall($this->_entityName, $fieldName, $method.$by); + return $this->$method([$fieldName => $arguments[0]], ...array_slice($arguments, 1)); } } From 5e51a985b7df08f45604642e154a98c65b9aac31 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:47:39 +0200 Subject: [PATCH 099/144] #6003 no default parameter needed --- lib/Doctrine/ORM/EntityRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index a3fcf0aff..7ba60b71e 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -300,7 +300,7 @@ class EntityRepository implements ObjectRepository, Selectable * * @return mixed */ - private function resolveMagicCall($method, $by, array $arguments = []) + private function resolveMagicCall($method, $by, array $arguments) { $argsCount = count($arguments); From de4c854ac955526285eab6111b9ba9a446d44b62 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:48:52 +0200 Subject: [PATCH 100/144] #6003 removed useless `count()` call --- lib/Doctrine/ORM/EntityRepository.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 7ba60b71e..cdd90baf0 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -302,9 +302,7 @@ class EntityRepository implements ObjectRepository, Selectable */ private function resolveMagicCall($method, $by, array $arguments) { - $argsCount = count($arguments); - - if (0 === $argsCount) { + if (! $arguments) { throw ORMException::findByRequiresParameter($method . $by); } From 7bf4a65c92413773af3039448eccc296c34cffe9 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:53:35 +0200 Subject: [PATCH 101/144] #6003 imported used symbol --- lib/Doctrine/ORM/EntityRepository.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index cdd90baf0..ce7b7c23a 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -19,6 +19,7 @@ namespace Doctrine\ORM; +use Doctrine\Common\Util\Inflector; use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\Common\Collections\Selectable; @@ -306,7 +307,7 @@ class EntityRepository implements ObjectRepository, Selectable throw ORMException::findByRequiresParameter($method . $by); } - $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by)); + $fieldName = lcfirst(Inflector::classify($by)); if (! ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName))) { throw ORMException::invalidMagicCall($this->_entityName, $fieldName, $method . $by); From e2cba87662c0ce01fb8b680daa3c6857ee6dfa1c Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:54:49 +0200 Subject: [PATCH 102/144] #6003 corrected return type definition --- lib/Doctrine/ORM/EntityRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index ce7b7c23a..f47608ea7 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -203,7 +203,7 @@ class EntityRepository implements ObjectRepository, Selectable * * @param array $criteria * - * @return int The quantity of objects that matches the criteria. + * @return int The cardinality of the objects that match the given criteria. */ public function count(array $criteria) { From 36e99040824a3da5554ab38427406ec5b679f5a8 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:55:09 +0200 Subject: [PATCH 103/144] #6003 inlined persister retrieval --- lib/Doctrine/ORM/EntityRepository.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index f47608ea7..85dd63c6e 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -207,9 +207,7 @@ class EntityRepository implements ObjectRepository, Selectable */ public function count(array $criteria) { - $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName); - - return $persister->count($criteria); + return $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName)->count($criteria); } /** From c5c56a9dad69d138057c1e1707390dec6c241912 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 00:55:49 +0200 Subject: [PATCH 104/144] #6003 clarifying thrown exception --- lib/Doctrine/ORM/EntityRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 85dd63c6e..0c2823757 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -295,7 +295,7 @@ class EntityRepository implements ObjectRepository, Selectable * @param string $by The property name used as condition * @param array $arguments The arguments to pass at method call * - * @throws ORMException If the method called is invalid. + * @throws ORMException If the method called is invalid or the requested field/association does not exist * * @return mixed */ From 12b5e79ff2d99ea6dfe8b23a77ae515c741c324a Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Fri, 2 Sep 2016 10:31:26 +0300 Subject: [PATCH 105/144] Create a failing test for issue #5989 Field with type=simple_array in a joined inheritance gets overridden by empty array in the hydrator --- .../Models/Issue5989/Issue5989Employee.php | 27 ++++++++++ .../Models/Issue5989/Issue5989Manager.php | 27 ++++++++++ .../Models/Issue5989/Issue5989Person.php | 29 +++++++++++ .../ORM/Functional/Ticket/Issue5989Test.php | 51 +++++++++++++++++++ .../Doctrine/Tests/OrmFunctionalTestCase.php | 11 ++++ 5 files changed, 145 insertions(+) create mode 100644 tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php create mode 100644 tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php create mode 100644 tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php new file mode 100644 index 000000000..e3eaac7d8 --- /dev/null +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php @@ -0,0 +1,27 @@ +tags; + } + + public function setTags(array $tags) + { + $this->tags = $tags; + } +} diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php new file mode 100644 index 000000000..32c053984 --- /dev/null +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php @@ -0,0 +1,27 @@ +tags; + } + + public function setTags(array $tags) + { + $this->tags = $tags; + } +} diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php new file mode 100644 index 000000000..c9e00c4c1 --- /dev/null +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php @@ -0,0 +1,29 @@ +id; + } +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php new file mode 100644 index 000000000..29a5a3fa2 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php @@ -0,0 +1,51 @@ +useModelSet('issue5989'); + parent::setUp(); + } + + public function testSimpleArrayTypeHydratedCorrectlyInJoinedInheritance() + { + $manager = new Issue5989Manager(); + + $managerTags = array('tag1', 'tag2'); + $manager->setTags($managerTags); + $this->_em->persist($manager); + + $employee = new Issue5989Employee(); + + $employeeTags = array('tag2', 'tag3'); + $employee->setTags($employeeTags); + $this->_em->persist($employee); + + $this->_em->flush(); + + $managerId = $manager->getId(); + $employeeId = $employee->getId(); + + // clear entity manager so that $repository->find actually fetches them and uses the hydrator + // instead of just returning the existing managed entities + $this->_em->clear(); + + $repository = $this->_em->getRepository(Issue5989Person::class); + + $manager = $repository->find($managerId); + $employee = $repository->find($employeeId); + + static::assertEquals($managerTags, $manager->getTags()); + static::assertEquals($employeeTags, $employee->getTags()); + } +} diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index 907c00617..a6a3bece4 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -295,6 +295,11 @@ abstract class OrmFunctionalTestCase extends OrmTestCase 'Doctrine\Tests\Models\VersionedManyToOne\Category', 'Doctrine\Tests\Models\VersionedManyToOne\Article', ), + 'issue5989' => array( + 'Doctrine\Tests\Models\Issue5989\Issue5989Person', + 'Doctrine\Tests\Models\Issue5989\Issue5989Employee', + 'Doctrine\Tests\Models\Issue5989\Issue5989Manager', + ), ); /** @@ -563,6 +568,12 @@ abstract class OrmFunctionalTestCase extends OrmTestCase $conn->executeUpdate('DELETE FROM versioned_many_to_one_category'); } + if (isset($this->_usedModelSets['issue5989'])) { + $conn->executeUpdate('DELETE FROM issue5989_persons'); + $conn->executeUpdate('DELETE FROM issue5989_employees'); + $conn->executeUpdate('DELETE FROM issue5989_managers'); + } + $this->_em->clear(); } From 95546d68c5eec4576b0d5dcb741175ee39692333 Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Sat, 3 Sep 2016 22:25:11 +0300 Subject: [PATCH 106/144] Fix hydration in a joined inheritance with simple array or json array SimpleArrayType and JsonArrayType convert NULL value to an empty array, which fails the null check that is used to prevent overwrite Fixes issue #5989 --- lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 92c77ddd3..798bd305a 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -121,6 +121,9 @@ class SimpleObjectHydrator extends AbstractHydrator continue; } + // Check if value is null before conversion (because some types convert null to something else) + $valueIsNull = $value === null; + // Convert field to a valid PHP value if (isset($cacheKeyInfo['type'])) { $type = $cacheKeyInfo['type']; @@ -130,7 +133,7 @@ class SimpleObjectHydrator extends AbstractHydrator $fieldName = $cacheKeyInfo['fieldName']; // Prevent overwrite in case of inherit classes using same property name (See AbstractHydrator) - if ( ! isset($data[$fieldName]) || $value !== null) { + if ( ! isset($data[$fieldName]) || ! $valueIsNull) { $data[$fieldName] = $value; } } From 00bbf4f52351280791fbc59761533d296b59861b Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Sun, 4 Sep 2016 18:37:03 +0300 Subject: [PATCH 107/144] Use yoda condition in the null check --- lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 798bd305a..785a2b796 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -122,7 +122,7 @@ class SimpleObjectHydrator extends AbstractHydrator } // Check if value is null before conversion (because some types convert null to something else) - $valueIsNull = $value === null; + $valueIsNull = null === $value; // Convert field to a valid PHP value if (isset($cacheKeyInfo['type'])) { From d2cbd5e872ac637474846c79bed7df9738343ffa Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Thu, 8 Sep 2016 11:48:34 +0300 Subject: [PATCH 108/144] PR fixes (public properties & correct letter case in annotations) --- .../Tests/Models/Issue5989/Issue5989Employee.php | 14 ++------------ .../Tests/Models/Issue5989/Issue5989Manager.php | 14 ++------------ .../Tests/Models/Issue5989/Issue5989Person.php | 7 +------ .../ORM/Functional/Ticket/Issue5989Test.php | 16 ++++++++-------- 4 files changed, 13 insertions(+), 38 deletions(-) diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php index e3eaac7d8..9f5e248d8 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php @@ -9,19 +9,9 @@ namespace Doctrine\Tests\Models\Issue5989; class Issue5989Employee extends Issue5989Person { /** - * @column(type="simple_array", nullable=true) + * @Column(type="simple_array", nullable=true) * * @var array */ - private $tags; - - public function getTags() - { - return $this->tags; - } - - public function setTags(array $tags) - { - $this->tags = $tags; - } + public $tags; } diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php index 32c053984..e00067d9c 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php @@ -9,19 +9,9 @@ namespace Doctrine\Tests\Models\Issue5989; class Issue5989Manager extends Issue5989Person { /** - * @column(type="simple_array", nullable=true) + * @Column(type="simple_array", nullable=true) * * @var array */ - private $tags; - - public function getTags() - { - return $this->tags; - } - - public function setTags(array $tags) - { - $this->tags = $tags; - } + public $tags; } diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php index c9e00c4c1..d31e65def 100644 --- a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php @@ -20,10 +20,5 @@ class Issue5989Person * @Column(type="integer") * @GeneratedValue */ - private $id; - - public function getId() - { - return $this->id; - } + public $id; } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php index 29a5a3fa2..cf601b99a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php @@ -21,20 +21,20 @@ class Issue5989Test extends \Doctrine\Tests\OrmFunctionalTestCase { $manager = new Issue5989Manager(); - $managerTags = array('tag1', 'tag2'); - $manager->setTags($managerTags); + $managerTags = ['tag1', 'tag2']; + $manager->tags = $managerTags; $this->_em->persist($manager); $employee = new Issue5989Employee(); - $employeeTags = array('tag2', 'tag3'); - $employee->setTags($employeeTags); + $employeeTags =['tag2', 'tag3']; + $employee->tags = $employeeTags; $this->_em->persist($employee); $this->_em->flush(); - $managerId = $manager->getId(); - $employeeId = $employee->getId(); + $managerId = $manager->id; + $employeeId = $employee->id; // clear entity manager so that $repository->find actually fetches them and uses the hydrator // instead of just returning the existing managed entities @@ -45,7 +45,7 @@ class Issue5989Test extends \Doctrine\Tests\OrmFunctionalTestCase $manager = $repository->find($managerId); $employee = $repository->find($employeeId); - static::assertEquals($managerTags, $manager->getTags()); - static::assertEquals($employeeTags, $employee->getTags()); + static::assertEquals($managerTags, $manager->tags); + static::assertEquals($employeeTags, $employee->tags); } } From 43d22984ae56facfba103a5d8e2361ba75fac8ca Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Thu, 8 Sep 2016 13:50:28 +0300 Subject: [PATCH 109/144] Add unit test for SimpleObjectHydrator --- .../Hydration/SimpleObjectHydratorTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php index eb33c23c2..d56718834 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/SimpleObjectHydratorTest.php @@ -86,4 +86,34 @@ class SimpleObjectHydratorTest extends HydrationTestCase $hydrator = new \Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator($this->_em); $hydrator->hydrateAll($stmt, $rsm); } + + /** + * @group issue-5989 + */ + public function testNullValueShouldNotOverwriteFieldWithSameNameInJoinedInheritance() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\Issue5989\Issue5989Person', 'p'); + $rsm->addFieldResult('p', 'p__id', 'id'); + $rsm->addFieldResult('p', 'm__tags', 'tags', 'Doctrine\Tests\Models\Issue5989\Issue5989Manager'); + $rsm->addFieldResult('p', 'e__tags', 'tags', 'Doctrine\Tests\Models\Issue5989\Issue5989Employee'); + $rsm->addMetaResult('p', 'discr', 'discr', false, 'string'); + $resultSet = array( + array( + 'p__id' => '1', + 'm__tags' => 'tag1,tag2', + 'e__tags' => null, + 'discr' => 'manager' + ), + ); + + $expectedEntity = new \Doctrine\Tests\Models\Issue5989\Issue5989Manager(); + $expectedEntity->id = 1; + $expectedEntity->tags = ['tag1', 'tag2']; + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + $this->assertEquals($result[0], $expectedEntity); + } } From 16a3a2a1326d902721e7cea3bab05e4a3e8c3875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Fri, 2 Sep 2016 09:53:41 +0000 Subject: [PATCH 110/144] Use microtime to have more precision on cache time --- UPGRADE.md | 6 ++++++ lib/Doctrine/ORM/Cache/QueryCacheEntry.php | 8 ++++---- lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php | 2 +- tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index ed9a538b3..2195f5b82 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 2.5 +## Minor BC BREAK: query cache key time is now a float + +As of 2.5, the `QueryCacheEntry#time` property will contain a float value +instead of an integer in order to have more precision and also to be consistent +with the `TimestampCacheEntry#time`. + ## Minor BC BREAK: discriminator map must now include all non-transient classes It is now required that you declare the root of an inheritance in the diff --git a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php index 74e4cdda5..b6af393fd 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheEntry.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheEntry.php @@ -38,18 +38,18 @@ class QueryCacheEntry implements CacheEntry /** * READ-ONLY: Public only for performance reasons, it should be considered immutable. * - * @var integer Time creation of this cache entry + * @var float Time creation of this cache entry */ public $time; /** - * @param array $result - * @param integer $time + * @param array $result + * @param float $time */ public function __construct($result, $time = null) { $this->result = $result; - $this->time = $time ?: time(); + $this->time = $time ?: microtime(true); } /** diff --git a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php index 4e504e4f8..71ac3e828 100644 --- a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php +++ b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php @@ -35,6 +35,6 @@ class TimestampQueryCacheValidator implements QueryCacheValidator return true; } - return ($entry->time + $key->lifetime) > time(); + return ($entry->time + $key->lifetime) > microtime(true); } } diff --git a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php index b183eaed4..8fa09bac6 100644 --- a/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/DefaultQueryCacheTest.php @@ -436,7 +436,7 @@ class DefaultQueryCacheTest extends OrmTestCase array('id'=>2, 'name' => 'Bar') ); - $entry->time = time() - 100; + $entry->time = microtime(true) - 100; $this->region->addReturn('get', $entry); $this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $entities[0])); From b49026b657f093a5ba0084c63f8d7d55bfce320d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 7 Sep 2016 22:19:45 +0000 Subject: [PATCH 111/144] Add timestamp key to QueryCacheKey --- lib/Doctrine/ORM/AbstractQuery.php | 35 ++++++++++++++---- .../Entity/AbstractEntityPersister.php | 36 +++++++++---------- lib/Doctrine/ORM/Cache/QueryCacheKey.php | 29 ++++++++++----- 3 files changed, 68 insertions(+), 32 deletions(-) diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 581a99c42..0089eeede 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -28,6 +28,7 @@ use Doctrine\ORM\Cache\QueryCacheKey; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\ORM\Cache; +use Doctrine\ORM\Query\ResultSetMapping; /** * Base contract for ORM queries. Base class for Query and NativeQuery. @@ -991,32 +992,54 @@ abstract class AbstractQuery private function executeUsingQueryCache($parameters = null, $hydrationMode = null) { $rsm = $this->getResultSetMapping(); - $querykey = new QueryCacheKey($this->getHash(), $this->lifetime, $this->cacheMode ?: Cache::MODE_NORMAL); $queryCache = $this->_em->getCache()->getQueryCache($this->cacheRegion); - $result = $queryCache->get($querykey, $rsm, $this->_hints); + $queryKey = new QueryCacheKey( + $this->getHash(), + $this->lifetime, + $this->cacheMode ?: Cache::MODE_NORMAL, + $this->getTimestampKey() + ); + + $result = $queryCache->get($queryKey, $rsm, $this->_hints); if ($result !== null) { if ($this->cacheLogger) { - $this->cacheLogger->queryCacheHit($queryCache->getRegion()->getName(), $querykey); + $this->cacheLogger->queryCacheHit($queryCache->getRegion()->getName(), $queryKey); } return $result; } $result = $this->executeIgnoreQueryCache($parameters, $hydrationMode); - $cached = $queryCache->put($querykey, $rsm, $result, $this->_hints); + $cached = $queryCache->put($queryKey, $rsm, $result, $this->_hints); if ($this->cacheLogger) { - $this->cacheLogger->queryCacheMiss($queryCache->getRegion()->getName(), $querykey); + $this->cacheLogger->queryCacheMiss($queryCache->getRegion()->getName(), $queryKey); if ($cached) { - $this->cacheLogger->queryCachePut($queryCache->getRegion()->getName(), $querykey); + $this->cacheLogger->queryCachePut($queryCache->getRegion()->getName(), $queryKey); } } return $result; } + /** + * @return \Doctrine\ORM\Cache\TimestampCacheKey|null + */ + private function getTimestampKey() + { + $entityName = reset($this->_resultSetMapping->aliasMap); + + if (empty($entityName)) { + return null; + } + + $metadata = $this->_em->getClassMetadata($entityName); + + return new Cache\TimestampCacheKey($metadata->getTableName()); + } + /** * Get the result cache id to use to store the result set cache entry. * Will return the configured id if it exists otherwise a hash will be diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 5690f9169..75e28ec1b 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -372,13 +372,13 @@ abstract class AbstractEntityPersister implements CachedEntityPersister $query = $this->persister->getSelectSQL($criteria, null, null, $limit, null, $orderBy); $hash = $this->getHash($query, $criteria, null, null, null, $timestamp ? $timestamp->time : null); $rsm = $this->getResultSetMapping(); - $querykey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL); + $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); - $result = $queryCache->get($querykey, $rsm); + $result = $queryCache->get($queryKey, $rsm); if ($result !== null) { if ($this->cacheLogger) { - $this->cacheLogger->queryCacheHit($this->regionName, $querykey); + $this->cacheLogger->queryCacheHit($this->regionName, $queryKey); } return $result[0]; @@ -388,15 +388,15 @@ abstract class AbstractEntityPersister implements CachedEntityPersister return null; } - $cached = $queryCache->put($querykey, $rsm, array($result)); + $cached = $queryCache->put($queryKey, $rsm, array($result)); if ($this->cacheLogger) { if ($result) { - $this->cacheLogger->queryCacheMiss($this->regionName, $querykey); + $this->cacheLogger->queryCacheMiss($this->regionName, $queryKey); } if ($cached) { - $this->cacheLogger->queryCachePut($this->regionName, $querykey); + $this->cacheLogger->queryCachePut($this->regionName, $queryKey); } } @@ -412,28 +412,28 @@ abstract class AbstractEntityPersister implements CachedEntityPersister $query = $this->persister->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); $hash = $this->getHash($query, $criteria, null, null, null, $timestamp ? $timestamp->time : null); $rsm = $this->getResultSetMapping(); - $querykey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL); + $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); - $result = $queryCache->get($querykey, $rsm); + $result = $queryCache->get($queryKey, $rsm); if ($result !== null) { if ($this->cacheLogger) { - $this->cacheLogger->queryCacheHit($this->regionName, $querykey); + $this->cacheLogger->queryCacheHit($this->regionName, $queryKey); } return $result; } $result = $this->persister->loadAll($criteria, $orderBy, $limit, $offset); - $cached = $queryCache->put($querykey, $rsm, $result); + $cached = $queryCache->put($queryKey, $rsm, $result); if ($this->cacheLogger) { if ($result) { - $this->cacheLogger->queryCacheMiss($this->regionName, $querykey); + $this->cacheLogger->queryCacheMiss($this->regionName, $queryKey); } if ($cached) { - $this->cacheLogger->queryCachePut($this->regionName, $querykey); + $this->cacheLogger->queryCachePut($this->regionName, $queryKey); } } @@ -514,28 +514,28 @@ abstract class AbstractEntityPersister implements CachedEntityPersister $timestamp = $this->timestampRegion->get($this->timestampKey); $hash = $this->getHash($query, $criteria, $orderBy, $limit, $offset, $timestamp ? $timestamp->time : null); $rsm = $this->getResultSetMapping(); - $querykey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL); + $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); - $cacheResult = $queryCache->get($querykey, $rsm); + $cacheResult = $queryCache->get($queryKey, $rsm); if ($cacheResult !== null) { if ($this->cacheLogger) { - $this->cacheLogger->queryCacheHit($this->regionName, $querykey); + $this->cacheLogger->queryCacheHit($this->regionName, $queryKey); } return $cacheResult; } $result = $this->persister->loadCriteria($criteria); - $cached = $queryCache->put($querykey, $rsm, $result); + $cached = $queryCache->put($queryKey, $rsm, $result); if ($this->cacheLogger) { if ($result) { - $this->cacheLogger->queryCacheMiss($this->regionName, $querykey); + $this->cacheLogger->queryCacheMiss($this->regionName, $queryKey); } if ($cached) { - $this->cacheLogger->queryCachePut($this->regionName, $querykey); + $this->cacheLogger->queryCachePut($this->regionName, $queryKey); } } diff --git a/lib/Doctrine/ORM/Cache/QueryCacheKey.php b/lib/Doctrine/ORM/Cache/QueryCacheKey.php index 9a7d2b7bc..0e072a36f 100644 --- a/lib/Doctrine/ORM/Cache/QueryCacheKey.php +++ b/lib/Doctrine/ORM/Cache/QueryCacheKey.php @@ -45,14 +45,27 @@ class QueryCacheKey extends CacheKey public $cacheMode; /** - * @param string $hash Result cache id - * @param integer $lifetime Query lifetime - * @param integer $cacheMode Query cache mode + * READ-ONLY: Public only for performance reasons, it should be considered immutable. + * + * @var TimestampCacheKey|null */ - public function __construct($hash, $lifetime = 0, $cacheMode = Cache::MODE_NORMAL) - { - $this->hash = $hash; - $this->lifetime = $lifetime; - $this->cacheMode = $cacheMode; + public $timestampKey; + + /** + * @param string $hash Result cache id + * @param integer $lifetime Query lifetime + * @param int $cacheMode Query cache mode + * @param TimestampCacheKey|null $timestampKey + */ + public function __construct( + $hash, + $lifetime = 0, + $cacheMode = Cache::MODE_NORMAL, + TimestampCacheKey $timestampKey = null + ) { + $this->hash = $hash; + $this->lifetime = $lifetime; + $this->cacheMode = $cacheMode; + $this->timestampKey = $timestampKey; } } From b431332cefe8e968d6af73033eaffc472eec7d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Fri, 2 Sep 2016 09:54:14 +0000 Subject: [PATCH 112/144] Evict query cache when entities are updated --- lib/Doctrine/ORM/Cache/CacheConfiguration.php | 4 ++- .../Cache/TimestampQueryCacheValidator.php | 34 ++++++++++++++++++ .../Tests/ORM/Cache/CacheConfigTest.php | 8 ++++- .../SecondLevelCacheQueryCacheTest.php | 35 ++++++++++++++++++- 4 files changed, 78 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/CacheConfiguration.php b/lib/Doctrine/ORM/Cache/CacheConfiguration.php index 4891cac49..eb3ec428d 100644 --- a/lib/Doctrine/ORM/Cache/CacheConfiguration.php +++ b/lib/Doctrine/ORM/Cache/CacheConfiguration.php @@ -110,7 +110,9 @@ class CacheConfiguration public function getQueryValidator() { if ($this->queryValidator === null) { - $this->queryValidator = new TimestampQueryCacheValidator(); + $this->queryValidator = new TimestampQueryCacheValidator( + $this->cacheFactory->getTimestampRegion() + ); } return $this->queryValidator; diff --git a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php index 71ac3e828..c6404d3b2 100644 --- a/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php +++ b/lib/Doctrine/ORM/Cache/TimestampQueryCacheValidator.php @@ -26,15 +26,49 @@ namespace Doctrine\ORM\Cache; */ class TimestampQueryCacheValidator implements QueryCacheValidator { + /** + * @var TimestampRegion + */ + private $timestampRegion; + + /** + * @param TimestampRegion $timestampRegion + */ + public function __construct(TimestampRegion $timestampRegion) + { + $this->timestampRegion = $timestampRegion; + } + /** * {@inheritdoc} */ public function isValid(QueryCacheKey $key, QueryCacheEntry $entry) { + if ($this->regionUpdated($key, $entry)) { + return false; + } + if ($key->lifetime == 0) { return true; } return ($entry->time + $key->lifetime) > microtime(true); } + + /** + * @param QueryCacheKey $key + * @param QueryCacheEntry $entry + * + * @return bool + */ + private function regionUpdated(QueryCacheKey $key, QueryCacheEntry $entry) + { + if ($key->timestampKey === null) { + return false; + } + + $timestamp = $this->timestampRegion->get($key->timestampKey); + + return $timestamp && $timestamp->time > $entry->time; + } } diff --git a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php index 321207c39..0de086387 100644 --- a/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php +++ b/tests/Doctrine/Tests/ORM/Cache/CacheConfigTest.php @@ -6,6 +6,7 @@ use Doctrine\ORM\Cache\CacheConfiguration; use Doctrine\ORM\Cache\CacheFactory; use Doctrine\ORM\Cache\QueryCacheValidator; use Doctrine\ORM\Cache\Logging\CacheLogger; +use Doctrine\ORM\Cache\TimestampRegion; use Doctrine\Tests\DoctrineTestCase; /** @@ -67,6 +68,11 @@ class CacheConfigTest extends DoctrineTestCase public function testSetGetQueryValidator() { + $factory = $this->createMock(CacheFactory::class); + $factory->method('getTimestampRegion')->willReturn($this->createMock(TimestampRegion::class)); + + $this->config->setCacheFactory($factory); + $validator = $this->createMock(QueryCacheValidator::class); $this->assertInstanceOf('Doctrine\ORM\Cache\TimestampQueryCacheValidator', $this->config->getQueryValidator()); @@ -75,4 +81,4 @@ class CacheConfigTest extends DoctrineTestCase $this->assertEquals($validator, $this->config->getQueryValidator()); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index 97d8ce82a..b34b0f825 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -1120,4 +1120,37 @@ class SecondLevelCacheQueryCacheTest extends SecondLevelCacheAbstractTest ->setCacheable(true) ->getResult(); } -} \ No newline at end of file + + public function testQueryCacheShouldBeEvictedOnTimestampUpdate() + { + $this->loadFixturesCountries(); + $this->_em->clear(); + + $queryCount = $this->getCurrentQueryCount(); + $dql = 'SELECT country FROM Doctrine\Tests\Models\Cache\Country country'; + + $result1 = $this->_em->createQuery($dql) + ->setCacheable(true) + ->getResult(); + + $this->assertCount(2, $result1); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + + $this->_em->persist(new Country('France')); + $this->_em->flush(); + $this->_em->clear(); + + $queryCount = $this->getCurrentQueryCount(); + + $result2 = $this->_em->createQuery($dql) + ->setCacheable(true) + ->getResult(); + + $this->assertCount(3, $result2); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + + foreach ($result2 as $entity) { + $this->assertInstanceOf(Country::CLASSNAME, $entity); + } + } +} From dd476094af6e811a394ec048ba96b9cfa48811f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 7 Sep 2016 22:32:59 +0000 Subject: [PATCH 113/144] The timestamp verification is now done by the validator So it's useless to keep it here too. --- .../Persister/Entity/AbstractEntityPersister.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php index 75e28ec1b..1a41014b9 100644 --- a/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php @@ -287,17 +287,16 @@ abstract class AbstractEntityPersister implements CachedEntityPersister * @param array $orderBy * @param integer $limit * @param integer $offset - * @param integer $timestamp * * @return string */ - protected function getHash($query, $criteria, array $orderBy = null, $limit = null, $offset = null, $timestamp = null) + protected function getHash($query, $criteria, array $orderBy = null, $limit = null, $offset = null) { list($params) = ($criteria instanceof Criteria) ? $this->persister->expandCriteriaParameters($criteria) : $this->persister->expandParameters($criteria); - return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset . $timestamp); + return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset); } /** @@ -368,9 +367,8 @@ abstract class AbstractEntityPersister implements CachedEntityPersister } //handle only EntityRepository#findOneBy - $timestamp = $this->timestampRegion->get($this->timestampKey); $query = $this->persister->getSelectSQL($criteria, null, null, $limit, null, $orderBy); - $hash = $this->getHash($query, $criteria, null, null, null, $timestamp ? $timestamp->time : null); + $hash = $this->getHash($query, $criteria, null, null, null); $rsm = $this->getResultSetMapping(); $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); @@ -408,9 +406,8 @@ abstract class AbstractEntityPersister implements CachedEntityPersister */ public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null) { - $timestamp = $this->timestampRegion->get($this->timestampKey); $query = $this->persister->getSelectSQL($criteria, null, null, $limit, $offset, $orderBy); - $hash = $this->getHash($query, $criteria, null, null, null, $timestamp ? $timestamp->time : null); + $hash = $this->getHash($query, $criteria, null, null, null); $rsm = $this->getResultSetMapping(); $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); @@ -511,8 +508,7 @@ abstract class AbstractEntityPersister implements CachedEntityPersister $limit = $criteria->getMaxResults(); $offset = $criteria->getFirstResult(); $query = $this->persister->getSelectSQL($criteria); - $timestamp = $this->timestampRegion->get($this->timestampKey); - $hash = $this->getHash($query, $criteria, $orderBy, $limit, $offset, $timestamp ? $timestamp->time : null); + $hash = $this->getHash($query, $criteria, $orderBy, $limit, $offset); $rsm = $this->getResultSetMapping(); $queryKey = new QueryCacheKey($hash, 0, Cache::MODE_NORMAL, $this->timestampKey); $queryCache = $this->cache->getQueryCache($this->regionName); From d27cffa8e65574c0468388f48977ac4859d44e1a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 8 Sep 2016 13:51:21 +0200 Subject: [PATCH 114/144] #6001 documenting minor BC break in `QueryCacheEntry#time` type - specific version used --- UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 2195f5b82..b71e10adb 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,7 +2,7 @@ ## Minor BC BREAK: query cache key time is now a float -As of 2.5, the `QueryCacheEntry#time` property will contain a float value +As of 2.5.5, the `QueryCacheEntry#time` property will contain a float value instead of an integer in order to have more precision and also to be consistent with the `TimestampCacheEntry#time`. From 5353137617345555ffba689d5a4b3ca451683222 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Thu, 8 Sep 2016 13:32:06 -0300 Subject: [PATCH 115/144] Update exception message at `EntityRepository::__call()` --- lib/Doctrine/ORM/EntityRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 0c2823757..1934a18d0 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -237,7 +237,7 @@ class EntityRepository implements ObjectRepository, Selectable throw new \BadMethodCallException( "Undefined method '$method'. The method name must start with ". - "either findBy or findOneBy!" + "either findBy, findOneBy or countBy!" ); } From e43b9e9e3a14f90213e4c8fe52f08e9df9cc1c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Fri, 9 Sep 2016 07:52:44 +0000 Subject: [PATCH 116/144] Use `isIdGeneratorIdentity()` to add the ID on query It's quite handy when creating CUSTOM id generators that should also rely on AUTO_INCREMENT stuff (one can just extend the `ClassMedatadaFactory` and create a different instance of `ClassMetadata` that overrides that method). --- lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index c62a10a12..d577df6d9 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -1442,7 +1442,7 @@ class BasicEntityPersister implements EntityPersister continue; } - if ($this->class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->class->identifier[0] != $name) { + if (! $this->class->isIdGeneratorIdentity() || $this->class->identifier[0] != $name) { $columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform); $this->columnTypes[$name] = $this->class->fieldMappings[$name]['type']; } From 60346e00469c9a06d2428e57d7132d2a4c32c57e Mon Sep 17 00:00:00 2001 From: guhelski Date: Fri, 9 Sep 2016 16:46:35 +0200 Subject: [PATCH 117/144] Fix typo --- docs/en/tutorials/embeddables.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tutorials/embeddables.rst b/docs/en/tutorials/embeddables.rst index 681aa7536..1dcb3c147 100644 --- a/docs/en/tutorials/embeddables.rst +++ b/docs/en/tutorials/embeddables.rst @@ -1,7 +1,7 @@ Separating Concerns using Embeddables ------------------------------------- -Embeddables are classes which are not entities themself, but are embedded +Embeddables are classes which are not entities themselves, but are embedded in entities and can also be queried in DQL. You'll mostly want to use them to reduce duplication or separating concerns. Value objects such as date range or address are the primary use case for this feature. Embeddables can only From 01d51bfca391e49bbb596c90d1a9c4766533155a Mon Sep 17 00:00:00 2001 From: Mathieu De Zutter Date: Tue, 1 Mar 2016 10:58:37 +0100 Subject: [PATCH 118/144] Avoid conflicts due to spl_object_hash(). When merging an entity with a to-many association, it will store the original entity data using the object hash of the to-be-merged entity instead of the managed entity. Since this to-be-merged entity is not managed by Doctrine, it can disappear from the memory. A new object can reuse the same memory location and thus have the same object hash. When one tries to persist this object as new, Doctrine will refuse it because it thinks that the entity is managed+dirty. This patch is a very naive fix: it just disables storing the original entity data in case of to-many associations. It may not be the ideal or even a good solution at all, but it solves the problem of object hash reuse. The test case relies on the immediate reusing of memory locations by PHP. The variable $user has twice the same object hash, though referring a different object. Tested on PHP 5.6.17 Without the fix, the test fails on the last line with: A managed+dirty entity Doctrine\Tests\Models\CMS\CmsUser@[...] can not be scheduled for insertion. --- lib/Doctrine/ORM/UnitOfWork.php | 2 +- .../Tests/ORM/Functional/OidReuseTest.php | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 7ac24cc60..403ab668d 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -3405,7 +3405,7 @@ class UnitOfWork implements PropertyChangedListener $managedCol->setOwner($managedCopy, $assoc2); $prop->setValue($managedCopy, $managedCol); - $this->originalEntityData[spl_object_hash($entity)][$name] = $managedCol; +// $this->originalEntityData[spl_object_hash($entity)][$name] = $managedCol; } if ($assoc2['isCascadeMerge']) { diff --git a/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php b/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php new file mode 100644 index 000000000..40aaf4238 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php @@ -0,0 +1,34 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testOidReuse() + { + $user = new CmsUser(); + $this->_em->merge($user); + + $user = null; + + $user = new CmsUser(); + $this->_em->persist($user); + } + +} \ No newline at end of file From b8c7d871bee7a4290551439ce65c7a66cf92041d Mon Sep 17 00:00:00 2001 From: Mathieu De Zutter Date: Tue, 1 Mar 2016 19:36:57 +0100 Subject: [PATCH 119/144] Remove old code in comments. --- lib/Doctrine/ORM/UnitOfWork.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 403ab668d..59ee1c1cb 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -3404,8 +3404,6 @@ class UnitOfWork implements PropertyChangedListener ); $managedCol->setOwner($managedCopy, $assoc2); $prop->setValue($managedCopy, $managedCol); - -// $this->originalEntityData[spl_object_hash($entity)][$name] = $managedCol; } if ($assoc2['isCascadeMerge']) { From 44af69c5d2299e46f90a94e91c35711afe8392de Mon Sep 17 00:00:00 2001 From: Mathieu De Zutter Date: Tue, 1 Mar 2016 19:51:38 +0100 Subject: [PATCH 120/144] Additional assertion to check that unreferenced objects are not in UOW. --- tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php b/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php index 40aaf4238..742b183fe 100644 --- a/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php @@ -22,11 +22,19 @@ class OidReuseTest extends OrmFunctionalTestCase public function testOidReuse() { + $uow = $this->_em->getUnitOfWork(); + $reflexion = new \ReflectionClass(get_class($uow)); + $originalEntityDataProperty = $reflexion->getProperty('originalEntityData'); + $originalEntityDataProperty->setAccessible(true); + $user = new CmsUser(); + $oid = spl_object_hash($user); $this->_em->merge($user); $user = null; + $this->assertArrayNotHasKey($oid, $originalEntityDataProperty->getValue($uow)); + $user = new CmsUser(); $this->_em->persist($user); } From 75bf197e115ce7f66ff49adc7c96f2f72c896762 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 10 Sep 2016 20:15:33 +0200 Subject: [PATCH 121/144] #5689 moved `OidReuseTest` contents into the `UnitOfWork` tests --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 6a2c882e8..a604641f8 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -14,6 +14,7 @@ use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\EntityPersisterMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; use Doctrine\Tests\Models\CMS\CmsPhonenumber; +use Doctrine\Tests\Models\CMS\CmsUser; use Doctrine\Tests\Models\Forum\ForumAvatar; use Doctrine\Tests\Models\Forum\ForumUser; use Doctrine\Tests\Models\GeoNames\City; @@ -459,6 +460,38 @@ class UnitOfWorkTest extends OrmTestCase 'second null string, two fields' => [$secondNullString, ['id1' => $secondNullString->id1, 'id2' => null]], ]; } + + /** + * @group 5689 + * @group 1465 + */ + public function testObjectHashesOfMergedEntitiesAreNotUsedInOriginalEntityDataMap() + { + $reflectionOriginalEntityData = new \ReflectionProperty('Doctrine\ORM\UnitOfWork', 'originalEntityData'); + + $reflectionOriginalEntityData->setAccessible(true); + + $user = new CmsUser(); + $user->name = 'ocramius'; + $mergedUser = $this->_unitOfWork->merge($user); + + self::assertSame([], $this->_unitOfWork->getOriginalEntityData($user), 'No original data was stored'); + self::assertSame([], $this->_unitOfWork->getOriginalEntityData($mergedUser), 'No original data was stored'); + + + $user = null; + $mergedUser = null; + + // force garbage collection of $user (frees the used object hashes, which may be recycled) + gc_collect_cycles(); + + $newUser = new CmsUser(); + $newUser->name = 'ocramius'; + + $this->_unitOfWork->persist($newUser); + + self::assertSame([], $this->_unitOfWork->getOriginalEntityData($newUser), 'No original data was stored'); + } } /** From f8436b2165ea6878e0fb45dbd3c30493443f544d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 10 Sep 2016 20:15:59 +0200 Subject: [PATCH 122/144] #5689 removed `OidReuseTest`, which was moved to `UnitOfWork` tests --- .../Tests/ORM/Functional/OidReuseTest.php | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php b/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php deleted file mode 100644 index 742b183fe..000000000 --- a/tests/Doctrine/Tests/ORM/Functional/OidReuseTest.php +++ /dev/null @@ -1,42 +0,0 @@ -useModelSet('cms'); - parent::setUp(); - } - - public function testOidReuse() - { - $uow = $this->_em->getUnitOfWork(); - $reflexion = new \ReflectionClass(get_class($uow)); - $originalEntityDataProperty = $reflexion->getProperty('originalEntityData'); - $originalEntityDataProperty->setAccessible(true); - - $user = new CmsUser(); - $oid = spl_object_hash($user); - $this->_em->merge($user); - - $user = null; - - $this->assertArrayNotHasKey($oid, $originalEntityDataProperty->getValue($uow)); - - $user = new CmsUser(); - $this->_em->persist($user); - } - -} \ No newline at end of file From 503b211a22db02ea825942aacf6dbff87d438aaa Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 10 Sep 2016 20:19:15 +0200 Subject: [PATCH 123/144] #5689 removed unused reflection access --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index a604641f8..0ff2572b9 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -467,10 +467,6 @@ class UnitOfWorkTest extends OrmTestCase */ public function testObjectHashesOfMergedEntitiesAreNotUsedInOriginalEntityDataMap() { - $reflectionOriginalEntityData = new \ReflectionProperty('Doctrine\ORM\UnitOfWork', 'originalEntityData'); - - $reflectionOriginalEntityData->setAccessible(true); - $user = new CmsUser(); $user->name = 'ocramius'; $mergedUser = $this->_unitOfWork->merge($user); From 67e205b36acdc73097b79802b097389a491216b9 Mon Sep 17 00:00:00 2001 From: Ed Hartwell Goose Date: Mon, 11 Apr 2016 17:01:55 +0100 Subject: [PATCH 124/144] Fixes #5755, uses '->getReflectionProperties()' instead of '->getReflectionClass()->getProperties()' to ensure all fields are copied, and adds test to confirm behaviour --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 2 +- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 50 +++++++++++++++++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 72f161eab..58dfc0932 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -196,7 +196,7 @@ class ProxyFactory extends AbstractProxyFactory ); } - foreach ($class->getReflectionClass()->getProperties() as $property) { + foreach ($class->getReflectionProperties() as $property) { if ( ! $class->hasField($property->name) && ! $class->hasAssociation($property->name)) { continue; } diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index dd5b730f6..1d21207f6 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -3,16 +3,17 @@ namespace Doctrine\Tests\ORM\Proxy; use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; +use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\ORM\EntityNotFoundException; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; use Doctrine\ORM\Proxy\ProxyFactory; use Doctrine\Tests\Mocks\ConnectionMock; +use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; -use Doctrine\Tests\Mocks\DriverMock; -use Doctrine\Common\Proxy\AbstractProxyFactory; use Doctrine\Tests\OrmTestCase; +use Doctrine\Tests\Models\Company\CompanyEmployee; /** * Test the proxy generator. Its work is generating on-the-fly subclasses of a given model, which implement the Proxy pattern. @@ -65,9 +66,9 @@ class ProxyFactoryTest extends OrmTestCase $persister ->expects($this->atLeastOnce()) - ->method('load') - ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) - ->will($this->returnValue(new \stdClass())); + ->method('load') + ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) + ->will($this->returnValue(new \stdClass())); $proxy->getDescription(); } @@ -139,6 +140,45 @@ class ProxyFactoryTest extends OrmTestCase $this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed'); $this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed'); } + + public function testProxyClonesParentFields() + { + $companyEmployee = new CompanyEmployee(); + $companyEmployee->setSalary(1000); // A property on the CompanyEmployee + $companyEmployee->setName("Bob"); // A property on the parent class, CompanyPerson + + // Set the id of the CompanyEmployee (which is in the parent CompanyPerson) + $class = new \ReflectionClass('Doctrine\Tests\Models\Company\CompanyPerson'); + + $property = $class->getProperty('id'); + $property->setAccessible(true); + + $property->setValue($companyEmployee, 42); + + $classMetaData = $this->emMock->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee'); + + $persister = $this->getMock('Doctrine\ORM\Persisters\Entity\BasicEntityPersister', array('load', 'getClassMetadata'), array(), '', false); + $this->uowMock->setEntityPersister('Doctrine\Tests\Models\Company\CompanyEmployee', $persister); + + /* @var $proxy \Doctrine\Common\Proxy\Proxy */ + $proxy = $this->proxyFactory->getProxy('Doctrine\Tests\Models\Company\CompanyEmployee', array('id' => 42)); + + $persister + ->expects($this->atLeastOnce()) + ->method('load') + ->will($this->returnValue($companyEmployee)); + + $persister + ->expects($this->atLeastOnce()) + ->method('getClassMetadata') + ->will($this->returnValue($classMetaData)); + + $cloned = clone $proxy; + + $this->assertEquals(42, $cloned->getId(), "Expected the Id to be cloned"); + $this->assertEquals(1000, $cloned->getSalary(), "Expect properties on the CompanyEmployee class to be cloned"); + $this->assertEquals("Bob", $cloned->getName(), "Expect properties on the CompanyPerson class to be cloned"); + } } abstract class AbstractClass From 3fca33bdc42ddb70d2b284970e8e6533f11b06ba Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 10 Sep 2016 20:45:01 +0200 Subject: [PATCH 125/144] #5768 #5755 cleaned up test scenario, using new mocking logic as per PHPUnit 5.4+ --- .../Tests/ORM/Proxy/ProxyFactoryTest.php | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php index 1d21207f6..174daf3c0 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -12,6 +12,7 @@ use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\Mocks\EntityManagerMock; use Doctrine\Tests\Mocks\UnitOfWorkMock; +use Doctrine\Tests\Models\Company\CompanyPerson; use Doctrine\Tests\OrmTestCase; use Doctrine\Tests\Models\Company\CompanyEmployee; @@ -145,39 +146,42 @@ class ProxyFactoryTest extends OrmTestCase { $companyEmployee = new CompanyEmployee(); $companyEmployee->setSalary(1000); // A property on the CompanyEmployee - $companyEmployee->setName("Bob"); // A property on the parent class, CompanyPerson + $companyEmployee->setName('Bob'); // A property on the parent class, CompanyPerson // Set the id of the CompanyEmployee (which is in the parent CompanyPerson) - $class = new \ReflectionClass('Doctrine\Tests\Models\Company\CompanyPerson'); + $property = new \ReflectionProperty(CompanyPerson::class, 'id'); - $property = $class->getProperty('id'); $property->setAccessible(true); - $property->setValue($companyEmployee, 42); - $classMetaData = $this->emMock->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee'); + $classMetaData = $this->emMock->getClassMetadata(CompanyEmployee::class); - $persister = $this->getMock('Doctrine\ORM\Persisters\Entity\BasicEntityPersister', array('load', 'getClassMetadata'), array(), '', false); - $this->uowMock->setEntityPersister('Doctrine\Tests\Models\Company\CompanyEmployee', $persister); + $persister = $this + ->getMockBuilder(BasicEntityPersister::class) + ->setMethods(['load', 'getClassMetadata']) + ->disableOriginalConstructor() + ->getMock(); + $this->uowMock->setEntityPersister(CompanyEmployee::class, $persister); /* @var $proxy \Doctrine\Common\Proxy\Proxy */ - $proxy = $this->proxyFactory->getProxy('Doctrine\Tests\Models\Company\CompanyEmployee', array('id' => 42)); + $proxy = $this->proxyFactory->getProxy(CompanyEmployee::class, ['id' => 42]); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('load') - ->will($this->returnValue($companyEmployee)); + ->willReturn($companyEmployee); $persister - ->expects($this->atLeastOnce()) + ->expects(self::atLeastOnce()) ->method('getClassMetadata') - ->will($this->returnValue($classMetaData)); + ->willReturn($classMetaData); + /* @var $cloned CompanyEmployee */ $cloned = clone $proxy; - $this->assertEquals(42, $cloned->getId(), "Expected the Id to be cloned"); - $this->assertEquals(1000, $cloned->getSalary(), "Expect properties on the CompanyEmployee class to be cloned"); - $this->assertEquals("Bob", $cloned->getName(), "Expect properties on the CompanyPerson class to be cloned"); + self::assertSame(42, $cloned->getId(), 'Expected the Id to be cloned'); + self::assertSame(1000, $cloned->getSalary(), 'Expect properties on the CompanyEmployee class to be cloned'); + self::assertSame('Bob', $cloned->getName(), 'Expect properties on the CompanyPerson class to be cloned'); } } From 974a9f4b9e2519f56db5c36fcdc455e644df5f71 Mon Sep 17 00:00:00 2001 From: Tomas Kormanak Date: Sun, 2 Oct 2016 22:38:40 +0200 Subject: [PATCH 126/144] Fix PHP version in readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 96862eea2..dffd57ed1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ | [![Build status][Master image]][Master] | [![Build status][2.5 image]][2.5] | | [![Coverage Status][Master coverage image]][Master coverage] | [![Coverage Status][2.5 coverage image]][2.5 coverage] | -Doctrine 2 is an object-relational mapper (ORM) for PHP 5.4+ that provides transparent persistence +Doctrine 2 is an object-relational mapper (ORM) for PHP 5.6+ that provides transparent persistence for PHP objects. It sits on top of a powerful database abstraction layer (DBAL). One of its key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL), inspired by Hibernate's HQL. This provides developers with a powerful alternative to SQL that maintains flexibility From 96b3797ad677b1db64e7874c5d6695b2325c863a Mon Sep 17 00:00:00 2001 From: Adrian Zmenda Date: Mon, 3 Oct 2016 12:25:49 +0200 Subject: [PATCH 127/144] Update Autoloader namespace --- docs/en/reference/advanced-configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/advanced-configuration.rst b/docs/en/reference/advanced-configuration.rst index 9d200f870..abb72636c 100644 --- a/docs/en/reference/advanced-configuration.rst +++ b/docs/en/reference/advanced-configuration.rst @@ -394,7 +394,7 @@ means that you have to register a special autoloader for these classes: .. code-block:: php Date: Wed, 5 Oct 2016 14:16:47 +0300 Subject: [PATCH 128/144] Update events.rst https://github.com/doctrine/doctrine2/pull/169 --- docs/en/reference/events.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/events.rst b/docs/en/reference/events.rst index 171adca02..5a18a1806 100644 --- a/docs/en/reference/events.rst +++ b/docs/en/reference/events.rst @@ -179,7 +179,7 @@ the life-time of their registered entities. allows providing fallback metadata even when no actual metadata exists or could be found. This event is not a lifecycle callback. - preFlush - The preFlush event occurs at the very beginning of a flush - operation. This event is not a lifecycle callback. + operation. - onFlush - The onFlush event occurs after the change-sets of all managed entities are computed. This event is not a lifecycle callback. From 277833b4877be45052cbac0c6a7ab2ecfa47fa57 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 11 Oct 2016 16:59:03 +0200 Subject: [PATCH 129/144] Fixed typo + added link --- docs/en/reference/events.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/reference/events.rst b/docs/en/reference/events.rst index 5a18a1806..e6c8b0aa4 100644 --- a/docs/en/reference/events.rst +++ b/docs/en/reference/events.rst @@ -406,8 +406,8 @@ behaviors across different entity classes. Note that they require much more detailed knowledge about the inner workings of the EntityManager and UnitOfWork. Please read the -*Implementing Event Listeners* section carefully if you are trying -to write your own listener. +:ref:`reference-events-implementing-listeners` section carefully if you +are trying to write your own listener. For event subscribers, there are no surprises. They declare the lifecycle events in their ``getSubscribedEvents`` method and provide @@ -434,7 +434,7 @@ A lifecycle event listener looks like the following: } } -A lifecycle event subscriber may looks like this: +A lifecycle event subscriber may look like this: .. code-block:: php From 03da85e19e4ec7a64de208e187af9ce3f151e4d4 Mon Sep 17 00:00:00 2001 From: chihiro-adachi Date: Sat, 15 Oct 2016 15:41:10 +0900 Subject: [PATCH 130/144] fix namespace --- docs/en/reference/second-level-cache.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/reference/second-level-cache.rst b/docs/en/reference/second-level-cache.rst index e89beba31..71286846f 100644 --- a/docs/en/reference/second-level-cache.rst +++ b/docs/en/reference/second-level-cache.rst @@ -156,17 +156,17 @@ Cached persisters are responsible to access cache regions. +-----------------------+-------------------------------------------------------------------------------+ | Cache Usage | Persister | +=======================+===============================================================================+ - | READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\ReadOnlyCachedEntityPersister | + | READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadOnlyCachedEntityPersister | +-----------------------+-------------------------------------------------------------------------------+ - | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\ReadWriteCachedEntityPersister | + | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadWriteCachedEntityPersister | +-----------------------+-------------------------------------------------------------------------------+ - | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\NonStrictReadWriteCachedEntityPersister | + | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\NonStrictReadWriteCachedEntityPersister | +-----------------------+-------------------------------------------------------------------------------+ - | READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\ReadOnlyCachedCollectionPersister | + | READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\Collection\\ReadOnlyCachedCollectionPersister | +-----------------------+-------------------------------------------------------------------------------+ - | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\ReadWriteCachedCollectionPersister | + | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\ReadWriteCachedCollectionPersister | +-----------------------+-------------------------------------------------------------------------------+ - | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\NonStrictReadWriteCacheCollectionPersister | + | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\NonStrictReadWriteCacheCollectionPersister | +-----------------------+-------------------------------------------------------------------------------+ Configuration From fb1136cc9acd462da75a30d741e9d4a958a7c81b Mon Sep 17 00:00:00 2001 From: chihiro-adachi Date: Sat, 15 Oct 2016 15:47:49 +0900 Subject: [PATCH 131/144] adjust the appearance of the table --- docs/en/reference/second-level-cache.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/en/reference/second-level-cache.rst b/docs/en/reference/second-level-cache.rst index 71286846f..dca4bf828 100644 --- a/docs/en/reference/second-level-cache.rst +++ b/docs/en/reference/second-level-cache.rst @@ -153,21 +153,21 @@ Built-in cached persisters Cached persisters are responsible to access cache regions. - +-----------------------+-------------------------------------------------------------------------------+ - | Cache Usage | Persister | - +=======================+===============================================================================+ - | READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadOnlyCachedEntityPersister | - +-----------------------+-------------------------------------------------------------------------------+ - | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadWriteCachedEntityPersister | - +-----------------------+-------------------------------------------------------------------------------+ - | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\NonStrictReadWriteCachedEntityPersister | - +-----------------------+-------------------------------------------------------------------------------+ + +-----------------------+-------------------------------------------------------------------------------------------+ + | Cache Usage | Persister | + +=======================+===========================================================================================+ + | READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadOnlyCachedEntityPersister | + +-----------------------+-------------------------------------------------------------------------------------------+ + | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\ReadWriteCachedEntityPersister | + +-----------------------+-------------------------------------------------------------------------------------------+ + | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Entity\\NonStrictReadWriteCachedEntityPersister | + +-----------------------+-------------------------------------------------------------------------------------------+ | READ_ONLY | Doctrine\\ORM\\Cache\\Persister\\Collection\\ReadOnlyCachedCollectionPersister | - +-----------------------+-------------------------------------------------------------------------------+ + +-----------------------+-------------------------------------------------------------------------------------------+ | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\ReadWriteCachedCollectionPersister | - +-----------------------+-------------------------------------------------------------------------------+ + +-----------------------+-------------------------------------------------------------------------------------------+ | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\NonStrictReadWriteCacheCollectionPersister | - +-----------------------+-------------------------------------------------------------------------------+ + +-----------------------+-------------------------------------------------------------------------------------------+ Configuration ------------- From 42c4938a8b904196c5cc66753e9b46f20a6d8806 Mon Sep 17 00:00:00 2001 From: chihiro-adachi Date: Tue, 18 Oct 2016 11:54:11 +0900 Subject: [PATCH 132/144] cache -> cached --- docs/en/reference/second-level-cache.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/second-level-cache.rst b/docs/en/reference/second-level-cache.rst index dca4bf828..07f39a34f 100644 --- a/docs/en/reference/second-level-cache.rst +++ b/docs/en/reference/second-level-cache.rst @@ -166,7 +166,7 @@ Cached persisters are responsible to access cache regions. +-----------------------+-------------------------------------------------------------------------------------------+ | READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\ReadWriteCachedCollectionPersister | +-----------------------+-------------------------------------------------------------------------------------------+ - | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\NonStrictReadWriteCacheCollectionPersister | + | NONSTRICT_READ_WRITE | Doctrine\\ORM\\Cache\\Persister\\Collection\\NonStrictReadWriteCachedCollectionPersister | +-----------------------+-------------------------------------------------------------------------------------------+ Configuration From d3c2c4045291f20b25fbb41c799c56f4b5c56fde Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 18 Oct 2016 18:21:46 +0200 Subject: [PATCH 133/144] Updated a link (hopefully :-) --- docs/en/reference/working-with-objects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 2b52fac41..101cb3352 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -744,7 +744,7 @@ The Repository implement the ``Doctrine\Common\Collections\Selectable`` interface. That means you can build ``Doctrine\Common\Collections\Criteria`` and pass them to the ``matching($criteria)`` method. -See the :ref:`Working with Associations: Filtering collections +See :doc:`Working with Associations: Filtering collections `. By Eager Loading From d6eddab94fd71f18ee80b9d7f2a26fd4b32b246c Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 18 Oct 2016 10:00:10 -0700 Subject: [PATCH 134/144] Revert "Merge pull request #6092 from ThomasLandauer/patch-2" This reverts commit ade3f3a7f36d4b8a2ccf14afd4b71e7b0d0509da, reversing changes made to a6e44d9305114c2a597bd7db2bb934f2c2325ed3. --- docs/en/reference/working-with-objects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/working-with-objects.rst b/docs/en/reference/working-with-objects.rst index 101cb3352..2b52fac41 100644 --- a/docs/en/reference/working-with-objects.rst +++ b/docs/en/reference/working-with-objects.rst @@ -744,7 +744,7 @@ The Repository implement the ``Doctrine\Common\Collections\Selectable`` interface. That means you can build ``Doctrine\Common\Collections\Criteria`` and pass them to the ``matching($criteria)`` method. -See :doc:`Working with Associations: Filtering collections +See the :ref:`Working with Associations: Filtering collections `. By Eager Loading From cdad5a82c56290a176ca035d3b47662256d519b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Schr=C3=B6der?= Date: Thu, 20 Oct 2016 13:32:59 +0200 Subject: [PATCH 135/144] Fixed typo in annotations reference --- docs/en/reference/annotations-reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index 7b59aa678..e55a23eff 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -315,7 +315,7 @@ depending on whether the classes are in the namespace or not. @Embeddable ~~~~~~~~~~~~~~~~~~~~~ -The embeddable is required on an entity targed to be embeddable inside +The embeddable is required on an entity targeted to be embeddable inside another. It works together with the :ref:`@Embedded ` annotation to establish the relationship between two entities. From 3861cbf3172b7c7f84aff0b952fb200ea9cb9055 Mon Sep 17 00:00:00 2001 From: Garanzha Dmitriy Date: Tue, 18 Oct 2016 10:39:16 +0300 Subject: [PATCH 136/144] Remove duplicated enum type comment from declaration. --- docs/en/cookbook/mysql-enums.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/en/cookbook/mysql-enums.rst b/docs/en/cookbook/mysql-enums.rst index 1d8df9259..1765ecc90 100644 --- a/docs/en/cookbook/mysql-enums.rst +++ b/docs/en/cookbook/mysql-enums.rst @@ -98,7 +98,7 @@ For example for the previous enum type: public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { - return sprintf("ENUM('visible', 'invisible') COMMENT '(DC2Type:%s)'", self::ENUM_VISIBILITY); + return "ENUM('visible', 'invisible')"; } public function convertToPHPValue($value, AbstractPlatform $platform) @@ -118,6 +118,11 @@ For example for the previous enum type: { return self::ENUM_VISIBILITY; } + + public function requiresSQLCommentHint(AbstractPlatform $platform) + { + return true; + } } You can register this type with ``Type::addType('enumvisibility', 'MyProject\DBAL\EnumVisibilityType');``. @@ -152,7 +157,7 @@ You can generalize this approach easily to create a base class for enums: { $values = array_map(function($val) { return "'".$val."'"; }, $this->values); - return "ENUM(".implode(", ", $values).") COMMENT '(DC2Type:".$this->name.")'"; + return "ENUM(".implode(", ", $values).")"; } public function convertToPHPValue($value, AbstractPlatform $platform) @@ -172,6 +177,11 @@ You can generalize this approach easily to create a base class for enums: { return $this->name; } + + public function requiresSQLCommentHint(AbstractPlatform $platform) + { + return true; + } } With this base class you can define an enum as easily as: From 81fefb40dbd6b7b6f913501616075ecc779a1742 Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Tue, 25 Oct 2016 23:51:31 -0300 Subject: [PATCH 137/144] composer require --dev malukenho/docheader --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f5b3b08f7..533c19299 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ }, "require-dev": { "symfony/yaml": "~2.3|~3.0", - "phpunit/phpunit": "^5.4" + "phpunit/phpunit": "^5.4", + "malukenho/docheader": "^0.1.4" }, "suggest": { "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" From e4050edb4ecc76de625547343ed4431fa64f230c Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Tue, 25 Oct 2016 23:52:07 -0300 Subject: [PATCH 138/144] add license template file --- .docheader | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .docheader diff --git a/.docheader b/.docheader new file mode 100644 index 000000000..23753e7fe --- /dev/null +++ b/.docheader @@ -0,0 +1,17 @@ +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. For more information, see + * . + */ From ca1a9473d3348cd0ed727ba6f2a5bfebe0ab4915 Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Tue, 25 Oct 2016 23:53:17 -0300 Subject: [PATCH 139/144] add license checker to the build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5a9fb2dcb..31516a116 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ before_script: script: - ENABLE_SECOND_LEVEL_CACHE=0 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml $PHPUNIT_FLAGS - ENABLE_SECOND_LEVEL_CACHE=1 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml --exclude-group performance,non-cacheable,locking_functional + - ./vendor/bin/docheader check lib/ after_script: - if [[ $TRAVIS_PHP_VERSION = '7.0' && $DB = 'sqlite' ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi From b8a18cd0a101df0aadc5339f6aaead175596cfca Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Tue, 25 Oct 2016 23:58:42 -0300 Subject: [PATCH 140/144] fix license header inconsistencies --- lib/Doctrine/ORM/EntityManagerInterface.php | 4 +-- lib/Doctrine/ORM/Event/LifecycleEventArgs.php | 2 +- .../Mapping/Driver/SimplifiedXmlDriver.php | 2 +- .../Mapping/Driver/SimplifiedYamlDriver.php | 2 +- lib/Doctrine/ORM/Mapping/MappingException.php | 2 +- .../ORM/Query/AST/NewObjectExpression.php | 2 +- .../ORM/Tools/Export/ExportException.php | 19 +++++++++++- .../Tools/Pagination/CountOutputWalker.php | 24 +++++++++------ .../ORM/Tools/Pagination/CountWalker.php | 24 +++++++++------ .../Pagination/LimitSubqueryOutputWalker.php | 24 +++++++++------ .../Tools/Pagination/LimitSubqueryWalker.php | 29 ++++++++++--------- .../ORM/Tools/Pagination/WhereInWalker.php | 28 +++++++++--------- lib/Doctrine/ORM/Tools/SchemaValidator.php | 2 +- lib/Doctrine/ORM/Tools/Setup.php | 2 +- 14 files changed, 102 insertions(+), 64 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index 016cfd4ec..09c7efdf9 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -7,9 +7,9 @@ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION); HOWEVER CAUSED AND ON ANY + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE); ARISING IN ANY WAY OUT OF THE USE + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals diff --git a/lib/Doctrine/ORM/Event/LifecycleEventArgs.php b/lib/Doctrine/ORM/Event/LifecycleEventArgs.php index 9a5c8cf06..c7eb80bf6 100644 --- a/lib/Doctrine/ORM/Event/LifecycleEventArgs.php +++ b/lib/Doctrine/ORM/Event/LifecycleEventArgs.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\ORM\Event; diff --git a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php index 85221f3a2..9bfd84cae 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedXmlDriver.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\ORM\Mapping\Driver; diff --git a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php index d2b8c0fcf..8f38784f4 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/SimplifiedYamlDriver.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\ORM\Mapping\Driver; diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index ace42db27..97686d654 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -14,7 +14,7 @@ * * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see - * . + * . */ namespace Doctrine\ORM\Mapping; diff --git a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php index 65b94ac63..ec011ce29 100644 --- a/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php +++ b/lib/Doctrine/ORM/Query/AST/NewObjectExpression.php @@ -13,7 +13,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many individuals - * and is licensed under the MIT. For more information, see + * and is licensed under the MIT license. For more information, see * . */ diff --git a/lib/Doctrine/ORM/Tools/Export/ExportException.php b/lib/Doctrine/ORM/Tools/Export/ExportException.php index 89ddfe22e..853159f17 100644 --- a/lib/Doctrine/ORM/Tools/Export/ExportException.php +++ b/lib/Doctrine/ORM/Tools/Export/ExportException.php @@ -1,4 +1,21 @@ . + */ namespace Doctrine\ORM\Tools\Export; @@ -35,4 +52,4 @@ class ExportException extends ORMException { return new self("Attempting to overwrite an existing file '".$file."'."); } -} \ No newline at end of file +} diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index e44be6c57..2cfd029df 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -1,14 +1,20 @@ . */ namespace Doctrine\ORM\Tools\Pagination; diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index ff0c6b363..628bd4cd1 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -1,14 +1,20 @@ . */ namespace Doctrine\ORM\Tools\Pagination; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 92386e46d..5d59722ed 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -1,14 +1,20 @@ . */ namespace Doctrine\ORM\Tools\Pagination; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index fd51fb46b..b2a292ad9 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -1,19 +1,20 @@ - * @copyright Copyright (c) 2010 David Abdemoulaie (http://hobodave.com/) - * @license http://hobodave.com/license.txt New BSD License + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. For more information, see + * . */ namespace Doctrine\ORM\Tools\Pagination; diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index 9f42a1eea..1f54da100 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -1,18 +1,20 @@ - * @copyright Copyright (c) 2010 David Abdemoulaie (http://hobodave.com/) - * @license http://hobodave.com/license.txt New BSD License + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. For more information, see + * . */ namespace Doctrine\ORM\Tools\Pagination; diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 03222700c..3f5799a4d 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\ORM\Tools; diff --git a/lib/Doctrine/ORM/Tools/Setup.php b/lib/Doctrine/ORM/Tools/Setup.php index 79d4670ad..99262f103 100644 --- a/lib/Doctrine/ORM/Tools/Setup.php +++ b/lib/Doctrine/ORM/Tools/Setup.php @@ -15,7 +15,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. For more information, see * . -*/ + */ namespace Doctrine\ORM\Tools; From dbe843fc4bae823cbe638cb7f396998908b93bca Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Wed, 26 Oct 2016 13:24:33 -0300 Subject: [PATCH 141/144] remove license from header of test files --- .../Tests/DbalTypes/CustomIdObject.php | 17 ---------------- .../Tests/DbalTypes/CustomIdObjectType.php | 17 ---------------- .../Tests/Mocks/EntityManagerMock.php | 19 ------------------ .../Tests/Mocks/StatementArrayMock.php | 8 +------- tests/Doctrine/Tests/Mocks/TaskMock.php | 19 ------------------ tests/Doctrine/Tests/Models/CMS/CmsGroup.php | 4 ---- tests/Doctrine/Tests/Models/CMS/CmsTag.php | 4 ---- .../CustomType/CustomIdObjectTypeChild.php | 17 ---------------- .../CustomType/CustomIdObjectTypeParent.php | 17 ---------------- .../DDC1476EntityWithDefaultFieldType.php | 20 +------------------ .../Tests/Models/DDC3711/DDC3711EntityA.php | 9 +++++---- .../Tests/Models/DDC3711/DDC3711EntityB.php | 9 +++++---- .../Models/DDC753/DDC753CustomRepository.php | 20 +------------------ .../Models/DDC753/DDC753DefaultRepository.php | 20 +------------------ .../DDC753EntityWithCustomRepository.php | 20 +------------------ ...DC753EntityWithDefaultCustomRepository.php | 20 +------------------ .../DDC753EntityWithInvalidRepository.php | 20 +------------------ .../Models/DDC753/DDC753InvalidRepository.php | 20 +------------------ .../Models/DDC869/DDC869ChequePayment.php | 20 +------------------ .../Models/DDC869/DDC869CreditCardPayment.php | 20 +------------------ .../Tests/Models/DDC869/DDC869Payment.php | 20 +------------------ .../Models/DDC869/DDC869PaymentRepository.php | 20 +------------------ .../Tests/Models/DDC889/DDC889Class.php | 20 +------------------ .../Tests/Models/DDC889/DDC889Entity.php | 20 +------------------ .../Tests/Models/DDC889/DDC889SuperClass.php | 20 +------------------ .../DirectoryTree/AbstractContentItem.php | 17 ---------------- .../Tests/Models/DirectoryTree/Directory.php | 17 ---------------- .../Tests/Models/DirectoryTree/File.php | 17 ---------------- .../ORM/Functional/CustomIdObjectTypeTest.php | 17 ---------------- .../EntityRepositoryCriteriaTest.php | 17 ---------------- .../Functional/MergeSharedEntitiesTest.php | 17 ---------------- .../PersistentCollectionCriteriaTest.php | 16 --------------- .../Functional/PersistentCollectionTest.php | 2 -- .../ORM/Functional/Ticket/DDC3711Test.php | 8 ++++---- .../ORM/Mapping/ClassMetadataBuilderTest.php | 17 ---------------- .../Tests/ORM/Mapping/FieldBuilderTest.php | 17 ---------------- .../JoinColumnClassNamingStrategy.php | 18 ----------------- .../Mapping/Symfony/AbstractDriverTest.php | 17 ---------------- .../ORM/Mapping/Symfony/XmlDriverTest.php | 17 ---------------- .../ORM/Mapping/Symfony/YamlDriverTest.php | 17 ---------------- .../ORM/Performance/ProxyPerformanceTest.php | 17 ---------------- .../JoinedSubclassPersisterTest.php | 17 ---------------- .../ORM/Query/CustomTreeWalkersJoinTest.php | 17 ---------------- .../Tests/ORM/Query/CustomTreeWalkersTest.php | 19 +----------------- .../ORM/Query/DeleteSqlGenerationTest.php | 19 ------------------ tests/Doctrine/Tests/ORM/Query/ExprTest.php | 17 ---------------- .../ORM/Query/ParameterTypeInfererTest.php | 18 +---------------- .../ORM/Query/QueryExpressionVisitorTest.php | 17 ---------------- .../ORM/Query/UpdateSqlGenerationTest.php | 19 ------------------ tests/Doctrine/Tests/ORM/QueryBuilderTest.php | 17 ---------------- .../ORM/Tools/ConvertDoctrine1SchemaTest.php | 19 ------------------ .../AbstractClassMetadataExporterTest.php | 19 ------------------ .../AnnotationClassMetadataExporterTest.php | 19 ------------------ .../Export/PhpClassMetadataExporterTest.php | 19 ------------------ .../Export/XmlClassMetadataExporterTest.php | 19 ------------------ .../Export/YamlClassMetadataExporterTest.php | 19 ------------------ 56 files changed, 31 insertions(+), 911 deletions(-) diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php index df34ebccb..d777d2dc4 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIdObject.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\DbalTypes; diff --git a/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php b/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php index 3d5aa0c19..f59ab151c 100644 --- a/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php +++ b/tests/Doctrine/Tests/DbalTypes/CustomIdObjectType.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\DbalTypes; diff --git a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php index 24ecb59ef..6f98e3c50 100644 --- a/tests/Doctrine/Tests/Mocks/EntityManagerMock.php +++ b/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\Mocks; diff --git a/tests/Doctrine/Tests/Mocks/StatementArrayMock.php b/tests/Doctrine/Tests/Mocks/StatementArrayMock.php index 4054b9a9e..9ef37da46 100644 --- a/tests/Doctrine/Tests/Mocks/StatementArrayMock.php +++ b/tests/Doctrine/Tests/Mocks/StatementArrayMock.php @@ -1,10 +1,4 @@ _result); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Mocks/TaskMock.php b/tests/Doctrine/Tests/Mocks/TaskMock.php index 22676f67a..f097abc03 100644 --- a/tests/Doctrine/Tests/Mocks/TaskMock.php +++ b/tests/Doctrine/Tests/Mocks/TaskMock.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\Mocks; diff --git a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php index b65ae8557..9707d8cc2 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsGroup.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsGroup.php @@ -1,8 +1,4 @@ . - */ namespace Doctrine\Tests\Models\CustomType; diff --git a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php index 3045c647b..0460676fc 100644 --- a/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php +++ b/tests/Doctrine/Tests/Models/CustomType/CustomIdObjectTypeParent.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\Models\CustomType; diff --git a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php index 58afe8128..4f94dad13 100644 --- a/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php +++ b/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC1476; /** @@ -73,4 +55,4 @@ class DDC1476EntityWithDefaultFieldType $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php index 3146969ed..ecbfd5277 100644 --- a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php +++ b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityA.php @@ -1,12 +1,13 @@ - */ + namespace Doctrine\Tests\Models\DDC3711; use Doctrine\Common\Collections\ArrayCollection; +/** + * @author Marc Pantel + */ class DDC3711EntityA { /** @@ -75,4 +76,4 @@ class DDC3711EntityA return $this; } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php index ff589e092..48c4fd860 100644 --- a/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php +++ b/tests/Doctrine/Tests/Models/DDC3711/DDC3711EntityB.php @@ -1,12 +1,13 @@ - */ + namespace Doctrine\Tests\Models\DDC3711; use Doctrine\Common\Collections\ArrayCollection; +/** + * @author Marc Pantel + */ class DDC3711EntityB { /** @@ -72,4 +73,4 @@ class DDC3711EntityB $this->entityA[] = $entityA; } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php index eaf9006c7..783faef61 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC753; use Doctrine\ORM\EntityRepository; @@ -33,4 +15,4 @@ class DDC753CustomRepository extends EntityRepository return true; } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php index 5be9aa522..1a3e071fa 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC753; use Doctrine\ORM\EntityRepository; @@ -32,4 +14,4 @@ class DDC753DefaultRepository extends EntityRepository return true; } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php index 7b92e66ac..7a9ce8d83 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC753; /** @@ -36,4 +18,4 @@ class DDC753EntityWithCustomRepository /** @column(type="string") */ protected $name; -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php index 8ca2a2c94..6f448755f 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC753; /** @@ -36,4 +18,4 @@ class DDC753EntityWithDefaultCustomRepository /** @column(type="string") */ protected $name; -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php index d12660cf4..e480e912c 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC753; /** @@ -36,4 +18,4 @@ class DDC753EntityWithInvalidRepository /** @column(type="string") */ protected $name; -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php b/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php index decc07078..4e8c7bad7 100644 --- a/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php +++ b/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php @@ -1,26 +1,8 @@ . - */ - namespace Doctrine\Tests\Models\DDC753; class DDC753InvalidRepository { -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php index a9f548ffc..00e5da017 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC869; /** @@ -37,4 +19,4 @@ class DDC869ChequePayment extends DDC869Payment )); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php index cd637b3c0..4c1f8c306 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC869; /** @@ -37,4 +19,4 @@ class DDC869CreditCardPayment extends DDC869Payment )); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php index 01e7fbefd..ea052d12e 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC869; /** @@ -54,4 +36,4 @@ class DDC869Payment $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php b/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php index f950df0e0..3c11b154b 100644 --- a/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php +++ b/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC869; use Doctrine\ORM\EntityRepository; @@ -34,4 +16,4 @@ class DDC869PaymentRepository extends EntityRepository { return true; } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php index 7520568b0..8bba1274c 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Class.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC889; class DDC889Class extends DDC889SuperClass @@ -43,4 +25,4 @@ class DDC889Class extends DDC889SuperClass $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php index 59cd21a61..43884435f 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889Entity.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC889; /** @@ -30,4 +12,4 @@ class DDC889Entity extends DDC889SuperClass { } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php index 7cffe488b..42fd93386 100644 --- a/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php +++ b/tests/Doctrine/Tests/Models/DDC889/DDC889SuperClass.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\Models\DDC889; /** @@ -38,4 +20,4 @@ class DDC889SuperClass $metadata->isMappedSuperclass = true; $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php index d2ba439a0..166f86cb0 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\Models\DirectoryTree; diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php index f0db778b8..cb3729974 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\Models\DirectoryTree; diff --git a/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/tests/Doctrine/Tests/Models/DirectoryTree/File.php index 428daad8b..2e18a06cf 100644 --- a/tests/Doctrine/Tests/Models/DirectoryTree/File.php +++ b/tests/Doctrine/Tests/Models/DirectoryTree/File.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\Models\DirectoryTree; diff --git a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php index 2e7abf76c..ea6fdfaff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/CustomIdObjectTypeTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Functional; diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php index 45f552d59..76e269a20 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Functional; diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php index 28e89c360..ffe64fcff 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeSharedEntitiesTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Functional; diff --git a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php index e38574b7c..a730546d6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php @@ -1,20 +1,4 @@ - */ namespace Doctrine\Tests\ORM\Functional\Ticket; @@ -9,6 +6,9 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\Tests\ORM\Mapping\YamlMappingDriverTest; +/** + * @author Marc Pantel + */ class DDC3711Test extends YamlMappingDriverTest { public function testCompositeKeyForJoinTableInManyToManyCreation() @@ -27,4 +27,4 @@ class DDC3711Test extends YamlMappingDriverTest $this->assertEquals(array('link_b_id1' => "id1", 'link_b_id2' => "id2"), $entityA->associationMappings['entityB']['relationToTargetKeyColumns']); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 996c40598..da4f4abf5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Mapping; diff --git a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php index 3d759aade..67a0ebce0 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/FieldBuilderTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Mapping; diff --git a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php index 8de8fa940..c4f967589 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php +++ b/tests/Doctrine/Tests/ORM/Mapping/NamingStrategy/JoinColumnClassNamingStrategy.php @@ -1,23 +1,5 @@ . - */ - namespace Doctrine\Tests\ORM\Mapping\NamingStrategy; use Doctrine\ORM\Mapping\DefaultNamingStrategy; diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php index e116c6763..ac8f1d695 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php @@ -1,21 +1,4 @@ . -*/ namespace Doctrine\Tests\ORM\Mapping\Symfony; use Doctrine\Common\Persistence\Mapping\MappingException; diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php index 5908b674a..f32d9f2ad 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php @@ -1,21 +1,4 @@ . -*/ namespace Doctrine\Tests\ORM\Mapping\Symfony; diff --git a/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php index c5d8d1cd1..5b7f38ead 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php @@ -1,21 +1,4 @@ . -*/ namespace Doctrine\Tests\ORM\Mapping\Symfony; diff --git a/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php b/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php index ffe621eef..bc98c23f6 100644 --- a/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php +++ b/tests/Doctrine/Tests/ORM/Performance/ProxyPerformanceTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Performance; diff --git a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php index 18145070f..5d4e992f7 100644 --- a/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php +++ b/tests/Doctrine/Tests/ORM/Persisters/JoinedSubclassPersisterTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Persisters; diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php index 284cc1adc..e47c48215 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersJoinTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Query; diff --git a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php index af7d2bf55..4114c4f8b 100644 --- a/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php +++ b/tests/Doctrine/Tests/ORM/Query/CustomTreeWalkersTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Functional; @@ -238,4 +221,4 @@ class CustomTreeWalkerJoin extends Query\TreeWalkerAdapter ) ); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index 0bae052d8..8218339df 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Query; use Doctrine\Tests\OrmTestCase; diff --git a/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/tests/Doctrine/Tests/ORM/Query/ExprTest.php index 01e82ce65..61def1770 100644 --- a/tests/Doctrine/Tests/ORM/Query/ExprTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Query; diff --git a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php index d10c78c9c..640a91314 100644 --- a/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php +++ b/tests/Doctrine/Tests/ORM/Query/ParameterTypeInfererTest.php @@ -1,21 +1,5 @@ . - */ + namespace Doctrine\Tests\ORM\Query; use Doctrine\ORM\Query\ParameterTypeInferer; diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 2b9fc2304..b8d688261 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Query; diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index 5dae79b3d..4110b54e6 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Query; diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 7b1e38c30..acf4d08e6 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\ORM; diff --git a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php index b0a07270d..6c62ca352 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Tools; diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php index d712730ff..5edd47b03 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Tools\Export; diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php index 9fa20941c..a432ec451 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Tools\Export; diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/PhpClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/PhpClassMetadataExporterTest.php index 2ad37588f..6ca3cf948 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/PhpClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/PhpClassMetadataExporterTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Tools\Export; diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php index 5bec99cfe..3eca15f9c 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Tools\Export; use Doctrine\ORM\Mapping\ClassMetadataInfo; diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php index 85c6e1c5e..a47c396d2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php @@ -1,23 +1,4 @@ . - */ namespace Doctrine\Tests\ORM\Tools\Export; From dc07fc609ea23e40f82432440bc1a56f896a420e Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Wed, 26 Oct 2016 13:27:18 -0300 Subject: [PATCH 142/144] Revert "add license checker to the build" This reverts commit ca1a9473d3348cd0ed727ba6f2a5bfebe0ab4915. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 31516a116..5a9fb2dcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,6 @@ before_script: script: - ENABLE_SECOND_LEVEL_CACHE=0 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml $PHPUNIT_FLAGS - ENABLE_SECOND_LEVEL_CACHE=1 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml --exclude-group performance,non-cacheable,locking_functional - - ./vendor/bin/docheader check lib/ after_script: - if [[ $TRAVIS_PHP_VERSION = '7.0' && $DB = 'sqlite' ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi From 5c6ecdcf1b7a13e1ee4f12774b8871cce0a2e9ed Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Wed, 26 Oct 2016 13:27:29 -0300 Subject: [PATCH 143/144] Revert "add license template file" This reverts commit e4050edb4ecc76de625547343ed4431fa64f230c. --- .docheader | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .docheader diff --git a/.docheader b/.docheader deleted file mode 100644 index 23753e7fe..000000000 --- a/.docheader +++ /dev/null @@ -1,17 +0,0 @@ -/* - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the MIT license. For more information, see - * . - */ From 83da3d4b04e14e012568043f62ce6fd0faab8b2e Mon Sep 17 00:00:00 2001 From: Jefersson Nathan Date: Wed, 26 Oct 2016 13:27:38 -0300 Subject: [PATCH 144/144] Revert "composer require --dev malukenho/docheader" This reverts commit 81fefb40dbd6b7b6f913501616075ecc779a1742. --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 533c19299..f5b3b08f7 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,7 @@ }, "require-dev": { "symfony/yaml": "~2.3|~3.0", - "phpunit/phpunit": "^5.4", - "malukenho/docheader": "^0.1.4" + "phpunit/phpunit": "^5.4" }, "suggest": { "symfony/yaml": "If you want to use YAML Metadata Mapping Driver"