From bf46316347f1c60423d35ed82c7889b1136e1421 Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Mon, 23 Jul 2012 17:09:03 +0200 Subject: [PATCH] Vendor update && Started using DoctrineMigrations --- app/AppKernel.php | 3 + .../Version20120723170354.php | 24 + .../Version20120723170752.php | 26 + composer.json | 2 +- vendor/composer/autoload_namespaces.php | 1 + .../common/doctrine-common-ac6c39b/.gitignore | 4 + .../doctrine-common-ac6c39b/.gitmodules | 3 + .../doctrine-common-ac6c39b/.travis.yml | 5 + .../common/doctrine-common-ac6c39b/LICENSE | 504 +++++ .../common/doctrine-common-ac6c39b/README.md | 12 + .../doctrine-common-ac6c39b/UPGRADE_TO_2_1 | 39 + .../doctrine-common-ac6c39b/UPGRADE_TO_2_2 | 61 + .../doctrine-common-ac6c39b/build.properties | 6 + .../common/doctrine-common-ac6c39b/build.xml | 59 + .../doctrine-common-ac6c39b/composer.json | 21 + .../Common/Annotations/Annotation.php | 75 + .../Annotations/Annotation/Attribute.php | 47 + .../Annotations/Annotation/Attributes.php | 37 + .../Annotation/IgnoreAnnotation.php | 44 + .../Annotations/Annotation/Required.php | 33 + .../Common/Annotations/Annotation/Target.php | 105 + .../Annotations/AnnotationException.php | 111 + .../Common/Annotations/AnnotationReader.php | 301 +++ .../Common/Annotations/AnnotationRegistry.php | 129 ++ .../Common/Annotations/CachedReader.php | 179 ++ .../Doctrine/Common/Annotations/DocLexer.php | 140 ++ .../Doctrine/Common/Annotations/DocParser.php | 891 ++++++++ .../Common/Annotations/FileCacheReader.php | 209 ++ .../Common/Annotations/IndexedReader.php | 94 + .../Doctrine/Common/Annotations/PhpParser.php | 203 ++ .../Doctrine/Common/Annotations/Reader.php | 35 + .../Annotations/SimpleAnnotationReader.php | 152 ++ .../lib/Doctrine/Common/Cache/ApcCache.php | 97 + .../lib/Doctrine/Common/Cache/ArrayCache.php | 96 + .../lib/Doctrine/Common/Cache/Cache.php | 102 + .../Doctrine/Common/Cache/CacheProvider.php | 188 ++ .../Doctrine/Common/Cache/MemcacheCache.php | 121 ++ .../Doctrine/Common/Cache/MemcachedCache.php | 124 ++ .../Doctrine/Common/Cache/WinCacheCache.php | 92 + .../lib/Doctrine/Common/Cache/XcacheCache.php | 110 + .../Doctrine/Common/Cache/ZendDataCache.php | 84 + .../lib/Doctrine/Common/ClassLoader.php | 262 +++ .../Common/Collections/ArrayCollection.php | 447 ++++ .../Common/Collections/Collection.php | 243 +++ .../lib/Doctrine/Common/CommonException.php | 28 + .../lib/Doctrine/Common/Comparable.php | 47 + .../lib/Doctrine/Common/EventArgs.php | 69 + .../lib/Doctrine/Common/EventManager.php | 136 ++ .../lib/Doctrine/Common/EventSubscriber.php | 45 + .../lib/Doctrine/Common/Lexer.php | 266 +++ .../Doctrine/Common/NotifyPropertyChanged.php | 45 + .../Persistence/AbstractManagerRegistry.php | 218 ++ .../Common/Persistence/ConnectionRegistry.php | 63 + .../Persistence/Event/LifecycleEventArgs.php | 77 + .../Event/LoadClassMetadataEventArgs.php | 76 + .../Persistence/Event/ManagerEventArgs.php | 59 + .../Persistence/Event/OnClearEventArgs.php | 84 + .../Persistence/Event/PreUpdateEventArgs.php | 129 ++ .../Common/Persistence/ManagerRegistry.php | 112 + .../Mapping/AbstractClassMetadataFactory.php | 359 ++++ .../Persistence/Mapping/ClassMetadata.php | 165 ++ .../Mapping/ClassMetadataFactory.php | 74 + .../Mapping/Driver/AnnotationDriver.php | 214 ++ .../Mapping/Driver/DefaultFileLocator.php | 169 ++ .../Persistence/Mapping/Driver/FileDriver.php | 178 ++ .../Mapping/Driver/FileLocator.php | 69 + .../Mapping/Driver/MappingDriver.php | 56 + .../Mapping/Driver/MappingDriverChain.php | 125 ++ .../Persistence/Mapping/Driver/PHPDriver.php | 70 + .../Mapping/Driver/StaticPHPDriver.php | 131 ++ .../Mapping/Driver/SymfonyFileLocator.php | 198 ++ .../Persistence/Mapping/MappingException.php | 57 + .../Persistence/Mapping/ReflectionService.php | 80 + .../Mapping/RuntimeReflectionService.php | 102 + .../Mapping/StaticReflectionService.php | 107 + .../Common/Persistence/ObjectManager.php | 143 ++ .../Common/Persistence/ObjectManagerAware.php | 49 + .../Common/Persistence/ObjectRepository.php | 78 + .../Common/Persistence/PersistentObject.php | 233 ++ .../lib/Doctrine/Common/Persistence/Proxy.php | 60 + .../Common/PropertyChangedListener.php | 48 + .../lib/Doctrine/Common/Util/ClassUtils.php | 103 + .../lib/Doctrine/Common/Util/Debug.php | 123 ++ .../lib/Doctrine/Common/Util/Inflector.php | 72 + .../lib/Doctrine/Common/Version.php | 55 + .../doctrine-common-ac6c39b/phpunit.xml.dist | 31 + .../doctrine-common-ac6c39b/tests/.gitignore | 3 + .../Common/Annotations/AbstractReaderTest.php | 538 +++++ .../Annotations/AnnotationReaderTest.php | 13 + .../Common/Annotations/CachedReaderTest.php | 56 + .../Tests/Common/Annotations/DocLexerTest.php | 27 + .../Common/Annotations/DocParserTest.php | 1118 ++++++++++ .../Annotations/FileCacheReaderTest.php | 40 + .../Annotation/AnnotWithDefaultValue.php | 10 + .../Fixtures/Annotation/Autoload.php | 10 + .../Annotations/Fixtures/Annotation/Route.php | 11 + .../Fixtures/Annotation/Secure.php | 18 + .../Fixtures/Annotation/Template.php | 14 + .../Fixtures/Annotation/Version.php | 11 + .../Fixtures/AnnotationTargetAll.php | 14 + .../Fixtures/AnnotationTargetAnnotation.php | 14 + .../Fixtures/AnnotationTargetClass.php | 15 + .../Fixtures/AnnotationTargetMethod.php | 15 + .../AnnotationTargetPropertyMethod.php | 14 + .../Fixtures/AnnotationWithAttributes.php | 119 ++ .../AnnotationWithRequiredAttributes.php | 50 + ...ithRequiredAttributesWithoutContructor.php | 24 + .../AnnotationWithTargetSyntaxError.php | 11 + .../Fixtures/AnnotationWithVarType.php | 62 + .../Annotations/Fixtures/ClassDDC1660.php | 30 + ...assWithAnnotationWithTargetSyntaxError.php | 21 + .../ClassWithAnnotationWithVarType.php | 31 + .../ClassWithFullyQualifiedUseStatements.php | 11 + ...lassWithInvalidAnnotationTargetAtClass.php | 17 + ...assWithInvalidAnnotationTargetAtMethod.php | 20 + ...sWithInvalidAnnotationTargetAtProperty.php | 24 + .../ClassWithValidAnnotationTarget.php | 41 + .../Annotations/Fixtures/Controller.php | 300 +++ ...erentNamespacesPerFileWithClassAsFirst.php | 15 + ...ferentNamespacesPerFileWithClassAsLast.php | 15 + ...EqualNamespacesPerFileWithClassAsFirst.php | 13 + .../EqualNamespacesPerFileWithClassAsLast.php | 12 + ...lobalNamespacesPerFileWithClassAsFirst.php | 12 + ...GlobalNamespacesPerFileWithClassAsLast.php | 12 + .../InvalidAnnotationUsageButIgnoredClass.php | 14 + .../Fixtures/InvalidAnnotationUsageClass.php | 10 + .../Fixtures/MultipleClassesInFile.php | 9 + .../MultipleImportsInUseStatement.php | 10 + .../NamespaceAndClassCommentedOut.php | 20 + .../NamespaceWithClosureDeclaration.php | 15 + .../Fixtures/NamespacedSingleClassLOC1000.php | 1009 +++++++++ .../Annotations/Fixtures/NoAnnotation.php | 5 + .../Fixtures/NonNamespacedClass.php | 10 + .../Fixtures/SingleClassLOC1000.php | 1006 +++++++++ .../Annotations/Fixtures/TestInterface.php | 13 + .../Common/Annotations/PerformanceTest.php | 194 ++ .../Common/Annotations/PhpParserTest.php | 179 ++ .../SimpleAnnotationReaderTest.php | 97 + .../Common/Annotations/Ticket/DCOM55Test.php | 65 + .../Annotations/Ticket/DCOM58Entity.php | 8 + .../Common/Annotations/Ticket/DCOM58Test.php | 112 + .../Common/Annotations/TopLevelAnnotation.php | 8 + .../Tests/Common/Cache/ApcCacheTest.php | 20 + .../Tests/Common/Cache/ArrayCacheTest.php | 13 + .../Doctrine/Tests/Common/Cache/CacheTest.php | 87 + .../Tests/Common/Cache/MemcacheCacheTest.php | 38 + .../Tests/Common/Cache/MemcachedCacheTest.php | 40 + .../Tests/Common/Cache/WinCacheCacheTest.php | 20 + .../Tests/Common/Cache/XcacheCacheTest.php | 20 + .../Tests/Common/Cache/ZendDataCacheTest.php | 20 + .../Doctrine/Tests/Common/ClassLoaderTest.php | 45 + .../Common/ClassLoaderTest/ClassA.class.php | 6 + .../Common/ClassLoaderTest/ClassB.class.php | 6 + .../Common/ClassLoaderTest/ClassC.class.php | 6 + .../Tests/Common/ClassLoaderTest/ClassD.php | 5 + .../Common/Collections/CollectionTest.php | 195 ++ .../Tests/Common/DoctrineExceptionTest.php | 0 .../Tests/Common/EventManagerTest.php | 88 + .../Persistence/Mapping/ChainDriverTest.php | 94 + .../Mapping/ClassMetadataFactoryTest.php | 134 ++ .../Mapping/DefaultFileLocatorTest.php | 90 + .../Persistence/Mapping/FileDriverTest.php | 142 ++ .../Persistence/Mapping/PHPDriverTest.php | 18 + .../Mapping/RuntimeReflectionServiceTest.php | 70 + .../Mapping/StaticPHPDriverTest.php | 35 + .../Mapping/StaticReflectionServiceTest.php | 70 + .../Mapping/SymfonyFileLocatorTest.php | 88 + .../Persistence/Mapping/_files/TestEntity.php | 3 + .../Persistence/Mapping/_files/global.yml | 1 + .../Persistence/Mapping/_files/stdClass.yml | 1 + .../Persistence/PersistentObjectTest.php | 247 +++ .../Tests/Common/Util/ClassUtilsTest.php | 100 + .../Doctrine/Tests/Common/Util/DebugTest.php | 27 + .../tests/Doctrine/Tests/DoctrineTestCase.php | 10 + .../tests/Doctrine/Tests/TestInit.php | 31 + .../tests/NativePhpunitTask.php | 246 +++ .../tests/README.markdown | 27 + vendor/doctrine/dbal/.gitignore | 6 + vendor/doctrine/dbal/.gitmodules | 9 + vendor/doctrine/dbal/bin/doctrine-dbal | 4 + vendor/doctrine/dbal/bin/doctrine-dbal.php | 43 + vendor/doctrine/dbal/bin/doctrine.php | 42 + vendor/doctrine/dbal/build.properties | 10 + vendor/doctrine/dbal/build.xml | 91 + vendor/doctrine/dbal/tests/.gitignore | 3 + .../Doctrine/Tests/DBAL/ConnectionTest.php | 148 ++ .../DBAL/Driver/OCI8/OCI8StatementTest.php | 82 + .../Doctrine/Tests/DBAL/DriverManagerTest.php | 117 ++ .../DBAL/Events/MysqlSessionInitTest.php | 33 + .../DBAL/Events/OracleSessionInitTest.php | 33 + .../Tests/DBAL/Events/SQLSessionInitTest.php | 35 + .../Tests/DBAL/Functional/BlobTest.php | 83 + .../Tests/DBAL/Functional/ConnectionTest.php | 219 ++ .../Tests/DBAL/Functional/DataAccessTest.php | 477 +++++ .../Tests/DBAL/Functional/LoggingTest.php | 52 + .../Functional/MasterSlaveConnectionTest.php | 82 + .../DBAL/Functional/ModifyLimitQueryTest.php | 114 + .../DBAL/Functional/NamedParametersTest.php | 166 ++ .../Tests/DBAL/Functional/PortabilityTest.php | 97 + .../Tests/DBAL/Functional/ResultCacheTest.php | 199 ++ .../Schema/Db2SchemaManagerTest.php | 12 + .../Schema/MySqlSchemaManagerTest.php | 50 + .../Schema/OracleSchemaManagerTest.php | 39 + .../Schema/PostgreSqlSchemaManagerTest.php | 228 ++ .../Schema/SQLServerSchemaManagerTest.php | 37 + .../SchemaManagerFunctionalTestCase.php | 642 ++++++ .../Schema/SqliteSchemaManagerTest.php | 46 + .../DBAL/Functional/TemporaryTableTest.php | 102 + .../DBAL/Functional/Ticket/DBAL168Test.php | 27 + .../DBAL/Functional/Ticket/DBAL202Test.php | 48 + .../DBAL/Functional/TypeConversionTest.php | 101 + .../Tests/DBAL/Functional/WriteTest.php | 137 ++ .../Tests/DBAL/Mocks/MockPlatform.php | 49 + .../Platforms/AbstractPlatformTestCase.php | 388 ++++ .../DBAL/Platforms/MySqlPlatformTest.php | 229 ++ .../DBAL/Platforms/OraclePlatformTest.php | 227 ++ .../DBAL/Platforms/PostgreSqlPlatformTest.php | 230 ++ .../ReservedKeywordsValidatorTest.php | 47 + .../DBAL/Platforms/SQLServerPlatformTest.php | 191 ++ .../DBAL/Platforms/SqlitePlatformTest.php | 134 ++ .../Expression/CompositeExpressionTest.php | 82 + .../Expression/ExpressionBuilderTest.php | 201 ++ .../Tests/DBAL/Query/QueryBuilderTest.php | 572 +++++ .../Tests/DBAL/SQLParserUtilsTest.php | 214 ++ .../Doctrine/Tests/DBAL/Schema/ColumnTest.php | 114 + .../Tests/DBAL/Schema/ComparatorTest.php | 787 +++++++ .../Doctrine/Tests/DBAL/Schema/IndexTest.php | 99 + .../DBAL/Schema/MySqlSchemaManagerTest.php | 76 + .../DBAL/Schema/Platforms/MySQLSchemaTest.php | 67 + .../Tests/DBAL/Schema/SchemaDiffTest.php | 109 + .../Doctrine/Tests/DBAL/Schema/SchemaTest.php | 224 ++ .../Doctrine/Tests/DBAL/Schema/TableTest.php | 500 +++++ .../Visitor/RemoveNamespacedAssetsTest.php | 77 + .../Schema/Visitor/SchemaSqlCollectorTest.php | 80 + .../Doctrine/Tests/DBAL/Types/ArrayTest.php | 61 + .../Doctrine/Tests/DBAL/Types/BlobTest.php | 26 + .../Doctrine/Tests/DBAL/Types/BooleanTest.php | 36 + .../Doctrine/Tests/DBAL/Types/DateTest.php | 75 + .../Tests/DBAL/Types/DateTimeTest.php | 50 + .../Tests/DBAL/Types/DateTimeTzTest.php | 50 + .../Doctrine/Tests/DBAL/Types/DecimalTest.php | 31 + .../Doctrine/Tests/DBAL/Types/FloatTest.php | 39 + .../Doctrine/Tests/DBAL/Types/IntegerTest.php | 32 + .../Doctrine/Tests/DBAL/Types/ObjectTest.php | 56 + .../Tests/DBAL/Types/SmallIntTest.php | 32 + .../Doctrine/Tests/DBAL/Types/StringTest.php | 49 + .../Doctrine/Tests/DBAL/Types/TimeTest.php | 47 + .../Tests/DBAL/Types/VarDateTimeTest.php | 62 + .../tests/Doctrine/Tests/DBAL/UtilTest.php | 78 + .../Doctrine/Tests/DbalFunctionalTestCase.php | 77 + .../tests/Doctrine/Tests/DbalTestCase.php | 10 + .../tests/Doctrine/Tests/DoctrineTestCase.php | 10 + .../Doctrine/Tests/Mocks/ConnectionMock.php | 92 + .../Tests/Mocks/DatabasePlatformMock.php | 98 + .../Tests/Mocks/DriverConnectionMock.php | 17 + .../tests/Doctrine/Tests/Mocks/DriverMock.php | 72 + .../Tests/Mocks/HydratorMockStatement.php | 101 + .../Tests/Mocks/SchemaManagerMock.php | 13 + .../tests/Doctrine/Tests/Mocks/TaskMock.php | 81 + .../dbal/tests/Doctrine/Tests/TestInit.php | 22 + .../dbal/tests/Doctrine/Tests/TestUtil.php | 131 ++ vendor/doctrine/dbal/tests/README.markdown | 25 + .../dbal/tests/travis/mysql.travis.xml | 32 + .../dbal/tests/travis/pgsql.travis.xml | 29 + .../dbal/tests/travis/sqlite.travis.xml | 14 + .../Doctrine/Bundle/DoctrineBundle/.gitignore | 4 + .../Doctrine/Bundle/MigrationsBundle | 1 + vendor/doctrine/orm/.gitignore | 11 + vendor/doctrine/orm/.gitmodules | 15 + vendor/doctrine/orm/UPGRADE_TO_2_0 | 240 +++ vendor/doctrine/orm/UPGRADE_TO_2_1 | 25 + vendor/doctrine/orm/UPGRADE_TO_2_2 | 81 + vendor/doctrine/orm/UPGRADE_TO_ALPHA3 | 35 + vendor/doctrine/orm/UPGRADE_TO_ALPHA4 | 36 + vendor/doctrine/orm/bin/doctrine | 4 + vendor/doctrine/orm/bin/doctrine.bat | 9 + vendor/doctrine/orm/bin/doctrine.php | 50 + vendor/doctrine/orm/build.properties | 11 + vendor/doctrine/orm/build.properties.dev | 16 + vendor/doctrine/orm/build.xml | 114 + vendor/doctrine/orm/tests/.gitignore | 3 + .../Doctrine/Tests/DbalFunctionalTestCase.php | 32 + .../orm/tests/Doctrine/Tests/DbalTestCase.php | 10 + .../DbalTypes/NegativeToPositiveType.php | 34 + .../Tests/DbalTypes/UpperCaseStringType.php | 29 + .../tests/Doctrine/Tests/DoctrineTestCase.php | 10 + .../Tests/Mocks/ClassMetadataMock.php | 14 + .../Doctrine/Tests/Mocks/ConnectionMock.php | 106 + .../Tests/Mocks/DatabasePlatformMock.php | 97 + .../Tests/Mocks/DriverConnectionMock.php | 17 + .../tests/Doctrine/Tests/Mocks/DriverMock.php | 72 + .../Tests/Mocks/EntityManagerMock.php | 106 + .../Tests/Mocks/EntityPersisterMock.php | 100 + .../Tests/Mocks/HydratorMockStatement.php | 111 + .../Tests/Mocks/IdentityIdGeneratorMock.php | 12 + .../Tests/Mocks/MetadataDriverMock.php | 21 + .../Doctrine/Tests/Mocks/MockTreeWalker.php | 17 + .../Tests/Mocks/SchemaManagerMock.php | 13 + .../Doctrine/Tests/Mocks/SequenceMock.php | 52 + .../tests/Doctrine/Tests/Mocks/TaskMock.php | 81 + .../Doctrine/Tests/Mocks/UnitOfWorkMock.php | 58 + .../Doctrine/Tests/Models/CMS/CmsAddress.php | 72 + .../Doctrine/Tests/Models/CMS/CmsArticle.php | 48 + .../Doctrine/Tests/Models/CMS/CmsComment.php | 38 + .../Doctrine/Tests/Models/CMS/CmsEmail.php | 48 + .../Doctrine/Tests/Models/CMS/CmsEmployee.php | 44 + .../Doctrine/Tests/Models/CMS/CmsGroup.php | 49 + .../Tests/Models/CMS/CmsPhonenumber.php | 28 + .../Doctrine/Tests/Models/CMS/CmsUser.php | 139 ++ .../Tests/Models/Company/CompanyAuction.php | 17 + .../Tests/Models/Company/CompanyCar.php | 33 + .../Tests/Models/Company/CompanyContract.php | 89 + .../Tests/Models/Company/CompanyEmployee.php | 59 + .../Tests/Models/Company/CompanyEvent.php | 36 + .../Models/Company/CompanyFixContract.php | 30 + .../Models/Company/CompanyFlexContract.php | 68 + .../Company/CompanyFlexUltraContract.php | 30 + .../Tests/Models/Company/CompanyManager.php | 42 + .../Models/Company/CompanyOrganization.php | 44 + .../Tests/Models/Company/CompanyPerson.php | 82 + .../Tests/Models/Company/CompanyRaffle.php | 17 + .../Models/CustomType/CustomTypeChild.php | 21 + .../Models/CustomType/CustomTypeParent.php | 68 + .../Models/CustomType/CustomTypeUpperCase.php | 21 + .../Models/DDC117/DDC117ApproveChanges.php | 65 + .../Tests/Models/DDC117/DDC117Article.php | 87 + .../Models/DDC117/DDC117ArticleDetails.php | 39 + .../Tests/Models/DDC117/DDC117Editor.php | 54 + .../Tests/Models/DDC117/DDC117Link.php | 31 + .../Tests/Models/DDC117/DDC117Reference.php | 64 + .../Tests/Models/DDC117/DDC117Translation.php | 65 + .../DDC1476EntityWithDefaultFieldType.php | 76 + .../Models/DDC753/DDC753CustomRepository.php | 36 + .../Models/DDC753/DDC753DefaultRepository.php | 35 + .../DDC753EntityWithCustomRepository.php | 39 + ...DC753EntityWithDefaultCustomRepository.php | 39 + .../DDC753EntityWithInvalidRepository.php | 39 + .../Models/DDC753/DDC753InvalidRepository.php | 28 + .../Models/DDC869/DDC869ChequePayment.php | 40 + .../Models/DDC869/DDC869CreditCardPayment.php | 40 + .../Tests/Models/DDC869/DDC869Payment.php | 57 + .../Models/DDC869/DDC869PaymentRepository.php | 37 + .../DirectoryTree/AbstractContentItem.php | 64 + .../Tests/Models/DirectoryTree/Directory.php | 41 + .../Tests/Models/DirectoryTree/File.php | 46 + .../Tests/Models/ECommerce/ECommerceCart.php | 91 + .../Models/ECommerce/ECommerceCategory.php | 126 ++ .../Models/ECommerce/ECommerceCustomer.php | 94 + .../Models/ECommerce/ECommerceFeature.php | 59 + .../Models/ECommerce/ECommerceProduct.php | 178 ++ .../Models/ECommerce/ECommerceShipping.php | 40 + .../Tests/Models/Forum/ForumAdministrator.php | 14 + .../Tests/Models/Forum/ForumAvatar.php | 17 + .../Tests/Models/Forum/ForumBoard.php | 28 + .../Tests/Models/Forum/ForumCategory.php | 32 + .../Tests/Models/Forum/ForumEntry.php | 26 + .../Doctrine/Tests/Models/Forum/ForumUser.php | 41 + .../Tests/Models/Generic/BooleanModel.php | 20 + .../Tests/Models/Generic/DateTimeModel.php | 28 + .../Tests/Models/Generic/DecimalModel.php | 25 + .../Models/Generic/SerializationModel.php | 25 + .../Models/Global/GlobalNamespaceModel.php | 68 + .../Tests/Models/Legacy/LegacyArticle.php | 33 + .../Tests/Models/Legacy/LegacyCar.php | 41 + .../Tests/Models/Legacy/LegacyUser.php | 80 + .../Models/Legacy/LegacyUserReference.php | 65 + .../Tests/Models/Navigation/NavCountry.php | 39 + .../Tests/Models/Navigation/NavPhotos.php | 48 + .../Models/Navigation/NavPointOfInterest.php | 56 + .../Tests/Models/Navigation/NavTour.php | 61 + .../Tests/Models/Routing/RoutingLeg.php | 37 + .../Tests/Models/Routing/RoutingLocation.php | 25 + .../Tests/Models/Routing/RoutingRoute.php | 39 + .../Models/Routing/RoutingRouteBooking.php | 32 + .../Tests/Models/StockExchange/Bond.php | 48 + .../Tests/Models/StockExchange/Market.php | 56 + .../Tests/Models/StockExchange/Stock.php | 49 + .../Tests/ORM/CommitOrderCalculatorTest.php | 56 + .../Tests/ORM/Criteria/DqlGenerationTest.php | 252 +++ .../Tests/ORM/Entity/ConstructorTest.php | 28 + .../Doctrine/Tests/ORM/EntityManagerTest.php | 158 ++ .../AbstractManyToManyAssociationTestCase.php | 42 + .../Functional/AdvancedAssociationTest.php | 598 ++++++ .../ORM/Functional/AdvancedDqlQueryTest.php | 181 ++ .../ORM/Functional/BasicFunctionalTest.php | 1232 +++++++++++ .../Functional/ClassTableInheritanceTest.php | 470 +++++ .../Functional/ClassTableInheritanceTest2.php | 176 ++ .../Tests/ORM/Functional/ClearEventTest.php | 40 + .../Functional/CompositePrimaryKeyTest.php | 121 ++ .../ORM/Functional/CustomTreeWalkersTest.php | 157 ++ .../ORM/Functional/DatabaseDriverTest.php | 166 ++ .../ORM/Functional/DefaultValuesTest.php | 150 ++ .../ORM/Functional/DetachedEntityTest.php | 218 ++ .../ORM/Functional/EntityRepositoryTest.php | 505 +++++ .../Functional/ExtraLazyCollectionTest.php | 583 +++++ .../Tests/ORM/Functional/FlushEventTest.php | 94 + .../ORM/Functional/HydrationCacheTest.php | 86 + .../Tests/ORM/Functional/IdentityMapTest.php | 288 +++ .../ORM/Functional/IndexByAssociationTest.php | 105 + .../ORM/Functional/LifecycleCallbackTest.php | 311 +++ .../Functional/Locking/GearmanLockTest.php | 180 ++ .../Functional/Locking/LockAgentWorker.php | 112 + .../Tests/ORM/Functional/Locking/LockTest.php | 184 ++ .../ORM/Functional/Locking/OptimisticTest.php | 277 +++ .../ManyToManyBasicAssociationTest.php | 380 ++++ ...ManyToManyBidirectionalAssociationTest.php | 202 ++ .../ORM/Functional/ManyToManyEventTest.php | 76 + ...nyToManySelfReferentialAssociationTest.php | 124 ++ ...anyToManyUnidirectionalAssociationTest.php | 108 + .../ORM/Functional/MappedSuperclassTest.php | 47 + .../Tests/ORM/Functional/NativeQueryTest.php | 333 +++ .../Tests/ORM/Functional/NotifyPolicyTest.php | 173 ++ .../OneToManyBidirectionalAssociationTest.php | 171 ++ .../Functional/OneToManyOrphanRemovalTest.php | 75 + ...neToManySelfReferentialAssociationTest.php | 123 ++ ...OneToManyUnidirectionalAssociationTest.php | 86 + .../OneToOneBidirectionalAssociationTest.php | 151 ++ .../Functional/OneToOneEagerLoadingTest.php | 307 +++ .../Functional/OneToOneOrphanRemovalTest.php | 94 + ...OneToOneSelfReferentialAssociationTest.php | 165 ++ .../OneToOneUnidirectionalAssociationTest.php | 125 ++ .../ORM/Functional/OrderedCollectionTest.php | 113 + ...edJoinedTableInheritanceCollectionTest.php | 133 ++ .../Tests/ORM/Functional/PaginationTest.php | 105 + .../Functional/PersistentCollectionTest.php | 98 + .../ORM/Functional/PersistentObjectTest.php | 105 + .../ORM/Functional/PostFlushEventTest.php | 95 + .../PostgreSQLIdentityStrategyTest.php | 53 + .../Tests/ORM/Functional/QueryCacheTest.php | 151 ++ .../ORM/Functional/QueryDqlFunctionTest.php | 401 ++++ .../Tests/ORM/Functional/QueryTest.php | 658 ++++++ .../Tests/ORM/Functional/ReadOnlyTest.php | 94 + .../ORM/Functional/ReferenceProxyTest.php | 250 +++ .../Tests/ORM/Functional/ResultCacheTest.php | 254 +++ .../Tests/ORM/Functional/SQLFilterTest.php | 1047 +++++++++ .../SchemaTool/CompanySchemaTest.php | 68 + .../ORM/Functional/SchemaTool/DDC214Test.php | 90 + .../SchemaTool/MySqlSchemaToolTest.php | 92 + .../SchemaTool/PostgreSqlSchemaToolTest.php | 108 + .../ORM/Functional/SchemaValidatorTest.php | 50 + .../ORM/Functional/SequenceGeneratorTest.php | 53 + .../Functional/SingleTableInheritanceTest.php | 370 ++++ .../StandardEntityPersisterTest.php | 110 + .../ORM/Functional/Ticket/DDC1040Test.php | 81 + .../ORM/Functional/Ticket/DDC1041Test.php | 33 + .../ORM/Functional/Ticket/DDC1043Test.php | 36 + .../ORM/Functional/Ticket/DDC1050Test.php | 37 + .../ORM/Functional/Ticket/DDC1080Test.php | 317 +++ .../ORM/Functional/Ticket/DDC1113Test.php | 99 + .../ORM/Functional/Ticket/DDC1129Test.php | 46 + .../ORM/Functional/Ticket/DDC1151Test.php | 56 + .../ORM/Functional/Ticket/DDC1163Test.php | 215 ++ .../ORM/Functional/Ticket/DDC117Test.php | 464 ++++ .../ORM/Functional/Ticket/DDC1181Test.php | 101 + .../ORM/Functional/Ticket/DDC1193Test.php | 93 + .../ORM/Functional/Ticket/DDC1209Test.php | 125 ++ .../ORM/Functional/Ticket/DDC1225Test.php | 85 + .../ORM/Functional/Ticket/DDC1228Test.php | 136 ++ .../ORM/Functional/Ticket/DDC1238Test.php | 100 + .../ORM/Functional/Ticket/DDC1250Test.php | 96 + .../ORM/Functional/Ticket/DDC1276Test.php | 50 + .../ORM/Functional/Ticket/DDC1300Test.php | 108 + .../ORM/Functional/Ticket/DDC1301Test.php | 148 ++ .../ORM/Functional/Ticket/DDC1306Test.php | 54 + .../ORM/Functional/Ticket/DDC1335Test.php | 218 ++ .../ORM/Functional/Ticket/DDC1360Test.php | 37 + .../ORM/Functional/Ticket/DDC1383Test.php | 99 + .../ORM/Functional/Ticket/DDC1392Test.php | 127 ++ .../ORM/Functional/Ticket/DDC1400Test.php | 131 ++ .../ORM/Functional/Ticket/DDC1404Test.php | 129 ++ .../ORM/Functional/Ticket/DDC1430Test.php | 297 +++ .../ORM/Functional/Ticket/DDC1436Test.php | 89 + .../ORM/Functional/Ticket/DDC144Test.php | 64 + .../ORM/Functional/Ticket/DDC1452Test.php | 127 ++ .../ORM/Functional/Ticket/DDC1454Test.php | 69 + .../ORM/Functional/Ticket/DDC1458Test.php | 131 ++ .../ORM/Functional/Ticket/DDC1461Test.php | 86 + .../ORM/Functional/Ticket/DDC1509Test.php | 146 ++ .../ORM/Functional/Ticket/DDC1514Test.php | 113 + .../ORM/Functional/Ticket/DDC1515Test.php | 64 + .../ORM/Functional/Ticket/DDC1526Test.php | 67 + .../ORM/Functional/Ticket/DDC1545Test.php | 201 ++ .../ORM/Functional/Ticket/DDC1548Test.php | 81 + .../ORM/Functional/Ticket/DDC1594Test.php | 45 + .../ORM/Functional/Ticket/DDC1595Test.php | 111 + .../ORM/Functional/Ticket/DDC163Test.php | 65 + .../ORM/Functional/Ticket/DDC1643Test.php | 121 ++ .../ORM/Functional/Ticket/DDC1654Test.php | 103 + .../ORM/Functional/Ticket/DDC1655Test.php | 144 ++ .../ORM/Functional/Ticket/DDC168Test.php | 64 + .../ORM/Functional/Ticket/DDC1695Test.php | 158 ++ .../ORM/Functional/Ticket/DDC1778Test.php | 74 + .../ORM/Functional/Ticket/DDC192Test.php | 65 + .../ORM/Functional/Ticket/DDC199Test.php | 100 + .../ORM/Functional/Ticket/DDC211Test.php | 116 + .../ORM/Functional/Ticket/DDC237Test.php | 112 + .../ORM/Functional/Ticket/DDC258Test.php | 142 ++ .../ORM/Functional/Ticket/DDC279Test.php | 133 ++ .../ORM/Functional/Ticket/DDC309Test.php | 73 + .../ORM/Functional/Ticket/DDC331Test.php | 39 + .../ORM/Functional/Ticket/DDC345Test.php | 157 ++ .../ORM/Functional/Ticket/DDC353Test.php | 150 ++ .../ORM/Functional/Ticket/DDC371Test.php | 69 + .../ORM/Functional/Ticket/DDC381Test.php | 63 + .../ORM/Functional/Ticket/DDC422Test.php | 75 + .../ORM/Functional/Ticket/DDC425Test.php | 43 + .../ORM/Functional/Ticket/DDC440Test.php | 216 ++ .../ORM/Functional/Ticket/DDC444Test.php | 77 + .../ORM/Functional/Ticket/DDC448Test.php | 74 + .../ORM/Functional/Ticket/DDC493Test.php | 72 + .../ORM/Functional/Ticket/DDC501Test.php | 124 ++ .../ORM/Functional/Ticket/DDC512Test.php | 94 + .../ORM/Functional/Ticket/DDC513Test.php | 74 + .../ORM/Functional/Ticket/DDC518Test.php | 36 + .../ORM/Functional/Ticket/DDC522Test.php | 121 ++ .../ORM/Functional/Ticket/DDC531Test.php | 88 + .../ORM/Functional/Ticket/DDC588Test.php | 48 + .../ORM/Functional/Ticket/DDC599Test.php | 132 ++ .../ORM/Functional/Ticket/DDC618Test.php | 185 ++ .../ORM/Functional/Ticket/DDC633Test.php | 102 + .../ORM/Functional/Ticket/DDC656Test.php | 82 + .../ORM/Functional/Ticket/DDC657Test.php | 118 ++ .../ORM/Functional/Ticket/DDC698Test.php | 107 + .../ORM/Functional/Ticket/DDC719Test.php | 112 + .../ORM/Functional/Ticket/DDC729Test.php | 182 ++ .../ORM/Functional/Ticket/DDC735Test.php | 122 ++ .../ORM/Functional/Ticket/DDC736Test.php | 100 + .../ORM/Functional/Ticket/DDC742Test.php | 130 ++ .../ORM/Functional/Ticket/DDC748Test.php | 64 + .../ORM/Functional/Ticket/DDC758Test.php | 185 ++ .../ORM/Functional/Ticket/DDC767Test.php | 74 + .../ORM/Functional/Ticket/DDC809Test.php | 109 + .../ORM/Functional/Ticket/DDC812Test.php | 48 + .../ORM/Functional/Ticket/DDC832Test.php | 194 ++ .../ORM/Functional/Ticket/DDC837Test.php | 198 ++ .../ORM/Functional/Ticket/DDC849Test.php | 84 + .../ORM/Functional/Ticket/DDC881Test.php | 215 ++ .../ORM/Functional/Ticket/DDC933Test.php | 39 + .../ORM/Functional/Ticket/DDC949Test.php | 43 + .../ORM/Functional/Ticket/DDC960Test.php | 92 + .../ORM/Functional/Ticket/DDC992Test.php | 147 ++ .../ORM/Functional/Ticket/Ticket2481Test.php | 44 + .../Tests/ORM/Functional/Ticket/Ticket69.php | 427 ++++ .../Tests/ORM/Functional/TypeTest.php | 182 ++ .../Tests/ORM/Functional/TypeValueSqlTest.php | 105 + .../Functional/UnitOfWorkLifecycleTest.php | 71 + .../Tests/ORM/Hydration/ArrayHydratorTest.php | 1147 ++++++++++ .../ORM/Hydration/CustomHydratorTest.php | 29 + .../Tests/ORM/Hydration/HydrationTestCase.php | 30 + .../ORM/Hydration/ObjectHydratorTest.php | 1866 +++++++++++++++++ .../ORM/Hydration/ResultSetMappingTest.php | 97 + .../ORM/Hydration/ScalarHydratorTest.php | 101 + .../Hydration/SingleScalarHydratorTest.php | 78 + .../Tests/ORM/Id/AssignedGeneratorTest.php | 67 + .../Tests/ORM/Id/SequenceGeneratorTest.php | 40 + .../ORM/Mapping/AbstractMappingDriverTest.php | 685 ++++++ .../ORM/Mapping/AnnotationDriverTest.php | 340 +++ .../Mapping/BasicInheritanceMappingTest.php | 319 +++ .../ORM/Mapping/ClassMetadataBuilderTest.php | 428 ++++ .../ORM/Mapping/ClassMetadataFactoryTest.php | 181 ++ .../Mapping/ClassMetadataLoadEventTest.php | 56 + .../Tests/ORM/Mapping/ClassMetadataTest.php | 553 +++++ .../Tests/ORM/Mapping/DriverChainTest.php | 96 + .../ORM/Mapping/PHPMappingDriverTest.php | 31 + .../Mapping/StaticPHPMappingDriverTest.php | 17 + .../Mapping/Symfony/AbstractDriverTest.php | 113 + .../ORM/Mapping/Symfony/XmlDriverTest.php | 40 + .../ORM/Mapping/Symfony/YamlDriverTest.php | 40 + .../ORM/Mapping/XmlMappingDriverTest.php | 96 + .../ORM/Mapping/YamlMappingDriverTest.php | 57 + ...1476.DDC1476EntityWithDefaultFieldType.php | 12 + ...ests.Models.DDC869.DDC869ChequePayment.php | 5 + ....Models.DDC869.DDC869CreditCardPayment.php | 5 + ...rine.Tests.Models.DDC869.DDC869Payment.php | 17 + ...ctrine.Tests.ORM.Mapping.DDC1170Entity.php | 16 + .../php/Doctrine.Tests.ORM.Mapping.User.php | 119 ++ .../Tests/ORM/Mapping/xml/CatNoId.dcm.xml | 8 + ...ts.Models.DDC117.DDC117Translation.dcm.xml | 22 + ....DDC1476EntityWithDefaultFieldType.dcm.xml | 15 + ....Models.DDC869.DDC869ChequePayment.dcm.xml | 11 + ...els.DDC869.DDC869CreditCardPayment.dcm.xml | 11 + ....Tests.Models.DDC869.DDC869Payment.dcm.xml | 15 + ....Models.Generic.SerializationModel.dcm.xml | 17 + .../Doctrine.Tests.ORM.Mapping.Animal.dcm.xml | 12 + .../Doctrine.Tests.ORM.Mapping.CTI.dcm.xml | 17 + ...ne.Tests.ORM.Mapping.DDC1170Entity.dcm.xml | 15 + .../Doctrine.Tests.ORM.Mapping.User.dcm.xml | 67 + ....DDC1476EntityWithDefaultFieldType.dcm.yml | 8 + ....Models.DDC869.DDC869ChequePayment.dcm.yml | 5 + ...els.DDC869.DDC869CreditCardPayment.dcm.yml | 5 + ....Tests.Models.DDC869.DDC869Payment.dcm.yml | 12 + ....DirectoryTree.AbstractContentItem.dcm.yml | 14 + ...sts.Models.DirectoryTree.Directory.dcm.yml | 6 + ...ne.Tests.Models.DirectoryTree.File.dcm.yml | 6 + ....Models.Generic.SerializationModel.dcm.yml | 13 + .../Doctrine.Tests.ORM.Mapping.Animal.dcm.yml | 6 + ...ne.Tests.ORM.Mapping.DDC1170Entity.dcm.yml | 10 + .../Doctrine.Tests.ORM.Mapping.User.dcm.yml | 68 + .../Performance/HydrationPerformanceTest.php | 461 ++++ .../InheritancePersisterPerformanceTest.php | 66 + .../ORM/Performance/InsertPerformanceTest.php | 56 + .../Performance/PersisterPerformanceTest.php | 121 ++ .../Performance/UnitOfWorkPerformanceTest.php | 51 + .../Tests/ORM/PersistentCollectionTest.php | 37 + .../BasicEntityPersisterTypeValueSqlTest.php | 79 + .../Tests/ORM/Proxy/AutoloaderTest.php | 62 + .../ORM/Proxy/ProxyClassGeneratorTest.php | 204 ++ .../Proxy/fixtures/NonNamespacedProxies.php | 13 + .../ORM/Query/DeleteSqlGenerationTest.php | 287 +++ .../Doctrine/Tests/ORM/Query/ExprTest.php | 348 +++ .../ORM/Query/LanguageRecognitionTest.php | 601 ++++++ .../Doctrine/Tests/ORM/Query/LexerTest.php | 234 +++ .../Tests/ORM/Query/ParserResultTest.php | 48 + .../Doctrine/Tests/ORM/Query/QueryTest.php | 128 ++ .../ORM/Query/SelectSqlGenerationTest.php | 1601 ++++++++++++++ .../ORM/Query/UpdateSqlGenerationTest.php | 205 ++ .../Doctrine/Tests/ORM/QueryBuilderTest.php | 748 +++++++ .../ConvertDoctrine1SchemaCommandTest.php | 23 + .../ORM/Tools/ConvertDoctrine1SchemaTest.php | 108 + .../Tests/ORM/Tools/EntityGeneratorTest.php | 294 +++ .../AbstractClassMetadataExporterTest.php | 392 ++++ .../AnnotationClassMetadataExporterTest.php | 42 + .../Export/ClassMetadataExporterTest.php | 0 .../Export/PhpClassMetadataExporterTest.php | 42 + .../Export/XmlClassMetadataExporterTest.php | 42 + .../Export/YamlClassMetadataExporterTest.php | 46 + .../Doctrine.Tests.ORM.Tools.Export.User.php | 73 + .../Doctrine.Tests.ORM.Tools.Export.User.php | 109 + ...ctrine.Tests.ORM.Tools.Export.User.dcm.xml | 66 + ...ctrine.Tests.ORM.Tools.Export.User.dcm.yml | 63 + .../ORM/Tools/Pagination/CountWalkerTest.php | 78 + .../Pagination/LimitSubqueryWalkerTest.php | 36 + .../Tools/Pagination/PaginationTestCase.php | 142 ++ .../Tools/Pagination/WhereInWalkerTest.php | 111 + .../Tools/ResolveTargetEntityListenerTest.php | 129 ++ .../Tests/ORM/Tools/SchemaToolTest.php | 132 ++ .../Tests/ORM/Tools/SchemaValidatorTest.php | 267 +++ .../Doctrine/Tests/ORM/Tools/SetupTest.php | 110 + .../ORM/Tools/doctrine1schema/schema.yml | 28 + .../Doctrine/Tests/ORM/UnitOfWorkTest.php | 312 +++ .../Doctrine/Tests/OrmFunctionalTestCase.php | 415 ++++ .../Doctrine/Tests/OrmPerformanceTestCase.php | 60 + .../orm/tests/Doctrine/Tests/OrmTestCase.php | 122 ++ .../orm/tests/Doctrine/Tests/TestInit.php | 43 + .../orm/tests/Doctrine/Tests/TestUtil.php | 119 ++ .../doctrine/orm/tests/NativePhpunitTask.php | 249 +++ vendor/doctrine/orm/tests/README.markdown | 25 + .../doctrine/orm/tests/dbproperties.xml.dev | 33 + .../orm/tests/travis/mysql.travis.xml | 32 + .../orm/tests/travis/pgsql.travis.xml | 34 + .../orm/tests/travis/sqlite.travis.xml | 15 + .../orm/tools/sandbox/Entities/Address.php | 45 + .../orm/tools/sandbox/Entities/User.php | 48 + .../doctrine/orm/tools/sandbox/cli-config.php | 36 + vendor/doctrine/orm/tools/sandbox/doctrine | 4 + .../doctrine/orm/tools/sandbox/doctrine.php | 49 + vendor/doctrine/orm/tools/sandbox/index.php | 62 + .../sandbox/xml/Entities.Address.dcm.xml | 15 + .../tools/sandbox/xml/Entities.User.dcm.xml | 17 + .../sandbox/yaml/Entities.Address.dcm.yml | 16 + .../tools/sandbox/yaml/Entities.User.dcm.yml | 18 + .../Aop/InterceptorLoader.php | 58 + .../Aop/PointcutContainer.php | 34 + .../Aop/PointcutInterface.php | 54 + .../Aop/RegexPointcut.php | 46 + .../Compiler/PointcutMatchingPass.php | 195 ++ .../DependencyInjection/Configuration.php | 45 + .../DependencyInjection/JMSAopExtension.php | 53 + .../Exception/Exception.php | 28 + .../Exception/RuntimeException.php | 28 + .../JMSAopBundle.php | 34 + .../schmittjoh-JMSAopBundle-8ef7db0/README | 8 + .../Resources/config/services.xml | 18 + .../Resources/doc/index.rst | 252 +++ .../Resources/meta/LICENSE | 201 ++ .../Tests/Aop/InterceptorLoaderTest.php | 64 + .../Tests/Aop/RegexPointcutTest.php | 47 + .../Compiler/Fixture/LoggingInterceptor.php | 39 + .../Compiler/Fixture/LoggingPointcut.php | 34 + .../Compiler/Fixture/TestService.php | 32 + .../Compiler/PointcutMatchingPassTest.php | 96 + .../composer.json | 21 + .../phpunit.xml.dist | 26 + .../cg/schmittjoh-cg-library-ce8ef43/LICENSE | 201 ++ .../schmittjoh-cg-library-ce8ef43/README.rst | 9 + .../composer.json | 19 + .../phpunit.xml.dist | 25 + .../src/CG/Core/AbstractClassGenerator.php | 60 + .../src/CG/Core/ClassGeneratorInterface.php | 36 + .../src/CG/Core/ClassUtils.php | 35 + .../src/CG/Core/DefaultGeneratorStrategy.php | 67 + .../src/CG/Core/DefaultNamingStrategy.php | 41 + .../CG/Core/GeneratorStrategyInterface.php | 34 + .../src/CG/Core/NamingStrategyInterface.php | 50 + .../src/CG/Core/ReflectionUtils.php | 57 + .../src/CG/Generator/AbstractPhpMember.php | 95 + .../src/CG/Generator/DefaultNavigator.php | 172 ++ .../src/CG/Generator/DefaultVisitor.php | 237 +++ .../CG/Generator/DefaultVisitorInterface.php | 47 + .../src/CG/Generator/GeneratorUtils.php | 38 + .../src/CG/Generator/PhpClass.php | 360 ++++ .../src/CG/Generator/PhpFunction.php | 146 ++ .../src/CG/Generator/PhpMethod.php | 158 ++ .../src/CG/Generator/PhpParameter.php | 126 ++ .../src/CG/Generator/PhpProperty.php | 84 + .../src/CG/Generator/Writer.php | 103 + .../src/CG/Proxy/Enhancer.php | 158 ++ .../src/CG/Proxy/GeneratorInterface.php | 38 + .../src/CG/Proxy/InterceptionGenerator.php | 117 ++ .../CG/Proxy/InterceptorLoaderInterface.php | 38 + .../src/CG/Proxy/LazyInitializerGenerator.php | 153 ++ .../src/CG/Proxy/LazyInitializerInterface.php | 38 + .../CG/Proxy/MethodInterceptorInterface.php | 42 + .../src/CG/Proxy/MethodInvocation.php | 77 + .../src/CG/Proxy/RegexInterceptionLoader.php | 48 + .../src/CG/Version.php | 8 + .../tests/CG/Tests/Core/ClassUtilsTest.php | 14 + .../Core/DefaultGeneratorStrategyTest.php | 66 + .../CG/Tests/Core/ReflectionUtilsTest.php | 48 + .../Core/generated/GenerationTestClass_A.php | 16 + .../Core/generated/GenerationTestClass_B.php | 16 + .../Tests/Generator/AbstractPhpMemberTest.php | 58 + .../CG/Tests/Generator/DefaultVisitorTest.php | 47 + .../CG/Tests/Generator/Fixture/Entity.php | 35 + .../Fixture/generated/a_b_function.php | 8 + .../tests/CG/Tests/Generator/PhpClassTest.php | 215 ++ .../CG/Tests/Generator/PhpFunctionTest.php | 75 + .../CG/Tests/Generator/PhpMethodTest.php | 74 + .../CG/Tests/Generator/PhpParameterTest.php | 51 + .../CG/Tests/Generator/PhpPropertyTest.php | 22 + .../tests/CG/Tests/Proxy/EnhancerTest.php | 111 + .../tests/CG/Tests/Proxy/Fixture/Entity.php | 23 + .../Proxy/Fixture/LazyLoadingInterceptor.php | 3 + .../Tests/Proxy/Fixture/MarkerInterface.php | 7 + .../CG/Tests/Proxy/Fixture/SimpleClass.php | 7 + .../Proxy/Fixture/SluggableInterface.php | 8 + .../Tests/Proxy/Fixture/TraceInterceptor.php | 29 + .../Entity__CG__LazyInitializing.php.gen | 37 + .../SimpleClass__CG__Enhanced.php.gen | 11 + .../SimpleClass__CG__Sluggable.php.gen | 14 + .../tests/bootstrap.php | 35 + .../Annotation/AfterSetup.php | 13 + .../Annotation/DoctrineListener.php | 74 + .../Annotation/FormType.php | 37 + .../Annotation/Inject.php | 27 + .../Annotation/InjectParams.php | 57 + .../Annotation/LookupMethod.php | 27 + .../Annotation/Observe.php | 62 + .../Annotation/Reference.php | 54 + .../Annotation/Service.php | 87 + .../Annotation/Tag.php | 60 + .../Annotation/Validator.php | 51 + .../Config/FastDirectoriesResource.php | 78 + .../Config/ServiceFilesResource.php | 52 + .../Compiler/AnnotationConfigurationPass.php | 120 ++ .../Compiler/IntegrationPass.php | 55 + .../Compiler/ResourceOptimizationPass.php | 81 + .../DependencyInjection/Configuration.php | 69 + .../JMSDiExtraExtension.php | 84 + .../LookupMethodClassInterface.php | 24 + .../EventListener/ControllerListener.php | 58 + .../EventListener/TemplateListener.php | 50 + .../Exception/Exception.php | 28 + .../Exception/InvalidArgumentException.php | 28 + .../Exception/InvalidTypeException.php | 29 + .../Exception/RuntimeException.php | 28 + .../Finder/PatternFinder.php | 201 ++ .../Generator/DefinitionInjectorGenerator.php | 192 ++ .../Generator/LookupMethodClassGenerator.php | 119 ++ .../Generator/NameGenerator.php | 79 + .../HttpKernel/ControllerResolver.php | 179 ++ .../JMSDiExtraBundle.php | 50 + .../Metadata/ClassMetadata.php | 74 + .../Metadata/Driver/AnnotationDriver.php | 220 ++ .../Metadata/MetadataConverter.php | 85 + .../README | 8 + .../Resources/config/services.xml | 50 + .../Resources/doc/index.rst | 290 +++ .../Resources/meta/LICENSE | 201 ++ .../AnnotationConfigurationPassTest.php | 127 ++ .../Compiler/Fixtures/a/b/.gitkeep | 0 .../Compiler/Fixtures/c/.gitkeep | 0 .../Compiler/ResourceOptimizationPassTest.php | 50 + .../Finder/AbstractPatternFinderTest.php | 50 + .../Tests/Finder/FindstrPatternFinderTest.php | 38 + .../Tests/Finder/GrepPatternFinderTest.php | 37 + .../Tests/Finder/PhpPatternFinderTest.php | 34 + .../Tests/Fixture/EmptyDirectory/.gitkeep | 0 .../Tests/Fixture/LoginController.php | 73 + .../Fixture/NonEmptyDirectory/DummyFile.php | 3 + .../Fixture/NonEmptyDirectory/Service1.php | 26 + .../NonEmptyDirectory/SubDir1/NonPhpFile.txt | 10 + .../NonEmptyDirectory/SubDir1/Service2.php | 26 + .../NonEmptyDirectory/SubDir2/Service3.php | 26 + .../Tests/Fixture/RequestListener.php | 58 + .../Tests/Fixture/Validator/Validator.php | 45 + .../Tests/Functional/AppKernel.php | 80 + .../Tests/Functional/BaseTestCase.php | 49 + .../Controller/AnotherSecuredController.php | 40 + .../Controller/RegisterController.php | 42 + .../Controller/SecuredController.php | 41 + .../TestBundle/Inheritance/AbstractClass.php | 31 + .../TestBundle/Inheritance/ConcreteClass.php | 38 + .../TestBundle/JMSDiExtraTestBundle.php | 25 + .../Bundle/TestBundle/Mailer/TestMailer.php | 34 + .../Functional/ControllerResolverTest.php | 50 + .../Tests/Functional/Issue11Test.php | 21 + .../Tests/Functional/config/default.yml | 12 + .../Tests/Functional/config/framework.yml | 16 + .../Tests/Functional/config/routing.yml | 3 + .../Tests/Functional/config/security.yml | 13 + .../Tests/Functional/config/twig.yml | 7 + .../Tests/Metadata/ClassMetadataTest.php | 35 + .../Metadata/Driver/AnnotationDriverTest.php | 37 + .../Metadata/Driver/Fixture/LoginType.php | 27 + .../Metadata/Driver/Fixture/SignUpType.php | 19 + .../Tests/PerformanceTest.php | 100 + .../Tests/bootstrap.php | 15 + .../composer.json | 21 + .../phpunit.xml.dist | 26 + .../schmittjoh-metadata-84088bc/CHANGELOG.md | 18 + .../schmittjoh-metadata-84088bc/LICENSE | 201 ++ .../schmittjoh-metadata-84088bc/README.rst | 37 + .../schmittjoh-metadata-84088bc/composer.json | 19 + .../phpunit.xml.dist | 25 + .../src/Metadata/Cache/CacheInterface.php | 35 + .../src/Metadata/Cache/FileCache.php | 46 + .../src/Metadata/ClassHierarchyMetadata.php | 55 + .../src/Metadata/ClassMetadata.php | 98 + .../Metadata/Driver/AbstractFileDriver.php | 42 + .../src/Metadata/Driver/DriverChain.php | 40 + .../src/Metadata/Driver/DriverInterface.php | 24 + .../src/Metadata/Driver/FileLocator.php | 29 + .../Metadata/Driver/FileLocatorInterface.php | 8 + .../src/Metadata/Driver/LazyLoadingDriver.php | 22 + .../src/Metadata/MergeableClassMetadata.php | 23 + .../src/Metadata/MergeableInterface.php | 8 + .../src/Metadata/MetadataFactory.php | 142 ++ .../src/Metadata/MetadataFactoryInterface.php | 24 + .../src/Metadata/MethodMetadata.php | 61 + .../src/Metadata/PropertyMetadata.php | 69 + .../src/Metadata/Version.php | 24 + .../Metadata/Tests/Cache/FileCacheTest.php | 23 + .../Metadata/Tests/ClassMetadataTest.php | 39 + .../Metadata/Tests/Driver/DriverChainTest.php | 37 + .../Metadata/Tests/Driver/FileLocatorTest.php | 26 + .../Metadata/Tests/Driver/Fixture/A/A.php | 5 + .../Metadata/Tests/Driver/Fixture/A/A.xml | 0 .../Metadata/Tests/Driver/Fixture/B/B.php | 5 + .../Metadata/Tests/Driver/Fixture/B/B.yml | 0 .../Tests/Driver/Fixture/C/SubDir.C.yml | 0 .../Tests/Driver/Fixture/C/SubDir/C.php | 5 + .../Fixtures/ComplexHierarchy/BaseClass.php | 8 + .../Fixtures/ComplexHierarchy/InterfaceA.php | 7 + .../Fixtures/ComplexHierarchy/InterfaceB.php | 7 + .../Fixtures/ComplexHierarchy/SubClassA.php | 8 + .../Fixtures/ComplexHierarchy/SubClassB.php | 8 + .../Metadata/Tests/Fixtures/TestObject.php | 18 + .../Metadata/Tests/Fixtures/TestParent.php | 7 + .../Tests/MergeableClassMetadataTest.php | 33 + .../Metadata/Tests/MetadataFactoryTest.php | 184 ++ .../Metadata/Tests/MethodMetadataTest.php | 36 + .../Metadata/Tests/PropertyMetadataTest.php | 36 + .../tests/bootstrap.php | 36 + .../Annotation/PreAuthorize.php | 59 + .../Annotation/RunAs.php | 42 + .../SatisfiesParentSecurityPolicy.php | 81 + .../Annotation/Secure.php | 45 + .../Annotation/SecureParam.php | 48 + .../Annotation/SecureReturn.php | 45 + .../CHANGELOG-1.1.md | 38 + .../AccessControlConfiguration.php | 90 + .../AddAfterInvocationProvidersPass.php | 52 + .../Compiler/AddExpressionCompilersPass.php | 66 + .../Compiler/CollectSecuredServicesPass.php | 43 + .../Compiler/DisableVotersPass.php | 46 + .../Compiler/IntegrationPass.php | 22 + .../DependencyInjection/Configuration.php | 64 + .../JMSSecurityExtraExtension.php | 100 + .../DependencyInjection/SecurityExtension.php | 130 ++ .../Exception/Exception.php | 28 + .../Exception/InvalidArgumentException.php | 28 + .../Exception/RuntimeException.php | 28 + .../JMSSecurityExtraBundle.php | 59 + .../Metadata/ClassMetadata.php | 93 + .../Metadata/Driver/AnnotationDriver.php | 107 + .../Metadata/Driver/ConfigDriver.php | 100 + .../Metadata/MethodMetadata.php | 84 + .../README | 8 + .../Resources/config/security_expressions.xml | 84 + .../Resources/config/services.xml | 99 + .../Resources/doc/index.rst | 352 ++++ .../Resources/meta/LICENSE | 201 ++ .../HasPermissionFunctionCompiler.php | 63 + .../Acl/Expression/PermissionEvaluator.php | 122 ++ .../Security/Acl/Voter/AclVoter.php | 136 ++ .../Provider/RunAsAuthenticationProvider.php | 57 + .../Authentication/Token/RunAsUserToken.php | 85 + .../AclAfterInvocationProvider.php | 111 + .../AfterInvocationManager.php | 77 + .../AfterInvocationManagerInterface.php | 56 + .../AfterInvocationProviderInterface.php | 33 + .../Expression/Ast/AndExpression.php | 31 + .../Expression/Ast/ArrayExpression.php | 29 + .../Expression/Ast/ConstantExpression.php | 29 + .../Expression/Ast/ExpressionInterface.php | 23 + .../Expression/Ast/FunctionExpression.php | 32 + .../Expression/Ast/GetItemExpression.php | 31 + .../Expression/Ast/GetPropertyExpression.php | 31 + .../Expression/Ast/IsEqualExpression.php | 31 + .../Expression/Ast/MethodCallExpression.php | 33 + .../Expression/Ast/NotExpression.php | 29 + .../Expression/Ast/OrExpression.php | 31 + .../Expression/Ast/ParameterExpression.php | 29 + .../Expression/Ast/VariableExpression.php | 31 + .../Compiler/AndExpressionCompiler.php | 32 + .../Compiler/BinaryExprCompiler.php | 51 + .../ContainerAwareVariableCompiler.php | 60 + .../AuthenticationTrustFunctionCompiler.php | 35 + .../Func/FunctionCompilerInterface.php | 29 + .../Func/HasAnyRoleFunctionCompiler.php | 63 + .../Compiler/Func/HasRoleFunctionCompiler.php | 51 + .../Func/IsAnonymousFunctionCompiler.php | 39 + .../Func/IsAuthenticatedFunctionCompiler.php | 41 + .../IsFullyAuthenticatedFunctionCompiler.php | 39 + .../Func/IsRememberMeFunctionCompiler.php | 39 + .../Compiler/IsEqualExpressionCompiler.php | 32 + .../Compiler/NotExpressionCompiler.php | 44 + .../Compiler/OrExpressionCompiler.php | 32 + .../Compiler/ParameterExpressionCompiler.php | 80 + .../Compiler/TypeCompilerInterface.php | 29 + .../Compiler/VariableExpressionCompiler.php | 74 + .../ContainerAwareExpressionHandler.php | 47 + .../Expression/DefaultExpressionHandler.php | 51 + .../Authorization/Expression/Expression.php | 40 + .../Expression/ExpressionCompiler.php | 395 ++++ .../Expression/ExpressionHandlerInterface.php | 26 + .../Expression/ExpressionLexer.php | 134 ++ .../Expression/ExpressionParser.php | 290 +++ .../Expression/ExpressionVoter.php | 114 + .../Expression/LazyLoadingExpressionVoter.php | 39 + .../MethodSecurityInterceptor.php | 150 ++ .../Interception/SecurityPointcut.php | 92 + .../Security/Authorization/RunAsManager.php | 79 + .../Authorization/RunAsManagerInterface.php | 57 + .../Authorization/Voter/IddqdVoter.php | 61 + .../AddAfterInvocationProvidersPassTest.php | 91 + .../CollectSecuredServicesPassTest.php | 50 + .../JMSSecurityExtraExtensionTest.php | 91 + ...irectlyOverwrittenInDirectChildService.php | 45 + .../Annotation/NonSecurityAnnotation.php | 24 + .../Tests/Fixtures/ComplexService.php | 54 + .../Tests/Fixtures/CorrectSubService.php | 34 + .../Tests/Fixtures/MainService.php | 42 + .../Tests/Fixtures/SubService.php | 29 + .../Tests/Functional/AppKernel.php | 97 + .../Tests/Functional/BaseTestCase.php | 64 + .../Functional/MethodAccessControlTest.php | 77 + .../Functional/Resources/views/base.html.twig | 13 + .../TestBundle/Controller/CrudController.php | 18 + .../TestBundle/Controller/PostController.php | 84 + .../Functional/TestBundle/Entity/Post.php | 41 + .../TestBundle/Logger/FileLogger.php | 60 + .../Resources/views/is_expr_granted.html.twig | 5 + .../Functional/TestBundle/TestBundle.php | 10 + .../TestBundle/User/UserManager.php | 11 + .../Tests/Functional/TwigIntegrationTest.php | 39 + .../Tests/Functional/VoterDisablingTest.php | 48 + .../Tests/Functional/config/acl_enabled.yml | 9 + .../Functional/config/all_voters_disabled.yml | 6 + .../Tests/Functional/config/default.yml | 5 + .../Tests/Functional/config/doctrine.yml | 13 + .../Tests/Functional/config/framework.yml | 18 + .../config/method_access_control.yml | 12 + .../Tests/Functional/config/routing.yml | 27 + .../Tests/Functional/config/security.yml | 17 + .../config/some_voters_disabled.yml | 10 + .../Tests/Functional/config/twig.yml | 7 + .../Tests/Metadata/ClassMetadataTest.php | 117 ++ .../Metadata/Driver/AnnotationDriverTest.php | 66 + .../Metadata/Driver/ConfigDriverTest.php | 54 + .../Fixtures/Controller/CrudController.php | 14 + .../Metadata/Driver/Fixtures/services.php | 46 + .../HasPermissionFunctionCompilerTest.php | 40 + .../Expression/PermissionEvaluatorTest.php | 143 ++ .../Tests/Security/Acl/Voter/AclVoterTest.php | 396 ++++ .../RunAsAuthenticationProviderTest.php | 86 + .../Token/RunAsUserTokenTest.php | 54 + .../AclAfterInvocationProviderTest.php | 248 +++ .../AfterInvocationManagerTest.php | 107 + .../Expression/ExpressionCompilerTest.php | 150 ++ .../Expression/ExpressionLexerTest.php | 27 + .../Expression/ExpressionParserTest.php | 158 ++ .../Expression/ExpressionVoterTest.php | 113 + .../Expression/Fixture/Issue22/Project.php | 18 + .../Fixture/Issue22/SecuredObject.php | 14 + .../ParameterExpressionCompilerTest.php | 67 + .../MethodSecurityInterceptorTest.php | 314 +++ .../Interception/SecurityPointcutTest.php | 34 + .../Twig/SecurityExtension.php | 35 + .../composer.json | 25 + .../phpunit.xml.dist | 19 + .../Seldaek-monolog-abc80e0/.gitignore | 4 + .../Seldaek-monolog-abc80e0/.travis.yml | 11 + .../Seldaek-monolog-abc80e0/CHANGELOG.mdown | 38 + .../monolog/Seldaek-monolog-abc80e0/LICENSE | 19 + .../Seldaek-monolog-abc80e0/README.mdown | 172 ++ .../Seldaek-monolog-abc80e0/composer.json | 27 + .../Seldaek-monolog-abc80e0/doc/extending.md | 76 + .../Seldaek-monolog-abc80e0/doc/sockets.md | 37 + .../Seldaek-monolog-abc80e0/doc/usage.md | 124 ++ .../Seldaek-monolog-abc80e0/phpunit.xml.dist | 15 + .../Monolog/Formatter/ChromePHPFormatter.php | 77 + .../Monolog/Formatter/FormatterInterface.php | 36 + .../Formatter/GelfMessageFormatter.php | 91 + .../src/Monolog/Formatter/JsonFormatter.php | 40 + .../src/Monolog/Formatter/LineFormatter.php | 92 + .../Monolog/Formatter/NormalizerFormatter.php | 90 + .../Monolog/Formatter/WildfireFormatter.php | 87 + .../src/Monolog/Handler/AbstractHandler.php | 173 ++ .../Handler/AbstractProcessingHandler.php | 70 + .../src/Monolog/Handler/BufferHandler.php | 67 + .../src/Monolog/Handler/ChromePHPHandler.php | 127 ++ .../ActivationStrategyInterface.php | 28 + .../ErrorLevelActivationStrategy.php | 32 + .../Monolog/Handler/FingersCrossedHandler.php | 104 + .../src/Monolog/Handler/FirePHPHandler.php | 161 ++ .../src/Monolog/Handler/GelfHandler.php | 66 + .../src/Monolog/Handler/GroupHandler.php | 74 + .../src/Monolog/Handler/HandlerInterface.php | 77 + .../src/Monolog/Handler/MailHandler.php | 55 + .../src/Monolog/Handler/MongoDBHandler.php | 51 + .../Monolog/Handler/NativeMailerHandler.php | 49 + .../src/Monolog/Handler/NullHandler.php | 45 + .../Monolog/Handler/RotatingFileHandler.php | 109 + .../src/Monolog/Handler/SocketHandler.php | 272 +++ .../src/Monolog/Handler/StreamHandler.php | 71 + .../Monolog/Handler/SwiftMailerHandler.php | 55 + .../src/Monolog/Handler/SyslogHandler.php | 108 + .../src/Monolog/Handler/TestHandler.php | 120 ++ .../src/Monolog/Logger.php | 421 ++++ .../Processor/IntrospectionProcessor.php | 58 + .../Processor/MemoryPeakUsageProcessor.php | 40 + .../src/Monolog/Processor/MemoryProcessor.php | 50 + .../Processor/MemoryUsageProcessor.php | 40 + .../src/Monolog/Processor/WebProcessor.php | 66 + .../Formatter/ChromePHPFormatterTest.php | 158 ++ .../Formatter/GelfMessageFormatterTest.php | 150 ++ .../Monolog/Formatter/JsonFormatterTest.php | 41 + .../Monolog/Formatter/LineFormatterTest.php | 134 ++ .../Formatter/NormalizerFormatterTest.php | 107 + .../Formatter/WildfireFormatterTest.php | 111 + .../Functional/Handler/FirePHPHandlerTest.php | 32 + .../Monolog/Handler/AbstractHandlerTest.php | 104 + .../Handler/AbstractProcessingHandlerTest.php | 80 + .../Monolog/Handler/BufferHandlerTest.php | 84 + .../Monolog/Handler/ChromePHPHandlerTest.php | 98 + .../Handler/FingersCrossedHandlerTest.php | 151 ++ .../Monolog/Handler/FirePHPHandlerTest.php | 94 + .../tests/Monolog/Handler/Fixtures/.gitkeep | 0 .../tests/Monolog/Handler/GelfHandlerTest.php | 102 + .../Monolog/Handler/GroupHandlerTest.php | 71 + .../tests/Monolog/Handler/MailHandlerTest.php | 75 + .../Monolog/Handler/MongoDBHandlerTest.php | 54 + .../tests/Monolog/Handler/NullHandlerTest.php | 33 + .../Handler/RotatingFileHandlerTest.php | 100 + .../Monolog/Handler/SocketHandlerTest.php | 284 +++ .../Monolog/Handler/StreamHandlerTest.php | 77 + .../Monolog/Handler/SyslogHandlerTest.php | 41 + .../tests/Monolog/Handler/TestHandlerTest.php | 54 + .../tests/Monolog/LoggerTest.php | 367 ++++ .../Processor/IntrospectionProcessorTest.php | 64 + .../MemoryPeakUsageProcessorTest.php | 29 + .../Processor/MemoryUsageProcessorTest.php | 29 + .../Monolog/Processor/WebProcessorTest.php | 68 + .../tests/Monolog/TestCase.php | 58 + .../tests/bootstrap.php | 13 + .../FrameworkExtension.php | 1 - .../Handler/NativeFileSessionHandler.php | 25 +- .../Handler/NativeFileSessionHandlerTest.php | 33 +- vendor/twig/extensions/.gitignore | 2 + vendor/twig/extensions/README | 7 + vendor/twig/extensions/doc/debug.rst | 30 + vendor/twig/extensions/doc/i18n.rst | 156 ++ vendor/twig/extensions/doc/index.rst | 18 + vendor/twig/extensions/doc/text.rst | 8 + vendor/twig/extensions/phpunit.xml.dist | 30 + .../test/Twig/Tests/Grammar/ArgumentsTest.php | 19 + .../test/Twig/Tests/Grammar/ArrayTest.php | 19 + .../test/Twig/Tests/Grammar/BodyTest.php | 19 + .../test/Twig/Tests/Grammar/BooleanTest.php | 19 + .../test/Twig/Tests/Grammar/ConstantTest.php | 19 + .../Twig/Tests/Grammar/ExpressionTest.php | 19 + .../test/Twig/Tests/Grammar/NumberTest.php | 19 + .../test/Twig/Tests/Grammar/OptionalTest.php | 19 + .../test/Twig/Tests/Grammar/TagTest.php | 23 + .../test/Twig/Tests/Node/DebugTest.php | 67 + .../test/Twig/Tests/Node/TransTest.php | 93 + .../test/Twig/Tests/SimpleTokenParser.php | 48 + .../test/Twig/Tests/SimpleTokenParserTest.php | 112 + .../test/Twig/Tests/grammarTest.php | 63 + vendor/twig/extensions/test/bootstrap.php | 20 + 1102 files changed, 103189 insertions(+), 7 deletions(-) create mode 100644 app/DoctrineMigrations/Version20120723170354.php create mode 100644 app/DoctrineMigrations/Version20120723170752.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/.gitignore create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/.gitmodules create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/.travis.yml create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/LICENSE create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/README.md create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_1 create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_2 create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/build.properties create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/build.xml create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/composer.json create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attribute.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attributes.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Required.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Target.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationException.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationReader.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationRegistry.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/CachedReader.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocLexer.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocParser.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/FileCacheReader.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/IndexedReader.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/PhpParser.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Reader.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ApcCache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ArrayCache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/Cache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/CacheProvider.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcacheCache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcachedCache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/WinCacheCache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/XcacheCache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ZendDataCache.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/ClassLoader.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/ArrayCollection.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/Collection.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/CommonException.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Comparable.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventArgs.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventManager.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventSubscriber.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Lexer.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/NotifyPropertyChanged.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ConnectionRegistry.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ManagerRegistry.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/MappingException.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManager.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManagerAware.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectRepository.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/PersistentObject.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Proxy.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/PropertyChangedListener.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/ClassUtils.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Debug.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Inflector.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Version.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/phpunit.xml.dist create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/.gitignore create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Autoload.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Route.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Secure.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetAll.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetAnnotation.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetClass.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetMethod.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetPropertyMethod.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithTargetSyntaxError.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAnnotationWithTargetSyntaxError.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAnnotationWithVarType.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithFullyQualifiedUseStatements.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithInvalidAnnotationTargetAtClass.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithInvalidAnnotationTargetAtMethod.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithInvalidAnnotationTargetAtProperty.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithValidAnnotationTarget.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsFirst.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsLast.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/EqualNamespacesPerFileWithClassAsFirst.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/EqualNamespacesPerFileWithClassAsLast.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/GlobalNamespacesPerFileWithClassAsFirst.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/GlobalNamespacesPerFileWithClassAsLast.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/InvalidAnnotationUsageButIgnoredClass.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/InvalidAnnotationUsageClass.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/MultipleClassesInFile.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/MultipleImportsInUseStatement.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NamespaceAndClassCommentedOut.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NamespaceWithClosureDeclaration.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NamespacedSingleClassLOC1000.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NoAnnotation.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NonNamespacedClass.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/SingleClassLOC1000.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/CacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassB.class.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassC.class.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassD.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Collections/CollectionTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/EventManagerTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/DebugTest.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/DoctrineTestCase.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/TestInit.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/NativePhpunitTask.php create mode 100644 vendor/doctrine/common/doctrine-common-ac6c39b/tests/README.markdown create mode 100644 vendor/doctrine/dbal/.gitignore create mode 100644 vendor/doctrine/dbal/.gitmodules create mode 100644 vendor/doctrine/dbal/bin/doctrine-dbal create mode 100644 vendor/doctrine/dbal/bin/doctrine-dbal.php create mode 100644 vendor/doctrine/dbal/bin/doctrine.php create mode 100644 vendor/doctrine/dbal/build.properties create mode 100644 vendor/doctrine/dbal/build.xml create mode 100644 vendor/doctrine/dbal/tests/.gitignore create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BlobTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/FloatTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/StringTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/UtilTest.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DbalTestCase.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/DoctrineTestCase.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/ConnectionMock.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverMock.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/TaskMock.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/TestInit.php create mode 100644 vendor/doctrine/dbal/tests/Doctrine/Tests/TestUtil.php create mode 100644 vendor/doctrine/dbal/tests/README.markdown create mode 100644 vendor/doctrine/dbal/tests/travis/mysql.travis.xml create mode 100644 vendor/doctrine/dbal/tests/travis/pgsql.travis.xml create mode 100644 vendor/doctrine/dbal/tests/travis/sqlite.travis.xml create mode 100644 vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/.gitignore create mode 160000 vendor/doctrine/doctrine-migrations-bundle/Doctrine/Bundle/MigrationsBundle create mode 100644 vendor/doctrine/orm/.gitignore create mode 100644 vendor/doctrine/orm/.gitmodules create mode 100644 vendor/doctrine/orm/UPGRADE_TO_2_0 create mode 100644 vendor/doctrine/orm/UPGRADE_TO_2_1 create mode 100644 vendor/doctrine/orm/UPGRADE_TO_2_2 create mode 100644 vendor/doctrine/orm/UPGRADE_TO_ALPHA3 create mode 100644 vendor/doctrine/orm/UPGRADE_TO_ALPHA4 create mode 100644 vendor/doctrine/orm/bin/doctrine create mode 100644 vendor/doctrine/orm/bin/doctrine.bat create mode 100644 vendor/doctrine/orm/bin/doctrine.php create mode 100644 vendor/doctrine/orm/build.properties create mode 100644 vendor/doctrine/orm/build.properties.dev create mode 100644 vendor/doctrine/orm/build.xml create mode 100644 vendor/doctrine/orm/tests/.gitignore create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/DbalFunctionalTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/DbalTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/NegativeToPositiveType.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/DoctrineTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ClassMetadataMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ConnectionMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityManagerMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MockTreeWalker.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/SequenceMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/TaskMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsAddress.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsArticle.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsComment.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmail.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsGroup.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsUser.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyAuction.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyCar.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyContract.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEvent.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyManager.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyPerson.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeParent.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ApproveChanges.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/File.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAvatar.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumBoard.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumCategory.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumEntry.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumUser.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/BooleanModel.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/DateTimeModel.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/DecimalModel.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/SerializationModel.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Global/GlobalNamespaceModel.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyArticle.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavCountry.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavTour.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLocation.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Market.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Stock.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/EntityManagerTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CustomTreeWalkersTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostgreSQLIdentityStrategyTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/AbstractDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/AutoloaderTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ExprTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LexerTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/QueryTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/QueryBuilderTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/ClassMetadataExporterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/PhpClassMetadataExporterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/YamlClassMetadataExporterTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/php/Doctrine.Tests.ORM.Tools.Export.User.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SetupTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/OrmPerformanceTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/TestInit.php create mode 100644 vendor/doctrine/orm/tests/Doctrine/Tests/TestUtil.php create mode 100644 vendor/doctrine/orm/tests/NativePhpunitTask.php create mode 100644 vendor/doctrine/orm/tests/README.markdown create mode 100644 vendor/doctrine/orm/tests/dbproperties.xml.dev create mode 100644 vendor/doctrine/orm/tests/travis/mysql.travis.xml create mode 100644 vendor/doctrine/orm/tests/travis/pgsql.travis.xml create mode 100644 vendor/doctrine/orm/tests/travis/sqlite.travis.xml create mode 100644 vendor/doctrine/orm/tools/sandbox/Entities/Address.php create mode 100644 vendor/doctrine/orm/tools/sandbox/Entities/User.php create mode 100644 vendor/doctrine/orm/tools/sandbox/cli-config.php create mode 100755 vendor/doctrine/orm/tools/sandbox/doctrine create mode 100644 vendor/doctrine/orm/tools/sandbox/doctrine.php create mode 100644 vendor/doctrine/orm/tools/sandbox/index.php create mode 100644 vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml create mode 100644 vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml create mode 100644 vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml create mode 100644 vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/InterceptorLoader.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutContainer.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutInterface.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/RegexPointcut.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Compiler/PointcutMatchingPass.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Configuration.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/JMSAopExtension.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/Exception.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/RuntimeException.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/JMSAopBundle.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/README create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/config/services.xml create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/doc/index.rst create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/meta/LICENSE create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/InterceptorLoaderTest.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/RegexPointcutTest.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingInterceptor.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingPointcut.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/TestService.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/PointcutMatchingPassTest.php create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/composer.json create mode 100644 vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/phpunit.xml.dist create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/LICENSE create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/README.rst create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/composer.json create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/phpunit.xml.dist create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/AbstractClassGenerator.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassGeneratorInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassUtils.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultGeneratorStrategy.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultNamingStrategy.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/GeneratorStrategyInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/NamingStrategyInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ReflectionUtils.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/AbstractPhpMember.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultNavigator.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitor.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitorInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/GeneratorUtils.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpClass.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpFunction.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpMethod.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpParameter.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpProperty.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/Writer.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/Enhancer.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/GeneratorInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptionGenerator.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptorLoaderInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerGenerator.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInterceptorInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInvocation.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/RegexInterceptionLoader.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Version.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/ClassUtilsTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/DefaultGeneratorStrategyTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/ReflectionUtilsTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_A.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_B.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/AbstractPhpMemberTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/DefaultVisitorTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/Entity.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/generated/a_b_function.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpClassTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpFunctionTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpMethodTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpParameterTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpPropertyTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/EnhancerTest.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/Entity.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/LazyLoadingInterceptor.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/MarkerInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/SimpleClass.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/SluggableInterface.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/TraceInterceptor.php create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/Entity__CG__LazyInitializing.php.gen create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Enhanced.php.gen create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Sluggable.php.gen create mode 100644 vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/bootstrap.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/AfterSetup.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/DoctrineListener.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/FormType.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Inject.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/InjectParams.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/LookupMethod.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Observe.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Reference.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Service.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Tag.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Validator.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/FastDirectoriesResource.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/ServiceFilesResource.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/AnnotationConfigurationPass.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/IntegrationPass.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/ResourceOptimizationPass.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Configuration.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/JMSDiExtraExtension.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/LookupMethodClassInterface.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/ControllerListener.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/TemplateListener.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/Exception.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidArgumentException.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidTypeException.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/RuntimeException.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Finder/PatternFinder.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/DefinitionInjectorGenerator.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/LookupMethodClassGenerator.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/NameGenerator.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/HttpKernel/ControllerResolver.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/JMSDiExtraBundle.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/ClassMetadata.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/Driver/AnnotationDriver.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/MetadataConverter.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/README create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/config/services.xml create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/doc/index.rst create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/meta/LICENSE create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/Fixtures/a/b/.gitkeep create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/Fixtures/c/.gitkeep create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/AbstractPatternFinderTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/FindstrPatternFinderTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/GrepPatternFinderTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/PhpPatternFinderTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/EmptyDirectory/.gitkeep create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/LoginController.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/DummyFile.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/Service1.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir1/NonPhpFile.txt create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir1/Service2.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir2/Service3.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/RequestListener.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/Validator/Validator.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/AppKernel.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/BaseTestCase.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/RegisterController.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/AbstractClass.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/ConcreteClass.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/JMSDiExtraTestBundle.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Mailer/TestMailer.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/ControllerResolverTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Issue11Test.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/default.yml create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/framework.yml create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/routing.yml create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/security.yml create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/twig.yml create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/ClassMetadataTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/AnnotationDriverTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/LoginType.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/SignUpType.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/PerformanceTest.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/bootstrap.php create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/composer.json create mode 100644 vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/phpunit.xml.dist create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/CHANGELOG.md create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/LICENSE create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/README.rst create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/composer.json create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/phpunit.xml.dist create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Cache/CacheInterface.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Cache/FileCache.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassHierarchyMetadata.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassMetadata.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/AbstractFileDriver.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverChain.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverInterface.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocator.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocatorInterface.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/LazyLoadingDriver.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableClassMetadata.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableInterface.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MetadataFactory.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MetadataFactoryInterface.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MethodMetadata.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/PropertyMetadata.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Version.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Cache/FileCacheTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/ClassMetadataTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/DriverChainTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/FileLocatorTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/A/A.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/A/A.xml create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/B/B.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/B/B.yml create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/C/SubDir.C.yml create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/C/SubDir/C.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/ComplexHierarchy/BaseClass.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/ComplexHierarchy/InterfaceA.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/ComplexHierarchy/InterfaceB.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/ComplexHierarchy/SubClassA.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/ComplexHierarchy/SubClassB.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/TestObject.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/TestParent.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MergeableClassMetadataTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MetadataFactoryTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MethodMetadataTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/PropertyMetadataTest.php create mode 100644 vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/bootstrap.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/PreAuthorize.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/RunAs.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SatisfiesParentSecurityPolicy.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/Secure.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureParam.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureReturn.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/CHANGELOG-1.1.md create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/AccessControlConfiguration.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddAfterInvocationProvidersPass.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddExpressionCompilersPass.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/CollectSecuredServicesPass.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/DisableVotersPass.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/IntegrationPass.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Configuration.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/JMSSecurityExtraExtension.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/SecurityExtension.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/Exception.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/InvalidArgumentException.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/RuntimeException.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/JMSSecurityExtraBundle.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/ClassMetadata.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/AnnotationDriver.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/ConfigDriver.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/MethodMetadata.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/README create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/security_expressions.xml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/services.xml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/doc/index.rst create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/meta/LICENSE create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/HasPermissionFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/PermissionEvaluator.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Voter/AclVoter.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Provider/RunAsAuthenticationProvider.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Token/RunAsUserToken.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AclAfterInvocationProvider.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManager.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManagerInterface.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationProviderInterface.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/AndExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ArrayExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ConstantExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ExpressionInterface.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/FunctionExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetItemExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetPropertyExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/IsEqualExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/MethodCallExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/NotExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/OrExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ParameterExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/VariableExpression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/AndExpressionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/BinaryExprCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ContainerAwareVariableCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/AuthenticationTrustFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/FunctionCompilerInterface.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasAnyRoleFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasRoleFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAnonymousFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAuthenticatedFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsFullyAuthenticatedFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsRememberMeFunctionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/IsEqualExpressionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/NotExpressionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/OrExpressionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ParameterExpressionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/TypeCompilerInterface.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/VariableExpressionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ContainerAwareExpressionHandler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/DefaultExpressionHandler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Expression.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionCompiler.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionHandlerInterface.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionLexer.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionParser.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionVoter.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/LazyLoadingExpressionVoter.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/MethodSecurityInterceptor.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/SecurityPointcut.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManager.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManagerInterface.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Voter/IddqdVoter.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/AddAfterInvocationProvidersPassTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/CollectSecuredServicesPassTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/JMSSecurityExtraExtensionTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/AbstractMethodNotDirectlyOverwrittenInDirectChildService.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/Annotation/NonSecurityAnnotation.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/ComplexService.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/CorrectSubService.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/MainService.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/SubService.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/AppKernel.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/BaseTestCase.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/MethodAccessControlTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/Resources/views/base.html.twig create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Controller/CrudController.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Controller/PostController.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Entity/Post.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Logger/FileLogger.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Resources/views/is_expr_granted.html.twig create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/TestBundle.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/User/UserManager.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TwigIntegrationTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/VoterDisablingTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/acl_enabled.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/all_voters_disabled.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/default.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/doctrine.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/framework.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/method_access_control.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/routing.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/security.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/some_voters_disabled.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/twig.yml create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/ClassMetadataTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/AnnotationDriverTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/ConfigDriverTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/Fixtures/Controller/CrudController.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/Fixtures/services.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/HasPermissionFunctionCompilerTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/PermissionEvaluatorTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Voter/AclVoterTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Provider/RunAsAuthenticationProviderTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Token/RunAsUserTokenTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AclAfterInvocationProviderTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AfterInvocationManagerTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionCompilerTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionLexerTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionParserTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionVoterTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/Project.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/SecuredObject.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ParameterExpressionCompilerTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/MethodSecurityInterceptorTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/SecurityPointcutTest.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Twig/SecurityExtension.php create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/composer.json create mode 100644 vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/phpunit.xml.dist create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/.gitignore create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/.travis.yml create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/CHANGELOG.mdown create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/LICENSE create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/README.mdown create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/composer.json create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/extending.md create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/sockets.md create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/usage.md create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/phpunit.xml.dist create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/ChromePHPFormatter.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/FormatterInterface.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/GelfMessageFormatter.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/JsonFormatter.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/LineFormatter.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/NormalizerFormatter.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/WildfireFormatter.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractProcessingHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/BufferHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/ChromePHPHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossedHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FirePHPHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GelfHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GroupHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/HandlerInterface.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MailHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MongoDBHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NativeMailerHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NullHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/RotatingFileHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SocketHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/StreamHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SwiftMailerHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SyslogHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/TestHandler.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Logger.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/IntrospectionProcessor.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryPeakUsageProcessor.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryProcessor.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryUsageProcessor.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/WebProcessor.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/ChromePHPFormatterTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/GelfMessageFormatterTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/JsonFormatterTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/LineFormatterTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/NormalizerFormatterTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/WildfireFormatterTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractProcessingHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/BufferHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/ChromePHPHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FingersCrossedHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FirePHPHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/Fixtures/.gitkeep create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GelfHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GroupHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MailHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MongoDBHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/NullHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/RotatingFileHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SocketHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/StreamHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SyslogHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/TestHandlerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/LoggerTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/IntrospectionProcessorTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryUsageProcessorTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/WebProcessorTest.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/TestCase.php create mode 100644 vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/bootstrap.php create mode 100644 vendor/twig/extensions/.gitignore create mode 100644 vendor/twig/extensions/README create mode 100644 vendor/twig/extensions/doc/debug.rst create mode 100644 vendor/twig/extensions/doc/i18n.rst create mode 100644 vendor/twig/extensions/doc/index.rst create mode 100644 vendor/twig/extensions/doc/text.rst create mode 100644 vendor/twig/extensions/phpunit.xml.dist create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/ArgumentsTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/ArrayTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/BodyTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/BooleanTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/ConstantTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/ExpressionTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/NumberTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/OptionalTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Grammar/TagTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Node/DebugTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/Node/TransTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/SimpleTokenParser.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/SimpleTokenParserTest.php create mode 100644 vendor/twig/extensions/test/Twig/Tests/grammarTest.php create mode 100644 vendor/twig/extensions/test/bootstrap.php diff --git a/app/AppKernel.php b/app/AppKernel.php index d3b85c9..867720e 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -19,7 +19,10 @@ class AppKernel extends Kernel new JMS\AopBundle\JMSAopBundle(), new JMS\DiExtraBundle\JMSDiExtraBundle($this), new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), + // 3rd party bundles new Ivory\CKEditorBundle\IvoryCKEditorBundle(), + new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), + // Own bundles new KekRozsak\FrontBundle\KekRozsakFrontBundle(), new KekRozsak\SecurityBundle\KekRozsakSecurityBundle(), new KekRozsak\AdminBundle\KekRozsakAdminBundle(), diff --git a/app/DoctrineMigrations/Version20120723170354.php b/app/DoctrineMigrations/Version20120723170354.php new file mode 100644 index 0000000..ce2c935 --- /dev/null +++ b/app/DoctrineMigrations/Version20120723170354.php @@ -0,0 +1,24 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + } +} diff --git a/composer.json b/composer.json index 7b6c5b5..23109e0 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "sensio/generator-bundle": "dev-master", "jms/security-extra-bundle": "1.1.*", "jms/di-extra-bundle": "1.0.*", - "doctrine/migrations": "dev-master", + "doctrine/doctrine-migrations-bundle": "dev-master", "egeloen/ckeditor-bundle": "dev-master" }, "scripts": { diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 0ffe2c6..29902d5 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -26,6 +26,7 @@ return array( 'Doctrine\\DBAL\\Migrations' => $vendorDir . '/doctrine/migrations/lib', 'Doctrine\\DBAL' => $vendorDir . '/doctrine/dbal/lib/', 'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib/', + 'Doctrine\\Bundle\\MigrationsBundle' => $vendorDir . '/doctrine/doctrine-migrations-bundle/', 'Doctrine\\Bundle\\DoctrineBundle' => $vendorDir . '/doctrine/doctrine-bundle/', 'CG\\' => $vendorDir . '/jms/cg/src/', 'Assetic' => $vendorDir . '/kriswallsmith/assetic/src/', diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/.gitignore b/vendor/doctrine/common/doctrine-common-ac6c39b/.gitignore new file mode 100644 index 0000000..fb5e79d --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/.gitignore @@ -0,0 +1,4 @@ +build/ +logs/ +reports/ +dist/ diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/.gitmodules b/vendor/doctrine/common/doctrine-common-ac6c39b/.gitmodules new file mode 100644 index 0000000..51f0843 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/vendor/doctrine-build-common"] + path = lib/vendor/doctrine-build-common + url = git://github.com/doctrine/doctrine-build-common.git diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/.travis.yml b/vendor/doctrine/common/doctrine-common-ac6c39b/.travis.yml new file mode 100644 index 0000000..4464d4f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/.travis.yml @@ -0,0 +1,5 @@ +language: php + +php: + - 5.3 + - 5.4 diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/LICENSE b/vendor/doctrine/common/doctrine-common-ac6c39b/LICENSE new file mode 100644 index 0000000..1c03f74 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/README.md b/vendor/doctrine/common/doctrine-common-ac6c39b/README.md new file mode 100644 index 0000000..c63f762 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/README.md @@ -0,0 +1,12 @@ +# Doctrine Common + +[![Build Status](https://secure.travis-ci.org/doctrine/common.png)](http://travis-ci.org/doctrine/common) + +The Doctrine Common project is a library that provides extensions to core PHP functionality. + +## More resources: + +* [Website](http://www.doctrine-project.org) +* [Documentation](http://www.doctrine-project.org/projects/common/current/docs/en) +* [Issue Tracker](http://www.doctrine-project.org/jira/browse/DCOM) +* [Downloads](http://github.com/doctrine/common/downloads) diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_1 b/vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_1 new file mode 100644 index 0000000..891a2e5 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_1 @@ -0,0 +1,39 @@ +This document details all the possible changes that you should investigate when updating +your project from Doctrine Common 2.0.x to 2.1 + +## AnnotationReader changes + +The annotation reader was heavily refactored between 2.0 and 2.1-RC1. In theory the operation of the new reader should be backwards compatible, but it has to be setup differently to work that way: + + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); + // new code necessary starting here + $reader->setIgnoreNotImportedAnnotations(true); + $reader->setEnableParsePhpImports(false); + $reader = new \Doctrine\Common\Annotations\CachedReader( + new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() + ); + +## Annotation Base class or @Annotation + +Beginning after 2.1-RC2 you have to either extend ``Doctrine\Common\Annotations\Annotation`` or add @Annotation to your annotations class-level docblock, otherwise the class will simply be ignored. + +## Removed methods on AnnotationReader + +* AnnotationReader::setAutoloadAnnotations() +* AnnotationReader::getAutoloadAnnotations() +* AnnotationReader::isAutoloadAnnotations() + +## AnnotationRegistry + +Autoloading through the PHP autoloader is removed from the 2.1 AnnotationReader. Instead you have to use the global AnnotationRegistry for loading purposes: + + \Doctrine\Common\Annotations\AnnotationRegistry::registerFile($fileWithAnnotations); + \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($namespace, $dirs = null); + \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces($namespaces); + \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader($callable); + +The $callable for registering a loader accepts a class as first and only parameter and must try to silently autoload it. On success true has to be returned. +The registerAutoloadNamespace function registers a PSR-0 compatible silent autoloader for all classes with the given namespace in the given directories. +If null is passed as directory the include path will be used. + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_2 b/vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_2 new file mode 100644 index 0000000..1d93a13 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/UPGRADE_TO_2_2 @@ -0,0 +1,61 @@ +This document details all the possible changes that you should investigate when +updating your project from Doctrine Common 2.1 to 2.2: + +## Annotation Changes + +- AnnotationReader::setIgnoreNotImportedAnnotations has been removed, you need to + add ignore annotation names which are supposed to be ignored via + AnnotationReader::addGlobalIgnoredName + +- AnnotationReader::setAutoloadAnnotations was deprecated by the AnnotationRegistry + in 2.1 and has been removed in 2.2 + +- AnnotationReader::setEnableParsePhpImports was added to ease transition to the new + annotation mechanism in 2.1 and is removed in 2.2 + +- AnnotationReader::isParsePhpImportsEnabled is removed (see above) + +- AnnotationReader::setDefaultAnnotationNamespace was deprecated in favor of explicit + configuration in 2.1 and will be removed in 2.2 (for isolated projects where you + have full-control over _all_ available annotations, we offer a dedicated reader + class ``SimpleAnnotationReader``) + +- AnnotationReader::setAnnotationCreationFunction was deprecated in 2.1 and will be + removed in 2.2. We only offer two creation mechanisms which cannot be changed + anymore to allow the same reader instance to work with all annotations regardless + of which library they are coming from. + +- AnnotationReader::setAnnotationNamespaceAlias was deprecated in 2.1 and will be + removed in 2.2 (see setDefaultAnnotationNamespace) + +- If you use a class as annotation which has not the @Annotation marker in it's + class block, we will now throw an exception instead of silently ignoring it. You + can however still achieve the previous behavior using the @IgnoreAnnotation, or + AnnotationReader::addGlobalIgnoredName (the exception message will contain detailed + instructions when you run into this problem). + +## Cache Changes + +- Renamed old AbstractCache to CacheProvider + +- Dropped the support to the following functions of all cache providers: + + - CacheProvider::deleteByWildcard + + - CacheProvider::deleteByRegEx + + - CacheProvider::deleteByPrefix + + - CacheProvider::deleteBySuffix + +- CacheProvider::deleteAll will not remove ALL entries, it will only mark them as invalid + +- CacheProvider::flushAll will remove ALL entries, namespaced or not + +- Added support to MemcachedCache + +- Added support to WincacheCache + +## ClassLoader Changes + +- ClassLoader::fileExistsInIncludePath() no longer exists. Use the native stream_resolve_include_path() PHP function \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/build.properties b/vendor/doctrine/common/doctrine-common-ac6c39b/build.properties new file mode 100644 index 0000000..ff311a4 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/build.properties @@ -0,0 +1,6 @@ +# Project Name +project.name=DoctrineCommon + +# Version class and file +project.version_class = Doctrine\Common\Version +project.version_file = lib/Doctrine/Common/Version.php diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/build.xml b/vendor/doctrine/common/doctrine-common-ac6c39b/build.xml new file mode 100644 index 0000000..71a9a50 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/build.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DoctrineCommon + Doctrine Common PHP Extensions + pear.doctrine-project.org + The Doctrine Common package contains shared code between the other packages. + + + + + LGPL + + + - + + + + + + + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/composer.json b/vendor/doctrine/common/doctrine-common-ac6c39b/composer.json new file mode 100644 index 0000000..7780d93 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "doctrine/common", + "type": "library","version":"2.2.2", + "description": "Common Library for Doctrine projects", + "keywords": ["collections", "spl", "eventmanager", "annotations", "persistence"], + "homepage": "http://www.doctrine-project.org", + "license": "LGPL", + "authors": [ + {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, + {"name": "Roman Borschel", "email": "roman@code-factory.org"}, + {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, + {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, + {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} + ], + "require": { + "php": ">=5.3.2" + }, + "autoload": { + "psr-0": { "Doctrine\\Common": "lib/" } + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation.php new file mode 100644 index 0000000..6251252 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation.php @@ -0,0 +1,75 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +/** + * Annotations class + * + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +class Annotation +{ + /** + * Value property. Common among all derived classes. + * + * @var string + */ + public $value; + + /** + * Constructor + * + * @param array $data Key-value for properties to be defined in this class + */ + public final function __construct(array $data) + { + foreach ($data as $key => $value) { + $this->$key = $value; + } + } + + /** + * Error handler for unknown property accessor in Annotation class. + * + * @param string $name Unknown property name + */ + public function __get($name) + { + throw new \BadMethodCallException( + sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this)) + ); + } + + /** + * Error handler for unknown property mutator in Annotation class. + * + * @param string $name Unkown property name + * @param mixed $value Property value + */ + public function __set($name, $value) + { + throw new \BadMethodCallException( + sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this)) + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attribute.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attribute.php new file mode 100644 index 0000000..21597b1 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attribute.php @@ -0,0 +1,47 @@ +. + */ + +namespace Doctrine\Common\Annotations\Annotation; + +/** + * Annotation that can be used to signal to the parser + * to check the attribute type during the parsing process. + * + * @author Fabio B. Silva + * + * @Annotation + */ +final class Attribute +{ + /** + * @var string + */ + public $name; + + /** + * @var string + */ + public $type; + + /** + * @var boolean + */ + public $required = false; +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attributes.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attributes.php new file mode 100644 index 0000000..6e314be --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Attributes.php @@ -0,0 +1,37 @@ +. + */ + +namespace Doctrine\Common\Annotations\Annotation; + +/** + * Annotation that can be used to signal to the parser + * to check the types of all declared attributes during the parsing process. + * + * @author Fabio B. Silva + * + * @Annotation + */ +final class Attributes +{ + /** + * @var array + */ + public $value; +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php new file mode 100644 index 0000000..1b2b20a --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php @@ -0,0 +1,44 @@ +. + */ + +namespace Doctrine\Common\Annotations\Annotation; + +/** + * Annotation that can be used to signal to the parser to ignore specific + * annotations during the parsing process. + * + * @Annotation + * @author Johannes M. Schmitt + */ +final class IgnoreAnnotation +{ + public $names; + + public function __construct(array $values) + { + if (is_string($values['value'])) { + $values['value'] = array($values['value']); + } + if (!is_array($values['value'])) { + throw new \RuntimeException(sprintf('@IgnoreAnnotation expects either a string name, or an array of strings, but got %s.', json_encode($values['value']))); + } + + $this->names = $values['value']; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Required.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Required.php new file mode 100644 index 0000000..7b89a02 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Required.php @@ -0,0 +1,33 @@ +. + */ + +namespace Doctrine\Common\Annotations\Annotation; + +/** + * Annotation that can be used to signal to the parser + * to check if that attribute is required during the parsing process. + * + * @author Fabio B. Silva + * + * @Annotation + */ +final class Required +{ +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Target.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Target.php new file mode 100644 index 0000000..c41896a --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Annotation/Target.php @@ -0,0 +1,105 @@ +. + */ + +namespace Doctrine\Common\Annotations\Annotation; + +/** + * Annotation that can be used to signal to the parser + * to check the annotation target during the parsing process. + * + * @author Fabio B. Silva + * + * @Annotation + */ +final class Target +{ + const TARGET_CLASS = 1; + const TARGET_METHOD = 2; + const TARGET_PROPERTY = 4; + const TARGET_ANNOTATION = 8; + const TARGET_ALL = 15; + + /** + * @var array + */ + private static $map = array( + 'ALL' => self::TARGET_ALL, + 'CLASS' => self::TARGET_CLASS, + 'METHOD' => self::TARGET_METHOD, + 'PROPERTY' => self::TARGET_PROPERTY, + 'ANNOTATION' => self::TARGET_ANNOTATION, + ); + + /** + * @var array + */ + public $value; + + /** + * Targets as bitmask. + * + * @var integer + */ + public $targets; + + /** + * Literal target declaration. + * + * @var integer + */ + public $literal; + + /** + * Annotation construct + * + * @param array $values + */ + public function __construct(array $values) + { + if (!isset($values['value'])){ + $values['value'] = null; + } + if (is_string($values['value'])){ + $values['value'] = array($values['value']); + } + if (!is_array($values['value'])){ + throw new \InvalidArgumentException( + sprintf('@Target expects either a string value, or an array of strings, "%s" given.', + is_object($values['value']) ? get_class($values['value']) : gettype($values['value']) + ) + ); + } + + $bitmask = 0; + foreach ($values['value'] as $literal) { + if(!isset(self::$map[$literal])){ + throw new \InvalidArgumentException( + sprintf('Invalid Target "%s". Available targets: [%s]', + $literal, implode(', ', array_keys(self::$map))) + ); + } + $bitmask += self::$map[$literal]; + } + + $this->targets = $bitmask; + $this->value = $values['value']; + $this->literal = implode(', ', $this->value); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationException.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationException.php new file mode 100644 index 0000000..fdc1913 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationException.php @@ -0,0 +1,111 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +/** + * Description of AnnotationException + * + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +class AnnotationException extends \Exception +{ + /** + * Creates a new AnnotationException describing a Syntax error. + * + * @param string $message Exception message + * @return AnnotationException + */ + public static function syntaxError($message) + { + return new self('[Syntax Error] ' . $message); + } + + /** + * Creates a new AnnotationException describing a Semantical error. + * + * @param string $message Exception message + * @return AnnotationException + */ + public static function semanticalError($message) + { + return new self('[Semantical Error] ' . $message); + } + + /** + * Creates a new AnnotationException describing an error which occurred during + * the creation of the annotation. + * + * @since 2.2 + * @param string $message + * @return AnnotationException + */ + public static function creationError($message) + { + return new self('[Creation Error] ' . $message); + } + + /** + * Creates a new AnnotationException describing an type error of an attribute. + * + * @since 2.2 + * @param string $attributeName + * @param string $annotationName + * @param string $context + * @param string $expected + * @param mixed $actual + * @return AnnotationException + */ + public static function typeError($attributeName, $annotationName, $context, $expected, $actual) + { + return new self(sprintf( + '[Type Error] Attribute "%s" of @%s declared on %s expects %s, but got %s.', + $attributeName, + $annotationName, + $context, + $expected, + is_object($actual) ? 'an instance of '.get_class($actual) : gettype($actual) + )); + } + + /** + * Creates a new AnnotationException describing an required error of an attribute. + * + * @since 2.2 + * @param string $attributeName + * @param string $annotationName + * @param string $context + * @param string $expected + * @return AnnotationException + */ + public static function requiredError($attributeName, $annotationName, $context, $expected) + { + return new self(sprintf( + '[Type Error] Attribute "%s" of @%s declared on %s expects %s. This value should not be null.', + $attributeName, + $annotationName, + $context, + $expected + )); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationReader.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationReader.php new file mode 100644 index 0000000..dda8b23 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationReader.php @@ -0,0 +1,301 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; +use Doctrine\Common\Annotations\Annotation\Target; +use Closure; +use ReflectionClass; +use ReflectionMethod; +use ReflectionProperty; + +/** + * A reader for docblock annotations. + * + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Johannes M. Schmitt + */ +final class AnnotationReader implements Reader +{ + /** + * Global map for imports. + * + * @var array + */ + private static $globalImports = array( + 'ignoreannotation' => 'Doctrine\Common\Annotations\Annotation\IgnoreAnnotation', + ); + + /** + * A list with annotations that are not causing exceptions when not resolved to an annotation class. + * + * The names are case sensitive. + * + * @var array + */ + private static $globalIgnoredNames = array( + 'access'=> true, 'author'=> true, 'copyright'=> true, 'deprecated'=> true, + 'example'=> true, 'ignore'=> true, 'internal'=> true, 'link'=> true, 'see'=> true, + 'since'=> true, 'tutorial'=> true, 'version'=> true, 'package'=> true, + 'subpackage'=> true, 'name'=> true, 'global'=> true, 'param'=> true, + 'return'=> true, 'staticvar'=> true, 'category'=> true, 'staticVar'=> true, + 'static'=> true, 'var'=> true, 'throws'=> true, 'inheritdoc'=> true, + 'inheritDoc'=> true, 'license'=> true, 'todo'=> true, 'deprecated'=> true, + 'deprec'=> true, 'author'=> true, 'property' => true, 'method' => true, + 'abstract'=> true, 'exception'=> true, 'magic' => true, 'api' => true, + 'final'=> true, 'filesource'=> true, 'throw' => true, 'uses' => true, + 'usedby'=> true, 'private' => true, 'Annotation' => true, 'override' => true, + 'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true, + 'Required' => true, 'Attribute' => true, 'Attributes' => true, + 'Target' => true, 'SuppressWarnings' => true, + ); + + /** + * Add a new annotation to the globally ignored annotation names with regard to exception handling. + * + * @param string $name + */ + static public function addGlobalIgnoredName($name) + { + self::$globalIgnoredNames[$name] = true; + } + + /** + * Annotations Parser + * + * @var Doctrine\Common\Annotations\DocParser + */ + private $parser; + + /** + * Annotations Parser used to collect parsing metadata + * + * @var Doctrine\Common\Annotations\DocParser + */ + private $preParser; + + /** + * PHP Parser used to collect imports. + * + * @var Doctrine\Common\Annotations\PhpParser + */ + private $phpParser; + + /** + * In-memory cache mechanism to store imported annotations per class. + * + * @var array + */ + private $imports = array(); + + /** + * In-memory cache mechanism to store ignored annotations per class. + * + * @var array + */ + private $ignoredAnnotationNames = array(); + + /** + * Constructor. + * + * Initializes a new AnnotationReader. + */ + public function __construct() + { + AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php'); + + $this->parser = new DocParser; + + $this->preParser = new DocParser; + $this->preParser->setImports(self::$globalImports); + $this->preParser->setIgnoreNotImportedAnnotations(true); + + $this->phpParser = new PhpParser; + } + + /** + * Gets the annotations applied to a class. + * + * @param ReflectionClass $class The ReflectionClass of the class from which + * the class annotations should be read. + * @return array An array of Annotations. + */ + public function getClassAnnotations(ReflectionClass $class) + { + $this->parser->setTarget(Target::TARGET_CLASS); + $this->parser->setImports($this->getImports($class)); + $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); + + return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName()); + } + + /** + * Gets a class annotation. + * + * @param ReflectionClass $class The ReflectionClass of the class from which + * the class annotations should be read. + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getClassAnnotation(ReflectionClass $class, $annotationName) + { + $annotations = $this->getClassAnnotations($class); + + foreach ($annotations as $annotation) { + if ($annotation instanceof $annotationName) { + return $annotation; + } + } + + return null; + } + + /** + * Gets the annotations applied to a property. + * + * @param ReflectionProperty $property The ReflectionProperty of the property + * from which the annotations should be read. + * @return array An array of Annotations. + */ + public function getPropertyAnnotations(ReflectionProperty $property) + { + $class = $property->getDeclaringClass(); + $context = 'property ' . $class->getName() . "::\$" . $property->getName(); + $this->parser->setTarget(Target::TARGET_PROPERTY); + $this->parser->setImports($this->getImports($class)); + $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); + + return $this->parser->parse($property->getDocComment(), $context); + } + + /** + * Gets a property annotation. + * + * @param ReflectionProperty $property + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getPropertyAnnotation(ReflectionProperty $property, $annotationName) + { + $annotations = $this->getPropertyAnnotations($property); + + foreach ($annotations as $annotation) { + if ($annotation instanceof $annotationName) { + return $annotation; + } + } + + return null; + } + + /** + * Gets the annotations applied to a method. + * + * @param ReflectionMethod $property The ReflectionMethod of the method from which + * the annotations should be read. + * @return array An array of Annotations. + */ + public function getMethodAnnotations(ReflectionMethod $method) + { + $class = $method->getDeclaringClass(); + $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; + $this->parser->setTarget(Target::TARGET_METHOD); + $this->parser->setImports($this->getImports($class)); + $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); + + return $this->parser->parse($method->getDocComment(), $context); + } + + /** + * Gets a method annotation. + * + * @param ReflectionMethod $method + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getMethodAnnotation(ReflectionMethod $method, $annotationName) + { + $annotations = $this->getMethodAnnotations($method); + + foreach ($annotations as $annotation) { + if ($annotation instanceof $annotationName) { + return $annotation; + } + } + + return null; + } + + /** + * Returns the ignored annotations for the given class. + * + * @param ReflectionClass $class + * @return array + */ + private function getIgnoredAnnotationNames(ReflectionClass $class) + { + if (isset($this->ignoredAnnotationNames[$name = $class->getName()])) { + return $this->ignoredAnnotationNames[$name]; + } + $this->collectParsingMetadata($class); + + return $this->ignoredAnnotationNames[$name]; + } + + private function getImports(ReflectionClass $class) + { + if (isset($this->imports[$name = $class->getName()])) { + return $this->imports[$name]; + } + $this->collectParsingMetadata($class); + + return $this->imports[$name]; + } + + /** + * Collects parsing metadata for a given class + * + * @param ReflectionClass $class + */ + private function collectParsingMetadata(ReflectionClass $class) + { + $ignoredAnnotationNames = self::$globalIgnoredNames; + + $annotations = $this->preParser->parse($class->getDocComment(), 'class '.$class->name); + foreach ($annotations as $annotation) { + if ($annotation instanceof IgnoreAnnotation) { + foreach ($annotation->names AS $annot) { + $ignoredAnnotationNames[$annot] = true; + } + } + } + + $name = $class->getName(); + $this->imports[$name] = array_merge( + self::$globalImports, + $this->phpParser->parseClass($class), + array('__NAMESPACE__' => $class->getNamespaceName()) + ); + $this->ignoredAnnotationNames[$name] = $ignoredAnnotationNames; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationRegistry.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationRegistry.php new file mode 100644 index 0000000..60b00f5 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/AnnotationRegistry.php @@ -0,0 +1,129 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +final class AnnotationRegistry +{ + /** + * A map of namespaces to use for autoloading purposes based on a PSR-0 convention. + * + * Contains the namespace as key and an array of directories as value. If the value is NULL + * the include path is used for checking for the corresponding file. + * + * This autoloading mechanism does not utilize the PHP autoloading but implements autoloading on its own. + * + * @var array + */ + static private $autoloadNamespaces = array(); + + /** + * A map of autoloader callables. + * + * @var array + */ + static private $loaders = array(); + + static public function reset() + { + self::$autoloadNamespaces = array(); + self::$loaders = array(); + } + + static public function registerFile($file) + { + require_once $file; + } + + /** + * Add a namespace with one or many directories to look for files or null for the include path. + * + * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. + * + * @param string $namespace + * @param string|array|null $dirs + */ + static public function registerAutoloadNamespace($namespace, $dirs = null) + { + self::$autoloadNamespaces[$namespace] = $dirs; + } + + /** + * Register multiple namespaces + * + * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. + * + * @param array $namespaces + */ + static public function registerAutoloadNamespaces(array $namespaces) + { + self::$autoloadNamespaces = array_merge(self::$autoloadNamespaces, $namespaces); + } + + /** + * Register an autoloading callabale for annotations, much like spl_autoload_register(). + * + * NOTE: These class loaders HAVE to be silent when a class was not found! + * IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class. + * + * @param callabale $callabale + */ + static public function registerLoader($callabale) + { + if (!is_callable($callabale)) { + throw new \InvalidArgumentException("A callable is expected in AnnotationRegistry::registerLoader()."); + } + self::$loaders[] = $callabale; + } + + /** + * Autoload an annotation class silently. + * + * @param string $class + * @return void + */ + static public function loadAnnotationClass($class) + { + foreach (self::$autoloadNamespaces AS $namespace => $dirs) { + if (strpos($class, $namespace) === 0) { + $file = str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php"; + if ($dirs === null) { + if ($path = stream_resolve_include_path($file)) { + require $path; + return true; + } + } else { + foreach((array)$dirs AS $dir) { + if (file_exists($dir . DIRECTORY_SEPARATOR . $file)) { + require $dir . DIRECTORY_SEPARATOR . $file; + return true; + } + } + } + } + } + + foreach (self::$loaders AS $loader) { + if (call_user_func($loader, $class) === true) { + return true; + } + } + return false; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/CachedReader.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/CachedReader.php new file mode 100644 index 0000000..6ea47c6 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/CachedReader.php @@ -0,0 +1,179 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +use Doctrine\Common\Cache\Cache; + +/** + * A cache aware annotation reader. + * + * @author Johannes M. Schmitt + * @author Benjamin Eberlei + */ +final class CachedReader implements Reader +{ + private static $CACHE_SALT = '@[Annot]'; + + /** + * @var Reader + */ + private $delegate; + + /** + * @var Cache + */ + private $cache; + + /** + * @var boolean + */ + private $debug; + + /** + * @var array + */ + private $loadedAnnotations; + + /** + * @param Reader $reader + * @param Cache $cache + */ + public function __construct(Reader $reader, Cache $cache, $debug = false) + { + $this->delegate = $reader; + $this->cache = $cache; + $this->debug = $debug; + } + + public function getClassAnnotations(\ReflectionClass $class) + { + $cacheKey = $class->getName() . self::$CACHE_SALT; + + if (isset($this->loadedAnnotations[$cacheKey])) { + return $this->loadedAnnotations[$cacheKey]; + } + + // Attempt to grab data from cache + if (($data = $this->cache->fetch($cacheKey)) !== false) { + if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) { + return $data; + } + } + + $annots = $this->delegate->getClassAnnotations($class); + $this->cache->save($cacheKey, $annots); + $this->cache->save('[C]'.$cacheKey, time()); + + return $this->loadedAnnotations[$cacheKey] = $annots; + } + + public function getClassAnnotation(\ReflectionClass $class, $annotationName) + { + foreach ($this->getClassAnnotations($class) as $annot) { + if ($annot instanceof $annotationName) { + return $annot; + } + } + + return null; + } + + public function getPropertyAnnotations(\ReflectionProperty $property) + { + $class = $property->getDeclaringClass(); + $cacheKey = $class->getName().'$'.$property->getName().self::$CACHE_SALT; + + if (isset($this->loadedAnnotations[$cacheKey])) { + return $this->loadedAnnotations[$cacheKey]; + } + + // Attempt to grab data from cache + if (($data = $this->cache->fetch($cacheKey)) !== false) { + if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) { + return $data; + } + } + + $annots = $this->delegate->getPropertyAnnotations($property); + $this->cache->save($cacheKey, $annots); + $this->cache->save('[C]'.$cacheKey, time()); + + return $this->loadedAnnotations[$cacheKey] = $annots; + } + + public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) + { + foreach ($this->getPropertyAnnotations($property) as $annot) { + if ($annot instanceof $annotationName) { + return $annot; + } + } + + return null; + } + + public function getMethodAnnotations(\ReflectionMethod $method) + { + $class = $method->getDeclaringClass(); + $cacheKey = $class->getName().'#'.$method->getName().self::$CACHE_SALT; + + if (isset($this->loadedAnnotations[$cacheKey])) { + return $this->loadedAnnotations[$cacheKey]; + } + + // Attempt to grab data from cache + if (($data = $this->cache->fetch($cacheKey)) !== false) { + if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) { + return $data; + } + } + + $annots = $this->delegate->getMethodAnnotations($method); + $this->cache->save($cacheKey, $annots); + $this->cache->save('[C]'.$cacheKey, time()); + + return $this->loadedAnnotations[$cacheKey] = $annots; + } + + public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) + { + foreach ($this->getMethodAnnotations($method) as $annot) { + if ($annot instanceof $annotationName) { + return $annot; + } + } + + return null; + } + + public function clearLoadedAnnotations() + { + $this->loadedAnnotations = array(); + } + + private function isCacheFresh($cacheKey, \ReflectionClass $class) + { + if (false === $filename = $class->getFilename()) { + return true; + } + + return $this->cache->fetch('[C]'.$cacheKey) >= filemtime($filename); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocLexer.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocLexer.php new file mode 100644 index 0000000..c6223e3 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocLexer.php @@ -0,0 +1,140 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +use Doctrine\Common\Lexer; + +/** + * Simple lexer for docblock annotations. + * + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Johannes M. Schmitt + */ +final class DocLexer extends Lexer +{ + const T_NONE = 1; + const T_IDENTIFIER = 2; + const T_INTEGER = 3; + const T_STRING = 4; + const T_FLOAT = 5; + + const T_AT = 101; + const T_CLOSE_CURLY_BRACES = 102; + const T_CLOSE_PARENTHESIS = 103; + const T_COMMA = 104; + const T_EQUALS = 105; + const T_FALSE = 106; + const T_NAMESPACE_SEPARATOR = 107; + const T_OPEN_CURLY_BRACES = 108; + const T_OPEN_PARENTHESIS = 109; + const T_TRUE = 110; + const T_NULL = 111; + const T_COLON = 112; + + /** + * @inheritdoc + */ + protected function getCatchablePatterns() + { + return array( + '[a-z_][a-z0-9_:]*', + '(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?', + '"(?:[^"]|"")*"', + ); + } + + /** + * @inheritdoc + */ + protected function getNonCatchablePatterns() + { + return array('\s+', '\*+', '(.)'); + } + + /** + * @inheritdoc + */ + protected function getType(&$value) + { + $type = self::T_NONE; + + // Checking numeric value + if (is_numeric($value)) { + return (strpos($value, '.') !== false || stripos($value, 'e') !== false) + ? self::T_FLOAT : self::T_INTEGER; + } + + if ($value[0] === '"') { + $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2)); + + return self::T_STRING; + } else { + switch (strtolower($value)) { + case '@': + return self::T_AT; + + case ',': + return self::T_COMMA; + + case '(': + return self::T_OPEN_PARENTHESIS; + + case ')': + return self::T_CLOSE_PARENTHESIS; + + case '{': + return self::T_OPEN_CURLY_BRACES; + + case '}': + return self::T_CLOSE_CURLY_BRACES; + + case '=': + return self::T_EQUALS; + + case '\\': + return self::T_NAMESPACE_SEPARATOR; + + case 'true': + return self::T_TRUE; + + case 'false': + return self::T_FALSE; + + case 'null': + return self::T_NULL; + + case ':': + return self::T_COLON; + + default: + if (ctype_alpha($value[0]) || $value[0] === '_') { + return self::T_IDENTIFIER; + } + + break; + } + } + + return $type; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocParser.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocParser.php new file mode 100644 index 0000000..9d16b17 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/DocParser.php @@ -0,0 +1,891 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +use Closure; +use ReflectionClass; +use Doctrine\Common\Annotations\Annotation\Target; +use Doctrine\Common\Annotations\Annotation\Attribute; +use Doctrine\Common\Annotations\Annotation\Attributes; + +/** + * A parser for docblock annotations. + * + * It is strongly discouraged to change the default annotation parsing process. + * + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Johannes M. Schmitt + * @author Fabio B. Silva + */ +final class DocParser +{ + /** + * An array of all valid tokens for a class name. + * + * @var array + */ + private static $classIdentifiers = array(DocLexer::T_IDENTIFIER, DocLexer::T_TRUE, DocLexer::T_FALSE, DocLexer::T_NULL); + + /** + * The lexer. + * + * @var Doctrine\Common\Annotations\DocLexer + */ + private $lexer; + + /** + * Current target context + * + * @var string + */ + private $target; + + /** + * Doc Parser used to collect annotation target + * + * @var Doctrine\Common\Annotations\DocParser + */ + private static $metadataParser; + + /** + * Flag to control if the current annotation is nested or not. + * + * @var boolean + */ + private $isNestedAnnotation = false; + + /** + * Hashmap containing all use-statements that are to be used when parsing + * the given doc block. + * + * @var array + */ + private $imports = array(); + + /** + * This hashmap is used internally to cache results of class_exists() + * look-ups. + * + * @var array + */ + private $classExists = array(); + + /** + * Whether annotations that have not been imported should be ignored. + * + * @var boolean + */ + private $ignoreNotImportedAnnotations = false; + + /** + * An array of default namespaces if operating in simple mode. + * + * @var array + */ + private $namespaces = array(); + + /** + * A list with annotations that are not causing exceptions when not resolved to an annotation class. + * + * The names must be the raw names as used in the class, not the fully qualified + * class names. + * + * @var array + */ + private $ignoredAnnotationNames = array(); + + /** + * @var string + */ + private $context = ''; + + /** + * Hash-map for caching annotation metadata + * @var array + */ + private static $annotationMetadata = array( + 'Doctrine\Common\Annotations\Annotation\Target' => array( + 'is_annotation' => true, + 'has_constructor' => true, + 'properties' => array(), + 'targets_literal' => 'ANNOTATION_CLASS', + 'targets' => Target::TARGET_CLASS, + 'default_property' => 'value', + 'attribute_types' => array( + 'value' => array( + 'required' => false, + 'type' =>'array', + 'array_type'=>'string', + 'value' =>'array' + ) + ), + ), + 'Doctrine\Common\Annotations\Annotation\Attribute' => array( + 'is_annotation' => true, + 'has_constructor' => false, + 'targets_literal' => 'ANNOTATION_ANNOTATION', + 'targets' => Target::TARGET_ANNOTATION, + 'default_property' => 'name', + 'properties' => array( + 'name' => 'name', + 'type' => 'type', + 'required' => 'required' + ), + 'attribute_types' => array( + 'value' => array( + 'required' => true, + 'type' =>'string', + 'value' =>'string' + ), + 'type' => array( + 'required' =>true, + 'type' =>'string', + 'value' =>'string' + ), + 'required' => array( + 'required' =>false, + 'type' =>'boolean', + 'value' =>'boolean' + ) + ), + ), + 'Doctrine\Common\Annotations\Annotation\Attributes' => array( + 'is_annotation' => true, + 'has_constructor' => false, + 'targets_literal' => 'ANNOTATION_CLASS', + 'targets' => Target::TARGET_CLASS, + 'default_property' => 'value', + 'properties' => array( + 'value' => 'value' + ), + 'attribute_types' => array( + 'value' => array( + 'type' =>'array', + 'required' =>true, + 'array_type'=>'Doctrine\Common\Annotations\Annotation\Attribute', + 'value' =>'array' + ) + ), + ), + ); + + /** + * Hash-map for handle types declaration + * + * @var array + */ + private static $typeMap = array( + 'float' => 'double', + 'bool' => 'boolean', + // allow uppercase Boolean in honor of George Boole + 'Boolean' => 'boolean', + 'int' => 'integer', + ); + + /** + * Constructs a new DocParser. + */ + public function __construct() + { + $this->lexer = new DocLexer; + } + + /** + * Sets the annotation names that are ignored during the parsing process. + * + * The names are supposed to be the raw names as used in the class, not the + * fully qualified class names. + * + * @param array $names + */ + public function setIgnoredAnnotationNames(array $names) + { + $this->ignoredAnnotationNames = $names; + } + + public function setIgnoreNotImportedAnnotations($bool) + { + $this->ignoreNotImportedAnnotations = (Boolean) $bool; + } + + /** + * Sets the default namespaces. + * @param array $namespaces + */ + public function addNamespace($namespace) + { + if ($this->imports) { + throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.'); + } + $this->namespaces[] = $namespace; + } + + public function setImports(array $imports) + { + if ($this->namespaces) { + throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.'); + } + $this->imports = $imports; + } + + /** + * Sets current target context as bitmask. + * + * @param integer $target + */ + public function setTarget($target) + { + $this->target = $target; + } + + /** + * Parses the given docblock string for annotations. + * + * @param string $input The docblock string to parse. + * @param string $context The parsing context. + * @return array Array of annotations. If no annotations are found, an empty array is returned. + */ + public function parse($input, $context = '') + { + if (false === $pos = strpos($input, '@')) { + return array(); + } + + // also parse whatever character is before the @ + if ($pos > 0) { + $pos -= 1; + } + + $this->context = $context; + $this->lexer->setInput(trim(substr($input, $pos), '* /')); + $this->lexer->moveNext(); + + return $this->Annotations(); + } + + /** + * Attempts to match the given token with the current lookahead token. + * If they match, updates the lookahead token; otherwise raises a syntax error. + * + * @param int Token type. + * @return bool True if tokens match; false otherwise. + */ + private function match($token) + { + if ( ! $this->lexer->isNextToken($token) ) { + $this->syntaxError($this->lexer->getLiteral($token)); + } + + return $this->lexer->moveNext(); + } + + /** + * Attempts to match the current lookahead token with any of the given tokens. + * + * If any of them matches, this method updates the lookahead token; otherwise + * a syntax error is raised. + * + * @param array $tokens + * @return bool + */ + private function matchAny(array $tokens) + { + if ( ! $this->lexer->isNextTokenAny($tokens)) { + $this->syntaxError(implode(' or ', array_map(array($this->lexer, 'getLiteral'), $tokens))); + } + + return $this->lexer->moveNext(); + } + + /** + * Generates a new syntax error. + * + * @param string $expected Expected string. + * @param array $token Optional token. + * @throws SyntaxException + */ + private function syntaxError($expected, $token = null) + { + if ($token === null) { + $token = $this->lexer->lookahead; + } + + $message = "Expected {$expected}, got "; + + if ($this->lexer->lookahead === null) { + $message .= 'end of string'; + } else { + $message .= "'{$token['value']}' at position {$token['position']}"; + } + + if (strlen($this->context)) { + $message .= ' in ' . $this->context; + } + + $message .= '.'; + + throw AnnotationException::syntaxError($message); + } + + /** + * Attempt to check if a class exists or not. This never goes through the PHP autoloading mechanism + * but uses the {@link AnnotationRegistry} to load classes. + * + * @param string $fqcn + * @return boolean + */ + private function classExists($fqcn) + { + if (isset($this->classExists[$fqcn])) { + return $this->classExists[$fqcn]; + } + + // first check if the class already exists, maybe loaded through another AnnotationReader + if (class_exists($fqcn, false)) { + return $this->classExists[$fqcn] = true; + } + + // final check, does this class exist? + return $this->classExists[$fqcn] = AnnotationRegistry::loadAnnotationClass($fqcn); + } + + /** + * Collects parsing metadata for a given annotation class + * + * @param string $name The annotation name + */ + private function collectAnnotationMetadata($name) + { + if (self::$metadataParser == null){ + self::$metadataParser = new self(); + self::$metadataParser->setTarget(Target::TARGET_CLASS); + self::$metadataParser->setIgnoreNotImportedAnnotations(true); + self::$metadataParser->setImports(array( + 'target' => 'Doctrine\Common\Annotations\Annotation\Target', + 'attribute' => 'Doctrine\Common\Annotations\Annotation\Attribute', + 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes' + )); + AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Target.php'); + AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attribute.php'); + AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attributes.php'); + } + + $class = new \ReflectionClass($name); + $docComment = $class->getDocComment(); + + // Sets default values for annotation metadata + $metadata = array( + 'default_property' => null, + 'has_constructor' => (null !== $constructor = $class->getConstructor()) && $constructor->getNumberOfParameters() > 0, + 'properties' => array(), + 'property_types' => array(), + 'attribute_types' => array(), + 'targets_literal' => null, + 'targets' => Target::TARGET_ALL, + 'is_annotation' => false !== strpos($docComment, '@Annotation'), + ); + + // verify that the class is really meant to be an annotation + if ($metadata['is_annotation']) { + foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { + if ($annotation instanceof Target) { + $metadata['targets'] = $annotation->targets; + $metadata['targets_literal'] = $annotation->literal; + + } elseif ($annotation instanceof Attributes) { + foreach ($annotation->value as $attrib) { + // handle internal type declaration + $type = isset(self::$typeMap[$attrib->type]) ? self::$typeMap[$attrib->type] : $attrib->type; + + // handle the case if the property type is mixed + if ('mixed' !== $type) { + // Checks if the property has array + if (false !== $pos = strpos($type, '<')) { + $arrayType = substr($type, $pos+1, -1); + $type = 'array'; + + if (isset(self::$typeMap[$arrayType])) { + $arrayType = self::$typeMap[$arrayType]; + } + + $metadata['attribute_types'][$attrib->name]['array_type'] = $arrayType; + } + + $metadata['attribute_types'][$attrib->name]['type'] = $type; + $metadata['attribute_types'][$attrib->name]['value'] = $attrib->type; + $metadata['attribute_types'][$attrib->name]['required'] = $attrib->required; + } + } + } + } + + // if not has a constructor will inject values into public properties + if (false === $metadata['has_constructor']) { + // collect all public properties + foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $metadata['properties'][$property->name] = $property->name; + + // checks if the property has @var annotation + if ((false !== $propertyComment = $property->getDocComment()) + && false !== strpos($propertyComment, '@var') + && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) { + // literal type declaration + $value = $matches[1]; + + // handle internal type declaration + $type = isset(self::$typeMap[$value]) ? self::$typeMap[$value] : $value; + + // handle the case if the property type is mixed + if ('mixed' !== $type) { + // Checks if the property has @var array annotation + if (false !== $pos = strpos($type, '<')) { + $arrayType = substr($type, $pos+1, -1); + $type = 'array'; + + if (isset(self::$typeMap[$arrayType])) { + $arrayType = self::$typeMap[$arrayType]; + } + + $metadata['attribute_types'][$property->name]['array_type'] = $arrayType; + } + + $metadata['attribute_types'][$property->name]['type'] = $type; + $metadata['attribute_types'][$property->name]['value'] = $value; + $metadata['attribute_types'][$property->name]['required'] = false !== strpos($propertyComment, '@Required'); + } + } + } + + // choose the first property as default property + $metadata['default_property'] = reset($metadata['properties']); + } + } + + self::$annotationMetadata[$name] = $metadata; + } + + /** + * Annotations ::= Annotation {[ "*" ]* [Annotation]}* + * + * @return array + */ + private function Annotations() + { + $annotations = array(); + + while (null !== $this->lexer->lookahead) { + if (DocLexer::T_AT !== $this->lexer->lookahead['type']) { + $this->lexer->moveNext(); + continue; + } + + // make sure the @ is preceded by non-catchable pattern + if (null !== $this->lexer->token && $this->lexer->lookahead['position'] === $this->lexer->token['position'] + strlen($this->lexer->token['value'])) { + $this->lexer->moveNext(); + continue; + } + + // make sure the @ is followed by either a namespace separator, or + // an identifier token + if ((null === $peek = $this->lexer->glimpse()) + || (DocLexer::T_NAMESPACE_SEPARATOR !== $peek['type'] && !in_array($peek['type'], self::$classIdentifiers, true)) + || $peek['position'] !== $this->lexer->lookahead['position'] + 1) { + $this->lexer->moveNext(); + continue; + } + + $this->isNestedAnnotation = false; + if (false !== $annot = $this->Annotation()) { + $annotations[] = $annot; + } + } + + return $annotations; + } + + /** + * Annotation ::= "@" AnnotationName ["(" [Values] ")"] + * AnnotationName ::= QualifiedName | SimpleName + * QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName + * NameSpacePart ::= identifier | null | false | true + * SimpleName ::= identifier | null | false | true + * + * @return mixed False if it is not a valid annotation. + */ + private function Annotation() + { + $this->match(DocLexer::T_AT); + + // check if we have an annotation + if ($this->lexer->isNextTokenAny(self::$classIdentifiers)) { + $this->lexer->moveNext(); + $name = $this->lexer->token['value']; + } else if ($this->lexer->isNextToken(DocLexer::T_NAMESPACE_SEPARATOR)) { + $name = ''; + } else { + $this->syntaxError('namespace separator or identifier'); + } + + while ($this->lexer->lookahead['position'] === $this->lexer->token['position'] + strlen($this->lexer->token['value']) && $this->lexer->isNextToken(DocLexer::T_NAMESPACE_SEPARATOR)) { + $this->match(DocLexer::T_NAMESPACE_SEPARATOR); + $this->matchAny(self::$classIdentifiers); + $name .= '\\'.$this->lexer->token['value']; + } + + // only process names which are not fully qualified, yet + // fully qualified names must start with a \ + $originalName = $name; + if ('\\' !== $name[0]) { + $alias = (false === $pos = strpos($name, '\\'))? $name : substr($name, 0, $pos); + + $found = false; + if ($this->namespaces) { + foreach ($this->namespaces as $namespace) { + if ($this->classExists($namespace.'\\'.$name)) { + $name = $namespace.'\\'.$name; + $found = true; + break; + } + } + } elseif (isset($this->imports[$loweredAlias = strtolower($alias)])) { + if (false !== $pos) { + $name = $this->imports[$loweredAlias].substr($name, $pos); + } else { + $name = $this->imports[$loweredAlias]; + } + $found = true; + } elseif (isset($this->imports['__NAMESPACE__']) && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name)) { + $name = $this->imports['__NAMESPACE__'].'\\'.$name; + $found = true; + } elseif ($this->classExists($name)) { + $found = true; + } + + if (!$found) { + if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$name])) { + return false; + } + + throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s was never imported. Did you maybe forget to add a "use" statement for this annotation?', $name, $this->context)); + } + } + + if (!$this->classExists($name)) { + throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); + } + + // at this point, $name contains the fully qualified class name of the + // annotation, and it is also guaranteed that this class exists, and + // that it is loaded + + + // collects the metadata annotation only if there is not yet + if (!isset(self::$annotationMetadata[$name])) { + $this->collectAnnotationMetadata($name); + } + + // verify that the class is really meant to be an annotation and not just any ordinary class + if (self::$annotationMetadata[$name]['is_annotation'] === false) { + if (isset($this->ignoredAnnotationNames[$originalName])) { + return false; + } + + throw AnnotationException::semanticalError(sprintf('The class "%s" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "%s". If it is indeed no annotation, then you need to add @IgnoreAnnotation("%s") to the _class_ doc comment of %s.', $name, $name, $originalName, $this->context)); + } + + //if target is nested annotation + $target = $this->isNestedAnnotation ? Target::TARGET_ANNOTATION : $this->target; + + // Next will be nested + $this->isNestedAnnotation = true; + + //if annotation does not support current target + if (0 === (self::$annotationMetadata[$name]['targets'] & $target) && $target) { + throw AnnotationException::semanticalError( + sprintf('Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.', + $originalName, $this->context, self::$annotationMetadata[$name]['targets_literal']) + ); + } + + $values = array(); + if ($this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) { + $this->match(DocLexer::T_OPEN_PARENTHESIS); + + if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) { + $values = $this->Values(); + } + + $this->match(DocLexer::T_CLOSE_PARENTHESIS); + } + + // checks all declared attributes + foreach (self::$annotationMetadata[$name]['attribute_types'] as $property => $type) { + if ($property === self::$annotationMetadata[$name]['default_property'] + && !isset($values[$property]) && isset($values['value'])) { + $property = 'value'; + } + + // handle a not given attribute or null value + if (!isset($values[$property])) { + if ($type['required']) { + throw AnnotationException::requiredError($property, $originalName, $this->context, 'a(n) '.$type['value']); + } + + continue; + } + + if ($type['type'] === 'array') { + // handle the case of a single value + if (!is_array($values[$property])) { + $values[$property] = array($values[$property]); + } + + // checks if the attribute has array type declaration, such as "array" + if (isset($type['array_type'])) { + foreach ($values[$property] as $item) { + if (gettype($item) !== $type['array_type'] && !$item instanceof $type['array_type']) { + throw AnnotationException::typeError($property, $originalName, $this->context, 'either a(n) '.$type['array_type'].', or an array of '.$type['array_type'].'s', $item); + } + } + } + } elseif (gettype($values[$property]) !== $type['type'] && !$values[$property] instanceof $type['type']) { + throw AnnotationException::typeError($property, $originalName, $this->context, 'a(n) '.$type['value'], $values[$property]); + } + } + + // check if the annotation expects values via the constructor, + // or directly injected into public properties + if (self::$annotationMetadata[$name]['has_constructor'] === true) { + return new $name($values); + } + + $instance = new $name(); + foreach ($values as $property => $value) { + if (!isset(self::$annotationMetadata[$name]['properties'][$property])) { + if ('value' !== $property) { + throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not have a property named "%s". Available properties: %s', $originalName, $this->context, $property, implode(', ', self::$annotationMetadata[$name]['properties']))); + } + + // handle the case if the property has no annotations + if (!$property = self::$annotationMetadata[$name]['default_property']) { + throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not accept any values, but got %s.', $originalName, $this->context, json_encode($values))); + } + } + + $instance->{$property} = $value; + } + + return $instance; + } + + /** + * Values ::= Array | Value {"," Value}* + * + * @return array + */ + private function Values() + { + $values = array(); + + // Handle the case of a single array as value, i.e. @Foo({....}) + if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) { + $values['value'] = $this->Value(); + return $values; + } + + $values[] = $this->Value(); + + while ($this->lexer->isNextToken(DocLexer::T_COMMA)) { + $this->match(DocLexer::T_COMMA); + $token = $this->lexer->lookahead; + $value = $this->Value(); + + if ( ! is_object($value) && ! is_array($value)) { + $this->syntaxError('Value', $token); + } + + $values[] = $value; + } + + foreach ($values as $k => $value) { + if (is_object($value) && $value instanceof \stdClass) { + $values[$value->name] = $value->value; + } else if ( ! isset($values['value'])){ + $values['value'] = $value; + } else { + if ( ! is_array($values['value'])) { + $values['value'] = array($values['value']); + } + + $values['value'][] = $value; + } + + unset($values[$k]); + } + + return $values; + } + + /** + * Value ::= PlainValue | FieldAssignment + * + * @return mixed + */ + private function Value() + { + $peek = $this->lexer->glimpse(); + + if (DocLexer::T_EQUALS === $peek['type']) { + return $this->FieldAssignment(); + } + + return $this->PlainValue(); + } + + /** + * PlainValue ::= integer | string | float | boolean | Array | Annotation + * + * @return mixed + */ + private function PlainValue() + { + if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) { + return $this->Arrayx(); + } + + if ($this->lexer->isNextToken(DocLexer::T_AT)) { + return $this->Annotation(); + } + + switch ($this->lexer->lookahead['type']) { + case DocLexer::T_STRING: + $this->match(DocLexer::T_STRING); + return $this->lexer->token['value']; + + case DocLexer::T_INTEGER: + $this->match(DocLexer::T_INTEGER); + return (int)$this->lexer->token['value']; + + case DocLexer::T_FLOAT: + $this->match(DocLexer::T_FLOAT); + return (float)$this->lexer->token['value']; + + case DocLexer::T_TRUE: + $this->match(DocLexer::T_TRUE); + return true; + + case DocLexer::T_FALSE: + $this->match(DocLexer::T_FALSE); + return false; + + case DocLexer::T_NULL: + $this->match(DocLexer::T_NULL); + return null; + + default: + $this->syntaxError('PlainValue'); + } + } + + /** + * FieldAssignment ::= FieldName "=" PlainValue + * FieldName ::= identifier + * + * @return array + */ + private function FieldAssignment() + { + $this->match(DocLexer::T_IDENTIFIER); + $fieldName = $this->lexer->token['value']; + + $this->match(DocLexer::T_EQUALS); + + $item = new \stdClass(); + $item->name = $fieldName; + $item->value = $this->PlainValue(); + + return $item; + } + + /** + * Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}" + * + * @return array + */ + private function Arrayx() + { + $array = $values = array(); + + $this->match(DocLexer::T_OPEN_CURLY_BRACES); + $values[] = $this->ArrayEntry(); + + while ($this->lexer->isNextToken(DocLexer::T_COMMA)) { + $this->match(DocLexer::T_COMMA); + + // optional trailing comma + if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) { + break; + } + + $values[] = $this->ArrayEntry(); + } + + $this->match(DocLexer::T_CLOSE_CURLY_BRACES); + + foreach ($values as $value) { + list ($key, $val) = $value; + + if ($key !== null) { + $array[$key] = $val; + } else { + $array[] = $val; + } + } + + return $array; + } + + /** + * ArrayEntry ::= Value | KeyValuePair + * KeyValuePair ::= Key ("=" | ":") PlainValue + * Key ::= string | integer + * + * @return array + */ + private function ArrayEntry() + { + $peek = $this->lexer->glimpse(); + + if (DocLexer::T_EQUALS === $peek['type'] + || DocLexer::T_COLON === $peek['type']) { + $this->matchAny(array(DocLexer::T_INTEGER, DocLexer::T_STRING)); + + $key = $this->lexer->token['value']; + $this->matchAny(array(DocLexer::T_EQUALS, DocLexer::T_COLON)); + + return array($key, $this->PlainValue()); + } + + return array(null, $this->Value()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/FileCacheReader.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/FileCacheReader.php new file mode 100644 index 0000000..4a42b58 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/FileCacheReader.php @@ -0,0 +1,209 @@ +. + */ + +namespace Doctrine\Common\Annotations; + + +/** + * File cache reader for annotations. + * + * @author Johannes M. Schmitt + * @author Benjamin Eberlei + */ +class FileCacheReader implements Reader +{ + /** + * @var Reader + */ + private $reader; + private $dir; + private $debug; + private $loadedAnnotations = array(); + + public function __construct(Reader $reader, $cacheDir, $debug = false) + { + $this->reader = $reader; + if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true)) { + throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $cacheDir)); + } + if (!is_writable($cacheDir)) { + throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $cacheDir)); + } + + $this->dir = rtrim($cacheDir, '\\/'); + $this->debug = $debug; + } + + public function getClassAnnotations(\ReflectionClass $class) + { + $key = $class->getName(); + + if (isset($this->loadedAnnotations[$key])) { + return $this->loadedAnnotations[$key]; + } + + $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; + if (!file_exists($path)) { + $annot = $this->reader->getClassAnnotations($class); + $this->saveCacheFile($path, $annot); + return $this->loadedAnnotations[$key] = $annot; + } + + if ($this->debug + && (false !== $filename = $class->getFilename()) + && filemtime($path) < filemtime($filename)) { + @unlink($path); + + $annot = $this->reader->getClassAnnotations($class); + $this->saveCacheFile($path, $annot); + return $this->loadedAnnotations[$key] = $annot; + } + + return $this->loadedAnnotations[$key] = include $path; + } + + public function getPropertyAnnotations(\ReflectionProperty $property) + { + $class = $property->getDeclaringClass(); + $key = $class->getName().'$'.$property->getName(); + + if (isset($this->loadedAnnotations[$key])) { + return $this->loadedAnnotations[$key]; + } + + $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; + if (!file_exists($path)) { + $annot = $this->reader->getPropertyAnnotations($property); + $this->saveCacheFile($path, $annot); + return $this->loadedAnnotations[$key] = $annot; + } + + if ($this->debug + && (false !== $filename = $class->getFilename()) + && filemtime($path) < filemtime($filename)) { + unlink($path); + + $annot = $this->reader->getPropertyAnnotations($property); + $this->saveCacheFile($path, $annot); + return $this->loadedAnnotations[$key] = $annot; + } + + return $this->loadedAnnotations[$key] = include $path; + } + + public function getMethodAnnotations(\ReflectionMethod $method) + { + $class = $method->getDeclaringClass(); + $key = $class->getName().'#'.$method->getName(); + + if (isset($this->loadedAnnotations[$key])) { + return $this->loadedAnnotations[$key]; + } + + $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php'; + if (!file_exists($path)) { + $annot = $this->reader->getMethodAnnotations($method); + $this->saveCacheFile($path, $annot); + return $this->loadedAnnotations[$key] = $annot; + } + + if ($this->debug + && (false !== $filename = $class->getFilename()) + && filemtime($path) < filemtime($filename)) { + unlink($path); + + $annot = $this->reader->getMethodAnnotations($method); + $this->saveCacheFile($path, $annot); + return $this->loadedAnnotations[$key] = $annot; + } + + return $this->loadedAnnotations[$key] = include $path; + } + + private function saveCacheFile($path, $data) + { + file_put_contents($path, 'getClassAnnotations($class); + + foreach ($annotations as $annotation) { + if ($annotation instanceof $annotationName) { + return $annotation; + } + } + + return null; + } + + /** + * Gets a method annotation. + * + * @param ReflectionMethod $method + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) + { + $annotations = $this->getMethodAnnotations($method); + + foreach ($annotations as $annotation) { + if ($annotation instanceof $annotationName) { + return $annotation; + } + } + + return null; + } + + /** + * Gets a property annotation. + * + * @param ReflectionProperty $property + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) + { + $annotations = $this->getPropertyAnnotations($property); + + foreach ($annotations as $annotation) { + if ($annotation instanceof $annotationName) { + return $annotation; + } + } + + return null; + } + + public function clearLoadedAnnotations() + { + $this->loadedAnnotations = array(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/IndexedReader.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/IndexedReader.php new file mode 100644 index 0000000..1eea492 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/IndexedReader.php @@ -0,0 +1,94 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +use Doctrine\Common\Annotations\Reader; + +/** + * Allows the reader to be used in-place of Doctrine's reader. + * + * @author Johannes M. Schmitt + */ +class IndexedReader implements Reader +{ + private $delegate; + + public function __construct(Reader $reader) + { + $this->delegate = $reader; + } + + public function getClassAnnotations(\ReflectionClass $class) + { + $annotations = array(); + foreach ($this->delegate->getClassAnnotations($class) as $annot) { + $annotations[get_class($annot)] = $annot; + } + + return $annotations; + } + + public function getClassAnnotation(\ReflectionClass $class, $annotation) + { + return $this->delegate->getClassAnnotation($class, $annotation); + } + + public function getMethodAnnotations(\ReflectionMethod $method) + { + $annotations = array(); + foreach ($this->delegate->getMethodAnnotations($method) as $annot) { + $annotations[get_class($annot)] = $annot; + } + + return $annotations; + } + + public function getMethodAnnotation(\ReflectionMethod $method, $annotation) + { + return $this->delegate->getMethodAnnotation($method, $annotation); + } + + public function getPropertyAnnotations(\ReflectionProperty $property) + { + $annotations = array(); + foreach ($this->delegate->getPropertyAnnotations($property) as $annot) { + $annotations[get_class($annot)] = $annot; + } + + return $annotations; + } + + public function getPropertyAnnotation(\ReflectionProperty $property, $annotation) + { + return $this->delegate->getPropertyAnnotation($property, $annotation); + } + + /** + * Proxy all methods to the delegate. + * + * @param type $method + * @param type $args + * @return type + */ + public function __call($method, $args) + { + return call_user_func_array(array($this->delegate, $method), $args); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/PhpParser.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/PhpParser.php new file mode 100644 index 0000000..a14f8f5 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/PhpParser.php @@ -0,0 +1,203 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +use SplFileObject; + +/** + * Parses a file for namespaces/use/class declarations. + * + * @author Fabien Potencier + * @author Christian Kaps + */ +final class PhpParser +{ + /** + * The token list. + * + * @var array + */ + private $tokens; + + /** + * The number of tokens. + * + * @var int + */ + private $numTokens = 0; + + /** + * The current array pointer. + * + * @var int + */ + private $pointer = 0; + + /** + * Parses a class. + * + * @param \ReflectionClass $class A ReflectionClass object. + * @return array A list with use statements in the form (Alias => FQN). + */ + public function parseClass(\ReflectionClass $class) + { + if (false === $filename = $class->getFilename()) { + return array(); + } + + $content = $this->getFileContent($filename, $class->getStartLine()); + $namespace = str_replace('\\', '\\\\', $class->getNamespaceName()); + $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content); + $this->tokens = token_get_all('numTokens = count($this->tokens); + $this->pointer = 0; + + $statements = $this->parseUseStatements($class->getNamespaceName()); + + return $statements; + } + + /** + * Get the content of the file right up to the given line number. + * + * @param string $filename The name of the file to load. + * @param int $lineNumber The number of lines to read from file. + * @return string The content of the file. + */ + private function getFileContent($filename, $lineNumber) + { + $content = ''; + $lineCnt = 0; + $file = new SplFileObject($filename); + while(!$file->eof()) { + if ($lineCnt++ == $lineNumber) { + break; + } + + $content .= $file->fgets(); + } + + return $content; + } + + /** + * Gets the next non whitespace and non comment token. + * + * @return array The token if exists, null otherwise. + */ + private function next() + { + for ($i = $this->pointer; $i < $this->numTokens; $i++) { + $this->pointer++; + if ($this->tokens[$i][0] === T_WHITESPACE || + $this->tokens[$i][0] === T_COMMENT || + $this->tokens[$i][0] === T_DOC_COMMENT) { + + continue; + } + + return $this->tokens[$i]; + } + + return null; + } + + /** + * Get all use statements. + * + * @param string $namespaceName The namespace name of the reflected class. + * @return array A list with all found use statements. + */ + private function parseUseStatements($namespaceName) + { + $statements = array(); + while (($token = $this->next())) { + if ($token[0] === T_USE) { + $statements = array_merge($statements, $this->parseUseStatement()); + continue; + } else if ($token[0] !== T_NAMESPACE || $this->parseNamespace() != $namespaceName) { + continue; + } + + // Get fresh array for new namespace. This is to prevent the parser to collect the use statements + // for a previous namespace with the same name. This is the case if a namespace is defined twice + // or if a namespace with the same name is commented out. + $statements = array(); + } + + return $statements; + } + + /** + * Get the namespace name. + * + * @return string The found namespace name. + */ + private function parseNamespace() + { + $namespace = ''; + while (($token = $this->next())){ + if ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR) { + $namespace .= $token[1]; + } else { + break; + } + } + + return $namespace; + } + + /** + * Parse a single use statement. + * + * @return array A list with all found class names for a use statement. + */ + private function parseUseStatement() + { + $class = ''; + $alias = ''; + $statements = array(); + $explicitAlias = false; + while (($token = $this->next())) { + $isNameToken = $token[0] === T_STRING || $token[0] === T_NS_SEPARATOR; + if (!$explicitAlias && $isNameToken) { + $class .= $token[1]; + $alias = $token[1]; + } else if ($explicitAlias && $isNameToken) { + $alias .= $token[1]; + } else if ($token[0] === T_AS) { + $explicitAlias = true; + $alias = ''; + } else if ($token === ',') { + $statements[strtolower($alias)] = $class; + $class = ''; + $alias = ''; + $explicitAlias = false; + } else if ($token === ';') { + $statements[strtolower($alias)] = $class; + break; + } else { + break; + } + } + + return $statements; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Reader.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Reader.php new file mode 100644 index 0000000..8e85d39 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/Reader.php @@ -0,0 +1,35 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +/** + * Interface for annotation readers. + * + * @author Johannes M. Schmitt + */ +interface Reader +{ + function getClassAnnotations(\ReflectionClass $class); + function getClassAnnotation(\ReflectionClass $class, $annotationName); + function getMethodAnnotations(\ReflectionMethod $method); + function getMethodAnnotation(\ReflectionMethod $method, $annotationName); + function getPropertyAnnotations(\ReflectionProperty $property); + function getPropertyAnnotation(\ReflectionProperty $property, $annotationName); +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php new file mode 100644 index 0000000..a13c7fa --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php @@ -0,0 +1,152 @@ +. + */ + +namespace Doctrine\Common\Annotations; + +use Doctrine\Common\Annotations\Annotation\Target; + +/** + * Simple Annotation Reader. + * + * This annotation reader is intended to be used in projects where you have + * full-control over all annotations that are available. + * + * @since 2.2 + * @author Johannes M. Schmitt + * @author Fabio B. Silva + */ +class SimpleAnnotationReader implements Reader +{ + /** + * @var DocParser + */ + private $parser; + + /** + * Constructor. + * + * Initializes a new SimpleAnnotationReader. + */ + public function __construct() + { + $this->parser = new DocParser(); + $this->parser->setIgnoreNotImportedAnnotations(true); + } + + /** + * Adds a namespace in which we will look for annotations. + * + * @param string $namespace + */ + public function addNamespace($namespace) + { + $this->parser->addNamespace($namespace); + } + + /** + * Gets the annotations applied to a class. + * + * @param ReflectionClass $class The ReflectionClass of the class from which + * the class annotations should be read. + * @return array An array of Annotations. + */ + public function getClassAnnotations(\ReflectionClass $class) + { + return $this->parser->parse($class->getDocComment(), 'class '.$class->getName()); + } + + /** + * Gets the annotations applied to a method. + * + * @param ReflectionMethod $property The ReflectionMethod of the method from which + * the annotations should be read. + * @return array An array of Annotations. + */ + public function getMethodAnnotations(\ReflectionMethod $method) + { + return $this->parser->parse($method->getDocComment(), 'method '.$method->getDeclaringClass()->name.'::'.$method->getName().'()'); + } + + /** + * Gets the annotations applied to a property. + * + * @param ReflectionProperty $property The ReflectionProperty of the property + * from which the annotations should be read. + * @return array An array of Annotations. + */ + public function getPropertyAnnotations(\ReflectionProperty $property) + { + return $this->parser->parse($property->getDocComment(), 'property '.$property->getDeclaringClass()->name.'::$'.$property->getName()); + } + + /** + * Gets a class annotation. + * + * @param ReflectionClass $class The ReflectionClass of the class from which + * the class annotations should be read. + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getClassAnnotation(\ReflectionClass $class, $annotationName) + { + foreach ($this->getClassAnnotations($class) as $annot) { + if ($annot instanceof $annotationName) { + return $annot; + } + } + + return null; + } + + /** + * Gets a method annotation. + * + * @param ReflectionMethod $method + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) + { + foreach ($this->getMethodAnnotations($method) as $annot) { + if ($annot instanceof $annotationName) { + return $annot; + } + } + + return null; + } + + /** + * Gets a property annotation. + * + * @param ReflectionProperty $property + * @param string $annotationName The name of the annotation. + * @return The Annotation or NULL, if the requested annotation does not exist. + */ + public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) + { + foreach ($this->getPropertyAnnotations($property) as $annot) { + if ($annot instanceof $annotationName) { + return $annot; + } + } + + return null; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ApcCache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ApcCache.php new file mode 100644 index 0000000..a59296f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ApcCache.php @@ -0,0 +1,97 @@ +. + */ + +namespace Doctrine\Common\Cache; + +/** + * APC cache provider. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie + */ +class ApcCache extends CacheProvider +{ + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return apc_fetch($id); + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + $found = false; + + apc_fetch($id, $found); + + return $found; + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + return (bool) apc_store($id, $data, (int) $lifeTime); + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + return apc_delete($id); + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + return apc_clear_cache() && apc_clear_cache('user'); + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + $info = apc_cache_info(); + $sma = apc_sma_info(); + + return array( + Cache::STATS_HITS => $info['num_hits'], + Cache::STATS_MISSES => $info['num_misses'], + Cache::STATS_UPTIME => $info['start_time'], + Cache::STATS_MEMORY_USAGE => $info['mem_size'], + Cache::STATS_MEMORY_AVAILIABLE => $sma['avail_mem'], + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ArrayCache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ArrayCache.php new file mode 100644 index 0000000..8a0b982 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ArrayCache.php @@ -0,0 +1,96 @@ +. + */ + +namespace Doctrine\Common\Cache; + +/** + * Array cache driver. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie + */ +class ArrayCache extends CacheProvider +{ + /** + * @var array $data + */ + private $data = array(); + + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return (isset($this->data[$id])) ? $this->data[$id] : false; + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + return isset($this->data[$id]); + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + $this->data[$id] = $data; + + return true; + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + unset($this->data[$id]); + + return true; + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + $this->data = array(); + + return true; + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + return null; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/Cache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/Cache.php new file mode 100644 index 0000000..d303bde --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/Cache.php @@ -0,0 +1,102 @@ +. + */ + +namespace Doctrine\Common\Cache; + +/** + * Interface for cache drivers. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Fabio B. Silva + */ +interface Cache +{ + const STATS_HITS = 'hits'; + const STATS_MISSES = 'misses'; + const STATS_UPTIME = 'uptime'; + const STATS_MEMORY_USAGE = 'memory_usage'; + const STATS_MEMORY_AVAILIABLE = 'memory_available'; + + /** + * Fetches an entry from the cache. + * + * @param string $id cache id The id of the cache entry to fetch. + * @return string The cached data or FALSE, if no cache entry exists for the given id. + */ + function fetch($id); + + /** + * Test if an entry exists in the cache. + * + * @param string $id cache id The cache id of the entry to check for. + * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. + */ + function contains($id); + + /** + * Puts data into the cache. + * + * @param string $id The cache id. + * @param string $data The cache entry/data. + * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime). + * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. + */ + function save($id, $data, $lifeTime = 0); + + /** + * Deletes a cache entry. + * + * @param string $id cache id + * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. + */ + function delete($id); + + /** + * Retrieves cached information from data store + * + * The server's statistics array has the following values: + * + * - hits + * Number of keys that have been requested and found present. + * + * - misses + * Number of items that have been requested and not found. + * + * - uptime + * Time that the server is running. + * + * - memory_usage + * Memory used by this server to store items. + * + * - memory_available + * Memory allowed to use for storage. + * + * @since 2.2 + * @var array Associative array with server's statistics if available, NULL otherwise. + */ + function getStats(); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/CacheProvider.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/CacheProvider.php new file mode 100644 index 0000000..fa11fc2 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/CacheProvider.php @@ -0,0 +1,188 @@ +. + */ + +namespace Doctrine\Common\Cache; + +/** + * Base class for cache provider implementations. + * + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Fabio B. Silva + */ +abstract class CacheProvider implements Cache +{ + const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]'; + + /** + * @var string The namespace to prefix all cache ids with + */ + private $namespace = ''; + + /** + * Set the namespace to prefix all cache ids with. + * + * @param string $namespace + * @return void + */ + public function setNamespace($namespace) + { + $this->namespace = (string) $namespace; + } + + /** + * Retrieve the namespace that prefixes all cache ids. + * + * @return string + */ + public function getNamespace() + { + return $this->namespace; + } + + /** + * {@inheritdoc} + */ + public function fetch($id) + { + return $this->doFetch($this->getNamespacedId($id)); + } + + /** + * {@inheritdoc} + */ + public function contains($id) + { + return $this->doContains($this->getNamespacedId($id)); + } + + /** + * {@inheritdoc} + */ + public function save($id, $data, $lifeTime = 0) + { + return $this->doSave($this->getNamespacedId($id), $data, $lifeTime); + } + + /** + * {@inheritdoc} + */ + public function delete($id) + { + return $this->doDelete($this->getNamespacedId($id)); + } + + /** + * {@inheritdoc} + */ + public function getStats() + { + return $this->doGetStats(); + } + + /** + * Deletes all cache entries. + * + * @return boolean TRUE if the cache entries were successfully flushed, FALSE otherwise. + */ + public function flushAll() + { + return $this->doFlush(); + } + + /** + * Delete all cache entries. + * + * @return boolean TRUE if the cache entries were successfully deleted, FALSE otherwise. + */ + public function deleteAll() + { + $namespaceCacheKey = sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace); + $namespaceVersion = ($this->doContains($namespaceCacheKey)) ? $this->doFetch($namespaceCacheKey) : 1; + + return $this->doSave($namespaceCacheKey, $namespaceVersion + 1); + } + + /** + * Prefix the passed id with the configured namespace value + * + * @param string $id The id to namespace + * @return string $id The namespaced id + */ + private function getNamespacedId($id) + { + $namespaceCacheKey = sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace); + $namespaceVersion = ($this->doContains($namespaceCacheKey)) ? $this->doFetch($namespaceCacheKey) : 1; + + return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion); + } + + /** + * Fetches an entry from the cache. + * + * @param string $id cache id The id of the cache entry to fetch. + * @return string The cached data or FALSE, if no cache entry exists for the given id. + */ + abstract protected function doFetch($id); + + /** + * Test if an entry exists in the cache. + * + * @param string $id cache id The cache id of the entry to check for. + * @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise. + */ + abstract protected function doContains($id); + + /** + * Puts data into the cache. + * + * @param string $id The cache id. + * @param string $data The cache entry/data. + * @param int $lifeTime The lifetime. If != false, sets a specific lifetime for this cache entry (null => infinite lifeTime). + * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. + */ + abstract protected function doSave($id, $data, $lifeTime = false); + + /** + * Deletes a cache entry. + * + * @param string $id cache id + * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. + */ + abstract protected function doDelete($id); + + /** + * Deletes all cache entries. + * + * @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise. + */ + abstract protected function doFlush(); + + /** + * Retrieves cached information from data store + * + * @since 2.2 + * @return array An associative array with server's statistics if available, NULL otherwise. + */ + abstract protected function doGetStats(); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcacheCache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcacheCache.php new file mode 100644 index 0000000..dd6d1e3 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcacheCache.php @@ -0,0 +1,121 @@ +. + */ + +namespace Doctrine\Common\Cache; + +use \Memcache; + +/** + * Memcache cache provider. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie + */ +class MemcacheCache extends CacheProvider +{ + /** + * @var Memcache + */ + private $memcache; + + /** + * Sets the memcache instance to use. + * + * @param Memcache $memcache + */ + public function setMemcache(Memcache $memcache) + { + $this->memcache = $memcache; + } + + /** + * Gets the memcache instance used by the cache. + * + * @return Memcache + */ + public function getMemcache() + { + return $this->memcache; + } + + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return $this->memcache->get($id); + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + return (bool) $this->memcache->get($id); + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + if ($lifeTime > 30 * 24 * 3600) { + $lifeTime = time() + $lifeTime; + } + return $this->memcache->set($id, $data, 0, (int) $lifeTime); + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + return $this->memcache->delete($id); + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + return $this->memcache->flush(); + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + $stats = $this->memcache->getStats(); + return array( + Cache::STATS_HITS => $stats['get_hits'], + Cache::STATS_MISSES => $stats['get_misses'], + Cache::STATS_UPTIME => $stats['uptime'], + Cache::STATS_MEMORY_USAGE => $stats['bytes'], + Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'], + ); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcachedCache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcachedCache.php new file mode 100644 index 0000000..4675fae --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/MemcachedCache.php @@ -0,0 +1,124 @@ +. + */ + +namespace Doctrine\Common\Cache; + +use \Memcached; + +/** + * Memcached cache provider. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie + */ +class MemcachedCache extends CacheProvider +{ + /** + * @var Memcached + */ + private $memcached; + + /** + * Sets the memcache instance to use. + * + * @param Memcached $memcached + */ + public function setMemcached(Memcached $memcached) + { + $this->memcached = $memcached; + } + + /** + * Gets the memcached instance used by the cache. + * + * @return Memcached + */ + public function getMemcached() + { + return $this->memcached; + } + + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return $this->memcached->get($id); + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + return (false !== $this->memcached->get($id)); + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + if ($lifeTime > 30 * 24 * 3600) { + $lifeTime = time() + $lifeTime; + } + return $this->memcached->set($id, $data, (int) $lifeTime); + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + return $this->memcached->delete($id); + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + return $this->memcached->flush(); + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + $stats = $this->memcached->getStats(); + $servers = $this->memcached->getServerList(); + $key = $servers[0]['host'] . ':' . $servers[0]['port']; + $stats = $stats[$key]; + return array( + Cache::STATS_HITS => $stats['get_hits'], + Cache::STATS_MISSES => $stats['get_misses'], + Cache::STATS_UPTIME => $stats['uptime'], + Cache::STATS_MEMORY_USAGE => $stats['bytes'], + Cache::STATS_MEMORY_AVAILIABLE => $stats['limit_maxbytes'], + ); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/WinCacheCache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/WinCacheCache.php new file mode 100644 index 0000000..ed8ca74 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/WinCacheCache.php @@ -0,0 +1,92 @@ +. + */ + +namespace Doctrine\Common\Cache; + +/** + * WinCache cache provider. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie + */ +class WincacheCache extends CacheProvider +{ + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return wincache_ucache_get($id); + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + return wincache_ucache_exists($id); + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + return (bool) wincache_ucache_set($id, $data, (int) $lifeTime); + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + return wincache_ucache_delete($id); + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + return wincache_ucache_clear(); + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + $info = wincache_ucache_info(); + $meminfo= wincache_ucache_meminfo(); + return array( + Cache::STATS_HITS => $info['total_hit_count'], + Cache::STATS_MISSES => $info['total_miss_count'], + Cache::STATS_UPTIME => $info['total_cache_uptime'], + Cache::STATS_MEMORY_USAGE => $meminfo['memory_total'], + Cache::STATS_MEMORY_AVAILIABLE => $meminfo['memory_free'], + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/XcacheCache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/XcacheCache.php new file mode 100644 index 0000000..6e22d26 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/XcacheCache.php @@ -0,0 +1,110 @@ +. + */ + +namespace Doctrine\Common\Cache; + +/** + * Xcache cache driver. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie + */ +class XcacheCache extends CacheProvider +{ + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return $this->doContains($id) ? unserialize(xcache_get($id)) : false; + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + return xcache_isset($id); + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + return xcache_set($id, serialize($data), (int) $lifeTime); + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + return xcache_unset($id); + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + $this->checkAuthorization(); + + xcache_clear_cache(XC_TYPE_VAR, 0); + + return true; + } + + /** + * Checks that xcache.admin.enable_auth is Off + * + * @throws \BadMethodCallException When xcache.admin.enable_auth is On + * @return void + */ + protected function checkAuthorization() + { + if (ini_get('xcache.admin.enable_auth')) { + throw new \BadMethodCallException('To use all features of \Doctrine\Common\Cache\XcacheCache, you must set "xcache.admin.enable_auth" to "Off" in your php.ini.'); + } + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + $this->checkAuthorization(); + + $info = xcache_info(XC_TYPE_VAR, 0); + return array( + Cache::STATS_HITS => $info['hits'], + Cache::STATS_MISSES => $info['misses'], + Cache::STATS_UPTIME => null, + Cache::STATS_MEMORY_USAGE => $info['size'], + Cache::STATS_MEMORY_AVAILIABLE => $info['avail'], + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ZendDataCache.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ZendDataCache.php new file mode 100644 index 0000000..4e4dabe --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Cache/ZendDataCache.php @@ -0,0 +1,84 @@ +. + */ + +namespace Doctrine\Common\Cache; + +/** + * Zend Data Cache cache driver. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Ralph Schindler + * @author Guilherme Blanco + */ +class ZendDataCache extends CacheProvider +{ + /** + * {@inheritdoc} + */ + protected function doFetch($id) + { + return zend_shm_cache_fetch($id); + } + + /** + * {@inheritdoc} + */ + protected function doContains($id) + { + return (false !== zend_shm_cache_fetch($id)); + } + + /** + * {@inheritdoc} + */ + protected function doSave($id, $data, $lifeTime = 0) + { + return zend_shm_cache_store($id, $data, $lifeTime); + } + + /** + * {@inheritdoc} + */ + protected function doDelete($id) + { + return zend_shm_cache_delete($id); + } + + /** + * {@inheritdoc} + */ + protected function doFlush() + { + $namespace = $this->getNamespace(); + if (empty($namespace)) { + return zend_shm_cache_clear(); + } + return zend_shm_cache_clear($namespace); + } + + /** + * {@inheritdoc} + */ + protected function doGetStats() + { + return null; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/ClassLoader.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/ClassLoader.php new file mode 100644 index 0000000..375b0d6 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/ClassLoader.php @@ -0,0 +1,262 @@ +. + */ + +namespace Doctrine\Common; + +/** + * A ClassLoader is an autoloader for class files that can be + * installed on the SPL autoload stack. It is a class loader that either loads only classes + * of a specific namespace or all namespaces and it is suitable for working together + * with other autoloaders in the SPL autoload stack. + * + * If no include path is configured through the constructor or {@link setIncludePath}, a ClassLoader + * relies on the PHP include_path. + * + * @author Roman Borschel + * @since 2.0 + */ +class ClassLoader +{ + /** + * @var string PHP file extension + */ + protected $fileExtension = '.php'; + + /** + * @var string Current namespace + */ + protected $namespace; + + /** + * @var string Current include path + */ + protected $includePath; + + /** + * @var string PHP namespace separator + */ + protected $namespaceSeparator = '\\'; + + /** + * Creates a new ClassLoader that loads classes of the + * specified namespace from the specified include path. + * + * If no include path is given, the ClassLoader relies on the PHP include_path. + * If neither a namespace nor an include path is given, the ClassLoader will + * be responsible for loading all classes, thereby relying on the PHP include_path. + * + * @param string $ns The namespace of the classes to load. + * @param string $includePath The base include path to use. + */ + public function __construct($ns = null, $includePath = null) + { + $this->namespace = $ns; + $this->includePath = $includePath; + } + + /** + * Sets the namespace separator used by classes in the namespace of this ClassLoader. + * + * @param string $sep The separator to use. + */ + public function setNamespaceSeparator($sep) + { + $this->namespaceSeparator = $sep; + } + + /** + * Gets the namespace separator used by classes in the namespace of this ClassLoader. + * + * @return string + */ + public function getNamespaceSeparator() + { + return $this->namespaceSeparator; + } + + /** + * Sets the base include path for all class files in the namespace of this ClassLoader. + * + * @param string $includePath + */ + public function setIncludePath($includePath) + { + $this->includePath = $includePath; + } + + /** + * Gets the base include path for all class files in the namespace of this ClassLoader. + * + * @return string + */ + public function getIncludePath() + { + return $this->includePath; + } + + /** + * Sets the file extension of class files in the namespace of this ClassLoader. + * + * @param string $fileExtension + */ + public function setFileExtension($fileExtension) + { + $this->fileExtension = $fileExtension; + } + + /** + * Gets the file extension of class files in the namespace of this ClassLoader. + * + * @return string + */ + public function getFileExtension() + { + return $this->fileExtension; + } + + /** + * Registers this ClassLoader on the SPL autoload stack. + */ + public function register() + { + spl_autoload_register(array($this, 'loadClass')); + } + + /** + * Removes this ClassLoader from the SPL autoload stack. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $classname The name of the class to load. + * @return boolean TRUE if the class has been successfully loaded, FALSE otherwise. + */ + public function loadClass($className) + { + if ($this->namespace !== null && strpos($className, $this->namespace.$this->namespaceSeparator) !== 0) { + return false; + } + + require ($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '') + . str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) + . $this->fileExtension; + + return true; + } + + /** + * Asks this ClassLoader whether it can potentially load the class (file) with + * the given name. + * + * @param string $className The fully-qualified name of the class. + * @return boolean TRUE if this ClassLoader can load the class, FALSE otherwise. + */ + public function canLoadClass($className) + { + if ($this->namespace !== null && strpos($className, $this->namespace.$this->namespaceSeparator) !== 0) { + return false; + } + + $file = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension; + + if ($this->includePath !== null) { + return file_exists($this->includePath . DIRECTORY_SEPARATOR . $file); + } + + return (false !== stream_resolve_include_path($file)); + } + + /** + * Checks whether a class with a given name exists. A class "exists" if it is either + * already defined in the current request or if there is an autoloader on the SPL + * autoload stack that is a) responsible for the class in question and b) is able to + * load a class file in which the class definition resides. + * + * If the class is not already defined, each autoloader in the SPL autoload stack + * is asked whether it is able to tell if the class exists. If the autoloader is + * a ClassLoader, {@link canLoadClass} is used, otherwise the autoload + * function of the autoloader is invoked and expected to return a value that + * evaluates to TRUE if the class (file) exists. As soon as one autoloader reports + * that the class exists, TRUE is returned. + * + * Note that, depending on what kinds of autoloaders are installed on the SPL + * autoload stack, the class (file) might already be loaded as a result of checking + * for its existence. This is not the case with a ClassLoader, who separates + * these responsibilities. + * + * @param string $className The fully-qualified name of the class. + * @return boolean TRUE if the class exists as per the definition given above, FALSE otherwise. + */ + public static function classExists($className) + { + if (class_exists($className, false) || interface_exists($className, false)) { + return true; + } + + foreach (spl_autoload_functions() as $loader) { + if (is_array($loader)) { // array(???, ???) + if (is_object($loader[0])) { + if ($loader[0] instanceof ClassLoader) { // array($obj, 'methodName') + if ($loader[0]->canLoadClass($className)) { + return true; + } + } else if ($loader[0]->{$loader[1]}($className)) { + return true; + } + } else if ($loader[0]::$loader[1]($className)) { // array('ClassName', 'methodName') + return true; + } + } else if ($loader instanceof \Closure) { // function($className) {..} + if ($loader($className)) { + return true; + } + } else if (is_string($loader) && $loader($className)) { // "MyClass::loadClass" + return true; + } + } + + return class_exists($className, false) || interface_exists($className, false); + } + + /** + * Gets the ClassLoader from the SPL autoload stack that is responsible + * for (and is able to load) the class with the given name. + * + * @param string $className The name of the class. + * @return The ClassLoader for the class or NULL if no such ClassLoader exists. + */ + public static function getClassLoader($className) + { + foreach (spl_autoload_functions() as $loader) { + if (is_array($loader) + && $loader[0] instanceof ClassLoader + && $loader[0]->canLoadClass($className) + ) { + return $loader[0]; + } + } + + return null; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/ArrayCollection.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/ArrayCollection.php new file mode 100644 index 0000000..2a7d4ea --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -0,0 +1,447 @@ +. + */ + +namespace Doctrine\Common\Collections; + +use Closure, ArrayIterator; + +/** + * An ArrayCollection is a Collection implementation that wraps a regular PHP array. + * + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +class ArrayCollection implements Collection +{ + /** + * An array containing the entries of this collection. + * + * @var array + */ + private $_elements; + + /** + * Initializes a new ArrayCollection. + * + * @param array $elements + */ + public function __construct(array $elements = array()) + { + $this->_elements = $elements; + } + + /** + * Gets the PHP array representation of this collection. + * + * @return array The PHP array representation of this collection. + */ + public function toArray() + { + return $this->_elements; + } + + /** + * Sets the internal iterator to the first element in the collection and + * returns this element. + * + * @return mixed + */ + public function first() + { + return reset($this->_elements); + } + + /** + * Sets the internal iterator to the last element in the collection and + * returns this element. + * + * @return mixed + */ + public function last() + { + return end($this->_elements); + } + + /** + * Gets the current key/index at the current internal iterator position. + * + * @return mixed + */ + public function key() + { + return key($this->_elements); + } + + /** + * Moves the internal iterator position to the next element. + * + * @return mixed + */ + public function next() + { + return next($this->_elements); + } + + /** + * Gets the element of the collection at the current internal iterator position. + * + * @return mixed + */ + public function current() + { + return current($this->_elements); + } + + /** + * Removes an element with a specific key/index from the collection. + * + * @param mixed $key + * @return mixed The removed element or NULL, if no element exists for the given key. + */ + public function remove($key) + { + if (isset($this->_elements[$key])) { + $removed = $this->_elements[$key]; + unset($this->_elements[$key]); + + return $removed; + } + + return null; + } + + /** + * Removes the specified element from the collection, if it is found. + * + * @param mixed $element The element to remove. + * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. + */ + public function removeElement($element) + { + $key = array_search($element, $this->_elements, true); + + if ($key !== false) { + unset($this->_elements[$key]); + + return true; + } + + return false; + } + + /** + * ArrayAccess implementation of offsetExists() + * + * @see containsKey() + */ + public function offsetExists($offset) + { + return $this->containsKey($offset); + } + + /** + * ArrayAccess implementation of offsetGet() + * + * @see get() + */ + public function offsetGet($offset) + { + return $this->get($offset); + } + + /** + * ArrayAccess implementation of offsetGet() + * + * @see add() + * @see set() + */ + public function offsetSet($offset, $value) + { + if ( ! isset($offset)) { + return $this->add($value); + } + return $this->set($offset, $value); + } + + /** + * ArrayAccess implementation of offsetUnset() + * + * @see remove() + */ + public function offsetUnset($offset) + { + return $this->remove($offset); + } + + /** + * Checks whether the collection contains a specific key/index. + * + * @param mixed $key The key to check for. + * @return boolean TRUE if the given key/index exists, FALSE otherwise. + */ + public function containsKey($key) + { + return isset($this->_elements[$key]); + } + + /** + * Checks whether the given element is contained in the collection. + * Only element values are compared, not keys. The comparison of two elements + * is strict, that means not only the value but also the type must match. + * For objects this means reference equality. + * + * @param mixed $element + * @return boolean TRUE if the given element is contained in the collection, + * FALSE otherwise. + */ + public function contains($element) + { + foreach ($this->_elements as $collectionElement) { + if ($element === $collectionElement) { + return true; + } + } + + return false; + } + + /** + * Tests for the existance of an element that satisfies the given predicate. + * + * @param Closure $p The predicate. + * @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise. + */ + public function exists(Closure $p) + { + foreach ($this->_elements as $key => $element) { + if ($p($key, $element)) { + return true; + } + } + return false; + } + + /** + * Searches for a given element and, if found, returns the corresponding key/index + * of that element. The comparison of two elements is strict, that means not + * only the value but also the type must match. + * For objects this means reference equality. + * + * @param mixed $element The element to search for. + * @return mixed The key/index of the element or FALSE if the element was not found. + */ + public function indexOf($element) + { + return array_search($element, $this->_elements, true); + } + + /** + * Gets the element with the given key/index. + * + * @param mixed $key The key. + * @return mixed The element or NULL, if no element exists for the given key. + */ + public function get($key) + { + if (isset($this->_elements[$key])) { + return $this->_elements[$key]; + } + return null; + } + + /** + * Gets all keys/indexes of the collection elements. + * + * @return array + */ + public function getKeys() + { + return array_keys($this->_elements); + } + + /** + * Gets all elements. + * + * @return array + */ + public function getValues() + { + return array_values($this->_elements); + } + + /** + * Returns the number of elements in the collection. + * + * Implementation of the Countable interface. + * + * @return integer The number of elements in the collection. + */ + public function count() + { + return count($this->_elements); + } + + /** + * Adds/sets an element in the collection at the index / with the specified key. + * + * When the collection is a Map this is like put(key,value)/add(key,value). + * When the collection is a List this is like add(position,value). + * + * @param mixed $key + * @param mixed $value + */ + public function set($key, $value) + { + $this->_elements[$key] = $value; + } + + /** + * Adds an element to the collection. + * + * @param mixed $value + * @return boolean Always TRUE. + */ + public function add($value) + { + $this->_elements[] = $value; + return true; + } + + /** + * Checks whether the collection is empty. + * + * Note: This is preferrable over count() == 0. + * + * @return boolean TRUE if the collection is empty, FALSE otherwise. + */ + public function isEmpty() + { + return ! $this->_elements; + } + + /** + * Gets an iterator for iterating over the elements in the collection. + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->_elements); + } + + /** + * Applies the given function to each element in the collection and returns + * a new collection with the elements returned by the function. + * + * @param Closure $func + * @return Collection + */ + public function map(Closure $func) + { + return new static(array_map($func, $this->_elements)); + } + + /** + * Returns all the elements of this collection that satisfy the predicate p. + * The order of the elements is preserved. + * + * @param Closure $p The predicate used for filtering. + * @return Collection A collection with the results of the filter operation. + */ + public function filter(Closure $p) + { + return new static(array_filter($this->_elements, $p)); + } + + /** + * Applies the given predicate p to all elements of this collection, + * returning true, if the predicate yields true for all elements. + * + * @param Closure $p The predicate. + * @return boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. + */ + public function forAll(Closure $p) + { + foreach ($this->_elements as $key => $element) { + if ( ! $p($key, $element)) { + return false; + } + } + + return true; + } + + /** + * Partitions this collection in two collections according to a predicate. + * Keys are preserved in the resulting collections. + * + * @param Closure $p The predicate on which to partition. + * @return array An array with two elements. The first element contains the collection + * of elements where the predicate returned TRUE, the second element + * contains the collection of elements where the predicate returned FALSE. + */ + public function partition(Closure $p) + { + $coll1 = $coll2 = array(); + foreach ($this->_elements as $key => $element) { + if ($p($key, $element)) { + $coll1[$key] = $element; + } else { + $coll2[$key] = $element; + } + } + return array(new static($coll1), new static($coll2)); + } + + /** + * Returns a string representation of this object. + * + * @return string + */ + public function __toString() + { + return __CLASS__ . '@' . spl_object_hash($this); + } + + /** + * Clears the collection. + */ + public function clear() + { + $this->_elements = array(); + } + + /** + * Extract a slice of $length elements starting at position $offset from the Collection. + * + * If $length is null it returns all elements from $offset to the end of the Collection. + * Keys have to be preserved by this method. Calling this method will only return the + * selected slice and NOT change the elements contained in the collection slice is called on. + * + * @param int $offset + * @param int $length + * @return array + */ + public function slice($offset, $length = null) + { + return array_slice($this->_elements, $offset, $length, true); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/Collection.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/Collection.php new file mode 100644 index 0000000..9fca659 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Collections/Collection.php @@ -0,0 +1,243 @@ +. + */ + +namespace Doctrine\Common\Collections; + +use Closure, Countable, IteratorAggregate, ArrayAccess; + +/** + * The missing (SPL) Collection/Array/OrderedMap interface. + * + * A Collection resembles the nature of a regular PHP array. That is, + * it is essentially an ordered map that can also be used + * like a list. + * + * A Collection has an internal iterator just like a PHP array. In addition, + * a Collection can be iterated with external iterators, which is preferrable. + * To use an external iterator simply use the foreach language construct to + * iterate over the collection (which calls {@link getIterator()} internally) or + * explicitly retrieve an iterator though {@link getIterator()} which can then be + * used to iterate over the collection. + * You can not rely on the internal iterator of the collection being at a certain + * position unless you explicitly positioned it before. Prefer iteration with + * external iterators. + * + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +interface Collection extends Countable, IteratorAggregate, ArrayAccess +{ + /** + * Adds an element at the end of the collection. + * + * @param mixed $element The element to add. + * @return boolean Always TRUE. + */ + function add($element); + + /** + * Clears the collection, removing all elements. + */ + function clear(); + + /** + * Checks whether an element is contained in the collection. + * This is an O(n) operation, where n is the size of the collection. + * + * @param mixed $element The element to search for. + * @return boolean TRUE if the collection contains the element, FALSE otherwise. + */ + function contains($element); + + /** + * Checks whether the collection is empty (contains no elements). + * + * @return boolean TRUE if the collection is empty, FALSE otherwise. + */ + function isEmpty(); + + /** + * Removes the element at the specified index from the collection. + * + * @param string|integer $key The kex/index of the element to remove. + * @return mixed The removed element or NULL, if the collection did not contain the element. + */ + function remove($key); + + /** + * Removes the specified element from the collection, if it is found. + * + * @param mixed $element The element to remove. + * @return boolean TRUE if this collection contained the specified element, FALSE otherwise. + */ + function removeElement($element); + + /** + * Checks whether the collection contains an element with the specified key/index. + * + * @param string|integer $key The key/index to check for. + * @return boolean TRUE if the collection contains an element with the specified key/index, + * FALSE otherwise. + */ + function containsKey($key); + + /** + * Gets the element at the specified key/index. + * + * @param string|integer $key The key/index of the element to retrieve. + * @return mixed + */ + function get($key); + + /** + * Gets all keys/indices of the collection. + * + * @return array The keys/indices of the collection, in the order of the corresponding + * elements in the collection. + */ + function getKeys(); + + /** + * Gets all values of the collection. + * + * @return array The values of all elements in the collection, in the order they + * appear in the collection. + */ + function getValues(); + + /** + * Sets an element in the collection at the specified key/index. + * + * @param string|integer $key The key/index of the element to set. + * @param mixed $value The element to set. + */ + function set($key, $value); + + /** + * Gets a native PHP array representation of the collection. + * + * @return array + */ + function toArray(); + + /** + * Sets the internal iterator to the first element in the collection and + * returns this element. + * + * @return mixed + */ + function first(); + + /** + * Sets the internal iterator to the last element in the collection and + * returns this element. + * + * @return mixed + */ + function last(); + + /** + * Gets the key/index of the element at the current iterator position. + * + */ + function key(); + + /** + * Gets the element of the collection at the current iterator position. + * + */ + function current(); + + /** + * Moves the internal iterator position to the next element. + * + */ + function next(); + + /** + * Tests for the existence of an element that satisfies the given predicate. + * + * @param Closure $p The predicate. + * @return boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise. + */ + function exists(Closure $p); + + /** + * Returns all the elements of this collection that satisfy the predicate p. + * The order of the elements is preserved. + * + * @param Closure $p The predicate used for filtering. + * @return Collection A collection with the results of the filter operation. + */ + function filter(Closure $p); + + /** + * Applies the given predicate p to all elements of this collection, + * returning true, if the predicate yields true for all elements. + * + * @param Closure $p The predicate. + * @return boolean TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. + */ + function forAll(Closure $p); + + /** + * Applies the given function to each element in the collection and returns + * a new collection with the elements returned by the function. + * + * @param Closure $func + * @return Collection + */ + function map(Closure $func); + + /** + * Partitions this collection in two collections according to a predicate. + * Keys are preserved in the resulting collections. + * + * @param Closure $p The predicate on which to partition. + * @return array An array with two elements. The first element contains the collection + * of elements where the predicate returned TRUE, the second element + * contains the collection of elements where the predicate returned FALSE. + */ + function partition(Closure $p); + + /** + * Gets the index/key of a given element. The comparison of two elements is strict, + * that means not only the value but also the type must match. + * For objects this means reference equality. + * + * @param mixed $element The element to search for. + * @return mixed The key/index of the element or FALSE if the element was not found. + */ + function indexOf($element); + + /** + * Extract a slice of $length elements starting at position $offset from the Collection. + * + * If $length is null it returns all elements from $offset to the end of the Collection. + * Keys have to be preserved by this method. Calling this method will only return the + * selected slice and NOT change the elements contained in the collection slice is called on. + * + * @param int $offset + * @param int $length + * @return array + */ + function slice($offset, $length = null); +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/CommonException.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/CommonException.php new file mode 100644 index 0000000..8c5669b --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/CommonException.php @@ -0,0 +1,28 @@ +. + */ + +namespace Doctrine\Common; + +/** + * Base exception class for package Doctrine\Common + * @author heinrich + * + */ +class CommonException extends \Exception { +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Comparable.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Comparable.php new file mode 100644 index 0000000..bc95d30 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Comparable.php @@ -0,0 +1,47 @@ +. + */ + + +namespace Doctrine\Common; + +/** + * Comparable interface that allows to compare two value objects to each other for similarity. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.com + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + */ +interface Comparable +{ + /** + * Compare the current object to the passed $other. + * + * Returns 0 if they are semantically equal, 1 if the other object + * is less than the current one, or -1 if its more than the current one. + * + * This method should not check for identity using ===, only for semantical equality for example + * when two different DateTime instances point to the exact same Date + TZ. + * + * @return int + */ + public function compareTo($other); +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventArgs.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventArgs.php new file mode 100644 index 0000000..6a3c069 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventArgs.php @@ -0,0 +1,69 @@ +. + */ + +namespace Doctrine\Common; + +/** + * EventArgs is the base class for classes containing event data. + * + * This class contains no event data. It is used by events that do not pass state + * information to an event handler when an event is raised. The single empty EventArgs + * instance can be obtained through {@link getEmptyInstance}. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision: 3938 $ + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +class EventArgs +{ + /** + * @var EventArgs Single instance of EventArgs + * @static + */ + private static $_emptyEventArgsInstance; + + /** + * Gets the single, empty and immutable EventArgs instance. + * + * This instance will be used when events are dispatched without any parameter, + * like this: EventManager::dispatchEvent('eventname'); + * + * The benefit from this is that only one empty instance is instantiated and shared + * (otherwise there would be instances for every dispatched in the abovementioned form) + * + * @see EventManager::dispatchEvent + * @link http://msdn.microsoft.com/en-us/library/system.eventargs.aspx + * @static + * @return EventArgs + */ + public static function getEmptyInstance() + { + if ( ! self::$_emptyEventArgsInstance) { + self::$_emptyEventArgsInstance = new EventArgs; + } + + return self::$_emptyEventArgsInstance; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventManager.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventManager.php new file mode 100644 index 0000000..a1f11ed --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventManager.php @@ -0,0 +1,136 @@ +. + */ + +namespace Doctrine\Common; + +/** + * The EventManager is the central point of Doctrine's event listener system. + * Listeners are registered on the manager and events are dispatched through the + * manager. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision: 3938 $ + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +class EventManager +{ + /** + * Map of registered listeners. + * => + * + * @var array + */ + private $_listeners = array(); + + /** + * Dispatches an event to all registered listeners. + * + * @param string $eventName The name of the event to dispatch. The name of the event is + * the name of the method that is invoked on listeners. + * @param EventArgs $eventArgs The event arguments to pass to the event handlers/listeners. + * If not supplied, the single empty EventArgs instance is used. + * @return boolean + */ + public function dispatchEvent($eventName, EventArgs $eventArgs = null) + { + if (isset($this->_listeners[$eventName])) { + $eventArgs = $eventArgs === null ? EventArgs::getEmptyInstance() : $eventArgs; + + foreach ($this->_listeners[$eventName] as $listener) { + $listener->$eventName($eventArgs); + } + } + } + + /** + * Gets the listeners of a specific event or all listeners. + * + * @param string $event The name of the event. + * @return array The event listeners for the specified event, or all event listeners. + */ + public function getListeners($event = null) + { + return $event ? $this->_listeners[$event] : $this->_listeners; + } + + /** + * Checks whether an event has any registered listeners. + * + * @param string $event + * @return boolean TRUE if the specified event has any listeners, FALSE otherwise. + */ + public function hasListeners($event) + { + return isset($this->_listeners[$event]) && $this->_listeners[$event]; + } + + /** + * Adds an event listener that listens on the specified events. + * + * @param string|array $events The event(s) to listen on. + * @param object $listener The listener object. + */ + public function addEventListener($events, $listener) + { + // Picks the hash code related to that listener + $hash = spl_object_hash($listener); + + foreach ((array) $events as $event) { + // Overrides listener if a previous one was associated already + // Prevents duplicate listeners on same event (same instance only) + $this->_listeners[$event][$hash] = $listener; + } + } + + /** + * Removes an event listener from the specified events. + * + * @param string|array $events + * @param object $listener + */ + public function removeEventListener($events, $listener) + { + // Picks the hash code related to that listener + $hash = spl_object_hash($listener); + + foreach ((array) $events as $event) { + // Check if actually have this listener associated + if (isset($this->_listeners[$event][$hash])) { + unset($this->_listeners[$event][$hash]); + } + } + } + + /** + * Adds an EventSubscriber. The subscriber is asked for all the events he is + * interested in and added as a listener for these events. + * + * @param Doctrine\Common\EventSubscriber $subscriber The subscriber. + */ + public function addEventSubscriber(EventSubscriber $subscriber) + { + $this->addEventListener($subscriber->getSubscribedEvents(), $subscriber); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventSubscriber.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventSubscriber.php new file mode 100644 index 0000000..ed3383f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/EventSubscriber.php @@ -0,0 +1,45 @@ +. + */ + +namespace Doctrine\Common; + +/** + * An EventSubscriber knows himself what events he is interested in. + * If an EventSubscriber is added to an EventManager, the manager invokes + * {@link getSubscribedEvents} and registers the subscriber as a listener for all + * returned events. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +interface EventSubscriber +{ + /** + * Returns an array of events this subscriber wants to listen to. + * + * @return array + */ + function getSubscribedEvents(); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Lexer.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Lexer.php new file mode 100644 index 0000000..8df3b84 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Lexer.php @@ -0,0 +1,266 @@ +. + */ + +namespace Doctrine\Common; + +/** + * Base class for writing simple lexers, i.e. for creating small DSLs. + * + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @todo Rename: AbstractLexer + */ +abstract class Lexer +{ + /** + * @var array Array of scanned tokens + */ + private $tokens = array(); + + /** + * @var integer Current lexer position in input string + */ + private $position = 0; + + /** + * @var integer Current peek of current lexer position + */ + private $peek = 0; + + /** + * @var array The next token in the input. + */ + public $lookahead; + + /** + * @var array The last matched/seen token. + */ + public $token; + + /** + * Sets the input data to be tokenized. + * + * The Lexer is immediately reset and the new input tokenized. + * Any unprocessed tokens from any previous input are lost. + * + * @param string $input The input to be tokenized. + */ + public function setInput($input) + { + $this->tokens = array(); + $this->reset(); + $this->scan($input); + } + + /** + * Resets the lexer. + */ + public function reset() + { + $this->lookahead = null; + $this->token = null; + $this->peek = 0; + $this->position = 0; + } + + /** + * Resets the peek pointer to 0. + */ + public function resetPeek() + { + $this->peek = 0; + } + + /** + * Resets the lexer position on the input to the given position. + * + * @param integer $position Position to place the lexical scanner + */ + public function resetPosition($position = 0) + { + $this->position = $position; + } + + /** + * Checks whether a given token matches the current lookahead. + * + * @param integer|string $token + * @return boolean + */ + public function isNextToken($token) + { + return null !== $this->lookahead && $this->lookahead['type'] === $token; + } + + /** + * Checks whether any of the given tokens matches the current lookahead + * + * @param array $tokens + * @return boolean + */ + public function isNextTokenAny(array $tokens) + { + return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); + } + + /** + * Moves to the next token in the input string. + * + * A token is an associative array containing three items: + * - 'value' : the string value of the token in the input string + * - 'type' : the type of the token (identifier, numeric, string, input + * parameter, none) + * - 'position' : the position of the token in the input string + * + * @return array|null the next token; null if there is no more tokens left + */ + public function moveNext() + { + $this->peek = 0; + $this->token = $this->lookahead; + $this->lookahead = (isset($this->tokens[$this->position])) + ? $this->tokens[$this->position++] : null; + + return $this->lookahead !== null; + } + + /** + * Tells the lexer to skip input tokens until it sees a token with the given value. + * + * @param $type The token type to skip until. + */ + public function skipUntil($type) + { + while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { + $this->moveNext(); + } + } + + /** + * Checks if given value is identical to the given token + * + * @param mixed $value + * @param integer $token + * @return boolean + */ + public function isA($value, $token) + { + return $this->getType($value) === $token; + } + + /** + * Moves the lookahead token forward. + * + * @return array | null The next token or NULL if there are no more tokens ahead. + */ + public function peek() + { + if (isset($this->tokens[$this->position + $this->peek])) { + return $this->tokens[$this->position + $this->peek++]; + } else { + return null; + } + } + + /** + * Peeks at the next token, returns it and immediately resets the peek. + * + * @return array|null The next token or NULL if there are no more tokens ahead. + */ + public function glimpse() + { + $peek = $this->peek(); + $this->peek = 0; + return $peek; + } + + /** + * Scans the input string for tokens. + * + * @param string $input a query string + */ + protected function scan($input) + { + static $regex; + + if ( ! isset($regex)) { + $regex = '/(' . implode(')|(', $this->getCatchablePatterns()) . ')|' + . implode('|', $this->getNonCatchablePatterns()) . '/i'; + } + + $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; + $matches = preg_split($regex, $input, -1, $flags); + + foreach ($matches as $match) { + // Must remain before 'value' assignment since it can change content + $type = $this->getType($match[0]); + + $this->tokens[] = array( + 'value' => $match[0], + 'type' => $type, + 'position' => $match[1], + ); + } + } + + /** + * Gets the literal for a given token. + * + * @param integer $token + * @return string + */ + public function getLiteral($token) + { + $className = get_class($this); + $reflClass = new \ReflectionClass($className); + $constants = $reflClass->getConstants(); + + foreach ($constants as $name => $value) { + if ($value === $token) { + return $className . '::' . $name; + } + } + + return $token; + } + + /** + * Lexical catchable patterns. + * + * @return array + */ + abstract protected function getCatchablePatterns(); + + /** + * Lexical non-catchable patterns. + * + * @return array + */ + abstract protected function getNonCatchablePatterns(); + + /** + * Retrieve token type. Also processes the token value if necessary. + * + * @param string $value + * @return integer + */ + abstract protected function getType(&$value); +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/NotifyPropertyChanged.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/NotifyPropertyChanged.php new file mode 100644 index 0000000..93e504a --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/NotifyPropertyChanged.php @@ -0,0 +1,45 @@ +. + */ + +namespace Doctrine\Common; + +/** + * Contract for classes that provide the service of notifying listeners of + * changes to their properties. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision: 3938 $ + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +interface NotifyPropertyChanged +{ + /** + * Adds a listener that wants to be notified about property changes. + * + * @param PropertyChangedListener $listener + */ + function addPropertyChangedListener(PropertyChangedListener $listener); +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php new file mode 100644 index 0000000..f045286 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php @@ -0,0 +1,218 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +use Doctrine\Common\Persistence\ManagerRegistry; + +/** + * Abstract implementation of the ManagerRegistry contract. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Fabien Potencier + * @author Benjamin Eberlei + * @author Lukas Kahwe Smith + */ +abstract class AbstractManagerRegistry implements ManagerRegistry +{ + private $name; + private $connections; + private $managers; + private $defaultConnection; + private $defaultManager; + private $proxyInterfaceName; + + public function __construct($name, array $connections, array $managers, $defaultConnection, $defaultManager, $proxyInterfaceName) + { + $this->name = $name; + $this->connections = $connections; + $this->managers = $managers; + $this->defaultConnection = $defaultConnection; + $this->defaultManager = $defaultManager; + $this->proxyInterfaceName = $proxyInterfaceName; + } + + /** + * Fetches/creates the given services + * + * A service in this context is connection or a manager instance + * + * @param string $name name of the service + * @return object instance of the given service + */ + abstract protected function getService($name); + + /** + * Resets the given services + * + * A service in this context is connection or a manager instance + * + * @param string $name name of the service + * @return void + */ + abstract protected function resetService($name); + + /** + * Get the name of the registry + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @inheritdoc + */ + public function getConnection($name = null) + { + if (null === $name) { + $name = $this->defaultConnection; + } + + if (!isset($this->connections[$name])) { + throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->name, $name)); + } + + return $this->getService($this->connections[$name]); + } + + /** + * @inheritdoc + */ + public function getConnectionNames() + { + return $this->connections; + } + + /** + * @inheritdoc + */ + public function getConnections() + { + $connections = array(); + foreach ($this->connections as $name => $id) { + $connections[$name] = $this->getService($id); + } + + return $connections; + } + + /** + * @inheritdoc + */ + public function getDefaultConnectionName() + { + return $this->defaultConnection; + } + + /** + * @inheritdoc + */ + public function getDefaultManagerName() + { + return $this->defaultManager; + } + + /** + * @inheritdoc + */ + public function getManager($name = null) + { + if (null === $name) { + $name = $this->defaultManager; + } + + if (!isset($this->managers[$name])) { + throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name)); + } + + return $this->getService($this->managers[$name]); + } + + /** + * @inheritdoc + */ + public function getManagerForClass($class) + { + $proxyClass = new \ReflectionClass($class); + if ($proxyClass->implementsInterface($this->proxyInterfaceName)) { + $class = $proxyClass->getParentClass()->getName(); + } + + foreach ($this->managers as $id) { + $manager = $this->getService($id); + + if (!$manager->getMetadataFactory()->isTransient($class)) { + return $manager; + } + } + } + + /** + * @inheritdoc + */ + public function getManagerNames() + { + return $this->managers; + } + + /** + * @inheritdoc + */ + public function getManagers() + { + $dms = array(); + foreach ($this->managers as $name => $id) { + $dms[$name] = $this->getService($id); + } + + return $dms; + } + + /** + * @inheritdoc + */ + public function getRepository($persistentObjectName, $persistentManagerName = null) + { + return $this->getManager($persistentManagerName)->getRepository($persistentObjectName); + } + + /** + * @inheritdoc + */ + public function resetManager($name = null) + { + if (null === $name) { + $name = $this->defaultManager; + } + + if (!isset($this->managers[$name])) { + throw new \InvalidArgumentException(sprintf('Doctrine %s Manager named "%s" does not exist.', $this->name, $name)); + } + + // force the creation of a new document manager + // if the current one is closed + $this->resetService($this->managers[$name]); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ConnectionRegistry.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ConnectionRegistry.php new file mode 100644 index 0000000..a47727f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ConnectionRegistry.php @@ -0,0 +1,63 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +/** + * Contract covering connection for a Doctrine persistence layer ManagerRegistry class to implement. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Fabien Potencier + * @author Benjamin Eberlei + * @author Lukas Kahwe Smith + */ +interface ConnectionRegistry +{ + /** + * Gets the default connection name. + * + * @return string The default connection name + */ + function getDefaultConnectionName(); + + /** + * Gets the named connection. + * + * @param string $name The connection name (null for the default one) + * + * @return Connection + */ + function getConnection($name = null); + + /** + * Gets an array of all registered connections + * + * @return array An array of Connection instances + */ + function getConnections(); + + /** + * Gets all connection names. + * + * @return array An array of connection names + */ + function getConnectionNames(); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php new file mode 100644 index 0000000..8055b66 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LifecycleEventArgs.php @@ -0,0 +1,77 @@ +. +*/ + +namespace Doctrine\Common\Persistence\Event; + +use Doctrine\Common\EventArgs; +use Doctrine\Common\Persistence\ObjectManager; + +/** + * Lifecycle Events are triggered by the UnitOfWork during lifecycle transitions + * of entities. + * + * @link www.doctrine-project.org + * @since 2.2 + * @author Roman Borschel + * @author Benjamin Eberlei + */ +class LifecycleEventArgs extends EventArgs +{ + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @var object + */ + private $entity; + + /** + * Constructor + * + * @param object $entity + * @param ObjectManager $objectManager + */ + public function __construct($entity, ObjectManager $objectManager) + { + $this->entity = $entity; + $this->objectManager = $objectManager; + } + + /** + * Retireve associated Entity. + * + * @return object + */ + public function getEntity() + { + return $this->entity; + } + + /** + * Retrieve associated ObjectManager. + * + * @return ObjectManager + */ + public function getObjectManager() + { + return $this->objectManager; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php new file mode 100644 index 0000000..4a18d16 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/LoadClassMetadataEventArgs.php @@ -0,0 +1,76 @@ +. + */ + +namespace Doctrine\Common\Persistence\Event; + +use Doctrine\Common\EventArgs; +use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; + +/** + * Class that holds event arguments for a loadMetadata event. + * + * @author Jonathan H. Wage + * @since 2.2 + */ +class LoadClassMetadataEventArgs extends EventArgs +{ + /** + * @var ClassMetadata + */ + private $classMetadata; + + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * Constructor. + * + * @param ClasseMetadata $classMetadata + * @param ObjectManager $objectManager + */ + public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager) + { + $this->classMetadata = $classMetadata; + $this->objectManager = $objectManager; + } + + /** + * Retrieve associated ClassMetadata. + * + * @return ClassMetadata + */ + public function getClassMetadata() + { + return $this->classMetadata; + } + + /** + * Retrieve associated ObjectManager. + * + * @return ObjectManager + */ + public function getObjectManager() + { + return $this->objectManager; + } +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php new file mode 100644 index 0000000..33c4d79 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/ManagerEventArgs.php @@ -0,0 +1,59 @@ +. +*/ + +namespace Doctrine\Common\Persistence\Event; + +use Doctrine\Common\Persistence\ObjectManager; + +/** + * Provides event arguments for the preFlush event. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Roman Borschel + * @author Benjamin Eberlei + */ +class ManagerEventArgs extends \Doctrine\Common\EventArgs +{ + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * Constructor. + * + * @param ObjectManager $objectManager + */ + public function __construct(ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Retrieve associated ObjectManager. + * + * @return ObjectManager + */ + public function getObjectManager() + { + return $this->objectManager; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php new file mode 100644 index 0000000..f67ab50 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/OnClearEventArgs.php @@ -0,0 +1,84 @@ +. + */ + +namespace Doctrine\Common\Persistence\Event; + +/** + * Provides event arguments for the onClear event. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Roman Borschel + * @author Benjamin Eberlei + */ +class OnClearEventArgs extends \Doctrine\Common\EventArgs +{ + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @var string + */ + private $entityClass; + + /** + * Constructor. + * + * @param ObjectManager $objectManager + * @param string $entityClass Optional entity class + */ + public function __construct($objectManager, $entityClass = null) + { + $this->objectManager = $objectManager; + $this->entityClass = $entityClass; + } + + /** + * Retrieve associated ObjectManager. + * + * @return ObjectManager + */ + public function getObjectManager() + { + return $this->objectManager; + } + + /** + * Name of the entity class that is cleared, or empty if all are cleared. + * + * @return string + */ + public function getEntityClass() + { + return $this->entityClass; + } + + /** + * Check if event clears all entities. + * + * @return bool + */ + public function clearsAllEntities() + { + return ($this->entityClass === null); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php new file mode 100644 index 0000000..191d053 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Event/PreUpdateEventArgs.php @@ -0,0 +1,129 @@ +. + */ + +namespace Doctrine\Common\Persistence\Event; + +use Doctrine\Common\EventArgs, + Doctrine\Common\Persistence\ObjectManager; + +/** + * Class that holds event arguments for a preUpdate event. + * + * @author Guilherme Blanco + * @author Roman Borschel + * @author Benjamin Eberlei + * @since 2.2 + */ +class PreUpdateEventArgs extends LifecycleEventArgs +{ + /** + * @var array + */ + private $entityChangeSet; + + /** + * Constructor. + * + * @param object $entity + * @param ObjectManager $objectManager + * @param array $changeSet + */ + public function __construct($entity, ObjectManager $objectManager, array &$changeSet) + { + parent::__construct($entity, $objectManager); + + $this->entityChangeSet = &$changeSet; + } + + /** + * Retrieve entity changeset. + * + * @return array + */ + public function getEntityChangeSet() + { + return $this->entityChangeSet; + } + + /** + * Check if field has a changeset. + * + * @return boolean + */ + public function hasChangedField($field) + { + return isset($this->entityChangeSet[$field]); + } + + /** + * Get the old value of the changeset of the changed field. + * + * @param string $field + * @return mixed + */ + public function getOldValue($field) + { + $this->assertValidField($field); + + return $this->entityChangeSet[$field][0]; + } + + /** + * Get the new value of the changeset of the changed field. + * + * @param string $field + * @return mixed + */ + public function getNewValue($field) + { + $this->assertValidField($field); + + return $this->entityChangeSet[$field][1]; + } + + /** + * Set the new value of this field. + * + * @param string $field + * @param mixed $value + */ + public function setNewValue($field, $value) + { + $this->assertValidField($field); + + $this->entityChangeSet[$field][1] = $value; + } + + /** + * Assert the field exists in changeset. + * + * @param string $field + */ + private function assertValidField($field) + { + if ( ! isset($this->entityChangeSet[$field])) { + throw new \InvalidArgumentException(sprintf( + 'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.', + $field, + get_class($this->getEntity()) + )); + } + } +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ManagerRegistry.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ManagerRegistry.php new file mode 100644 index 0000000..4d92426 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ManagerRegistry.php @@ -0,0 +1,112 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +/** + * Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Fabien Potencier + * @author Benjamin Eberlei + * @author Lukas Kahwe Smith + */ +interface ManagerRegistry extends ConnectionRegistry +{ + /** + * Gets the default object manager name. + * + * @return string The default object manager name + */ + function getDefaultManagerName(); + + /** + * Gets a named object manager. + * + * @param string $name The object manager name (null for the default one) + * + * @return \Doctrine\Common\Persistence\ObjectManager + */ + function getManager($name = null); + + /** + * Gets an array of all registered object managers + * + * @return array An array of ObjectManager instances + */ + function getManagers(); + + /** + * Resets a named object manager. + * + * This method is useful when an object manager has been closed + * because of a rollbacked transaction AND when you think that + * it makes sense to get a new one to replace the closed one. + * + * Be warned that you will get a brand new object manager as + * the existing one is not useable anymore. This means that any + * other object with a dependency on this object manager will + * hold an obsolete reference. You can inject the registry instead + * to avoid this problem. + * + * @param string $name The object manager name (null for the default one) + * + * @return \Doctrine\Common\Persistence\ObjectManager + */ + function resetManager($name = null); + + /** + * Resolves a registered namespace alias to the full namespace. + * + * This method looks for the alias in all registered object managers. + * + * @param string $alias The alias + * + * @return string The full namespace + */ + function getAliasNamespace($alias); + + /** + * Gets all connection names. + * + * @return array An array of connection names + */ + function getManagerNames(); + + /** + * Gets the ObjectRepository for an persistent object. + * + * @param string $persistentObject The name of the persistent object. + * @param string $persistentManagerName The object manager name (null for the default one) + * + * @return \Doctrine\Common\Persistence\ObjectRepository + */ + function getRepository($persistentObject, $persistentManagerName = null); + + /** + * Gets the object manager associated with a given class. + * + * @param string $class A persistent object class name + * + * @return \Doctrine\Common\Persistence\ObjectManager|null + */ + function getManagerForClass($class); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php new file mode 100644 index 0000000..a2a6185 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php @@ -0,0 +1,359 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping; + +use Doctrine\Common\Cache\Cache; + +/** + * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the + * metadata mapping informations of a class which describes how a class should be mapped + * to a relational database. + * + * This class was abstracted from the ORM ClassMetadataFactory + * + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +abstract class AbstractClassMetadataFactory implements ClassMetadataFactory +{ + /** + * Salt used by specific Object Manager implementation. + * + * @var string + */ + protected $cacheSalt = "\$CLASSMETADATA"; + + /** + * @var \Doctrine\Common\Cache\Cache + */ + private $cacheDriver; + + /** + * @var array + */ + private $loadedMetadata = array(); + + /** + * @var bool + */ + protected $initialized = false; + + /** + * @var ReflectionService + */ + private $reflectionService; + + /** + * Sets the cache driver used by the factory to cache ClassMetadata instances. + * + * @param Doctrine\Common\Cache\Cache $cacheDriver + */ + public function setCacheDriver(Cache $cacheDriver = null) + { + $this->cacheDriver = $cacheDriver; + } + + /** + * Gets the cache driver used by the factory to cache ClassMetadata instances. + * + * @return Doctrine\Common\Cache\Cache + */ + public function getCacheDriver() + { + return $this->cacheDriver; + } + + /** + * Return an array of all the loaded metadata currently in memory. + * + * @return array + */ + public function getLoadedMetadata() + { + return $this->loadedMetadata; + } + + /** + * Forces the factory to load the metadata of all classes known to the underlying + * mapping driver. + * + * @return array The ClassMetadata instances of all mapped classes. + */ + public function getAllMetadata() + { + if ( ! $this->initialized) { + $this->initialize(); + } + + $driver = $this->getDriver(); + $metadata = array(); + foreach ($driver->getAllClassNames() as $className) { + $metadata[] = $this->getMetadataFor($className); + } + + return $metadata; + } + + /** + * Lazy initialization of this stuff, especially the metadata driver, + * since these are not needed at all when a metadata cache is active. + * + * @return void + */ + abstract protected function initialize(); + + /** + * Get the fully qualified class-name from the namespace alias. + * + * @param string $namespaceAlias + * @param string $simpleClassName + * @return string + */ + abstract protected function getFqcnFromAlias($namespaceAlias, $simpleClassName); + + /** + * Return the mapping driver implementation. + * + * @return MappingDriver + */ + abstract protected function getDriver(); + + /** + * Wakeup reflection after ClassMetadata gets unserialized from cache. + * + * @param ClassMetadata $class + * @param ReflectionService $reflService + * @return void + */ + abstract protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService); + + /** + * Initialize Reflection after ClassMetadata was constructed. + * + * @param ClassMetadata $class + * @param ReflectionSErvice $reflService + * @return void + */ + abstract protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService); + + /** + * Gets the class metadata descriptor for a class. + * + * @param string $className The name of the class. + * @return Doctrine\Common\Persistence\Mapping\ClassMetadata + */ + public function getMetadataFor($className) + { + if ( ! isset($this->loadedMetadata[$className])) { + $realClassName = $className; + + // Check for namespace alias + if (strpos($className, ':') !== false) { + list($namespaceAlias, $simpleClassName) = explode(':', $className); + $realClassName = $this->getFqcnFromAlias($namespaceAlias, $simpleClassName); + + if (isset($this->loadedMetadata[$realClassName])) { + // We do not have the alias name in the map, include it + $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; + + return $this->loadedMetadata[$realClassName]; + } + } + + if ($this->cacheDriver) { + if (($cached = $this->cacheDriver->fetch($realClassName . $this->cacheSalt)) !== false) { + $this->loadedMetadata[$realClassName] = $cached; + $this->wakeupReflection($cached, $this->getReflectionService()); + } else { + foreach ($this->loadMetadata($realClassName) as $loadedClassName) { + $this->cacheDriver->save( + $loadedClassName . $this->cacheSalt, $this->loadedMetadata[$loadedClassName], null + ); + } + } + } else { + $this->loadMetadata($realClassName); + } + + if ($className != $realClassName) { + // We do not have the alias name in the map, include it + $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName]; + } + } + + return $this->loadedMetadata[$className]; + } + + /** + * Checks whether the factory has the metadata for a class loaded already. + * + * @param string $className + * @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise. + */ + public function hasMetadataFor($className) + { + return isset($this->loadedMetadata[$className]); + } + + /** + * Sets the metadata descriptor for a specific class. + * + * NOTE: This is only useful in very special cases, like when generating proxy classes. + * + * @param string $className + * @param ClassMetadata $class + */ + public function setMetadataFor($className, $class) + { + $this->loadedMetadata[$className] = $class; + } + + /** + * Get array of parent classes for the given entity class + * + * @param string $name + * @return array $parentClasses + */ + protected function getParentClasses($name) + { + // Collect parent classes, ignoring transient (not-mapped) classes. + $parentClasses = array(); + foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) { + if ( ! $this->getDriver()->isTransient($parentClass)) { + $parentClasses[] = $parentClass; + } + } + return $parentClasses; + } + + /** + * Loads the metadata of the class in question and all it's ancestors whose metadata + * is still not loaded. + * + * @param string $name The name of the class for which the metadata should get loaded. + * @param array $tables The metadata collection to which the loaded metadata is added. + */ + protected function loadMetadata($name) + { + if ( ! $this->initialized) { + $this->initialize(); + } + + $loaded = array(); + + $parentClasses = $this->getParentClasses($name); + $parentClasses[] = $name; + + // Move down the hierarchy of parent classes, starting from the topmost class + $parent = null; + $rootEntityFound = false; + $visited = array(); + $reflService = $this->getReflectionService(); + foreach ($parentClasses as $className) { + if (isset($this->loadedMetadata[$className])) { + $parent = $this->loadedMetadata[$className]; + if (isset($parent->isMappedSuperclass) && $parent->isMappedSuperclass === false) { + $rootEntityFound = true; + array_unshift($visited, $className); + } + continue; + } + + $class = $this->newClassMetadataInstance($className); + $this->initializeReflection($class, $reflService); + + $this->doLoadMetadata($class, $parent, $rootEntityFound); + + $this->loadedMetadata[$className] = $class; + + $parent = $class; + + if (isset($parent->isMappedSuperclass) && $class->isMappedSuperclass === false) { + $rootEntityFound = true; + array_unshift($visited, $className); + } + + $this->wakeupReflection($class, $reflService); + + $loaded[] = $className; + } + + return $loaded; + } + + /** + * Actually load the metadata from the underlying metadata + * + * @param ClassMetadata $class + * @param ClassMetadata $parent + * @param bool $rootEntityFound + * @return void + */ + abstract protected function doLoadMetadata($class, $parent, $rootEntityFound); + + /** + * Creates a new ClassMetadata instance for the given class name. + * + * @param string $className + * @return ClassMetadata + */ + abstract protected function newClassMetadataInstance($className); + + /** + * Check if this class is mapped by this Object Manager + ClassMetadata configuration + * + * @param $class + * @return bool + */ + public function isTransient($class) + { + if ( ! $this->initialized) { + $this->initialize(); + } + + return $this->getDriver()->isTransient($class); + } + + /** + * Set reflectionService. + * + * @param ReflectionService $reflectionService + */ + public function setReflectionService(ReflectionService $reflectionService) + { + $this->reflectionService = $reflectionService; + } + + /** + * Get the reflection service associated with this metadata factory. + * + * @return ReflectionService + */ + public function getReflectionService() + { + if ($this->reflectionService === null) { + $this->reflectionService = new RuntimeReflectionService(); + } + return $this->reflectionService; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php new file mode 100644 index 0000000..705d59a --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadata.php @@ -0,0 +1,165 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping; + +/** + * Contract for a Doctrine persistence layer ClassMetadata class to implement. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage + */ +interface ClassMetadata +{ + /** + * Get fully-qualified class name of this persistent class. + * + * @return string + */ + function getName(); + + /** + * Gets the mapped identifier field name. + * + * The returned structure is an array of the identifier field names. + * + * @return array + */ + function getIdentifier(); + + /** + * Gets the ReflectionClass instance for this mapped class. + * + * @return ReflectionClass + */ + function getReflectionClass(); + + /** + * Checks if the given field name is a mapped identifier for this class. + * + * @param string $fieldName + * @return boolean + */ + function isIdentifier($fieldName); + + /** + * Checks if the given field is a mapped property for this class. + * + * @param string $fieldName + * @return boolean + */ + function hasField($fieldName); + + /** + * Checks if the given field is a mapped association for this class. + * + * @param string $fieldName + * @return boolean + */ + function hasAssociation($fieldName); + + /** + * Checks if the given field is a mapped single valued association for this class. + * + * @param string $fieldName + * @return boolean + */ + function isSingleValuedAssociation($fieldName); + + /** + * Checks if the given field is a mapped collection valued association for this class. + * + * @param string $fieldName + * @return boolean + */ + function isCollectionValuedAssociation($fieldName); + + /** + * A numerically indexed list of field names of this persistent class. + * + * This array includes identifier fields if present on this class. + * + * @return array + */ + function getFieldNames(); + + /** + * Returns an array of identifier field names numerically indexed. + * + * @return array + */ + function getIdentifierFieldNames(); + + /** + * A numerically indexed list of association names of this persistent class. + * + * This array includes identifier associations if present on this class. + * + * @return array + */ + function getAssociationNames(); + + /** + * Returns a type name of this field. + * + * This type names can be implementation specific but should at least include the php types: + * integer, string, boolean, float/double, datetime. + * + * @param string $fieldName + * @return string + */ + function getTypeOfField($fieldName); + + /** + * Returns the target class name of the given association. + * + * @param string $assocName + * @return string + */ + function getAssociationTargetClass($assocName); + + /** + * Checks if the association is the inverse side of a bidirectional association + * + * @param string $assocName + * @return boolean + */ + function isAssociationInverseSide($assocName); + + /** + * Returns the target field of the owning side of the association + * + * @param string $assocName + * @return string + */ + function getAssociationMappedByTargetField($assocName); + + /** + * Return the identifier of this object as an array with field name as key. + * + * Has to return an empty array if no identifier isset. + * + * @param object $object + * @return array + */ + function getIdentifierValues($object); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php new file mode 100644 index 0000000..bf27ba9 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ClassMetadataFactory.php @@ -0,0 +1,74 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping; + +/** + * Contract for a Doctrine persistence layer ClassMetadata class to implement. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage + */ +interface ClassMetadataFactory +{ + /** + * Forces the factory to load the metadata of all classes known to the underlying + * mapping driver. + * + * @return array The ClassMetadata instances of all mapped classes. + */ + function getAllMetadata(); + + /** + * Gets the class metadata descriptor for a class. + * + * @param string $className The name of the class. + * @return ClassMetadata + */ + function getMetadataFor($className); + + /** + * Checks whether the factory has the metadata for a class loaded already. + * + * @param string $className + * @return boolean TRUE if the metadata of the class in question is already loaded, FALSE otherwise. + */ + function hasMetadataFor($className); + + /** + * Sets the metadata descriptor for a specific class. + * + * @param string $className + * @param ClassMetadata $class + */ + function setMetadataFor($className, $class); + + /** + * Whether the class with the specified name should have its metadata loaded. + * This is only the case if it is either mapped directly or as a + * MappedSuperclass. + * + * @param string $className + * @return boolean + */ + function isTransient($className); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php new file mode 100644 index 0000000..f52d37e --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php @@ -0,0 +1,214 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Cache\ArrayCache, + Doctrine\Common\Annotations\AnnotationReader, + Doctrine\Common\Annotations\AnnotationRegistry, + Doctrine\Common\Persistence\Mapping\MappingException; + +/** + * The AnnotationDriver reads the mapping metadata from docblock annotations. + * + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel + */ +abstract class AnnotationDriver implements MappingDriver +{ + /** + * The AnnotationReader. + * + * @var AnnotationReader + */ + protected $reader; + + /** + * The paths where to look for mapping files. + * + * @var array + */ + protected $paths = array(); + + /** + * The file extension of mapping documents. + * + * @var string + */ + protected $fileExtension = '.php'; + + /** + * Cache for AnnotationDriver#getAllClassNames() + * + * @var array + */ + protected $classNames; + + /** + * Name of the entity annotations as keys + * + * @var array + */ + protected $entityAnnotationClasses = array(); + + /** + * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading + * docblock annotations. + * + * @param AnnotationReader $reader The AnnotationReader to use, duck-typed. + * @param string|array $paths One or multiple paths where mapping classes can be found. + */ + public function __construct($reader, $paths = null) + { + $this->reader = $reader; + if ($paths) { + $this->addPaths((array) $paths); + } + } + + /** + * Append lookup paths to metadata driver. + * + * @param array $paths + */ + public function addPaths(array $paths) + { + $this->paths = array_unique(array_merge($this->paths, $paths)); + } + + /** + * Retrieve the defined metadata lookup paths. + * + * @return array + */ + public function getPaths() + { + return $this->paths; + } + + /** + * Retrieve the current annotation reader + * + * @return AnnotationReader + */ + public function getReader() + { + return $this->reader; + } + + /** + * Get the file extension used to look for mapping files under + * + * @return void + */ + public function getFileExtension() + { + return $this->fileExtension; + } + + /** + * Set the file extension used to look for mapping files under + * + * @param string $fileExtension The file extension to set + * @return void + */ + public function setFileExtension($fileExtension) + { + $this->fileExtension = $fileExtension; + } + + /** + * Whether the class with the specified name is transient. Only non-transient + * classes, that is entities and mapped superclasses, should have their metadata loaded. + * + * A class is non-transient if it is annotated with an annotation + * from the {@see AnnotationDriver::entityAnnotationClasses}. + * + * @param string $className + * @return boolean + */ + public function isTransient($className) + { + $classAnnotations = $this->reader->getClassAnnotations(new \ReflectionClass($className)); + + foreach ($classAnnotations as $annot) { + if (isset($this->entityAnnotationClasses[get_class($annot)])) { + return false; + } + } + return true; + } + + /** + * {@inheritDoc} + */ + public function getAllClassNames() + { + if ($this->classNames !== null) { + return $this->classNames; + } + + if (!$this->paths) { + throw MappingException::pathRequired(); + } + + $classes = array(); + $includedFiles = array(); + + foreach ($this->paths as $path) { + if ( ! is_dir($path)) { + throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); + } + + $iterator = new \RegexIterator( + new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), + \RecursiveIteratorIterator::LEAVES_ONLY + ), + '/^.+' . str_replace('.', '\.', $this->fileExtension) . '$/i', + \RecursiveRegexIterator::GET_MATCH + ); + + foreach ($iterator as $file) { + $sourceFile = realpath($file[0]); + + require_once $sourceFile; + + $includedFiles[] = $sourceFile; + } + } + + $declared = get_declared_classes(); + + foreach ($declared as $className) { + $rc = new \ReflectionClass($className); + $sourceFile = $rc->getFileName(); + if (in_array($sourceFile, $includedFiles) && ! $this->isTransient($className)) { + $classes[] = $className; + } + } + + $this->classNames = $classes; + + return $classes; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php new file mode 100644 index 0000000..efaf545 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php @@ -0,0 +1,169 @@ +. +*/ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Persistence\Mapping\MappingException; + +/** + * Locate the file that contains the metadata information for a given class name. + * + * This behavior is inpependent of the actual content of the file. It just detects + * the file which is responsible for the given class name. + * + * @author Benjamin Eberlei + * @author Johannes M. Schmitt + */ +class DefaultFileLocator implements FileLocator +{ + /** + * The paths where to look for mapping files. + * + * @var array + */ + protected $paths = array(); + + /** + * The file extension of mapping documents. + * + * @var string + */ + protected $fileExtension; + + /** + * Initializes a new FileDriver that looks in the given path(s) for mapping + * documents and operates in the specified operating mode. + * + * @param string|array $paths One or multiple paths where mapping documents can be found. + */ + public function __construct($paths, $fileExtension = null) + { + $this->addPaths((array) $paths); + $this->fileExtension = $fileExtension; + } + + /** + * Append lookup paths to metadata driver. + * + * @param array $paths + */ + public function addPaths(array $paths) + { + $this->paths = array_unique(array_merge($this->paths, $paths)); + } + + /** + * Retrieve the defined metadata lookup paths. + * + * @return array + */ + public function getPaths() + { + return $this->paths; + } + + /** + * Get the file extension used to look for mapping files under + * + * @return void + */ + public function getFileExtension() + { + return $this->fileExtension; + } + + /** + * Set the file extension used to look for mapping files under + * + * @param string $fileExtension The file extension to set + * @return void + */ + public function setFileExtension($fileExtension) + { + $this->fileExtension = $fileExtension; + } + + /** + * {@inheritDoc} + */ + public function findMappingFile($className) + { + $fileName = str_replace('\\', '.', $className) . $this->fileExtension; + + // Check whether file exists + foreach ($this->paths as $path) { + if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { + return $path . DIRECTORY_SEPARATOR . $fileName; + } + } + + throw MappingException::mappingFileNotFound($className, $fileName); + } + + /** + * {@inheritDoc} + */ + public function getAllClassNames($globalBasename) + { + $classes = array(); + + if ($this->paths) { + foreach ($this->paths as $path) { + if ( ! is_dir($path)) { + throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); + } + + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path), + \RecursiveIteratorIterator::LEAVES_ONLY + ); + + foreach ($iterator as $file) { + $fileName = $file->getBasename($this->fileExtension); + + if ($fileName == $file->getBasename() || $fileName == $globalBasename) { + continue; + } + + // NOTE: All files found here means classes are not transient! + $classes[] = str_replace('.', '\\', $fileName); + } + } + } + + return $classes; + } + + /** + * {@inheritDoc} + */ + public function fileExists($className) + { + $fileName = str_replace('\\', '.', $className) . $this->fileExtension; + + // Check whether file exists + foreach ((array) $this->paths as $path) { + if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { + return true; + } + } + + return false; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php new file mode 100644 index 0000000..22cf117 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php @@ -0,0 +1,178 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Persistence\Mapping\MappingException; + +/** + * Base driver for file-based metadata drivers. + * + * A file driver operates in a mode where it loads the mapping files of individual + * classes on demand. This requires the user to adhere to the convention of 1 mapping + * file per class and the file names of the mapping files must correspond to the full + * class name, including namespace, with the namespace delimiters '\', replaced by dots '.'. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.com + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel + */ +abstract class FileDriver implements MappingDriver +{ + /** + * @var FileLocator + */ + protected $locator; + + /** + * @var array + */ + protected $classCache; + + /** + * @var string + */ + protected $globalBasename; + + /** + * Initializes a new FileDriver that looks in the given path(s) for mapping + * documents and operates in the specified operating mode. + * + * @param string|array|FileLocator $paths A FileLocator or one/multiple paths where mapping documents can be found. + * @param string $fileExtension + */ + public function __construct($locator, $fileExtension = null) + { + if ($locator instanceof FileLocator) { + $this->locator = $locator; + } else { + $this->locator = new DefaultFileLocator((array)$locator, $fileExtension); + } + } + + public function setGlobalBasename($file) + { + $this->globalBasename = $file; + } + + public function getGlobalBasename() + { + return $this->globalBasename; + } + + /** + * Get the element of schema meta data for the class from the mapping file. + * This will lazily load the mapping file if it is not loaded yet + * + * @return array $element The element of schema meta data + */ + public function getElement($className) + { + if ($this->classCache === null) { + $this->initialize(); + } + + if (isset($this->classCache[$className])) { + return $this->classCache[$className]; + } + + $result = $this->loadMappingFile($this->locator->findMappingFile($className)); + + return $result[$className]; + } + + /** + * Whether the class with the specified name should have its metadata loaded. + * This is only the case if it is either mapped as an Entity or a + * MappedSuperclass. + * + * @param string $className + * @return boolean + */ + public function isTransient($className) + { + if ($this->classCache === null) { + $this->initialize(); + } + + if (isset($this->classCache[$className])) { + return false; + } + + return !$this->locator->fileExists($className); + } + + /** + * Gets the names of all mapped classes known to this driver. + * + * @return array The names of all mapped classes known to this driver. + */ + public function getAllClassNames() + { + if ($this->classCache === null) { + $this->initialize(); + } + + $classNames = (array)$this->locator->getAllClassNames($this->globalBasename); + if ($this->classCache) { + $classNames = array_merge(array_keys($this->classCache), $classNames); + } + return $classNames; + } + + /** + * Loads a mapping file with the given name and returns a map + * from class/entity names to their corresponding file driver elements. + * + * @param string $file The mapping file to load. + * @return array + */ + abstract protected function loadMappingFile($file); + + /** + * Initialize the class cache from all the global files. + * + * Using this feature adds a substantial performance hit to file drivers as + * more metadata has to be loaded into memory than might actually be + * necessary. This may not be relevant to scenarios where caching of + * metadata is in place, however hits very hard in scenarios where no + * caching is used. + * + * @return void + */ + protected function initialize() + { + $this->classCache = array(); + if (null !== $this->globalBasename) { + foreach ($this->locator->getPaths() as $path) { + $file = $path.'/'.$this->globalBasename.$this->locator->getFileExtension(); + if (is_file($file)) { + $this->classCache = array_merge( + $this->classCache, + $this->loadMappingFile($file) + ); + } + } + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php new file mode 100644 index 0000000..a1019d7 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/FileLocator.php @@ -0,0 +1,69 @@ +. +*/ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +/** + * Locate the file that contains the metadata information for a given class name. + * + * This behavior is inpependent of the actual content of the file. It just detects + * the file which is responsible for the given class name. + * + * @author Benjamin Eberlei + * @author Johannes M. Schmitt + */ +interface FileLocator +{ + /** + * Locate mapping file for the given class name. + * + * @param string $className + * @return string + */ + function findMappingFile($className); + + /** + * Get all class names that are found with this file locator. + * + * @param string $globalBasename Passed to allow excluding the basename + * @return array + */ + function getAllClassNames($globalBasename); + + /** + * Check if a file can be found for this class name. + * + * @return bool + */ + function fileExists($className); + + /** + * Get all the paths that this file locator looks for mapping files. + * + * @return array + */ + function getPaths(); + + /** + * Get the file extension that mapping files are suffixed with. + * + * @return string + */ + function getFileExtension(); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php new file mode 100644 index 0000000..c050d32 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriver.php @@ -0,0 +1,56 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Persistence\Mapping\ClassMetadata; + +/** + * Contract for metadata drivers. + * + * @since 2.2 + * @author Jonathan H. Wage + */ +interface MappingDriver +{ + /** + * Loads the metadata for the specified class into the provided container. + * + * @param string $className + * @param ClassMetadata $metadata + */ + function loadMetadataForClass($className, ClassMetadata $metadata); + + /** + * Gets the names of all mapped classes known to this driver. + * + * @return array The names of all mapped classes known to this driver. + */ + function getAllClassNames(); + + /** + * Whether the class with the specified name should have its metadata loaded. + * This is only the case if it is either mapped as an Entity or a + * MappedSuperclass. + * + * @param string $className + * @return boolean + */ + function isTransient($className); +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php new file mode 100644 index 0000000..c7c1452 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php @@ -0,0 +1,125 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, + Doctrine\Common\Persistence\Mapping\ClassMetadata, + Doctrine\Common\Persistence\Mapping\MappingException; + +/** + * The DriverChain allows you to add multiple other mapping drivers for + * certain namespaces + * + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel + */ +class MappingDriverChain implements MappingDriver +{ + /** + * @var array + */ + private $drivers = array(); + + /** + * Add a nested driver. + * + * @param Driver $nestedDriver + * @param string $namespace + */ + public function addDriver(MappingDriver $nestedDriver, $namespace) + { + $this->drivers[$namespace] = $nestedDriver; + } + + /** + * Get the array of nested drivers. + * + * @return array $drivers + */ + public function getDrivers() + { + return $this->drivers; + } + + /** + * Loads the metadata for the specified class into the provided container. + * + * @param string $className + * @param ClassMetadataInfo $metadata + */ + public function loadMetadataForClass($className, ClassMetadata $metadata) + { + foreach ($this->drivers as $namespace => $driver) { + if (strpos($className, $namespace) === 0) { + $driver->loadMetadataForClass($className, $metadata); + return; + } + } + + throw MappingException::classNotFoundInNamespaces($className, array_keys($this->drivers)); + } + + /** + * Gets the names of all mapped classes known to this driver. + * + * @return array The names of all mapped classes known to this driver. + */ + public function getAllClassNames() + { + $classNames = array(); + $driverClasses = array(); + foreach ($this->drivers AS $namespace => $driver) { + $oid = spl_object_hash($driver); + if (!isset($driverClasses[$oid])) { + $driverClasses[$oid] = $driver->getAllClassNames(); + } + + foreach ($driverClasses[$oid] AS $className) { + if (strpos($className, $namespace) === 0) { + $classNames[$className] = true; + } + } + } + return array_keys($classNames); + } + + /** + * Whether the class with the specified name should have its metadata loaded. + * + * This is only the case for non-transient classes either mapped as an Entity or MappedSuperclass. + * + * @param string $className + * @return boolean + */ + public function isTransient($className) + { + foreach ($this->drivers AS $namespace => $driver) { + if (strpos($className, $namespace) === 0) { + return $driver->isTransient($className); + } + } + + // class isTransient, i.e. not an entity or mapped superclass + return true; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php new file mode 100644 index 0000000..7751dae --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php @@ -0,0 +1,70 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Persistence\Mapping\ClassMetadata; + +/** + * The PHPDriver includes php files which just populate ClassMetadataInfo + * instances with plain php code + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision$ + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel + */ +class PHPDriver extends FileDriver +{ + /** + * {@inheritdoc} + */ + protected $metadata; + + /** + * {@inheritDoc} + */ + public function __construct($locator, $fileExtension = null) + { + $fileExtension = ".php"; + parent::__construct($locator, $fileExtension); + } + + /** + * {@inheritdoc} + */ + public function loadMetadataForClass($className, ClassMetadata $metadata) + { + $this->metadata = $metadata; + $this->loadMappingFile($this->locator->findMappingFile($className)); + } + + /** + * {@inheritdoc} + */ + protected function loadMappingFile($file) + { + $metadata = $this->metadata; + include $file; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php new file mode 100644 index 0000000..9103ed8 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php @@ -0,0 +1,131 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Persistence\Mapping\MappingException; + +/** + * The StaticPHPDriver calls a static loadMetadata() method on your entity + * classes where you can manually populate the ClassMetadata instance. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.2 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan H. Wage + * @author Roman Borschel + */ +class StaticPHPDriver implements MappingDriver +{ + /** + * Paths of entity directories. + * + * @var array + */ + private $paths = array(); + + /** + * Map of all class names. + * + * @var array + */ + private $classNames; + + public function __construct($paths) + { + $this->addPaths((array) $paths); + } + + public function addPaths(array $paths) + { + $this->paths = array_unique(array_merge($this->paths, $paths)); + } + + /** + * {@inheritdoc} + */ + public function loadMetadataForClass($className, ClassMetadata $metadata) + { + $className::loadMetadata($metadata); + } + + /** + * {@inheritDoc} + * @todo Same code exists in AnnotationDriver, should we re-use it somehow or not worry about it? + */ + public function getAllClassNames() + { + if ($this->classNames !== null) { + return $this->classNames; + } + + if (!$this->paths) { + throw MappingException::pathRequired(); + } + + $classes = array(); + $includedFiles = array(); + + foreach ($this->paths as $path) { + if (!is_dir($path)) { + throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); + } + + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path), + \RecursiveIteratorIterator::LEAVES_ONLY + ); + + foreach ($iterator as $file) { + if ($file->getBasename('.php') == $file->getBasename()) { + continue; + } + + $sourceFile = realpath($file->getPathName()); + require_once $sourceFile; + $includedFiles[] = $sourceFile; + } + } + + $declared = get_declared_classes(); + + foreach ($declared as $className) { + $rc = new \ReflectionClass($className); + $sourceFile = $rc->getFileName(); + if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { + $classes[] = $className; + } + } + + $this->classNames = $classes; + + return $classes; + } + + /** + * {@inheritdoc} + */ + public function isTransient($className) + { + return ! method_exists($className, 'loadMetadata'); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php new file mode 100644 index 0000000..d338cf6 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php @@ -0,0 +1,198 @@ +. +*/ + +namespace Doctrine\Common\Persistence\Mapping\Driver; + +use Doctrine\Common\Persistence\Mapping\MappingException; + +/** + * The Symfony File Locator makes a simplifying assumptions compared + * to the DefaultFileLocator. By assuming paths only contain entities of a certain + * namespace the mapping files consists of the short classname only. + * + * @author Fabien Potencier + * @author Benjamin Eberlei + * @license MIT + */ +class SymfonyFileLocator implements FileLocator +{ + /** + * The paths where to look for mapping files. + * + * @var array + */ + protected $paths = array(); + + /** + * A map of mapping directory path to namespace prefix used to expand class shortnames. + * + * @var array + */ + protected $prefixes = array(); + + /** + * File extension that is searched for. + * + * @var string + */ + protected $fileExtension; + + public function __construct(array $prefixes, $fileExtension = null) + { + $this->addNamespacePrefixes($prefixes); + $this->fileExtension = $fileExtension; + } + + public function addNamespacePrefixes(array $prefixes) + { + $this->prefixes = array_merge($this->prefixes, $prefixes); + $this->paths = array_merge($this->paths, array_keys($prefixes)); + } + + public function getNamespacePrefixes() + { + return $this->prefixes; + } + + /** + * {@inheritDoc} + */ + public function getPaths() + { + return $this->paths; + } + + /** + * {@inheritDoc} + */ + public function getFileExtension() + { + return $this->fileExtension; + } + + /** + * Set the file extension used to look for mapping files under + * + * @param string $fileExtension The file extension to set + * @return void + */ + public function setFileExtension($fileExtension) + { + $this->fileExtension = $fileExtension; + } + + /** + * {@inheritDoc} + */ + public function fileExists($className) + { + $defaultFileName = str_replace('\\', '.', $className).$this->fileExtension; + foreach ($this->paths as $path) { + if (!isset($this->prefixes[$path])) { + // global namespace class + if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) { + return true; + } + + continue; + } + + $prefix = $this->prefixes[$path]; + + if (0 !== strpos($className, $prefix.'\\')) { + continue; + } + + $filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension; + return is_file($filename); + } + + return false; + } + + /** + * {@inheritDoc} + */ + public function getAllClassNames($globalBasename = null) + { + $classes = array(); + + if ($this->paths) { + foreach ((array) $this->paths as $path) { + if (!is_dir($path)) { + throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); + } + + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($path), + \RecursiveIteratorIterator::LEAVES_ONLY + ); + + foreach ($iterator as $file) { + $fileName = $file->getBasename($this->fileExtension); + + if ($fileName == $file->getBasename() || $fileName == $globalBasename) { + continue; + } + + // NOTE: All files found here means classes are not transient! + if (isset($this->prefixes[$path])) { + $classes[] = $this->prefixes[$path].'\\'.str_replace('.', '\\', $fileName); + } else { + $classes[] = str_replace('.', '\\', $fileName); + } + } + } + } + + return $classes; + } + + /** + * {@inheritDoc} + */ + public function findMappingFile($className) + { + $defaultFileName = str_replace('\\', '.', $className).$this->fileExtension; + foreach ($this->paths as $path) { + if (!isset($this->prefixes[$path])) { + if (is_file($path.DIRECTORY_SEPARATOR.$defaultFileName)) { + return $path.DIRECTORY_SEPARATOR.$defaultFileName; + } + + continue; + } + + $prefix = $this->prefixes[$path]; + + if (0 !== strpos($className, $prefix.'\\')) { + continue; + } + + $filename = $path.'/'.strtr(substr($className, strlen($prefix)+1), '\\', '.').$this->fileExtension; + if (is_file($filename)) { + return $filename; + } + + throw MappingException::mappingFileNotFound($className, $filename); + } + + throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1).$this->fileExtension); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/MappingException.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/MappingException.php new file mode 100644 index 0000000..4ecd2ad --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/MappingException.php @@ -0,0 +1,57 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping; + +/** + * A MappingException indicates that something is wrong with the mapping setup. + * + * @since 2.2 + */ +class MappingException extends \Exception +{ + public static function classNotFoundInNamespaces($className, $namespaces) + { + return new self("The class '" . $className . "' was not found in the ". + "chain configured namespaces " . implode(", ", $namespaces)); + } + + public static function pathRequired() + { + return new self("Specifying the paths to your entities is required ". + "in the AnnotationDriver to retrieve all class names."); + } + + public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null) + { + if ( ! empty($path)) { + $path = '[' . $path . ']'; + } + + return new self( + 'File mapping drivers must have a valid directory path, ' . + 'however the given path ' . $path . ' seems to be incorrect!' + ); + } + + public static function mappingFileNotFound($entityName, $fileName) + { + return new self("No mapping file found named '$fileName' for class '$entityName'."); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php new file mode 100644 index 0000000..4e0e312 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/ReflectionService.php @@ -0,0 +1,80 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping; + +/** + * Very simple reflection service abstraction. + * + * This is required inside metadata layers that may require either + * static or runtime reflection. + * + * @author Benjamin Eberlei + */ +interface ReflectionService +{ + /** + * Return an array of the parent classes (not interfaces) for the given class. + * + * @param string $class + * @return array + */ + function getParentClasses($class); + + /** + * Return the shortname of a class. + * + * @param string $class + * @return string + */ + function getClassShortName($class); + + /** + * @param string $class + * @return string + */ + function getClassNamespace($class); + + /** + * Return a reflection class instance or null + * + * @param string $class + * @return ReflectionClass|null + */ + function getClass($class); + + /** + * Return an accessible property (setAccessible(true)) or null. + * + * @param string $class + * @param string $property + * @return ReflectionProperty|null + */ + function getAccessibleProperty($class, $property); + + /** + * Check if the class have a public method with the given name. + * + * @param mixed $class + * @param mixed $method + * @return bool + */ + function hasPublicMethod($class, $method); +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php new file mode 100644 index 0000000..abcff58 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php @@ -0,0 +1,102 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping; + +use ReflectionClass; +use ReflectionProperty; + +/** + * PHP Runtime Reflection Service + * + * @author Benjamin Eberlei + */ +class RuntimeReflectionService implements ReflectionService +{ + /** + * Return an array of the parent classes (not interfaces) for the given class. + * + * @param string $class + * @return array + */ + public function getParentClasses($class) + { + return class_parents($class); + } + + /** + * Return the shortname of a class. + * + * @param string $class + * @return string + */ + public function getClassShortName($class) + { + $r = new ReflectionClass($class); + return $r->getShortName(); + } + + /** + * @param string $class + * @return string + */ + public function getClassNamespace($class) + { + $r = new ReflectionClass($class); + return $r->getNamespaceName(); + } + + /** + * Return a reflection class instance or null + * + * @param string $class + * @return ReflectionClass|null + */ + public function getClass($class) + { + return new ReflectionClass($class); + } + + /** + * Return an accessible property (setAccessible(true)) or null. + * + * @param string $class + * @param string $property + * @return ReflectionProperty|null + */ + public function getAccessibleProperty($class, $property) + { + $property = new ReflectionProperty($class, $property); + $property->setAccessible(true); + return $property; + } + + /** + * Check if the class have a public method with the given name. + * + * @param mixed $class + * @param mixed $method + * @return bool + */ + public function hasPublicMethod($class, $method) + { + return method_exists($class, $method) && is_callable(array($class, $method)); + } +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php new file mode 100644 index 0000000..2de6e76 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php @@ -0,0 +1,107 @@ +. + */ + +namespace Doctrine\Common\Persistence\Mapping; + +use ReflectionClass; +use ReflectionProperty; + +/** + * PHP Runtime Reflection Service + * + * @author Benjamin Eberlei + */ +class StaticReflectionService implements ReflectionService +{ + /** + * Return an array of the parent classes (not interfaces) for the given class. + * + * @param string $class + * @return array + */ + public function getParentClasses($class) + { + return array(); + } + + /** + * Return the shortname of a class. + * + * @param string $className + * @return string + */ + public function getClassShortName($className) + { + if (strpos($className, '\\') !== false) { + $className = substr($className, strrpos($className, "\\")+1); + } + return $className; + } + + /** + * Return the namespace of a class. + * + * @param string $className + * @return string + */ + public function getClassNamespace($className) + { + $namespace = ''; + if (strpos($className, '\\') !== false) { + $namespace = strrev(substr( strrev($className), strpos(strrev($className), '\\')+1 )); + } + return $namespace; + } + + /** + * Return a reflection class instance or null + * + * @param string $class + * @return ReflectionClass|null + */ + public function getClass($class) + { + return null; + } + + /** + * Return an accessible property (setAccessible(true)) or null. + * + * @param string $class + * @param string $property + * @return ReflectionProperty|null + */ + public function getAccessibleProperty($class, $property) + { + return null; + } + + /** + * Check if the class have a public method with the given name. + * + * @param mixed $class + * @param mixed $method + * @return bool + */ + public function hasPublicMethod($class, $method) + { + return method_exists($class, $method) && is_callable(array($class, $method)); + } +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManager.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManager.php new file mode 100644 index 0000000..6d70fc1 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManager.php @@ -0,0 +1,143 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +/** + * Contract for a Doctrine persistence layer ObjectManager class to implement. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage + */ +interface ObjectManager +{ + /** + * Finds a object by its identifier. + * + * This is just a convenient shortcut for getRepository($className)->find($id). + * + * @param string + * @param mixed + * @return object + */ + function find($className, $id); + + /** + * Tells the ObjectManager to make an instance managed and persistent. + * + * The object will be entered into the database as a result of the flush operation. + * + * NOTE: The persist operation always considers objects that are not yet known to + * this ObjectManager as NEW. Do not pass detached objects to the persist operation. + * + * @param object $object The instance to make managed and persistent. + */ + function persist($object); + + /** + * Removes an object instance. + * + * A removed object will be removed from the database as a result of the flush operation. + * + * @param object $object The object instance to remove. + */ + function remove($object); + + /** + * Merges the state of a detached object into the persistence context + * of this ObjectManager and returns the managed copy of the object. + * The object passed to merge will not become associated/managed with this ObjectManager. + * + * @param object $object + */ + function merge($object); + + /** + * Detaches an object from the ObjectManager, causing a managed object to + * become detached. Unflushed changes made to the object if any + * (including removal of the object), will not be synchronized to the database. + * Objects which previously referenced the detached object will continue to + * reference it. + * + * @param object $object The object to detach. + */ + function detach($object); + + /** + * Refreshes the persistent state of an object from the database, + * overriding any local changes that have not yet been persisted. + * + * @param object $object The object to refresh. + */ + function refresh($object); + + /** + * Flushes all changes to objects that have been queued up to now to the database. + * This effectively synchronizes the in-memory state of managed objects with the + * database. + */ + function flush(); + + /** + * Gets the repository for a class. + * + * @param string $className + * @return \Doctrine\Common\Persistence\ObjectRepository + */ + function getRepository($className); + + /** + * Returns the ClassMetadata descriptor for a class. + * + * The class name must be the fully-qualified class name without a leading backslash + * (as it is returned by get_class($obj)). + * + * @param string $className + * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata + */ + function getClassMetadata($className); + + /** + * Gets the metadata factory used to gather the metadata of classes. + * + * @return Doctrine\Common\Persistence\Mapping\ClassMetadataFactory + */ + function getMetadataFactory(); + + /** + * Helper method to initialize a lazy loading proxy or persistent collection. + * + * This method is a no-op for other objects. + * + * @param object $obj + */ + function initializeObject($obj); + + /** + * Check if the object is part of the current UnitOfWork and therefore + * managed. + * + * @param object $object + * @return bool + */ + function contains($object); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManagerAware.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManagerAware.php new file mode 100644 index 0000000..015dd3d --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectManagerAware.php @@ -0,0 +1,49 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +use Doctrine\Common\Persistence\Mapping\ClassMetadata; + +/** + * Makes a Persistent Objects aware of its own object-manager. + * + * Using this interface the managing object manager and class metadata instances + * are injected into the persistent object after construction. This allows + * you to implement ActiveRecord functionality on top of the persistance-ignorance + * that Doctrine propagates. + * + * Word of Warning: This is a very powerful hook to change how you can work with your domain models. + * Using this hook will break the Single Responsibility Principle inside your Domain Objects + * and increase the coupling of database and objects. + * + * Every ObjectManager has to implement this functionality itself. + * + * @author Benjamin Eberlei + */ +interface ObjectManagerAware +{ + /** + * Injects responsible ObjectManager and the ClassMetadata into this persistent object. + * + * @param ObjectManager $objectManager + * @param ClassMetadata $classMetadata + */ + public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectRepository.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectRepository.php new file mode 100644 index 0000000..2263328 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/ObjectRepository.php @@ -0,0 +1,78 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +/** + * Contract for a Doctrine persistence layer ObjectRepository class to implement. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.1 + * @author Benjamin Eberlei + * @author Jonathan Wage + */ +interface ObjectRepository +{ + /** + * Finds an object by its primary key / identifier. + * + * @param $id The identifier. + * @return object The object. + */ + function find($id); + + /** + * Finds all objects in the repository. + * + * @return mixed The objects. + */ + function findAll(); + + /** + * Finds objects by a set of criteria. + * + * Optionally sorting and limiting details can be passed. An implementation may throw + * an UnexpectedValueException if certain values of the sorting or limiting details are + * not supported. + * + * @throws UnexpectedValueException + * @param array $criteria + * @param array|null $orderBy + * @param int|null $limit + * @param int|null $offset + * @return mixed The objects. + */ + function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null); + + /** + * Finds a single object by a set of criteria. + * + * @param array $criteria + * @return object The object. + */ + function findOneBy(array $criteria); + + /** + * Returns the class name of the object managed by the repository + * + * @return string + */ + function getClassName(); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/PersistentObject.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/PersistentObject.php new file mode 100644 index 0000000..4274af6 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/PersistentObject.php @@ -0,0 +1,233 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +use Doctrine\Common\Persistence\Mapping\ClassMetadata; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; + +/** + * PersistentObject base class that implements getter/setter methods for all mapped fields and associations + * by overriding __call. + * + * This class is a forward compatible implementation of the PersistentObject trait. + * + * + * Limitations: + * + * 1. All persistent objects have to be associated with a single ObjectManager, multiple + * ObjectManagers are not supported. You can set the ObjectManager with `PersistentObject#setObjectManager()`. + * 2. Setters and getters only work if a ClassMetadata instance was injected into the PersistentObject. + * This is either done on `postLoad` of an object or by accessing the global object manager. + * 3. There are no hooks for setters/getters. Just implement the method yourself instead of relying on __call(). + * 4. Slower than handcoded implementations: An average of 7 method calls per access to a field and 11 for an association. + * 5. Only the inverse side associations get autoset on the owning side aswell. Setting objects on the owning side + * will not set the inverse side associations. + * + * @example + * + * PersistentObject::setObjectManager($em); + * + * class Foo extends PersistentObject + * { + * private $id; + * } + * + * $foo = new Foo(); + * $foo->getId(); // method exists through __call + * + * @author Benjamin Eberlei + */ +abstract class PersistentObject implements ObjectManagerAware +{ + /** + * @var ObjectManager + */ + private static $objectManager; + + /** + * @var ClassMetadata + */ + private $cm; + + /** + * Set the object manager responsible for all persistent object base classes. + * + * @param ObjectManager $objectManager + */ + static public function setObjectManager(ObjectManager $objectManager = null) + { + self::$objectManager = $objectManager; + } + + /** + * @return ObjectManager + */ + static public function getObjectManager() + { + return self::$objectManager; + } + + /** + * Inject Doctrine Object Manager + * + * @param ObjectManager $objectManager + * @param ClassMetadata $classMetadata + */ + public function injectObjectManager(ObjectManager $objectManager, ClassMetadata $classMetadata) + { + if ($objectManager !== self::$objectManager) { + throw new \RuntimeException("Trying to use PersistentObject with different ObjectManager instances. " . + "Was PersistentObject::setObjectManager() called?"); + } + + $this->cm = $classMetadata; + } + + /** + * Sets a persistent fields value. + * + * @throws InvalidArgumentException - When the wrong target object type is passed to an association + * @throws BadMethodCallException - When no persistent field exists by that name. + * @param string $field + * @param array $args + * @return void + */ + private function set($field, $args) + { + $this->initializeDoctrine(); + + if ($this->cm->hasField($field) && !$this->cm->isIdentifier($field)) { + $this->$field = $args[0]; + } else if ($this->cm->hasAssociation($field) && $this->cm->isSingleValuedAssociation($field)) { + $targetClass = $this->cm->getAssociationTargetClass($field); + if (!($args[0] instanceof $targetClass) && $args[0] !== null) { + throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'"); + } + $this->$field = $args[0]; + $this->completeOwningSide($field, $targetClass, $args[0]); + } else { + throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'"); + } + } + + /** + * Get persistent field value. + * + * @throws BadMethodCallException - When no persistent field exists by that name. + * @param string $field + * @return mixed + */ + private function get($field) + { + $this->initializeDoctrine(); + + if ( $this->cm->hasField($field) || $this->cm->hasAssociation($field) ) { + return $this->$field; + } else { + throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'"); + } + } + + /** + * If this is an inverse side association complete the owning side. + * + * @param string $field + * @param ClassMetadata $targetClass + * @param object $targetObject + */ + private function completeOwningSide($field, $targetClass, $targetObject) + { + // add this object on the owning side aswell, for obvious infinite recursion + // reasons this is only done when called on the inverse side. + if ($this->cm->isAssociationInverseSide($field)) { + $mappedByField = $this->cm->getAssociationMappedByTargetField($field); + $targetMetadata = self::$objectManager->getClassMetadata($targetClass); + + $setter = ($targetMetadata->isCollectionValuedAssociation($mappedByField) ? "add" : "set").$mappedByField; + $targetObject->$setter($this); + } + } + + /** + * Add an object to a collection + * + * @param type $field + * @param assoc $args + */ + private function add($field, $args) + { + $this->initializeDoctrine(); + + if ($this->cm->hasAssociation($field) && $this->cm->isCollectionValuedAssociation($field)) { + $targetClass = $this->cm->getAssociationTargetClass($field); + if (!($args[0] instanceof $targetClass)) { + throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'"); + } + if (!($this->$field instanceof Collection)) { + $this->$field = new ArrayCollection($this->$field ?: array()); + } + $this->$field->add($args[0]); + $this->completeOwningSide($field, $targetClass, $args[0]); + } else { + throw new \BadMethodCallException("There is no method add".$field."() on ".$this->cm->getName()); + } + } + + /** + * Initialize Doctrine Metadata for this class. + * + * @return void + */ + private function initializeDoctrine() + { + if ($this->cm !== null) { + return; + } + + if (!self::$objectManager) { + throw new \RuntimeException("No runtime object manager set. Call PersistentObject#setObjectManager()."); + } + + $this->cm = self::$objectManager->getClassMetadata(get_class($this)); + } + + /** + * Magic method that implements + * + * @param string $method + * @param array $args + * @return mixed + */ + public function __call($method, $args) + { + $command = substr($method, 0, 3); + $field = lcfirst(substr($method, 3)); + if ($command == "set") { + $this->set($field, $args); + } else if ($command == "get") { + return $this->get($field); + } else if ($command == "add") { + $this->add($field, $args); + } else { + throw new \BadMethodCallException("There is no method ".$method." on ".$this->cm->getName()); + } + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Proxy.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Proxy.php new file mode 100644 index 0000000..726979f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Persistence/Proxy.php @@ -0,0 +1,60 @@ +. + */ + +namespace Doctrine\Common\Persistence; + +/** + * Interface for proxy classes. + * + * @author Roman Borschel + * @since 2.2 + */ +interface Proxy +{ + /** + * Marker for Proxy class names. + * + * @var string + */ + const MARKER = '__CG__'; + + /** + * Length of the proxy marker + * + * @var int + */ + const MARKER_LENGTH = 6; + + /** + * Initialize this proxy if its not yet initialized. + * + * Acts as a no-op if already initialized. + * + * @return void + */ + public function __load(); + + /** + * Is this proxy initialized or not. + * + * @return bool + */ + public function __isInitialized(); +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/PropertyChangedListener.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/PropertyChangedListener.php new file mode 100644 index 0000000..87c5b41 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/PropertyChangedListener.php @@ -0,0 +1,48 @@ +. + */ + +namespace Doctrine\Common; + +/** + * Contract for classes that are potential listeners of a NotifyPropertyChanged + * implementor. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision: 3938 $ + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +interface PropertyChangedListener +{ + /** + * Notifies the listener of a property change. + * + * @param object $sender The object on which the property changed. + * @param string $propertyName The name of the property that changed. + * @param mixed $oldValue The old value of the property that changed. + * @param mixed $newValue The new value of the property that changed. + */ + function propertyChanged($sender, $propertyName, $oldValue, $newValue); +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/ClassUtils.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/ClassUtils.php new file mode 100644 index 0000000..c346278 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/ClassUtils.php @@ -0,0 +1,103 @@ +. + */ + +namespace Doctrine\Common\Util; + +use Doctrine\Common\Persistence\Proxy; + +/** + * Class and reflection related functionality for objects that + * might or not be proxy objects at the moment. + * + * @author Benjamin Eberlei + * @author Johannes Schmitt + */ +class ClassUtils +{ + /** + * Get the real class name of a class name that could be a proxy. + * + * @param string + * @return string + */ + public static function getRealClass($class) + { + if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) { + return $class; + } + + return substr($class, $pos + Proxy::MARKER_LENGTH + 2); + } + + /** + * Get the real class name of an object (even if its a proxy) + * + * @param object + * @return string + */ + public static function getClass($object) + { + return self::getRealClass(get_class($object)); + } + + /** + * Get the real parent class name of a class or object + * + * @param string + * @return string + */ + public static function getParentClass($className) + { + return get_parent_class( self::getRealClass( $className ) ); + } + + /** + * Create a new reflection class + * + * @param string + * @return ReflectionClass + */ + public static function newReflectionClass($class) + { + return new \ReflectionClass( self::getRealClass( $class ) ); + } + + /** + * Create a new reflection object + * + * @param object + * @return ReflectionObject + */ + public static function newReflectionObject($object) + { + return self::newReflectionClass( self::getClass( $object ) ); + } + + /** + * Given a class name and a proxy namespace return the proxy name. + * + * @param string $className + * @param string $proxyNamespace + * @return string + */ + public static function generateProxyClassName($className, $proxyNamespace) + { + return rtrim($proxyNamespace, '\\') . '\\'.Proxy::MARKER.'\\' . ltrim($className, '\\'); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Debug.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Debug.php new file mode 100644 index 0000000..57ae312 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Debug.php @@ -0,0 +1,123 @@ +. + */ + +namespace Doctrine\Common\Util; + +/** + * Static class containing most used debug methods. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author Giorgio Sironi + */ +final class Debug +{ + /** + * Private constructor (prevents from instantiation) + * + */ + private function __construct() {} + + /** + * Prints a dump of the public, protected and private properties of $var. + * + * @static + * @link http://xdebug.org/ + * @param mixed $var + * @param integer $maxDepth Maximum nesting level for object properties + * @param boolean $stripTags Flag that indicate if output should strip HTML tags + */ + public static function dump($var, $maxDepth = 2, $stripTags = true) + { + ini_set('html_errors', 'On'); + + if (extension_loaded('xdebug')) { + ini_set('xdebug.var_display_max_depth', $maxDepth); + } + + $var = self::export($var, $maxDepth++); + + ob_start(); + var_dump($var); + $dump = ob_get_contents(); + ob_end_clean(); + + echo ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump); + + ini_set('html_errors', 'Off'); + } + + public static function export($var, $maxDepth) + { + $return = null; + $isObj = is_object($var); + + if ($isObj && in_array('Doctrine\Common\Collections\Collection', class_implements($var))) { + $var = $var->toArray(); + } + + if ($maxDepth) { + if (is_array($var)) { + $return = array(); + + foreach ($var as $k => $v) { + $return[$k] = self::export($v, $maxDepth - 1); + } + } else if ($isObj) { + $return = new \stdclass(); + if ($var instanceof \DateTime) { + $return->__CLASS__ = "DateTime"; + $return->date = $var->format('c'); + $return->timezone = $var->getTimeZone()->getName(); + } else { + $reflClass = ClassUtils::newReflectionObject($var); + $return->__CLASS__ = ClassUtils::getClass($var); + + if ($var instanceof \Doctrine\Common\Persistence\Proxy) { + $return->__IS_PROXY__ = true; + $return->__PROXY_INITIALIZED__ = $var->__isInitialized(); + } + + foreach ($reflClass->getProperties() as $reflProperty) { + $name = $reflProperty->getName(); + + $reflProperty->setAccessible(true); + $return->$name = self::export($reflProperty->getValue($var), $maxDepth - 1); + } + } + } else { + $return = $var; + } + } else { + $return = is_object($var) ? get_class($var) + : (is_array($var) ? 'Array(' . count($var) . ')' : $var); + } + + return $return; + } + + public static function toString($obj) + { + return method_exists('__toString', $obj) ? (string) $obj : get_class($obj) . '@' . spl_object_hash($obj); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Inflector.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Inflector.php new file mode 100644 index 0000000..ba1eb17 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Util/Inflector.php @@ -0,0 +1,72 @@ +. + */ + +namespace Doctrine\Common\Util; + +/** + * Doctrine inflector has static methods for inflecting text + * + * The methods in these classes are from several different sources collected + * across several different php projects and several different authors. The + * original author names and emails are not known + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 1.0 + * @version $Revision: 3189 $ + * @author Konsta Vesterinen + * @author Jonathan H. Wage + */ +class Inflector +{ + /** + * Convert word in to the format for a Doctrine table name. Converts 'ModelName' to 'model_name' + * + * @param string $word Word to tableize + * @return string $word Tableized word + */ + public static function tableize($word) + { + return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word)); + } + + /** + * Convert a word in to the format for a Doctrine class name. Converts 'table_name' to 'TableName' + * + * @param string $word Word to classify + * @return string $word Classified word + */ + public static function classify($word) + { + return str_replace(" ", "", ucwords(strtr($word, "_-", " "))); + } + + /** + * Camelize a word. This uses the classify() method and turns the first character to lowercase + * + * @param string $word + * @return string $word + */ + public static function camelize($word) + { + return lcfirst(self::classify($word)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Version.php b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Version.php new file mode 100644 index 0000000..b7c9a82 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/lib/Doctrine/Common/Version.php @@ -0,0 +1,55 @@ +. + */ + +namespace Doctrine\Common; + +/** + * Class to store and retrieve the version of Doctrine + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision$ + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +class Version +{ + /** + * Current Doctrine Version + */ + const VERSION = '2.2.2'; + + /** + * Compares a Doctrine version with the current one. + * + * @param string $version Doctrine version to compare. + * @return int Returns -1 if older, 0 if it is the same, 1 if version + * passed as argument is newer. + */ + public static function compare($version) + { + $currentVersion = str_replace(' ', '', strtolower(self::VERSION)); + $version = str_replace(' ', '', $version); + + return version_compare($version, $currentVersion); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/phpunit.xml.dist b/vendor/doctrine/common/doctrine-common-ac6c39b/phpunit.xml.dist new file mode 100644 index 0000000..b9d3b34 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + ./tests/Doctrine/ + + + + + + ./lib/Doctrine/ + + + + + + performance + + + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/.gitignore b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/.gitignore new file mode 100644 index 0000000..7210405 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/.gitignore @@ -0,0 +1,3 @@ +Doctrine/Tests/Proxies/ +Doctrine/Tests/ORM/Proxy/generated/ +Doctrine/Tests/ORM/Tools/Export/export diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php new file mode 100644 index 0000000..0a329a3 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -0,0 +1,538 @@ +getReader(); + + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClass'); + $this->assertEquals(1, count($reader->getClassAnnotations($class))); + $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName)); + $this->assertEquals("hello", $annot->dummyValue); + + $field1Prop = $class->getProperty('field1'); + $propAnnots = $reader->getPropertyAnnotations($field1Prop); + $this->assertEquals(1, count($propAnnots)); + $this->assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName)); + $this->assertEquals("fieldHello", $annot->dummyValue); + + $getField1Method = $class->getMethod('getField1'); + $methodAnnots = $reader->getMethodAnnotations($getField1Method); + $this->assertEquals(1, count($methodAnnots)); + $this->assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName)); + $this->assertEquals(array(1, 2, "three"), $annot->value); + + $field2Prop = $class->getProperty('field2'); + $propAnnots = $reader->getPropertyAnnotations($field2Prop); + $this->assertEquals(1, count($propAnnots)); + $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyJoinTable', $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName)); + $this->assertEquals(1, count($joinTableAnnot->joinColumns)); + $this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns)); + $this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn); + $this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn); + $this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name); + $this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName); + $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name); + $this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName); + + $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); + $this->assertEquals('', $dummyAnnot->dummyValue); + $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value); + + $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); + $this->assertEquals('fieldHello', $dummyAnnot->dummyValue); + + $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); + $this->assertEquals('hello', $classAnnot->dummyValue); + } + + public function testAnnotationsWithValidTargets() + { + $reader = $this->getReader(); + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); + + $this->assertEquals(1,count($reader->getClassAnnotations($class))); + $this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('foo')))); + $this->assertEquals(1,count($reader->getMethodAnnotations($class->getMethod('someFunction')))); + $this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('nested')))); + } + + public function testAnnotationsWithVarType() + { + $reader = $this->getReader(); + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); + + $this->assertEquals(1,count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')))); + $this->assertEquals(1,count($barAnnot = $reader->getMethodAnnotations($class->getMethod('bar')))); + + $this->assertInternalType('string', $fooAnnot[0]->string); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', $barAnnot[0]->annotation); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetPropertyMethod is not allowed to be declared on class Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass. You may only use this annotation on these code elements: METHOD, PROPERTY + */ + public function testClassWithInvalidAnnotationTargetAtClassDocBlock() + { + $reader = $this->getReader(); + $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$foo. You may only use this annotation on these code elements: CLASS + */ + public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock() + { + $reader = $this->getReader(); + $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'foo')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetAnnotation is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$bar. You may only use this annotation on these code elements: ANNOTATION + */ + public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock() + { + $reader = $this->getReader(); + $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'bar')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod::functionName(). You may only use this annotation on these code elements: CLASS + */ + public function testClassWithInvalidAnnotationTargetAtMethodDocBlock() + { + $reader = $this->getReader(); + $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod', 'functionName')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError. + */ + public function testClassWithAnnotationWithTargetSyntaxErrorAtClassDocBlock() + { + $reader = $this->getReader(); + $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError. + */ + public function testClassWithAnnotationWithTargetSyntaxErrorAtPropertyDocBlock() + { + $reader = $this->getReader(); + $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','foo')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError. + */ + public function testClassWithAnnotationWithTargetSyntaxErrorAtMethodDocBlock() + { + $reader = $this->getReader(); + $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','bar')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Type Error] Attribute "string" of @AnnotationWithVarType declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::$invalidProperty expects a(n) string, but got integer. + */ + public function testClassWithPropertyInvalidVarTypeError() + { + $reader = $this->getReader(); + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); + + $reader->getPropertyAnnotations($class->getProperty('invalidProperty')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Type Error] Attribute "annotation" of @AnnotationWithVarType declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::invalidMethod() expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll, but got an instance of Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. + */ + public function testClassWithMethodInvalidVarTypeError() + { + $reader = $this->getReader(); + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); + + $reader->getMethodAnnotations($class->getMethod('invalidMethod')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in class Doctrine\Tests\Common\Annotations\DummyClassSyntaxError. + */ + public function testClassSyntaxErrorContext() + { + $reader = $this->getReader(); + $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassSyntaxError')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in method Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError::foo(). + */ + public function testMethodSyntaxErrorContext() + { + $reader = $this->getReader(); + $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError', 'foo')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in property Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError::$foo. + */ + public function testPropertySyntaxErrorContext() + { + $reader = $this->getReader(); + $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError', 'foo')); + } + + /** + * @group regression + */ + public function testMultipleAnnotationsOnSameLine() + { + $reader = $this->getReader(); + $annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id')); + $this->assertEquals(3, count($annots)); + } + + public function testNonAnnotationProblem() + { + $reader = $this->getReader(); + + $this->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassNonAnnotationProblem', 'foo'), $name = 'Doctrine\Tests\Common\Annotations\DummyAnnotation')); + $this->assertInstanceOf($name, $annot); + } + + public function testImportWithConcreteAnnotation() + { + $reader = $this->getReader(); + $property = new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestImportWithConcreteAnnotation', 'field'); + $annotations = $reader->getPropertyAnnotations($property); + $this->assertEquals(1, count($annotations)); + $this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation')); + } + + public function testImportWithInheritance() + { + $reader = $this->getReader(); + + $class = new TestParentClass(); + $ref = new \ReflectionClass($class); + + $childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child')); + $this->assertEquals(1, count($childAnnotations)); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations)); + + $parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent')); + $this->assertEquals(1, count($parentAnnotations)); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations)); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage The annotation "@NameFoo" in property Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass::$field was never imported. + */ + public function testImportDetectsNotImportedAnnotation() + { + $reader = $this->getReader(); + $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass', 'field')); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage The annotation "@Foo\Bar\Name" in property Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass::$field was never imported. + */ + public function testImportDetectsNonExistentAnnotation() + { + $reader = $this->getReader(); + $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass', 'field')); + } + + public function testTopLevelAnnotation() + { + $reader = $this->getReader(); + $annotations = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestTopLevelAnnotationClass', 'field')); + + $this->assertEquals(1, count($annotations)); + $this->assertInstanceOf('\TopLevelAnnotation', reset($annotations)); + } + + public function testIgnoresAnnotationsNotPrefixedWithWhitespace() + { + $reader = $this->getReader(); + + $annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), 'Doctrine\Tests\Common\Annotations\Name'); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annotation); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage The class "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation". If it is indeed no annotation, then you need to add @IgnoreAnnotation("NoAnnotation") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass. + */ + public function testErrorWhenInvalidAnnotationIsUsed() + { + $reader = $this->getReader(); + $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass'); + $reader->getClassAnnotations($ref); + } + + public function testInvalidAnnotationUsageButIgnoredClass() + { + $reader = $this->getReader(); + $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass'); + $annots = $reader->getClassAnnotations($ref); + + $this->assertEquals(2, count($annots)); + } + + /** + * @group DDC-1660 + * @group regression + */ + public function testInvalidAnnotationButIgnored() + { + $reader = $this->getReader(); + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660'); + + $this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version')); + $this->assertCount(0, $reader->getClassAnnotations($class)); + $this->assertCount(0, $reader->getMethodAnnotations($class->getMethod('bar'))); + $this->assertCount(0, $reader->getPropertyAnnotations($class->getProperty('foo'))); + } + + abstract protected function getReader(); +} + +/** + * @parseAnnotation("var") + * @author Johannes M. Schmitt + * + */ +class TestParseAnnotationClass +{ + /** + * @var + */ + private $field; +} + +/** + * @Name + * @author Johannes M. Schmitt + */ +class TestIgnoresNonAnnotationsClass +{ +} + +class TestTopLevelAnnotationClass +{ + /** + * @\TopLevelAnnotation + */ + private $field; +} + +class TestNonExistentAnnotationClass +{ + /** + * @Foo\Bar\Name + */ + private $field; +} + +class TestAnnotationNotImportedClass +{ + /** + * @NameFoo + */ + private $field; +} + +class TestChildClass +{ + /** + * @\Doctrine\Tests\Common\Annotations\Foo\Name(name = "foo") + */ + protected $child; +} + +class TestParentClass extends TestChildClass +{ + /** + * @\Doctrine\Tests\Common\Annotations\Bar\Name(name = "bar") + */ + private $parent; +} + +class TestImportWithConcreteAnnotation +{ + /** + * @DummyAnnotation(dummyValue = "bar") + */ + private $field; +} + +/** + * A description of this class. + * + * Let's see if the parser recognizes that this @ is not really referring to an + * annotation. Also make sure that @var \ is not concated to "@var\is". + * + * @author robo + * @since 2.0 + * @DummyAnnotation(dummyValue="hello") + */ +class DummyClass { + /** + * A nice property. + * + * @var mixed + * @DummyAnnotation(dummyValue="fieldHello") + */ + private $field1; + + /** + * @DummyJoinTable(name="join_table", + * joinColumns={@DummyJoinColumn(name="col1", referencedColumnName="col2")}, + * inverseJoinColumns={ + * @DummyJoinColumn(name="col3", referencedColumnName="col4") + * }) + */ + private $field2; + + /** + * Gets the value of field1. + * + * @return mixed + * @DummyAnnotation({1,2,"three"}) + */ + public function getField1() { + } +} + +/** + * @ignoreAnnotation("var") + */ +class DummyClass2 { + /** + * @DummyId @DummyColumn(type="integer") @DummyGeneratedValue + * @var integer + */ + private $id; +} + +/** @Annotation */ +class DummyId extends \Doctrine\Common\Annotations\Annotation {} +/** @Annotation */ +class DummyColumn extends \Doctrine\Common\Annotations\Annotation { + public $type; +} +/** @Annotation */ +class DummyGeneratedValue extends \Doctrine\Common\Annotations\Annotation {} +/** @Annotation */ +class DummyAnnotation extends \Doctrine\Common\Annotations\Annotation { + public $dummyValue; +} +/** @Annotation */ +class DummyJoinColumn extends \Doctrine\Common\Annotations\Annotation { + public $name; + public $referencedColumnName; +} +/** @Annotation */ +class DummyJoinTable extends \Doctrine\Common\Annotations\Annotation { + public $name; + public $joinColumns; + public $inverseJoinColumns; +} + +/** + * @DummyAnnotation(@) + */ +class DummyClassSyntaxError +{ + +} + +class DummyClassMethodSyntaxError +{ + /** + * @DummyAnnotation(@) + */ + public function foo() + { + + } +} + +class DummyClassPropertySyntaxError +{ + /** + * @DummyAnnotation(@) + */ + public $foo; +} + +/** + * @ignoreAnnotation({"since", "var"}) + */ +class DummyClassNonAnnotationProblem +{ + /** + * @DummyAnnotation + * + * @var \Test + * @since 0.1 + */ + public $foo; +} + + +/** +* @DummyAnnotation Foo bar +*/ +class DummyClassWithEmail +{ + +} + +namespace Doctrine\Tests\Common\Annotations\Foo; + +/** @Annotation */ +class Name extends \Doctrine\Common\Annotations\Annotation +{ + public $name; +} + +namespace Doctrine\Tests\Common\Annotations\Bar; + +/** @Annotation */ +class Name extends \Doctrine\Common\Annotations\Annotation +{ + public $name; +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php new file mode 100644 index 0000000..d2cc667 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php @@ -0,0 +1,13 @@ +getMock('Doctrine\Common\Cache\Cache'); + $cache + ->expects($this->at(0)) + ->method('fetch') + ->with($this->equalTo($cacheKey)) + ->will($this->returnValue(array())) + ; + $cache + ->expects($this->at(1)) + ->method('fetch') + ->with($this->equalTo('[C]'.$cacheKey)) + ->will($this->returnValue(time() - 10)) + ; + $cache + ->expects($this->at(2)) + ->method('save') + ->with($this->equalTo($cacheKey)) + ; + $cache + ->expects($this->at(3)) + ->method('save') + ->with($this->equalTo('[C]'.$cacheKey)) + ; + + $reader = new CachedReader(new AnnotationReader(), $cache, true); + $route = new Route(); + $route->pattern = '/someprefix'; + $this->assertEquals(array($route), $reader->getClassAnnotations(new \ReflectionClass($name))); + } + + protected function getReader() + { + $this->cache = new ArrayCache(); + return new CachedReader(new AnnotationReader(), $this->cache); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php new file mode 100644 index 0000000..cb080f0 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -0,0 +1,27 @@ +setInput("@Name"); + $this->assertNull($lexer->token); + $this->assertNull($lexer->lookahead); + + $this->assertTrue($lexer->moveNext()); + $this->assertNull($lexer->token); + $this->assertEquals('@', $lexer->lookahead['value']); + + $this->assertTrue($lexer->moveNext()); + $this->assertEquals('@', $lexer->token['value']); + $this->assertEquals('Name', $lexer->lookahead['value']); + + $this->assertFalse($lexer->moveNext()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php new file mode 100644 index 0000000..56cae7f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -0,0 +1,1118 @@ +createTestParser(); + + // Nested arrays with nested annotations + $result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})'); + $annot = $result[0]; + + $this->assertTrue($annot instanceof Name); + $this->assertNull($annot->value); + $this->assertEquals(3, count($annot->foo)); + $this->assertEquals(1, $annot->foo[0]); + $this->assertEquals(2, $annot->foo[1]); + $this->assertTrue(is_array($annot->foo[2])); + + $nestedArray = $annot->foo[2]; + $this->assertTrue(isset($nestedArray['key'])); + $this->assertTrue($nestedArray['key'] instanceof Name); + } + + public function testBasicAnnotations() + { + $parser = $this->createTestParser(); + + // Marker annotation + $result = $parser->parse("@Name"); + $annot = $result[0]; + $this->assertTrue($annot instanceof Name); + $this->assertNull($annot->value); + $this->assertNull($annot->foo); + + // Associative arrays + $result = $parser->parse('@Name(foo={"key1" = "value1"})'); + $annot = $result[0]; + $this->assertNull($annot->value); + $this->assertTrue(is_array($annot->foo)); + $this->assertTrue(isset($annot->foo['key1'])); + + // Numerical arrays + $result = $parser->parse('@Name({2="foo", 4="bar"})'); + $annot = $result[0]; + $this->assertTrue(is_array($annot->value)); + $this->assertEquals('foo', $annot->value[2]); + $this->assertEquals('bar', $annot->value[4]); + $this->assertFalse(isset($annot->value[0])); + $this->assertFalse(isset($annot->value[1])); + $this->assertFalse(isset($annot->value[3])); + + // Multiple values + $result = $parser->parse('@Name(@Name, @Name)'); + $annot = $result[0]; + + $this->assertTrue($annot instanceof Name); + $this->assertTrue(is_array($annot->value)); + $this->assertTrue($annot->value[0] instanceof Name); + $this->assertTrue($annot->value[1] instanceof Name); + + // Multiple types as values + $result = $parser->parse('@Name(foo="Bar", @Name, {"key1"="value1", "key2"="value2"})'); + $annot = $result[0]; + + $this->assertTrue($annot instanceof Name); + $this->assertTrue(is_array($annot->value)); + $this->assertTrue($annot->value[0] instanceof Name); + $this->assertTrue(is_array($annot->value[1])); + $this->assertEquals('value1', $annot->value[1]['key1']); + $this->assertEquals('value2', $annot->value[1]['key2']); + + // Complete docblock + $docblock = <<parse($docblock); + $this->assertEquals(1, count($result)); + $annot = $result[0]; + $this->assertTrue($annot instanceof Name); + $this->assertEquals("bar", $annot->foo); + $this->assertNull($annot->value); + } + + public function testNamespacedAnnotations() + { + $parser = new DocParser; + $parser->setIgnoreNotImportedAnnotations(true); + + $docblock = << + * @Doctrine\Tests\Common\Annotations\Name(foo="bar") + * @ignore + */ +DOCBLOCK; + + $result = $parser->parse($docblock); + $this->assertEquals(1, count($result)); + $annot = $result[0]; + $this->assertTrue($annot instanceof Name); + $this->assertEquals("bar", $annot->foo); + } + + /** + * @group debug + */ + public function testTypicalMethodDocBlock() + { + $parser = $this->createTestParser(); + + $docblock = <<parse($docblock); + $this->assertEquals(2, count($result)); + $this->assertTrue(isset($result[0])); + $this->assertTrue(isset($result[1])); + $annot = $result[0]; + $this->assertTrue($annot instanceof Name); + $this->assertEquals("bar", $annot->foo); + $marker = $result[1]; + $this->assertTrue($marker instanceof Marker); + } + + + public function testAnnotationWithoutConstructor() + { + $parser = $this->createTestParser(); + + + $docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $annot = $result[0]; + + $this->assertNotNull($annot); + $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); + + $this->assertNull($annot->name); + $this->assertNotNull($annot->data); + $this->assertEquals($annot->data, "Some data"); + + + + +$docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $annot = $result[0]; + + $this->assertNotNull($annot); + $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); + + $this->assertEquals($annot->name, "Some Name"); + $this->assertEquals($annot->data, "Some data"); + + + + +$docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $annot = $result[0]; + + $this->assertEquals($annot->data, "Some data"); + $this->assertNull($annot->name); + + + $docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $annot = $result[0]; + + $this->assertEquals($annot->name, "Some name"); + $this->assertNull($annot->data); + + $docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $annot = $result[0]; + + $this->assertEquals($annot->data, "Some data"); + $this->assertNull($annot->name); + + + + $docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $annot = $result[0]; + + $this->assertEquals($annot->name, "Some name"); + $this->assertEquals($annot->data, "Some data"); + + + $docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $annot = $result[0]; + + $this->assertEquals($annot->name, "Some name"); + $this->assertEquals($annot->data, "Some data"); + + $docblock = <<parse($docblock); + $this->assertEquals(count($result), 1); + $this->assertTrue($result[0] instanceof SomeAnnotationClassNameWithoutConstructorAndProperties); + } + + public function testAnnotationTarget() + { + + $parser = new DocParser; + $parser->setImports(array( + '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Fixtures', + )); + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); + + + $context = 'class ' . $class->getName(); + $docComment = $class->getDocComment(); + + $parser->setTarget(Target::TARGET_CLASS); + $this->assertNotNull($parser->parse($docComment,$context)); + + + $property = $class->getProperty('foo'); + $docComment = $property->getDocComment(); + $context = 'property ' . $class->getName() . "::\$" . $property->getName(); + + $parser->setTarget(Target::TARGET_PROPERTY); + $this->assertNotNull($parser->parse($docComment,$context)); + + + + $method = $class->getMethod('someFunction'); + $docComment = $property->getDocComment(); + $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; + + $parser->setTarget(Target::TARGET_METHOD); + $this->assertNotNull($parser->parse($docComment,$context)); + + + try { + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass'); + $context = 'class ' . $class->getName(); + $docComment = $class->getDocComment(); + + $parser->setTarget(Target::TARGET_CLASS); + $parser->parse($class->getDocComment(),$context); + + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertNotNull($exc->getMessage()); + } + + + try { + + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod'); + $method = $class->getMethod('functionName'); + $docComment = $method->getDocComment(); + $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; + + $parser->setTarget(Target::TARGET_METHOD); + $parser->parse($docComment,$context); + + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertNotNull($exc->getMessage()); + } + + + try { + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty'); + $property = $class->getProperty('foo'); + $docComment = $property->getDocComment(); + $context = 'property ' . $class->getName() . "::\$" . $property->getName(); + + $parser->setTarget(Target::TARGET_PROPERTY); + $parser->parse($docComment,$context); + + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertNotNull($exc->getMessage()); + } + + } + + public function getAnnotationVarTypeProviderValid() + { + //({attribute name}, {attribute value}) + return array( + // mixed type + array('mixed', '"String Value"'), + array('mixed', 'true'), + array('mixed', 'false'), + array('mixed', '1'), + array('mixed', '1.2'), + array('mixed', '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll'), + + // boolean type + array('boolean', 'true'), + array('boolean', 'false'), + + // alias for internal type boolean + array('bool', 'true'), + array('bool', 'false'), + + // integer type + array('integer', '0'), + array('integer', '1'), + array('integer', '123456789'), + array('integer', '9223372036854775807'), + + // alias for internal type double + array('float', '0.1'), + array('float', '1.2'), + array('float', '123.456'), + + // string type + array('string', '"String Value"'), + array('string', '"true"'), + array('string', '"123"'), + + // array type + array('array', '{@AnnotationExtendsAnnotationTargetAll}'), + array('array', '{@AnnotationExtendsAnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll}'), + + array('arrayOfIntegers', '1'), + array('arrayOfIntegers', '{1}'), + array('arrayOfIntegers', '{1,2,3,4}'), + array('arrayOfAnnotations', '@AnnotationExtendsAnnotationTargetAll'), + array('arrayOfAnnotations', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll}'), + array('arrayOfAnnotations', '{@AnnotationExtendsAnnotationTargetAll, @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll}'), + + // annotation instance + array('annotation', '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll'), + array('annotation', '@AnnotationExtendsAnnotationTargetAll'), + ); + } + + public function getAnnotationVarTypeProviderInvalid() + { + //({attribute name}, {type declared type}, {attribute value} , {given type or class}) + return array( + // boolean type + array('boolean','boolean','1','integer'), + array('boolean','boolean','1.2','double'), + array('boolean','boolean','"str"','string'), + array('boolean','boolean','{1,2,3}','array'), + array('boolean','boolean','@Name', 'an instance of Doctrine\Tests\Common\Annotations\Name'), + + // alias for internal type boolean + array('bool','bool', '1','integer'), + array('bool','bool', '1.2','double'), + array('bool','bool', '"str"','string'), + array('bool','bool', '{"str"}','array'), + + // integer type + array('integer','integer', 'true','boolean'), + array('integer','integer', 'false','boolean'), + array('integer','integer', '1.2','double'), + array('integer','integer', '"str"','string'), + array('integer','integer', '{"str"}','array'), + array('integer','integer', '{1,2,3,4}','array'), + + // alias for internal type double + array('float','float', 'true','boolean'), + array('float','float', 'false','boolean'), + array('float','float', '123','integer'), + array('float','float', '"str"','string'), + array('float','float', '{"str"}','array'), + array('float','float', '{12.34}','array'), + array('float','float', '{1,2,3}','array'), + + // string type + array('string','string', 'true','boolean'), + array('string','string', 'false','boolean'), + array('string','string', '12','integer'), + array('string','string', '1.2','double'), + array('string','string', '{"str"}','array'), + array('string','string', '{1,2,3,4}','array'), + + // annotation instance + array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true','boolean'), + array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false','boolean'), + array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '12','integer'), + array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '1.2','double'), + array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{"str"}','array'), + array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{1,2,3,4}','array'), + array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '@Name','an instance of Doctrine\Tests\Common\Annotations\Name'), + ); + } + + public function getAnnotationVarTypeArrayProviderInvalid() + { + //({attribute name}, {type declared type}, {attribute value} , {given type or class}) + return array( + array('arrayOfIntegers','integer', 'true','boolean'), + array('arrayOfIntegers','integer', 'false','boolean'), + array('arrayOfIntegers','integer', '{true,true}','boolean'), + array('arrayOfIntegers','integer', '{1,true}','boolean'), + array('arrayOfIntegers','integer', '{1,2,1.2}','double'), + array('arrayOfIntegers','integer', '{1,2,"str"}','string'), + + + array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true','boolean'), + array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false','boolean'), + array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}','boolean'), + array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}','boolean'), + array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,1.2}','double'), + array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll,"str"}','string'), + ); + } + + /** + * @dataProvider getAnnotationVarTypeProviderValid + */ + public function testAnnotationWithVarType($attribute, $value) + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::$invalidProperty.'; + $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType(%s = %s)',$attribute, $value); + $parser->setTarget(Target::TARGET_PROPERTY); + + $result = $parser->parse($docblock, $context); + + $this->assertTrue(sizeof($result) === 1); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType', $result[0]); + $this->assertNotNull($result[0]->$attribute); + } + + /** + * @dataProvider getAnnotationVarTypeProviderInvalid + */ + public function testAnnotationWithVarTypeError($attribute,$type,$value,$given) + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType(%s = %s)',$attribute, $value); + $parser->setTarget(Target::TARGET_PROPERTY); + + try { + $parser->parse($docblock, $context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage()); + } + } + + + /** + * @dataProvider getAnnotationVarTypeArrayProviderInvalid + */ + public function testAnnotationWithVarTypeArrayError($attribute,$type,$value,$given) + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType(%s = %s)',$attribute, $value); + $parser->setTarget(Target::TARGET_PROPERTY); + + try { + $parser->parse($docblock, $context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage()); + } + } + + /** + * @dataProvider getAnnotationVarTypeProviderValid + */ + public function testAnnotationWithAttributes($attribute, $value) + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::$invalidProperty.'; + $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute, $value); + $parser->setTarget(Target::TARGET_PROPERTY); + + $result = $parser->parse($docblock, $context); + + $this->assertTrue(sizeof($result) === 1); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes', $result[0]); + $getter = "get".ucfirst($attribute); + $this->assertNotNull($result[0]->$getter()); + } + + /** + * @dataProvider getAnnotationVarTypeProviderInvalid + */ + public function testAnnotationWithAttributesError($attribute,$type,$value,$given) + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute, $value); + $parser->setTarget(Target::TARGET_PROPERTY); + + try { + $parser->parse($docblock, $context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage()); + } + } + + + /** + * @dataProvider getAnnotationVarTypeArrayProviderInvalid + */ + public function testAnnotationWithAttributesWithVarTypeArrayError($attribute,$type,$value,$given) + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $docblock = sprintf('@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes(%s = %s)',$attribute, $value); + $parser->setTarget(Target::TARGET_PROPERTY); + + try { + $parser->parse($docblock, $context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage()); + } + } + + public function testAnnotationWithRequiredAttributes() + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $parser->setTarget(Target::TARGET_PROPERTY); + + + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; + $result = $parser->parse($docblock); + + $this->assertTrue(sizeof($result) === 1); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes', $result[0]); + $this->assertEquals("Some Value",$result[0]->getValue()); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->getAnnot()); + + + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")'; + try { + $result = $parser->parse($docblock,$context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); + } + + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; + try { + $result = $parser->parse($docblock,$context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); + } + + } + + public function testAnnotationWithRequiredAttributesWithoutContructor() + { + $parser = $this->createTestParser(); + $context = 'property SomeClassName::invalidProperty.'; + $parser->setTarget(Target::TARGET_PROPERTY); + + + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; + $result = $parser->parse($docblock); + + $this->assertTrue(sizeof($result) === 1); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor', $result[0]); + $this->assertEquals("Some Value", $result[0]->value); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->annot); + + + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value")'; + try { + $result = $parser->parse($docblock,$context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); + } + + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; + try { + $result = $parser->parse($docblock,$context); + $this->fail(); + } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + $this->assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); + } + + } + + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage The annotation @SomeAnnotationClassNameWithoutConstructorAndProperties declared on does not accept any values, but got {"value":"Foo"}. + */ + public function testWithoutConstructorWhenIsNotDefaultValue() + { + $parser = $this->createTestParser(); + $docblock = <<setTarget(Target::TARGET_CLASS); + $parser->parse($docblock); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage The annotation @SomeAnnotationClassNameWithoutConstructorAndProperties declared on does not accept any values, but got {"value":"Foo"}. + */ + public function testWithoutConstructorWhenHasNoProperties() + { + $parser = $this->createTestParser(); + $docblock = <<setTarget(Target::TARGET_CLASS); + $parser->parse($docblock); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError. + */ + public function testAnnotationTargetSyntaxError() + { + $parser = $this->createTestParser(); + $context = 'class ' . 'SomeClassName'; + $docblock = <<setTarget(Target::TARGET_CLASS); + $parser->parse($docblock,$context); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid Target "Foo". Available targets: [ALL, CLASS, METHOD, PROPERTY, ANNOTATION] + */ + public function testAnnotationWithInvalidTargetDeclarationError() + { + $parser = $this->createTestParser(); + $context = 'class ' . 'SomeClassName'; + $docblock = <<setTarget(Target::TARGET_CLASS); + $parser->parse($docblock,$context); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage @Target expects either a string value, or an array of strings, "NULL" given. + */ + public function testAnnotationWithTargetEmptyError() + { + $parser = $this->createTestParser(); + $context = 'class ' . 'SomeClassName'; + $docblock = <<setTarget(Target::TARGET_CLASS); + $parser->parse($docblock,$context); + } + + /** + * @group DDC-575 + */ + public function testRegressionDDC575() + { + $parser = $this->createTestParser(); + + $docblock = <<parse($docblock); + + $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); + + $docblock = <<parse($docblock); + + $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); + } + + /** + * @group DDC-77 + */ + public function testAnnotationWithoutClassIsIgnoredWithoutWarning() + { + $parser = new DocParser(); + $parser->setIgnoreNotImportedAnnotations(true); + $result = $parser->parse("@param"); + + $this->assertEquals(0, count($result)); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected PlainValue, got ''' at position 10. + */ + public function testAnnotationDontAcceptSingleQuotes() + { + $parser = $this->createTestParser(); + $parser->parse("@Name(foo='bar')"); + } + + /** + * @group DCOM-41 + */ + public function testAnnotationDoesntThrowExceptionWhenAtSignIsNotFollowedByIdentifier() + { + $parser = new DocParser(); + $result = $parser->parse("'@'"); + + $this->assertEquals(0, count($result)); + } + + /** + * @group DCOM-41 + * @expectedException Doctrine\Common\Annotations\AnnotationException + */ + public function testAnnotationThrowsExceptionWhenAtSignIsNotFollowedByIdentifierInNestedAnnotation() + { + $parser = new DocParser(); + $result = $parser->parse("@Doctrine\Tests\Common\Annotations\Name(@')"); + } + + /** + * @group DCOM-56 + */ + public function testAutoloadAnnotation() + { + $this->assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload', false), 'Pre-condition: Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload not allowed to be loaded.'); + + $parser = new DocParser(); + + AnnotationRegistry::registerAutoloadNamespace('Doctrine\Tests\Common\Annotations\Fixtures\Annotation', __DIR__ . '/../../../../'); + + $parser->setImports(array( + 'autoload' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', + )); + $annotations = $parser->parse('@Autoload'); + + $this->assertEquals(1, count($annotations)); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + } + + public function createTestParser() + { + $parser = new DocParser(); + $parser->setIgnoreNotImportedAnnotations(true); + $parser->setImports(array( + 'name' => 'Doctrine\Tests\Common\Annotations\Name', + '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations', + )); + + return $parser; + } + + /** + * @group DDC-78 + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage Expected PlainValue, got ''' at position 10 in class \Doctrine\Tests\Common\Annotations\Name + */ + public function testSyntaxErrorWithContextDescription() + { + $parser = $this->createTestParser(); + $parser->parse("@Name(foo='bar')", "class \Doctrine\Tests\Common\Annotations\Name"); + } + + /** + * @group DDC-183 + */ + public function testSyntaxErrorWithUnknownCharacters() + { + $docblock = <<setInput(trim($docblock, '/ *')); + //var_dump($lexer); + + try { + $parser = $this->createTestParser(); + $result = $parser->parse($docblock); + } catch (Exception $e) { + $this->fail($e->getMessage()); + } + } + + /** + * @group DCOM-14 + */ + public function testIgnorePHPDocThrowTag() + { + $docblock = <<createTestParser(); + $result = $parser->parse($docblock); + } catch (Exception $e) { + $this->fail($e->getMessage()); + } + } + + /** + * @group DCOM-38 + */ + public function testCastInt() + { + $parser = $this->createTestParser(); + + $result = $parser->parse("@Name(foo=1234)"); + $annot = $result[0]; + $this->assertInternalType('int', $annot->foo); + } + + /** + * @group DCOM-38 + */ + public function testCastNegativeInt() + { + $parser = $this->createTestParser(); + + $result = $parser->parse("@Name(foo=-1234)"); + $annot = $result[0]; + $this->assertInternalType('int', $annot->foo); + } + + /** + * @group DCOM-38 + */ + public function testCastFloat() + { + $parser = $this->createTestParser(); + + $result = $parser->parse("@Name(foo=1234.345)"); + $annot = $result[0]; + $this->assertInternalType('float', $annot->foo); + } + + /** + * @group DCOM-38 + */ + public function testCastNegativeFloat() + { + $parser = $this->createTestParser(); + + $result = $parser->parse("@Name(foo=-1234.345)"); + $annot = $result[0]; + $this->assertInternalType('float', $annot->foo); + + $result = $parser->parse("@Marker(-1234.345)"); + $annot = $result[0]; + $this->assertInternalType('float', $annot->value); + } + + public function testReservedKeywordsInAnnotations() + { + $parser = $this->createTestParser(); + + $result = $parser->parse('@Doctrine\Tests\Common\Annotations\True'); + $this->assertTrue($result[0] instanceof True); + $result = $parser->parse('@Doctrine\Tests\Common\Annotations\False'); + $this->assertTrue($result[0] instanceof False); + $result = $parser->parse('@Doctrine\Tests\Common\Annotations\Null'); + $this->assertTrue($result[0] instanceof Null); + + $result = $parser->parse('@True'); + $this->assertTrue($result[0] instanceof True); + $result = $parser->parse('@False'); + $this->assertTrue($result[0] instanceof False); + $result = $parser->parse('@Null'); + $this->assertTrue($result[0] instanceof Null); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Creation Error] The annotation @SomeAnnotationClassNameWithoutConstructor declared on some class does not have a property named "invalidaProperty". Available properties: data, name + */ + public function testSetValuesExeption() + { + $docblock = <<createTestParser()->parse($docblock, 'some class'); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_IDENTIFIER or Doctrine\Common\Annotations\DocLexer::T_TRUE or Doctrine\Common\Annotations\DocLexer::T_FALSE or Doctrine\Common\Annotations\DocLexer::T_NULL, got '3.42' at position 5. + */ + public function testInvalidIdentifierInAnnotation() + { + $parser = $this->createTestParser(); + $parser->parse('@Foo\3.42'); + } + + public function testTrailingCommaIsAllowed() + { + $parser = $this->createTestParser(); + + $annots = $parser->parse('@Name({ + "Foo", + "Bar", + })'); + $this->assertEquals(1, count($annots)); + $this->assertEquals(array('Foo', 'Bar'), $annots[0]->value); + } + + public function testDefaultAnnotationValueIsNotOverwritten() + { + $parser = $this->createTestParser(); + + $annots = $parser->parse('@Doctrine\Tests\Common\Annotations\Fixtures\Annotation\AnnotWithDefaultValue'); + $this->assertEquals(1, count($annots)); + $this->assertEquals('bar', $annots[0]->foo); + } + + public function testArrayWithColon() + { + $parser = $this->createTestParser(); + + $annots = $parser->parse('@Name({"foo": "bar"})'); + $this->assertEquals(1, count($annots)); + $this->assertEquals(array('foo' => 'bar'), $annots[0]->value); + } + + /** + * @expectedException Doctrine\Common\Annotations\AnnotationException + * @expectedExceptionMessage [Syntax Error] Expected PlainValue, got 'foo:' at position 6. + */ + public function testColonNotAllowedOnTopLevel() + { + $parser = $this->createTestParser(); + $parser->parse('@Name(foo: "bar")'); + } +} + +/** @Annotation */ +class SomeAnnotationClassNameWithoutConstructor +{ + public $data; + public $name; +} + +/** @Annotation */ +class SomeAnnotationWithConstructorWithoutParams +{ + function __construct() + { + $this->data = "Some data"; + } + public $data; + public $name; +} + +/** @Annotation */ +class SomeAnnotationClassNameWithoutConstructorAndProperties{} + +/** + * @Annotation + * @Target("Foo") + */ +class AnnotationWithInvalidTargetDeclaration{} + +/** + * @Annotation + * @Target + */ +class AnnotationWithTargetEmpty{} + +/** @Annotation */ +class AnnotationExtendsAnnotationTargetAll extends \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll +{ +} + +/** @Annotation */ +class Name extends \Doctrine\Common\Annotations\Annotation { + public $foo; +} + +/** @Annotation */ +class Marker { + public $value; +} + +/** @Annotation */ +class True {} + +/** @Annotation */ +class False {} + +/** @Annotation */ +class Null {} + +namespace Doctrine\Tests\Common\Annotations\FooBar; + +/** @Annotation */ +class Name extends \Doctrine\Common\Annotations\Annotation { +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php new file mode 100644 index 0000000..c84344d --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php @@ -0,0 +1,40 @@ +cacheDir = sys_get_temp_dir() . "/annotations_". uniqid(); + @mkdir($this->cacheDir); + return new FileCacheReader(new AnnotationReader(), $this->cacheDir); + } + + public function tearDown() + { + foreach (glob($this->cacheDir.'/*.php') AS $file) { + unlink($file); + } + rmdir($this->cacheDir); + } + + /** + * @group DCOM-81 + */ + public function testAttemptToCreateAnnotationCacheDir() + { + $this->cacheDir = sys_get_temp_dir() . "/not_existed_dir_". uniqid(); + + $this->assertFalse(is_dir($this->cacheDir)); + + $cache = new FileCacheReader(new AnnotationReader(), $this->cacheDir); + + $this->assertTrue(is_dir($this->cacheDir)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php new file mode 100644 index 0000000..44108e1 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/AnnotWithDefaultValue.php @@ -0,0 +1,10 @@ +roles = $values['value']; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php new file mode 100644 index 0000000..b507e60 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php @@ -0,0 +1,14 @@ +name = isset($values['value']) ? $values['value'] : null; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php new file mode 100644 index 0000000..09ef031 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Version.php @@ -0,0 +1,11 @@ +"), + @Attribute("annotation", type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll"), + @Attribute("arrayOfAnnotations", type = "array"), + }) + */ +final class AnnotationWithAttributes +{ + + public final function __construct(array $data) + { + foreach ($data as $key => $value) { + $this->$key = $value; + } + } + + private $mixed; + private $boolean; + private $bool; + private $float; + private $string; + private $integer; + private $array; + private $annotation; + private $arrayOfIntegers; + private $arrayOfAnnotations; + + /** + * @return mixed + */ + public function getMixed() + { + return $this->mixed; + } + + /** + * @return boolean + */ + public function getBoolean() + { + return $this->boolean; + } + + /** + * @return bool + */ + public function getBool() + { + return $this->bool; + } + + /** + * @return float + */ + public function getFloat() + { + return $this->float; + } + + /** + * @return string + */ + public function getString() + { + return $this->string; + } + + public function getInteger() + { + return $this->integer; + } + + /** + * @return array + */ + public function getArray() + { + return $this->array; + } + + /** + * @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll + */ + public function getAnnotation() + { + return $this->annotation; + } + + /** + * @return array + */ + public function getArrayOfIntegers() + { + return $this->arrayOfIntegers; + } + + /** + * @return array + */ + public function getArrayOfAnnotations() + { + return $this->arrayOfAnnotations; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php new file mode 100644 index 0000000..6eb1bc5 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php @@ -0,0 +1,50 @@ + $value) { + $this->$key = $value; + } + } + + /** + * @var string + */ + private $value; + + /** + * + * @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation + */ + private $annot; + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation + */ + public function getAnnot() + { + return $this->annot; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php new file mode 100644 index 0000000..bf458ee --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php @@ -0,0 +1,24 @@ + + */ + public $arrayOfIntegers; + + /** + * @var array + */ + public $arrayOfAnnotations; + +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php new file mode 100644 index 0000000..4e652e1 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassDDC1660.php @@ -0,0 +1,30 @@ + + */ +class Controller +{ + /** + * @Route("/", name="_demo") + * @Template() + */ + public function indexAction() + { + return array(); + } + + /** + * @Route("/hello/{name}", name="_demo_hello") + * @Template() + */ + public function helloAction($name) + { + return array('name' => $name); + } + + /** + * @Route("/contact", name="_demo_contact") + * @Template() + */ + public function contactAction() + { + $form = ContactForm::create($this->get('form.context'), 'contact'); + + $form->bind($this->container->get('request'), $form); + if ($form->isValid()) { + $form->send($this->get('mailer')); + + $this->get('session')->setFlash('notice', 'Message sent!'); + + return new RedirectResponse($this->generateUrl('_demo')); + } + + return array('form' => $form); + } + + /** + * Creates the ACL for the passed object identity + * + * @param ObjectIdentityInterface $oid + * @return void + */ + private function createObjectIdentity(ObjectIdentityInterface $oid) + { + $classId = $this->createOrRetrieveClassId($oid->getType()); + + $this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true)); + } + + /** + * Returns the primary key for the passed class type. + * + * If the type does not yet exist in the database, it will be created. + * + * @param string $classType + * @return integer + */ + private function createOrRetrieveClassId($classType) + { + if (false !== $id = $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn()) { + return $id; + } + + $this->connection->executeQuery($this->getInsertClassSql($classType)); + + return $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn(); + } + + /** + * Returns the primary key for the passed security identity. + * + * If the security identity does not yet exist in the database, it will be + * created. + * + * @param SecurityIdentityInterface $sid + * @return integer + */ + private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid) + { + if (false !== $id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn()) { + return $id; + } + + $this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid)); + + return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn(); + } + + /** + * Deletes all ACEs for the given object identity primary key. + * + * @param integer $oidPK + * @return void + */ + private function deleteAccessControlEntries($oidPK) + { + $this->connection->executeQuery($this->getDeleteAccessControlEntriesSql($oidPK)); + } + + /** + * Deletes the object identity from the database. + * + * @param integer $pk + * @return void + */ + private function deleteObjectIdentity($pk) + { + $this->connection->executeQuery($this->getDeleteObjectIdentitySql($pk)); + } + + /** + * Deletes all entries from the relations table from the database. + * + * @param integer $pk + * @return void + */ + private function deleteObjectIdentityRelations($pk) + { + $this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk)); + } + + /** + * This regenerates the ancestor table which is used for fast read access. + * + * @param AclInterface $acl + * @return void + */ + private function regenerateAncestorRelations(AclInterface $acl) + { + $pk = $acl->getId(); + $this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk)); + $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk)); + + $parentAcl = $acl->getParentAcl(); + while (null !== $parentAcl) { + $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId())); + + $parentAcl = $parentAcl->getParentAcl(); + } + } + + /** + * This processes changes on an ACE related property (classFieldAces, or objectFieldAces). + * + * @param string $name + * @param array $changes + * @return void + */ + private function updateFieldAceProperty($name, array $changes) + { + $sids = new \SplObjectStorage(); + $classIds = new \SplObjectStorage(); + $currentIds = array(); + foreach ($changes[1] as $field => $new) { + for ($i=0,$c=count($new); $i<$c; $i++) { + $ace = $new[$i]; + + if (null === $ace->getId()) { + if ($sids->contains($ace->getSecurityIdentity())) { + $sid = $sids->offsetGet($ace->getSecurityIdentity()); + } else { + $sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity()); + } + + $oid = $ace->getAcl()->getObjectIdentity(); + if ($classIds->contains($oid)) { + $classId = $classIds->offsetGet($oid); + } else { + $classId = $this->createOrRetrieveClassId($oid->getType()); + } + + $objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId(); + + $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure())); + $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))->fetchColumn(); + $this->loadedAces[$aceId] = $ace; + + $aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id'); + $aceIdProperty->setAccessible(true); + $aceIdProperty->setValue($ace, intval($aceId)); + } else { + $currentIds[$ace->getId()] = true; + } + } + } + + foreach ($changes[0] as $old) { + for ($i=0,$c=count($old); $i<$c; $i++) { + $ace = $old[$i]; + + if (!isset($currentIds[$ace->getId()])) { + $this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId())); + unset($this->loadedAces[$ace->getId()]); + } + } + } + } + + /** + * This processes changes on an ACE related property (classAces, or objectAces). + * + * @param string $name + * @param array $changes + * @return void + */ + private function updateAceProperty($name, array $changes) + { + list($old, $new) = $changes; + + $sids = new \SplObjectStorage(); + $classIds = new \SplObjectStorage(); + $currentIds = array(); + for ($i=0,$c=count($new); $i<$c; $i++) { + $ace = $new[$i]; + + if (null === $ace->getId()) { + if ($sids->contains($ace->getSecurityIdentity())) { + $sid = $sids->offsetGet($ace->getSecurityIdentity()); + } else { + $sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity()); + } + + $oid = $ace->getAcl()->getObjectIdentity(); + if ($classIds->contains($oid)) { + $classId = $classIds->offsetGet($oid); + } else { + $classId = $this->createOrRetrieveClassId($oid->getType()); + } + + $objectIdentityId = $name === 'classAces' ? null : $ace->getAcl()->getId(); + + $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, null, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure())); + $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, null, $i))->fetchColumn(); + $this->loadedAces[$aceId] = $ace; + + $aceIdProperty = new \ReflectionProperty($ace, 'id'); + $aceIdProperty->setAccessible(true); + $aceIdProperty->setValue($ace, intval($aceId)); + } else { + $currentIds[$ace->getId()] = true; + } + } + + for ($i=0,$c=count($old); $i<$c; $i++) { + $ace = $old[$i]; + + if (!isset($currentIds[$ace->getId()])) { + $this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId())); + unset($this->loadedAces[$ace->getId()]); + } + } + } + + /** + * Persists the changes which were made to ACEs to the database. + * + * @param \SplObjectStorage $aces + * @return void + */ + private function updateAces(\SplObjectStorage $aces) + { + foreach ($aces as $ace) { + $propertyChanges = $aces->offsetGet($ace); + $sets = array(); + + if (isset($propertyChanges['mask'])) { + $sets[] = sprintf('mask = %d', $propertyChanges['mask'][1]); + } + if (isset($propertyChanges['strategy'])) { + $sets[] = sprintf('granting_strategy = %s', $this->connection->quote($propertyChanges['strategy'])); + } + if (isset($propertyChanges['aceOrder'])) { + $sets[] = sprintf('ace_order = %d', $propertyChanges['aceOrder'][1]); + } + if (isset($propertyChanges['auditSuccess'])) { + $sets[] = sprintf('audit_success = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditSuccess'][1])); + } + if (isset($propertyChanges['auditFailure'])) { + $sets[] = sprintf('audit_failure = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditFailure'][1])); + } + + $this->connection->executeQuery($this->getUpdateAccessControlEntrySql($ace->getId(), $sets)); + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsFirst.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsFirst.php new file mode 100644 index 0000000..bda2cc2 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/DifferentNamespacesPerFileWithClassAsFirst.php @@ -0,0 +1,15 @@ +test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test2() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test3() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test4() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test5() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test6() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test7() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test8() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test9() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test10() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test11() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test12() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test13() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test14() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test15() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test16() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test17() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test18() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test19() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test20() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test21() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test22() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test23() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test24() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test25() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test26() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test27() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test28() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test29() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test30() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test31() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test32() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test33() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test34() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test35() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test36() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test37() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test38() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test39() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NoAnnotation.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NoAnnotation.php new file mode 100644 index 0000000..1dae104 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/NoAnnotation.php @@ -0,0 +1,5 @@ +test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test2() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test3() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test4() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test5() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test6() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test7() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test8() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test9() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test10() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test11() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test12() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test13() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test14() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test15() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test16() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test17() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test18() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test19() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test20() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test21() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test22() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test23() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test24() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test25() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test26() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test27() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test28() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test29() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test30() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test31() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test32() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test33() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test34() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test35() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test36() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test37() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + + } + + public function test38() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } + + public function test39() + { + echo $this->test1; + echo $this->test2; + echo $this->test3; + $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foreach ($array as $key => $value) { + echo $key . ' => ' . $value; + } + + $val = (string)self::TEST1; + $val .= (string)self::TEST2; + $val .= (string)self::TEST3; + $val .= (string)self::TEST4; + $val .= (string)self::TEST5; + $val .= (string)self::TEST6; + $val .= (string)self::TEST7; + $val .= (string)self::TEST8; + $val .= (string)self::TEST9; + + strtolower($val); + + return $val; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php new file mode 100644 index 0000000..58c5e6a --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php @@ -0,0 +1,13 @@ +getMethod(); + + $time = microtime(true); + for ($i=0,$c=500; $i<$c; $i++) { + $reader->getMethodAnnotations($method); + } + $time = microtime(true) - $time; + + $this->printResults('cached reader (in-memory)', $time, $c); + } + + /** + * @group performance + */ + public function testCachedReadPerformanceWithFileCache() + { + $method = $this->getMethod(); + + // prime cache + $reader = new FileCacheReader(new AnnotationReader(), sys_get_temp_dir()); + $reader->getMethodAnnotations($method); + + $time = microtime(true); + for ($i=0,$c=500; $i<$c; $i++) { + $reader = new FileCacheReader(new AnnotationReader(), sys_get_temp_dir()); + $reader->getMethodAnnotations($method); + clearstatcache(); + } + $time = microtime(true) - $time; + + $this->printResults('cached reader (file)', $time, $c); + } + + /** + * @group performance + */ + public function testReadPerformance() + { + $method = $this->getMethod(); + + $time = microtime(true); + for ($i=0,$c=150; $i<$c; $i++) { + $reader = new AnnotationReader(); + $reader->getMethodAnnotations($method); + } + $time = microtime(true) - $time; + + $this->printResults('reader', $time, $c); + } + + /** + * @group performance + */ + public function testDocParsePerformance() + { + $imports = array( + 'ignorephpdoc' => 'Annotations\Annotation\IgnorePhpDoc', + 'ignoreannotation' => 'Annotations\Annotation\IgnoreAnnotation', + 'route' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route', + 'template' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template', + '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Fixtures', + ); + $ignored = array( + 'access', 'author', 'copyright', 'deprecated', 'example', 'ignore', + 'internal', 'link', 'see', 'since', 'tutorial', 'version', 'package', + 'subpackage', 'name', 'global', 'param', 'return', 'staticvar', + 'static', 'var', 'throws', 'inheritdoc', + ); + + $method = $this->getMethod(); + $methodComment = $method->getDocComment(); + $classComment = $method->getDeclaringClass()->getDocComment(); + + $time = microtime(true); + for ($i=0,$c=200; $i<$c; $i++) { + $parser = new DocParser(); + $parser->setImports($imports); + $parser->setIgnoredAnnotationNames($ignored); + $parser->setIgnoreNotImportedAnnotations(true); + + $parser->parse($methodComment); + $parser->parse($classComment); + } + $time = microtime(true) - $time; + + $this->printResults('doc-parser', $time, $c); + } + + /** + * @group performance + */ + public function testDocLexerPerformance() + { + $method = $this->getMethod(); + $methodComment = $method->getDocComment(); + $classComment = $method->getDeclaringClass()->getDocComment(); + + $time = microtime(true); + for ($i=0,$c=500; $i<$c; $i++) { + $lexer = new DocLexer(); + $lexer->setInput($methodComment); + $lexer->setInput($classComment); + } + $time = microtime(true) - $time; + + $this->printResults('doc-lexer', $time, $c); + } + + /** + * @group performance + */ + public function testPhpParserPerformanceWithShortCut() + { + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\NamespacedSingleClassLOC1000'); + + $time = microtime(true); + for ($i=0,$c=500; $i<$c; $i++) { + $parser = new PhpParser(); + $parser->parseClass($class); + } + $time = microtime(true) - $time; + + $this->printResults('doc-parser-with-short-cut', $time, $c); + } + + /** + * @group performance + */ + public function testPhpParserPerformanceWithoutShortCut() + { + $class = new \ReflectionClass('SingleClassLOC1000'); + + $time = microtime(true); + for ($i=0,$c=500; $i<$c; $i++) { + $parser = new PhpParser(); + $parser->parseClass($class); + } + $time = microtime(true) - $time; + + $this->printResults('doc-parser-without-short-cut', $time, $c); + } + + private function getMethod() + { + return new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\Controller', 'helloAction'); + } + + private function printResults($test, $time, $iterations) + { + if (0 == $iterations) { + throw new \InvalidArgumentException('$iterations cannot be zero.'); + } + + $title = $test." results:\n"; + $iterationsText = sprintf("Iterations: %d\n", $iterations); + $totalTime = sprintf("Total Time: %.3f s\n", $time); + $iterationTime = sprintf("Time per iteration: %.3f ms\n", $time/$iterations * 1000); + + $max = max(strlen($title), strlen($iterationTime)) - 1; + + echo "\n".str_repeat('-', $max)."\n"; + echo $title; + echo str_repeat('=', $max)."\n"; + echo $iterationsText; + echo $totalTime; + echo $iterationTime; + echo str_repeat('-', $max)."\n"; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php new file mode 100644 index 0000000..8de4aab --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php @@ -0,0 +1,179 @@ +assertEquals(array( + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + ), $parser->parseClass($class)); + } + + public function testParseClassWithMultipleImportsInUseStatement() + { + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\MultipleImportsInUseStatement'); + $parser = new PhpParser(); + + $this->assertEquals(array( + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + ), $parser->parseClass($class)); + } + + public function testParseClassWhenNotUserDefined() + { + $parser = new PhpParser(); + $this->assertEquals(array(), $parser->parseClass(new \ReflectionClass('\stdClass'))); + } + + public function testParseClassWhenClassIsNotNamespaced() + { + $parser = new PhpParser(); + $class = new ReflectionClass('\AnnotationsTestsFixturesNonNamespacedClass'); + + $this->assertEquals(array( + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } + + public function testParseClassWhenClassIsInterface() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\TestInterface'); + + $this->assertEquals(array( + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + ), $parser->parseClass($class)); + } + + public function testClassWithFullyQualifiedUseStatements() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\ClassWithFullyQualifiedUseStatements'); + + $this->assertEquals(array( + 'secure' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Secure', + 'route' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } + + public function testNamespaceAndClassCommentedOut() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceAndClassCommentedOut'); + + $this->assertEquals(array( + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } + + public function testEqualNamespacesPerFileWithClassAsFirst() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\EqualNamespacesPerFileWithClassAsFirst'); + + $this->assertEquals(array( + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + ), $parser->parseClass($class)); + } + + public function testEqualNamespacesPerFileWithClassAsLast() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\EqualNamespacesPerFileWithClassAsLast'); + + $this->assertEquals(array( + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } + + public function testDifferentNamespacesPerFileWithClassAsFirst() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\DifferentNamespacesPerFileWithClassAsFirst'); + + $this->assertEquals(array( + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + ), $parser->parseClass($class)); + } + + public function testDifferentNamespacesPerFileWithClassAsLast() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\DifferentNamespacesPerFileWithClassAsLast'); + + $this->assertEquals(array( + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } + + public function testGlobalNamespacesPerFileWithClassAsFirst() + { + $parser = new PhpParser(); + $class = new \ReflectionClass('\GlobalNamespacesPerFileWithClassAsFirst'); + + $this->assertEquals(array( + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + ), $parser->parseClass($class)); + } + + public function testGlobalNamespacesPerFileWithClassAsLast() + { + $parser = new PhpParser(); + $class = new ReflectionClass('\GlobalNamespacesPerFileWithClassAsLast'); + + $this->assertEquals(array( + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } + + public function testNamespaceWithClosureDeclaration() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceWithClosureDeclaration'); + + $this->assertEquals(array( + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } + + public function testIfPointerResetsOnMultipleParsingTries() + { + $parser = new PhpParser(); + $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceWithClosureDeclaration'); + + $this->assertEquals(array( + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + + $this->assertEquals(array( + 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', + 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', + 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', + ), $parser->parseClass($class)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php new file mode 100644 index 0000000..376539f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php @@ -0,0 +1,97 @@ +getReader(); + $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660'); + + $this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version')); + $this->assertCount(1, $reader->getClassAnnotations($class)); + $this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar'))); + $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); + } + + protected function getReader() + { + $reader = new SimpleAnnotationReader(); + $reader->addNamespace(__NAMESPACE__); + $reader->addNamespace(__NAMESPACE__ . '\Fixtures'); + $reader->addNamespace(__NAMESPACE__ . '\Fixtures\Annotation'); + + return $reader; + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php new file mode 100644 index 0000000..a7b9e2f --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php @@ -0,0 +1,65 @@ +getClassAnnotations($class); + } + + public function testAnnotation() + { + $class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Consumer'); + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $annots = $reader->getClassAnnotations($class); + + $this->assertEquals(1, count($annots)); + $this->assertInstanceOf(__NAMESPACE__.'\\DCOM55Annotation', $annots[0]); + } + + public function testParseAnnotationDocblocks() + { + $class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Annotation'); + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $annots = $reader->getClassAnnotations($class); + + $this->assertEquals(0, count($annots)); + } +} + +/** + * @Controller + */ +class Dummy +{ + +} + +/** + * @Annotation + */ +class DCOM55Annotation +{ + +} + +/** + * @DCOM55Annotation + */ +class DCOM55Consumer +{ + +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php new file mode 100644 index 0000000..708bcc9 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Entity.php @@ -0,0 +1,8 @@ +getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass")); + + foreach ($result as $annot) { + $classAnnotations[get_class($annot)] = $annot; + } + + $this->assertTrue(!isset($classAnnotations['']), 'Class "xxx" is not a valid entity or mapped super class.'); + } + + public function testIssueGlobalNamespace() + { + $docblock = "@Entity"; + $parser = new \Doctrine\Common\Annotations\DocParser(); + $parser->setImports(array( + "__NAMESPACE__" =>"Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping" + )); + + $annots = $parser->parse($docblock); + + $this->assertEquals(1, count($annots)); + $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + } + + public function testIssueNamespaces() + { + $docblock = "@Entity"; + $parser = new \Doctrine\Common\Annotations\DocParser(); + $parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM"); + + $annots = $parser->parse($docblock); + + $this->assertEquals(1, count($annots)); + $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Entity", $annots[0]); + } + + public function testIssueMultipleNamespaces() + { + $docblock = "@Entity"; + $parser = new \Doctrine\Common\Annotations\DocParser(); + $parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping"); + $parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM"); + + $annots = $parser->parse($docblock); + + $this->assertEquals(1, count($annots)); + $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + } + + public function testIssueWithNamespacesOrImports() + { + $docblock = "@Entity"; + $parser = new \Doctrine\Common\Annotations\DocParser(); + $annots = $parser->parse($docblock); + + $this->assertEquals(1, count($annots)); + $this->assertInstanceOf("Entity", $annots[0]); + $this->assertEquals(1, count($annots)); + } + + + public function testIssueSimpleAnnotationReader() + { + $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); + $reader->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping'); + $annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass")); + + $this->assertEquals(1, count($annots)); + $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + } + +} + +/** + * @Entity + */ +class MappedClass +{ + +} + + +namespace Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping; +/** +* @Annotation +*/ +class Entity +{ + +} + +namespace Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM; +/** +* @Annotation +*/ +class Entity +{ + +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php new file mode 100644 index 0000000..ff3ca37 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php @@ -0,0 +1,8 @@ +markTestSkipped('The ' . __CLASS__ .' requires the use of APC'); + } + } + + protected function _getCacheDriver() + { + return new ApcCache(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php new file mode 100644 index 0000000..7192717 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php @@ -0,0 +1,13 @@ +_getCacheDriver(); + + // Test save + $cache->save('test_key', 'testing this out'); + + // Test contains to test that save() worked + $this->assertTrue($cache->contains('test_key')); + + // Test fetch + $this->assertEquals('testing this out', $cache->fetch('test_key')); + + // Test delete + $cache->save('test_key2', 'test2'); + $cache->delete('test_key2'); + $this->assertFalse($cache->contains('test_key2')); + } + + public function testDeleteAll() + { + $cache = $this->_getCacheDriver(); + $cache->save('test_key1', '1'); + $cache->save('test_key2', '2'); + $cache->deleteAll(); + + $this->assertFalse($cache->contains('test_key1')); + $this->assertFalse($cache->contains('test_key2')); + } + + public function testFlushAll() + { + $cache = $this->_getCacheDriver(); + $cache->save('test_key1', '1'); + $cache->save('test_key2', '2'); + $cache->flushAll(); + + $this->assertFalse($cache->contains('test_key1')); + $this->assertFalse($cache->contains('test_key2')); + } + + public function testNamespace() + { + $cache = $this->_getCacheDriver(); + $cache->setNamespace('test_'); + $cache->save('key1', 'test'); + + $this->assertTrue($cache->contains('key1')); + + $cache->setNamespace('test2_'); + + $this->assertFalse($cache->contains('key1')); + } + + /** + * @group DCOM-43 + */ + public function testGetStats() + { + if ($this instanceof ArrayCacheTest || $this instanceof ZendDataCacheTest ) { + $this->markTestSkipped("Statistics are not available for this driver"); + } + + $cache = $this->_getCacheDriver(); + $stats = $cache->getStats(); + + + $this->assertArrayHasKey(Cache::STATS_HITS, $stats); + $this->assertArrayHasKey(Cache::STATS_MISSES, $stats); + $this->assertArrayHasKey(Cache::STATS_UPTIME, $stats); + $this->assertArrayHasKey(Cache::STATS_MEMORY_USAGE, $stats); + $this->assertArrayHasKey(Cache::STATS_MEMORY_AVAILIABLE, $stats); + } + + /** + * @return \Doctrine\Common\Cache\CacheProvider + */ + abstract protected function _getCacheDriver(); +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php new file mode 100644 index 0000000..362ff69 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php @@ -0,0 +1,38 @@ +_memcache = new \Memcache; + $ok = @$this->_memcache->connect('localhost', 11211); + if (!$ok) { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); + } + } else { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); + } + } + + public function testNoExpire() { + $cache = $this->_getCacheDriver(); + $cache->save('noexpire', 'value', 0); + sleep(1); + $this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire'); + } + + protected function _getCacheDriver() + { + $driver = new MemcacheCache(); + $driver->setMemcache($this->_memcache); + return $driver; + } + +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php new file mode 100644 index 0000000..947ba75 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/MemcachedCacheTest.php @@ -0,0 +1,40 @@ +memcached = new \Memcached(); + $this->memcached->setOption(\Memcached::OPT_COMPRESSION, false); + $this->memcached->addServer('127.0.0.1', 11211); + + $fh = @fsockopen('127.0.0.1', 11211); + if (!$fh) { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); + } + } else { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); + } + } + + public function testNoExpire() { + $cache = $this->_getCacheDriver(); + $cache->save('noexpire', 'value', 0); + sleep(1); + $this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire'); + } + + protected function _getCacheDriver() + { + $driver = new MemcachedCache(); + $driver->setMemcached($this->memcached); + return $driver; + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php new file mode 100644 index 0000000..cb363df --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/WinCacheCacheTest.php @@ -0,0 +1,20 @@ +markTestSkipped('The ' . __CLASS__ .' requires the use of Wincache'); + } + } + + protected function _getCacheDriver() + { + return new WincacheCache(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php new file mode 100644 index 0000000..6259848 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php @@ -0,0 +1,20 @@ +markTestSkipped('The ' . __CLASS__ .' requires the use of xcache'); + } + } + + protected function _getCacheDriver() + { + return new XcacheCache(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php new file mode 100644 index 0000000..27dcf35 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php @@ -0,0 +1,20 @@ +markTestSkipped('The ' . __CLASS__ .' requires the use of Zend Data Cache which only works in apache2handler SAPI'); + } + } + + protected function _getCacheDriver() + { + return new ZendDataCache(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest.php new file mode 100644 index 0000000..567cf91 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest.php @@ -0,0 +1,45 @@ +setIncludePath(__DIR__); + $classLoader->setFileExtension('.class.php'); + $classLoader->setNamespaceSeparator('_'); + + $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassA')); + $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassB')); + $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassC')); + $this->assertFalse($classLoader->canLoadClass('OtherClass')); + $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassA'), true); + $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassB'), true); + $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassC'), true); + } + + public function testClassExists() + { + $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\ClassD')); + $badLoader = function($className) { + require __DIR__ . '/ClassLoaderTest/ClassD.php'; + return true; + }; + spl_autoload_register($badLoader); + $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\ClassD')); + spl_autoload_unregister($badLoader); + } + + public function testGetClassLoader() + { + $cl = new ClassLoader('ClassLoaderTest', __DIR__); + $cl->register(); + $this->assertTrue(ClassLoader::getClassLoader('ClassLoaderTest\ClassD') instanceof \Doctrine\Common\ClassLoader); + $this->assertNull(ClassLoader::getClassLoader('This\Class\Does\Not\Exist')); + $cl->unregister(); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php new file mode 100644 index 0000000..8554654 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php @@ -0,0 +1,6 @@ +_coll = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function testIssetAndUnset() + { + $this->assertFalse(isset($this->_coll[0])); + $this->_coll->add('testing'); + $this->assertTrue(isset($this->_coll[0])); + unset($this->_coll[0]); + $this->assertFalse(isset($this->_coll[0])); + } + + public function testToString() + { + $this->_coll->add('testing'); + $this->assertTrue(is_string((string) $this->_coll)); + } + + public function testRemovingNonExistentEntryReturnsNull() + { + $this->assertEquals(null, $this->_coll->remove('testing_does_not_exist')); + } + + public function testExists() + { + $this->_coll->add("one"); + $this->_coll->add("two"); + $exists = $this->_coll->exists(function($k, $e) { return $e == "one"; }); + $this->assertTrue($exists); + $exists = $this->_coll->exists(function($k, $e) { return $e == "other"; }); + $this->assertFalse($exists); + } + + public function testMap() + { + $this->_coll->add(1); + $this->_coll->add(2); + $res = $this->_coll->map(function($e) { return $e * 2; }); + $this->assertEquals(array(2, 4), $res->toArray()); + } + + public function testFilter() + { + $this->_coll->add(1); + $this->_coll->add("foo"); + $this->_coll->add(3); + $res = $this->_coll->filter(function($e) { return is_numeric($e); }); + $this->assertEquals(array(0 => 1, 2 => 3), $res->toArray()); + } + + public function testFirstAndLast() + { + $this->_coll->add('one'); + $this->_coll->add('two'); + + $this->assertEquals($this->_coll->first(), 'one'); + $this->assertEquals($this->_coll->last(), 'two'); + } + + public function testArrayAccess() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + + $this->assertEquals($this->_coll[0], 'one'); + $this->assertEquals($this->_coll[1], 'two'); + + unset($this->_coll[0]); + $this->assertEquals($this->_coll->count(), 1); + } + + public function testContainsKey() + { + $this->_coll[5] = 'five'; + $this->assertTrue($this->_coll->containsKey(5)); + } + + public function testContains() + { + $this->_coll[0] = 'test'; + $this->assertTrue($this->_coll->contains('test')); + } + + public function testSearch() + { + $this->_coll[0] = 'test'; + $this->assertEquals(0, $this->_coll->indexOf('test')); + } + + public function testGet() + { + $this->_coll[0] = 'test'; + $this->assertEquals('test', $this->_coll->get(0)); + } + + public function testGetKeys() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + $this->assertEquals(array(0, 1), $this->_coll->getKeys()); + } + + public function testGetValues() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + $this->assertEquals(array('one', 'two'), $this->_coll->getValues()); + } + + public function testCount() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + $this->assertEquals($this->_coll->count(), 2); + $this->assertEquals(count($this->_coll), 2); + } + + public function testForAll() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_string($e); }), true); + $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_array($e); }), false); + } + + public function testPartition() + { + $this->_coll[] = true; + $this->_coll[] = false; + $partition = $this->_coll->partition(function($k, $e) { return $e == true; }); + $this->assertEquals($partition[0][0], true); + $this->assertEquals($partition[1][0], false); + } + + public function testClear() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + $this->_coll->clear(); + $this->assertEquals($this->_coll->isEmpty(), true); + } + + public function testRemove() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + $el = $this->_coll->remove(0); + + $this->assertEquals('one', $el); + $this->assertEquals($this->_coll->contains('one'), false); + $this->assertNull($this->_coll->remove(0)); + } + + public function testRemoveElement() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + + $this->assertTrue($this->_coll->removeElement('two')); + $this->assertFalse($this->_coll->contains('two')); + $this->assertFalse($this->_coll->removeElement('two')); + } + + public function testSlice() + { + $this->_coll[] = 'one'; + $this->_coll[] = 'two'; + $this->_coll[] = 'three'; + + $slice = $this->_coll->slice(0, 1); + $this->assertInternalType('array', $slice); + $this->assertEquals(array('one'), $slice); + + $slice = $this->_coll->slice(1); + $this->assertEquals(array(1 => 'two', 2 => 'three'), $slice); + + $slice = $this->_coll->slice(1, 1); + $this->assertEquals(array(1 => 'two'), $slice); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php new file mode 100644 index 0000000..e69de29 diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/EventManagerTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/EventManagerTest.php new file mode 100644 index 0000000..2b11b20 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/EventManagerTest.php @@ -0,0 +1,88 @@ +_eventManager = new EventManager; + $this->_preFooInvoked = false; + $this->_postFooInvoked = false; + } + + public function testInitialState() + { + $this->assertEquals(array(), $this->_eventManager->getListeners()); + $this->assertFalse($this->_eventManager->hasListeners(self::preFoo)); + $this->assertFalse($this->_eventManager->hasListeners(self::postFoo)); + } + + public function testAddEventListener() + { + $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this); + $this->assertTrue($this->_eventManager->hasListeners(self::preFoo)); + $this->assertTrue($this->_eventManager->hasListeners(self::postFoo)); + $this->assertEquals(1, count($this->_eventManager->getListeners(self::preFoo))); + $this->assertEquals(1, count($this->_eventManager->getListeners(self::postFoo))); + $this->assertEquals(2, count($this->_eventManager->getListeners())); + } + + public function testDispatchEvent() + { + $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this); + $this->_eventManager->dispatchEvent(self::preFoo); + $this->assertTrue($this->_preFooInvoked); + $this->assertFalse($this->_postFooInvoked); + } + + public function testRemoveEventListener() + { + $this->_eventManager->addEventListener(array('preBar'), $this); + $this->assertTrue($this->_eventManager->hasListeners(self::preBar)); + $this->_eventManager->removeEventListener(array('preBar'), $this); + $this->assertFalse($this->_eventManager->hasListeners(self::preBar)); + } + + public function testAddEventSubscriber() + { + $eventSubscriber = new TestEventSubscriber(); + $this->_eventManager->addEventSubscriber($eventSubscriber); + $this->assertTrue($this->_eventManager->hasListeners(self::preFoo)); + $this->assertTrue($this->_eventManager->hasListeners(self::postFoo)); + } + + /* Listener methods */ + + public function preFoo(EventArgs $e) + { + $this->_preFooInvoked = true; + } + + public function postFoo(EventArgs $e) + { + $this->_postFooInvoked = true; + } +} + +class TestEventSubscriber implements \Doctrine\Common\EventSubscriber +{ + public function getSubscribedEvents() + { + return array('preFoo', 'postFoo'); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php new file mode 100644 index 0000000..e1825ae --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php @@ -0,0 +1,94 @@ +getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + + $chain = new MappingDriverChain(); + + $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $driver1->expects($this->never()) + ->method('loadMetadataForClass'); + $driver1->expectS($this->never()) + ->method('isTransient'); + + $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $driver2->expects($this->at(0)) + ->method('loadMetadataForClass') + ->with($this->equalTo($className), $this->equalTo($classMetadata)); + $driver2->expects($this->at(1)) + ->method('isTransient') + ->with($this->equalTo($className)) + ->will($this->returnValue( true )); + + $chain->addDriver($driver1, 'Doctrine\Tests\Models\Company'); + $chain->addDriver($driver2, 'Doctrine\Tests\Common\Persistence\Mapping'); + + $chain->loadMetadataForClass($className, $classMetadata); + + $this->assertTrue( $chain->isTransient($className) ); + } + + public function testLoadMetadata_NoDelegatorFound_ThrowsMappingException() + { + $className = 'Doctrine\Tests\Common\Persistence\Mapping\DriverChainEntity'; + $classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + + $chain = new MappingDriverChain(); + + $this->setExpectedException('Doctrine\Common\Persistence\Mapping\MappingException'); + $chain->loadMetadataForClass($className, $classMetadata); + } + + public function testGatherAllClassNames() + { + $className = 'Doctrine\Tests\Common\Persistence\Mapping\DriverChainEntity'; + $classMetadata = $this->getMock('Doctrine\Common\Peristence\ClassMetadata'); + + $chain = new MappingDriverChain(); + + $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $driver1->expects($this->once()) + ->method('getAllClassNames') + ->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); + + $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $driver2->expects($this->once()) + ->method('getAllClassNames') + ->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz'))); + + $chain->addDriver($driver1, 'Doctrine\Tests\Models\Company'); + $chain->addDriver($driver2, 'Doctrine\Tests\ORM\Mapping'); + + $this->assertEquals(array( + 'Doctrine\Tests\Models\Company\Foo', + 'Doctrine\Tests\ORM\Mapping\Bar', + 'Doctrine\Tests\ORM\Mapping\Baz' + ), $chain->getAllClassNames()); + } + + /** + * @group DDC-706 + */ + public function testIsTransient() + { + $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $chain = new MappingDriverChain(); + $chain->addDriver($driver1, 'Doctrine\Tests\Models\CMS'); + + $this->assertTrue($chain->isTransient('stdClass'), "stdClass isTransient"); + } +} + +class DriverChainEntity +{ + +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php new file mode 100644 index 0000000..9fe3299 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/ClassMetadataFactoryTest.php @@ -0,0 +1,134 @@ +getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); + $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $this->cmf = new TestClassMetadataFactory($driver, $metadata); + } + + public function testGetCacheDriver() + { + $this->assertNull($this->cmf->getCacheDriver()); + $cache = new ArrayCache(); + $this->cmf->setCacheDriver($cache); + $this->assertSame($cache, $this->cmf->getCacheDriver()); + } + + public function testGetMetadataFor() + { + $metadata = $this->cmf->getMetadataFor('stdClass'); + + $this->assertInstanceOf('Doctrine\Common\Persistence\Mapping\ClassMetadata', $metadata); + $this->assertTrue($this->cmf->hasMetadataFor('stdClass')); + } + + public function testGetParentMetadata() + { + $metadata = $this->cmf->getMetadataFor(__NAMESPACE__ . '\ChildEntity'); + + $this->assertInstanceOf('Doctrine\Common\Persistence\Mapping\ClassMetadata', $metadata); + $this->assertTrue($this->cmf->hasMetadataFor(__NAMESPACE__ . '\ChildEntity')); + $this->assertTrue($this->cmf->hasMetadataFor(__NAMESPACE__ . '\RootEntity')); + } + + public function testGetCachedMetadata() + { + $metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $cache = new ArrayCache(); + $cache->save(__NAMESPACE__. '\ChildEntity$CLASSMETADATA', $metadata); + + $this->cmf->setCacheDriver($cache); + + $loadedMetadata = $this->cmf->getMetadataFor(__NAMESPACE__ . '\ChildEntity'); + $this->assertSame($loadedMetadata, $metadata); + } + + public function testCacheGetMetadataFor() + { + $cache = new ArrayCache(); + $this->cmf->setCacheDriver($cache); + + $loadedMetadata = $this->cmf->getMetadataFor(__NAMESPACE__ . '\ChildEntity'); + + $this->assertSame($loadedMetadata, $cache->fetch(__NAMESPACE__. '\ChildEntity$CLASSMETADATA')); + } + + public function testGetAliasedMetadata() + { + $loadedMetadata = $this->cmf->getMetadataFor('prefix:ChildEntity'); + + $this->assertTrue($this->cmf->hasMetadataFor(__NAMESPACE__ . '\ChildEntity')); + $this->assertTrue($this->cmf->hasMetadataFor('prefix:ChildEntity')); + } +} + +class TestClassMetadataFactory extends AbstractClassMetadataFactory +{ + public $driver; + public $metadata; + + public function __construct($driver, $metadata) + { + $this->driver = $driver; + $this->metadata = $metadata; + } + + protected function doLoadMetadata($class, $parent, $rootEntityFound) + { + + } + + protected function getFqcnFromAlias($namespaceAlias, $simpleClassName) + { + return __NAMESPACE__ . '\\' . $simpleClassName; + } + + protected function initialize() + { + + } + + protected function newClassMetadataInstance($className) + { + return $this->metadata; + } + + protected function getDriver() + { + return $this->driver; + } + protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService) + { + } + + protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService) + { + } +} + +class RootEntity +{ + +} + +class ChildEntity extends RootEntity +{ + +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php new file mode 100644 index 0000000..3c600c4 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/DefaultFileLocatorTest.php @@ -0,0 +1,90 @@ +assertEquals(array($path), $locator->getPaths()); + + $locator = new DefaultFileLocator($path); + $this->assertEquals(array($path), $locator->getPaths()); + } + + public function testGetFileExtension() + { + $locator = new DefaultFileLocator(array(), ".yml"); + $this->assertEquals(".yml", $locator->getFileExtension()); + $locator->setFileExtension(".xml"); + $this->assertEquals(".xml", $locator->getFileExtension()); + } + + public function testUniquePaths() + { + $path = __DIR__ . "/_files"; + + $locator = new DefaultFileLocator(array($path, $path)); + $this->assertEquals(array($path), $locator->getPaths()); + } + + public function testFindMappingFile() + { + $path = __DIR__ . "/_files"; + + $locator = new DefaultFileLocator(array($path), ".yml"); + + $this->assertEquals(__DIR__ . '/_files/stdClass.yml', $locator->findMappingFile('stdClass')); + } + + public function testFindMappingFileNotFound() + { + $path = __DIR__ . "/_files"; + + $locator = new DefaultFileLocator(array($path), ".yml"); + + $this->setExpectedException( + 'Doctrine\Common\Persistence\Mapping\MappingException', + "No mapping file found named 'stdClass2.yml' for class 'stdClass2'" + ); + $locator->findMappingFile('stdClass2'); + } + + public function testGetAllClassNames() + { + $path = __DIR__ . "/_files"; + + $locator = new DefaultFileLocator(array($path), ".yml"); + $classes = $locator->getAllClassNames(null); + sort($classes); + + $this->assertEquals(array('global', 'stdClass'), $classes); + $this->assertEquals(array('stdClass'), $locator->getAllClassNames("global")); + } + + public function testGetAllClassNamesNonMatchingFileExtension() + { + $path = __DIR__ . "/_files"; + + $locator = new DefaultFileLocator(array($path), ".xml"); + $this->assertEquals(array(), $locator->getAllClassNames("global")); + } + + public function testFileExists() + { + $path = __DIR__ . "/_files"; + + $locator = new DefaultFileLocator(array($path), ".yml"); + + $this->assertTrue($locator->fileExists("stdClass")); + $this->assertFalse($locator->fileExists("stdClass2")); + $this->assertTrue($locator->fileExists("global")); + $this->assertFalse($locator->fileExists("global2")); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php new file mode 100644 index 0000000..020c242 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php @@ -0,0 +1,142 @@ +assertNull($driver->getGlobalBasename()); + + $driver->setGlobalBasename("global"); + $this->assertEquals("global", $driver->getGlobalBasename()); + } + + public function testGetElementFromGlobalFile() + { + $driver = new TestFileDriver($this->newLocator()); + $driver->setGlobalBasename("global"); + + $element = $driver->getElement('stdGlobal'); + + $this->assertEquals('stdGlobal', $element); + } + + public function testGetElementFromFile() + { + $locator = $this->newLocator(); + $locator->expects($this->once()) + ->method('findMappingFile') + ->with($this->equalTo('stdClass')) + ->will($this->returnValue(__DIR__ . '/_files/stdClass.yml')); + + $driver = new TestFileDriver($locator); + + $this->assertEquals('stdClass', $driver->getElement('stdClass')); + } + + public function testGetAllClassNamesGlobalBasename() + { + $driver = new TestFileDriver($this->newLocator()); + $driver->setGlobalBasename("global"); + + $classNames = $driver->getAllClassNames(); + + $this->assertEquals(array('stdGlobal', 'stdGlobal2'), $classNames); + } + + public function testGetAllClassNamesFromMappingFile() + { + $locator = $this->newLocator(); + $locator->expects($this->any()) + ->method('getAllClassNames') + ->with($this->equalTo(null)) + ->will($this->returnValue(array('stdClass'))); + $driver = new TestFileDriver($locator); + + $classNames = $driver->getAllClassNames(); + + $this->assertEquals(array('stdClass'), $classNames); + } + + public function testGetAllClassNamesBothSources() + { + $locator = $this->newLocator(); + $locator->expects($this->any()) + ->method('getAllClassNames') + ->with($this->equalTo('global')) + ->will($this->returnValue(array('stdClass'))); + $driver = new TestFileDriver($locator); + $driver->setGlobalBasename("global"); + + $classNames = $driver->getAllClassNames(); + + $this->assertEquals(array('stdGlobal', 'stdGlobal2', 'stdClass'), $classNames); + } + + public function testIsNotTransient() + { + $locator = $this->newLocator(); + $locator->expects($this->once()) + ->method('fileExists') + ->with($this->equalTo('stdClass')) + ->will($this->returnValue( true )); + + $driver = new TestFileDriver($locator); + $driver->setGlobalBasename("global"); + + $this->assertFalse($driver->isTransient('stdClass')); + $this->assertFalse($driver->isTransient('stdGlobal')); + $this->assertFalse($driver->isTransient('stdGlobal2')); + } + + public function testIsTransient() + { + $locator = $this->newLocator(); + $locator->expects($this->once()) + ->method('fileExists') + ->with($this->equalTo('stdClass2')) + ->will($this->returnValue( false )); + + $driver = new TestFileDriver($locator); + + $this->assertTrue($driver->isTransient('stdClass2')); + } + + public function testNonLocatorFallback() + { + $driver = new TestFileDriver(__DIR__ . '/_files', '.yml'); + $this->assertTrue($driver->isTransient('stdClass2')); + $this->assertFalse($driver->isTransient('stdClass')); + } + + private function newLocator() + { + $locator = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\FileLocator'); + $locator->expects($this->any())->method('getFileExtension')->will($this->returnValue('.yml')); + $locator->expects($this->any())->method('getPaths')->will($this->returnValue(array(__DIR__ . "/_files"))); + return $locator; + } +} + +class TestFileDriver extends FileDriver +{ + protected function loadMappingFile($file) + { + if (strpos($file, "global.yml") !== false) { + return array('stdGlobal' => 'stdGlobal', 'stdGlobal2' => 'stdGlobal2'); + } + return array('stdClass' => 'stdClass'); + } + + public function loadMetadataForClass($className, ClassMetadata $metadata) + { + + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php new file mode 100644 index 0000000..8fc4d80 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/PHPDriverTest.php @@ -0,0 +1,18 @@ +getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $metadata->expects($this->once())->method('getFieldNames'); + + $driver = new PHPDriver(array(__DIR__ . "/_files")); + $driver->loadMetadataForClass('TestEntity', $metadata); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php new file mode 100644 index 0000000..5f06cad --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/RuntimeReflectionServiceTest.php @@ -0,0 +1,70 @@ +. + */ + +namespace Doctrine\Tests\Common\Persistence\Mapping; + +use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService; + +/** + * @group DCOM-93 + */ +class RuntimeReflectionServiceTest extends \PHPUnit_Framework_TestCase +{ + private $reflectionService; + + public function setUp() + { + $this->reflectionService = new RuntimeReflectionService(); + } + + public function testShortname() + { + $this->assertEquals("RuntimeReflectionServiceTest", $this->reflectionService->getClassShortName(__CLASS__)); + } + + public function testClassNamespaceName() + { + $this->assertEquals("Doctrine\Tests\Common\Persistence\Mapping", $this->reflectionService->getClassNamespace(__CLASS__)); + } + + public function testGetParentClasses() + { + $classes = $this->reflectionService->getParentClasses(__CLASS__); + $this->assertTrue(count($classes) >= 1, "The test class ".__CLASS__." should have at least one parent."); + } + + public function testGetReflectionClass() + { + $class = $this->reflectionService->getClass(__CLASS__); + $this->assertInstanceOf("ReflectionClass", $class); + } + + public function testGetMethods() + { + $this->assertTrue($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods")); + $this->assertFalse($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods2")); + } + + public function testGetAccessibleProperty() + { + $reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "reflectionService"); + $this->assertInstanceOf("ReflectionProperty", $reflProp); + } +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php new file mode 100644 index 0000000..9f1c568 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticPHPDriverTest.php @@ -0,0 +1,35 @@ +getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $metadata->expects($this->once())->method('getFieldNames'); + + $driver = new StaticPHPDriver(array(__DIR__)); + $driver->loadMetadataForClass(__NAMESPACE__ . '\\TestEntity', $metadata); + } + + public function testGetAllClassNames() + { + $driver = new StaticPHPDriver(array(__DIR__)); + $classNames = $driver->getAllClassNames(); + + $this->assertContains( + 'Doctrine\Tests\Common\Persistence\Mapping\TestEntity', $classNames); + } +} + +class TestEntity +{ + static public function loadMetadata($metadata) + { + $metadata->getFieldNames(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php new file mode 100644 index 0000000..ffce6d4 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/StaticReflectionServiceTest.php @@ -0,0 +1,70 @@ +. + */ + +namespace Doctrine\Tests\Common\Persistence\Mapping; + +use Doctrine\Common\Persistence\Mapping\StaticReflectionService; + +/** + * @group DCOM-93 + */ +class StaticReflectionServiceTest extends \PHPUnit_Framework_TestCase +{ + private $reflectionService; + + public function setUp() + { + $this->reflectionService = new StaticReflectionService(); + } + + public function testShortname() + { + $this->assertEquals("StaticReflectionServiceTest", $this->reflectionService->getClassShortName(__CLASS__)); + } + + public function testClassNamespaceName() + { + $this->assertEquals("Doctrine\Tests\Common\Persistence\Mapping", $this->reflectionService->getClassNamespace(__CLASS__)); + } + + public function testGetParentClasses() + { + $classes = $this->reflectionService->getParentClasses(__CLASS__); + $this->assertTrue(count($classes) == 0, "The test class ".__CLASS__." should have no parents according to static reflection."); + } + + public function testGetReflectionClass() + { + $class = $this->reflectionService->getClass(__CLASS__); + $this->assertNull($class); + } + + public function testGetMethods() + { + $this->assertTrue($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods")); + $this->assertFalse($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods2")); + } + + public function testGetAccessibleProperty() + { + $reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "reflectionService"); + $this->assertNull($reflProp); + } +} + diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php new file mode 100644 index 0000000..b51162e --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php @@ -0,0 +1,88 @@ + $prefix)); + $this->assertEquals(array($path), $locator->getPaths()); + + $locator = new SymfonyFileLocator(array($path => $prefix)); + $this->assertEquals(array($path), $locator->getPaths()); + } + + public function testGetPrefixes() + { + $path = __DIR__ . "/_files"; + $prefix = "Foo"; + + $locator = new SymfonyFileLocator(array($path => $prefix)); + $this->assertEquals(array($path => $prefix), $locator->getNamespacePrefixes()); + } + + public function testGetFileExtension() + { + $locator = new SymfonyFileLocator(array(), ".yml"); + $this->assertEquals(".yml", $locator->getFileExtension()); + $locator->setFileExtension(".xml"); + $this->assertEquals(".xml", $locator->getFileExtension()); + } + + public function testFileExists() + { + $path = __DIR__ . "/_files"; + $prefix = "Foo"; + + $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); + + $this->assertTrue($locator->fileExists("Foo\stdClass")); + $this->assertTrue($locator->fileExists("Foo\global")); + $this->assertFalse($locator->fileExists("Foo\stdClass2")); + $this->assertFalse($locator->fileExists("Foo\global2")); + } + + public function testGetAllClassNames() + { + $path = __DIR__ . "/_files"; + $prefix = "Foo"; + + $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); + $classes = $locator->getAllClassNames(null); + sort($classes); + + $this->assertEquals(array("Foo\\global", "Foo\\stdClass"), $classes); + $this->assertEquals(array("Foo\\stdClass"), $locator->getAllClassNames("global")); + } + + public function testFindMappingFile() + { + $path = __DIR__ . "/_files"; + $prefix = "Foo"; + + $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); + + $this->assertEquals(__DIR__ . "/_files/stdClass.yml", $locator->findMappingFile("Foo\\stdClass")); + } + + public function testFindMappingFileNotFound() + { + $path = __DIR__ . "/_files"; + $prefix = "Foo"; + + $locator = new SymfonyFileLocator(array($path => $prefix), ".yml"); + + $this->setExpectedException( + "Doctrine\Common\Persistence\Mapping\MappingException", + "No mapping file found named '".__DIR__."/_files/stdClass2.yml' for class 'Foo\stdClass2'." + ); + $locator->findMappingFile("Foo\\stdClass2"); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php new file mode 100644 index 0000000..d0e9976 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/TestEntity.php @@ -0,0 +1,3 @@ +getFieldNames(); \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml new file mode 100644 index 0000000..30d74d2 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/global.yml @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml new file mode 100644 index 0000000..30d74d2 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/stdClass.yml @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php new file mode 100644 index 0000000..a0f77b5 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Persistence/PersistentObjectTest.php @@ -0,0 +1,247 @@ +cm = new TestObjectMetadata; + $this->om = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + $this->om->expects($this->any())->method('getClassMetadata') + ->will($this->returnValue($this->cm)); + $this->object = new TestObject; + PersistentObject::setObjectManager($this->om); + $this->object->injectObjectManager($this->om, $this->cm); + } + + public function testGetObjectManager() + { + $this->assertSame($this->om, PersistentObject::getObjectManager()); + } + + public function testNonMatchingObjectManager() + { + $this->setExpectedException('RuntimeException'); + $om = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); + $this->object->injectObjectManager($om, $this->cm); + } + + public function testGetField() + { + $this->assertEquals('beberlei', $this->object->getName()); + } + + public function testSetField() + { + $this->object->setName("test"); + $this->assertEquals("test", $this->object->getName()); + } + + public function testGetIdentifier() + { + $this->assertEquals(1, $this->object->getId()); + } + + public function testSetIdentifier() + { + $this->setExpectedException('BadMethodCallException'); + $this->object->setId(2); + } + + public function testSetUnknownField() + { + $this->setExpectedException('BadMethodCallException'); + $this->object->setUnknown("test"); + } + + public function testGetUnknownField() + { + $this->setExpectedException('BadMethodCallException'); + $this->object->getUnknown(); + } + + public function testGetToOneAssociation() + { + $this->assertNull($this->object->getParent()); + } + + public function testSetToOneAssociation() + { + $parent = new TestObject(); + $this->object->setParent($parent); + $this->assertSame($parent, $this->object->getParent($parent)); + } + + public function testSetInvalidToOneAssocation() + { + $parent = new \stdClass(); + + $this->setExpectedException('InvalidArgumentException'); + $this->object->setParent($parent); + } + + public function testSetToOneAssociationNull() + { + $parent = new TestObject(); + $this->object->setParent($parent); + $this->object->setParent(null); + $this->assertNull($this->object->getParent()); + } + + public function testAddToManyAssocation() + { + $child = new TestObject(); + $this->object->addChildren($child); + + $this->assertSame($this->object, $child->getParent()); + $this->assertEquals(1, count($this->object->getChildren())); + + $child = new TestObject(); + $this->object->addChildren($child); + + $this->assertEquals(2, count($this->object->getChildren())); + } + + public function testAddInvalidToManyAssocation() + { + $this->setExpectedException('InvalidArgumentException'); + $this->object->addChildren(new \stdClass()); + } + + public function testNoObjectManagerSet() + { + PersistentObject::setObjectManager(null); + $child = new TestObject(); + + $this->setExpectedException('RuntimeException'); + $child->setName("test"); + } + + public function testInvalidMethod() + { + $this->setExpectedException('BadMethodCallException'); + $this->object->asdf(); + } + + public function testAddInvalidCollection() + { + $this->setExpectedException('BadMethodCallException'); + $this->object->addAsdf(new \stdClass()); + } +} + +class TestObject extends PersistentObject +{ + protected $id = 1; + protected $name = 'beberlei'; + protected $parent; + protected $children; +} + +class TestObjectMetadata implements ClassMetadata +{ + + public function getAssociationMappedByTargetField($assocName) + { + $assoc = array('children' => 'parent'); + return $assoc[$assocName]; + } + + public function getAssociationNames() + { + return array('parent', 'children'); + } + + public function getAssociationTargetClass($assocName) + { + return __NAMESPACE__ . '\TestObject'; + } + + public function getFieldNames() + { + return array('id', 'name'); + } + + public function getIdentifier() + { + return array('id'); + } + + public function getName() + { + return __NAMESPACE__ . '\TestObject'; + } + + public function getReflectionClass() + { + return new \ReflectionClass($this->getName()); + } + + public function getTypeOfField($fieldName) + { + $types = array('id' => 'integer', 'name' => 'string'); + return $types[$fieldName]; + } + + public function hasAssociation($fieldName) + { + return in_array($fieldName, array('parent', 'children')); + } + + public function hasField($fieldName) + { + return in_array($fieldName, array('id', 'name')); + } + + public function isAssociationInverseSide($assocName) + { + return ($assocName === 'children'); + } + + public function isCollectionValuedAssociation($fieldName) + { + return ($fieldName === 'children'); + } + + public function isIdentifier($fieldName) + { + return $fieldName === 'id'; + } + + public function isSingleValuedAssociation($fieldName) + { + return $fieldName === 'parent'; + } + + public function getIdentifierValues($entity) + { + + } + + public function getIdentifierFieldNames() + { + + } + + public function initializeReflection(ReflectionService $reflService) + { + + } + + public function wakeupReflection(ReflectionService $reflService) + { + + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php new file mode 100644 index 0000000..a281450 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/ClassUtilsTest.php @@ -0,0 +1,100 @@ +assertEquals($expectedClassName, ClassUtils::getRealClass($className)); + } + + /** + * @dataProvider dataGetClass + */ + public function testGetClass( $className, $expectedClassName ) + { + $object = new $className(); + $this->assertEquals($expectedClassName, ClassUtils::getClass($object)); + } + + public function testGetParentClass() + { + $parentClass = ClassUtils::getParentClass( 'MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\Doctrine\Tests\Common\Util\ChildObject' ); + $this->assertEquals('stdClass', $parentClass); + } + + public function testGenerateProxyClassName() + { + $this->assertEquals( 'Proxies\__CG__\stdClass', ClassUtils::generateProxyClassName( 'stdClass', 'Proxies' ) ); + } + + /** + * @dataProvider dataGetClass + */ + public function testNewReflectionClass( $className, $expectedClassName ) + { + $reflClass = ClassUtils::newReflectionClass( $className ); + $this->assertEquals( $expectedClassName, $reflClass->getName() ); + } + + /** + * @dataProvider dataGetClass + */ + public function testNewReflectionObject( $className, $expectedClassName ) + { + $object = new $className; + $reflClass = ClassUtils::newReflectionObject( $object ); + $this->assertEquals( $expectedClassName, $reflClass->getName() ); + } + } + + class ChildObject extends \stdClass + { + } +} + +namespace MyProject\Proxies\__CG__ +{ + class stdClass extends \stdClass + { + } +} + +namespace MyProject\Proxies\__CG__\Doctrine\Tests\Common\Util +{ + class ChildObject extends \Doctrine\Tests\Common\Util\ChildObject + { + } +} + +namespace MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__ +{ + class stdClass extends \MyProject\Proxies\__CG__\stdClass + { + } +} + +namespace MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\Doctrine\Tests\Common\Util +{ + class ChildObject extends \MyProject\Proxies\__CG__\Doctrine\Tests\Common\Util\ChildObject + { + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/DebugTest.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/DebugTest.php new file mode 100644 index 0000000..b4e9eed --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/Common/Util/DebugTest.php @@ -0,0 +1,27 @@ +foo = "bar"; + $obj->bar = 1234; + + $var = Debug::export($obj, 2); + $this->assertEquals( "stdClass", $var->__CLASS__ ); + } + + public function testExportDateTime() + { + $obj = new \DateTime( "2010-10-10 10:10:10" ); + + $var = Debug::export( $obj, 2 ); + $this->assertEquals( "DateTime", $var->__CLASS__ ); + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/DoctrineTestCase.php b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/DoctrineTestCase.php new file mode 100644 index 0000000..e8323d2 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/Doctrine/Tests/DoctrineTestCase.php @@ -0,0 +1,10 @@ + + */ +class NativePhpunitTask extends Task +{ + private $test; + private $testfile; + private $testdirectory; + private $configuration = null; + private $coverageClover = null; + private $junitlogfile = null; + private $haltonfailure = true; + private $haltonerror = true; + + public function setTestdirectory($directory) { + $this->testdirectory = $directory; + } + + public function setTest($test) { + $this->test = $test; + } + + public function setTestfile($testfile) { + $this->testfile = $testfile; + } + + public function setJunitlogfile($junitlogfile) { + if (strlen($junitlogfile) == 0) { + $junitlogfile = NULL; + } + + $this->junitlogfile = $junitlogfile; + } + + public function setConfiguration($configuration) { + if (strlen($configuration) == 0) { + $configuration = NULL; + } + + $this->configuration = $configuration; + } + + public function setCoverageClover($coverageClover) { + if (strlen($coverageClover) == 0) { + $coverageClover = NULL; + } + + $this->coverageClover = $coverageClover; + } + + public function setHaltonfailure($haltonfailures) { + $this->haltonfailure = $haltonfailures; + } + + public function setHaltonerror($haltonerrors) { + $this->haltonerror = $haltonerrors; + } + + public function init() + { + require_once "PHPUnit/Runner/Version.php"; + $version = PHPUnit_Runner_Version::id(); + + if (version_compare($version, '3.4.0') < 0) { + throw new BuildException("NativePHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation()); + } + + require_once 'PHPUnit/Util/Filter.php'; + + // point PHPUnit_MAIN_METHOD define to non-existing method + if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined'); + } + } + + public function main() + { + if (!is_dir(realpath($this->testdirectory))) { + throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '".$this->testdirectory."' given."); + } + set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path()); + + $printer = new NativePhpunitPrinter(); + + $arguments = array( + 'configuration' => $this->configuration, + 'coverageClover' => $this->coverageClover, + 'junitLogfile' => $this->junitlogfile, + 'printer' => $printer, + ); + + $runner = new PHPUnit_TextUI_TestRunner(); + $suite = $runner->getTest($this->test, $this->testfile, true); + + try { + $result = $runner->doRun($suite, $arguments); + /* @var $result PHPUnit_Framework_TestResult */ + + if ( ($this->haltonfailure && $result->failureCount() > 0) || ($this->haltonerror && $result->errorCount() > 0) ) { + throw new BuildException("PHPUnit: ".$result->failureCount()." Failures and ".$result->errorCount()." Errors, ". + "last failure message: ".$printer->getMessages()); + } + + $this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ". + "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); + + // Hudson for example doesn't like the backslash in class names + if (file_exists($this->coverageClover)) { + $this->log("Generated Clover Coverage XML to: ".$this->coverageClover); + $content = file_get_contents($this->coverageClover); + $content = str_replace("\\", ".", $content); + file_put_contents($this->coverageClover, $content); + unset($content); + } + + } catch(\Exception $e) { + throw new BuildException("NativePhpunitTask failed: ".$e->getMessage()); + } + } +} + +class NativePhpunitPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener +{ + private $_messages = array(); + + public function write($buffer) + { + // do nothing + } + + public function getMessages() + { + return $this->_messages; + } + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->_messages[] = "Test ERROR: ".$test->getName().": ".$e->getMessage(); + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + $this->_messages[] = "Test FAILED: ".$test->getName().": ".$e->getMessage(); + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + + } + + /** + * A test suite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + + } + + /** + * A test suite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + + } +} diff --git a/vendor/doctrine/common/doctrine-common-ac6c39b/tests/README.markdown b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/README.markdown new file mode 100644 index 0000000..e6f1703 --- /dev/null +++ b/vendor/doctrine/common/doctrine-common-ac6c39b/tests/README.markdown @@ -0,0 +1,27 @@ +# Running the Doctrine 2 Testsuite + +## Running tests + +Execute PHPUnit in the root folder of your doctrine-common clone. + + phpunit + +## Testing Lock-Support + +The Lock support in Doctrine 2 is tested using Gearman, which allows to run concurrent tasks in parallel. +Install Gearman with PHP as follows: + +1. Go to http://www.gearman.org and download the latest Gearman Server +2. Compile it and then call ldconfig +3. Start it up "gearmand -vvvv" +4. Install pecl/gearman by calling "gearman-beta" + +You can then go into tests/ and start up two workers: + + php Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php + +Then run the locking test-suite: + + phpunit --configuration Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php + +This can run considerable time, because it is using sleep() to test for the timing ranges of locks. \ No newline at end of file diff --git a/vendor/doctrine/dbal/.gitignore b/vendor/doctrine/dbal/.gitignore new file mode 100644 index 0000000..a9b57aa --- /dev/null +++ b/vendor/doctrine/dbal/.gitignore @@ -0,0 +1,6 @@ +build/ +logs/ +reports/ +dist/ +download/ +lib/Doctrine/Common/ diff --git a/vendor/doctrine/dbal/.gitmodules b/vendor/doctrine/dbal/.gitmodules new file mode 100644 index 0000000..00dc3fa --- /dev/null +++ b/vendor/doctrine/dbal/.gitmodules @@ -0,0 +1,9 @@ +[submodule "lib/vendor/doctrine-common"] + path = lib/vendor/doctrine-common + url = git://github.com/doctrine/common.git +[submodule "lib/vendor/Symfony/Component/Console"] + path = lib/vendor/Symfony/Component/Console + url = git://github.com/symfony/Console.git +[submodule "lib/vendor/doctrine-build-common"] + path = lib/vendor/doctrine-build-common + url = git://github.com/doctrine/doctrine-build-common.git diff --git a/vendor/doctrine/dbal/bin/doctrine-dbal b/vendor/doctrine/dbal/bin/doctrine-dbal new file mode 100644 index 0000000..7ca0142 --- /dev/null +++ b/vendor/doctrine/dbal/bin/doctrine-dbal @@ -0,0 +1,4 @@ +#!/usr/bin/env php +register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine'); +$classLoader->register(); + +$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; + +$helperSet = null; +if (file_exists($configFile)) { + if ( ! is_readable($configFile)) { + trigger_error( + 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR + ); + } + + require $configFile; + + foreach ($GLOBALS as $helperSetCandidate) { + if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) { + $helperSet = $helperSetCandidate; + break; + } + } +} + +$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet(); + +$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\DBAL\Version::VERSION); +$cli->setCatchExceptions(true); +$cli->setHelperSet($helperSet); +$cli->addCommands(array( + // DBAL Commands + new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), + new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), + new \Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand(), + +)); +$cli->run(); \ No newline at end of file diff --git a/vendor/doctrine/dbal/bin/doctrine.php b/vendor/doctrine/dbal/bin/doctrine.php new file mode 100644 index 0000000..c24d306 --- /dev/null +++ b/vendor/doctrine/dbal/bin/doctrine.php @@ -0,0 +1,42 @@ +register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine'); +$classLoader->register(); + +$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; + +$helperSet = null; +if (file_exists($configFile)) { + if ( ! is_readable($configFile)) { + trigger_error( + 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR + ); + } + + require $configFile; + + foreach ($GLOBALS as $helperSetCandidate) { + if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) { + $helperSet = $helperSetCandidate; + break; + } + } +} + +$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet(); + +$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\DBAL\Version::VERSION); +$cli->setCatchExceptions(true); +$cli->setHelperSet($helperSet); +$cli->addCommands(array( + // DBAL Commands + new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), + new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), + +)); +$cli->run(); diff --git a/vendor/doctrine/dbal/build.properties b/vendor/doctrine/dbal/build.properties new file mode 100644 index 0000000..12b5e8f --- /dev/null +++ b/vendor/doctrine/dbal/build.properties @@ -0,0 +1,10 @@ +# Project Name +project.name=DoctrineDBAL + +# Dependency minimum versions +dependencies.common=2.0.1 +dependencies.sfconsole=2.0.0 + +# Version class and file +project.version_class = Doctrine\DBAL\Version +project.version_file = lib/Doctrine/DBAL/Version.php diff --git a/vendor/doctrine/dbal/build.xml b/vendor/doctrine/dbal/build.xml new file mode 100644 index 0000000..0fb05ff --- /dev/null +++ b/vendor/doctrine/dbal/build.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${project.name} + Doctrine Database Abstraction Layer + pear.doctrine-project.org + The Doctrine DBAL package is the database abstraction layer used to power the ORM package. + + + + + LGPL + + + - + + + + + + + script + Doctrine/Common/ + Doctrine/Symfony/ + + + + + + + diff --git a/vendor/doctrine/dbal/tests/.gitignore b/vendor/doctrine/dbal/tests/.gitignore new file mode 100644 index 0000000..7210405 --- /dev/null +++ b/vendor/doctrine/dbal/tests/.gitignore @@ -0,0 +1,3 @@ +Doctrine/Tests/Proxies/ +Doctrine/Tests/ORM/Proxy/generated/ +Doctrine/Tests/ORM/Tools/Export/export diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php new file mode 100644 index 0000000..bcd6834 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -0,0 +1,148 @@ + 'pdo_mysql', + 'host' => 'localhost', + 'user' => 'root', + 'password' => 'password', + 'port' => '1234' + ); + $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($params); + } + + public function testIsConnected() + { + $this->assertFalse($this->_conn->isConnected()); + } + + public function testNoTransactionActiveByDefault() + { + $this->assertFalse($this->_conn->isTransactionActive()); + } + + public function testCommitWithNoActiveTransaction_ThrowsException() + { + $this->setExpectedException('Doctrine\DBAL\ConnectionException'); + $this->_conn->commit(); + } + + public function testRollbackWithNoActiveTransaction_ThrowsException() + { + $this->setExpectedException('Doctrine\DBAL\ConnectionException'); + $this->_conn->rollback(); + } + + public function testSetRollbackOnlyNoActiveTransaction_ThrowsException() + { + $this->setExpectedException('Doctrine\DBAL\ConnectionException'); + $this->_conn->setRollbackOnly(); + } + + public function testIsRollbackOnlyNoActiveTransaction_ThrowsException() + { + $this->setExpectedException('Doctrine\DBAL\ConnectionException'); + $this->_conn->isRollbackOnly(); + } + + public function testGetConfiguration() + { + $config = $this->_conn->getConfiguration(); + + $this->assertInstanceOf('Doctrine\DBAL\Configuration', $config); + } + + public function testGetHost() + { + $this->assertEquals('localhost', $this->_conn->getHost()); + } + + public function testGetPort() + { + $this->assertEquals('1234', $this->_conn->getPort()); + } + + public function testGetUsername() + { + $this->assertEquals('root', $this->_conn->getUsername()); + } + + public function testGetPassword() + { + $this->assertEquals('password', $this->_conn->getPassword()); + } + + public function testGetDriver() + { + $this->assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $this->_conn->getDriver()); + } + + public function testGetEventManager() + { + $this->assertInstanceOf('Doctrine\Common\EventManager', $this->_conn->getEventManager()); + } + + public function testConnectDispatchEvent() + { + $listenerMock = $this->getMock('ConnectDispatchEventListener', array('postConnect')); + $listenerMock->expects($this->once())->method('postConnect'); + + $eventManager = new EventManager(); + $eventManager->addEventListener(array(Events::postConnect), $listenerMock); + + $driverMock = $this->getMock('Doctrine\DBAL\Driver'); + $driverMock->expects(($this->at(0))) + ->method('connect'); + $platform = new Mocks\MockPlatform(); + + $conn = new Connection(array('platform' => $platform), $driverMock, new Configuration(), $eventManager); + $conn->connect(); + } + + public function testEventManagerPassedToPlatform() + { + $this->assertInstanceOf('Doctrine\Common\EventManager', $this->_conn->getDatabasePlatform()->getEventManager()); + $this->assertSame($this->_conn->getEventManager(), $this->_conn->getDatabasePlatform()->getEventManager()); + } + + /** + * Pretty dumb test, however we want to check that the EchoSQLLogger correctly implements the interface. + * + * @group DBAL-11 + */ + public function testEchoSQLLogger() + { + $logger = new \Doctrine\DBAL\Logging\EchoSQLLogger(); + $this->_conn->getConfiguration()->setSQLLogger($logger); + $this->assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger()); + } + + /** + * Pretty dumb test, however we want to check that the DebugStack correctly implements the interface. + * + * @group DBAL-11 + */ + public function testDebugSQLStack() + { + $logger = new \Doctrine\DBAL\Logging\DebugStack(); + $this->_conn->getConfiguration()->setSQLLogger($logger); + $this->assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php new file mode 100644 index 0000000..a3dfe2a --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -0,0 +1,82 @@ +markTestSkipped('oci8 is not installed.'); + } + + parent::setUp(); + } + + /** + * This scenario shows that when the first parameter is not null + * it properly sets $hasZeroIndex to 1 and calls bindValue starting at 1. + * + * This also verifies that the statement will check with the connection to + * see what the current execution mode is. + * + * The expected exception is due to oci_execute failing due to no valid connection. + * + * @dataProvider executeDataProvider + * @expectedException \Doctrine\DBAL\Driver\OCI8\OCI8Exception + */ + public function testExecute(array $params) + { + $statement = $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Statement', + array('bindValue', 'errorInfo'), + array(), '', false); + + $statement->expects($this->at(0)) + ->method('bindValue') + ->with( + $this->equalTo(1), + $this->equalTo($params[0]) + ); + $statement->expects($this->at(1)) + ->method('bindValue') + ->with( + $this->equalTo(2), + $this->equalTo($params[1]) + ); + $statement->expects($this->at(2)) + ->method('bindValue') + ->with( + $this->equalTo(3), + $this->equalTo($params[2]) + ); + + // can't pass to constructor since we don't have a real database handle, + // but execute must check the connection for the executeMode + $conn = $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Connection', array('getExecuteMode'), array(), '', false); + $conn->expects($this->once()) + ->method('getExecuteMode'); + + $reflProperty = new \ReflectionProperty($statement, '_conn'); + $reflProperty->setAccessible(true); + $reflProperty->setValue($statement, $conn); + + $statement->execute($params); + } + + public static function executeDataProvider() + { + return array( + // $hasZeroIndex = isset($params[0]); == true + array( + array(0 => 'test', 1 => null, 2 => 'value') + ), + // $hasZeroIndex = isset($params[0]); == false + array( + array(0 => null, 1 => 'test', 2 => 'value') + ) + ); + } + +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php new file mode 100644 index 0000000..055b2ae --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -0,0 +1,117 @@ + 'test' + ); + $test = \Doctrine\DBAL\DriverManager::getConnection($options); + } + + public function testValidPdoInstance() + { + $options = array( + 'pdo' => new \PDO('sqlite::memory:') + ); + $conn = \Doctrine\DBAL\DriverManager::getConnection($options); + $this->assertEquals('sqlite', $conn->getDatabasePlatform()->getName()); + } + + /** + * @group DBAL-32 + */ + public function testPdoInstanceSetErrorMode() + { + $pdo = new \PDO('sqlite::memory:'); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); + $options = array( + 'pdo' => $pdo + ); + + $conn = \Doctrine\DBAL\DriverManager::getConnection($options); + $this->assertEquals(\PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(\PDO::ATTR_ERRMODE)); + } + + /** + * @expectedException \Doctrine\DBAL\DBALException + */ + public function testCheckParams() + { + $conn = \Doctrine\DBAL\DriverManager::getConnection(array()); + } + + /** + * @expectedException \Doctrine\DBAL\DBALException + */ + public function testInvalidDriver() + { + $conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'invalid_driver')); + } + + public function testCustomPlatform() + { + $mockPlatform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $options = array( + 'pdo' => new \PDO('sqlite::memory:'), + 'platform' => $mockPlatform + ); + + $conn = \Doctrine\DBAL\DriverManager::getConnection($options); + $this->assertSame($mockPlatform, $conn->getDatabasePlatform()); + } + + public function testCustomWrapper() + { + $wrapperClass = 'Doctrine\Tests\Mocks\ConnectionMock'; + + $options = array( + 'pdo' => new \PDO('sqlite::memory:'), + 'wrapperClass' => $wrapperClass, + ); + + $conn = \Doctrine\DBAL\DriverManager::getConnection($options); + $this->assertInstanceOf($wrapperClass, $conn); + } + + public function testInvalidWrapperClass() + { + $this->setExpectedException('\Doctrine\DBAL\DBALException'); + + $options = array( + 'pdo' => new \PDO('sqlite::memory:'), + 'wrapperClass' => 'stdClass', + ); + + $conn = \Doctrine\DBAL\DriverManager::getConnection($options); + } + + public function testInvalidDriverClass() + { + $this->setExpectedException('\Doctrine\DBAL\DBALException'); + + $options = array( + 'driverClass' => 'stdClass' + ); + + $conn = \Doctrine\DBAL\DriverManager::getConnection($options); + } + + public function testValidDriverClass() + { + $options = array( + 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', + ); + + $conn = \Doctrine\DBAL\DriverManager::getConnection($options); + $this->assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $conn->getDriver()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php new file mode 100644 index 0000000..1ef47dd --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php @@ -0,0 +1,33 @@ +getMock('Doctrine\DBAL\Connection', array(), array(), '', false); + $connectionMock->expects($this->once()) + ->method('executeUpdate') + ->with($this->equalTo("SET NAMES foo COLLATE bar")); + + $eventArgs = new ConnectionEventArgs($connectionMock); + + + $listener = new MysqlSessionInit('foo', 'bar'); + $listener->postConnect($eventArgs); + } + + public function testGetSubscribedEvents() + { + $listener = new MysqlSessionInit(); + $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php new file mode 100644 index 0000000..847ed6b --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php @@ -0,0 +1,33 @@ +getMock('Doctrine\DBAL\Connection', array(), array(), '', false); + $connectionMock->expects($this->once()) + ->method('executeUpdate') + ->with($this->isType('string')); + + $eventArgs = new ConnectionEventArgs($connectionMock); + + + $listener = new OracleSessionInit(); + $listener->postConnect($eventArgs); + } + + public function testGetSubscribedEvents() + { + $listener = new OracleSessionInit(); + $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php new file mode 100644 index 0000000..ed2dd43 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php @@ -0,0 +1,35 @@ +getMock('Doctrine\DBAL\Connection', array(), array(), '', false); + $connectionMock->expects($this->once()) + ->method('exec') + ->with($this->equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'")); + + $eventArgs = new ConnectionEventArgs($connectionMock); + + $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"); + $listener->postConnect($eventArgs); + } + + public function testGetSubscribedEvents() + { + $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"); + $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php new file mode 100644 index 0000000..7c56542 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php @@ -0,0 +1,83 @@ +addColumn('id', 'integer'); + $table->addColumn('clobfield', 'text'); + $table->addColumn('blobfield', 'blob'); + $table->setPrimaryKey(array('id')); + + $sm = $this->_conn->getSchemaManager(); + $sm->createTable($table); + } catch(\Exception $e) { + + } + $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('blob_table')); + } + + public function testInsert() + { + $ret = $this->_conn->insert('blob_table', + array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test'), + array(\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_LOB) + ); + $this->assertEquals(1, $ret); + } + + public function testSelect() + { + $ret = $this->_conn->insert('blob_table', + array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test'), + array(\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_LOB) + ); + + $this->assertBlobContains('test'); + } + + public function testUpdate() + { + $ret = $this->_conn->insert('blob_table', + array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test'), + array(\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_LOB) + ); + + $this->_conn->update('blob_table', + array('blobfield' => 'test2'), + array('id' => 1), + array(\PDO::PARAM_LOB, \PDO::PARAM_INT) + ); + + $this->assertBlobContains('test2'); + } + + private function assertBlobContains($text) + { + $rows = $this->_conn->fetchAll('SELECT * FROM blob_table'); + + $this->assertEquals(1, count($rows)); + $row = array_change_key_case($rows[0], CASE_LOWER); + + $blobValue = Type::getType('blob')->convertToPHPValue($row['blobfield'], $this->_conn->getDatabasePlatform()); + + $this->assertInternalType('resource', $blobValue); + $this->assertEquals($text, stream_get_contents($blobValue)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php new file mode 100644 index 0000000..31da42f --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -0,0 +1,219 @@ +resetSharedConn(); + parent::setUp(); + } + + public function tearDown() + { + parent::tearDown(); + $this->resetSharedConn(); + } + + public function testGetWrappedConnection() + { + $this->assertInstanceOf('Doctrine\DBAL\Driver\Connection', $this->_conn->getWrappedConnection()); + } + + public function testCommitWithRollbackOnlyThrowsException() + { + $this->_conn->beginTransaction(); + $this->_conn->setRollbackOnly(); + $this->setExpectedException('Doctrine\DBAL\ConnectionException'); + $this->_conn->commit(); + } + + public function testTransactionNestingBehavior() + { + try { + $this->_conn->beginTransaction(); + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + + try { + $this->_conn->beginTransaction(); + $this->assertEquals(2, $this->_conn->getTransactionNestingLevel()); + throw new \Exception; + $this->_conn->commit(); // never reached + } catch (\Exception $e) { + $this->_conn->rollback(); + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + //no rethrow + } + $this->assertTrue($this->_conn->isRollbackOnly()); + + $this->_conn->commit(); // should throw exception + $this->fail('Transaction commit after failed nested transaction should fail.'); + } catch (ConnectionException $e) { + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + $this->_conn->rollback(); + $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); + } + } + + public function testTransactionNestingBehaviorWithSavepoints() + { + if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) { + $this->markTestSkipped('This test requires the platform to support savepoints.'); + } + + $this->_conn->setNestTransactionsWithSavepoints(true); + try { + $this->_conn->beginTransaction(); + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + + try { + $this->_conn->beginTransaction(); + $this->assertEquals(2, $this->_conn->getTransactionNestingLevel()); + $this->_conn->beginTransaction(); + $this->assertEquals(3, $this->_conn->getTransactionNestingLevel()); + $this->_conn->commit(); + $this->assertEquals(2, $this->_conn->getTransactionNestingLevel()); + throw new \Exception; + $this->_conn->commit(); // never reached + } catch (\Exception $e) { + $this->_conn->rollback(); + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + //no rethrow + } + $this->assertFalse($this->_conn->isRollbackOnly()); + try { + $this->_conn->setNestTransactionsWithSavepoints(false); + $this->fail('Should not be able to disable savepoints in usage for nested transactions inside an open transaction.'); + } catch (ConnectionException $e) { + $this->assertTrue($this->_conn->getNestTransactionsWithSavepoints()); + } + $this->_conn->commit(); // should not throw exception + } catch (ConnectionException $e) { + $this->fail('Transaction commit after failed nested transaction should not fail when using savepoints.'); + $this->_conn->rollback(); + } + } + + public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction() + { + if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) { + $this->markTestSkipped('This test requires the platform to support savepoints.'); + } + + $this->_conn->beginTransaction(); + try { + $this->_conn->setNestTransactionsWithSavepoints(true); + $this->fail('An exception should have been thrown by chaning the nesting transaction behavior within an transaction.'); + } catch(ConnectionException $e) { + $this->_conn->rollBack(); + } + } + + public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException() + { + if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { + $this->markTestSkipped('This test requires the platform not to support savepoints.'); + } + + $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); + + $this->_conn->setNestTransactionsWithSavepoints(true); + } + + public function testCreateSavepointsNotSupportedThrowsException() + { + if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { + $this->markTestSkipped('This test requires the platform not to support savepoints.'); + } + + $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); + + $this->_conn->createSavepoint('foo'); + } + + public function testReleaseSavepointsNotSupportedThrowsException() + { + if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { + $this->markTestSkipped('This test requires the platform not to support savepoints.'); + } + + $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); + + $this->_conn->releaseSavepoint('foo'); + } + + public function testRollbackSavepointsNotSupportedThrowsException() + { + if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) { + $this->markTestSkipped('This test requires the platform not to support savepoints.'); + } + + $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver."); + + $this->_conn->rollbackSavepoint('foo'); + } + + public function testTransactionBehaviorWithRollback() + { + try { + $this->_conn->beginTransaction(); + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + + throw new \Exception; + + $this->_conn->commit(); // never reached + } catch (\Exception $e) { + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + $this->_conn->rollback(); + $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); + } + } + + public function testTransactionBehaviour() + { + try { + $this->_conn->beginTransaction(); + $this->assertEquals(1, $this->_conn->getTransactionNestingLevel()); + $this->_conn->commit(); + } catch (\Exception $e) { + $this->_conn->rollback(); + $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); + } + + $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); + } + + public function testTransactionalWithException() + { + try { + $this->_conn->transactional(function($conn) { + $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); + throw new \RuntimeException("Ooops!"); + }); + } catch (\RuntimeException $expected) { + $this->assertEquals(0, $this->_conn->getTransactionNestingLevel()); + } + } + + public function testTransactional() + { + $this->_conn->transactional(function($conn) { + /* @var $conn Connection */ + $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); + }); + } + + /** + * Tests that the quote function accepts DBAL and PDO types. + */ + public function testQuote() + { + $this->assertEquals($this->_conn->quote("foo", Type::STRING), $this->_conn->quote("foo", \PDO::PARAM_STR)); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php new file mode 100644 index 0000000..86a7ee4 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -0,0 +1,477 @@ +addColumn('test_int', 'integer'); + $table->addColumn('test_string', 'string'); + $table->addColumn('test_datetime', 'datetime', array('notnull' => false)); + $table->setPrimaryKey(array('test_int')); + + $sm = $this->_conn->getSchemaManager(); + $sm->createTable($table); + + $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10')); + self::$generated = true; + } + } + + public function testPrepareWithBindValue() + { + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + + $stmt->bindValue(1, 1); + $stmt->bindValue(2, 'foo'); + $stmt->execute(); + + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = array_change_key_case($row, \CASE_LOWER); + $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); + } + + public function testPrepareWithBindParam() + { + $paramInt = 1; + $paramStr = 'foo'; + + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + + $stmt->bindParam(1, $paramInt); + $stmt->bindParam(2, $paramStr); + $stmt->execute(); + + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $row = array_change_key_case($row, \CASE_LOWER); + $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); + } + + public function testPrepareWithFetchAll() + { + $paramInt = 1; + $paramStr = 'foo'; + + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + + $stmt->bindParam(1, $paramInt); + $stmt->bindParam(2, $paramStr); + $stmt->execute(); + + $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $rows[0] = array_change_key_case($rows[0], \CASE_LOWER); + $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]); + } + + /** + * @group DBAL-228 + */ + public function testPrepareWithFetchAllBoth() + { + $paramInt = 1; + $paramStr = 'foo'; + + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + + $stmt->bindParam(1, $paramInt); + $stmt->bindParam(2, $paramStr); + $stmt->execute(); + + $rows = $stmt->fetchAll(\PDO::FETCH_BOTH); + $rows[0] = array_change_key_case($rows[0], \CASE_LOWER); + $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'), $rows[0]); + } + + public function testPrepareWithFetchColumn() + { + $paramInt = 1; + $paramStr = 'foo'; + + $sql = "SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + + $stmt->bindParam(1, $paramInt); + $stmt->bindParam(2, $paramStr); + $stmt->execute(); + + $column = $stmt->fetchColumn(); + $this->assertEquals(1, $column); + } + + public function testPrepareWithIterator() + { + $paramInt = 1; + $paramStr = 'foo'; + + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + + $stmt->bindParam(1, $paramInt); + $stmt->bindParam(2, $paramStr); + $stmt->execute(); + + $rows = array(); + $stmt->setFetchMode(\PDO::FETCH_ASSOC); + foreach ($stmt as $row) { + $rows[] = array_change_key_case($row, \CASE_LOWER); + } + + $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]); + } + + public function testPrepareWithQuoted() + { + $table = 'fetch_table'; + $paramInt = 1; + $paramStr = 'foo'; + + $sql = "SELECT test_int, test_string FROM " . $this->_conn->quoteIdentifier($table) . " ". + "WHERE test_int = " . $this->_conn->quote($paramInt) . " AND test_string = " . $this->_conn->quote($paramStr); + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + } + + public function testPrepareWithExecuteParams() + { + $paramInt = 1; + $paramStr = 'foo'; + + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $stmt = $this->_conn->prepare($sql); + $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt); + $stmt->execute(array($paramInt, $paramStr)); + + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $this->assertTrue($row !== false); + $row = array_change_key_case($row, \CASE_LOWER); + $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row); + } + + public function testFetchAll() + { + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $data = $this->_conn->fetchAll($sql, array(1, 'foo')); + + $this->assertEquals(1, count($data)); + + $row = $data[0]; + $this->assertEquals(2, count($row)); + + $row = array_change_key_case($row, \CASE_LOWER); + $this->assertEquals(1, $row['test_int']); + $this->assertEquals('foo', $row['test_string']); + } + + public function testFetchBoth() + { + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $row = $this->_conn->executeQuery($sql, array(1, 'foo'))->fetch(); + + $this->assertTrue($row !== false); + + $row = array_change_key_case($row, \CASE_LOWER); + + $this->assertEquals(1, $row['test_int']); + $this->assertEquals('foo', $row['test_string']); + $this->assertEquals(1, $row[0]); + $this->assertEquals('foo', $row[1]); + } + + public function testFetchRow() + { + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $row = $this->_conn->fetchAssoc($sql, array(1, 'foo')); + + $this->assertTrue($row !== false); + + $row = array_change_key_case($row, \CASE_LOWER); + + $this->assertEquals(1, $row['test_int']); + $this->assertEquals('foo', $row['test_string']); + } + + public function testFetchArray() + { + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $row = $this->_conn->fetchArray($sql, array(1, 'foo')); + + $this->assertEquals(1, $row[0]); + $this->assertEquals('foo', $row[1]); + } + + public function testFetchColumn() + { + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $testInt = $this->_conn->fetchColumn($sql, array(1, 'foo'), 0); + + $this->assertEquals(1, $testInt); + + $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; + $testString = $this->_conn->fetchColumn($sql, array(1, 'foo'), 1); + + $this->assertEquals('foo', $testString); + } + + /** + * @group DDC-697 + */ + public function testExecuteQueryBindDateTimeType() + { + $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; + $stmt = $this->_conn->executeQuery($sql, + array(1 => new \DateTime('2010-01-01 10:10:10')), + array(1 => Type::DATETIME) + ); + + $this->assertEquals(1, $stmt->fetchColumn()); + } + + /** + * @group DDC-697 + */ + public function testExecuteUpdateBindDateTimeType() + { + $datetime = new \DateTime('2010-02-02 20:20:20'); + + $sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)'; + $affectedRows = $this->_conn->executeUpdate($sql, + array(1 => 50, 2 => 'foo', 3 => $datetime), + array(1 => PDO::PARAM_INT, 2 => PDO::PARAM_STR, 3 => Type::DATETIME) + ); + + $this->assertEquals(1, $affectedRows); + $this->assertEquals(1, $this->_conn->executeQuery( + 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?', + array(1 => $datetime), + array(1 => Type::DATETIME) + )->fetchColumn()); + } + + /** + * @group DDC-697 + */ + public function testPrepareQueryBindValueDateTimeType() + { + $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; + $stmt = $this->_conn->prepare($sql); + $stmt->bindValue(1, new \DateTime('2010-01-01 10:10:10'), Type::DATETIME); + $stmt->execute(); + + $this->assertEquals(1, $stmt->fetchColumn()); + } + + /** + * @group DBAL-78 + */ + public function testNativeArrayListSupport() + { + for ($i = 100; $i < 110; $i++) { + $this->_conn->insert('fetch_table', array('test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10')); + } + + $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_int IN (?)', + array(array(100, 101, 102, 103, 104)), array(Connection::PARAM_INT_ARRAY)); + + $data = $stmt->fetchAll(PDO::FETCH_NUM); + $this->assertEquals(5, count($data)); + $this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data); + + $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_string IN (?)', + array(array('foo100', 'foo101', 'foo102', 'foo103', 'foo104')), array(Connection::PARAM_STR_ARRAY)); + + $data = $stmt->fetchAll(PDO::FETCH_NUM); + $this->assertEquals(5, count($data)); + $this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data); + } + + /** + * @group DDC-1014 + */ + public function testDateArithmetics() + { + $p = $this->_conn->getDatabasePlatform(); + $sql = 'SELECT '; + $sql .= $p->getDateDiffExpression('test_datetime', $p->getCurrentTimestampSQL()) .' AS diff, '; + $sql .= $p->getDateAddDaysExpression('test_datetime', 10) .' AS add_days, '; + $sql .= $p->getDateSubDaysExpression('test_datetime', 10) .' AS sub_days, '; + $sql .= $p->getDateAddMonthExpression('test_datetime', 2) .' AS add_month, '; + $sql .= $p->getDateSubMonthExpression('test_datetime', 2) .' AS sub_month '; + $sql .= 'FROM fetch_table'; + + $row = $this->_conn->fetchAssoc($sql); + $row = array_change_key_case($row, CASE_LOWER); + + $diff = floor( (strtotime('2010-01-01')-time()) / 3600 / 24); + $this->assertEquals($diff, (int)$row['diff'], "Date difference should be approx. ".$diff." days.", 1); + $this->assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])), "Adding date should end up on 2010-01-11"); + $this->assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])), "Subtracting date should end up on 2009-12-22"); + $this->assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])), "Adding month should end up on 2010-03-01"); + $this->assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])), "Adding month should end up on 2009-11-01"); + } + + public function testQuoteSQLInjection() + { + $sql = "SELECT * FROM fetch_table WHERE test_string = " . $this->_conn->quote("bar' OR '1'='1"); + $rows = $this->_conn->fetchAll($sql); + + $this->assertEquals(0, count($rows), "no result should be returned, otherwise SQL injection is possible"); + } + + /** + * @group DDC-1213 + */ + public function testBitComparisonExpressionSupport() + { + $this->_conn->executeQuery('DELETE FROM fetch_table')->execute(); + $platform = $this->_conn->getDatabasePlatform(); + $bitmap = array(); + + for ($i = 2; $i < 9; $i = $i + 2) { + $bitmap[$i] = array( + 'bit_or' => ($i | 2), + 'bit_and' => ($i & 2) + ); + $this->_conn->insert('fetch_table', array( + 'test_int' => $i, + 'test_string' => json_encode($bitmap[$i]), + 'test_datetime' => '2010-01-01 10:10:10' + )); + } + + $sql[] = 'SELECT '; + $sql[] = 'test_int, '; + $sql[] = 'test_string, '; + $sql[] = $platform->getBitOrComparisonExpression('test_int', 2) . ' AS bit_or, '; + $sql[] = $platform->getBitAndComparisonExpression('test_int', 2) . ' AS bit_and '; + $sql[] = 'FROM fetch_table'; + + $stmt = $this->_conn->executeQuery(implode(PHP_EOL, $sql)); + $data = $stmt->fetchAll(PDO::FETCH_ASSOC); + + + $this->assertEquals(4, count($data)); + $this->assertEquals(count($bitmap), count($data)); + foreach ($data as $row) { + $row = array_change_key_case($row, CASE_LOWER); + + $this->assertArrayHasKey('test_int', $row); + + $id = $row['test_int']; + + $this->assertArrayHasKey($id, $bitmap); + $this->assertArrayHasKey($id, $bitmap); + + $this->assertArrayHasKey('bit_or', $row); + $this->assertArrayHasKey('bit_and', $row); + + $this->assertEquals($row['bit_or'], $bitmap[$id]['bit_or']); + $this->assertEquals($row['bit_and'], $bitmap[$id]['bit_and']); + } + } + + public function testSetDefaultFetchMode() + { + $stmt = $this->_conn->query("SELECT * FROM fetch_table"); + $stmt->setFetchMode(\PDO::FETCH_NUM); + + $row = array_keys($stmt->fetch()); + $this->assertEquals(0, count( array_filter($row, function($v) { return ! is_numeric($v); })), "should be no non-numerical elements in the result."); + } + + /** + * @group DBAL-196 + */ + public function testFetchAllSupportFetchClass() + { + $this->skipOci8AndMysqli(); + + $this->_conn->executeQuery('DELETE FROM fetch_table')->execute(); + $this->_conn->insert('fetch_table', array( + 'test_int' => 1, + 'test_string' => 'foo', + 'test_datetime' => '2010-01-01 10:10:10' + )); + + $sql = "SELECT test_int, test_string, test_datetime FROM fetch_table"; + $stmt = $this->_conn->prepare($sql); + $stmt->execute(); + + $results = $stmt->fetchAll( + \PDO::FETCH_CLASS, + __NAMESPACE__.'\\MyFetchClass' + ); + + $this->assertEquals(1, count($results)); + $this->assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]); + + $this->assertEquals(1, $results[0]->test_int); + $this->assertEquals('foo', $results[0]->test_string); + $this->assertStringStartsWith('2010-01-01 10:10:10', $results[0]->test_datetime); + } + + /** + * @group DBAL-241 + */ + public function testFetchAllStyleColumn() + { + $sql = "DELETE FROM fetch_table"; + $this->_conn->executeUpdate($sql); + + $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo')); + $this->_conn->insert('fetch_table', array('test_int' => 10, 'test_string' => 'foo')); + + $sql = "SELECT test_int FROM fetch_table"; + $rows = $this->_conn->query($sql)->fetchAll(\PDO::FETCH_COLUMN); + + $this->assertEquals(array(1, 10), $rows); + } + + /** + * @group DBAL-257 + */ + public function testEmptyFetchColumnReturnsFalse() + { + $this->_conn->executeQuery('DELETE FROM fetch_table')->execute(); + $this->assertFalse($this->_conn->fetchColumn('SELECT test_int FROM fetch_table')); + $this->assertFalse($this->_conn->query('SELECT test_int FROM fetch_table')->fetchColumn()); + } + + private function skipOci8AndMysqli() + { + if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] == "oci8") { + $this->markTestSkipped("Not supported by OCI8"); + } + if ('mysqli' == $this->_conn->getDriver()->getName()) { + $this->markTestSkipped('Mysqli driver dont support this feature.'); + } + } +} + +class MyFetchClass +{ + public $test_int, $test_string, $test_datetime; +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php new file mode 100644 index 0000000..7c96813 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php @@ -0,0 +1,52 @@ +_conn->getDatabasePlatform()->getDummySelectSQL(); + + $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger'); + $logMock->expects($this->at(0)) + ->method('startQuery') + ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array())); + $logMock->expects($this->at(1)) + ->method('stopQuery'); + $this->_conn->getConfiguration()->setSQLLogger($logMock); + $this->_conn->executeQuery($sql, array()); + } + + public function testLogExecuteUpdate() + { + $this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).'); + + $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL(); + + $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger'); + $logMock->expects($this->at(0)) + ->method('startQuery') + ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array())); + $logMock->expects($this->at(1)) + ->method('stopQuery'); + $this->_conn->getConfiguration()->setSQLLogger($logMock); + $this->_conn->executeUpdate($sql, array()); + } + + public function testLogPrepareExecute() + { + $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL(); + + $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger'); + $logMock->expects($this->once()) + ->method('startQuery') + ->with($this->equalTo($sql), $this->equalTo(array())); + $logMock->expects($this->at(1)) + ->method('stopQuery'); + $this->_conn->getConfiguration()->setSQLLogger($logMock); + + $stmt = $this->_conn->prepare($sql); + $stmt->execute(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php new file mode 100644 index 0000000..6959d30 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -0,0 +1,82 @@ +_conn->getDatabasePlatform()->getName() == "sqlite") { + $this->markTestSkipped('Test does not work on sqlite.'); + } + + try { + /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ + $table = new \Doctrine\DBAL\Schema\Table("master_slave_table"); + $table->addColumn('test_int', 'integer'); + $table->setPrimaryKey(array('test_int')); + + $sm = $this->_conn->getSchemaManager(); + $sm->createTable($table); + + $this->_conn->insert('master_slave_table', array('test_int' => 1)); + } catch(\Exception $e) { + } + } + + public function createMasterSlaveConnection() + { + $params = $this->_conn->getParams(); + $params['master'] = $params; + $params['slaves'] = array($params, $params); + $params['wrapperClass'] = 'Doctrine\DBAL\Connections\MasterSlaveConnection'; + + return DriverManager::getConnection($params); + } + + public function testMasterOnConnect() + { + $conn = $this->createMasterSlaveConnection(); + + $this->assertFalse($conn->isConnectedToMaster()); + $conn->connect('slave'); + $this->assertFalse($conn->isConnectedToMaster()); + $conn->connect('master'); + $this->assertTrue($conn->isConnectedToMaster()); + } + + public function testNoMasterOnExecuteQuery() + { + $conn = $this->createMasterSlaveConnection(); + + $sql = "SELECT count(*) as num FROM master_slave_table"; + $data = $conn->fetchAll($sql); + $data[0] = array_change_key_case($data[0], CASE_LOWER); + + $this->assertEquals(1, $data[0]['num']); + $this->assertFalse($conn->isConnectedToMaster()); + } + + public function testMasterOnWriteOperation() + { + $conn = $this->createMasterSlaveConnection(); + $conn->insert('master_slave_table', array('test_int' => 30)); + + $this->assertTrue($conn->isConnectedToMaster()); + + $sql = "SELECT count(*) as num FROM master_slave_table"; + $data = $conn->fetchAll($sql); + $data[0] = array_change_key_case($data[0], CASE_LOWER); + + $this->assertEquals(2, $data[0]['num']); + $this->assertTrue($conn->isConnectedToMaster()); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php new file mode 100644 index 0000000..69ba6ac --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php @@ -0,0 +1,114 @@ +addColumn('test_int', 'integer'); + $table->setPrimaryKey(array('test_int')); + + $table2 = new \Doctrine\DBAL\Schema\Table("modify_limit_table2"); + $table2->addColumn('id', 'integer', array('autoincrement' => true)); + $table2->addColumn('test_int', 'integer'); + $table2->setPrimaryKey(array('id')); + + $sm = $this->_conn->getSchemaManager(); + $sm->createTable($table); + $sm->createTable($table2); + self::$tableCreated = true; + } + $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table')); + $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2')); + } + + public function testModifyLimitQuerySimpleQuery() + { + $this->_conn->insert('modify_limit_table', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table', array('test_int' => 2)); + $this->_conn->insert('modify_limit_table', array('test_int' => 3)); + $this->_conn->insert('modify_limit_table', array('test_int' => 4)); + + $sql = "SELECT * FROM modify_limit_table"; + + $this->assertLimitResult(array(1, 2, 3, 4), $sql, 10, 0); + $this->assertLimitResult(array(1, 2), $sql, 2, 0); + $this->assertLimitResult(array(3, 4), $sql, 2, 2); + } + + public function testModifyLimitQueryJoinQuery() + { + $this->_conn->insert('modify_limit_table', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table', array('test_int' => 2)); + + $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); + + $sql = "SELECT modify_limit_table.test_int FROM modify_limit_table INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int"; + + $this->assertLimitResult(array(1, 1, 1, 2, 2), $sql, 10, 0); + $this->assertLimitResult(array(1, 1, 1), $sql, 3, 0); + $this->assertLimitResult(array(2, 2), $sql, 2, 3); + } + + public function testModifyLimitQueryOrderBy() + { + $this->_conn->insert('modify_limit_table', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table', array('test_int' => 2)); + $this->_conn->insert('modify_limit_table', array('test_int' => 3)); + $this->_conn->insert('modify_limit_table', array('test_int' => 4)); + + $sql = "SELECT * FROM modify_limit_table ORDER BY test_int DESC"; + + $this->assertLimitResult(array(4, 3, 2, 1), $sql, 10, 0); + $this->assertLimitResult(array(4, 3), $sql, 2, 0); + $this->assertLimitResult(array(2, 1), $sql, 2, 2); + } + + public function testModifyLimitQueryGroupBy() + { + $this->_conn->insert('modify_limit_table', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table', array('test_int' => 2)); + + $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 1)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); + $this->_conn->insert('modify_limit_table2', array('test_int' => 2)); + + $sql = "SELECT modify_limit_table.test_int FROM modify_limit_table " . + "INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ". + "GROUP BY modify_limit_table.test_int"; + $this->assertLimitResult(array(1, 2), $sql, 10, 0); + $this->assertLimitResult(array(1), $sql, 1, 0); + $this->assertLimitResult(array(2), $sql, 1, 1); + } + + public function assertLimitResult($expectedResults, $sql, $limit, $offset) + { + $p = $this->_conn->getDatabasePlatform(); + $data = array(); + foreach ($this->_conn->fetchAll($p->modifyLimitQuery($sql, $limit, $offset)) AS $row) { + $row = array_change_key_case($row, CASE_LOWER); + $data[] = $row['test_int']; + } + $this->assertEquals($expectedResults, $data); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php new file mode 100644 index 0000000..6f9e513 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php @@ -0,0 +1,166 @@ +1,'bar'=> array(1, 2, 3)), + array('foo'=>PDO::PARAM_INT,'bar'=> Connection::PARAM_INT_ARRAY,), + array( + array('id'=>1,'foo'=>1,'bar'=>1), + array('id'=>2,'foo'=>1,'bar'=>2), + array('id'=>3,'foo'=>1,'bar'=>3), + ) + ), + + array( + 'SELECT * FROM ddc1372_foobar f WHERE f.foo = :foo AND f.bar IN (:bar)', + array('foo'=>1,'bar'=> array(1, 2, 3)), + array('bar'=> Connection::PARAM_INT_ARRAY,'foo'=>PDO::PARAM_INT), + array( + array('id'=>1,'foo'=>1,'bar'=>1), + array('id'=>2,'foo'=>1,'bar'=>2), + array('id'=>3,'foo'=>1,'bar'=>3), + ) + ), + + array( + 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo = :foo', + array('foo'=>1,'bar'=> array(1, 2, 3)), + array('bar'=> Connection::PARAM_INT_ARRAY,'foo'=>PDO::PARAM_INT), + array( + array('id'=>1,'foo'=>1,'bar'=>1), + array('id'=>2,'foo'=>1,'bar'=>2), + array('id'=>3,'foo'=>1,'bar'=>3), + ) + ), + + array( + 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo = :foo', + array('foo'=>1,'bar'=> array('1', '2', '3')), + array('bar'=> Connection::PARAM_STR_ARRAY,'foo'=>PDO::PARAM_INT), + array( + array('id'=>1,'foo'=>1,'bar'=>1), + array('id'=>2,'foo'=>1,'bar'=>2), + array('id'=>3,'foo'=>1,'bar'=>3), + ) + ), + + array( + 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo IN (:foo)', + array('foo'=>array('1'),'bar'=> array(1, 2, 3,4)), + array('bar'=> Connection::PARAM_STR_ARRAY,'foo'=>Connection::PARAM_INT_ARRAY), + array( + array('id'=>1,'foo'=>1,'bar'=>1), + array('id'=>2,'foo'=>1,'bar'=>2), + array('id'=>3,'foo'=>1,'bar'=>3), + array('id'=>4,'foo'=>1,'bar'=>4), + ) + ), + + array( + 'SELECT * FROM ddc1372_foobar f WHERE f.bar IN (:bar) AND f.foo IN (:foo)', + array('foo'=>1,'bar'=> 2), + array('bar'=>PDO::PARAM_INT,'foo'=>PDO::PARAM_INT), + array( + array('id'=>2,'foo'=>1,'bar'=>2), + ) + ), + + array( + 'SELECT * FROM ddc1372_foobar f WHERE f.bar = :arg AND f.foo <> :arg', + array('arg'=>'1'), + array('arg'=>PDO::PARAM_STR), + array( + array('id'=>5,'foo'=>2,'bar'=>1), + ) + ), + + array( + 'SELECT * FROM ddc1372_foobar f WHERE f.bar NOT IN (:arg) AND f.foo IN (:arg)', + array('arg'=>array(1, 2)), + array('arg'=>Connection::PARAM_INT_ARRAY), + array( + array('id'=>3,'foo'=>1,'bar'=>3), + array('id'=>4,'foo'=>1,'bar'=>4), + ) + ), + + ); + } + + public function setUp() + { + parent::setUp(); + + if (!$this->_conn->getSchemaManager()->tablesExist("ddc1372_foobar")) { + try { + $table = new \Doctrine\DBAL\Schema\Table("ddc1372_foobar"); + $table->addColumn('id', 'integer'); + $table->addColumn('foo','string'); + $table->addColumn('bar','string'); + $table->setPrimaryKey(array('id')); + + + $sm = $this->_conn->getSchemaManager(); + $sm->createTable($table); + + $this->_conn->insert('ddc1372_foobar', array( + 'id' => 1, 'foo' => 1, 'bar' => 1 + )); + $this->_conn->insert('ddc1372_foobar', array( + 'id' => 2, 'foo' => 1, 'bar' => 2 + )); + $this->_conn->insert('ddc1372_foobar', array( + 'id' => 3, 'foo' => 1, 'bar' => 3 + )); + $this->_conn->insert('ddc1372_foobar', array( + 'id' => 4, 'foo' => 1, 'bar' => 4 + )); + $this->_conn->insert('ddc1372_foobar', array( + 'id' => 5, 'foo' => 2, 'bar' => 1 + )); + $this->_conn->insert('ddc1372_foobar', array( + 'id' => 6, 'foo' => 2, 'bar' => 2 + )); + } catch(\Exception $e) { + $this->fail($e->getMessage()); + } + } + } + + /** + * @dataProvider ticketProvider + * @param string $query + * @param array $params + * @param array $types + * @param array $expected + */ + public function testTicket($query,$params,$types,$expected) + { + $stmt = $this->_conn->executeQuery($query, $params, $types); + $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); + + foreach ($result as $k => $v) { + $result[$k] = array_change_key_case($v, CASE_LOWER); + } + + $this->assertEquals($result, $expected); + } + +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php new file mode 100644 index 0000000..acf995b --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php @@ -0,0 +1,97 @@ +portableConnection) { + $this->portableConnection->close(); + } + } + + private function getPortableConnection($portabilityMode = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL, $case = \PDO::CASE_LOWER) + { + if (!$this->portableConnection) { + $params = $this->_conn->getParams(); + $params['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection'; + $params['portability'] = $portabilityMode; + $params['fetch_case'] = $case; + $this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager()); + + try { + /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ + $table = new \Doctrine\DBAL\Schema\Table("portability_table"); + $table->addColumn('Test_Int', 'integer'); + $table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32)); + $table->addColumn('Test_Null', 'string', array('notnull' => false)); + $table->setPrimaryKey(array('Test_Int')); + + $sm = $this->portableConnection->getSchemaManager(); + $sm->createTable($table); + + $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => '')); + $this->portableConnection->insert('portability_table', array('Test_Int' => 2, 'Test_String' => 'foo ', 'Test_Null' => null)); + } catch(\Exception $e) { + + } + } + + return $this->portableConnection; + } + + public function testFullFetchMode() + { + $rows = $this->getPortableConnection()->fetchAll('SELECT * FROM portability_table'); + $this->assertFetchResultRows($rows); + + $stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table'); + $stmt->setFetchMode(\PDO::FETCH_ASSOC); + foreach ($stmt as $row) { + $this->assertFetchResultRow($row); + } + + $stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table'); + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + $this->assertFetchResultRow($row); + } + + $stmt = $this->getPortableConnection()->prepare('SELECT * FROM portability_table'); + $stmt->execute(); + + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + $this->assertFetchResultRow($row); + } + } + + public function assertFetchResultRows($rows) + { + $this->assertEquals(2, count($rows)); + foreach ($rows AS $row) { + $this->assertFetchResultRow($row); + } + } + + public function assertFetchResultRow($row) + { + $this->assertTrue(in_array($row['test_int'], array(1, 2)), "Primary key test_int should either be 1 or 2."); + $this->assertArrayHasKey('test_string', $row, "Case should be lowered."); + $this->assertEquals(3, strlen($row['test_string']), "test_string should be rtrimed to length of three for CHAR(32) column."); + $this->assertNull($row['test_null']); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php new file mode 100644 index 0000000..5e678a7 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -0,0 +1,199 @@ + 100, 'test_string' => 'foo'), array('test_int' => 200, 'test_string' => 'bar'), array('test_int' => 300, 'test_string' => 'baz')); + private $sqlLogger; + + public function setUp() + { + parent::setUp(); + + try { + /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ + $table = new \Doctrine\DBAL\Schema\Table("caching"); + $table->addColumn('test_int', 'integer'); + $table->addColumn('test_string', 'string', array('notnull' => false)); + $table->setPrimaryKey(array('test_int')); + + $sm = $this->_conn->getSchemaManager(); + $sm->createTable($table); + } catch(\Exception $e) { + + } + $this->_conn->executeUpdate('DELETE FROM caching'); + foreach ($this->expectedResult AS $row) { + $this->_conn->insert('caching', $row); + } + + $config = $this->_conn->getConfiguration(); + $config->setSQLLogger($this->sqlLogger = new \Doctrine\DBAL\Logging\DebugStack); + + $cache = new \Doctrine\Common\Cache\ArrayCache; + $config->setResultCacheImpl($cache); + } + + public function testCacheFetchAssoc() + { + $this->assertCacheNonCacheSelectSameFetchModeAreEqual($this->expectedResult, \PDO::FETCH_ASSOC); + } + + public function testFetchNum() + { + $expectedResult = array(); + foreach ($this->expectedResult AS $v) { + $expectedResult[] = array_values($v); + } + $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, \PDO::FETCH_NUM); + } + + public function testFetchBoth() + { + $expectedResult = array(); + foreach ($this->expectedResult AS $v) { + $expectedResult[] = array_merge($v, array_values($v)); + } + $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, \PDO::FETCH_BOTH); + } + + public function testMixingFetch() + { + $numExpectedResult = array(); + foreach ($this->expectedResult AS $v) { + $numExpectedResult[] = array_values($v); + } + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $data = $this->hydrateStmt($stmt, \PDO::FETCH_ASSOC); + + $this->assertEquals($this->expectedResult, $data); + + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM); + + $this->assertEquals($numExpectedResult, $data); + } + + public function testIteratorFetch() + { + $this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_BOTH); + $this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_ASSOC); + $this->assertStandardAndIteratorFetchAreEqual(\PDO::FETCH_NUM); + } + + public function assertStandardAndIteratorFetchAreEqual($fetchStyle) + { + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + $data = $this->hydrateStmt($stmt, $fetchStyle); + + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + $data_iterator = $this->hydrateStmtIterator($stmt, $fetchStyle); + + $this->assertEquals($data, $data_iterator); + } + + public function testDontCloseNoCache() + { + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $data = array(); + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + $data[] = $row; + } + + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $data = array(); + while ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $data[] = $row; + } + + $this->assertEquals(2, count($this->sqlLogger->queries)); + } + + public function testDontFinishNoCache() + { + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $data = $this->hydrateStmt($stmt, \PDO::FETCH_NUM); + + $this->assertEquals(2, count($this->sqlLogger->queries)); + } + + public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchStyle) + { + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $this->assertEquals(2, $stmt->columnCount()); + $data = $this->hydrateStmt($stmt, $fetchStyle); + $this->assertEquals($expectedResult, $data); + + $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey")); + + $this->assertEquals(2, $stmt->columnCount()); + $data = $this->hydrateStmt($stmt, $fetchStyle); + $this->assertEquals($expectedResult, $data); + $this->assertEquals(1, count($this->sqlLogger->queries), "just one dbal hit"); + } + + public function testEmptyResultCache() + { + $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey")); + $data = $this->hydrateStmt($stmt); + + $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey")); + $data = $this->hydrateStmt($stmt); + + $this->assertEquals(1, count($this->sqlLogger->queries), "just one dbal hit"); + } + + public function testChangeCacheImpl() + { + $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey")); + $data = $this->hydrateStmt($stmt); + + $secondCache = new \Doctrine\Common\Cache\ArrayCache; + $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey", $secondCache)); + $data = $this->hydrateStmt($stmt); + + $this->assertEquals(2, count($this->sqlLogger->queries), "two hits"); + $this->assertEquals(1, count($secondCache->fetch("emptycachekey"))); + } + + private function hydrateStmt($stmt, $fetchStyle = \PDO::FETCH_ASSOC) + { + $data = array(); + while ($row = $stmt->fetch($fetchStyle)) { + $data[] = array_change_key_case($row, CASE_LOWER); + } + $stmt->closeCursor(); + return $data; + } + + private function hydrateStmtIterator($stmt, $fetchStyle = \PDO::FETCH_ASSOC) + { + $data = array(); + $stmt->setFetchMode($fetchStyle); + foreach ($stmt as $row) { + $data[] = array_change_key_case($row, CASE_LOWER); + } + $stmt->closeCursor(); + return $data; + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php new file mode 100644 index 0000000..a567900 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php @@ -0,0 +1,12 @@ +addColumn('foo_id', 'integer'); + $tableOld->addColumn('bar_id', 'integer'); + $tableNew = clone $tableOld; + + $this->_sm->createTable($tableOld); + $tableFetched = $this->_sm->listTableDetails("switch_primary_key_columns"); + $tableNew = clone $tableFetched; + $tableNew->setPrimaryKey(array('bar_id', 'foo_id')); + + $comparator = new \Doctrine\DBAL\Schema\Comparator; + $this->_sm->alterTable($comparator->diffTable($tableFetched, $tableNew)); + } + + public function testDiffTableBug() + { + $schema = new Schema(); + $table = $schema->createTable('diffbug_routing_translations'); + $table->addColumn('id', 'integer'); + $table->addColumn('route', 'string'); + $table->addColumn('locale', 'string'); + $table->addColumn('attribute', 'string'); + $table->addColumn('localized_value', 'string'); + $table->addColumn('original_value', 'string'); + $table->setPrimaryKey(array('id')); + $table->addUniqueIndex(array('route', 'locale', 'attribute')); + $table->addIndex(array('localized_value')); // this is much more selective than the unique index + + $this->_sm->createTable($table); + $tableFetched = $this->_sm->listTableDetails("diffbug_routing_translations"); + + $comparator = new \Doctrine\DBAL\Schema\Comparator; + $diff = $comparator->diffTable($tableFetched, $table); + + $this->assertFalse($diff, "no changes expected."); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php new file mode 100644 index 0000000..231b542 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php @@ -0,0 +1,39 @@ +markTestSkipped('Foo'); + } + + $username = $GLOBALS['db_username']; + + $query = "GRANT ALL PRIVILEGES TO ".$username; + + $conn = \Doctrine\Tests\TestUtil::getTempConnection(); + $conn->executeUpdate($query); + } + + public function testRenameTable() + { + $this->_sm->tryMethod('DropTable', 'list_tables_test'); + $this->_sm->tryMethod('DropTable', 'list_tables_test_new_name'); + + $this->createTestTable('list_tables_test'); + $this->_sm->renameTable('list_tables_test', 'list_tables_test_new_name'); + + $tables = $this->_sm->listTables(); + + $this->assertHasTable($tables, 'list_tables_test_new_name'); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php new file mode 100644 index 0000000..61d799f --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -0,0 +1,228 @@ +_conn) { + return; + } + + $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression(null); + } + + /** + * @group DBAL-177 + */ + public function testGetSearchPath() + { + $params = $this->_conn->getParams(); + + $paths = $this->_sm->getSchemaSearchPaths(); + $this->assertEquals(array($params['user'], 'public'), $paths); + } + + /** + * @group DBAL-244 + */ + public function testGetSchemaNames() + { + $names = $this->_sm->getSchemaNames(); + + $this->assertInternalType('array', $names); + $this->assertTrue(count($names) > 0); + $this->assertTrue(in_array('public', $names), "The public schema should be found."); + } + + /** + * @group DBAL-21 + */ + public function testSupportDomainTypeFallback() + { + $createDomainTypeSQL = "CREATE DOMAIN MyMoney AS DECIMAL(18,2)"; + $this->_conn->exec($createDomainTypeSQL); + + $createTableSQL = "CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)"; + $this->_conn->exec($createTableSQL); + + $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test'); + $this->assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $table->getColumn('value')->getType()); + + Type::addType('MyMoney', 'Doctrine\Tests\DBAL\Functional\Schema\MoneyType'); + $this->_conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'MyMoney'); + + $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test'); + $this->assertInstanceOf('Doctrine\Tests\DBAL\Functional\Schema\MoneyType', $table->getColumn('value')->getType()); + } + + /** + * @group DBAL-37 + */ + public function testDetectsAutoIncrement() + { + $autoincTable = new \Doctrine\DBAL\Schema\Table('autoinc_table'); + $column = $autoincTable->addColumn('id', 'integer'); + $column->setAutoincrement(true); + $this->_sm->createTable($autoincTable); + $autoincTable = $this->_sm->listTableDetails('autoinc_table'); + + $this->assertTrue($autoincTable->getColumn('id')->getAutoincrement()); + } + + /** + * @group DBAL-37 + */ + public function testAlterTableAutoIncrementAdd() + { + $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_add'); + $column = $tableFrom->addColumn('id', 'integer'); + $this->_sm->createTable($tableFrom); + $tableFrom = $this->_sm->listTableDetails('autoinc_table_add'); + $this->assertFalse($tableFrom->getColumn('id')->getAutoincrement()); + + $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_add'); + $column = $tableTo->addColumn('id', 'integer'); + $column->setAutoincrement(true); + + $c = new \Doctrine\DBAL\Schema\Comparator(); + $diff = $c->diffTable($tableFrom, $tableTo); + $sql = $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff); + $this->assertEquals(array( + "CREATE SEQUENCE autoinc_table_add_id_seq", + "SELECT setval('autoinc_table_add_id_seq', (SELECT MAX(id) FROM autoinc_table_add))", + "ALTER TABLE autoinc_table_add ALTER id SET DEFAULT nextval('autoinc_table_add_id_seq')", + ), $sql); + + $this->_sm->alterTable($diff); + $tableFinal = $this->_sm->listTableDetails('autoinc_table_add'); + $this->assertTrue($tableFinal->getColumn('id')->getAutoincrement()); + } + + /** + * @group DBAL-37 + */ + public function testAlterTableAutoIncrementDrop() + { + $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop'); + $column = $tableFrom->addColumn('id', 'integer'); + $column->setAutoincrement(true); + $this->_sm->createTable($tableFrom); + $tableFrom = $this->_sm->listTableDetails('autoinc_table_drop'); + $this->assertTrue($tableFrom->getColumn('id')->getAutoincrement()); + + $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop'); + $column = $tableTo->addColumn('id', 'integer'); + + $c = new \Doctrine\DBAL\Schema\Comparator(); + $diff = $c->diffTable($tableFrom, $tableTo); + $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $diff, "There should be a difference and not false being returned from the table comparison"); + $this->assertEquals(array("ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT"), $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff)); + + $this->_sm->alterTable($diff); + $tableFinal = $this->_sm->listTableDetails('autoinc_table_drop'); + $this->assertFalse($tableFinal->getColumn('id')->getAutoincrement()); + } + + /** + * @group DBAL-75 + */ + public function testTableWithSchema() + { + $this->_conn->exec('CREATE SCHEMA nested'); + + $nestedRelatedTable = new \Doctrine\DBAL\Schema\Table('nested.schemarelated'); + $column = $nestedRelatedTable->addColumn('id', 'integer'); + $column->setAutoincrement(true); + $nestedRelatedTable->setPrimaryKey(array('id')); + + $nestedSchemaTable = new \Doctrine\DBAL\Schema\Table('nested.schematable'); + $column = $nestedSchemaTable->addColumn('id', 'integer'); + $column->setAutoincrement(true); + $nestedSchemaTable->setPrimaryKey(array('id')); + $nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, array('id'), array('id')); + + $this->_sm->createTable($nestedRelatedTable); + $this->_sm->createTable($nestedSchemaTable); + + $tables = $this->_sm->listTableNames(); + $this->assertContains('nested.schematable', $tables, "The table should be detected with its non-public schema."); + + $nestedSchemaTable = $this->_sm->listTableDetails('nested.schematable'); + $this->assertTrue($nestedSchemaTable->hasColumn('id')); + $this->assertEquals(array('id'), $nestedSchemaTable->getPrimaryKey()->getColumns()); + + $relatedFks = $nestedSchemaTable->getForeignKeys(); + $this->assertEquals(1, count($relatedFks)); + $relatedFk = array_pop($relatedFks); + $this->assertEquals("nested.schemarelated", $relatedFk->getForeignTableName()); + } + + /** + * @group DBAL-91 + * @group DBAL-88 + */ + public function testReturnQuotedAssets() + { + $sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );'; + $this->_conn->exec($sql); + + $sql = 'ALTER TABLE dbal91_something ADD CONSTRAINT something_input FOREIGN KEY( "table" ) REFERENCES dbal91_something ON UPDATE CASCADE;'; + $this->_conn->exec($sql); + + $table = $this->_sm->listTableDetails('dbal91_something'); + + $this->assertEquals( + array( + "CREATE TABLE dbal91_something (id INT NOT NULL, \"table\" INT DEFAULT NULL, PRIMARY KEY(id))", + "CREATE INDEX IDX_A9401304ECA7352B ON dbal91_something (\"table\")", + ), + $this->_conn->getDatabasePlatform()->getCreateTableSQL($table) + ); + } + + /** + * @group DBAL-204 + */ + public function testFilterSchemaExpression() + { + $testTable = new \Doctrine\DBAL\Schema\Table('dbal204_test_prefix'); + $column = $testTable->addColumn('id', 'integer'); + $this->_sm->createTable($testTable); + $testTable = new \Doctrine\DBAL\Schema\Table('dbal204_without_prefix'); + $column = $testTable->addColumn('id', 'integer'); + $this->_sm->createTable($testTable); + + $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression('^dbal204_'); + $names = $this->_sm->listTableNames(); + $this->assertEquals(2, count($names)); + + $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression('^dbal204_test'); + $names = $this->_sm->listTableNames(); + $this->assertEquals(1, count($names)); + } +} + +class MoneyType extends Type +{ + + public function getName() + { + return "MyMoney"; + } + + public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + { + return 'MyMoney'; + } + +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php new file mode 100644 index 0000000..b6372b4 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php @@ -0,0 +1,37 @@ +addColumn('id', 'integer'); + $table->addColumn('todrop', 'decimal', array('default' => 10.2)); + + $this->_sm->createTable($table); + + $diff = new TableDiff('sqlsrv_drop_column', array(), array(), array( + new Column('todrop', Type::getType('decimal')) + )); + $this->_sm->alterTable($diff); + + $columns = $this->_sm->listTableColumns('sqlsrv_drop_column'); + $this->assertEquals(1, count($columns)); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php new file mode 100644 index 0000000..ac9fa8e --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -0,0 +1,642 @@ +getPlatformName(); + + if ($this->_conn->getDatabasePlatform()->getName() !== $dbms) { + $this->markTestSkipped(get_class($this) . ' requires the use of ' . $dbms); + } + + $this->_sm = $this->_conn->getSchemaManager(); + } + + /** + * @group DBAL-195 + */ + public function testDropAndCreateSequence() + { + if(!$this->_conn->getDatabasePlatform()->supportsSequences()) { + $this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.'); + } + + $sequence = new \Doctrine\DBAL\Schema\Sequence('dropcreate_sequences_test_seq', 20, 10); + $this->_sm->dropAndCreateSequence($sequence); + } + + public function testListSequences() + { + if(!$this->_conn->getDatabasePlatform()->supportsSequences()) { + $this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.'); + } + + $sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10); + $this->_sm->createSequence($sequence); + + $sequences = $this->_sm->listSequences(); + + $this->assertInternalType('array', $sequences, 'listSequences() should return an array.'); + + $foundSequence = null; + foreach($sequences AS $sequence) { + $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $sequence, 'Array elements of listSequences() should be Sequence instances.'); + if(strtolower($sequence->getName()) == 'list_sequences_test_seq') { + $foundSequence = $sequence; + } + } + + $this->assertNotNull($foundSequence, "Sequence with name 'list_sequences_test_seq' was not found."); + $this->assertEquals(20, $foundSequence->getAllocationSize(), "Allocation Size is expected to be 20."); + $this->assertEquals(10, $foundSequence->getInitialValue(), "Initial Value is expected to be 10."); + } + + public function testListDatabases() + { + if (!$this->_sm->getDatabasePlatform()->supportsCreateDropDatabase()) { + $this->markTestSkipped('Cannot drop Database client side with this Driver.'); + } + + $this->_sm->dropAndCreateDatabase('test_create_database'); + $databases = $this->_sm->listDatabases(); + + $databases = \array_map('strtolower', $databases); + + $this->assertEquals(true, \in_array('test_create_database', $databases)); + } + + public function testListTables() + { + $this->createTestTable('list_tables_test'); + $tables = $this->_sm->listTables(); + + $this->assertInternalType('array', $tables); + $this->assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'."); + + $foundTable = false; + foreach ($tables AS $table) { + $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table); + if (strtolower($table->getName()) == 'list_tables_test') { + $foundTable = true; + + $this->assertTrue($table->hasColumn('id')); + $this->assertTrue($table->hasColumn('test')); + $this->assertTrue($table->hasColumn('foreign_key_test')); + } + } + + $this->assertTrue( $foundTable , "The 'list_tables_test' table has to be found."); + } + + public function createListTableColumns() + { + $table = new \Doctrine\DBAL\Schema\Table('list_table_columns'); + $table->addColumn('id', 'integer', array('notnull' => true)); + $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false, 'default' => 'expected default')); + $table->addColumn('foo', 'text', array('notnull' => true)); + $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false)); + $table->addColumn('baz1', 'datetime'); + $table->addColumn('baz2', 'time'); + $table->addColumn('baz3', 'date'); + + return $table; + } + + public function testListTableColumns() + { + $table = $this->createListTableColumns(); + + $this->_sm->dropAndCreateTable($table); + + $columns = $this->_sm->listTableColumns('list_table_columns'); + + $this->assertArrayHasKey('id', $columns); + $this->assertEquals('id', strtolower($columns['id']->getname())); + $this->assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype()); + $this->assertEquals(false, $columns['id']->getunsigned()); + $this->assertEquals(true, $columns['id']->getnotnull()); + $this->assertEquals(null, $columns['id']->getdefault()); + $this->assertInternalType('array', $columns['id']->getPlatformOptions()); + + $this->assertArrayHasKey('test', $columns); + $this->assertEquals('test', strtolower($columns['test']->getname())); + $this->assertInstanceOf('Doctrine\DBAL\Types\StringType', $columns['test']->gettype()); + $this->assertEquals(255, $columns['test']->getlength()); + $this->assertEquals(false, $columns['test']->getfixed()); + $this->assertEquals(false, $columns['test']->getnotnull()); + $this->assertEquals('expected default', $columns['test']->getdefault()); + $this->assertInternalType('array', $columns['test']->getPlatformOptions()); + + $this->assertEquals('foo', strtolower($columns['foo']->getname())); + $this->assertInstanceOf('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype()); + $this->assertEquals(false, $columns['foo']->getunsigned()); + $this->assertEquals(false, $columns['foo']->getfixed()); + $this->assertEquals(true, $columns['foo']->getnotnull()); + $this->assertEquals(null, $columns['foo']->getdefault()); + $this->assertInternalType('array', $columns['foo']->getPlatformOptions()); + + $this->assertEquals('bar', strtolower($columns['bar']->getname())); + $this->assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype()); + $this->assertEquals(null, $columns['bar']->getlength()); + $this->assertEquals(10, $columns['bar']->getprecision()); + $this->assertEquals(4, $columns['bar']->getscale()); + $this->assertEquals(false, $columns['bar']->getunsigned()); + $this->assertEquals(false, $columns['bar']->getfixed()); + $this->assertEquals(false, $columns['bar']->getnotnull()); + $this->assertEquals(null, $columns['bar']->getdefault()); + $this->assertInternalType('array', $columns['bar']->getPlatformOptions()); + + $this->assertEquals('baz1', strtolower($columns['baz1']->getname())); + $this->assertInstanceOf('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype()); + $this->assertEquals(true, $columns['baz1']->getnotnull()); + $this->assertEquals(null, $columns['baz1']->getdefault()); + $this->assertInternalType('array', $columns['baz1']->getPlatformOptions()); + + $this->assertEquals('baz2', strtolower($columns['baz2']->getname())); + $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); + $this->assertEquals(true, $columns['baz2']->getnotnull()); + $this->assertEquals(null, $columns['baz2']->getdefault()); + $this->assertInternalType('array', $columns['baz2']->getPlatformOptions()); + + $this->assertEquals('baz3', strtolower($columns['baz3']->getname())); + $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); + $this->assertEquals(true, $columns['baz3']->getnotnull()); + $this->assertEquals(null, $columns['baz3']->getdefault()); + $this->assertInternalType('array', $columns['baz3']->getPlatformOptions()); + } + + public function testListTableColumnsDispatchEvent() + { + $table = $this->createListTableColumns(); + + $this->_sm->dropAndCreateTable($table); + + $listenerMock = $this->getMock('ListTableColumnsDispatchEventListener', array('onSchemaColumnDefinition')); + $listenerMock + ->expects($this->exactly(7)) + ->method('onSchemaColumnDefinition'); + + $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager(); + + $eventManager = new EventManager(); + $eventManager->addEventListener(array(Events::onSchemaColumnDefinition), $listenerMock); + + $this->_sm->getDatabasePlatform()->setEventManager($eventManager); + + $this->_sm->listTableColumns('list_table_columns'); + + $this->_sm->getDatabasePlatform()->setEventManager($oldEventManager); + } + + public function testListTableIndexesDispatchEvent() + { + $table = $this->getTestTable('list_table_indexes_test'); + $table->addUniqueIndex(array('test'), 'test_index_name'); + $table->addIndex(array('id', 'test'), 'test_composite_idx'); + + $this->_sm->dropAndCreateTable($table); + + $listenerMock = $this->getMock('ListTableIndexesDispatchEventListener', array('onSchemaIndexDefinition')); + $listenerMock + ->expects($this->exactly(3)) + ->method('onSchemaIndexDefinition'); + + $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager(); + + $eventManager = new EventManager(); + $eventManager->addEventListener(array(Events::onSchemaIndexDefinition), $listenerMock); + + $this->_sm->getDatabasePlatform()->setEventManager($eventManager); + + $this->_sm->listTableIndexes('list_table_indexes_test'); + + $this->_sm->getDatabasePlatform()->setEventManager($oldEventManager); + } + + public function testDiffListTableColumns() + { + if ($this->_sm->getDatabasePlatform()->getName() == 'oracle') { + $this->markTestSkipped('Does not work with Oracle, since it cannot detect DateTime, Date and Time differenecs (at the moment).'); + } + + $offlineTable = $this->createListTableColumns(); + $onlineTable = $this->_sm->listTableDetails('list_table_columns'); + + $comparator = new \Doctrine\DBAL\Schema\Comparator(); + $diff = $comparator->diffTable($offlineTable, $onlineTable); + + $this->assertFalse($diff, "No differences should be detected with the offline vs online schema."); + } + + public function testListTableIndexes() + { + $table = $this->getTestCompositeTable('list_table_indexes_test'); + $table->addUniqueIndex(array('test'), 'test_index_name'); + $table->addIndex(array('id', 'test'), 'test_composite_idx'); + + $this->_sm->dropAndCreateTable($table); + + $tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_test'); + + $this->assertEquals(3, count($tableIndexes)); + + $this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.'); + $this->assertEquals(array('id', 'other_id'), array_map('strtolower', $tableIndexes['primary']->getColumns())); + $this->assertTrue($tableIndexes['primary']->isUnique()); + $this->assertTrue($tableIndexes['primary']->isPrimary()); + + $this->assertEquals('test_index_name', $tableIndexes['test_index_name']->getName()); + $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test_index_name']->getColumns())); + $this->assertTrue($tableIndexes['test_index_name']->isUnique()); + $this->assertFalse($tableIndexes['test_index_name']->isPrimary()); + + $this->assertEquals('test_composite_idx', $tableIndexes['test_composite_idx']->getName()); + $this->assertEquals(array('id', 'test'), array_map('strtolower', $tableIndexes['test_composite_idx']->getColumns())); + $this->assertFalse($tableIndexes['test_composite_idx']->isUnique()); + $this->assertFalse($tableIndexes['test_composite_idx']->isPrimary()); + } + + public function testDropAndCreateIndex() + { + $table = $this->getTestTable('test_create_index'); + $table->addUniqueIndex(array('test'), 'test'); + $this->_sm->dropAndCreateTable($table); + + $this->_sm->dropAndCreateIndex($table->getIndex('test'), $table); + $tableIndexes = $this->_sm->listTableIndexes('test_create_index'); + $this->assertInternalType('array', $tableIndexes); + + $this->assertEquals('test', strtolower($tableIndexes['test']->getName())); + $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns())); + $this->assertTrue($tableIndexes['test']->isUnique()); + $this->assertFalse($tableIndexes['test']->isPrimary()); + } + + public function testCreateTableWithForeignKeys() + { + if(!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped('Platform does not support foreign keys.'); + } + + $tableB = $this->getTestTable('test_foreign'); + + $this->_sm->dropAndCreateTable($tableB); + + $tableA = $this->getTestTable('test_create_fk'); + $tableA->addForeignKeyConstraint('test_foreign', array('foreign_key_test'), array('id')); + + $this->_sm->dropAndCreateTable($tableA); + + $fkTable = $this->_sm->listTableDetails('test_create_fk'); + $fkConstraints = $fkTable->getForeignKeys(); + $this->assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key."); + + $fkConstraint = current($fkConstraints); + $this->assertInstanceOf('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint); + $this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName())); + $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns())); + $this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns())); + + $this->assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), "The columns of a foreign key constraint should always be indexed."); + } + + public function testListForeignKeys() + { + if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped('Does not support foreign key constraints.'); + } + + $this->createTestTable('test_create_fk1'); + $this->createTestTable('test_create_fk2'); + + $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint( + array('foreign_key_test'), 'test_create_fk2', array('id'), 'foreign_key_test_fk', array('onDelete' => 'CASCADE') + ); + + $this->_sm->createForeignKey($foreignKey, 'test_create_fk1'); + + $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1'); + + $this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key."); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); + $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); + $this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); + $this->assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName())); + + if($fkeys[0]->hasOption('onDelete')) { + $this->assertEquals('CASCADE', $fkeys[0]->getOption('onDelete')); + } + } + + protected function getCreateExampleViewSql() + { + $this->markTestSkipped('No Create Example View SQL was defined for this SchemaManager'); + } + + public function testCreateSchema() + { + $this->createTestTable('test_table'); + + $schema = $this->_sm->createSchema(); + $this->assertTrue($schema->hasTable('test_table')); + } + + public function testAlterTableScenario() + { + if(!$this->_sm->getDatabasePlatform()->supportsAlterTable()) { + $this->markTestSkipped('Alter Table is not supported by this platform.'); + } + + $this->createTestTable('alter_table'); + $this->createTestTable('alter_table_foreign'); + + $table = $this->_sm->listTableDetails('alter_table'); + $this->assertTrue($table->hasColumn('id')); + $this->assertTrue($table->hasColumn('test')); + $this->assertTrue($table->hasColumn('foreign_key_test')); + $this->assertEquals(0, count($table->getForeignKeys())); + $this->assertEquals(1, count($table->getIndexes())); + + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); + $tableDiff->addedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', Type::getType('integer')); + $tableDiff->removedColumns['test'] = $table->getColumn('test'); + + $this->_sm->alterTable($tableDiff); + + $table = $this->_sm->listTableDetails('alter_table'); + $this->assertFalse($table->hasColumn('test')); + $this->assertTrue($table->hasColumn('foo')); + + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); + $tableDiff->addedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo')); + + $this->_sm->alterTable($tableDiff); + + $table = $this->_sm->listTableDetails('alter_table'); + $this->assertEquals(2, count($table->getIndexes())); + $this->assertTrue($table->hasIndex('foo_idx')); + $this->assertEquals(array('foo'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); + $this->assertFalse($table->getIndex('foo_idx')->isPrimary()); + $this->assertFalse($table->getIndex('foo_idx')->isUnique()); + + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); + $tableDiff->changedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test')); + + $this->_sm->alterTable($tableDiff); + + $table = $this->_sm->listTableDetails('alter_table'); + $this->assertEquals(2, count($table->getIndexes())); + $this->assertTrue($table->hasIndex('foo_idx')); + $this->assertEquals(array('foo', 'foreign_key_test'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); + + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table"); + $tableDiff->removedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test')); + $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('foreign_key_test'), 'alter_table_foreign', array('id')); + $tableDiff->addedForeignKeys[] = $fk; + + $this->_sm->alterTable($tableDiff); + $table = $this->_sm->listTableDetails('alter_table'); + + // dont check for index size here, some platforms automatically add indexes for foreign keys. + $this->assertFalse($table->hasIndex('foo_idx')); + + $this->assertEquals(1, count($table->getForeignKeys())); + $fks = $table->getForeignKeys(); + $foreignKey = current($fks); + $this->assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName())); + $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $foreignKey->getColumns())); + $this->assertEquals(array('id'), array_map('strtolower', $foreignKey->getForeignColumns())); + } + + public function testCreateAndListViews() + { + $this->createTestTable('view_test_table'); + + $name = "doctrine_test_view"; + $sql = "SELECT * FROM view_test_table"; + + $view = new \Doctrine\DBAL\Schema\View($name, $sql); + + $this->_sm->dropAndCreateView($view); + + $views = $this->_sm->listViews(); + } + + public function testAutoincrementDetection() + { + if (!$this->_sm->getDatabasePlatform()->supportsIdentityColumns()) { + $this->markTestSkipped('This test is only supported on platforms that have autoincrement'); + } + + $table = new \Doctrine\DBAL\Schema\Table('test_autoincrement'); + $table->setSchemaConfig($this->_sm->createSchemaConfig()); + $table->addColumn('id', 'integer', array('autoincrement' => true)); + $table->setPrimaryKey(array('id')); + + $this->_sm->createTable($table); + + $inferredTable = $this->_sm->listTableDetails('test_autoincrement'); + $this->assertTrue($inferredTable->hasColumn('id')); + $this->assertTrue($inferredTable->getColumn('id')->getAutoincrement()); + } + + /** + * @group DDC-887 + */ + public function testUpdateSchemaWithForeignKeyRenaming() + { + if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); + } + + $table = new \Doctrine\DBAL\Schema\Table('test_fk_base'); + $table->addColumn('id', 'integer'); + $table->setPrimaryKey(array('id')); + + $tableFK = new \Doctrine\DBAL\Schema\Table('test_fk_rename'); + $tableFK->setSchemaConfig($this->_sm->createSchemaConfig()); + $tableFK->addColumn('id', 'integer'); + $tableFK->addColumn('fk_id', 'integer'); + $tableFK->setPrimaryKey(array('id')); + $tableFK->addIndex(array('fk_id'), 'fk_idx'); + $tableFK->addForeignKeyConstraint('test_fk_base', array('fk_id'), array('id')); + + $this->_sm->createTable($table); + $this->_sm->createTable($tableFK); + + $tableFKNew = new \Doctrine\DBAL\Schema\Table('test_fk_rename'); + $tableFKNew->setSchemaConfig($this->_sm->createSchemaConfig()); + $tableFKNew->addColumn('id', 'integer'); + $tableFKNew->addColumn('rename_fk_id', 'integer'); + $tableFKNew->setPrimaryKey(array('id')); + $tableFKNew->addIndex(array('rename_fk_id'), 'fk_idx'); + $tableFKNew->addForeignKeyConstraint('test_fk_base', array('rename_fk_id'), array('id')); + + $c = new \Doctrine\DBAL\Schema\Comparator(); + $tableDiff = $c->diffTable($tableFK, $tableFKNew); + + $this->_sm->alterTable($tableDiff); + } + + /** + * @group DBAL-42 + */ + public function testGetColumnComment() + { + if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) { + $this->markTestSkipped('Database does not support column comments.'); + } + + $table = new \Doctrine\DBAL\Schema\Table('column_comment_test'); + $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); + $table->setPrimaryKey(array('id')); + + $this->_sm->createTable($table); + + $columns = $this->_sm->listTableColumns("column_comment_test"); + $this->assertEquals(1, count($columns)); + $this->assertEquals('This is a comment', $columns['id']->getComment()); + } + + /** + * @group DBAL-42 + */ + public function testAutomaticallyAppendCommentOnMarkedColumns() + { + if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) { + $this->markTestSkipped('Database does not support column comments.'); + } + + $table = new \Doctrine\DBAL\Schema\Table('column_comment_test2'); + $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); + $table->addColumn('obj', 'object', array('comment' => 'This is a comment')); + $table->addColumn('arr', 'array', array('comment' => 'This is a comment')); + $table->setPrimaryKey(array('id')); + + $this->_sm->createTable($table); + + $columns = $this->_sm->listTableColumns("column_comment_test2"); + $this->assertEquals(3, count($columns)); + $this->assertEquals('This is a comment', $columns['id']->getComment()); + $this->assertEquals('This is a comment', $columns['obj']->getComment(), "The Doctrine2 Typehint should be stripped from comment."); + $this->assertInstanceOf('Doctrine\DBAL\Types\ObjectType', $columns['obj']->getType(), "The Doctrine2 should be detected from comment hint."); + $this->assertEquals('This is a comment', $columns['arr']->getComment(), "The Doctrine2 Typehint should be stripped from comment."); + $this->assertInstanceOf('Doctrine\DBAL\Types\ArrayType', $columns['arr']->getType(), "The Doctrine2 should be detected from comment hint."); + } + + /** + * @group DBAL-197 + */ + public function testListTableWithBlob() + { + $table = new \Doctrine\DBAL\Schema\Table('test_blob_table'); + $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); + $table->addColumn('binarydata', 'blob', array()); + $table->setPrimaryKey(array('id')); + + $this->_sm->createTable($table); + $blobTable = $this->_sm->listTableDetails('test_blob_table'); + } + + /** + * @param string $name + * @param array $data + */ + protected function createTestTable($name = 'test_table', $data = array()) + { + $options = array(); + if (isset($data['options'])) { + $options = $data['options']; + } + + $table = $this->getTestTable($name, $options); + + $this->_sm->dropAndCreateTable($table); + } + + protected function getTestTable($name, $options=array()) + { + $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options); + $table->setSchemaConfig($this->_sm->createSchemaConfig()); + $table->addColumn('id', 'integer', array('notnull' => true)); + $table->setPrimaryKey(array('id')); + $table->addColumn('test', 'string', array('length' => 255)); + $table->addColumn('foreign_key_test', 'integer'); + return $table; + } + + protected function getTestCompositeTable($name) + { + $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, array()); + $table->setSchemaConfig($this->_sm->createSchemaConfig()); + $table->addColumn('id', 'integer', array('notnull' => true)); + $table->addColumn('other_id', 'integer', array('notnull' => true)); + $table->setPrimaryKey(array('id', 'other_id')); + $table->addColumn('test', 'string', array('length' => 255)); + return $table; + } + + protected function assertHasTable($tables, $tableName) + { + $foundTable = false; + foreach ($tables AS $table) { + $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table, 'No Table instance was found in tables array.'); + if (strtolower($table->getName()) == 'list_tables_test_new_name') { + $foundTable = true; + } + } + $this->assertTrue($foundTable, "Could not find new table"); + } + + public function testListForeignKeysComposite() + { + if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped('Does not support foreign key constraints.'); + } + + $this->_sm->createTable($this->getTestTable('test_create_fk3')); + $this->_sm->createTable($this->getTestCompositeTable('test_create_fk4')); + + $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint( + array('id', 'foreign_key_test'), 'test_create_fk4', array('id', 'other_id'), 'foreign_key_test_fk' + ); + + $this->_sm->createForeignKey($foreignKey, 'test_create_fk3'); + + $fkeys = $this->_sm->listTableForeignKeys('test_create_fk3'); + + $this->assertEquals(1, count($fkeys), "Table 'test_create_fk3' has to have one foreign key."); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); + $this->assertEquals(array('id', 'foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); + $this->assertEquals(array('id', 'other_id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php new file mode 100644 index 0000000..2dccb51 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -0,0 +1,46 @@ +_sm->listDatabases(); + } + + public function testCreateAndDropDatabase() + { + $path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite'; + + $this->_sm->createDatabase($path); + $this->assertEquals(true, file_exists($path)); + $this->_sm->dropDatabase($path); + $this->assertEquals(false, file_exists($path)); + } + + /** + * @expectedException \Doctrine\DBAL\DBALException + */ + public function testRenameTable() + { + $this->_sm->renameTable('oldname', 'newname'); + } + + public function testAutoincrementDetection() + { + $this->markTestSkipped( + 'There is currently no reliable way to determine whether an SQLite column is marked as ' + . 'auto-increment. So, while it does support a single identity column, we cannot with ' + . 'certainty determine which it is.'); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php new file mode 100644 index 0000000..9fa92c7 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php @@ -0,0 +1,102 @@ +_conn->exec($this->_conn->getDatabasePlatform()->getDropTableSQL("nontemporary")); + } catch(\Exception $e) { + + } + } + + public function tearDown() + { + if ($this->_conn) { + try { + $tempTable = $this->_conn->getDatabasePlatform()->getTemporaryTableName("temporary"); + $this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable)); + } catch(\Exception $e) { } + } + } + + /** + * @group DDC-1337 + * @return void + */ + public function testDropTemporaryTableNotAutoCommitTransaction() + { + $platform = $this->_conn->getDatabasePlatform(); + $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true)); + $tempTable = $platform->getTemporaryTableName("temporary"); + + $createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' + . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')'; + $this->_conn->executeUpdate($createTempTableSQL); + + $table = new Table("nontemporary"); + $table->addColumn("id", "integer"); + $table->setPrimaryKey(array('id')); + + foreach ($platform->getCreateTableSQL($table) AS $sql) { + $this->_conn->executeQuery($sql); + } + + $this->_conn->beginTransaction(); + $this->_conn->insert("nontemporary", array("id" => 1)); + $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable)); + $this->_conn->insert("nontemporary", array("id" => 2)); + + $this->_conn->rollback(); + + $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary'); + $this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit."); + } + + /** + * @group DDC-1337 + * @return void + */ + public function testCreateTemporaryTableNotAutoCommitTransaction() + { + $platform = $this->_conn->getDatabasePlatform(); + $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true)); + $tempTable = $platform->getTemporaryTableName("temporary"); + + $createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' + . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')'; + + $table = new Table("nontemporary"); + $table->addColumn("id", "integer"); + $table->setPrimaryKey(array('id')); + + foreach ($platform->getCreateTableSQL($table) AS $sql) { + $this->_conn->executeQuery($sql); + } + + $this->_conn->beginTransaction(); + $this->_conn->insert("nontemporary", array("id" => 1)); + + $this->_conn->exec($createTempTableSQL); + $this->_conn->insert("nontemporary", array("id" => 2)); + + $this->_conn->rollback(); + + try { + $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable)); + } catch(\Exception $e) { + + } + + $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary'); + $this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit."); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php new file mode 100644 index 0000000..1393404 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php @@ -0,0 +1,27 @@ +_conn->getDatabasePlatform()->getName() != "postgresql") { + $this->markTestSkipped('PostgreSQL only test'); + } + + $table = new \Doctrine\DBAL\Schema\Table("domains"); + $table->addColumn('id', 'integer'); + $table->addColumn('parent_id', 'integer'); + $table->setPrimaryKey(array('id')); + $table->addForeignKeyConstraint('domains', array('parent_id'), array('id')); + + $this->_conn->getSchemaManager()->createTable($table); + $table = $this->_conn->getSchemaManager()->listTableDetails('domains'); + + $this->assertEquals('domains', $table->getName()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php new file mode 100644 index 0000000..4448ed7 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php @@ -0,0 +1,48 @@ +_conn->getDatabasePlatform()->getName() != 'oracle') { + $this->markTestSkipped('OCI8 only test'); + } + + if ($this->_conn->getSchemaManager()->tablesExist('DBAL202')) { + $this->_conn->executeQuery('DELETE FROM DBAL202'); + } else { + $table = new \Doctrine\DBAL\Schema\Table('DBAL202'); + $table->addColumn('id', 'integer'); + $table->setPrimaryKey(array('id')); + + $this->_conn->getSchemaManager()->createTable($table); + } + } + + public function testStatementRollback() + { + $stmt = $this->_conn->prepare('INSERT INTO DBAL202 VALUES (8)'); + $this->_conn->beginTransaction(); + $stmt->execute(); + $this->_conn->rollback(); + + $this->assertEquals(0, $this->_conn->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn()); + } + + public function testStatementCommit() + { + $stmt = $this->_conn->prepare('INSERT INTO DBAL202 VALUES (8)'); + $this->_conn->beginTransaction(); + $stmt->execute(); + $this->_conn->commit(); + + $this->assertEquals(1, $this->_conn->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn()); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php new file mode 100644 index 0000000..67e6dda --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php @@ -0,0 +1,101 @@ +_conn->getSchemaManager(); + + $table = new \Doctrine\DBAL\Schema\Table("type_conversion"); + $table->addColumn('id', 'integer', array('notnull' => false)); + $table->addColumn('test_string', 'string', array('notnull' => false)); + $table->addColumn('test_boolean', 'boolean', array('notnull' => false)); + $table->addColumn('test_bigint', 'bigint', array('notnull' => false)); + $table->addColumn('test_smallint', 'bigint', array('notnull' => false)); + $table->addColumn('test_datetime', 'datetime', array('notnull' => false)); + $table->addColumn('test_datetimetz', 'datetimetz', array('notnull' => false)); + $table->addColumn('test_date', 'date', array('notnull' => false)); + $table->addColumn('test_time', 'time', array('notnull' => false)); + $table->addColumn('test_text', 'text', array('notnull' => false)); + $table->addColumn('test_array', 'array', array('notnull' => false)); + $table->addColumn('test_object', 'object', array('notnull' => false)); + $table->addColumn('test_float', 'float', array('notnull' => false)); + $table->addColumn('test_decimal', 'decimal', array('notnull' => false, 'scale' => 2, 'precision' => 10)); + $table->setPrimaryKey(array('id')); + + try { + foreach ($this->_conn->getDatabasePlatform()->getCreateTableSQL($table) AS $sql) { + $this->_conn->executeQuery($sql); + } + } catch(\Exception $e) { + + } + } + + static public function dataIdempotentDataConversion() + { + $obj = new \stdClass(); + $obj->foo = "bar"; + $obj->bar = "baz"; + + return array( + array('string', 'ABCDEFGaaaBBB', 'string'), + array('boolean', true, 'bool'), + array('boolean', false, 'bool'), + array('bigint', 12345678, 'string'), + array('smallint', 123, 'int'), + array('datetime', new \DateTime('2010-04-05 10:10:10'), 'DateTime'), + array('datetimetz', new \DateTime('2010-04-05 10:10:10'), 'DateTime'), + array('date', new \DateTime('2010-04-05'), 'DateTime'), + array('time', new \DateTime('10:10:10'), 'DateTime'), + array('text', str_repeat('foo ', 1000), 'string'), + array('array', array('foo' => 'bar'), 'array'), + array('object', $obj, 'object'), + array('float', 1.5, 'float'), + array('decimal', 1.55, 'string'), + ); + } + + /** + * @dataProvider dataIdempotentDataConversion + * @param string $type + * @param mixed $originalValue + * @param string $expectedPhpType + */ + public function testIdempotentDataConversion($type, $originalValue, $expectedPhpType) + { + $columnName = "test_" . $type; + $typeInstance = Type::getType($type); + $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->_conn->getDatabasePlatform()); + + $this->_conn->insert('type_conversion', array('id' => ++self::$typeCounter, $columnName => $insertionValue)); + + $sql = "SELECT " . $columnName . " FROM type_conversion WHERE id = " . self::$typeCounter; + $actualDbValue = $typeInstance->convertToPHPValue($this->_conn->fetchColumn($sql), $this->_conn->getDatabasePlatform()); + + if ($originalValue instanceof \DateTime) { + $this->assertInstanceOf($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType); + } else { + $this->assertInternalType($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType); + } + + if ($type !== "datetimetz") { + $this->assertEquals($originalValue, $actualDbValue, "Conversion between values should produce the same out as in value, but doesnt!"); + + if ($originalValue instanceof \DateTime) { + $this->assertEquals($originalValue->getTimezone()->getName(), $actualDbValue->getTimezone()->getName(), "Timezones should be the same."); + } + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php new file mode 100644 index 0000000..3bdbab0 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -0,0 +1,137 @@ +addColumn('test_int', 'integer'); + $table->addColumn('test_string', 'string', array('notnull' => false)); + $table->setPrimaryKey(array('test_int')); + + foreach ($this->_conn->getDatabasePlatform()->getCreateTableSQL($table) AS $sql) { + $this->_conn->executeQuery($sql); + } + } catch(\Exception $e) { + + } + $this->_conn->executeUpdate('DELETE FROM write_table'); + } + + /** + * @group DBAL-80 + */ + public function testExecuteUpdateFirstTypeIsNull() + { + $sql = "INSERT INTO write_table (test_string, test_int) VALUES (?, ?)"; + $this->_conn->executeUpdate($sql, array("text", 1111), array(null, PDO::PARAM_INT)); + + $sql = "SELECT * FROM write_table WHERE test_string = ? AND test_int = ?"; + $this->assertTrue((bool)$this->_conn->fetchColumn($sql, array("text", 1111))); + } + + public function testExecuteUpdate() + { + $sql = "INSERT INTO write_table (test_int) VALUES ( " . $this->_conn->quote(1) . ")"; + $affected = $this->_conn->executeUpdate($sql); + + $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!"); + } + + public function testExecuteUpdateWithTypes() + { + $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; + $affected = $this->_conn->executeUpdate($sql, array(1, 'foo'), array(\PDO::PARAM_INT, \PDO::PARAM_STR)); + + $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!"); + } + + public function testPrepareRowCountReturnsAffectedRows() + { + $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; + $stmt = $this->_conn->prepare($sql); + + $stmt->bindValue(1, 1); + $stmt->bindValue(2, "foo"); + $stmt->execute(); + + $this->assertEquals(1, $stmt->rowCount()); + } + + public function testPrepareWithPdoTypes() + { + $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; + $stmt = $this->_conn->prepare($sql); + + $stmt->bindValue(1, 1, \PDO::PARAM_INT); + $stmt->bindValue(2, "foo", \PDO::PARAM_STR); + $stmt->execute(); + + $this->assertEquals(1, $stmt->rowCount()); + } + + public function testPrepareWithDbalTypes() + { + $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; + $stmt = $this->_conn->prepare($sql); + + $stmt->bindValue(1, 1, Type::getType('integer')); + $stmt->bindValue(2, "foo", Type::getType('string')); + $stmt->execute(); + + $this->assertEquals(1, $stmt->rowCount()); + } + + public function testPrepareWithDbalTypeNames() + { + $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"; + $stmt = $this->_conn->prepare($sql); + + $stmt->bindValue(1, 1, 'integer'); + $stmt->bindValue(2, "foo", 'string'); + $stmt->execute(); + + $this->assertEquals(1, $stmt->rowCount()); + } + + public function insertRows() + { + $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 1, 'test_string' => 'foo'))); + $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 2, 'test_string' => 'bar'))); + } + + public function testInsert() + { + $this->insertRows(); + } + + public function testDelete() + { + $this->insertRows(); + + $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 2))); + $this->assertEquals(1, count($this->_conn->fetchAll('SELECT * FROM write_table'))); + + $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 1))); + $this->assertEquals(0, count($this->_conn->fetchAll('SELECT * FROM write_table'))); + } + + public function testUpdate() + { + $this->insertRows(); + + $this->assertEquals(1, $this->_conn->update('write_table', array('test_string' => 'bar'), array('test_string' => 'foo'))); + $this->assertEquals(2, $this->_conn->update('write_table', array('test_string' => 'baz'), array('test_string' => 'bar'))); + $this->assertEquals(0, $this->_conn->update('write_table', array('test_string' => 'baz'), array('test_string' => 'bar'))); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php new file mode 100644 index 0000000..576430c --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php @@ -0,0 +1,49 @@ +_platform = $this->createPlatform(); + } + + /** + * @group DDC-1360 + */ + public function testQuoteIdentifier() + { + if ($this->_platform->getName() == "mssql") { + $this->markTestSkipped('Not working this way on mssql.'); + } + + $c = $this->_platform->getIdentifierQuoteCharacter(); + $this->assertEquals($c."test".$c, $this->_platform->quoteIdentifier("test")); + $this->assertEquals($c."test".$c.".".$c."test".$c, $this->_platform->quoteIdentifier("test.test")); + $this->assertEquals(str_repeat($c, 4), $this->_platform->quoteIdentifier($c)); + } + + /** + * @group DDC-1360 + */ + public function testQuoteSingleIdentifier() + { + if ($this->_platform->getName() == "mssql") { + $this->markTestSkipped('Not working this way on mssql.'); + } + + $c = $this->_platform->getIdentifierQuoteCharacter(); + $this->assertEquals($c."test".$c, $this->_platform->quoteSingleIdentifier("test")); + $this->assertEquals($c."test.test".$c, $this->_platform->quoteSingleIdentifier("test.test")); + $this->assertEquals(str_repeat($c, 4), $this->_platform->quoteSingleIdentifier($c)); + } + + public function testGetInvalidtForeignKeyReferentialActionSQL() + { + $this->setExpectedException('InvalidArgumentException'); + $this->_platform->getForeignKeyReferentialActionSQL('unknown'); + } + + public function testGetUnknownDoctrineMappingType() + { + $this->setExpectedException('Doctrine\DBAL\DBALException'); + $this->_platform->getDoctrineTypeMapping('foobar'); + } + + public function testRegisterDoctrineMappingType() + { + $this->_platform->registerDoctrineTypeMapping('foo', 'integer'); + $this->assertEquals('integer', $this->_platform->getDoctrineTypeMapping('foo')); + } + + public function testRegisterUnknownDoctrineMappingType() + { + $this->setExpectedException('Doctrine\DBAL\DBALException'); + $this->_platform->registerDoctrineTypeMapping('foo', 'bar'); + } + + public function testCreateWithNoColumns() + { + $table = new \Doctrine\DBAL\Schema\Table('test'); + + $this->setExpectedException('Doctrine\DBAL\DBALException'); + $sql = $this->_platform->getCreateTableSQL($table); + } + + public function testGeneratesTableCreationSql() + { + $table = new \Doctrine\DBAL\Schema\Table('test'); + $table->addColumn('id', 'integer', array('notnull' => true, 'autoincrement' => true)); + $table->addColumn('test', 'string', array('notnull' => false, 'length' => 255)); + $table->setPrimaryKey(array('id')); + + $sql = $this->_platform->getCreateTableSQL($table); + $this->assertEquals($this->getGenerateTableSql(), $sql[0]); + } + + abstract public function getGenerateTableSql(); + + public function testGenerateTableWithMultiColumnUniqueIndex() + { + $table = new \Doctrine\DBAL\Schema\Table('test'); + $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255)); + $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255)); + $table->addUniqueIndex(array("foo", "bar")); + + $sql = $this->_platform->getCreateTableSQL($table); + $this->assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql); + } + + abstract public function getGenerateTableWithMultiColumnUniqueIndexSql(); + + public function testGeneratesIndexCreationSql() + { + $indexDef = new \Doctrine\DBAL\Schema\Index('my_idx', array('user_name', 'last_login')); + + $this->assertEquals( + $this->getGenerateIndexSql(), + $this->_platform->getCreateIndexSQL($indexDef, 'mytable') + ); + } + + abstract public function getGenerateIndexSql(); + + public function testGeneratesUniqueIndexCreationSql() + { + $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true); + + $sql = $this->_platform->getCreateIndexSQL($indexDef, 'test'); + $this->assertEquals($this->getGenerateUniqueIndexSql(), $sql); + } + + abstract public function getGenerateUniqueIndexSql(); + + public function testGeneratesForeignKeyCreationSql() + { + $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), ''); + + $sql = $this->_platform->getCreateForeignKeySQL($fk, 'test'); + $this->assertEquals($sql, $this->getGenerateForeignKeySql()); + } + + abstract public function getGenerateForeignKeySql(); + + public function testGeneratesConstraintCreationSql() + { + $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false); + $sql = $this->_platform->getCreateConstraintSQL($idx, 'test'); + $this->assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql); + + $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true); + $sql = $this->_platform->getCreateConstraintSQL($pk, 'test'); + $this->assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql); + + $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk'); + $sql = $this->_platform->getCreateConstraintSQL($fk, 'test'); + $this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql); + } + + protected function getBitAndComparisonExpressionSql($value1, $value2) + { + return '(' . $value1 . ' & ' . $value2 . ')'; + } + + /** + * @group DDC-1213 + */ + public function testGeneratesBitAndComparisonExpressionSql() + { + $sql = $this->_platform->getBitAndComparisonExpression(2, 4); + $this->assertEquals($this->getBitAndComparisonExpressionSql(2, 4), $sql); + } + + protected function getBitOrComparisonExpressionSql($value1, $value2) + { + return '(' . $value1 . ' | ' . $value2 . ')'; + } + + /** + * @group DDC-1213 + */ + public function testGeneratesBitOrComparisonExpressionSql() + { + $sql = $this->_platform->getBitOrComparisonExpression(2, 4); + $this->assertEquals($this->getBitOrComparisonExpressionSql(2, 4), $sql); + } + + public function getGenerateConstraintUniqueIndexSql() + { + return 'ALTER TABLE test ADD CONSTRAINT constraint_name UNIQUE (test)'; + } + + public function getGenerateConstraintPrimaryIndexSql() + { + return 'ALTER TABLE test ADD CONSTRAINT constraint_name PRIMARY KEY (test)'; + } + + public function getGenerateConstraintForeignKeySql() + { + return 'ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES foreign (id)'; + } + + abstract public function getGenerateAlterTableSql(); + + public function testGeneratesTableAlterationSql() + { + $expectedSql = $this->getGenerateAlterTableSql(); + + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable'); + $tableDiff->newName = 'userlist'; + $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('notnull' => false)); + $tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer')); + $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff( + 'bar', new \Doctrine\DBAL\Schema\Column( + 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('default' => 'def') + ), + array('type', 'notnull', 'default') + ); + $tableDiff->changedColumns['bloo'] = new \Doctrine\DBAL\Schema\ColumnDiff( + 'bloo', new \Doctrine\DBAL\Schema\Column( + 'bloo', \Doctrine\DBAL\Types\Type::getType('boolean'), array('default' => false) + ), + array('type', 'notnull', 'default') + ); + + $sql = $this->_platform->getAlterTableSQL($tableDiff); + + $this->assertEquals($expectedSql, $sql); + } + + public function testGetCustomColumnDeclarationSql() + { + $field = array('columnDefinition' => 'MEDIUMINT(6) UNSIGNED'); + $this->assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSQL('foo', $field)); + } + + public function testGetCreateTableSqlDispatchEvent() + { + $listenerMock = $this->getMock('GetCreateTableSqlDispatchEvenListener', array('onSchemaCreateTable', 'onSchemaCreateTableColumn')); + $listenerMock + ->expects($this->once()) + ->method('onSchemaCreateTable'); + $listenerMock + ->expects($this->exactly(2)) + ->method('onSchemaCreateTableColumn'); + + $eventManager = new EventManager(); + $eventManager->addEventListener(array(Events::onSchemaCreateTable, Events::onSchemaCreateTableColumn), $listenerMock); + + $this->_platform->setEventManager($eventManager); + + $table = new \Doctrine\DBAL\Schema\Table('test'); + $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255)); + $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255)); + + $this->_platform->getCreateTableSQL($table); + } + + public function testGetDropTableSqlDispatchEvent() + { + $listenerMock = $this->getMock('GetDropTableSqlDispatchEventListener', array('onSchemaDropTable')); + $listenerMock + ->expects($this->once()) + ->method('onSchemaDropTable'); + + $eventManager = new EventManager(); + $eventManager->addEventListener(array(Events::onSchemaDropTable), $listenerMock); + + $this->_platform->setEventManager($eventManager); + + $this->_platform->getDropTableSQL('TABLE'); + } + + public function testGetAlterTableSqlDispatchEvent() + { + $events = array( + 'onSchemaAlterTable', + 'onSchemaAlterTableAddColumn', + 'onSchemaAlterTableRemoveColumn', + 'onSchemaAlterTableChangeColumn', + 'onSchemaAlterTableRenameColumn' + ); + + $listenerMock = $this->getMock('GetAlterTableSqlDispatchEvenListener', $events); + $listenerMock + ->expects($this->once()) + ->method('onSchemaAlterTable'); + $listenerMock + ->expects($this->once()) + ->method('onSchemaAlterTableAddColumn'); + $listenerMock + ->expects($this->once()) + ->method('onSchemaAlterTableRemoveColumn'); + $listenerMock + ->expects($this->once()) + ->method('onSchemaAlterTableChangeColumn'); + $listenerMock + ->expects($this->once()) + ->method('onSchemaAlterTableRenameColumn'); + + $eventManager = new EventManager(); + $events = array( + Events::onSchemaAlterTable, + Events::onSchemaAlterTableAddColumn, + Events::onSchemaAlterTableRemoveColumn, + Events::onSchemaAlterTableChangeColumn, + Events::onSchemaAlterTableRenameColumn + ); + $eventManager->addEventListener($events, $listenerMock); + + $this->_platform->setEventManager($eventManager); + + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable'); + $tableDiff->addedColumns['added'] = new \Doctrine\DBAL\Schema\Column('added', \Doctrine\DBAL\Types\Type::getType('integer'), array()); + $tableDiff->removedColumns['removed'] = new \Doctrine\DBAL\Schema\Column('removed', \Doctrine\DBAL\Types\Type::getType('integer'), array()); + $tableDiff->changedColumns['changed'] = new \Doctrine\DBAL\Schema\ColumnDiff( + 'changed', new \Doctrine\DBAL\Schema\Column( + 'changed2', \Doctrine\DBAL\Types\Type::getType('string'), array() + ), + array() + ); + $tableDiff->renamedColumns['renamed'] = new \Doctrine\DBAL\Schema\Column('renamed2', \Doctrine\DBAL\Types\Type::getType('integer'), array()); + + $this->_platform->getAlterTableSQL($tableDiff); + } + + /** + * @group DBAL-42 + */ + public function testCreateTableColumnComments() + { + $table = new \Doctrine\DBAL\Schema\Table('test'); + $table->addColumn('id', 'integer', array('comment' => 'This is a comment')); + $table->setPrimaryKey(array('id')); + + $this->assertEquals($this->getCreateTableColumnCommentsSQL(), $this->_platform->getCreateTableSQL($table)); + } + + /** + * @group DBAL-42 + */ + public function testAlterTableColumnComments() + { + $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable'); + $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('comment' => 'A comment')); + $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff( + 'bar', new \Doctrine\DBAL\Schema\Column( + 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('comment' => 'B comment') + ), + array('comment') + ); + + $this->assertEquals($this->getAlterTableColumnCommentsSQL(), $this->_platform->getAlterTableSQL($tableDiff)); + } + + public function testCreateTableColumnTypeComments() + { + $table = new \Doctrine\DBAL\Schema\Table('test'); + $table->addColumn('id', 'integer'); + $table->addColumn('data', 'array'); + $table->setPrimaryKey(array('id')); + + $this->assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->_platform->getCreateTableSQL($table)); + } + + public function getCreateTableColumnCommentsSQL() + { + $this->markTestSkipped('Platform does not support Column comments.'); + } + + public function getAlterTableColumnCommentsSQL() + { + $this->markTestSkipped('Platform does not support Column comments.'); + } + + public function getCreateTableColumnTypeCommentsSQL() + { + $this->markTestSkipped('Platform does not support Column comments.'); + } + + /** + * @group DBAL-45 + */ + public function testKeywordList() + { + $keywordList = $this->_platform->getReservedKeywordsList(); + $this->assertInstanceOf('Doctrine\DBAL\Platforms\Keywords\KeywordList', $keywordList); + + $this->assertTrue($keywordList->isKeyword('table')); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php new file mode 100644 index 0000000..1deb460 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php @@ -0,0 +1,229 @@ +addColumn("Bar", "integer"); + + $sql = $this->_platform->getCreateTableSQL($table); + $this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) ENGINE = InnoDB', array_shift($sql)); + } + + public function getGenerateTableSql() + { + return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) ENGINE = InnoDB'; + } + + public function getGenerateTableWithMultiColumnUniqueIndexSql() + { + return array( + 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) ENGINE = InnoDB' + ); + } + + public function getGenerateAlterTableSql() + { + return array( + "ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL, CHANGE bloo bloo TINYINT(1) DEFAULT '0' NOT NULL" + ); + } + + public function testGeneratesSqlSnippets() + { + $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); + $this->assertEquals('`', $this->_platform->getIdentifierQuoteCharacter(), 'Quote character is not correct'); + $this->assertEquals('CONCAT(column1, column2, column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct'); + } + + public function testGeneratesTransactionsCommands() + { + $this->assertEquals( + 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED), + '' + ); + $this->assertEquals( + 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) + ); + $this->assertEquals( + 'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) + ); + $this->assertEquals( + 'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) + ); + } + + + public function testGeneratesDDLSnippets() + { + $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); + $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); + $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar')); + $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); + } + + public function testGeneratesTypeDeclarationForIntegers() + { + $this->assertEquals( + 'INT', + $this->_platform->getIntegerTypeDeclarationSQL(array()) + ); + $this->assertEquals( + 'INT AUTO_INCREMENT', + $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) + )); + $this->assertEquals( + 'INT AUTO_INCREMENT', + $this->_platform->getIntegerTypeDeclarationSQL( + array('autoincrement' => true, 'primary' => true) + )); + } + + public function testGeneratesTypeDeclarationForStrings() + { + $this->assertEquals( + 'CHAR(10)', + $this->_platform->getVarcharTypeDeclarationSQL( + array('length' => 10, 'fixed' => true) + )); + $this->assertEquals( + 'VARCHAR(50)', + $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), + 'Variable string declaration is not correct' + ); + $this->assertEquals( + 'VARCHAR(255)', + $this->_platform->getVarcharTypeDeclarationSQL(array()), + 'Long string declaration is not correct' + ); + } + + public function testPrefersIdentityColumns() + { + $this->assertTrue($this->_platform->prefersIdentityColumns()); + } + + public function testSupportsIdentityColumns() + { + $this->assertTrue($this->_platform->supportsIdentityColumns()); + } + + public function testDoesSupportSavePoints() + { + $this->assertTrue($this->_platform->supportsSavepoints()); + } + + public function getGenerateIndexSql() + { + return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; + } + + public function getGenerateUniqueIndexSql() + { + return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; + } + + public function getGenerateForeignKeySql() + { + return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; + } + + /** + * @group DBAL-126 + */ + public function testUniquePrimaryKey() + { + $keyTable = new Table("foo"); + $keyTable->addColumn("bar", "integer"); + $keyTable->addColumn("baz", "string"); + $keyTable->setPrimaryKey(array("bar")); + $keyTable->addUniqueIndex(array("baz")); + + $oldTable = new Table("foo"); + $oldTable->addColumn("bar", "integer"); + $oldTable->addColumn("baz", "string"); + + $c = new \Doctrine\DBAL\Schema\Comparator; + $diff = $c->diffTable($oldTable, $keyTable); + + $sql = $this->_platform->getAlterTableSQL($diff); + + $this->assertEquals(array( + "ALTER TABLE foo ADD PRIMARY KEY (bar)", + "CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)", + ), $sql); + } + + public function testModifyLimitQuery() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); + $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); + } + + public function testModifyLimitQueryWithEmptyOffset() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); + $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); + } + + /** + * @group DDC-118 + */ + public function testGetDateTimeTypeDeclarationSql() + { + $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => false))); + $this->assertEquals("TIMESTAMP", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => true))); + $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array())); + } + + public function getCreateTableColumnCommentsSQL() + { + return array("CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) ENGINE = InnoDB"); + } + + public function getAlterTableColumnCommentsSQL() + { + return array("ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'"); + } + + public function getCreateTableColumnTypeCommentsSQL() + { + return array("CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) ENGINE = InnoDB"); + } + + /** + * @group DBAL-237 + */ + public function testChangeIndexWithForeignKeys() + { + $index = new Index("idx", array("col"), false); + $unique = new Index("uniq", array("col"), true); + + $diff = new TableDiff("test", array(), array(), array(), array($unique), array(), array($index)); + $sql = $this->_platform->getAlterTableSQL($diff); + $this->assertEquals(array("ALTER TABLE test DROP INDEX idx, ADD UNIQUE INDEX uniq (col)"), $sql); + + $diff = new TableDiff("test", array(), array(), array(), array($index), array(), array($unique)); + $sql = $this->_platform->getAlterTableSQL($diff); + $this->assertEquals(array("ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)"), $sql); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php new file mode 100644 index 0000000..d79423e --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -0,0 +1,227 @@ +assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); + } + + public function testGeneratesSqlSnippets() + { + $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); + $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); + } + + public function testGeneratesTransactionsCommands() + { + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) + ); + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) + ); + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) + ); + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) + ); + } + + /** + * @expectedException Doctrine\DBAL\DBALException + */ + public function testShowDatabasesThrowsException() + { + $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); + } + + /** + * @expectedException Doctrine\DBAL\DBALException + */ + public function testCreateDatabaseThrowsException() + { + $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); + } + + public function testDropDatabaseThrowsException() + { + $this->assertEquals('DROP USER foobar CASCADE', $this->_platform->getDropDatabaseSQL('foobar')); + } + + public function testDropTable() + { + $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); + } + + public function testGeneratesTypeDeclarationForIntegers() + { + $this->assertEquals( + 'NUMBER(10)', + $this->_platform->getIntegerTypeDeclarationSQL(array()) + ); + $this->assertEquals( + 'NUMBER(10)', + $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) + )); + $this->assertEquals( + 'NUMBER(10)', + $this->_platform->getIntegerTypeDeclarationSQL( + array('autoincrement' => true, 'primary' => true) + )); + } + + public function testGeneratesTypeDeclarationsForStrings() + { + $this->assertEquals( + 'CHAR(10)', + $this->_platform->getVarcharTypeDeclarationSQL( + array('length' => 10, 'fixed' => true) + )); + $this->assertEquals( + 'VARCHAR2(50)', + $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), + 'Variable string declaration is not correct' + ); + $this->assertEquals( + 'VARCHAR2(255)', + $this->_platform->getVarcharTypeDeclarationSQL(array()), + 'Long string declaration is not correct' + ); + } + + public function testPrefersIdentityColumns() + { + $this->assertFalse($this->_platform->prefersIdentityColumns()); + } + + public function testSupportsIdentityColumns() + { + $this->assertFalse($this->_platform->supportsIdentityColumns()); + } + + public function testSupportsSavePoints() + { + $this->assertTrue($this->_platform->supportsSavepoints()); + } + + public function getGenerateIndexSql() + { + return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; + } + + public function getGenerateUniqueIndexSql() + { + return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; + } + + public function getGenerateForeignKeySql() + { + return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; + } + + public function testModifyLimitQuery() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); + $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); + } + + public function testModifyLimitQueryWithEmptyOffset() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); + $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); + } + + public function testModifyLimitQueryWithAscOrderBy() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); + $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username ASC) a WHERE ROWNUM <= 10', $sql); + } + + public function testModifyLimitQueryWithDescOrderBy() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); + $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10', $sql); + } + + public function getCreateTableColumnCommentsSQL() + { + return array( + "CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))", + "COMMENT ON COLUMN test.id IS 'This is a comment'", + ); + } + + public function getCreateTableColumnTypeCommentsSQL() + { + return array( + "CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))", + "COMMENT ON COLUMN test.data IS '(DC2Type:array)'" + ); + } + + public function getAlterTableColumnCommentsSQL() + { + return array( + "ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)", + "ALTER TABLE mytable MODIFY (baz VARCHAR2(255) NOT NULL)", + "COMMENT ON COLUMN mytable.quota IS 'A comment'", + "COMMENT ON COLUMN mytable.baz IS 'B comment'", + ); + } + + public function getBitAndComparisonExpressionSql($value1, $value2) + { + return 'BITAND('.$value1 . ', ' . $value2 . ')'; + } + + public function getBitOrComparisonExpressionSql($value1, $value2) + { + return '(' . $value1 . '-' . + $this->getBitAndComparisonExpressionSql($value1, $value2) + . '+' . $value2 . ')'; + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php new file mode 100644 index 0000000..de75d02 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php @@ -0,0 +1,230 @@ + 'CASCADE') + ); + $this->assertEquals( + "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", + $this->_platform->getForeignKeyDeclarationSQL($foreignKey) + ); + } + + public function testGeneratesSqlSnippets() + { + $this->assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); + $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); + $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); + $this->assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); + $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); + } + + public function testGeneratesTransactionCommands() + { + $this->assertEquals( + 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) + ); + $this->assertEquals( + 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) + ); + $this->assertEquals( + 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) + ); + $this->assertEquals( + 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) + ); + } + + public function testGeneratesDDLSnippets() + { + $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); + $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar')); + $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); + } + + public function testGenerateTableWithAutoincrement() + { + $table = new \Doctrine\DBAL\Schema\Table('autoinc_table'); + $column = $table->addColumn('id', 'integer'); + $column->setAutoincrement(true); + + $this->assertEquals(array('CREATE TABLE autoinc_table (id SERIAL NOT NULL)'), $this->_platform->getCreateTableSQL($table)); + } + + public function testGeneratesTypeDeclarationForIntegers() + { + $this->assertEquals( + 'INT', + $this->_platform->getIntegerTypeDeclarationSQL(array()) + ); + $this->assertEquals( + 'SERIAL', + $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) + )); + $this->assertEquals( + 'SERIAL', + $this->_platform->getIntegerTypeDeclarationSQL( + array('autoincrement' => true, 'primary' => true) + )); + } + + public function testGeneratesTypeDeclarationForStrings() + { + $this->assertEquals( + 'CHAR(10)', + $this->_platform->getVarcharTypeDeclarationSQL( + array('length' => 10, 'fixed' => true)) + ); + $this->assertEquals( + 'VARCHAR(50)', + $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), + 'Variable string declaration is not correct' + ); + $this->assertEquals( + 'VARCHAR(255)', + $this->_platform->getVarcharTypeDeclarationSQL(array()), + 'Long string declaration is not correct' + ); + } + + public function getGenerateUniqueIndexSql() + { + return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; + } + + public function testGeneratesSequenceSqlCommands() + { + $sequence = new \Doctrine\DBAL\Schema\Sequence('myseq', 20, 1); + $this->assertEquals( + 'CREATE SEQUENCE myseq INCREMENT BY 20 MINVALUE 1 START 1', + $this->_platform->getCreateSequenceSQL($sequence) + ); + $this->assertEquals( + 'DROP SEQUENCE myseq', + $this->_platform->getDropSequenceSQL('myseq') + ); + $this->assertEquals( + "SELECT NEXTVAL('myseq')", + $this->_platform->getSequenceNextValSQL('myseq') + ); + } + + public function testDoesNotPreferIdentityColumns() + { + $this->assertFalse($this->_platform->prefersIdentityColumns()); + } + + public function testPrefersSequences() + { + $this->assertTrue($this->_platform->prefersSequences()); + } + + public function testSupportsIdentityColumns() + { + $this->assertTrue($this->_platform->supportsIdentityColumns()); + } + + public function testSupportsSavePoints() + { + $this->assertTrue($this->_platform->supportsSavepoints()); + } + + public function testSupportsSequences() + { + $this->assertTrue($this->_platform->supportsSequences()); + } + + public function testModifyLimitQuery() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); + $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); + } + + public function testModifyLimitQueryWithEmptyOffset() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); + $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); + } + + public function getCreateTableColumnCommentsSQL() + { + return array( + "CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))", + "COMMENT ON COLUMN test.id IS 'This is a comment'", + ); + } + + public function getAlterTableColumnCommentsSQL() + { + return array( + "ALTER TABLE mytable ADD quota INT NOT NULL", + "COMMENT ON COLUMN mytable.quota IS 'A comment'", + "COMMENT ON COLUMN mytable.baz IS 'B comment'", + ); + } + + public function getCreateTableColumnTypeCommentsSQL() + { + return array( + "CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))", + "COMMENT ON COLUMN test.data IS '(DC2Type:array)'" + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php new file mode 100644 index 0000000..388115f --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php @@ -0,0 +1,47 @@ +validator = new ReservedKeywordsValidator(array( + new \Doctrine\DBAL\Platforms\Keywords\MySQLKeywords() + )); + } + + public function testReservedTableName() + { + $table = new Table("TABLE"); + $this->validator->acceptTable($table); + + $this->assertEquals( + array('Table TABLE keyword violations: MySQL'), + $this->validator->getViolations() + ); + } + + public function testReservedColumnName() + { + $table = new Table("TABLE"); + $column = $table->addColumn('table', 'string'); + + $this->validator->acceptColumn($table, $column); + + $this->assertEquals( + array('Table TABLE column table keyword violations: MySQL'), + $this->validator->getViolations() + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php new file mode 100644 index 0000000..887dbef --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php @@ -0,0 +1,191 @@ +assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); + $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); + $this->assertEquals('(column1 + column2 + column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); + } + + public function testGeneratesTransactionsCommands() + { + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) + ); + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) + ); + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) + ); + $this->assertEquals( + 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) + ); + } + + public function testGeneratesDDLSnippets() + { + $dropDatabaseExpectation = 'DROP DATABASE foobar'; + + $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL()); + $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar')); + $this->assertEquals($dropDatabaseExpectation, $this->_platform->getDropDatabaseSQL('foobar')); + $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar')); + } + + public function testGeneratesTypeDeclarationForIntegers() + { + $this->assertEquals( + 'INT', + $this->_platform->getIntegerTypeDeclarationSQL(array()) + ); + $this->assertEquals( + 'INT IDENTITY', + $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) + )); + $this->assertEquals( + 'INT IDENTITY', + $this->_platform->getIntegerTypeDeclarationSQL( + array('autoincrement' => true, 'primary' => true) + )); + } + + public function testGeneratesTypeDeclarationsForStrings() + { + $this->assertEquals( + 'NCHAR(10)', + $this->_platform->getVarcharTypeDeclarationSQL( + array('length' => 10, 'fixed' => true) + )); + $this->assertEquals( + 'NVARCHAR(50)', + $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), + 'Variable string declaration is not correct' + ); + $this->assertEquals( + 'NVARCHAR(255)', + $this->_platform->getVarcharTypeDeclarationSQL(array()), + 'Long string declaration is not correct' + ); + } + + public function testPrefersIdentityColumns() + { + $this->assertTrue($this->_platform->prefersIdentityColumns()); + } + + public function testSupportsIdentityColumns() + { + $this->assertTrue($this->_platform->supportsIdentityColumns()); + } + + public function testDoesNotSupportSavePoints() + { + $this->assertTrue($this->_platform->supportsSavepoints()); + } + + public function getGenerateIndexSql() + { + return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; + } + + public function getGenerateUniqueIndexSql() + { + return 'CREATE UNIQUE INDEX index_name ON test (test, test2) WHERE test IS NOT NULL AND test2 IS NOT NULL'; + } + + public function getGenerateForeignKeySql() + { + return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; + } + + public function testModifyLimitQuery() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); + $this->assertEquals('SELECT TOP 10 * FROM user', $sql); + } + + public function testModifyLimitQueryWithEmptyOffset() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); + $this->assertEquals('SELECT TOP 10 * FROM user', $sql); + } + + public function testModifyLimitQueryWithOffset() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5); + $this->assertEquals('SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY username DESC) AS "doctrine_rownum", * FROM user) AS doctrine_tbl WHERE "doctrine_rownum" BETWEEN 6 AND 15', $sql); + } + + public function testModifyLimitQueryWithAscOrderBy() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); + $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username ASC', $sql); + } + + public function testModifyLimitQueryWithDescOrderBy() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); + $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username DESC', $sql); + } + + /** + * @group DDC-1360 + */ + public function testQuoteIdentifier() + { + $this->assertEquals('[fo][o]', $this->_platform->quoteIdentifier('fo]o')); + $this->assertEquals('[test]', $this->_platform->quoteIdentifier('test')); + $this->assertEquals('[test].[test]', $this->_platform->quoteIdentifier('test.test')); + } + + /** + * @group DDC-1360 + */ + public function testQuoteSingleIdentifier() + { + $this->assertEquals('[fo][o]', $this->_platform->quoteSingleIdentifier('fo]o')); + $this->assertEquals('[test]', $this->_platform->quoteSingleIdentifier('test')); + $this->assertEquals('[test.test]', $this->_platform->quoteSingleIdentifier('test.test')); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php new file mode 100644 index 0000000..0e50891 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -0,0 +1,134 @@ +assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct'); + $this->assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); + $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); + } + + public function testGeneratesTransactionCommands() + { + $this->assertEquals( + 'PRAGMA read_uncommitted = 0', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED) + ); + $this->assertEquals( + 'PRAGMA read_uncommitted = 1', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED) + ); + $this->assertEquals( + 'PRAGMA read_uncommitted = 1', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ) + ); + $this->assertEquals( + 'PRAGMA read_uncommitted = 1', + $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE) + ); + } + + public function testPrefersIdentityColumns() + { + $this->assertTrue($this->_platform->prefersIdentityColumns()); + } + + public function testGeneratesTypeDeclarationForIntegers() + { + $this->assertEquals( + 'INTEGER', + $this->_platform->getIntegerTypeDeclarationSQL(array()) + ); + $this->assertEquals( + 'INTEGER', + $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)) + ); + $this->assertEquals( + 'INTEGER', + $this->_platform->getIntegerTypeDeclarationSQL( + array('autoincrement' => true, 'primary' => true)) + ); + } + + public function testGeneratesTypeDeclarationForStrings() + { + $this->assertEquals( + 'CHAR(10)', + $this->_platform->getVarcharTypeDeclarationSQL( + array('length' => 10, 'fixed' => true)) + ); + $this->assertEquals( + 'VARCHAR(50)', + $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)), + 'Variable string declaration is not correct' + ); + $this->assertEquals( + 'VARCHAR(255)', + $this->_platform->getVarcharTypeDeclarationSQL(array()), + 'Long string declaration is not correct' + ); + } + + public function getGenerateIndexSql() + { + return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; + } + + public function getGenerateUniqueIndexSql() + { + return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; + } + + public function getGenerateForeignKeySql() + { + $this->markTestSkipped('SQLite does not support ForeignKeys.'); + } + + public function testModifyLimitQuery() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0); + $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql); + } + + public function testModifyLimitQueryWithEmptyOffset() + { + $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10); + $this->assertEquals('SELECT * FROM user LIMIT 10', $sql); + } + + public function getGenerateAlterTableSql() + { + $this->markTestSkipped('SQlite does not support ALTER Table.'); + } + + public function testGetAlterTableSqlDispatchEvent() + { + $this->markTestSkipped('SQlite does not support ALTER Table.'); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php new file mode 100644 index 0000000..9939659 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php @@ -0,0 +1,82 @@ +assertEquals(1, count($expr)); + + $expr->add('u.group_id = 2'); + + $this->assertEquals(2, count($expr)); + } + + /** + * @dataProvider provideDataForConvertToString + */ + public function testCompositeUsageAndGeneration($type, $parts, $expects) + { + $expr = new CompositeExpression($type, $parts); + + $this->assertEquals($expects, (string) $expr); + } + + public function provideDataForConvertToString() + { + return array( + array( + CompositeExpression::TYPE_AND, + array('u.user = 1'), + 'u.user = 1' + ), + array( + CompositeExpression::TYPE_AND, + array('u.user = 1', 'u.group_id = 1'), + '(u.user = 1) AND (u.group_id = 1)' + ), + array( + CompositeExpression::TYPE_OR, + array('u.user = 1'), + 'u.user = 1' + ), + array( + CompositeExpression::TYPE_OR, + array('u.group_id = 1', 'u.group_id = 2'), + '(u.group_id = 1) OR (u.group_id = 2)' + ), + array( + CompositeExpression::TYPE_AND, + array( + 'u.user = 1', + new CompositeExpression( + CompositeExpression::TYPE_OR, + array('u.group_id = 1', 'u.group_id = 2') + ) + ), + '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))' + ), + array( + CompositeExpression::TYPE_OR, + array( + 'u.group_id = 1', + new CompositeExpression( + CompositeExpression::TYPE_AND, + array('u.user = 1', 'u.group_id = 2') + ) + ), + '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))' + ), + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php new file mode 100644 index 0000000..1893e97 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -0,0 +1,201 @@ +getMock('Doctrine\DBAL\Connection', array(), array(), '', false); + + $this->expr = new ExpressionBuilder($conn); + + $conn->expects($this->any()) + ->method('getExpressionBuilder') + ->will($this->returnValue($this->expr)); + } + + /** + * @dataProvider provideDataForAndX + */ + public function testAndX($parts, $expected) + { + $composite = $this->expr->andX(); + + foreach ($parts as $part) { + $composite->add($part); + } + + $this->assertEquals($expected, (string) $composite); + } + + public function provideDataForAndX() + { + return array( + array( + array('u.user = 1'), + 'u.user = 1' + ), + array( + array('u.user = 1', 'u.group_id = 1'), + '(u.user = 1) AND (u.group_id = 1)' + ), + array( + array('u.user = 1'), + 'u.user = 1' + ), + array( + array('u.group_id = 1', 'u.group_id = 2'), + '(u.group_id = 1) AND (u.group_id = 2)' + ), + array( + array( + 'u.user = 1', + new CompositeExpression( + CompositeExpression::TYPE_OR, + array('u.group_id = 1', 'u.group_id = 2') + ) + ), + '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))' + ), + array( + array( + 'u.group_id = 1', + new CompositeExpression( + CompositeExpression::TYPE_AND, + array('u.user = 1', 'u.group_id = 2') + ) + ), + '(u.group_id = 1) AND ((u.user = 1) AND (u.group_id = 2))' + ), + ); + } + + /** + * @dataProvider provideDataForOrX + */ + public function testOrX($parts, $expected) + { + $composite = $this->expr->orX(); + + foreach ($parts as $part) { + $composite->add($part); + } + + $this->assertEquals($expected, (string) $composite); + } + + public function provideDataForOrX() + { + return array( + array( + array('u.user = 1'), + 'u.user = 1' + ), + array( + array('u.user = 1', 'u.group_id = 1'), + '(u.user = 1) OR (u.group_id = 1)' + ), + array( + array('u.user = 1'), + 'u.user = 1' + ), + array( + array('u.group_id = 1', 'u.group_id = 2'), + '(u.group_id = 1) OR (u.group_id = 2)' + ), + array( + array( + 'u.user = 1', + new CompositeExpression( + CompositeExpression::TYPE_OR, + array('u.group_id = 1', 'u.group_id = 2') + ) + ), + '(u.user = 1) OR ((u.group_id = 1) OR (u.group_id = 2))' + ), + array( + array( + 'u.group_id = 1', + new CompositeExpression( + CompositeExpression::TYPE_AND, + array('u.user = 1', 'u.group_id = 2') + ) + ), + '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))' + ), + ); + } + + /** + * @dataProvider provideDataForComparison + */ + public function testComparison($leftExpr, $operator, $rightExpr, $expected) + { + $part = $this->expr->comparison($leftExpr, $operator, $rightExpr); + + $this->assertEquals($expected, (string) $part); + } + + public function provideDataForComparison() + { + return array( + array('u.user_id', ExpressionBuilder::EQ, '1', 'u.user_id = 1'), + array('u.user_id', ExpressionBuilder::NEQ, '1', 'u.user_id <> 1'), + array('u.salary', ExpressionBuilder::LT, '10000', 'u.salary < 10000'), + array('u.salary', ExpressionBuilder::LTE, '10000', 'u.salary <= 10000'), + array('u.salary', ExpressionBuilder::GT, '10000', 'u.salary > 10000'), + array('u.salary', ExpressionBuilder::GTE, '10000', 'u.salary >= 10000'), + ); + } + + public function testEq() + { + $this->assertEquals('u.user_id = 1', $this->expr->eq('u.user_id', '1')); + } + + public function testNeq() + { + $this->assertEquals('u.user_id <> 1', $this->expr->neq('u.user_id', '1')); + } + + public function testLt() + { + $this->assertEquals('u.salary < 10000', $this->expr->lt('u.salary', '10000')); + } + + public function testLte() + { + $this->assertEquals('u.salary <= 10000', $this->expr->lte('u.salary', '10000')); + } + + public function testGt() + { + $this->assertEquals('u.salary > 10000', $this->expr->gt('u.salary', '10000')); + } + + public function testGte() + { + $this->assertEquals('u.salary >= 10000', $this->expr->gte('u.salary', '10000')); + } + + public function testIsNull() + { + $this->assertEquals('u.deleted IS NULL', $this->expr->isNull('u.deleted')); + } + + public function testIsNotNull() + { + $this->assertEquals('u.updated IS NOT NULL', $this->expr->isNotNull('u.updated')); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php new file mode 100644 index 0000000..98f1616 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php @@ -0,0 +1,572 @@ +conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false); + + $expressionBuilder = new ExpressionBuilder($this->conn); + + $this->conn->expects($this->any()) + ->method('getExpressionBuilder') + ->will($this->returnValue($expressionBuilder)); + } + + public function testSimpleSelect() + { + $qb = new QueryBuilder($this->conn); + + $qb->select('u.id') + ->from('users', 'u'); + + $this->assertEquals('SELECT u.id FROM users u', (string) $qb); + } + + public function testSelectWithSimpleWhere() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.id') + ->from('users', 'u') + ->where($expr->andX($expr->eq('u.nickname', '?'))); + + $this->assertEquals("SELECT u.id FROM users u WHERE u.nickname = ?", (string) $qb); + } + + public function testSelectWithLeftJoin() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->leftJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); + + $this->assertEquals('SELECT u.*, p.* FROM users u LEFT JOIN phones p ON p.user_id = u.id', (string) $qb); + } + + public function testSelectWithJoin() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->Join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); + + $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); + } + + public function testSelectWithInnerJoin() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->innerJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); + + $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); + } + + public function testSelectWithRightJoin() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->rightJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id')); + + $this->assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb); + } + + public function testSelectWithAndWhereConditions() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->where('u.username = ?') + ->andWhere('u.name = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb); + } + + public function testSelectWithOrWhereConditions() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->where('u.username = ?') + ->orWhere('u.name = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); + } + + public function testSelectWithOrOrWhereConditions() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->orWhere('u.username = ?') + ->orWhere('u.name = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); + } + + public function testSelectWithAndOrWhereConditions() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->where('u.username = ?') + ->andWhere('u.username = ?') + ->orWhere('u.name = ?') + ->andWhere('u.name = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb); + } + + public function testSelectGroupBy() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb); + } + + public function testSelectEmptyGroupBy() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->groupBy(array()) + ->from('users', 'u'); + + $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); + } + + public function testSelectEmptyAddGroupBy() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->addGroupBy(array()) + ->from('users', 'u'); + + $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); + } + + public function testSelectAddGroupBy() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->addGroupBy('u.foo'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb); + } + + public function testSelectAddGroupBys() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->addGroupBy('u.foo', 'u.bar'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb); + } + + public function testSelectHaving() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->having('u.name = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); + } + + public function testSelectAndHaving() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->andHaving('u.name = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); + } + + public function testSelectHavingAndHaving() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->having('u.name = ?') + ->andHaving('u.username = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb); + } + + public function testSelectHavingOrHaving() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->having('u.name = ?') + ->orHaving('u.username = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); + } + + public function testSelectOrHavingOrHaving() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->orHaving('u.name = ?') + ->orHaving('u.username = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); + } + + public function testSelectHavingAndOrHaving() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->groupBy('u.id') + ->having('u.name = ?') + ->orHaving('u.username = ?') + ->andHaving('u.username = ?'); + + $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb); + } + + public function testSelectOrderBy() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->orderBy('u.name'); + + $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb); + } + + public function testSelectAddOrderBy() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->orderBy('u.name') + ->addOrderBy('u.username', 'DESC'); + + $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); + } + + public function testSelectAddAddOrderBy() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*', 'p.*') + ->from('users', 'u') + ->addOrderBy('u.name') + ->addOrderBy('u.username', 'DESC'); + + $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); + } + + public function testEmptySelect() + { + $qb = new QueryBuilder($this->conn); + $qb2 = $qb->select(); + + $this->assertSame($qb, $qb2); + $this->assertEquals(QueryBuilder::SELECT, $qb->getType()); + } + + public function testSelectAddSelect() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*') + ->addSelect('p.*') + ->from('users', 'u'); + + $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); + } + + public function testEmptyAddSelect() + { + $qb = new QueryBuilder($this->conn); + $qb2 = $qb->addSelect(); + + $this->assertSame($qb, $qb2); + $this->assertEquals(QueryBuilder::SELECT, $qb->getType()); + } + + public function testSelectMultipleFrom() + { + $qb = new QueryBuilder($this->conn); + $expr = $qb->expr(); + + $qb->select('u.*') + ->addSelect('p.*') + ->from('users', 'u') + ->from('phonenumbers', 'p'); + + $this->assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb); + } + + public function testUpdate() + { + $qb = new QueryBuilder($this->conn); + $qb->update('users', 'u') + ->set('u.foo', '?') + ->set('u.bar', '?'); + + $this->assertEquals(QueryBuilder::UPDATE, $qb->getType()); + $this->assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb); + } + + public function testUpdateWithoutAlias() + { + $qb = new QueryBuilder($this->conn); + $qb->update('users') + ->set('foo', '?') + ->set('bar', '?'); + + $this->assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb); + } + + public function testUpdateWhere() + { + $qb = new QueryBuilder($this->conn); + $qb->update('users', 'u') + ->set('u.foo', '?') + ->where('u.foo = ?'); + + $this->assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb); + } + + public function testEmptyUpdate() + { + $qb = new QueryBuilder($this->conn); + $qb2 = $qb->update(); + + $this->assertEquals(QueryBuilder::UPDATE, $qb->getType()); + $this->assertSame($qb2, $qb); + } + + public function testDelete() + { + $qb = new QueryBuilder($this->conn); + $qb->delete('users', 'u'); + + $this->assertEquals(QueryBuilder::DELETE, $qb->getType()); + $this->assertEquals('DELETE FROM users u', (string) $qb); + } + + public function testDeleteWithoutAlias() + { + $qb = new QueryBuilder($this->conn); + $qb->delete('users'); + + $this->assertEquals(QueryBuilder::DELETE, $qb->getType()); + $this->assertEquals('DELETE FROM users', (string) $qb); + } + + public function testDeleteWhere() + { + $qb = new QueryBuilder($this->conn); + $qb->delete('users', 'u') + ->where('u.foo = ?'); + + $this->assertEquals('DELETE FROM users u WHERE u.foo = ?', (string) $qb); + } + + public function testEmptyDelete() + { + $qb = new QueryBuilder($this->conn); + $qb2 = $qb->delete(); + + $this->assertEquals(QueryBuilder::DELETE, $qb->getType()); + $this->assertSame($qb2, $qb); + } + + public function testGetConnection() + { + $qb = new QueryBuilder($this->conn); + $this->assertSame($this->conn, $qb->getConnection()); + } + + public function testGetState() + { + $qb = new QueryBuilder($this->conn); + + $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); + + $qb->select('u.*')->from('users', 'u'); + + $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); + + $sql1 = $qb->getSQL(); + + $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); + $this->assertEquals($sql1, $qb->getSQL()); + } + + public function testSetMaxResults() + { + $qb = new QueryBuilder($this->conn); + $qb->setMaxResults(10); + + $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); + $this->assertEQuals(10, $qb->getMaxResults()); + } + + public function testSetFirstResult() + { + $qb = new QueryBuilder($this->conn); + $qb->setFirstResult(10); + + $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); + $this->assertEQuals(10, $qb->getFirstResult()); + } + + public function testResetQueryPart() + { + $qb = new QueryBuilder($this->conn); + + $qb->select('u.*')->from('users', 'u')->where('u.name = ?'); + + $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb); + $qb->resetQueryPart('where'); + $this->assertEquals('SELECT u.* FROM users u', (string)$qb); + } + + public function testResetQueryParts() + { + $qb = new QueryBuilder($this->conn); + + $qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name'); + + $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ? ORDER BY u.name ASC', (string)$qb); + $qb->resetQueryParts(array('where', 'orderBy')); + $this->assertEquals('SELECT u.* FROM users u', (string)$qb); + } + + public function testCreateNamedParameter() + { + $qb = new QueryBuilder($this->conn); + + $qb->select('u.*')->from('users', 'u')->where( + $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT)) + ); + + $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :dcValue1', (string)$qb); + $this->assertEquals(10, $qb->getParameter('dcValue1')); + } + + public function testCreateNamedParameterCustomPlaceholder() + { + $qb = new QueryBuilder($this->conn); + + $qb->select('u.*')->from('users', 'u')->where( + $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT, ':test')) + ); + + $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :test', (string)$qb); + $this->assertEquals(10, $qb->getParameter('test')); + } + + public function testCreatePositionalParameter() + { + $qb = new QueryBuilder($this->conn); + + $qb->select('u.*')->from('users', 'u')->where( + $qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT)) + ); + + $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb); + $this->assertEquals(10, $qb->getParameter(1)); + } + + /** + * @group DBAL-172 + */ + public function testReferenceJoinFromJoin() + { + $qb = new QueryBuilder($this->conn); + + $qb->select("l.id", "mdsh.xcode", "mdso.xcode") + ->from("location_tree", "l") + ->join("l", "location_tree_pos", "p", "l.id = p.tree_id") + ->rightJoin("l", "hotel", "h", "h.location_id = l.id") + ->leftJoin("l", "offer_location", "ol", "l.id=ol.location_id") + ->leftJoin("ol", "mds_offer", "mdso", "ol.offer_id = mdso.offer_id") + ->leftJoin("h", "mds_hotel", "mdsh", "h.id = mdsh.hotel_id") + ->where("p.parent_id IN (:ids)") + ->andWhere("(mdso.xcode IS NOT NULL OR mdsh.xcode IS NOT NULL)"); + + $this->setExpectedException('Doctrine\DBAL\Query\QueryException', "The given alias 'ol' is not part of any FROM clause table. The currently registered FROM-clause aliases are: l"); + $this->assertEquals('', $qb->getSQL()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php new file mode 100644 index 0000000..6467d8b --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php @@ -0,0 +1,214 @@ + 'foo', 17 => 'bar')), + array('SELECT * FROM Foo WHERE bar IN (:name1, :name2)', false, array(32 => 'name1', 40 => 'name2')), + array('SELECT ":foo" FROM Foo WHERE bar IN (:name1, :name2)', false, array(37 => 'name1', 45 => 'name2')), + array("SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, array(37 => 'name1', 45 => 'name2')), + array('SELECT :foo_id', false, array(7 => 'foo_id')), // Ticket DBAL-231 + ); + } + + /** + * @dataProvider dataGetPlaceholderPositions + * @param type $query + * @param type $isPositional + * @param type $expectedParamPos + */ + public function testGetPlaceholderPositions($query, $isPositional, $expectedParamPos) + { + $actualParamPos = SQLParserUtils::getPlaceholderPositions($query, $isPositional); + $this->assertEquals($expectedParamPos, $actualParamPos); + } + + static public function dataExpandListParameters() + { + return array( + // Positional: Very simple with one needle + array( + "SELECT * FROM Foo WHERE foo IN (?)", + array(array(1, 2, 3)), + array(Connection::PARAM_INT_ARRAY), + 'SELECT * FROM Foo WHERE foo IN (?, ?, ?)', + array(1, 2, 3), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Positional: One non-list before d one after list-needle + array( + "SELECT * FROM Foo WHERE foo = ? AND bar IN (?)", + array("string", array(1, 2, 3)), + array(\PDO::PARAM_STR, Connection::PARAM_INT_ARRAY), + 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)', + array("string", 1, 2, 3), + array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Positional: One non-list after list-needle + array( + "SELECT * FROM Foo WHERE bar IN (?) AND baz = ?", + array(array(1, 2, 3), "foo"), + array(Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR), + 'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?', + array(1, 2, 3, "foo"), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR) + ), + // Positional: One non-list before and one after list-needle + array( + "SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?", + array(1, array(1, 2, 3), 4), + array(\PDO::PARAM_INT, Connection::PARAM_INT_ARRAY, \PDO::PARAM_INT), + 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?', + array(1, 1, 2, 3, 4), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Positional: Two lists + array( + "SELECT * FROM Foo WHERE foo IN (?, ?)", + array(array(1, 2, 3), array(4, 5)), + array(Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY), + 'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)', + array(1, 2, 3, 4, 5), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Named parameters : Very simple with param int + array( + "SELECT * FROM Foo WHERE foo = :foo", + array('foo'=>1), + array('foo'=>\PDO::PARAM_INT), + 'SELECT * FROM Foo WHERE foo = ?', + array(1), + array(\PDO::PARAM_INT) + ), + + // Named parameters : Very simple with param int and string + array( + "SELECT * FROM Foo WHERE foo = :foo AND bar = :bar", + array('bar'=>'Some String','foo'=>1), + array('foo'=>\PDO::PARAM_INT,'bar'=>\PDO::PARAM_STR), + 'SELECT * FROM Foo WHERE foo = ? AND bar = ?', + array(1,'Some String'), + array(\PDO::PARAM_INT, \PDO::PARAM_STR) + ), + + // Named parameters : Very simple with one needle + array( + "SELECT * FROM Foo WHERE foo IN (:foo)", + array('foo'=>array(1, 2, 3)), + array('foo'=>Connection::PARAM_INT_ARRAY), + 'SELECT * FROM Foo WHERE foo IN (?, ?, ?)', + array(1, 2, 3), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Named parameters: One non-list before d one after list-needle + array( + "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar)", + array('foo'=>"string", 'bar'=>array(1, 2, 3)), + array('foo'=>\PDO::PARAM_STR, 'bar'=>Connection::PARAM_INT_ARRAY), + 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)', + array("string", 1, 2, 3), + array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Named parameters: One non-list after list-needle + array( + "SELECT * FROM Foo WHERE bar IN (:bar) AND baz = :baz", + array('bar'=>array(1, 2, 3), 'baz'=>"foo"), + array('bar'=>Connection::PARAM_INT_ARRAY, 'baz'=>\PDO::PARAM_STR), + 'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?', + array(1, 2, 3, "foo"), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR) + ), + // Named parameters: One non-list before and one after list-needle + array( + "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar) AND baz = :baz", + array('bar'=>array(1, 2, 3),'foo'=>1, 'baz'=>4), + array('bar'=>Connection::PARAM_INT_ARRAY, 'foo'=>\PDO::PARAM_INT, 'baz'=>\PDO::PARAM_INT), + 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?', + array(1, 1, 2, 3, 4), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Named parameters: Two lists + array( + "SELECT * FROM Foo WHERE foo IN (:a, :b)", + array('b'=>array(4, 5),'a'=>array(1, 2, 3)), + array('a'=>Connection::PARAM_INT_ARRAY, 'b'=>Connection::PARAM_INT_ARRAY), + 'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)', + array(1, 2, 3, 4, 5), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + // Named parameters : With the same name arg type string + array( + "SELECT * FROM Foo WHERE foo <> :arg AND bar = :arg", + array('arg'=>"Some String"), + array('arg'=>\PDO::PARAM_STR), + 'SELECT * FROM Foo WHERE foo <> ? AND bar = ?', + array("Some String","Some String"), + array(\PDO::PARAM_STR,\PDO::PARAM_STR,) + ), + // Named parameters : With the same name arg + array( + "SELECT * FROM Foo WHERE foo IN (:arg) AND NOT bar IN (:arg)", + array('arg'=>array(1, 2, 3)), + array('arg'=>Connection::PARAM_INT_ARRAY), + 'SELECT * FROM Foo WHERE foo IN (?, ?, ?) AND NOT bar IN (?, ?, ?)', + array(1, 2, 3, 1, 2, 3), + array(\PDO::PARAM_INT,\PDO::PARAM_INT, \PDO::PARAM_INT,\PDO::PARAM_INT,\PDO::PARAM_INT, \PDO::PARAM_INT) + ), + + // Named parameters : Same name, other name in between DBAL-299 + array( + "SELECT * FROM Foo WHERE (:foo = 2) AND (:bar = 3) AND (:foo = 2)", + array('foo'=>2,'bar'=>3), + array('foo'=>\PDO::PARAM_INT,'bar'=>\PDO::PARAM_INT), + 'SELECT * FROM Foo WHERE (? = 2) AND (? = 3) AND (? = 2)', + array(2, 3, 2), + array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) + ), + ); + } + + /** + * @dataProvider dataExpandListParameters + * @param type $q + * @param type $p + * @param type $t + * @param type $expectedQuery + * @param type $expectedParams + * @param type $expectedTypes + */ + public function testExpandListParameters($q, $p, $t, $expectedQuery, $expectedParams, $expectedTypes) + { + list($query, $params, $types) = SQLParserUtils::expandListParameters($q, $p, $t); + + $this->assertEquals($expectedQuery, $query, "Query was not rewritten correctly."); + $this->assertEquals($expectedParams, $params, "Params dont match"); + $this->assertEquals($expectedTypes, $types, "Types dont match"); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php new file mode 100644 index 0000000..2051061 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php @@ -0,0 +1,114 @@ +createColumn(); + + $this->assertEquals("foo", $column->getName()); + $this->assertSame(Type::getType('string'), $column->getType()); + + $this->assertEquals(200, $column->getLength()); + $this->assertEquals(5, $column->getPrecision()); + $this->assertEquals(2, $column->getScale()); + $this->assertTrue($column->getUnsigned()); + $this->assertFalse($column->getNotNull()); + $this->assertTrue($column->getFixed()); + $this->assertEquals("baz", $column->getDefault()); + + $this->assertEquals(array('foo' => 'bar'), $column->getPlatformOptions()); + $this->assertTrue($column->hasPlatformOption('foo')); + $this->assertEquals('bar', $column->getPlatformOption('foo')); + $this->assertFalse($column->hasPlatformOption('bar')); + + $this->assertEquals(array('bar' => 'baz'), $column->getCustomSchemaOptions()); + $this->assertTrue($column->hasCustomSchemaOption('bar')); + $this->assertEquals('baz', $column->getCustomSchemaOption('bar')); + $this->assertFalse($column->hasCustomSchemaOption('foo')); + } + + public function testToArray() + { + $expected = array( + 'name' => 'foo', + 'type' => Type::getType('string'), + 'default' => 'baz', + 'notnull' => false, + 'length' => 200, + 'precision' => 5, + 'scale' => 2, + 'fixed' => true, + 'unsigned' => true, + 'autoincrement' => false, + 'columnDefinition' => null, + 'comment' => null, + 'foo' => 'bar', + 'bar' => 'baz' + ); + + $this->assertEquals($expected, $this->createColumn()->toArray()); + } + + /** + * @return Column + */ + public function createColumn() + { + $options = array( + 'length' => 200, + 'precision' => 5, + 'scale' => 2, + 'unsigned' => true, + 'notnull' => false, + 'fixed' => true, + 'default' => 'baz', + 'platformOptions' => array('foo' => 'bar'), + 'customSchemaOptions' => array('bar' => 'baz'), + ); + + $string = Type::getType('string'); + return new Column("foo", $string, $options); + } + + /** + * @group DBAL-64 + */ + public function testQuotedColumnName() + { + $string = Type::getType('string'); + $column = new Column("`bar`", $string, array()); + + $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform(); + $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform(); + + $this->assertEquals('bar', $column->getName()); + $this->assertEquals('`bar`', $column->getQuotedName($mysqlPlatform)); + $this->assertEquals('"bar"', $column->getQuotedName($sqlitePlatform)); + } + + /** + * @group DBAL-42 + */ + public function testColumnComment() + { + $column = new Column("bar", Type::getType('string')); + $this->assertNull($column->getComment()); + + $column->setComment("foo"); + $this->assertEquals("foo", $column->getComment()); + + $columnArray = $column->toArray(); + $this->assertArrayHasKey('comment', $columnArray); + $this->assertEquals('foo', $columnArray['comment']); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php new file mode 100644 index 0000000..bb48c5b --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php @@ -0,0 +1,787 @@ +. + */ + +namespace Doctrine\Tests\DBAL\Schema; + +require_once __DIR__ . '/../../TestInit.php'; + +use Doctrine\DBAL\Schema\Schema, + Doctrine\DBAL\Schema\SchemaConfig, + Doctrine\DBAL\Schema\Table, + Doctrine\DBAL\Schema\Column, + Doctrine\DBAL\Schema\Index, + Doctrine\DBAL\Schema\Sequence, + Doctrine\DBAL\Schema\SchemaDiff, + Doctrine\DBAL\Schema\TableDiff, + Doctrine\DBAL\Schema\Comparator, + Doctrine\DBAL\Types\Type, + Doctrine\DBAL\Schema\ForeignKeyConstraint; + +/** + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @since 2.0 + * @version $Revision$ + * @author Benjamin Eberlei + */ +class ComparatorTest extends \PHPUnit_Framework_TestCase +{ + public function testCompareSame1() + { + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer' ) ), + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer') ), + ) + ), + ) ); + + $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareSame2() + { + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + ) + ), + ) ); + $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareMissingTable() + { + $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig; + $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer')))); + $table->setSchemaConfig($schemaConfig); + + $schema1 = new Schema( array($table), array(), $schemaConfig ); + $schema2 = new Schema( array(), array(), $schemaConfig ); + + $expected = new SchemaDiff( array(), array(), array('bugdb' => $table) ); + + $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareNewTable() + { + $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig; + $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer')))); + $table->setSchemaConfig($schemaConfig); + + $schema1 = new Schema( array(), array(), $schemaConfig ); + $schema2 = new Schema( array($table), array(), $schemaConfig ); + + $expected = new SchemaDiff( array('bugdb' => $table), array(), array() ); + $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareOnlyAutoincrementChanged() + { + $column1 = new Column('foo', Type::getType('integer'), array('autoincrement' => true)); + $column2 = new Column('foo', Type::getType('integer'), array('autoincrement' => false)); + + $comparator = new Comparator(); + $changedProperties = $comparator->diffColumn($column1, $column2); + + $this->assertEquals(array('autoincrement'), $changedProperties); + } + + public function testCompareMissingField() + { + $missingColumn = new Column('integerfield1', Type::getType('integer')); + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => $missingColumn, + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ) + ), + ) ); + + $expected = new SchemaDiff ( array(), + array ( + 'bugdb' => new TableDiff( 'bugdb', array(), array(), + array ( + 'integerfield1' => $missingColumn, + ) + ) + ) + ); + $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareNewField() + { + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ) + ), + ) ); + + $expected = new SchemaDiff ( array(), + array ( + 'bugdb' => new TableDiff ('bugdb', + array ( + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ) + ), + ) + ); + $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareChangedColumns_ChangeType() + { + $column1 = new Column('charfield1', Type::getType('string')); + $column2 = new Column('charfield1', Type::getType('integer')); + + $c = new Comparator(); + $this->assertEquals(array('type'), $c->diffColumn($column1, $column2)); + $this->assertEquals(array(), $c->diffColumn($column1, $column1)); + } + + public function testCompareChangedColumns_ChangeCustomSchemaOption() + { + $column1 = new Column('charfield1', Type::getType('string')); + $column2 = new Column('charfield1', Type::getType('string')); + + $column1->setCustomSchemaOption('foo', 'bar'); + $column2->setCustomSchemaOption('foo', 'bar'); + + $column1->setCustomSchemaOption('foo1', 'bar1'); + $column2->setCustomSchemaOption('foo2', 'bar2'); + + $c = new Comparator(); + $this->assertEquals(array('foo1', 'foo2'), $c->diffColumn($column1, $column2)); + $this->assertEquals(array(), $c->diffColumn($column1, $column1)); + } + + public function testCompareRemovedIndex() + { + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ), + array ( + 'primary' => new Index('primary', + array( + 'integerfield1' + ), + true + ) + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ) + ), + ) ); + + $expected = new SchemaDiff ( array(), + array ( + 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), array(), + array ( + 'primary' => new Index('primary', + array( + 'integerfield1' + ), + true + ) + ) + ), + ) + ); + $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareNewIndex() + { + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ), + array ( + 'primary' => new Index('primary', + array( + 'integerfield1' + ), + true + ) + ) + ), + ) ); + + $expected = new SchemaDiff ( array(), + array ( + 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), + array ( + 'primary' => new Index('primary', + array( + 'integerfield1' + ), + true + ) + ) + ), + ) + ); + $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) ); + } + + public function testCompareChangedIndex() + { + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ), + array ( + 'primary' => new Index('primary', + array( + 'integerfield1' + ), + true + ) + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ), + array ( + 'primary' => new Index('primary', + array('integerfield1', 'integerfield2'), + true + ) + ) + ), + ) ); + + $expected = new SchemaDiff ( array(), + array ( + 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), + array ( + 'primary' => new Index('primary', + array( + 'integerfield1', + 'integerfield2' + ), + true + ) + ) + ), + ) + ); + $actual = Comparator::compareSchemas( $schema1, $schema2 ); + $this->assertEquals($expected, $actual); + } + + public function testCompareChangedIndexFieldPositions() + { + $schema1 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ), + array ( + 'primary' => new Index('primary', array('integerfield1', 'integerfield2'), true) + ) + ), + ) ); + $schema2 = new Schema( array( + 'bugdb' => new Table('bugdb', + array ( + 'integerfield1' => new Column('integerfield1', Type::getType('integer')), + 'integerfield2' => new Column('integerfield2', Type::getType('integer')), + ), + array ( + 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true) + ) + ), + ) ); + + $expected = new SchemaDiff ( array(), + array ( + 'bugdb' => new TableDiff('bugdb', array(), array(), array(), array(), + array ( + 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true) + ) + ), + ) + ); + $actual = Comparator::compareSchemas( $schema1, $schema2 ); + $this->assertEquals($expected, $actual); + } + + public function testCompareSequences() + { + $seq1 = new Sequence('foo', 1, 1); + $seq2 = new Sequence('foo', 1, 2); + $seq3 = new Sequence('foo', 2, 1); + + $c = new Comparator(); + + $this->assertTrue($c->diffSequence($seq1, $seq2)); + $this->assertTrue($c->diffSequence($seq1, $seq3)); + } + + public function testRemovedSequence() + { + $schema1 = new Schema(); + $seq = $schema1->createSequence('foo'); + + $schema2 = new Schema(); + + $c = new Comparator(); + $diffSchema = $c->compare($schema1, $schema2); + + $this->assertEquals(1, count($diffSchema->removedSequences)); + $this->assertSame($seq, $diffSchema->removedSequences[0]); + } + + public function testAddedSequence() + { + $schema1 = new Schema(); + + $schema2 = new Schema(); + $seq = $schema2->createSequence('foo'); + + $c = new Comparator(); + $diffSchema = $c->compare($schema1, $schema2); + + $this->assertEquals(1, count($diffSchema->newSequences)); + $this->assertSame($seq, $diffSchema->newSequences[0]); + } + + public function testTableAddForeignKey() + { + $tableForeign = new Table("bar"); + $tableForeign->addColumn('id', 'integer'); + + $table1 = new Table("foo"); + $table1->addColumn('fk', 'integer'); + + $table2 = new Table("foo"); + $table2->addColumn('fk', 'integer'); + $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); + + $c = new Comparator(); + $tableDiff = $c->diffTable($table1, $table2); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + $this->assertEquals(1, count($tableDiff->addedForeignKeys)); + } + + public function testTableRemoveForeignKey() + { + $tableForeign = new Table("bar"); + $tableForeign->addColumn('id', 'integer'); + + $table1 = new Table("foo"); + $table1->addColumn('fk', 'integer'); + + $table2 = new Table("foo"); + $table2->addColumn('fk', 'integer'); + $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); + + $c = new Comparator(); + $tableDiff = $c->diffTable($table2, $table1); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + $this->assertEquals(1, count($tableDiff->removedForeignKeys)); + } + + public function testTableUpdateForeignKey() + { + $tableForeign = new Table("bar"); + $tableForeign->addColumn('id', 'integer'); + + $table1 = new Table("foo"); + $table1->addColumn('fk', 'integer'); + $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); + + $table2 = new Table("foo"); + $table2->addColumn('fk', 'integer'); + $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'), array('onUpdate' => 'CASCADE')); + + $c = new Comparator(); + $tableDiff = $c->diffTable($table1, $table2); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + $this->assertEquals(1, count($tableDiff->changedForeignKeys)); + } + + public function testTablesCaseInsensitive() + { + $schemaA = new Schema(); + $schemaA->createTable('foo'); + $schemaA->createTable('bAr'); + $schemaA->createTable('BAZ'); + $schemaA->createTable('new'); + + $schemaB = new Schema(); + $schemaB->createTable('FOO'); + $schemaB->createTable('bar'); + $schemaB->createTable('Baz'); + $schemaB->createTable('old'); + + $c = new Comparator(); + $diff = $c->compare($schemaA, $schemaB); + + $this->assertSchemaTableChangeCount($diff, 1, 0, 1); + } + + public function testSequencesCaseInsenstive() + { + $schemaA = new Schema(); + $schemaA->createSequence('foo'); + $schemaA->createSequence('BAR'); + $schemaA->createSequence('Baz'); + $schemaA->createSequence('new'); + + $schemaB = new Schema(); + $schemaB->createSequence('FOO'); + $schemaB->createSequence('Bar'); + $schemaB->createSequence('baz'); + $schemaB->createSequence('old'); + + $c = new Comparator(); + $diff = $c->compare($schemaA, $schemaB); + + $this->assertSchemaSequenceChangeCount($diff, 1, 0, 1); + } + + public function testCompareColumnCompareCaseInsensitive() + { + $tableA = new Table("foo"); + $tableA->addColumn('id', 'integer'); + + $tableB = new Table("foo"); + $tableB->addColumn('ID', 'integer'); + + $c = new Comparator(); + $tableDiff = $c->diffTable($tableA, $tableB); + + $this->assertFalse($tableDiff); + } + + public function testCompareIndexBasedOnPropertiesNotName() + { + $tableA = new Table("foo"); + $tableA->addColumn('id', 'integer'); + $tableA->addIndex(array("id"), "foo_bar_idx"); + + $tableB = new Table("foo"); + $tableB->addColumn('ID', 'integer'); + $tableB->addIndex(array("id"), "bar_foo_idx"); + + $c = new Comparator(); + $tableDiff = $c->diffTable($tableA, $tableB); + + $this->assertFalse($tableDiff); + } + + public function testCompareForeignKeyBasedOnPropertiesNotName() + { + $tableA = new Table("foo"); + $tableA->addColumn('id', 'integer'); + $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id')); + + $tableB = new Table("foo"); + $tableB->addColumn('ID', 'integer'); + $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id')); + + $c = new Comparator(); + $tableDiff = $c->diffTable($tableA, $tableB); + + $this->assertFalse($tableDiff); + } + + public function testCompareForeignKey_RestrictNoAction_AreTheSame() + { + $fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION')); + $fk2 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'RESTRICT')); + + $c = new Comparator(); + $this->assertFalse($c->diffForeignKey($fk1, $fk2)); + } + + public function testDetectRenameColumn() + { + $tableA = new Table("foo"); + $tableA->addColumn('foo', 'integer'); + + $tableB = new Table("foo"); + $tableB->addColumn('bar', 'integer'); + + $c = new Comparator(); + $tableDiff = $c->diffTable($tableA, $tableB); + + $this->assertEquals(0, count($tableDiff->addedColumns)); + $this->assertEquals(0, count($tableDiff->removedColumns)); + $this->assertArrayHasKey('foo', $tableDiff->renamedColumns); + $this->assertEquals('bar', $tableDiff->renamedColumns['foo']->getName()); + } + + /** + * You can easily have ambiguouties in the column renaming. If these + * are detected no renaming should take place, instead adding and dropping + * should be used exclusively. + * + * @group DBAL-24 + */ + public function testDetectRenameColumnAmbiguous() + { + $tableA = new Table("foo"); + $tableA->addColumn('foo', 'integer'); + $tableA->addColumn('bar', 'integer'); + + $tableB = new Table("foo"); + $tableB->addColumn('baz', 'integer'); + + $c = new Comparator(); + $tableDiff = $c->diffTable($tableA, $tableB); + + $this->assertEquals(1, count($tableDiff->addedColumns), "'baz' should be added, not created through renaming!"); + $this->assertArrayHasKey('baz', $tableDiff->addedColumns, "'baz' should be added, not created through renaming!"); + $this->assertEquals(2, count($tableDiff->removedColumns), "'foo' and 'bar' should both be dropped, an ambigouty exists which one could be renamed to 'baz'."); + $this->assertArrayHasKey('foo', $tableDiff->removedColumns, "'foo' should be removed."); + $this->assertArrayHasKey('bar', $tableDiff->removedColumns, "'bar' should be removed."); + $this->assertEquals(0, count($tableDiff->renamedColumns), "no renamings should take place."); + } + + public function testDetectChangeIdentifierType() + { + $this->markTestSkipped('DBAL-2 was reopened, this test cannot work anymore.'); + + $tableA = new Table("foo"); + $tableA->addColumn('id', 'integer', array('autoincrement' => false)); + + $tableB = new Table("foo"); + $tableB->addColumn('id', 'integer', array('autoincrement' => true)); + + $c = new Comparator(); + $tableDiff = $c->diffTable($tableA, $tableB); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + $this->assertArrayHasKey('id', $tableDiff->changedColumns); + } + + + /** + * @group DBAL-105 + */ + public function testDiff() + { + $table = new \Doctrine\DBAL\Schema\Table('twitter_users'); + $table->addColumn('id', 'integer', array('autoincrement' => true)); + $table->addColumn('twitterId', 'integer', array('nullable' => false)); + $table->addColumn('displayName', 'string', array('nullable' => false)); + $table->setPrimaryKey(array('id')); + + $newtable = new \Doctrine\DBAL\Schema\Table('twitter_users'); + $newtable->addColumn('id', 'integer', array('autoincrement' => true)); + $newtable->addColumn('twitter_id', 'integer', array('nullable' => false)); + $newtable->addColumn('display_name', 'string', array('nullable' => false)); + $newtable->addColumn('logged_in_at', 'datetime', array('nullable' => true)); + $newtable->setPrimaryKey(array('id')); + + $c = new Comparator(); + $tableDiff = $c->diffTable($table, $newtable); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + $this->assertEquals(array('twitterid', 'displayname'), array_keys($tableDiff->renamedColumns)); + $this->assertEquals(array('logged_in_at'), array_keys($tableDiff->addedColumns)); + $this->assertEquals(0, count($tableDiff->removedColumns)); + } + + + /** + * @group DBAL-112 + */ + public function testChangedSequence() + { + $schema = new Schema(); + $sequence = $schema->createSequence('baz'); + + $schemaNew = clone $schema; + /* @var $schemaNew Schema */ + $schemaNew->getSequence('baz')->setAllocationSize(20); + + $c = new \Doctrine\DBAL\Schema\Comparator; + $diff = $c->compare($schema, $schemaNew); + + $this->assertSame($diff->changedSequences[0] , $schemaNew->getSequence('baz')); + } + + /** + * @group DBAL-106 + */ + public function testDiffDecimalWithNullPrecision() + { + $column = new Column('foo', Type::getType('decimal')); + $column->setPrecision(null); + + $column2 = new Column('foo', Type::getType('decimal')); + + $c = new Comparator(); + $this->assertEquals(array(), $c->diffColumn($column, $column2)); + } + + /** + * @group DBAL-204 + */ + public function testFqnSchemaComparision() + { + $config = new SchemaConfig(); + $config->setName("foo"); + + $oldSchema = new Schema(array(), array(), $config); + $oldSchema->createTable('bar'); + + $newSchema= new Schema(array(), array(), $config); + $newSchema->createTable('foo.bar'); + + $c = new Comparator(); + $this->assertEquals(new SchemaDiff(), $c->compare($oldSchema, $newSchema)); + } + + /** + * @group DBAL-204 + */ + public function testFqnSchemaComparisionDifferentSchemaNameButSameTableNoDiff() + { + $config = new SchemaConfig(); + $config->setName("foo"); + + $oldSchema = new Schema(array(), array(), $config); + $oldSchema->createTable('foo.bar'); + + $newSchema = new Schema(); + $newSchema->createTable('bar'); + + $c = new Comparator(); + $diff = $c->compare($oldSchema, $newSchema); + $this->assertEquals(new SchemaDiff(), $c->compare($oldSchema, $newSchema)); + } + + /** + * @group DBAL-204 + */ + public function testFqnSchemaComparisionNoSchemaSame() + { + $config = new SchemaConfig(); + $config->setName("foo"); + $oldSchema = new Schema(array(), array(), $config); + $oldSchema->createTable('bar'); + + $newSchema = new Schema(); + $newSchema->createTable('bar'); + + $c = new Comparator(); + $diff = $c->compare($oldSchema, $newSchema); + + $this->assertEquals(new SchemaDiff(), $c->compare($oldSchema, $newSchema)); + } + + /** + * @param SchemaDiff $diff + * @param int $newTableCount + * @param int $changeTableCount + * @param int $removeTableCount + */ + public function assertSchemaTableChangeCount($diff, $newTableCount=0, $changeTableCount=0, $removeTableCount=0) + { + $this->assertEquals($newTableCount, count($diff->newTables)); + $this->assertEquals($changeTableCount, count($diff->changedTables)); + $this->assertEquals($removeTableCount, count($diff->removedTables)); + } + + /** + * @param SchemaDiff $diff + * @param int $newSequenceCount + * @param int $changeSequenceCount + * @param int $changeSequenceCount + */ + public function assertSchemaSequenceChangeCount($diff, $newSequenceCount=0, $changeSequenceCount=0, $removeSequenceCount=0) + { + $this->assertEquals($newSequenceCount, count($diff->newSequences), "Expected number of new sequences is wrong."); + $this->assertEquals($changeSequenceCount, count($diff->changedSequences), "Expected number of changed sequences is wrong."); + $this->assertEquals($removeSequenceCount, count($diff->removedSequences), "Expected number of removed sequences is wrong."); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php new file mode 100644 index 0000000..6d5f5b8 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php @@ -0,0 +1,99 @@ +createIndex(); + $this->assertEquals("foo", $idx->getName()); + $columns = $idx->getColumns(); + $this->assertEquals(2, count($columns)); + $this->assertEquals(array("bar", "baz"), $columns); + $this->assertFalse($idx->isUnique()); + $this->assertFalse($idx->isPrimary()); + } + + public function testCreatePrimary() + { + $idx = $this->createIndex(false, true); + $this->assertTrue($idx->isUnique()); + $this->assertTrue($idx->isPrimary()); + } + + public function testCreateUnique() + { + $idx = $this->createIndex(true, false); + $this->assertTrue($idx->isUnique()); + $this->assertFalse($idx->isPrimary()); + } + + /** + * @group DBAL-50 + */ + public function testFullfilledByUnique() + { + $idx1 = $this->createIndex(true, false); + $idx2 = $this->createIndex(true, false); + $idx3 = $this->createIndex(); + + $this->assertTrue($idx1->isFullfilledBy($idx2)); + $this->assertFalse($idx1->isFullfilledBy($idx3)); + } + + /** + * @group DBAL-50 + */ + public function testFullfilledByPrimary() + { + $idx1 = $this->createIndex(true, true); + $idx2 = $this->createIndex(true, true); + $idx3 = $this->createIndex(true, false); + + $this->assertTrue($idx1->isFullfilledBy($idx2)); + $this->assertFalse($idx1->isFullfilledBy($idx3)); + } + + /** + * @group DBAL-50 + */ + public function testFullfilledByIndex() + { + $idx1 = $this->createIndex(); + $idx2 = $this->createIndex(); + $pri = $this->createIndex(true, true); + $uniq = $this->createIndex(true); + + $this->assertTrue($idx1->isFullfilledBy($idx2)); + $this->assertTrue($idx1->isFullfilledBy($pri)); + $this->assertTrue($idx1->isFullfilledBy($uniq)); + } + + /** + * @group DBAL-285 + */ + public function testIndexQuotes() + { + $index = new Index("foo", array("`bar`", "`baz`")); + + $this->assertTrue($index->spansColumns(array("bar", "baz"))); + $this->assertTrue($index->hasColumnAtPosition("bar", 0)); + $this->assertTrue($index->hasColumnAtPosition("baz", 1)); + + $this->assertFalse($index->hasColumnAtPosition("bar", 1)); + $this->assertFalse($index->hasColumnAtPosition("baz", 0)); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php new file mode 100644 index 0000000..e5033d6 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php @@ -0,0 +1,76 @@ +getMock('Doctrine\DBAL\Driver'); + $platform = $this->getMock('Doctrine\DBAL\Platforms\MySqlPlatform'); + $this->conn = $this->getMock( + 'Doctrine\DBAL\Connection', + array('fetchAll'), + array(array('platform' => $platform), $driverMock, new Configuration(), $eventManager) + ); + $this->manager = new MySqlSchemaManager($this->conn); + } + + public function testCompositeForeignKeys() + { + $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue($this->getFKDefinition())); + $fkeys = $this->manager->listTableForeignKeys('dummy'); + $this->assertEquals(1, count($fkeys), "Table has to have one foreign key."); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); + $this->assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getLocalColumns())); + $this->assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getForeignColumns())); + } + + public function getFKDefinition() + { + return array( + array( + "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E", + "COLUMN_NAME" => "column_1", + "REFERENCED_TABLE_NAME" => "dummy", + "REFERENCED_COLUMN_NAME" => "column_1", + "update_rule" => "RESTRICT", + "delete_rule" => "RESTRICT", + ), + array( + "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E", + "COLUMN_NAME" => "column_2", + "REFERENCED_TABLE_NAME" => "dummy", + "REFERENCED_COLUMN_NAME" => "column_2", + "update_rule" => "RESTRICT", + "delete_rule" => "RESTRICT", + ), + array( + "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E", + "COLUMN_NAME" => "column_3", + "REFERENCED_TABLE_NAME" => "dummy", + "REFERENCED_COLUMN_NAME" => "column_3", + "update_rule" => "RESTRICT", + "delete_rule" => "RESTRICT", + ) + ); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php new file mode 100644 index 0000000..36f362e --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php @@ -0,0 +1,67 @@ +comparator = new \Doctrine\DBAL\Schema\Comparator; + $this->platform = new \Doctrine\DBAL\Platforms\MySqlPlatform; + } + + public function testSwitchPrimaryKeyOrder() + { + $tableOld = new Table("test"); + $tableOld->addColumn('foo_id', 'integer'); + $tableOld->addColumn('bar_id', 'integer'); + $tableNew = clone $tableOld; + + $tableOld->setPrimaryKey(array('foo_id', 'bar_id')); + $tableNew->setPrimaryKey(array('bar_id', 'foo_id')); + + $diff = $this->comparator->diffTable($tableOld, $tableNew); + $sql = $this->platform->getAlterTableSQL($diff); + + $this->assertEquals( + array( + 'ALTER TABLE test DROP PRIMARY KEY', + 'ALTER TABLE test ADD PRIMARY KEY (bar_id, foo_id)' + ), $sql + ); + } + + /** + * @group DBAL-132 + */ + public function testGenerateForeignKeySQL() + { + $tableOld = new Table("test"); + $tableOld->addColumn('foo_id', 'integer'); + $tableOld->addUnnamedForeignKeyConstraint('test_foreign', array('foo_id'), array('foo_id')); + + $sqls = array(); + foreach ($tableOld->getForeignKeys() AS $fk) { + $sqls[] = $this->platform->getCreateForeignKeySQL($fk, $tableOld); + } + + $this->assertEquals(array("ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C8E48560F FOREIGN KEY (foo_id) REFERENCES test_foreign (foo_id)"), $sqls); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php new file mode 100644 index 0000000..16bf92a --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php @@ -0,0 +1,109 @@ +createSchemaDiff(); + $platform = $this->createPlatform(true); + + $sql = $diff->toSql($platform); + + $expected = array('drop_orphan_fk', 'alter_seq', 'drop_seq', 'create_seq', 'create_table', 'create_foreign_key', 'drop_table', 'alter_table'); + + $this->assertEquals($expected, $sql); + } + + public function testSchemaDiffToSaveSql() + { + $diff = $this->createSchemaDiff(); + $platform = $this->createPlatform(false); + + $sql = $diff->toSaveSql($platform); + + $expected = array('alter_seq', 'create_seq', 'create_table', 'create_foreign_key', 'alter_table'); + + $this->assertEquals($expected, $sql); + } + + public function createPlatform($unsafe = false) + { + $platform = $this->getMock('Doctrine\Tests\DBAL\Mocks\MockPlatform'); + if ($unsafe) { + $platform->expects($this->exactly(1)) + ->method('getDropSequenceSql') + ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) + ->will($this->returnValue('drop_seq')); + } + $platform->expects($this->exactly(1)) + ->method('getAlterSequenceSql') + ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) + ->will($this->returnValue('alter_seq')); + $platform->expects($this->exactly(1)) + ->method('getCreateSequenceSql') + ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) + ->will($this->returnValue('create_seq')); + if ($unsafe) { + $platform->expects($this->exactly(1)) + ->method('getDropTableSql') + ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) + ->will($this->returnValue('drop_table')); + } + $platform->expects($this->exactly(1)) + ->method('getCreateTableSql') + ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) + ->will($this->returnValue(array('create_table'))); + $platform->expects($this->exactly(1)) + ->method('getCreateForeignKeySQL') + ->with($this->isInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint')) + ->will($this->returnValue('create_foreign_key')); + $platform->expects($this->exactly(1)) + ->method('getAlterTableSql') + ->with($this->isInstanceOf('Doctrine\DBAL\Schema\TableDiff')) + ->will($this->returnValue(array('alter_table'))); + if ($unsafe) { + $platform->expects($this->exactly(1)) + ->method('getDropForeignKeySql') + ->with($this->isInstanceof('Doctrine\DBAL\Schema\ForeignKeyConstraint'), $this->equalTo('local_table')) + ->will($this->returnValue('drop_orphan_fk')); + } + $platform->expects($this->exactly(1)) + ->method('supportsSequences') + ->will($this->returnValue(true)); + $platform->expects($this->exactly(2)) + ->method('supportsForeignKeyConstraints') + ->will($this->returnValue(true)); + return $platform; + } + + public function createSchemaDiff() + { + $diff = new SchemaDiff(); + $diff->changedSequences['foo_seq'] = new Sequence('foo_seq'); + $diff->newSequences['bar_seq'] = new Sequence('bar_seq'); + $diff->removedSequences['baz_seq'] = new Sequence('baz_seq'); + $diff->newTables['foo_table'] = new Table('foo_table'); + $diff->removedTables['bar_table'] = new Table('bar_table'); + $diff->changedTables['baz_table'] = new TableDiff('baz_table'); + $diff->newTables['foo_table']->addColumn('foreign_id', 'integer'); + $diff->newTables['foo_table']->addForeignKeyConstraint('foreign_table', array('foreign_id'), array('id')); + $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('id'), 'foreign_table', array('id')); + $fk->setLocalTable(new Table('local_table')); + $diff->orphanedForeignKeys[] = $fk; + return $diff; + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php new file mode 100644 index 0000000..096ede7 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -0,0 +1,224 @@ +assertTrue($schema->hasTable($tableName)); + + $tables = $schema->getTables(); + $this->assertTrue( isset($tables[$tableName]) ); + $this->assertSame($table, $tables[$tableName]); + $this->assertSame($table, $schema->getTable($tableName)); + $this->assertTrue($schema->hasTable($tableName)); + } + + public function testTableMatchingCaseInsenstive() + { + $table = new Table("Foo"); + + $schema = new Schema(array($table)); + $this->assertTrue($schema->hasTable("foo")); + $this->assertTrue($schema->hasTable("FOO")); + + $this->assertSame($table, $schema->getTable('FOO')); + $this->assertSame($table, $schema->getTable('foo')); + $this->assertSame($table, $schema->getTable('Foo')); + } + + public function testGetUnknownTableThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $schema = new Schema(); + $schema->getTable("unknown"); + } + + public function testCreateTableTwiceThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $tableName = "foo"; + $table = new Table($tableName); + $tables = array($table, $table); + + $schema = new Schema($tables); + } + + public function testRenameTable() + { + $tableName = "foo"; + $table = new Table($tableName); + $schema = new Schema(array($table)); + + $this->assertTrue($schema->hasTable("foo")); + $schema->renameTable("foo", "bar"); + $this->assertFalse($schema->hasTable("foo")); + $this->assertTrue($schema->hasTable("bar")); + $this->assertSame($table, $schema->getTable("bar")); + } + + public function testDropTable() + { + $tableName = "foo"; + $table = new Table($tableName); + $schema = new Schema(array($table)); + + $this->assertTrue($schema->hasTable("foo")); + + $schema->dropTable("foo"); + + $this->assertFalse($schema->hasTable("foo")); + } + + public function testCreateTable() + { + $schema = new Schema(); + + $this->assertFalse($schema->hasTable("foo")); + + $table = $schema->createTable("foo"); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table); + $this->assertEquals("foo", $table->getName()); + $this->assertTrue($schema->hasTable("foo")); + } + + public function testAddSequences() + { + $sequence = new Sequence("a_seq", 1, 1); + + $schema = new Schema(array(), array($sequence)); + + $this->assertTrue($schema->hasSequence("a_seq")); + $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq")); + + $sequences = $schema->getSequences(); + $this->assertArrayHasKey('public.a_seq', $sequences); + } + + public function testSequenceAccessCaseInsensitive() + { + $sequence = new Sequence("a_Seq"); + + $schema = new Schema(array(), array($sequence)); + $this->assertTrue($schema->hasSequence('a_seq')); + $this->assertTrue($schema->hasSequence('a_Seq')); + $this->assertTrue($schema->hasSequence('A_SEQ')); + + $this->assertEquals($sequence, $schema->getSequence('a_seq')); + $this->assertEquals($sequence, $schema->getSequence('a_Seq')); + $this->assertEquals($sequence, $schema->getSequence('A_SEQ')); + } + + public function testGetUnknownSequenceThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $schema = new Schema(); + $schema->getSequence("unknown"); + } + + public function testCreateSequence() + { + $schema = new Schema(); + $sequence = $schema->createSequence('a_seq', 10, 20); + + $this->assertEquals('a_seq', $sequence->getName()); + $this->assertEquals(10, $sequence->getAllocationSize()); + $this->assertEquals(20, $sequence->getInitialValue()); + + $this->assertTrue($schema->hasSequence("a_seq")); + $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq")); + + $sequences = $schema->getSequences(); + $this->assertArrayHasKey('public.a_seq', $sequences); + } + + public function testDropSequence() + { + $sequence = new Sequence("a_seq", 1, 1); + + $schema = new Schema(array(), array($sequence)); + + $schema->dropSequence("a_seq"); + $this->assertFalse($schema->hasSequence("a_seq")); + } + + public function testAddSequenceTwiceThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $sequence = new Sequence("a_seq", 1, 1); + + $schema = new Schema(array(), array($sequence, $sequence)); + } + + public function testConfigMaxIdentifierLength() + { + $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig(); + $schemaConfig->setMaxIdentifierLength(5); + + $schema = new Schema(array(), array(), $schemaConfig); + $table = $schema->createTable("smalltable"); + $table->addColumn('long_id', 'integer'); + $table->addIndex(array('long_id')); + + $index = current($table->getIndexes()); + $this->assertEquals(5, strlen($index->getName())); + } + + public function testDeepClone() + { + $schema = new Schema(); + $sequence = $schema->createSequence('baz'); + + $tableA = $schema->createTable('foo'); + $tableA->addColumn('id', 'integer'); + + $tableB = $schema->createTable('bar'); + $tableB->addColumn('id', 'integer'); + $tableB->addColumn('foo_id', 'integer'); + $tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id')); + + $schemaNew = clone $schema; + + $this->assertNotSame($sequence, $schemaNew->getSequence('baz')); + + $this->assertNotSame($tableA, $schemaNew->getTable('foo')); + $this->assertNotSame($tableA->getColumn('id'), $schemaNew->getTable('foo')->getColumn('id')); + + $this->assertNotSame($tableB, $schemaNew->getTable('bar')); + $this->assertNotSame($tableB->getColumn('id'), $schemaNew->getTable('bar')->getColumn('id')); + + $fk = $schemaNew->getTable('bar')->getForeignKeys(); + $fk = current($fk); + $this->assertSame($schemaNew->getTable('bar'), $this->readAttribute($fk, '_localTable')); + } + + /** + * @group DBAL-219 + */ + public function testHasTableForQuotedAsset() + { + $schema = new Schema(); + + $tableA = $schema->createTable('foo'); + $tableA->addColumn('id', 'integer'); + + $this->assertTrue($schema->hasTable('`foo`')); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php new file mode 100644 index 0000000..778ad56 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php @@ -0,0 +1,500 @@ +setExpectedException('Doctrine\DBAL\DBALException'); + $table = new \Doctrine\DBAL\Schema\Table(''); + } + + public function testGetName() + { + $table = new Table("foo", array(), array(), array()); + $this->assertEquals("foo", $table->getName()); + } + + public function testColumns() + { + $type = Type::getType('integer'); + $columns = array(); + $columns[] = new Column("foo", $type); + $columns[] = new Column("bar", $type); + $table = new Table("foo", $columns, array(), array()); + + $this->assertTrue($table->hasColumn("foo")); + $this->assertTrue($table->hasColumn("bar")); + $this->assertFalse($table->hasColumn("baz")); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("foo")); + $this->assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("bar")); + + $this->assertEquals(2, count($table->getColumns())); + } + + public function testColumnsCaseInsensitive() + { + $table = new Table("foo"); + $column = $table->addColumn('Foo', 'integer'); + + $this->assertTrue($table->hasColumn('Foo')); + $this->assertTrue($table->hasColumn('foo')); + $this->assertTrue($table->hasColumn('FOO')); + + $this->assertSame($column, $table->getColumn('Foo')); + $this->assertSame($column, $table->getColumn('foo')); + $this->assertSame($column, $table->getColumn('FOO')); + } + + public function testCreateColumn() + { + $type = Type::getType('integer'); + + $table = new Table("foo"); + + $this->assertFalse($table->hasColumn("bar")); + $table->addColumn("bar", 'integer'); + $this->assertTrue($table->hasColumn("bar")); + $this->assertSame($type, $table->getColumn("bar")->getType()); + } + + public function testDropColumn() + { + $type = Type::getType('integer'); + $columns = array(); + $columns[] = new Column("foo", $type); + $columns[] = new Column("bar", $type); + $table = new Table("foo", $columns, array(), array()); + + $this->assertTrue($table->hasColumn("foo")); + $this->assertTrue($table->hasColumn("bar")); + + $table->dropColumn("foo")->dropColumn("bar"); + + $this->assertFalse($table->hasColumn("foo")); + $this->assertFalse($table->hasColumn("bar")); + } + + public function testGetUnknownColumnThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $table = new Table("foo", array(), array(), array()); + $table->getColumn('unknown'); + } + + public function testAddColumnTwiceThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $type = \Doctrine\DBAL\Types\Type::getType('integer'); + $columns = array(); + $columns[] = new Column("foo", $type); + $columns[] = new Column("foo", $type); + $table = new Table("foo", $columns, array(), array()); + } + + public function testCreateIndex() + { + $type = \Doctrine\DBAL\Types\Type::getType('integer'); + $columns = array(new Column("foo", $type), new Column("bar", $type), new Column("baz", $type)); + $table = new Table("foo", $columns); + + $table->addIndex(array("foo", "bar"), "foo_foo_bar_idx"); + $table->addUniqueIndex(array("bar", "baz"), "foo_bar_baz_uniq"); + + $this->assertTrue($table->hasIndex("foo_foo_bar_idx")); + $this->assertTrue($table->hasIndex("foo_bar_baz_uniq")); + } + + public function testIndexCaseInsensitive() + { + $type = \Doctrine\DBAL\Types\Type::getType('integer'); + $columns = array( + new Column("foo", $type), + new Column("bar", $type), + new Column("baz", $type) + ); + $table = new Table("foo", $columns); + + $table->addIndex(array("foo", "bar", "baz"), "Foo_Idx"); + + $this->assertTrue($table->hasIndex('foo_idx')); + $this->assertTrue($table->hasIndex('Foo_Idx')); + $this->assertTrue($table->hasIndex('FOO_IDX')); + } + + public function testAddIndexes() + { + $type = \Doctrine\DBAL\Types\Type::getType('integer'); + $columns = array( + new Column("foo", $type), + new Column("bar", $type), + ); + $indexes = array( + new Index("the_primary", array("foo"), true, true), + new Index("bar_idx", array("bar"), false, false), + ); + $table = new Table("foo", $columns, $indexes, array()); + + $this->assertTrue($table->hasIndex("the_primary")); + $this->assertTrue($table->hasIndex("bar_idx")); + $this->assertFalse($table->hasIndex("some_idx")); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey()); + $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('the_primary')); + $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('bar_idx')); + } + + public function testGetUnknownIndexThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $table = new Table("foo", array(), array(), array()); + $table->getIndex("unknownIndex"); + } + + public function testAddTwoPrimaryThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $type = \Doctrine\DBAL\Types\Type::getType('integer'); + $columns = array(new Column("foo", $type), new Column("bar", $type)); + $indexes = array( + new Index("the_primary", array("foo"), true, true), + new Index("other_primary", array("bar"), true, true), + ); + $table = new Table("foo", $columns, $indexes, array()); + } + + public function testAddTwoIndexesWithSameNameThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $type = \Doctrine\DBAL\Types\Type::getType('integer'); + $columns = array(new Column("foo", $type), new Column("bar", $type)); + $indexes = array( + new Index("an_idx", array("foo"), false, false), + new Index("an_idx", array("bar"), false, false), + ); + $table = new Table("foo", $columns, $indexes, array()); + } + + public function testConstraints() + { + $constraint = new ForeignKeyConstraint(array(), "foo", array()); + + $tableA = new Table("foo", array(), array(), array($constraint)); + $constraints = $tableA->getForeignKeys(); + + $this->assertEquals(1, count($constraints)); + $this->assertSame($constraint, array_shift($constraints)); + } + + public function testOptions() + { + $table = new Table("foo", array(), array(), array(), false, array("foo" => "bar")); + + $this->assertTrue($table->hasOption("foo")); + $this->assertEquals("bar", $table->getOption("foo")); + } + + public function testBuilderSetPrimaryKey() + { + $table = new Table("foo"); + + $table->addColumn("bar", 'integer'); + $table->setPrimaryKey(array("bar")); + + $this->assertTrue($table->hasIndex("primary")); + $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey()); + $this->assertTrue($table->getIndex("primary")->isUnique()); + $this->assertTrue($table->getIndex("primary")->isPrimary()); + } + + public function testBuilderAddUniqueIndex() + { + $table = new Table("foo"); + + $table->addColumn("bar", 'integer'); + $table->addUniqueIndex(array("bar"), "my_idx"); + + $this->assertTrue($table->hasIndex("my_idx")); + $this->assertTrue($table->getIndex("my_idx")->isUnique()); + $this->assertFalse($table->getIndex("my_idx")->isPrimary()); + } + + public function testBuilderAddIndex() + { + $table = new Table("foo"); + + $table->addColumn("bar", 'integer'); + $table->addIndex(array("bar"), "my_idx"); + + $this->assertTrue($table->hasIndex("my_idx")); + $this->assertFalse($table->getIndex("my_idx")->isUnique()); + $this->assertFalse($table->getIndex("my_idx")->isPrimary()); + } + + public function testBuilderAddIndexWithInvalidNameThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $table = new Table("foo"); + $table->addColumn("bar",'integer'); + $table->addIndex(array("bar"), "invalid name %&/"); + } + + public function testBuilderAddIndexWithUnknownColumnThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $table = new Table("foo"); + $table->addIndex(array("bar"), "invalidName"); + } + + public function testBuilderOptions() + { + $table = new Table("foo"); + $table->addOption("foo", "bar"); + $this->assertTrue($table->hasOption("foo")); + $this->assertEquals("bar", $table->getOption("foo")); + } + + public function testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $table = new Table("foo"); + $table->addColumn("id", 'integer'); + + $foreignTable = new Table("bar"); + $foreignTable->addColumn("id", 'integer'); + + $table->addForeignKeyConstraint($foreignTable, array("foo"), array("id")); + } + + public function testAddForeignKeyConstraint_UnknownForeignColumn_ThrowsException() + { + $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException"); + + $table = new Table("foo"); + $table->addColumn("id", 'integer'); + + $foreignTable = new Table("bar"); + $foreignTable->addColumn("id", 'integer'); + + $table->addForeignKeyConstraint($foreignTable, array("id"), array("foo")); + } + + public function testAddForeignKeyConstraint() + { + $table = new Table("foo"); + $table->addColumn("id", 'integer'); + + $foreignTable = new Table("bar"); + $foreignTable->addColumn("id", 'integer'); + + $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar")); + + $constraints = $table->getForeignKeys(); + $this->assertEquals(1, count($constraints)); + $constraint = current($constraints); + + $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $constraint); + + $this->assertTrue($constraint->hasOption("foo")); + $this->assertEquals("bar", $constraint->getOption("foo")); + } + + public function testAddIndexWithCaseSensitiveColumnProblem() + { + $table = new Table("foo"); + $table->addColumn("id", 'integer'); + + $table->addIndex(array("ID"), "my_idx"); + + $this->assertTrue($table->hasIndex('my_idx')); + $this->assertEquals(array("ID"), $table->getIndex("my_idx")->getColumns()); + $this->assertTrue($table->getIndex('my_idx')->spansColumns(array('id'))); + } + + public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull() + { + $table = new Table("foo"); + $column = $table->addColumn("id", 'integer', array('notnull' => false)); + + $this->assertFalse($column->getNotnull()); + + $table->setPrimaryKey(array('id')); + + $this->assertTrue($column->getNotnull()); + } + + /** + * @group DDC-133 + */ + public function testAllowImplicitSchemaTableInAutogeneratedIndexNames() + { + $table = new Table("foo.bar"); + $table->addColumn('baz', 'integer', array()); + $table->addIndex(array('baz')); + + $this->assertEquals(1, count($table->getIndexes())); + } + + /** + * @group DBAL-50 + */ + public function testAddIndexTwice_IgnoreSecond() + { + $table = new Table("foo.bar"); + $table->addColumn('baz', 'integer', array()); + $table->addIndex(array('baz')); + $table->addIndex(array('baz')); + + $this->assertEquals(1, count($table->getIndexes())); + } + + /** + * @group DBAL-50 + */ + public function testAddForeignKeyIndexImplicitly() + { + $table = new Table("foo"); + $table->addColumn("id", 'integer'); + + $foreignTable = new Table("bar"); + $foreignTable->addColumn("id", 'integer'); + + $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar")); + + $indexes = $table->getIndexes(); + $this->assertEquals(1, count($indexes)); + $index = current($indexes); + + $this->assertTrue($table->hasIndex($index->getName())); + $this->assertEquals(array('id'), $index->getColumns()); + } + + /** + * @group DBAL-50 + */ + public function testOverruleIndex() + { + $table = new Table("bar"); + $table->addColumn('baz', 'integer', array()); + $table->addIndex(array('baz')); + + $indexes = $table->getIndexes(); + $this->assertEquals(1, count($indexes)); + $index = current($indexes); + + $table->addUniqueIndex(array('baz')); + $this->assertEquals(1, count($table->getIndexes())); + $this->assertFalse($table->hasIndex($index->getName())); + } + + public function testPrimaryKeyOverrulesUniqueIndex() + { + $table = new Table("bar"); + $table->addColumn('baz', 'integer', array()); + $table->addUniqueIndex(array('baz')); + + $table->setPrimaryKey(array('baz')); + + $indexes = $table->getIndexes(); + $this->assertEquals(1, count($indexes), "Table should only contain the primary key table index, not the unique one anymore, because it was overruled."); + + $index = current($indexes); + $this->assertTrue($index->isPrimary()); + } + + /** + * @group DBAL-64 + */ + public function testQuotedTableName() + { + $table = new Table("`bar`"); + + $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform(); + $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform(); + + $this->assertEquals('bar', $table->getName()); + $this->assertEquals('`bar`', $table->getQuotedName($mysqlPlatform)); + $this->assertEquals('"bar"', $table->getQuotedName($sqlitePlatform)); + } + + /** + * @group DBAL-79 + */ + public function testTableHasPrimaryKey() + { + $table = new Table("test"); + + $this->assertFalse($table->hasPrimaryKey()); + + $table->addColumn("foo", "integer"); + $table->setPrimaryKey(array("foo")); + + $this->assertTrue($table->hasPrimaryKey()); + } + + /** + * @group DBAL-91 + */ + public function testAddIndexWithQuotedColumns() + { + $table = new Table("test"); + $table->addColumn('"foo"', 'integer'); + $table->addColumn('bar', 'integer'); + $table->addIndex(array('"foo"', '"bar"')); + } + + /** + * @group DBAL-91 + */ + public function testAddForeignKeyWithQuotedColumnsAndTable() + { + $table = new Table("test"); + $table->addColumn('"foo"', 'integer'); + $table->addColumn('bar', 'integer'); + $table->addForeignKeyConstraint('"boing"', array('"foo"', '"bar"'), array("id")); + } + + /** + * @group DBAL-177 + */ + public function testQuoteSchemaPrefixed() + { + $table = new Table("`test`.`test`"); + $this->assertEquals("test.test", $table->getName()); + $this->assertEquals("`test`.`test`", $table->getQuotedName(new \Doctrine\DBAL\Platforms\MySqlPlatform)); + } + + /** + * @group DBAL-204 + */ + public function testFullQualifiedTableName() + { + $table = new Table("`test`.`test`"); + $this->assertEquals('test.test', $table->getFullQualifiedName("test")); + $this->assertEquals('test.test', $table->getFullQualifiedName("other")); + + $table = new Table("test"); + $this->assertEquals('test.test', $table->getFullQualifiedName("test")); + $this->assertEquals('other.test', $table->getFullQualifiedName("other")); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php new file mode 100644 index 0000000..e5b660f --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php @@ -0,0 +1,77 @@ +setName("test"); + $schema = new Schema(array(), array(), $config); + + $schema->createTable("test.test"); + $schema->createTable("foo.bar"); + $schema->createTable("baz"); + + $schema->visit(new RemoveNamespacedAssets()); + + $tables = $schema->getTables(); + $this->assertEquals(array("test.test", "test.baz"), array_keys($tables), "Only 2 tables should be present, both in 'test' namespace."); + } + + /** + * @group DBAL-204 + */ + public function testCleanupForeignKeys() + { + $config = new SchemaConfig; + $config->setName("test"); + $schema = new Schema(array(), array(), $config); + + $fooTable = $schema->createTable("foo.bar"); + $fooTable->addColumn('id', 'integer'); + + $testTable = $schema->createTable("test.test"); + $testTable->addColumn('id', 'integer'); + + $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id")); + + $schema->visit(new RemoveNamespacedAssets()); + + $sql = $schema->toSql(new MySqlPlatform()); + $this->assertEquals(1, count($sql), "Just one CREATE TABLE statement, no foreign key and table to foo.bar"); + } + + /** + * @group DBAL-204 + */ + public function testCleanupForeignKeysDifferentOrder() + { + $config = new SchemaConfig; + $config->setName("test"); + $schema = new Schema(array(), array(), $config); + + $testTable = $schema->createTable("test.test"); + $testTable->addColumn('id', 'integer'); + + $fooTable = $schema->createTable("foo.bar"); + $fooTable->addColumn('id', 'integer'); + + $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id")); + + $schema->visit(new RemoveNamespacedAssets()); + + $sql = $schema->toSql(new MySqlPlatform()); + $this->assertEquals(1, count($sql), "Just one CREATE TABLE statement, no foreign key and table to foo.bar"); + } +} + diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php new file mode 100644 index 0000000..8dfd2b2 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php @@ -0,0 +1,80 @@ +getMock( + 'Doctrine\DBAL\Platforms\MySqlPlatform', + array('getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql') + ); + $platformMock->expects($this->exactly(2)) + ->method('getCreateTableSql') + ->will($this->returnValue(array("foo"))); + $platformMock->expects($this->exactly(1)) + ->method('getCreateSequenceSql') + ->will($this->returnValue(array("bar"))); + $platformMock->expects($this->exactly(1)) + ->method('getCreateForeignKeySql') + ->will($this->returnValue(array("baz"))); + + $schema = $this->createFixtureSchema(); + + $sql = $schema->toSql($platformMock); + + $this->assertEquals(array("foo", "foo", "bar", "baz"), $sql); + } + + public function testDropSchema() + { + $platformMock = $this->getMock( + 'Doctrine\DBAL\Platforms\MySqlPlatform', + array('getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql') + ); + $platformMock->expects($this->exactly(2)) + ->method('getDropTableSql') + ->will($this->returnValue("tbl")); + $platformMock->expects($this->exactly(1)) + ->method('getDropSequenceSql') + ->will($this->returnValue("seq")); + $platformMock->expects($this->exactly(1)) + ->method('getDropForeignKeySql') + ->will($this->returnValue("fk")); + + $schema = $this->createFixtureSchema(); + + $sql = $schema->toDropSql($platformMock); + + $this->assertEquals(array("fk", "seq", "tbl", "tbl"), $sql); + } + + /** + * @return Schema + */ + public function createFixtureSchema() + { + $schema = new Schema(); + $tableA = $schema->createTable("foo"); + $tableA->addColumn("id", 'integer'); + $tableA->addColumn("bar", 'string', array('length' => 255)); + $tableA->setPrimaryKey(array("id")); + + $schema->createSequence("foo_seq"); + + $tableB = $schema->createTable("bar"); + $tableB->addColumn("id", 'integer'); + $tableB->setPrimaryKey(array("id")); + + $tableA->addForeignKeyConstraint($tableB, array("bar"), array("id")); + + return $schema; + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php new file mode 100644 index 0000000..ac4244d --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php @@ -0,0 +1,61 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('array'); + } + + public function tearDown() + { + error_reporting(-1); // reactive all error levels + } + + + public function testArrayConvertsToDatabaseValue() + { + $this->assertTrue( + is_string($this->_type->convertToDatabaseValue(array(), $this->_platform)) + ); + } + + public function testArrayConvertsToPHPValue() + { + $this->assertTrue( + is_array($this->_type->convertToPHPValue(serialize(array()), $this->_platform)) + ); + } + + public function testConversionFailure() + { + error_reporting( (E_ALL | E_STRICT) - \E_NOTICE ); + $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); + $this->_type->convertToPHPValue('abcdefg', $this->_platform); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } + + /** + * @group DBAL-73 + */ + public function testFalseConversion() + { + $this->assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BlobTest.php new file mode 100644 index 0000000..756487d --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BlobTest.php @@ -0,0 +1,26 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('blob'); + } + + public function testBlobNullConvertsToPHPValue() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php new file mode 100644 index 0000000..753cfb4 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php @@ -0,0 +1,36 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('boolean'); + } + + public function testBooleanConvertsToDatabaseValue() + { + $this->assertInternalType('integer', $this->_type->convertToDatabaseValue(1, $this->_platform)); + } + + public function testBooleanConvertsToPHPValue() + { + $this->assertInternalType('bool', $this->_type->convertToPHPValue(0, $this->_platform)); + } + + public function testBooleanNullConvertsToPHPValue() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTest.php new file mode 100644 index 0000000..8d97640 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTest.php @@ -0,0 +1,75 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('date'); + $this->_tz = date_default_timezone_get(); + } + + public function tearDown() + { + date_default_timezone_set($this->_tz); + } + + public function testDateConvertsToDatabaseValue() + { + $this->assertTrue( + is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform)) + ); + } + + public function testDateConvertsToPHPValue() + { + // Birthday of jwage and also birthday of Doctrine. Send him a present ;) + $this->assertTrue( + $this->_type->convertToPHPValue('1985-09-01', $this->_platform) + instanceof \DateTime + ); + } + + public function testDateResetsNonDatePartsToZeroUnixTimeValues() + { + $date = $this->_type->convertToPHPValue('1985-09-01', $this->_platform); + + $this->assertEquals('00:00:00', $date->format('H:i:s')); + } + + public function testDateRests_SummerTimeAffection() + { + date_default_timezone_set('Europe/Berlin'); + + $date = $this->_type->convertToPHPValue('2009-08-01', $this->_platform); + $this->assertEquals('00:00:00', $date->format('H:i:s')); + $this->assertEquals('2009-08-01', $date->format('Y-m-d')); + + $date = $this->_type->convertToPHPValue('2009-11-01', $this->_platform); + $this->assertEquals('00:00:00', $date->format('H:i:s')); + $this->assertEquals('2009-11-01', $date->format('Y-m-d')); + } + + public function testInvalidDateFormatConversion() + { + $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); + $this->_type->convertToPHPValue('abcdefg', $this->_platform); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php new file mode 100644 index 0000000..f9674e7 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php @@ -0,0 +1,50 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('datetime'); + } + + public function testDateTimeConvertsToDatabaseValue() + { + $date = new \DateTime('1985-09-01 10:10:10'); + + $expected = $date->format($this->_platform->getDateTimeTzFormatString()); + $actual = $this->_type->convertToDatabaseValue($date, $this->_platform); + + $this->assertEquals($expected, $actual); + } + + public function testDateTimeConvertsToPHPValue() + { + // Birthday of jwage and also birthday of Doctrine. Send him a present ;) + $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform); + $this->assertInstanceOf('DateTime', $date); + $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); + } + + public function testInvalidDateTimeFormatConversion() + { + $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); + $this->_type->convertToPHPValue('abcdefg', $this->_platform); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php new file mode 100644 index 0000000..3e2ae17 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php @@ -0,0 +1,50 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('datetimetz'); + } + + public function testDateTimeConvertsToDatabaseValue() + { + $date = new \DateTime('1985-09-01 10:10:10'); + + $expected = $date->format($this->_platform->getDateTimeTzFormatString()); + $actual = $this->_type->convertToDatabaseValue($date, $this->_platform); + + $this->assertEquals($expected, $actual); + } + + public function testDateTimeConvertsToPHPValue() + { + // Birthday of jwage and also birthday of Doctrine. Send him a present ;) + $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform); + $this->assertInstanceOf('DateTime', $date); + $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); + } + + public function testInvalidDateFormatConversion() + { + $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); + $this->_type->convertToPHPValue('abcdefg', $this->_platform); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php new file mode 100644 index 0000000..983029c --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php @@ -0,0 +1,31 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('decimal'); + } + + public function testDecimalConvertsToPHPValue() + { + $this->assertInternalType('string', $this->_type->convertToPHPValue('5.5', $this->_platform)); + } + + public function testDecimalNullConvertsToPHPValue() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/FloatTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/FloatTest.php new file mode 100644 index 0000000..38d9237 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/FloatTest.php @@ -0,0 +1,39 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('float'); + } + + public function testFloatConvertsToPHPValue() + { + $this->assertInternalType('float', $this->_type->convertToPHPValue('5.5', $this->_platform)); + } + + public function testFloatNullConvertsToPHPValue() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } + + public function testFloatConvertToDatabaseValue() + { + $this->assertInternalType('float', $this->_type->convertToDatabaseValue(5.5, $this->_platform)); + } + + public function testFloatNullConvertToDatabaseValue() + { + $this->assertNull($this->_type->convertToDatabaseValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php new file mode 100644 index 0000000..adcde53 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php @@ -0,0 +1,32 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('integer'); + } + + public function testIntegerConvertsToPHPValue() + { + $this->assertInternalType('integer', $this->_type->convertToPHPValue('1', $this->_platform)); + $this->assertInternalType('integer', $this->_type->convertToPHPValue('0', $this->_platform)); + } + + public function testIntegerNullConvertsToPHPValue() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php new file mode 100644 index 0000000..d25c49a --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php @@ -0,0 +1,56 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('object'); + } + + public function tearDown() + { + error_reporting(-1); // reactive all error levels + } + + public function testObjectConvertsToDatabaseValue() + { + $this->assertInternalType('string', $this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform)); + } + + public function testObjectConvertsToPHPValue() + { + $this->assertInternalType('object', $this->_type->convertToPHPValue(serialize(new \stdClass), $this->_platform)); + } + + public function testConversionFailure() + { + error_reporting( (E_ALL | E_STRICT) - \E_NOTICE ); + $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); + $this->_type->convertToPHPValue('abcdefg', $this->_platform); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } + + /** + * @group DBAL-73 + */ + public function testFalseConversion() + { + $this->assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php new file mode 100644 index 0000000..399095c --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php @@ -0,0 +1,32 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('smallint'); + } + + public function testSmallIntConvertsToPHPValue() + { + $this->assertInternalType('integer', $this->_type->convertToPHPValue('1', $this->_platform)); + $this->assertInternalType('integer', $this->_type->convertToPHPValue('0', $this->_platform)); + } + + public function testSmallIntNullConvertsToPHPValue() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/StringTest.php new file mode 100644 index 0000000..52d2955 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/StringTest.php @@ -0,0 +1,49 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('string'); + } + + public function testReturnsSqlDeclarationFromPlatformVarchar() + { + $this->assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform)); + } + + public function testReturnsDefaultLengthFromPlatformVarchar() + { + $this->assertEquals(255, $this->_type->getDefaultLength($this->_platform)); + } + + public function testConvertToPHPValue() + { + $this->assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform)); + $this->assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform)); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } + + public function testSQLConversion() + { + $this->assertFalse($this->_type->canRequireSQLConversion(), "String type can never require SQL conversion to work."); + $this->assertEquals('t.foo', $this->_type->convertToDatabaseValueSQL('t.foo', $this->_platform)); + $this->assertEquals('t.foo', $this->_type->convertToPHPValueSQL('t.foo', $this->_platform)); + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php new file mode 100644 index 0000000..32374ad --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/TimeTest.php @@ -0,0 +1,47 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + $this->_type = Type::getType('time'); + } + + public function testTimeConvertsToDatabaseValue() + { + $this->assertTrue( + is_string($this->_type->convertToDatabaseValue(new \DateTime(), $this->_platform)) + ); + } + + public function testTimeConvertsToPHPValue() + { + $this->assertTrue( + $this->_type->convertToPHPValue('5:30:55', $this->_platform) + instanceof \DateTime + ); + } + + public function testInvalidTimeFormatConversion() + { + $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); + $this->_type->convertToPHPValue('abcdefg', $this->_platform); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php new file mode 100644 index 0000000..8934bca --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php @@ -0,0 +1,62 @@ +_platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform(); + if (!Type::hasType('vardatetime')) { + Type::addType('vardatetime', 'Doctrine\DBAL\Types\VarDateTimeType'); + } + $this->_type = Type::getType('vardatetime'); + } + + public function testDateTimeConvertsToDatabaseValue() + { + $date = new \DateTime('1985-09-01 10:10:10'); + + $expected = $date->format($this->_platform->getDateTimeTzFormatString()); + $actual = $this->_type->convertToDatabaseValue($date, $this->_platform); + + $this->assertEquals($expected, $actual); + } + + public function testDateTimeConvertsToPHPValue() + { + // Birthday of jwage and also birthday of Doctrine. Send him a present ;) + $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform); + $this->assertInstanceOf('DateTime', $date); + $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); + $this->assertEquals('000000', $date->format('u')); + } + + public function testInvalidDateTimeFormatConversion() + { + $this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); + $this->_type->convertToPHPValue('abcdefg', $this->_platform); + } + + public function testConversionWithMicroseconds() + { + $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00.123456', $this->_platform); + $this->assertInstanceOf('DateTime', $date); + $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); + $this->assertEquals('123456', $date->format('u')); + } + + public function testNullConversion() + { + $this->assertNull($this->_type->convertToPHPValue(null, $this->_platform)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/UtilTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/UtilTest.php new file mode 100644 index 0000000..b793e35 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/UtilTest.php @@ -0,0 +1,78 @@ + ':param1') + ), + array( + 'SELECT name FROM users WHERE id = ? AND status = ?', + 'SELECT name FROM users WHERE id = :param1 AND status = :param2', + array(1 => ':param1', 2 => ':param2'), + ), + array( + "UPDATE users SET name = '???', status = ?", + "UPDATE users SET name = '???', status = :param1", + array(1 => ':param1'), + ), + array( + "UPDATE users SET status = ?, name = '???'", + "UPDATE users SET status = :param1, name = '???'", + array(1 => ':param1'), + ), + array( + "UPDATE users SET foo = ?, name = '???', status = ?", + "UPDATE users SET foo = :param1, name = '???', status = :param2", + array(1 => ':param1', 2 => ':param2'), + ), + array( + 'UPDATE users SET name = "???", status = ?', + 'UPDATE users SET name = "???", status = :param1', + array(1 => ':param1'), + ), + array( + 'UPDATE users SET status = ?, name = "???"', + 'UPDATE users SET status = :param1, name = "???"', + array(1 => ':param1'), + ), + array( + 'UPDATE users SET foo = ?, name = "???", status = ?', + 'UPDATE users SET foo = :param1, name = "???", status = :param2', + array(1 => ':param1', 2 => ':param2'), + ), + array( + 'SELECT * FROM users WHERE id = ? AND name = "" AND status = ?', + 'SELECT * FROM users WHERE id = :param1 AND name = "" AND status = :param2', + array(1 => ':param1', 2 => ':param2'), + ), + array( + "SELECT * FROM users WHERE id = ? AND name = '' AND status = ?", + "SELECT * FROM users WHERE id = :param1 AND name = '' AND status = :param2", + array(1 => ':param1', 2 => ':param2'), + ) + ); + } + + /** + * @dataProvider dataConvertPositionalToNamedParameters + * @param string $inputSQL + * @param string $expectedOutputSQL + * @param array $expectedOutputParamsMap + */ + public function testConvertPositionalToNamedParameters($inputSQL, $expectedOutputSQL, $expectedOutputParamsMap) + { + list($statement, $params) = \Doctrine\DBAL\Driver\OCI8\OCI8Statement::convertPositionalToNamedPlaceholders($inputSQL); + + $this->assertEquals($expectedOutputSQL, $statement); + $this->assertEquals($expectedOutputParamsMap, $params); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php new file mode 100644 index 0000000..27dd149 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -0,0 +1,77 @@ +close(); + self::$_sharedConn = null; + } + } + + protected function setUp() + { + if ( ! isset(self::$_sharedConn)) { + self::$_sharedConn = TestUtil::getConnection(); + } + $this->_conn = self::$_sharedConn; + + $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); + $this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); + } + + protected function onNotSuccessfulTest(\Exception $e) + { + if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { + throw $e; + } + + if(isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) { + $queries = ""; + $i = count($this->_sqlLoggerStack->queries); + foreach (array_reverse($this->_sqlLoggerStack->queries) AS $query) { + $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; + $i--; + } + + $trace = $e->getTrace(); + $traceMsg = ""; + foreach($trace AS $part) { + if(isset($part['file'])) { + if(strpos($part['file'], "PHPUnit/") !== false) { + // Beginning with PHPUnit files we don't print the trace anymore. + break; + } + + $traceMsg .= $part['file'].":".$part['line'].PHP_EOL; + } + } + + $message = "[".get_class($e)."] ".$e->getMessage().PHP_EOL.PHP_EOL."With queries:".PHP_EOL.$queries.PHP_EOL."Trace:".PHP_EOL.$traceMsg; + + throw new \Exception($message, (int)$e->getCode(), $e); + } + throw $e; + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalTestCase.php new file mode 100644 index 0000000..2478e7b --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalTestCase.php @@ -0,0 +1,10 @@ +_platformMock = new DatabasePlatformMock(); + + parent::__construct($params, $driver, $config, $eventManager); + + // Override possible assignment of platform to database platform mock + $this->_platform = $this->_platformMock; + } + + /** + * @override + */ + public function getDatabasePlatform() + { + return $this->_platformMock; + } + + /** + * @override + */ + public function insert($tableName, array $data, array $types = array()) + { + $this->_inserts[$tableName][] = $data; + } + + /** + * @override + */ + public function lastInsertId($seqName = null) + { + return $this->_lastInsertId; + } + + /** + * @override + */ + public function fetchColumn($statement, array $params = array(), $colnum = 0) + { + return $this->_fetchOneResult; + } + + /** + * @override + */ + public function quote($input, $type = null) + { + if (is_string($input)) { + return "'" . $input . "'"; + } + return $input; + } + + /* Mock API */ + + public function setFetchOneResult($fetchOneResult) + { + $this->_fetchOneResult = $fetchOneResult; + } + + public function setDatabasePlatform($platform) + { + $this->_platformMock = $platform; + } + + public function setLastInsertId($id) + { + $this->_lastInsertId = $id; + } + + public function getInserts() + { + return $this->_inserts; + } + + public function reset() + { + $this->_inserts = array(); + $this->_lastInsertId = 0; + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php new file mode 100644 index 0000000..0153f9b --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php @@ -0,0 +1,98 @@ +_prefersIdentityColumns; + } + + /** + * @override + */ + public function prefersSequences() + { + return $this->_prefersSequences; + } + + /** @override */ + public function getSequenceNextValSQL($sequenceName) + { + return $this->_sequenceNextValSql; + } + + /** @override */ + public function getBooleanTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getIntegerTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getBigIntTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getSmallIntTypeDeclarationSQL(array $field) {} + + /** @override */ + protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {} + + /** @override */ + public function getVarcharTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getClobTypeDeclarationSQL(array $field) {} + + /* MOCK API */ + + public function setPrefersIdentityColumns($bool) + { + $this->_prefersIdentityColumns = $bool; + } + + public function setPrefersSequences($bool) + { + $this->_prefersSequences = $bool; + } + + public function setSequenceNextValSql($sql) + { + $this->_sequenceNextValSql = $sql; + } + + public function getName() + { + return 'mock'; + } + protected function initializeDoctrineTypeMappings() { + } + protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) + { + + } + /** + * Gets the SQL Snippet used to declare a BLOB column type. + */ + public function getBlobTypeDeclarationSQL(array $field) + { + throw DBALException::notSupported(__METHOD__); + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php new file mode 100644 index 0000000..03d44ca --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php @@ -0,0 +1,17 @@ +_platformMock) { + $this->_platformMock = new DatabasePlatformMock; + } + return $this->_platformMock; + } + + /** + * @override + */ + public function getSchemaManager(\Doctrine\DBAL\Connection $conn) + { + if($this->_schemaManagerMock == null) { + return new SchemaManagerMock($conn); + } else { + return $this->_schemaManagerMock; + } + } + + /* MOCK API */ + + public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) + { + $this->_platformMock = $platform; + } + + public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm) + { + $this->_schemaManagerMock = $sm; + } + + public function getName() + { + return 'mock'; + } + + public function getDatabase(\Doctrine\DBAL\Connection $conn) + { + return; + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php new file mode 100644 index 0000000..a5bd1c6 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php @@ -0,0 +1,101 @@ + + */ +class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement +{ + private $_resultSet; + + /** + * Creates a new mock statement that will serve the provided fake result set to clients. + * + * @param array $resultSet The faked SQL result set. + */ + public function __construct(array $resultSet) + { + $this->_resultSet = $resultSet; + } + + /** + * Fetches all rows from the result set. + * + * @return array + */ + public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null) + { + return $this->_resultSet; + } + + public function fetchColumn($columnNumber = 0) + { + $row = current($this->_resultSet); + if ( ! is_array($row)) return false; + $val = array_shift($row); + return $val !== null ? $val : false; + } + + /** + * Fetches the next row in the result set. + * + */ + public function fetch($fetchStyle = null) + { + $current = current($this->_resultSet); + next($this->_resultSet); + return $current; + } + + /** + * Closes the cursor, enabling the statement to be executed again. + * + * @return boolean + */ + public function closeCursor() + { + return true; + } + + public function setResultSet(array $resultSet) + { + reset($resultSet); + $this->_resultSet = $resultSet; + } + + public function bindColumn($column, &$param, $type = null) + { + } + + public function bindValue($param, $value, $type = null) + { + } + + public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) + { + } + + public function columnCount() + { + } + + public function errorCode() + { + } + + public function errorInfo() + { + } + + public function execute($params = array()) + { + } + + public function rowCount() + { + } +} \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php new file mode 100644 index 0000000..d4c3c28 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php @@ -0,0 +1,13 @@ +. + */ + +namespace Doctrine\Tests\Mocks; + +use Doctrine\Common\Cli\AbstractNamespace; + +/** + * TaskMock used for testing the CLI interface. + * @author Nils Adermann + */ +class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask +{ + /** + * Since instances of this class can be created elsewhere all instances + * register themselves in this array for later inspection. + * + * @var array(TaskMock) + */ + static public $instances = array(); + + private $runCounter = 0; + + /** + * Constructor of Task Mock Object. + * Makes sure the object can be inspected later. + * + * @param AbstractNamespace CLI Namespace, passed to parent constructor + */ + function __construct(AbstractNamespace $namespace) + { + self::$instances[] = $this; + + parent::__construct($namespace); + } + + /** + * Returns the number of times run() was called on this object. + * + * @return int + */ + public function getRunCounter() + { + return $this->runCounter; + } + + /* Mock API */ + + /** + * Method invoked by CLI to run task. + */ + public function run() + { + $this->runCounter++; + } + + /** + * Method supposed to generate the CLI Task Documentation + */ + public function buildDocumentation() + { + } +} diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/TestInit.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/TestInit.php new file mode 100644 index 0000000..6580343 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/TestInit.php @@ -0,0 +1,22 @@ +register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', __DIR__ . '/../../../lib'); +$classLoader->register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Tests', __DIR__ . '/../../'); +$classLoader->register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Symfony', __DIR__ . "/../../../lib/vendor"); +$classLoader->register(); + diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/TestUtil.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/TestUtil.php new file mode 100644 index 0000000..17d7cc0 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/TestUtil.php @@ -0,0 +1,131 @@ +real database connection using the following parameters + * of the $GLOBALS array: + * + * 'db_type' : The name of the Doctrine DBAL database driver to use. + * 'db_username' : The username to use for connecting. + * 'db_password' : The password to use for connecting. + * 'db_host' : The hostname of the database to connect to. + * 'db_name' : The name of the database to connect to. + * 'db_port' : The port of the database to connect to. + * + * Usually these variables of the $GLOBALS array are filled by PHPUnit based + * on an XML configuration file. If no such parameters exist, an SQLite + * in-memory database is used. + * + * IMPORTANT: + * 1) Each invocation of this method returns a NEW database connection. + * 2) The database is dropped and recreated to ensure it's clean. + * + * @return Doctrine\DBAL\Connection The database connection instance. + */ + public static function getConnection() + { + if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'], + $GLOBALS['db_host'], $GLOBALS['db_name'], $GLOBALS['db_port']) && + isset($GLOBALS['tmpdb_type'], $GLOBALS['tmpdb_username'], $GLOBALS['tmpdb_password'], + $GLOBALS['tmpdb_host'], $GLOBALS['tmpdb_name'], $GLOBALS['tmpdb_port'])) { + $realDbParams = array( + 'driver' => $GLOBALS['db_type'], + 'user' => $GLOBALS['db_username'], + 'password' => $GLOBALS['db_password'], + 'host' => $GLOBALS['db_host'], + 'dbname' => $GLOBALS['db_name'], + 'port' => $GLOBALS['db_port'] + ); + $tmpDbParams = array( + 'driver' => $GLOBALS['tmpdb_type'], + 'user' => $GLOBALS['tmpdb_username'], + 'password' => $GLOBALS['tmpdb_password'], + 'host' => $GLOBALS['tmpdb_host'], + 'dbname' => $GLOBALS['tmpdb_name'], + 'port' => $GLOBALS['tmpdb_port'] + ); + + if (isset($GLOBALS['db_unix_socket'])) { + $realDbParams['unix_socket'] = $GLOBALS['db_unix_socket']; + } + + if (isset($GLOBALS['tmpdb_unix_socket'])) { + $tmpDbParams['unix_socket'] = $GLOBALS['tmpdb_unix_socket']; + } + + $realConn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams); + + $platform = $realConn->getDatabasePlatform(); + + if ($platform->supportsCreateDropDatabase()) { + $dbname = $realConn->getDatabase(); + // Connect to tmpdb in order to drop and create the real test db. + $tmpConn = \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); + $realConn->close(); + + $tmpConn->getSchemaManager()->dropDatabase($dbname); + $tmpConn->getSchemaManager()->createDatabase($dbname); + + $tmpConn->close(); + } else { + $sm = $realConn->getSchemaManager(); + + /* @var $schema Schema */ + $schema = $sm->createSchema(); + $stmts = $schema->toDropSql($realConn->getDatabasePlatform()); + + foreach ($stmts AS $stmt) { + $realConn->exec($stmt); + } + } + + $conn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams, null, null); + } else { + $params = array( + 'driver' => 'pdo_sqlite', + 'memory' => true + ); + if (isset($GLOBALS['db_path'])) { + $params['path'] = $GLOBALS['db_path']; + unlink($GLOBALS['db_path']); + } + $conn = \Doctrine\DBAL\DriverManager::getConnection($params); + } + + if (isset($GLOBALS['db_event_subscribers'])) { + $evm = $conn->getEventManager(); + foreach (explode(",", $GLOBALS['db_event_subscribers']) AS $subscriberClass) { + $subscriberInstance = new $subscriberClass(); + $evm->addEventSubscriber($subscriberInstance); + } + } + + return $conn; + } + + /** + * @return \Doctrine\DBAL\Connection + */ + public static function getTempConnection() + { + $tmpDbParams = array( + 'driver' => $GLOBALS['tmpdb_type'], + 'user' => $GLOBALS['tmpdb_username'], + 'password' => $GLOBALS['tmpdb_password'], + 'host' => $GLOBALS['tmpdb_host'], + 'dbname' => $GLOBALS['tmpdb_name'], + 'port' => $GLOBALS['tmpdb_port'] + ); + + // Connect to tmpdb in order to drop and create the real test db. + return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); + } +} diff --git a/vendor/doctrine/dbal/tests/README.markdown b/vendor/doctrine/dbal/tests/README.markdown new file mode 100644 index 0000000..c1027ac --- /dev/null +++ b/vendor/doctrine/dbal/tests/README.markdown @@ -0,0 +1,25 @@ +# Running the Doctrine 2 Testsuite + +## Setting up a PHPUnit Configuration XML + +.. + +## Testing Lock-Support + +The Lock support in Doctrine 2 is tested using Gearman, which allows to run concurrent tasks in parallel. +Install Gearman with PHP as follows: + +1. Go to http://www.gearman.org and download the latest Gearman Server +2. Compile it and then call ldconfig +3. Start it up "gearmand -vvvv" +4. Install pecl/gearman by calling "gearman-beta" + +You can then go into tests/ and start up two workers: + + php Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php + +Then run the locking test-suite: + + phpunit --configuration Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php + +This can run considerable time, because it is using sleep() to test for the timing ranges of locks. \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/travis/mysql.travis.xml b/vendor/doctrine/dbal/tests/travis/mysql.travis.xml new file mode 100644 index 0000000..c80f4d2 --- /dev/null +++ b/vendor/doctrine/dbal/tests/travis/mysql.travis.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + ./../Doctrine/Tests/DBAL + + + + + performance + locking_functional + + + + + diff --git a/vendor/doctrine/dbal/tests/travis/pgsql.travis.xml b/vendor/doctrine/dbal/tests/travis/pgsql.travis.xml new file mode 100644 index 0000000..e3bd7ea --- /dev/null +++ b/vendor/doctrine/dbal/tests/travis/pgsql.travis.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + ./../Doctrine/Tests/DBAL + + + + + performance + locking_functional + + + \ No newline at end of file diff --git a/vendor/doctrine/dbal/tests/travis/sqlite.travis.xml b/vendor/doctrine/dbal/tests/travis/sqlite.travis.xml new file mode 100644 index 0000000..944f137 --- /dev/null +++ b/vendor/doctrine/dbal/tests/travis/sqlite.travis.xml @@ -0,0 +1,14 @@ + + + + + ./../Doctrine/Tests/DBAL + + + + + performance + locking_functional + + + \ No newline at end of file diff --git a/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/.gitignore b/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/.gitignore new file mode 100644 index 0000000..1d034f4 --- /dev/null +++ b/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/.gitignore @@ -0,0 +1,4 @@ +vendor +composer.phar +composer.lock +phpunit.xml diff --git a/vendor/doctrine/doctrine-migrations-bundle/Doctrine/Bundle/MigrationsBundle b/vendor/doctrine/doctrine-migrations-bundle/Doctrine/Bundle/MigrationsBundle new file mode 160000 index 0000000..3792aa7 --- /dev/null +++ b/vendor/doctrine/doctrine-migrations-bundle/Doctrine/Bundle/MigrationsBundle @@ -0,0 +1 @@ +Subproject commit 3792aa78445773387754c6853bbd7f4dcb31f486 diff --git a/vendor/doctrine/orm/.gitignore b/vendor/doctrine/orm/.gitignore new file mode 100644 index 0000000..a918417 --- /dev/null +++ b/vendor/doctrine/orm/.gitignore @@ -0,0 +1,11 @@ +build/ +logs/ +reports/ +dist/ +download/ +lib/api/ +lib/Doctrine/Common +lib/Doctrine/DBAL +/.settings/ +.buildpath +.project diff --git a/vendor/doctrine/orm/.gitmodules b/vendor/doctrine/orm/.gitmodules new file mode 100644 index 0000000..21a1fb2 --- /dev/null +++ b/vendor/doctrine/orm/.gitmodules @@ -0,0 +1,15 @@ +[submodule "lib/vendor/doctrine-common"] + path = lib/vendor/doctrine-common + url = git://github.com/doctrine/common.git +[submodule "lib/vendor/doctrine-dbal"] + path = lib/vendor/doctrine-dbal + url = git://github.com/doctrine/dbal.git +[submodule "lib/vendor/Symfony/Component/Console"] + path = lib/vendor/Symfony/Component/Console + url = git://github.com/symfony/Console.git +[submodule "lib/vendor/Symfony/Component/Yaml"] + path = lib/vendor/Symfony/Component/Yaml + url = git://github.com/symfony/Yaml.git +[submodule "lib/vendor/doctrine-build-common"] + path = lib/vendor/doctrine-build-common + url = https://github.com/doctrine/doctrine-build-common.git diff --git a/vendor/doctrine/orm/UPGRADE_TO_2_0 b/vendor/doctrine/orm/UPGRADE_TO_2_0 new file mode 100644 index 0000000..1dcc807 --- /dev/null +++ b/vendor/doctrine/orm/UPGRADE_TO_2_0 @@ -0,0 +1,240 @@ +# Update from 2.0-BETA3 to 2.0-BETA4 + +## XML Driver element demoted to attribute + +We changed how the XML Driver allows to define the change-tracking-policy. The working case is now: + + + +# Update from 2.0-BETA2 to 2.0-BETA3 + +## Serialization of Uninitialized Proxies + +As of Beta3 you can now serialize uninitialized proxies, an exception will only be thrown when +trying to access methods on the unserialized proxy as long as it has not been re-attached to the +EntityManager using `EntityManager#merge()`. See this example: + + $proxy = $em->getReference('User', 1); + + $serializedProxy = serialize($proxy); + $detachedProxy = unserialized($serializedProxy); + + echo $em->contains($detachedProxy); // FALSE + + try { + $detachedProxy->getId(); // uninitialized detached proxy + } catch(Exception $e) { + + } + $attachedProxy = $em->merge($detachedProxy); + echo $attackedProxy->getId(); // works! + +## Changed SQL implementation of Postgres and Oracle DateTime types + +The DBAL Type "datetime" included the Timezone Offset in both Postgres and Oracle. As of this version they are now +generated without Timezone (TIMESTAMP WITHOUT TIME ZONE instead of TIMESTAMP WITH TIME ZONE). +See [this comment to Ticket DBAL-22](http://www.doctrine-project.org/jira/browse/DBAL-22?focusedCommentId=13396&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_13396) +for more details as well as migration issues for PostgreSQL and Oracle. + +Both Postgres and Oracle will throw Exceptions during hydration of Objects with "DateTime" fields unless migration steps are taken! + +## Removed multi-dot/deep-path expressions in DQL + +The support for implicit joins in DQL through the multi-dot/Deep Path Expressions +was dropped. For example: + + SELECT u FROM User u WHERE u.group.name = ?1 + +See the "u.group.id" here is using multi dots (deep expression) to walk +through the graph of objects and properties. Internally the DQL parser +would rewrite these queries to: + + SELECT u FROM User u JOIN u.group g WHERE g.name = ?1 + +This explicit notation will be the only supported notation as of now. The internal +handling of multi-dots in the DQL Parser was very complex, error prone in edge cases +and required special treatment for several features we added. Additionally +it had edge cases that could not be solved without making the DQL Parser +even much more complex. For this reason we will drop the support for the +deep path expressions to increase maintainability and overall performance +of the DQL parsing process. This will benefit any DQL query being parsed, +even those not using deep path expressions. + +Note that the generated SQL of both notations is exactly the same! You +don't loose anything through this. + +## Default Allocation Size for Sequences + +The default allocation size for sequences has been changed from 10 to 1. This step was made +to not cause confusion with users and also because it is partly some kind of premature optimization. + +# Update from 2.0-BETA1 to 2.0-BETA2 + +There are no backwards incompatible changes in this release. + +# Upgrade from 2.0-ALPHA4 to 2.0-BETA1 + +## EntityRepository deprecates access to protected variables + +Instead of accessing protected variables for the EntityManager in +a custom EntityRepository it is now required to use the getter methods +for all the three instance variables: + +* `$this->_em` now accessible through `$this->getEntityManager()` +* `$this->_class` now accessible through `$this->getClassMetadata()` +* `$this->_entityName` now accessible through `$this->getEntityName()` + +Important: For Beta 2 the protected visibility of these three properties will be +changed to private! + +## Console migrated to Symfony Console + +The Doctrine CLI has been replaced by Symfony Console Configuration + +Instead of having to specify: + + [php] + $cliConfig = new CliConfiguration(); + $cliConfig->setAttribute('em', $entityManager); + +You now have to configure the script like: + + [php] + $helperSet = new \Symfony\Components\Console\Helper\HelperSet(array( + 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), + 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) + )); + +## Console: No need for Mapping Paths anymore + +In previous versions you had to specify the --from and --from-path options +to show where your mapping paths are from the console. However this information +is already known from the Mapping Driver configuration, so the requirement +for this options were dropped. + +Instead for each console command all the entities are loaded and to +restrict the operation to one or more sub-groups you can use the --filter flag. + +## AnnotationDriver is not a default mapping driver anymore + +In conjunction with the recent changes to Console we realized that the +annotations driver being a default metadata driver lead to lots of glue +code in the console components to detect where entities lie and how to load +them for batch updates like SchemaTool and other commands. However the +annotations driver being a default driver does not really help that much +anyways. + +Therefore we decided to break backwards compability in this issue and drop +the support for Annotations as Default Driver and require our users to +specify the driver explicitly (which allows us to ask for the path to all +entities). + +If you are using the annotations metadata driver as default driver, you +have to add the following lines to your bootstrap code: + + $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); + $config->setMetadataDriverImpl($driverImpl); + +You have to specify the path to your entities as either string of a single +path or array of multiple paths +to your entities. This information will be used by all console commands to +access all entities. + +Xml and Yaml Drivers work as before! + + +## New inversedBy attribute + +It is now *mandatory* that the owning side of a bidirectional association specifies the +'inversedBy' attribute that points to the name of the field on the inverse side that completes +the association. Example: + + [php] + // BEFORE (ALPHA4 AND EARLIER) + class User + { + //... + /** @OneToOne(targetEntity="Address", mappedBy="user") */ + private $address; + //... + } + class Address + { + //... + /** @OneToOne(targetEntity="User") */ + private $user; + //... + } + + // SINCE BETA1 + // User class DOES NOT CHANGE + class Address + { + //... + /** @OneToOne(targetEntity="User", inversedBy="address") */ + private $user; + //... + } + +Thus, the inversedBy attribute is the counterpart to the mappedBy attribute. This change +was necessary to enable some simplifications and further performance improvements. We +apologize for the inconvenience. + +## Default Property for Field Mappings + +The "default" option for database column defaults has been removed. If desired, database column defaults can +be implemented by using the columnDefinition attribute of the @Column annotation (or the approriate XML and YAML equivalents). +Prefer PHP default values, if possible. + +## Selecting Partial Objects + +Querying for partial objects now has a new syntax. The old syntax to query for partial objects +now has a different meaning. This is best illustrated by an example. If you previously +had a DQL query like this: + + [sql] + SELECT u.id, u.name FROM User u + +Since BETA1, simple state field path expressions in the select clause are used to select +object fields as plain scalar values (something that was not possible before). +To achieve the same result as previously (that is, a partial object with only id and name populated) +you need to use the following, explicit syntax: + + [sql] + SELECT PARTIAL u.{id,name} FROM User u + +## XML Mapping Driver + +The 'inheritance-type' attribute changed to take last bit of ClassMetadata constant names, i.e. +NONE, SINGLE_TABLE, INHERITANCE_TYPE_JOINED + +## YAML Mapping Driver + +The way to specify lifecycle callbacks in YAML Mapping driver was changed to allow for multiple callbacks +per event. The Old syntax ways: + + [yaml] + lifecycleCallbacks: + doStuffOnPrePersist: prePersist + doStuffOnPostPersist: postPersist + +The new syntax is: + + [yaml] + lifecycleCallbacks: + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] + +## PreUpdate Event Listeners + +Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets +by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes +to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic +performance benefits for the preUpdate event. + +## Collection API + +The Collection interface in the Common package has been updated with some missing methods +that were present only on the default implementation, ArrayCollection. Custom collection +implementations need to be updated to adhere to the updated interface. + diff --git a/vendor/doctrine/orm/UPGRADE_TO_2_1 b/vendor/doctrine/orm/UPGRADE_TO_2_1 new file mode 100644 index 0000000..f422444 --- /dev/null +++ b/vendor/doctrine/orm/UPGRADE_TO_2_1 @@ -0,0 +1,25 @@ +This document details all the possible changes that you should investigate when updating +your project from Doctrine 2.0.x to 2.1 + +## Interface for EntityRepository + +The EntityRepository now has an interface Doctrine\Common\Persistence\ObjectRepository. This means that your classes that override EntityRepository and extend find(), findOneBy() or findBy() must be adjusted to follow this interface. + +## AnnotationReader changes + +The annotation reader was heavily refactored between 2.0 and 2.1-RC1. In theory the operation of the new reader should be backwards compatible, but it has to be setup differently to work that way: + + // new call to the AnnotationRegistry + \Doctrine\Common\Annotations\AnnotationRegistry::registerFile('/doctrine-src/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); + + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); + // new code necessary starting here + $reader->setIgnoreNotImportedAnnotations(true); + $reader->setEnableParsePhpImports(false); + $reader = new \Doctrine\Common\Annotations\CachedReader( + new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() + ); + +This is already done inside the ``$config->newDefaultAnnotationDriver``, so everything should automatically work if you are using this method. You can verify if everything still works by executing a console command such as schema-validate that loads all metadata into memory. + diff --git a/vendor/doctrine/orm/UPGRADE_TO_2_2 b/vendor/doctrine/orm/UPGRADE_TO_2_2 new file mode 100644 index 0000000..78e77d3 --- /dev/null +++ b/vendor/doctrine/orm/UPGRADE_TO_2_2 @@ -0,0 +1,81 @@ +# ResultCache implementation rewritten + +The result cache is completely rewritten and now works on the database result level, not inside the ORM AbstractQuery +anymore. This means that for result cached queries the hydration will now always be performed again, regardless of +the hydration mode. Affected areas are: + +1. Fixes the problem that entities coming from the result cache were not registered in the UnitOfWork + leading to problems during EntityManager#flush. Calls to EntityManager#merge are not necessary anymore. +2. Affects the array hydrator which now includes the overhead of hydration compared to caching the final result. + +The API is backwards compatible however most of the getter methods on the `AbstractQuery` object are now +deprecated in favor of calling AbstractQuery#getQueryCacheProfile(). This method returns a `Doctrine\DBAL\Cache\QueryCacheProfile` +instance with access to result cache driver, lifetime and cache key. + + +# EntityManager#getPartialReference() creates read-only entity + +Entities returned from EntityManager#getPartialReference() are now marked as read-only if they +haven't been in the identity map before. This means objects of this kind never lead to changes +in the UnitOfWork. + + +# Fields omitted in a partial DQL query or a native query are never updated + +Fields of an entity that are not returned from a partial DQL Query or native SQL query +will never be updated through an UPDATE statement. + + +# Removed support for onUpdate in @JoinColumn + +The onUpdate foreign key handling makes absolutely no sense in an ORM. Additionally Oracle doesn't even support it. Support for it is removed. + + +# Changes in Annotation Handling + +There have been some changes to the annotation handling in Common 2.2 again, that affect how people with old configurations +from 2.0 have to configure the annotation driver if they don't use `Configuration::newDefaultAnnotationDriver()`: + + // Register the ORM Annotations in the AnnotationRegistry + AnnotationRegistry::registerFile('path/to/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); + + $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); + $reader->addNamespace('Doctrine\ORM\Mapping'); + $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); + + $driver = new AnnotationDriver($reader, (array)$paths); + + $config->setMetadataDriverImpl($driver); + + +# Scalar mappings can now be ommitted from DQL result + +You are now allowed to mark scalar SELECT expressions as HIDDEN an they are not hydrated anymore. +Example: + +SELECT u, SUM(a.id) AS HIDDEN numArticles FROM User u LEFT JOIN u.Articles a ORDER BY numArticles DESC HAVING numArticles > 10 + +Your result will be a collection of Users, and not an array with key 0 as User object instance and "numArticles" as the number of articles per user + + +# Map entities as scalars in DQL result + +When hydrating to array or even a mixed result in object hydrator, previously you had the 0 index holding you entity instance. +You are now allowed to alias this, providing more flexibility for you code. +Example: + +SELECT u AS user FROM User u + +Will now return a collection of arrays with index "user" pointing to the User object instance. + + +# Performance optimizations + +Thousands of lines were completely reviewed and optimized for best performance. +Removed redundancy and improved code readability made now internal Doctrine code easier to understand. +Also, Doctrine 2.2 now is around 10-15% faster than 2.1. + +# EntityManager#find(null) + +Previously EntityManager#find(null) returned null. It now throws an exception. + diff --git a/vendor/doctrine/orm/UPGRADE_TO_ALPHA3 b/vendor/doctrine/orm/UPGRADE_TO_ALPHA3 new file mode 100644 index 0000000..3db76af --- /dev/null +++ b/vendor/doctrine/orm/UPGRADE_TO_ALPHA3 @@ -0,0 +1,35 @@ +# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3 + +This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you +to upgrade your projects to use this version. + +## CLI Changes + +The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments. + +## Proxy class changes + +You are now required to make supply some minimalist configuration with regards to proxy objects. That involves 2 new configuration options. First, the directory where generated proxy classes should be placed needs to be specified. Secondly, you need to configure the namespace used for proxy classes. The following snippet shows an example: + + [php] + // step 1: configure directory for proxy classes + // $config instanceof Doctrine\ORM\Configuration + $config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies'); + $config->setProxyNamespace('MyProject\Generated\Proxies'); + +Note that proxy classes behave exactly like any other classes when it comes to class loading. Therefore you need to make sure the proxy classes can be loaded by some class loader. If you place the generated proxy classes in a namespace and directory under your projects class files, like in the example above, it would be sufficient to register the MyProject namespace on a class loader. Since the proxy classes are contained in that namespace and adhere to the standards for class loading, no additional work is required. +Generating the proxy classes into a namespace within your class library is the recommended setup. + +Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application. + +For more details refer to the Configuration section of the manual. + +## Removed allowPartialObjects configuration option + +The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed. +The new behavior is as if the option were set to FALSE all the time, basically disallowing partial objects globally. However, you can still use the `Query::HINT_FORCE_PARTIAL_LOAD` query hint to force a query to return partial objects for optimization purposes. + +## Renamed Methods + +* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir() +* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir) \ No newline at end of file diff --git a/vendor/doctrine/orm/UPGRADE_TO_ALPHA4 b/vendor/doctrine/orm/UPGRADE_TO_ALPHA4 new file mode 100644 index 0000000..81a2ef6 --- /dev/null +++ b/vendor/doctrine/orm/UPGRADE_TO_ALPHA4 @@ -0,0 +1,36 @@ +# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4 + +## CLI Controller changes + +CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\Common\Cli\CliController. +Doctrine\Common\Cli\CliController now only deals with namespaces. Ready to go, Core, Dbal and Orm are available and you can subscribe new tasks by retrieving the namespace and including new task. Example: + + [php] + $cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask'); + + +## CLI Tasks documentation + +Tasks have implemented a new way to build documentation. Although it is still possible to define the help manually by extending the basicHelp and extendedHelp, they are now optional. +With new required method AbstractTask::buildDocumentation, its implementation defines the TaskDocumentation instance (accessible through AbstractTask::getDocumentation()), basicHelp and extendedHelp are now not necessary to be implemented. + +## Changes in Method Signatures + + * A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager + have changed quite significantly by adopting the new Schema instance objects. + +## Renamed Methods + + * Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache() + * Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache() + +## SchemaTool Changes + + * "doctrine schema-tool --drop" now always drops the complete database instead of + only those tables defined by the current database model. The previous method had + problems when foreign keys of orphaned tables pointed to tables that were schedulded + for deletion. + * Use "doctrine schema-tool --update" to get a save incremental update for your + database schema without deleting any unused tables, sequences or foreign keys. + * Use "doctrine schema-tool --complete-update" to do a full incremental update of + your schema. diff --git a/vendor/doctrine/orm/bin/doctrine b/vendor/doctrine/orm/bin/doctrine new file mode 100644 index 0000000..92f323f --- /dev/null +++ b/vendor/doctrine/orm/bin/doctrine @@ -0,0 +1,4 @@ +#!/usr/bin/env php +. + */ + +require_once 'Doctrine/Common/ClassLoader.php'; + +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); +$classLoader->register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine'); +$classLoader->register(); + +$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; + +$helperSet = null; +if (file_exists($configFile)) { + if ( ! is_readable($configFile)) { + trigger_error( + 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR + ); + } + + require $configFile; + + foreach ($GLOBALS as $helperSetCandidate) { + if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) { + $helperSet = $helperSetCandidate; + break; + } + } +} + +$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet(); + +\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet); diff --git a/vendor/doctrine/orm/build.properties b/vendor/doctrine/orm/build.properties new file mode 100644 index 0000000..37c834c --- /dev/null +++ b/vendor/doctrine/orm/build.properties @@ -0,0 +1,11 @@ +# Project Name +project.name=DoctrineORM + +# Dependency minimum versions +dependencies.common=2.2.0beta1 +dependencies.dbal=2.2.0beta1 +dependencies.sfconsole=2.0.0 + +# Version class and file +project.version_class = Doctrine\ORM\Version +project.version_file = lib/Doctrine/ORM/Version.php diff --git a/vendor/doctrine/orm/build.properties.dev b/vendor/doctrine/orm/build.properties.dev new file mode 100644 index 0000000..20e91dc --- /dev/null +++ b/vendor/doctrine/orm/build.properties.dev @@ -0,0 +1,16 @@ +version=2.0.0BETA2 +dependencies.common=2.0.0BETA4 +dependencies.dbal=2.0.0BETA4 +stability=beta +build.dir=build +dist.dir=dist +report.dir=reports +log.archive.dir=logs +project.pirum_dir= +project.download_dir= +project.xsd_dir= +test.phpunit_configuration_file= +test.phpunit_generate_coverage=0 +test.pmd_reports=0 +test.pdepend_exec= +test.phpmd_exec= \ No newline at end of file diff --git a/vendor/doctrine/orm/build.xml b/vendor/doctrine/orm/build.xml new file mode 100644 index 0000000..8b22f07 --- /dev/null +++ b/vendor/doctrine/orm/build.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DoctrineORM + Doctrine Object Relational Mapper + pear.doctrine-project.org + The Doctrine ORM package is the primary package containing the object relational mapper. + + + + + LGPL + + + - + + + + + + + + + script + Doctrine/Common/ + Doctrine/DBAL/ + Symfony/Component/Yaml/ + Symfony/Component/Console/ + + + + + + + + + + diff --git a/vendor/doctrine/orm/tests/.gitignore b/vendor/doctrine/orm/tests/.gitignore new file mode 100644 index 0000000..7210405 --- /dev/null +++ b/vendor/doctrine/orm/tests/.gitignore @@ -0,0 +1,3 @@ +Doctrine/Tests/Proxies/ +Doctrine/Tests/ORM/Proxy/generated/ +Doctrine/Tests/ORM/Tools/Export/export diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalFunctionalTestCase.php new file mode 100644 index 0000000..c4705a2 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -0,0 +1,32 @@ +sharedFixture['conn'] = null; + self::$_sharedConn = null; + } + + protected function setUp() + { + if (isset($this->sharedFixture['conn'])) { + $this->_conn = $this->sharedFixture['conn']; + } else { + if ( ! isset(self::$_sharedConn)) { + self::$_sharedConn = TestUtil::getConnection(); + } + $this->_conn = self::$_sharedConn; + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTestCase.php new file mode 100644 index 0000000..2478e7b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTestCase.php @@ -0,0 +1,10 @@ +getIntegerTypeDeclarationSQL($fieldDeclaration); + } + + public function canRequireSQLConversion() + { + return true; + } + + public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform) + { + return 'ABS(' . $sqlExpr . ')'; + } + + public function convertToPHPValueSQL($sqlExpr, $platform) + { + return '-(' . $sqlExpr . ')'; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php new file mode 100644 index 0000000..47e8c79 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/DbalTypes/UpperCaseStringType.php @@ -0,0 +1,29 @@ +_generatorType = $type; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ConnectionMock.php new file mode 100644 index 0000000..90ebfec --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -0,0 +1,106 @@ +_platformMock = new DatabasePlatformMock(); + + parent::__construct($params, $driver, $config, $eventManager); + + // Override possible assignment of platform to database platform mock + $this->_platform = $this->_platformMock; + } + + /** + * @override + */ + public function getDatabasePlatform() + { + return $this->_platformMock; + } + + /** + * @override + */ + public function insert($tableName, array $data, array $types = array()) + { + $this->_inserts[$tableName][] = $data; + } + + /** + * @override + */ + public function executeUpdate($query, array $params = array(), array $types = array()) + { + $this->_executeUpdates[] = array('query' => $query, 'params' => $params, 'types' => $types); + } + + /** + * @override + */ + public function lastInsertId($seqName = null) + { + return $this->_lastInsertId; + } + + /** + * @override + */ + public function fetchColumn($statement, array $params = array(), $colnum = 0) + { + return $this->_fetchOneResult; + } + + /** + * @override + */ + public function quote($input, $type = null) + { + if (is_string($input)) { + return "'" . $input . "'"; + } + return $input; + } + + /* Mock API */ + + public function setFetchOneResult($fetchOneResult) + { + $this->_fetchOneResult = $fetchOneResult; + } + + public function setDatabasePlatform($platform) + { + $this->_platformMock = $platform; + } + + public function setLastInsertId($id) + { + $this->_lastInsertId = $id; + } + + public function getInserts() + { + return $this->_inserts; + } + + public function getExecuteUpdates() + { + return $this->_executeUpdates; + } + + public function reset() + { + $this->_inserts = array(); + $this->_lastInsertId = 0; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php new file mode 100644 index 0000000..b634408 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php @@ -0,0 +1,97 @@ +_prefersIdentityColumns; + } + + /** + * @override + */ + public function prefersSequences() + { + return $this->_prefersSequences; + } + + /** @override */ + public function getSequenceNextValSQL($sequenceName) + { + return $this->_sequenceNextValSql; + } + + /** @override */ + public function getBooleanTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getIntegerTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getBigIntTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getSmallIntTypeDeclarationSQL(array $field) {} + + /** @override */ + protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {} + + /** @override */ + public function getVarcharTypeDeclarationSQL(array $field) {} + + /** @override */ + public function getClobTypeDeclarationSQL(array $field) {} + + /* MOCK API */ + + public function setPrefersIdentityColumns($bool) + { + $this->_prefersIdentityColumns = $bool; + } + + public function setPrefersSequences($bool) + { + $this->_prefersSequences = $bool; + } + + public function setSequenceNextValSql($sql) + { + $this->_sequenceNextValSql = $sql; + } + + public function getName() + { + return 'mock'; + } + + protected function initializeDoctrineTypeMappings() + { + + } + /** + * Gets the SQL Snippet used to declare a BLOB column type. + */ + public function getBlobTypeDeclarationSQL(array $field) + { + throw DBALException::notSupported(__METHOD__); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php new file mode 100644 index 0000000..03d44ca --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php @@ -0,0 +1,17 @@ +_platformMock) { + $this->_platformMock = new DatabasePlatformMock; + } + return $this->_platformMock; + } + + /** + * @override + */ + public function getSchemaManager(\Doctrine\DBAL\Connection $conn) + { + if($this->_schemaManagerMock == null) { + return new SchemaManagerMock($conn); + } else { + return $this->_schemaManagerMock; + } + } + + /* MOCK API */ + + public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform) + { + $this->_platformMock = $platform; + } + + public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm) + { + $this->_schemaManagerMock = $sm; + } + + public function getName() + { + return 'mock'; + } + + public function getDatabase(\Doctrine\DBAL\Connection $conn) + { + return; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityManagerMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityManagerMock.php new file mode 100644 index 0000000..04b038d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityManagerMock.php @@ -0,0 +1,106 @@ +. + */ + +namespace Doctrine\Tests\Mocks; + +use Doctrine\ORM\Proxy\ProxyFactory; + +/** + * Special EntityManager mock used for testing purposes. + */ +class EntityManagerMock extends \Doctrine\ORM\EntityManager +{ + private $_uowMock; + private $_proxyFactoryMock; + private $_idGenerators = array(); + + /** + * @override + */ + public function getUnitOfWork() + { + return isset($this->_uowMock) ? $this->_uowMock : parent::getUnitOfWork(); + } + + /* Mock API */ + + /** + * Sets a (mock) UnitOfWork that will be returned when getUnitOfWork() is called. + * + * @param $uow + */ + public function setUnitOfWork($uow) + { + $this->_uowMock = $uow; + } + + public function setProxyFactory($proxyFactory) + { + $this->_proxyFactoryMock = $proxyFactory; + } + + public function getProxyFactory() + { + return isset($this->_proxyFactoryMock) ? $this->_proxyFactoryMock : parent::getProxyFactory(); + } + + /** + * Mock factory method to create an EntityManager. + * + * @param unknown_type $conn + * @param unknown_type $name + * @param Doctrine_Configuration $config + * @param Doctrine_EventManager $eventManager + * @return Doctrine\ORM\EntityManager + */ + public static function create($conn, \Doctrine\ORM\Configuration $config = null, + \Doctrine\Common\EventManager $eventManager = null) + { + if (is_null($config)) { + $config = new \Doctrine\ORM\Configuration(); + $config->setProxyDir(__DIR__ . '/../Proxies'); + $config->setProxyNamespace('Doctrine\Tests\Proxies'); + $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver()); + } + if (is_null($eventManager)) { + $eventManager = new \Doctrine\Common\EventManager(); + } + + return new EntityManagerMock($conn, $config, $eventManager); + } +/* + public function setIdGenerator($className, $generator) + { + $this->_idGenerators[$className] = $generator; + } +*/ + /** @override */ +/* public function getIdGenerator($className) + { + + if (isset($this->_idGenerators[$className])) { + return $this->_idGenerators[$className]; + } + + return parent::getIdGenerator($className); + } + */ +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php new file mode 100644 index 0000000..768e357 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/EntityPersisterMock.php @@ -0,0 +1,100 @@ + $entity + * @return + * @override + */ + public function insert($entity) + { + $this->_inserts[] = $entity; + if ( ! is_null($this->_mockIdGeneratorType) && $this->_mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY + || $this->_class->isIdGeneratorIdentity()) { + $id = $this->_identityColumnValueCounter++; + $this->_postInsertIds[$id] = $entity; + return $id; + } + return null; + } + + public function addInsert($entity) + { + $this->_inserts[] = $entity; + if ( ! is_null($this->_mockIdGeneratorType) && $this->_mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY + || $this->_class->isIdGeneratorIdentity()) { + $id = $this->_identityColumnValueCounter++; + $this->_postInsertIds[$id] = $entity; + return $id; + } + return null; + } + + public function executeInserts() + { + return $this->_postInsertIds; + } + + public function setMockIdGeneratorType($genType) + { + $this->_mockIdGeneratorType = $genType; + } + + public function update($entity) + { + $this->_updates[] = $entity; + } + + public function exists($entity, array $extraConditions = array()) + { + $this->existsCalled = true; + } + + public function delete($entity) + { + $this->_deletes[] = $entity; + } + + public function getInserts() + { + return $this->_inserts; + } + + public function getUpdates() + { + return $this->_updates; + } + + public function getDeletes() + { + return $this->_deletes; + } + + public function reset() + { + $this->existsCalled = false; + $this->_identityColumnValueCounter = 0; + $this->_inserts = array(); + $this->_updates = array(); + $this->_deletes = array(); + } + + public function isExistsCalled() + { + return $this->existsCalled; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php new file mode 100644 index 0000000..83e978f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php @@ -0,0 +1,111 @@ + + */ +class HydratorMockStatement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement +{ + private $_resultSet; + + /** + * Creates a new mock statement that will serve the provided fake result set to clients. + * + * @param array $resultSet The faked SQL result set. + */ + public function __construct(array $resultSet) + { + $this->_resultSet = $resultSet; + } + + /** + * Fetches all rows from the result set. + * + * @return array + */ + public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null) + { + return $this->_resultSet; + } + + public function fetchColumn($columnNumber = 0) + { + $row = current($this->_resultSet); + if ( ! is_array($row)) return false; + $val = array_shift($row); + return $val !== null ? $val : false; + } + + /** + * Fetches the next row in the result set. + * + */ + public function fetch($fetchStyle = null) + { + $current = current($this->_resultSet); + next($this->_resultSet); + return $current; + } + + /** + * Closes the cursor, enabling the statement to be executed again. + * + * @return boolean + */ + public function closeCursor() + { + return true; + } + + public function setResultSet(array $resultSet) + { + reset($resultSet); + $this->_resultSet = $resultSet; + } + + public function bindColumn($column, &$param, $type = null) + { + } + + public function bindValue($param, $value, $type = null) + { + } + + public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array()) + { + } + + public function columnCount() + { + } + + public function errorCode() + { + } + + public function errorInfo() + { + } + + public function execute($params = array()) + { + } + + public function rowCount() + { + } + + public function getIterator() + { + return $this->_resultSet; + } + + public function setFetchMode($fetchMode) + { + + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php new file mode 100644 index 0000000..0c5696b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/IdentityIdGeneratorMock.php @@ -0,0 +1,12 @@ +_mockPostInsertId = $id; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php new file mode 100644 index 0000000..fb533f4 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php @@ -0,0 +1,21 @@ +_sequenceNumber++; + } + + /** + * @override + */ + public function nextId($seqName, $ondemand = true) + { + return $this->_sequenceNumber++; + } + + /** + * @override + */ + public function lastInsertId($table = null, $field = null) + { + return $this->_sequenceNumber - 1; + } + + /** + * @override + */ + public function currId($seqName) + { + return $this->_sequenceNumber; + } + + /* Mock API */ + + public function reset() + { + $this->_sequenceNumber = 0; + } + + public function autoinc() + { + $this->_sequenceNumber++; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/TaskMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/TaskMock.php new file mode 100644 index 0000000..d4d5068 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/TaskMock.php @@ -0,0 +1,81 @@ +. + */ + +namespace Doctrine\Tests\Mocks; + +use Doctrine\Common\Cli\AbstractNamespace; + +/** + * TaskMock used for testing the CLI interface. + * @author Nils Adermann + */ +class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask +{ + /** + * Since instances of this class can be created elsewhere all instances + * register themselves in this array for later inspection. + * + * @var array(TaskMock) + */ + static public $instances = array(); + + private $runCounter = 0; + + /** + * Constructor of Task Mock Object. + * Makes sure the object can be inspected later. + * + * @param AbstractNamespace CLI Namespace, passed to parent constructor + */ + function __construct(AbstractNamespace $namespace) + { + self::$instances[] = $this; + + parent::__construct($namespace); + } + + /** + * Returns the number of times run() was called on this object. + * + * @return int + */ + public function getRunCounter() + { + return $this->runCounter; + } + + /* Mock API */ + + /** + * Method invoked by CLI to run task. + */ + public function run() + { + $this->runCounter++; + } + + /** + * Method supposed to generate the CLI Task Documentation + */ + public function buildDocumentation() + { + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php new file mode 100644 index 0000000..9535cdd --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Mocks/UnitOfWorkMock.php @@ -0,0 +1,58 @@ +_persisterMock[$entityName]) ? + $this->_persisterMock[$entityName] : parent::getEntityPersister($entityName); + } + + /** + * @param $entity + * @override + */ + public function getEntityChangeSet($entity) + { + $oid = spl_object_hash($entity); + return isset($this->_mockDataChangeSets[$oid]) ? + $this->_mockDataChangeSets[$oid] : parent::getEntityChangeSet($entity); + } + + /* MOCK API */ + + /** + * Sets a (mock) persister for an entity class that will be returned when + * getEntityPersister() is invoked for that class. + * + * @param $entityName + * @param $persister + */ + public function setEntityPersister($entityName, $persister) + { + $this->_persisterMock[$entityName] = $persister; + } + + public function setDataChangeSet($entity, array $mockChangeSet) + { + $this->_mockDataChangeSets[spl_object_hash($entity)] = $mockChangeSet; + } + + public function setEntityState($entity, $state) + { + $this->_entityStates[spl_object_hash($entity)] = $state; + } + + public function setOriginalEntityData($entity, array $originalData) + { + $this->_originalEntityData[spl_object_hash($entity)] = $originalData; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsAddress.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsAddress.php new file mode 100644 index 0000000..d32416a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsAddress.php @@ -0,0 +1,72 @@ +id; + } + + public function getUser() { + return $this->user; + } + + public function getCountry() { + return $this->country; + } + + public function getZipCode() { + return $this->zip; + } + + public function getCity() { + return $this->city; + } + + public function setUser(CmsUser $user) { + if ($this->user !== $user) { + $this->user = $user; + $user->setAddress($this); + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsArticle.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsArticle.php new file mode 100644 index 0000000..266cbc6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsArticle.php @@ -0,0 +1,48 @@ +user = $author; + } + + public function addComment(CmsComment $comment) { + $this->comments[] = $comment; + $comment->setArticle($this); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsComment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsComment.php new file mode 100644 index 0000000..3e23821 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsComment.php @@ -0,0 +1,38 @@ +article = $article; + } + + public function __toString() { + return __CLASS__."[id=".$this->id."]"; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmail.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmail.php new file mode 100644 index 0000000..c79c300 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmail.php @@ -0,0 +1,48 @@ +id; + } + + public function getEmail() { + return $this->email; + } + + public function setEmail($email) { + $this->email = $email; + } + + public function getUser() { + return $this->user; + } + + public function setUser(CmsUser $user) { + $this->user = $user; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php new file mode 100644 index 0000000..c169715 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsEmployee.php @@ -0,0 +1,44 @@ +id; + } + + public function getName() { + return $this->name; + } + + public function getSpouse() { + return $this->spouse; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsGroup.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsGroup.php new file mode 100644 index 0000000..b65ae85 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsGroup.php @@ -0,0 +1,49 @@ +name = $name; + } + + public function getName() { + return $this->name; + } + + public function addUser(CmsUser $user) { + $this->users[] = $user; + } + + public function getUsers() { + return $this->users; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php new file mode 100644 index 0000000..ff28dfd --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsPhonenumber.php @@ -0,0 +1,28 @@ +user = $user; + } + + public function getUser() { + return $this->user; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsUser.php new file mode 100644 index 0000000..05fefb5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CMS/CmsUser.php @@ -0,0 +1,139 @@ +phonenumbers = new ArrayCollection; + $this->articles = new ArrayCollection; + $this->groups = new ArrayCollection; + } + + public function getId() { + return $this->id; + } + + public function getStatus() { + return $this->status; + } + + public function getUsername() { + return $this->username; + } + + public function getName() { + return $this->name; + } + + /** + * Adds a phonenumber to the user. + * + * @param CmsPhonenumber $phone + */ + public function addPhonenumber(CmsPhonenumber $phone) { + $this->phonenumbers[] = $phone; + $phone->setUser($this); + } + + public function getPhonenumbers() { + return $this->phonenumbers; + } + + public function addArticle(CmsArticle $article) { + $this->articles[] = $article; + $article->setAuthor($this); + } + + public function addGroup(CmsGroup $group) { + $this->groups[] = $group; + $group->addUser($this); + } + + public function getGroups() { + return $this->groups; + } + + public function removePhonenumber($index) { + if (isset($this->phonenumbers[$index])) { + $ph = $this->phonenumbers[$index]; + unset($this->phonenumbers[$index]); + $ph->user = null; + return true; + } + return false; + } + + public function getAddress() { return $this->address; } + + public function setAddress(CmsAddress $address) { + if ($this->address !== $address) { + $this->address = $address; + $address->setUser($this); + } + } + + public function getEmail() { return $this->email; } + + public function setEmail(CmsEmail $email = null) { + if ($this->email !== $email) { + $this->email = $email; + + if ($email) { + $email->setUser($this); + } + } + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyAuction.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyAuction.php new file mode 100644 index 0000000..5743122 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyAuction.php @@ -0,0 +1,17 @@ +data = $data; + } + + public function getData() { + return $this->data; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyCar.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyCar.php new file mode 100644 index 0000000..5af89b2 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyCar.php @@ -0,0 +1,33 @@ +brand = $brand; + } + + public function getId() { + return $this->id; + } + + public function getBrand() { + return $this->title; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyContract.php new file mode 100644 index 0000000..7787e96 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyContract.php @@ -0,0 +1,89 @@ +engineers = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function getId() + { + return $this->id; + } + + public function markCompleted() + { + $this->completed = true; + } + + public function isCompleted() + { + return $this->completed; + } + + public function getSalesPerson() + { + return $this->salesPerson; + } + + public function setSalesPerson(CompanyEmployee $salesPerson) + { + $this->salesPerson = $salesPerson; + } + + public function getEngineers() + { + return $this->engineers; + } + + public function addEngineer(CompanyEmployee $engineer) + { + $this->engineers[] = $engineer; + } + + public function removeEngineer(CompanyEmployee $engineer) + { + $this->engineers->removeElement($engineer); + } + + abstract public function calculatePrice(); +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php new file mode 100644 index 0000000..9d15377 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEmployee.php @@ -0,0 +1,59 @@ +salary; + } + + public function setSalary($salary) { + $this->salary = $salary; + } + + public function getDepartment() { + return $this->department; + } + + public function setDepartment($dep) { + $this->department = $dep; + } + + public function getStartDate() { + return $this->startDate; + } + + public function setStartDate($date) { + $this->startDate = $date; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEvent.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEvent.php new file mode 100644 index 0000000..bb320aa --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyEvent.php @@ -0,0 +1,36 @@ +id; + } + + public function getOrganization() { + return $this->organization; + } + + public function setOrganization(CompanyOrganization $org) { + $this->organization = $org; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php new file mode 100644 index 0000000..9186fc3 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFixContract.php @@ -0,0 +1,30 @@ +fixPrice; + } + + public function getFixPrice() + { + return $this->fixPrice; + } + + public function setFixPrice($fixPrice) + { + $this->fixPrice = $fixPrice; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php new file mode 100644 index 0000000..e322888 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -0,0 +1,68 @@ +hoursWorked * $this->pricePerHour; + } + + public function getHoursWorked() + { + return $this->hoursWorked; + } + + public function setHoursWorked($hoursWorked) + { + $this->hoursWorked = $hoursWorked; + } + + public function getPricePerHour() + { + return $this->pricePerHour; + } + + public function setPricePerHour($pricePerHour) + { + $this->pricePerHour = $pricePerHour; + } + public function getManagers() + { + return $this->managers; + } + + public function addManager(CompanyManager $manager) + { + $this->managers[] = $manager; + } + + public function removeManager(CompanyManager $manager) + { + $this->managers->removeElement($manager); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php new file mode 100644 index 0000000..b9ad3d4 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyFlexUltraContract.php @@ -0,0 +1,30 @@ +maxPrice, parent::calculatePrice()); + } + + public function getMaxPrice() + { + return $this->maxPrice; + } + + public function setMaxPrice($maxPrice) + { + $this->maxPrice = $maxPrice; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyManager.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyManager.php new file mode 100644 index 0000000..aec9a77 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyManager.php @@ -0,0 +1,42 @@ +title; + } + + public function setTitle($title) { + $this->title = $title; + } + + public function getCar() { + return $this->car; + } + + public function setCar(CompanyCar $car) { + $this->car = $car; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php new file mode 100644 index 0000000..ca99410 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyOrganization.php @@ -0,0 +1,44 @@ +id; + } + + public function getEvents() { + return $this->events; + } + + public function addEvent(CompanyEvent $event) { + $this->events[] = $event; + $event->setOrganization($this); + } + + /** + * @OneToOne(targetEntity="CompanyEvent", cascade={"persist"}) + * @JoinColumn(name="main_event_id", referencedColumnName="id", nullable=true) + */ + private $mainevent; + + public function getMainEvent() { + return $this->mainevent; + } + + public function setMainEvent($event) { + $this->mainevent = $event; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyPerson.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyPerson.php new file mode 100644 index 0000000..0dfe919 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyPerson.php @@ -0,0 +1,82 @@ +friends = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function getId() { + return $this->id; + } + + public function getName() { + return $this->name; + } + + public function setName($name) { + $this->name = $name; + } + + public function getSpouse() { + return $this->spouse; + } + + public function getFriends() { + return $this->friends; + } + + public function addFriend(CompanyPerson $friend) { + if ( ! $this->friends->contains($friend)) { + $this->friends->add($friend); + $friend->addFriend($this); + } + } + + public function setSpouse(CompanyPerson $spouse) { + if ($spouse !== $this->spouse) { + $this->spouse = $spouse; + $this->spouse->setSpouse($this); + } + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php new file mode 100644 index 0000000..733190d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Company/CompanyRaffle.php @@ -0,0 +1,17 @@ +data = $data; + } + + public function getData() { + return $this->data; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php new file mode 100644 index 0000000..e178ab5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeChild.php @@ -0,0 +1,21 @@ +friendsWithMe = new \Doctrine\Common\Collections\ArrayCollection(); + $this->myFriends = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function addMyFriend(CustomTypeParent $friend) + { + $this->getMyFriends()->add($friend); + $friend->addFriendWithMe($this); + } + + public function getMyFriends() + { + return $this->myFriends; + } + + public function addFriendWithMe(CustomTypeParent $friend) + { + $this->getFriendsWithMe()->add($friend); + } + + public function getFriendsWithMe() + { + return $this->friendsWithMe; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php new file mode 100644 index 0000000..26e0ec1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/CustomType/CustomTypeUpperCase.php @@ -0,0 +1,21 @@ +articleDetails = $details; + $this->reference = $reference; + $this->translation = $translation; + } + + public function getId() + { + return $this->id; + } + + public function getArticleDetails() + { + return $this->articleDetails; + } + + public function getReference() + { + return $this->reference; + } + + public function getTranslation() + { + return $this->translation; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php new file mode 100644 index 0000000..d77bb94 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Article.php @@ -0,0 +1,87 @@ +title = $title; + $this->references = new \Doctrine\Common\Collections\ArrayCollection(); + $this->translations = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function setDetails($details) + { + $this->details = $details; + } + + public function id() + { + return $this->id; + } + + public function addReference($reference) + { + $this->references[] = $reference; + } + + public function references() + { + return $this->references; + } + + public function addTranslation($language, $title) + { + $this->translations[] = new DDC117Translation($this, $language, $title); + } + + public function getText() + { + return $this->details->getText(); + } + + public function getDetails() + { + return $this->details; + } + + public function resetText() + { + $this->details = null; + } + + public function getTranslations() + { + return $this->translations; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php new file mode 100644 index 0000000..ae13df0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117ArticleDetails.php @@ -0,0 +1,39 @@ +article = $article; + $article->setDetails($this); + + $this->update($text); + } + + public function update($text) + { + $this->text = $text; + } + + public function getText() + { + return $this->text; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php new file mode 100644 index 0000000..a323bb3 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Editor.php @@ -0,0 +1,54 @@ +name = $name; + $this->reviewingTranslations = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function addLastTranslation(DDC117Translation $t) + { + $this->lastTranslation = $t; + $t->lastTranslatedBy[] = $this; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php new file mode 100644 index 0000000..7e0084a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Link.php @@ -0,0 +1,31 @@ +source = $source; + $this->target = $target; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php new file mode 100644 index 0000000..3c9017d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Reference.php @@ -0,0 +1,64 @@ +addReference($this); + $target->addReference($this); + + $this->source = $source; + $this->target = $target; + $this->description = $description; + $this->created = new \DateTime("now"); + } + + public function source() + { + return $this->source; + } + + public function target() + { + return $this->target; + } + + public function setDescription($desc) + { + $this->description = $desc; + } + + public function getDescription() + { + return $this->description; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php new file mode 100644 index 0000000..b0fb437 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC117/DDC117Translation.php @@ -0,0 +1,65 @@ +article = $article; + $this->language = $language; + $this->title = $title; + $this->reviewedByEditors = new \Doctrine\Common\Collections\ArrayCollection(); + $this->lastTranslatedBy = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function getArticleId() + { + return $this->article->id(); + } + + public function getLanguage() + { + return $this->language; + } + + public function getLastTranslatedBy() + { + return $this->lastTranslatedBy; + } + + public function getReviewedByEditors() + { + return $this->reviewedByEditors; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php new file mode 100644 index 0000000..cc09c13 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC1476/DDC1476EntityWithDefaultFieldType.php @@ -0,0 +1,76 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC1476; + +/** + * @Entity() + */ +class DDC1476EntityWithDefaultFieldType +{ + + /** + * @Id + * @Column() + * @GeneratedValue("NONE") + */ + protected $id; + + /** @column() */ + protected $name; + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) + { + $metadata->mapField(array( + 'id' => true, + 'fieldName' => 'id', + )); + $metadata->mapField(array( + 'fieldName' => 'name', + )); + + $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE); + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php new file mode 100644 index 0000000..eaf9006 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753CustomRepository.php @@ -0,0 +1,36 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC753; + +use Doctrine\ORM\EntityRepository; + +class DDC753CustomRepository extends EntityRepository +{ + + /** + * @return bool + */ + public function isCustomRepository() + { + return true; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php new file mode 100644 index 0000000..5be9aa5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753DefaultRepository.php @@ -0,0 +1,35 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC753; + +use Doctrine\ORM\EntityRepository; + +class DDC753DefaultRepository extends EntityRepository +{ + /** + * @return bool + */ + public function isDefaultRepository() + { + return true; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php new file mode 100644 index 0000000..7b92e66 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithCustomRepository.php @@ -0,0 +1,39 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC753; + +/** + * @Entity(repositoryClass = "Doctrine\Tests\Models\DDC753\DDC753CustomRepository") + */ +class DDC753EntityWithCustomRepository +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + protected $id; + + /** @column(type="string") */ + protected $name; + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php new file mode 100644 index 0000000..8ca2a2c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithDefaultCustomRepository.php @@ -0,0 +1,39 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC753; + +/** + * @Entity() + */ +class DDC753EntityWithDefaultCustomRepository +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + protected $id; + + /** @column(type="string") */ + protected $name; + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php new file mode 100644 index 0000000..d12660c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753EntityWithInvalidRepository.php @@ -0,0 +1,39 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC753; + +/** + * @Entity(repositoryClass = "\stdClass") + */ +class DDC753EntityWithInvalidRepository +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + protected $id; + + /** @column(type="string") */ + protected $name; + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php new file mode 100644 index 0000000..9f0937a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC753/DDC753InvalidRepository.php @@ -0,0 +1,28 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC753; + +use Doctrine\ORM\EntityRepository; + +class DDC753InvalidRepository +{ + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php new file mode 100644 index 0000000..594f79f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869ChequePayment.php @@ -0,0 +1,40 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC869; + +/** + * @Entity + */ +class DDC869ChequePayment extends DDC869Payment +{ + + /** @column(type="string") */ + protected $serialNumber; + + public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) + { + $metadata->mapField(array( + 'fieldName' => 'serialNumber', + 'type' => 'string', + )); + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php new file mode 100644 index 0000000..9e978d4 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869CreditCardPayment.php @@ -0,0 +1,40 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC869; + +/** + * @Entity + */ +class DDC869CreditCardPayment extends DDC869Payment +{ + + /** @column(type="string") */ + protected $creditCardNumber; + + public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) + { + $metadata->mapField(array( + 'fieldName' => 'creditCardNumber', + 'type' => 'string', + )); + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php new file mode 100644 index 0000000..b9b8feb --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869Payment.php @@ -0,0 +1,57 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC869; + +/** + * @MappedSuperclass(repositoryClass = "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository") + */ +class DDC869Payment +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + protected $id; + + /** @column(type="float") */ + protected $value; + + + public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) + { + $metadata->mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'type' => 'integer', + 'columnName' => 'id', + )); + $metadata->mapField(array( + 'fieldName' => 'value', + 'type' => 'float', + )); + $metadata->isMappedSuperclass = true; + $metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); + $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php new file mode 100644 index 0000000..f950df0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DDC869/DDC869PaymentRepository.php @@ -0,0 +1,37 @@ +. + */ + +namespace Doctrine\Tests\Models\DDC869; + +use Doctrine\ORM\EntityRepository; + +class DDC869PaymentRepository extends EntityRepository +{ + + /** + * Very complex method + * + * @return bool + */ + public function isTrue() + { + return true; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php new file mode 100644 index 0000000..12b27ee --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/AbstractContentItem.php @@ -0,0 +1,64 @@ +. + */ + +namespace Doctrine\Tests\Models\DirectoryTree; + +/** + * @MappedSuperclass + */ +abstract class AbstractContentItem +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + private $id; + + /** + * @ManyToOne(targetEntity="Directory") + */ + protected $parentDirectory; + + /** @column(type="string") */ + protected $name; + + public function __construct(Directory $parentDir = null) + { + $this->parentDirectory = $parentDir; + } + + public function getId() + { + return $this->id; + } + + public function setName($name) + { + $this->name = $name; + } + + public function getName() + { + return $this->name; + } + + public function getParent() + { + return $this->parentDirectory; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php new file mode 100644 index 0000000..f0db778 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/Directory.php @@ -0,0 +1,41 @@ +. + */ + +namespace Doctrine\Tests\Models\DirectoryTree; + +/** + * @Entity + */ +class Directory extends AbstractContentItem +{ + /** + * @Column(type="string") + */ + protected $path; + + public function setPath($path) + { + $this->path = $path; + } + + public function getPath() + { + return $this->path; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/File.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/File.php new file mode 100644 index 0000000..3513268 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/DirectoryTree/File.php @@ -0,0 +1,46 @@ +. + */ + + +namespace Doctrine\Tests\Models\DirectoryTree; + +/** + * @Entity + * @Table(name="`file`") + */ +class File extends AbstractContentItem +{ + /** @Column(type="string") */ + protected $extension = "html"; + + public function __construct(Directory $parent = null) + { + parent::__construct($parent); + } + + public function getExtension() + { + return $this->extension; + } + + public function setExtension($ext) + { + $this->extension = $ext; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php new file mode 100644 index 0000000..3d9f679 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCart.php @@ -0,0 +1,91 @@ +products = new ArrayCollection; + } + + public function getId() { + return $this->id; + } + + public function getPayment() { + return $this->payment; + } + + public function setPayment($payment) { + $this->payment = $payment; + } + + public function setCustomer(ECommerceCustomer $customer) { + if ($this->customer !== $customer) { + $this->customer = $customer; + $customer->setCart($this); + } + } + + public function removeCustomer() { + if ($this->customer !== null) { + $customer = $this->customer; + $this->customer = null; + $customer->removeCart(); + } + } + + public function getCustomer() { + return $this->customer; + } + + public function getProducts() + { + return $this->products; + } + + public function addProduct(ECommerceProduct $product) { + $this->products[] = $product; + } + + public function removeProduct(ECommerceProduct $product) { + return $this->products->removeElement($product); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php new file mode 100644 index 0000000..a8d8dc6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCategory.php @@ -0,0 +1,126 @@ +products = new ArrayCollection(); + $this->children = new ArrayCollection(); + } + + public function getId() + { + return $this->id; + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + public function addProduct(ECommerceProduct $product) + { + if (!$this->products->contains($product)) { + $this->products[] = $product; + $product->addCategory($this); + } + } + + public function removeProduct(ECommerceProduct $product) + { + $removed = $this->products->removeElement($product); + if ($removed) { + $product->removeCategory($this); + } + } + + public function getProducts() + { + return $this->products; + } + + private function setParent(ECommerceCategory $parent) + { + $this->parent = $parent; + } + + public function getChildren() + { + return $this->children; + } + + public function getParent() + { + return $this->parent; + } + + public function addChild(ECommerceCategory $child) + { + $this->children[] = $child; + $child->setParent($this); + } + + /** does not set the owning side. */ + public function brokenAddChild(ECommerceCategory $child) + { + $this->children[] = $child; + } + + + public function removeChild(ECommerceCategory $child) + { + $removed = $this->children->removeElement($child); + if ($removed) { + $child->removeParent(); + } + } + + private function removeParent() + { + $this->parent = null; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php new file mode 100644 index 0000000..a5de9e1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceCustomer.php @@ -0,0 +1,94 @@ +id; + } + + public function getName() { + return $this->name; + } + + public function setName($name) { + $this->name = $name; + } + + public function setCart(ECommerceCart $cart) + { + if ($this->cart !== $cart) { + $this->cart = $cart; + $cart->setCustomer($this); + } + } + + /* Does not properly maintain the bidirectional association! */ + public function brokenSetCart(ECommerceCart $cart) { + $this->cart = $cart; + } + + public function getCart() { + return $this->cart; + } + + public function removeCart() + { + if ($this->cart !== null) { + $cart = $this->cart; + $this->cart = null; + $cart->removeCustomer(); + } + } + + public function setMentor(ECommerceCustomer $mentor) + { + $this->mentor = $mentor; + } + + public function removeMentor() + { + $this->mentor = null; + } + + public function getMentor() + { + return $this->mentor; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php new file mode 100644 index 0000000..04fc2be --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceFeature.php @@ -0,0 +1,59 @@ +id; + } + + public function getDescription() { + return $this->description; + } + + public function setDescription($description) { + $this->description = $description; + } + + public function setProduct(ECommerceProduct $product) { + $this->product = $product; + } + + public function removeProduct() { + if ($this->product !== null) { + $product = $this->product; + $this->product = null; + $product->removeFeature($this); + } + } + + public function getProduct() { + return $this->product; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php new file mode 100644 index 0000000..f053fd2 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceProduct.php @@ -0,0 +1,178 @@ +features = new ArrayCollection; + $this->categories = new ArrayCollection; + $this->related = new ArrayCollection; + } + + public function getId() + { + return $this->id; + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + public function getShipping() + { + return $this->shipping; + } + + public function setShipping(ECommerceShipping $shipping) + { + $this->shipping = $shipping; + } + + public function removeShipping() + { + $this->shipping = null; + } + + public function getFeatures() + { + return $this->features; + } + + public function addFeature(ECommerceFeature $feature) + { + $this->features[] = $feature; + $feature->setProduct($this); + } + + /** does not set the owning side */ + public function brokenAddFeature(ECommerceFeature $feature) + { + $this->features[] = $feature; + } + + public function removeFeature(ECommerceFeature $feature) + { + $removed = $this->features->removeElement($feature); + if ($removed) { + $feature->removeProduct(); + } + return $removed; + } + + public function addCategory(ECommerceCategory $category) + { + if (!$this->categories->contains($category)) { + $this->categories[] = $category; + $category->addProduct($this); + } + } + + public function removeCategory(ECommerceCategory $category) + { + $removed = $this->categories->removeElement($category); + if ($removed) { + $category->removeProduct($this); + } + } + + public function getCategories() + { + return $this->categories; + } + + public function getRelated() + { + return $this->related; + } + + public function addRelated(ECommerceProduct $related) + { + if (!$this->related->contains($related)) { + $this->related[] = $related; + $related->addRelated($this); + } + } + + public function removeRelated(ECommerceProduct $related) + { + $removed = $this->related->removeElement($related); + if ($removed) { + $related->removeRelated($this); + } + } + + public function __clone() + { + $this->isCloned = true; + } + + /** + * Testing docblock contents here + */ + public function __wakeup() + { + $this->wakeUp = true; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php new file mode 100644 index 0000000..a0f302c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/ECommerce/ECommerceShipping.php @@ -0,0 +1,40 @@ +id; + } + + public function getDays() + { + return $this->days; + } + + public function setDays($days) + { + $this->days = $days; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php new file mode 100644 index 0000000..13d78ab --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumAdministrator.php @@ -0,0 +1,14 @@ +id; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumEntry.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumEntry.php new file mode 100644 index 0000000..efa359b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumEntry.php @@ -0,0 +1,26 @@ +topic; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumUser.php new file mode 100644 index 0000000..3f3b5d9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Forum/ForumUser.php @@ -0,0 +1,41 @@ +id; + } + + public function getUsername() { + return $this->username; + } + + public function getAvatar() { + return $this->avatar; + } + + public function setAvatar(ForumAvatar $avatar) { + $this->avatar = $avatar; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/BooleanModel.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/BooleanModel.php new file mode 100644 index 0000000..2c93156 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Generic/BooleanModel.php @@ -0,0 +1,20 @@ +_user = $author; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php new file mode 100644 index 0000000..ac38341 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyCar.php @@ -0,0 +1,41 @@ +_description; + } + + public function addUser(LegacyUser $user) { + $this->_users[] = $user; + } + + public function getUsers() { + return $this->_users; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php new file mode 100644 index 0000000..3e3deed --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUser.php @@ -0,0 +1,80 @@ +_articles = new ArrayCollection; + $this->_references = new ArrayCollection; + $this->_cars = new ArrayCollection; + } + + public function getId() { + return $this->_id; + } + + public function getUsername() { + return $this->_username; + } + + public function addArticle(LegacyArticle $article) { + $this->_articles[] = $article; + $article->setAuthor($this); + } + + public function addReference($reference) + { + $this->_references[] = $reference; + } + + public function references() + { + return $this->_references; + } + + public function addCar(LegacyCar $car) { + $this->_cars[] = $car; + $car->addUser($this); + } + + public function getCars() { + return $this->_cars; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php new file mode 100644 index 0000000..8dc20db --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Legacy/LegacyUserReference.php @@ -0,0 +1,65 @@ +addReference($this); + $target->addReference($this); + + $this->_source = $source; + $this->_target = $target; + $this->_description = $description; + $this->_created = new \DateTime("now"); + } + + public function source() + { + return $this->_source; + } + + public function target() + { + return $this->_target; + } + + public function setDescription($desc) + { + $this->_description = $desc; + } + + public function getDescription() + { + return $this->_description; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavCountry.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavCountry.php new file mode 100644 index 0000000..fd37552 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavCountry.php @@ -0,0 +1,39 @@ +name = $name; + } + + public function getId() { + return $this->id; + } + + public function getName() { + return $this->name; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php new file mode 100644 index 0000000..25858d0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPhotos.php @@ -0,0 +1,48 @@ +poi = $poi; + $this->file = $file; + } + + public function getId() { + return $this->id; + } + + public function getPointOfInterest() { + return $this->poi; + } + + public function getFile() { + return $this->file; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php new file mode 100644 index 0000000..662a57a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavPointOfInterest.php @@ -0,0 +1,56 @@ +lat = $lat; + $this->long = $long; + $this->name = $name; + $this->country = $country; + } + + public function getLong() { + return $this->long; + } + + public function getLat() { + return $this->lat; + } + + public function getName() { + return $this->name; + } + + public function getCountry() { + return $this->country; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavTour.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavTour.php new file mode 100644 index 0000000..5a58017 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Navigation/NavTour.php @@ -0,0 +1,61 @@ +name = $name; + $this->pois = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function addPointOfInterest(NavPointOfInterest $poi) + { + $this->pois[] = $poi; + } + + public function getPointOfInterests() + { + return $this->pois; + } + + public function getName() + { + return $this->name; + } + + public function getId() + { + return $this->id; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php new file mode 100644 index 0000000..a130e7b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingLeg.php @@ -0,0 +1,37 @@ +name; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php new file mode 100644 index 0000000..9e5d5d0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRoute.php @@ -0,0 +1,39 @@ +legs = new ArrayCollection(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php new file mode 100644 index 0000000..9b862fc --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/Routing/RoutingRouteBooking.php @@ -0,0 +1,32 @@ +passengerName; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php new file mode 100644 index 0000000..c8d6617 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Bond.php @@ -0,0 +1,48 @@ +name = $name; + } + + public function getId() + { + return $this->id; + } + + public function addStock(Stock $stock) + { + $this->stocks[$stock->getSymbol()] = $stock; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Market.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Market.php new file mode 100644 index 0000000..87e12ca --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Market.php @@ -0,0 +1,56 @@ +name = $name; + $this->stocks = new ArrayCollection(); + } + + public function getId() + { + return $this->id; + } + + public function getName() + { + return $this->name; + } + + public function addStock(Stock $stock) + { + $this->stocks[$stock->getSymbol()] = $stock; + } + + public function getStock($symbol) + { + return $this->stocks[$symbol]; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Stock.php b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Stock.php new file mode 100644 index 0000000..d65675b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/Models/StockExchange/Stock.php @@ -0,0 +1,49 @@ +symbol = $symbol; + $this->price = $initialOfferingPrice; + $this->market = $market; + $market->addStock($this); + } + + public function getSymbol() + { + return $this->symbol; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php new file mode 100644 index 0000000..ff82059 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/CommitOrderCalculatorTest.php @@ -0,0 +1,56 @@ +_calc = new \Doctrine\ORM\Internal\CommitOrderCalculator(); + } + + public function testCommitOrdering1() + { + $class1 = new ClassMetadata(__NAMESPACE__ . '\NodeClass1'); + $class2 = new ClassMetadata(__NAMESPACE__ . '\NodeClass2'); + $class3 = new ClassMetadata(__NAMESPACE__ . '\NodeClass3'); + $class4 = new ClassMetadata(__NAMESPACE__ . '\NodeClass4'); + $class5 = new ClassMetadata(__NAMESPACE__ . '\NodeClass5'); + + $this->_calc->addClass($class1); + $this->_calc->addClass($class2); + $this->_calc->addClass($class3); + $this->_calc->addClass($class4); + $this->_calc->addClass($class5); + + $this->_calc->addDependency($class1, $class2); + $this->_calc->addDependency($class2, $class3); + $this->_calc->addDependency($class3, $class4); + $this->_calc->addDependency($class5, $class1); + + $sorted = $this->_calc->getCommitOrder(); + + // There is only 1 valid ordering for this constellation + $correctOrder = array($class5, $class1, $class2, $class3, $class4); + $this->assertSame($correctOrder, $sorted); + } +} + +class NodeClass1 {} +class NodeClass2 {} +class NodeClass3 {} +class NodeClass4 {} +class NodeClass5 {} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php new file mode 100644 index 0000000..b3aa607 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php @@ -0,0 +1,252 @@ +. + */ + +namespace Doctrine\Tests\ORM\Query; + +require_once __DIR__ . '/../../TestInit.php'; + +/** + * Test case for testing the saving and referencing of query identifiers. + * + * @author Guilherme Blanco + * @author Janne Vanhala + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://www.doctrine-project.org + * @since 2.0 + * @version $Revision$ + */ +class DqlGenerationTest extends \Doctrine\Tests\OrmTestCase +{ + protected function setUp() { + $this->markTestSkipped('Not yet implemented.'); + } + + protected function createQuery() + { + return $this->_em->createQuery(); + } + + public function testSelect() + { + $query = $this->createQuery(); + + // select and from + $query->setDql('FROM User u'); + $this->assertEquals('FROM User u', $query->getDql()); // Internally we use SELECT * FROM User u to process the DQL + $query->free(); + + $query->select()->from('User u'); + $this->assertEquals('SELECT * FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.*')->from('User u'); + $this->assertEquals('SELECT u.* FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.id')->from('User u'); + $this->assertEquals('SELECT u.id FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.id, u.name')->from('User u'); + $this->assertEquals('SELECT u.id, u.name FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.name AS myCustomName')->from('User u'); + $this->assertEquals('SELECT u.name AS myCustomName FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.id')->select('u.name')->from('User u'); + $this->assertEquals('SELECT u.id, u.name FROM User u', $query->getDql()); + $query->free(); + } + + + public function testSelectDistinct() + { + $query = $this->createQuery(); + + $query->select()->distinct()->from('User u'); + $this->assertEquals('SELECT DISTINCT * FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.name')->distinct(false)->from('User u'); + $this->assertEquals('SELECT u.name FROM User u', $query->getDql()); + $query->free(); + + $query->select()->distinct(false)->from('User u'); + $this->assertEquals('SELECT * FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.name')->distinct()->from('User u'); + $this->assertEquals('SELECT DISTINCT u.name FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.name, u.email')->distinct()->from('User u'); + $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); + $query->free(); + + $query->select('u.name')->select('u.email')->distinct()->from('User u'); + $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); + $query->free(); + + $query->select('DISTINCT u.name')->from('User u'); + $this->assertEquals('SELECT DISTINCT u.name FROM User u', $query->getDql()); + $query->free(); + + $query->select('DISTINCT u.name, u.email')->from('User u'); + $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); + $query->free(); + + $query->select('DISTINCT u.name')->select('u.email')->from('User u'); + $this->assertEquals('SELECT DISTINCT u.name, u.email FROM User u', $query->getDql()); + $query->free(); + } + + + public function testSelectJoin() + { + $query = $this->createQuery(); + + $query->select('u.*')->from('User u')->join('u.Group g')->where('g.id = ?', 1); + $this->assertEquals('SELECT u.* FROM User u INNER JOIN u.Group g WHERE g.id = ?', $query->getDql()); + $this->assertEquals(array(1), $query->getParams()); + $query->free(); + + $query->select('u.*')->from('User u')->innerJoin('u.Group g')->where('g.id = ?', 1); + $this->assertEquals('SELECT u.* FROM User u INNER JOIN u.Group g WHERE g.id = ?', $query->getDql()); + $this->assertEquals(array(1), $query->getParams()); + $query->free(); + + $query->select('u.*')->from('User u')->leftJoin('u.Group g')->where('g.id IS NULL'); + $this->assertEquals('SELECT u.* FROM User u LEFT JOIN u.Group g WHERE g.id IS NULL', $query->getDql()); + $query->free(); + + $query->select('u.*')->from('User u')->leftJoin('u.UserGroup ug')->leftJoin('ug.Group g')->where('g.name = ?', 'admin'); + $this->assertEquals('SELECT u.* FROM User u LEFT JOIN u.UserGroup ug LEFT JOIN ug.Group g WHERE g.name = ?', $query->getDql()); + $query->free(); + } + + + public function testSelectWhere() + { + $query = $this->createQuery(); + + $query->select('u.name')->from('User u')->where('u.id = ?', 1); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ?', $query->getDql()); + $this->assertEquals(array(1), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->where('u.id = ? AND u.type != ?', array(1, 'admin')); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? AND u.type != ?', $query->getDql()); + $this->assertEquals(array(1, 'admin'), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->where('u.id = ?', 1)->andWhere('u.type != ?', 'admin'); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? AND u.type != ?', $query->getDql()); + $this->assertEquals(array(1, 'admin'), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->where('( u.id = ?', 1)->andWhere('u.type != ? )', 'admin'); + $this->assertEquals('SELECT u.name FROM User u WHERE ( u.id = ? AND u.type != ? )', $query->getDql()); + $this->assertEquals(array(1, 'admin'), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->where('u.id = ? OR u.type != ?', array(1, 'admin')); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? OR u.type != ?', $query->getDql()); + $this->assertEquals(array(1, 'admin'), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->where('u.id = ?', 1)->orWhere('u.type != ?', 'admin'); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? OR u.type != ?', $query->getDql()); + $this->assertEquals(array(1, 'admin'), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->andwhere('u.id = ?', 1)->andWhere('u.type != ?', 'admin')->orWhere('u.email = ?', 'admin@localhost'); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id = ? AND u.type != ? OR u.email = ?', $query->getDql()); + $this->assertEquals(array(1, 'admin', 'admin@localhost'), $query->getParams()); + $query->free(); + } + + + public function testSelectWhereIn() + { + $query = $this->createQuery(); + + $query->select('u.name')->from('User u')->whereIn('u.id', array(1, 2, 3, 4, 5)); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id IN (?, ?, ?, ?, ?)', $query->getDql()); + $this->assertEquals(array(1, 2, 3, 4, 5), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->whereNotIn('u.id', array(1, 2, 3)); + $this->assertEquals('SELECT u.name FROM User u WHERE u.id NOT IN (?, ?, ?)', $query->getDql()); + $this->assertEquals(array(1, 2, 3), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->where('u.type = ?', 'admin')->andWhereIn('u.id', array(1, 2)); + $this->assertEquals('SELECT u.name FROM User u WHERE u.type = ? AND u.id IN (?, ?)', $query->getDql()); + $this->assertEquals(array('admin', 1, 2), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->where('u.type = ?', 'admin')->andWhereNotIn('u.id', array(1, 2)); + $this->assertEquals('SELECT u.name FROM User u WHERE u.type = ? AND u.id NOT IN (?, ?)', $query->getDql()); + $this->assertEquals(array('admin', 1, 2), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->whereIn('u.type', array('admin', 'moderator'))->andWhereNotIn('u.id', array(1, 2, 3, 4)); + $this->assertEquals('SELECT u.name FROM User u WHERE u.type IN (?, ?) AND u.id NOT IN (?, ?, ?, ?)', $query->getDql()); + $this->assertEquals(array('admin', 'moderator', 1, 2, 3, 4), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->whereIn('u.type', array('admin', 'moderator'))->orWhereIn('u.id', array(1, 2, 3, 4)); + $this->assertEquals('SELECT u.name FROM User u WHERE u.type IN (?, ?) OR u.id IN (?, ?, ?, ?)', $query->getDql()); + $this->assertEquals(array('admin', 'moderator', 1, 2, 3, 4), $query->getParams()); + $query->free(); + + $query->select('u.name')->from('User u')->whereIn('u.type', array('admin', 'moderator'))->andWhereNotIn('u.id', array(1, 2))->orWhereNotIn('u.type', array('admin', 'moderator'))->andWhereNotIn('u.email', array('user@localhost', 'guest@localhost')); + $this->assertEquals('SELECT u.name FROM User u WHERE u.type IN (?, ?) AND u.id NOT IN (?, ?) OR u.type NOT IN (?, ?) AND u.email NOT IN (?, ?)', $query->getDql()); + $this->assertEquals(array('admin', 'moderator', 1, 2, 'admin', 'moderator', 'user@localhost', 'guest@localhost'), $query->getParams()); + $query->free(); + } + + + public function testDelete() + { + $query = $this->createQuery(); + + $query->setDql('DELETE CmsUser u'); + $this->assertEquals('DELETE CmsUser u', $query->getDql()); + $query->free(); + + $query->delete()->from('CmsUser u'); + $this->assertEquals('DELETE FROM CmsUser u', $query->getDql()); + $query->free(); + + $query->delete()->from('CmsUser u')->where('u.id = ?', 1); + $this->assertEquals('DELETE FROM CmsUser u WHERE u.id = ?', $query->getDql()); + $query->free(); + + $query->delete()->from('CmsUser u')->where('u.username = ?', 'gblanco')->orWhere('u.name = ?', 'Guilherme'); + $this->assertEquals('DELETE FROM CmsUser u WHERE u.username = ? OR u.name = ?', $query->getDql()); + $query->free(); + } + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php new file mode 100644 index 0000000..014a7b4 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Entity/ConstructorTest.php @@ -0,0 +1,28 @@ +assertEquals("romanb", $entity->username); + } +} + +class ConstructorTestEntity1 +{ + private $id; + public $username; + + public function __construct($username = null) + { + if ($username !== null) { + $this->username = $username; + } + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/EntityManagerTest.php new file mode 100644 index 0000000..5f15781 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -0,0 +1,158 @@ +_em = $this->_getTestEntityManager(); + } + + /** + * @group DDC-899 + */ + public function testIsOpen() + { + $this->assertTrue($this->_em->isOpen()); + $this->_em->close(); + $this->assertFalse($this->_em->isOpen()); + } + + public function testGetConnection() + { + $this->assertInstanceOf('Doctrine\DBAL\Connection', $this->_em->getConnection()); + } + + public function testGetMetadataFactory() + { + $this->assertInstanceOf('Doctrine\ORM\Mapping\ClassMetadataFactory', $this->_em->getMetadataFactory()); + } + + public function testGetConfiguration() + { + $this->assertInstanceOf('Doctrine\ORM\Configuration', $this->_em->getConfiguration()); + } + + public function testGetUnitOfWork() + { + $this->assertInstanceOf('Doctrine\ORM\UnitOfWork', $this->_em->getUnitOfWork()); + } + + public function testGetProxyFactory() + { + $this->assertInstanceOf('Doctrine\ORM\Proxy\ProxyFactory', $this->_em->getProxyFactory()); + } + + public function testGetEventManager() + { + $this->assertInstanceOf('Doctrine\Common\EventManager', $this->_em->getEventManager()); + } + + public function testCreateNativeQuery() + { + $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); + $query = $this->_em->createNativeQuery('SELECT foo', $rsm); + + $this->assertSame('SELECT foo', $query->getSql()); + } + + public function testCreateQueryBuilder() + { + $this->assertInstanceOf('Doctrine\ORM\QueryBuilder', $this->_em->createQueryBuilder()); + } + + public function testCreateQueryBuilderAliasValid() + { + $q = $this->_em->createQueryBuilder() + ->select('u')->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $q2 = clone $q; + + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q->getQuery()->getDql()); + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q2->getQuery()->getDql()); + + $q3 = clone $q; + + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $q3->getQuery()->getDql()); + } + + public function testCreateQuery_DqlIsOptional() + { + $this->assertInstanceOf('Doctrine\ORM\Query', $this->_em->createQuery()); + } + + public function testGetPartialReference() + { + $user = $this->_em->getPartialReference('Doctrine\Tests\Models\CMS\CmsUser', 42); + $this->assertTrue($this->_em->contains($user)); + $this->assertEquals(42, $user->id); + $this->assertNull($user->getName()); + } + + public function testCreateQuery() + { + $q = $this->_em->createQuery('SELECT 1'); + $this->assertInstanceOf('Doctrine\ORM\Query', $q); + $this->assertEquals('SELECT 1', $q->getDql()); + } + + static public function dataMethodsAffectedByNoObjectArguments() + { + return array( + array('persist'), + array('remove'), + array('merge'), + array('refresh'), + array('detach') + ); + } + + /** + * @dataProvider dataMethodsAffectedByNoObjectArguments + * @expectedException \InvalidArgumentException + * @param string $methodName + */ + public function testThrowsExceptionOnNonObjectValues($methodName) { + $this->_em->$methodName(null); + } + + static public function dataAffectedByErrorIfClosedException() + { + return array( + array('flush'), + array('persist'), + array('remove'), + array('merge'), + array('refresh'), + ); + } + + /** + * @dataProvider dataAffectedByErrorIfClosedException + * @param string $methodName + */ + public function testAffectedByErrorIfClosedException($methodName) + { + $this->setExpectedException('Doctrine\ORM\ORMException', 'closed'); + + $this->_em->close(); + $this->_em->$methodName(new \stdClass()); + } + + /** + * @group DDC-1125 + */ + public function testTransactionalAcceptsReturn() + { + $return = $this->_em->transactional(function ($em) { + return 'foo'; + }); + + $this->assertEquals('foo', $return); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php new file mode 100644 index 0000000..f11ad26 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AbstractManyToManyAssociationTestCase.php @@ -0,0 +1,42 @@ +assertEquals(1, $this->_countForeignKeys($firstId, $secondId)); + } + + public function assertForeignKeysNotContain($firstId, $secondId) + { + $this->assertEquals(0, $this->_countForeignKeys($firstId, $secondId)); + } + + protected function _countForeignKeys($firstId, $secondId) + { + return count($this->_em->getConnection()->executeQuery(" + SELECT {$this->_firstField} + FROM {$this->_table} + WHERE {$this->_firstField} = ? + AND {$this->_secondField} = ? + ", array($firstId, $secondId))->fetchAll()); + } + + public function assertCollectionEquals(Collection $first, Collection $second) + { + return $first->forAll(function($k, $e) use($second) { return $second->contains($e); }); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php new file mode 100644 index 0000000..f152796 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php @@ -0,0 +1,598 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Phrase'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PhraseType'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Definition'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Lemma'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Type') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + + public function testIssue() + { + //setup + $phrase = new Phrase; + $phrase->setPhrase('lalala'); + + $type = new PhraseType; + $type->setType('nonsense'); + $type->setAbbreviation('non'); + + $def1 = new Definition; + $def1->setDefinition('def1'); + $def2 = new Definition; + $def2->setDefinition('def2'); + + $phrase->setType($type); + $phrase->addDefinition($def1); + $phrase->addDefinition($def2); + + $this->_em->persist($phrase); + $this->_em->persist($type); + + $this->_em->flush(); + $this->_em->clear(); + //end setup + + // test1 - lazy-loading many-to-one after find() + $phrase2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Phrase', $phrase->getId()); + $this->assertTrue(is_numeric($phrase2->getType()->getId())); + + $this->_em->clear(); + + // test2 - eager load in DQL query + $query = $this->_em->createQuery("SELECT p,t FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t"); + $res = $query->getResult(); + $this->assertEquals(1, count($res)); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType()); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases()); + $this->assertFalse($res[0]->getType()->getPhrases()->isInitialized()); + + $this->_em->clear(); + + // test2 - eager load in DQL query with double-join back and forth + $query = $this->_em->createQuery("SELECT p,t,pp FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t JOIN t.phrases pp"); + $res = $query->getResult(); + $this->assertEquals(1, count($res)); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType()); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases()); + $this->assertTrue($res[0]->getType()->getPhrases()->isInitialized()); + + $this->_em->clear(); + + // test3 - lazy-loading one-to-many after find() + $phrase3 = $this->_em->find('Doctrine\Tests\ORM\Functional\Phrase', $phrase->getId()); + $definitions = $phrase3->getDefinitions(); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $definitions); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]); + + $this->_em->clear(); + + // test4 - lazy-loading after DQL query + $query = $this->_em->createQuery("SELECT p FROM Doctrine\Tests\ORM\Functional\Phrase p"); + $res = $query->getResult(); + $definitions = $res[0]->getDefinitions(); + + $this->assertEquals(1, count($res)); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]); + $this->assertEquals(2, $definitions->count()); + } + + public function testManyToMany() + { + $lemma = new Lemma; + $lemma->setLemma('abu'); + + $type = new Type(); + $type->setType('nonsense'); + $type->setAbbreviation('non'); + + $lemma->addType($type); + + $this->_em->persist($lemma); + $this->_em->persist($type); + $this->_em->flush(); + + // test5 ManyToMany + $query = $this->_em->createQuery("SELECT l FROM Doctrine\Tests\ORM\Functional\Lemma l"); + $res = $query->getResult(); + $types = $res[0]->getTypes(); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Type', $types[0]); + } +} + +/** + * @Entity + * @Table(name="lemma") + */ +class Lemma { + + const CLASS_NAME = __CLASS__; + + /** + * @var int + * @Id + * @Column(type="integer", name="lemma_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * + * @var string + * @Column(type="string", name="lemma_name", unique=true, length=255) + */ + private $lemma; + + /** + * @var kateglo\application\utilities\collections\ArrayCollection + * @ManyToMany(targetEntity="Type", mappedBy="lemmas", cascade={"persist"}) + */ + private $types; + + public function __construct() { + $this->types = new \Doctrine\Common\Collections\ArrayCollection(); + } + + + /** + * + * @return int + */ + public function getId(){ + return $this->id; + } + + /** + * + * @param string $lemma + * @return void + */ + public function setLemma($lemma){ + $this->lemma = $lemma; + } + + /** + * + * @return string + */ + public function getLemma(){ + return $this->lemma; + } + + /** + * + * @param kateglo\application\models\Type $type + * @return void + */ + public function addType(Type $type){ + if (!$this->types->contains($type)) { + $this->types[] = $type; + $type->addLemma($this); + } + } + + /** + * + * @param kateglo\application\models\Type $type + * @return void + */ + public function removeType(Type $type) + { + $removed = $this->sources->removeElement($type); + if ($removed !== null) { + $removed->removeLemma($this); + } + } + + /** + * + * @return kateglo\application\helpers\collections\ArrayCollection + */ + public function getTypes() + { + return $this->types; + } +} + +/** + * @Entity + * @Table(name="type") + */ +class Type { + + const CLASS_NAME = __CLASS__; + + /** + * + * @var int + * @Id + * @Column(type="integer", name="type_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * + * @var string + * @Column(type="string", name="type_name", unique=true) + */ + private $type; + + /** + * + * @var string + * @Column(type="string", name="type_abbreviation", unique=true) + */ + private $abbreviation; + + /** + * @var kateglo\application\helpers\collections\ArrayCollection + * @ManyToMany(targetEntity="Lemma") + * @JoinTable(name="lemma_type", + * joinColumns={@JoinColumn(name="type_id", referencedColumnName="type_id")}, + * inverseJoinColumns={@JoinColumn(name="lemma_id", referencedColumnName="lemma_id")} + * ) + */ + private $lemmas; + + public function __construct(){ + $this->lemmas = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * + * @return int + */ + public function getId(){ + return $this->id; + } + + /** + * + * @param string $type + * @return void + */ + public function setType($type){ + $this->type = $type; + } + + /** + * + * @return string + */ + public function getType(){ + return $this->type; + } + + /** + * + * @param string $abbreviation + * @return void + */ + public function setAbbreviation($abbreviation){ + $this->abbreviation = $abbreviation; + } + + /** + * + * @return string + */ + public function getAbbreviation(){ + return $this->abbreviation; + } + + /** + * + * @param kateglo\application\models\Lemma $lemma + * @return void + */ + public function addLemma(Lemma $lemma) + { + if (!$this->lemmas->contains($lemma)) { + $this->lemmas[] = $lemma; + $lemma->addType($this); + } + } + + /** + * + * @param kateglo\application\models\Lemma $lemma + * @return void + */ + public function removeLEmma(Lemma $lemma) + { + $removed = $this->lemmas->removeElement($lemma); + if ($removed !== null) { + $removed->removeType($this); + } + } + + /** + * + * @return kateglo\application\helpers\collections\ArrayCollection + */ + public function getCategories() + { + return $this->categories; + } + +} + + +/** + * @Entity + * @Table(name="phrase") + */ +class Phrase { + + const CLASS_NAME = __CLASS__; + + /** + * @Id + * @Column(type="integer", name="phrase_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @Column(type="string", name="phrase_name", unique=true, length=255) + */ + private $phrase; + + /** + * @ManyToOne(targetEntity="PhraseType") + * @JoinColumn(name="phrase_type_id", referencedColumnName="phrase_type_id") + */ + private $type; + + /** + * @OneToMany(targetEntity="Definition", mappedBy="phrase", cascade={"persist"}) + */ + private $definitions; + + public function __construct() { + $this->definitions = new \Doctrine\Common\Collections\ArrayCollection; + } + + /** + * + * @param Definition $definition + * @return void + */ + public function addDefinition(Definition $definition){ + $this->definitions[] = $definition; + $definition->setPhrase($this); + } + + /** + * @return int + */ + public function getId(){ + return $this->id; + } + + /** + * @param string $phrase + * @return void + */ + public function setPhrase($phrase){ + $this->phrase = $phrase; + } + + /** + * @return string + */ + public function getPhrase(){ + return $this->phrase; + } + + /** + * + * @param PhraseType $type + * @return void + */ + public function setType(PhraseType $type){ + $this->type = $type; + } + + /** + * + * @return PhraseType + */ + public function getType(){ + return $this->type; + } + + /** + * + * @return ArrayCollection + */ + public function getDefinitions(){ + return $this->definitions; + } +} + +/** + * @Entity + * @Table(name="phrase_type") + */ +class PhraseType { + + const CLASS_NAME = __CLASS__; + + /** + * @Id + * @Column(type="integer", name="phrase_type_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @Column(type="string", name="phrase_type_name", unique=true) + */ + private $type; + + /** + * @Column(type="string", name="phrase_type_abbreviation", unique=true) + */ + private $abbreviation; + + /** + * @OneToMany(targetEntity="Phrase", mappedBy="type") + */ + private $phrases; + + public function __construct() { + $this->phrases = new \Doctrine\Common\Collections\ArrayCollection; + } + + /** + * @return int + */ + public function getId(){ + return $this->id; + } + + /** + * @param string $type + * @return void + */ + public function setType($type){ + $this->type = $type; + } + + /** + * @return string + */ + public function getType(){ + return $this->type; + } + + /** + * @param string $abbreviation + * @return void + */ + public function setAbbreviation($abbreviation){ + $this->abbreviation = $abbreviation; + } + + /** + * @return string + */ + public function getAbbreviation(){ + return $this->abbreviation; + } + + /** + * @param ArrayCollection $phrases + * @return void + */ + public function setPhrases($phrases){ + $this->phrases = $phrases; + } + + /** + * + * @return ArrayCollection + */ + public function getPhrases(){ + return $this->phrases; + } + +} + +/** + * @Entity + * @Table(name="definition") + */ +class Definition { + + const CLASS_NAME = __CLASS__; + + /** + * @Id + * @Column(type="integer", name="definition_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @ManyToOne(targetEntity="Phrase") + * @JoinColumn(name="definition_phrase_id", referencedColumnName="phrase_id") + */ + private $phrase; + + /** + * @Column(type="text", name="definition_text") + */ + private $definition; + + /** + * @return int + */ + public function getId(){ + return $this->id; + } + + /** + * @param Phrase $phrase + * @return void + */ + public function setPhrase(Phrase $phrase){ + $this->phrase = $phrase; + } + + /** + * @return Phrase + */ + public function getPhrase(){ + return $this->phrase; + } + + public function removePhrase() { + if ($this->phrase !== null) { + /*@var $phrase kateglo\application\models\Phrase */ + $phrase = $this->phrase; + $this->phrase = null; + $phrase->removeDefinition($this); + } + } + + /** + * @param string $definition + * @return void + */ + public function setDefinition($definition){ + $this->definition = $definition; + } + + /** + * @return string + */ + public function getDefinition(){ + return $this->definition; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php new file mode 100644 index 0000000..e7bb831 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php @@ -0,0 +1,181 @@ + + */ +class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() + { + $this->useModelSet('company'); + parent::setUp(); + + $this->generateFixture(); + } + + public function testAggregateWithHavingClause() + { + $dql = 'SELECT p.department, AVG(p.salary) AS avgSalary '. + 'FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. + 'GROUP BY p.department HAVING SUM(p.salary) > 200000 ORDER BY p.department'; + + $result = $this->_em->createQuery($dql)->getScalarResult(); + + $this->assertEquals(2, count($result)); + $this->assertEquals('IT', $result[0]['department']); + $this->assertEquals(150000, $result[0]['avgSalary']); + $this->assertEquals('IT2', $result[1]['department']); + $this->assertEquals(600000, $result[1]['avgSalary']); + } + + public function testUnnamedScalarResultsAreOneBased() + { + $dql = 'SELECT p.department, AVG(p.salary) '. + 'FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. + 'GROUP BY p.department HAVING SUM(p.salary) > 200000 ORDER BY p.department'; + + $result = $this->_em->createQuery($dql)->getScalarResult(); + + $this->assertEquals(2, count($result)); + $this->assertEquals(150000, $result[0][1]); + $this->assertEquals(600000, $result[1][1]); + } + + public function testOrderByResultVariableCollectionSize() + { + $dql = 'SELECT p.name, size(p.friends) AS friends ' . + 'FROM Doctrine\Tests\Models\Company\CompanyPerson p ' . + 'WHERE p.friends IS NOT EMPTY ' . + 'ORDER BY friends DESC, p.name DESC'; + + $result = $this->_em->createQuery($dql)->getScalarResult(); + + $this->assertEquals(4, count($result)); + + $this->assertEquals("Jonathan W.", $result[0]['name']); + $this->assertEquals(3, $result[0]['friends']); + + $this->assertEquals('Guilherme B.', $result[1]['name']); + $this->assertEquals(2, $result[1]['friends']); + + $this->assertEquals('Benjamin E.', $result[2]['name']); + $this->assertEquals(2, $result[2]['friends']); + + $this->assertEquals('Roman B.', $result[3]['name']); + $this->assertEquals(1, $result[3]['friends']); + } + + public function testIsNullAssocation() + { + $dql = 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p '. + 'WHERE p.spouse IS NULL'; + $result = $this->_em->createQuery($dql)->getResult(); + + $this->assertEquals(2, count($result)); + $this->assertTrue($result[0]->getId() > 0); + $this->assertNull($result[0]->getSpouse()); + + $this->assertTrue($result[1]->getId() > 0); + $this->assertNull($result[1]->getSpouse()); + } + + public function testSelectSubselect() + { + $dql = 'SELECT p, (SELECT c.brand FROM Doctrine\Tests\Models\Company\CompanyCar c WHERE p.car = c) brandName '. + 'FROM Doctrine\Tests\Models\Company\CompanyManager p'; + $result = $this->_em->createQuery($dql)->getArrayResult(); + + $this->assertEquals(1, count($result)); + $this->assertEquals("Caramba", $result[0]['brandName']); + } + + public function testInSubselect() + { + $dql = "SELECT p.name FROM Doctrine\Tests\Models\Company\CompanyPerson p ". + "WHERE p.name IN (SELECT n.name FROM Doctrine\Tests\Models\Company\CompanyPerson n WHERE n.name = 'Roman B.')"; + $result = $this->_em->createQuery($dql)->getScalarResult(); + + $this->assertEquals(1, count($result)); + $this->assertEquals('Roman B.', $result[0]['name']); + } + + public function testGroupByMultipleFields() + { + $dql = 'SELECT p.department, p.name, count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. + 'GROUP BY p.department, p.name'; + $result = $this->_em->createQuery($dql)->getResult(); + + $this->assertEquals(4, count($result)); + } + + public function testUpdateAs() + { + $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1'; + $this->_em->createQuery($dql)->execute(); + + $this->assertTrue(count($this->_em->createQuery( + 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')->getResult()) > 0); + } + + /*public function testDeleteAs() + { + $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyEmployee AS p'; + $this->_em->createQuery($dql)->getResult(); + + $this->assertEquals(0, count($this->_em->createQuery( + 'SELECT count(p) FROM Doctrine\Tests\Models\Company\CompanyEmployee p')->getResult())); + }*/ + + public function generateFixture() + { + $car = new CompanyCar('Caramba'); + + $manager1 = new CompanyManager(); + $manager1->setName('Roman B.'); + $manager1->setTitle('Foo'); + $manager1->setDepartment('IT'); + $manager1->setSalary(100000); + $manager1->setCar($car); + + $person2 = new CompanyEmployee(); + $person2->setName('Benjamin E.'); + $person2->setDepartment('IT'); + $person2->setSalary(200000); + + $person3 = new CompanyEmployee(); + $person3->setName('Guilherme B.'); + $person3->setDepartment('IT2'); + $person3->setSalary(400000); + + $person4 = new CompanyEmployee(); + $person4->setName('Jonathan W.'); + $person4->setDepartment('IT2'); + $person4->setSalary(800000); + + $person2->setSpouse($person3); + + $manager1->addFriend($person4); + $person2->addFriend($person3); + $person2->addFriend($person4); + $person3->addFriend($person4); + + $this->_em->persist($car); + $this->_em->persist($manager1); + $this->_em->persist($person2); + $this->_em->persist($person3); + $this->_em->persist($person4); + $this->_em->flush(); + $this->_em->clear(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php new file mode 100644 index 0000000..695e10c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php @@ -0,0 +1,1232 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testBasicUnitsOfWorkWithOneToManyAssociation() + { + // Create + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'developer'; + $this->_em->persist($user); + + $this->_em->flush(); + + $this->assertTrue(is_numeric($user->id)); + $this->assertTrue($this->_em->contains($user)); + + // Read + $user2 = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id); + $this->assertTrue($user === $user2); + + // Add a phonenumber + $ph = new CmsPhonenumber; + $ph->phonenumber = "12345"; + $user->addPhonenumber($ph); + $this->_em->flush(); + $this->assertTrue($this->_em->contains($ph)); + $this->assertTrue($this->_em->contains($user)); + //$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers); + + // Update name + $user->name = 'guilherme'; + $this->_em->flush(); + $this->assertEquals('guilherme', $user->name); + + // Add another phonenumber + $ph2 = new CmsPhonenumber; + $ph2->phonenumber = "6789"; + $user->addPhonenumber($ph2); + $this->_em->flush(); + $this->assertTrue($this->_em->contains($ph2)); + + // Delete + $this->_em->remove($user); + $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($user)); + $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph)); + $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph2)); + $this->_em->flush(); + $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)); + } + + public function testOneToManyAssociationModification() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'developer'; + + $ph1 = new CmsPhonenumber; + $ph1->phonenumber = "0301234"; + $ph2 = new CmsPhonenumber; + $ph2->phonenumber = "987654321"; + + $user->addPhonenumber($ph1); + $user->addPhonenumber($ph2); + + $this->_em->persist($user); + $this->_em->flush(); + + //$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers); + + // Remove the first element from the collection + unset($user->phonenumbers[0]); + $ph1->user = null; // owning side! + + $this->_em->flush(); + + $this->assertEquals(1, count($user->phonenumbers)); + $this->assertNull($ph1->user); + } + + public function testBasicOneToOne() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'developer'; + + $address = new CmsAddress; + $address->country = 'Germany'; + $address->city = 'Berlin'; + $address->zip = '12345'; + + $user->address = $address; // inverse side + $address->user = $user; // owning side! + + $this->_em->persist($user); + $this->_em->flush(); + + // Check that the foreign key has been set + $userId = $this->_em->getConnection()->executeQuery( + "SELECT user_id FROM cms_addresses WHERE id=?", array($address->id) + )->fetchColumn(); + $this->assertTrue(is_numeric($userId)); + + $this->_em->clear(); + + $user2 = $this->_em->createQuery('select u from \Doctrine\Tests\Models\CMS\CmsUser u where u.id=?1') + ->setParameter(1, $userId) + ->getSingleResult(); + + // Address has been eager-loaded because it cant be lazy + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $user2->address); + } + + /** + * @group DDC-1230 + */ + public function testRemove() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $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->_em->persist($user); + + $this->assertEquals(\Doctrine\ORM\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->_em->persist($user); + $this->_em->flush(); + $id = $user->getId(); + + $this->_em->remove($user); + + $this->assertEquals(\Doctrine\ORM\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->assertNull($this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $id)); + } + + public function testOneToManyOrphanRemoval() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + for ($i=0; $i<3; ++$i) { + $phone = new CmsPhonenumber; + $phone->phonenumber = 100 + $i; + $user->addPhonenumber($phone); + } + + $this->_em->persist($user); + + $this->_em->flush(); + + $user->getPhonenumbers()->remove(0); + $this->assertEquals(2, count($user->getPhonenumbers())); + + $this->_em->flush(); + + // Check that there are just 2 phonenumbers left + $count = $this->_em->getConnection()->fetchColumn("SELECT COUNT(*) FROM cms_phonenumbers"); + $this->assertEquals(2, $count); // only 2 remaining + + // check that clear() removes the others via orphan removal + $user->getPhonenumbers()->clear(); + $this->_em->flush(); + $this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_phonenumbers")); + } + + public function testBasicQuery() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + $this->_em->persist($user); + $this->_em->flush(); + + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); + + $users = $query->getResult(); + + $this->assertEquals(1, count($users)); + $this->assertEquals('Guilherme', $users[0]->name); + $this->assertEquals('gblanco', $users[0]->username); + $this->assertEquals('developer', $users[0]->status); + //$this->assertNull($users[0]->phonenumbers); + //$this->assertNull($users[0]->articles); + + $usersArray = $query->getArrayResult(); + + $this->assertTrue(is_array($usersArray)); + $this->assertEquals(1, count($usersArray)); + $this->assertEquals('Guilherme', $usersArray[0]['name']); + $this->assertEquals('gblanco', $usersArray[0]['username']); + $this->assertEquals('developer', $usersArray[0]['status']); + + $usersScalar = $query->getScalarResult(); + + $this->assertTrue(is_array($usersScalar)); + $this->assertEquals(1, count($usersScalar)); + $this->assertEquals('Guilherme', $usersScalar[0]['u_name']); + $this->assertEquals('gblanco', $usersScalar[0]['u_username']); + $this->assertEquals('developer', $usersScalar[0]['u_status']); + } + + public function testBasicOneToManyInnerJoin() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + $this->_em->persist($user); + $this->_em->flush(); + + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p"); + + $users = $query->getResult(); + + $this->assertEquals(0, count($users)); + } + + public function testBasicOneToManyLeftJoin() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + $this->_em->persist($user); + $this->_em->flush(); + + $query = $this->_em->createQuery("select u,p from Doctrine\Tests\Models\CMS\CmsUser u left join u.phonenumbers p"); + + $users = $query->getResult(); + + $this->assertEquals(1, count($users)); + $this->assertEquals('Guilherme', $users[0]->name); + $this->assertEquals('gblanco', $users[0]->username); + $this->assertEquals('developer', $users[0]->status); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->phonenumbers); + $this->assertTrue($users[0]->phonenumbers->isInitialized()); + $this->assertEquals(0, $users[0]->phonenumbers->count()); + //$this->assertNull($users[0]->articles); + } + + public function testBasicRefresh() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->flush(); + + $user->status = 'mascot'; + + $this->assertEquals('mascot', $user->status); + $this->_em->refresh($user); + $this->assertEquals('developer', $user->status); + } + + /** + * @group DDC-833 + */ + public function testRefreshResetsCollection() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + // Add a phonenumber + $ph1 = new CmsPhonenumber; + $ph1->phonenumber = "12345"; + $user->addPhonenumber($ph1); + + // Add a phonenumber + $ph2 = new CmsPhonenumber; + $ph2->phonenumber = "54321"; + + $this->_em->persist($user); + $this->_em->persist($ph1); + $this->_em->persist($ph2); + $this->_em->flush(); + + $user->addPhonenumber($ph2); + + $this->assertEquals(2, count($user->phonenumbers)); + $this->_em->refresh($user); + + $this->assertEquals(1, count($user->phonenumbers)); + } + + /** + * @group DDC-833 + */ + public function testDqlRefreshResetsCollection() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + // Add a phonenumber + $ph1 = new CmsPhonenumber; + $ph1->phonenumber = "12345"; + $user->addPhonenumber($ph1); + + // Add a phonenumber + $ph2 = new CmsPhonenumber; + $ph2->phonenumber = "54321"; + + $this->_em->persist($user); + $this->_em->persist($ph1); + $this->_em->persist($ph2); + $this->_em->flush(); + + $user->addPhonenumber($ph2); + + $this->assertEquals(2, count($user->phonenumbers)); + $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; + $user = $this->_em->createQuery($dql) + ->setParameter(1, $user->id) + ->setHint(Query::HINT_REFRESH, true) + ->getSingleResult(); + + $this->assertEquals(1, count($user->phonenumbers)); + } + + /** + * @group DDC-833 + */ + public function testCreateEntityOfProxy() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + // Add a phonenumber + $ph1 = new CmsPhonenumber; + $ph1->phonenumber = "12345"; + $user->addPhonenumber($ph1); + + // Add a phonenumber + $ph2 = new CmsPhonenumber; + $ph2->phonenumber = "54321"; + + $this->_em->persist($user); + $this->_em->persist($ph1); + $this->_em->persist($ph2); + $this->_em->flush(); + $this->_em->clear(); + + $userId = $user->id; + $user = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->id); + + $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; + $user = $this->_em->createQuery($dql) + ->setParameter(1, $userId) + ->getSingleResult(); + + $this->assertEquals(1, count($user->phonenumbers)); + } + + public function testAddToCollectionDoesNotInitialize() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + for ($i=0; $i<3; ++$i) { + $phone = new CmsPhonenumber; + $phone->phonenumber = 100 + $i; + $user->addPhonenumber($phone); + } + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $this->assertEquals(3, $user->getPhonenumbers()->count()); + + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); + + $gblanco = $query->getSingleResult(); + + $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + + $newPhone = new CmsPhonenumber; + $newPhone->phonenumber = 555; + $gblanco->addPhonenumber($newPhone); + + $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + $this->_em->persist($gblanco); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); + $gblanco2 = $query->getSingleResult(); + $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); + } + + public function testInitializeCollectionWithNewObjectsRetainsNewObjects() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + for ($i=0; $i<3; ++$i) { + $phone = new CmsPhonenumber; + $phone->phonenumber = 100 + $i; + $user->addPhonenumber($phone); + } + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $this->assertEquals(3, $user->getPhonenumbers()->count()); + + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); + + $gblanco = $query->getSingleResult(); + + $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + + $newPhone = new CmsPhonenumber; + $newPhone->phonenumber = 555; + $gblanco->addPhonenumber($newPhone); + + $this->assertFalse($gblanco->getPhonenumbers()->isInitialized()); + $this->assertEquals(4, $gblanco->getPhonenumbers()->count()); + $this->assertTrue($gblanco->getPhonenumbers()->isInitialized()); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p where u.username='gblanco'"); + $gblanco2 = $query->getSingleResult(); + $this->assertEquals(4, $gblanco2->getPhonenumbers()->count()); + } + + public function testSetSetAssociationWithGetReference() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + $this->_em->persist($user); + + $address = new CmsAddress; + $address->country = 'Germany'; + $address->city = 'Berlin'; + $address->zip = '12345'; + $this->_em->persist($address); + + $this->_em->flush(); + $this->_em->detach($address); + + $this->assertFalse($this->_em->contains($address)); + $this->assertTrue($this->_em->contains($user)); + + // Assume we only got the identifier of the address and now want to attach + // that address to the user without actually loading it, using getReference(). + $addressRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsAddress', $address->getId()); + + //$addressRef->getId(); + //\Doctrine\Common\Util\Debug::dump($addressRef); + + $user->setAddress($addressRef); // Ugh! Initializes address 'cause of $address->setUser($user)! + + $this->_em->flush(); + $this->_em->clear(); + + // Check with a fresh load that the association is indeed there + $query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a where u.username='gblanco'"); + $gblanco = $query->getSingleResult(); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $gblanco); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $gblanco->getAddress()); + $this->assertEquals('Berlin', $gblanco->getAddress()->getCity()); + + } + + public function testOneToManyCascadeRemove() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + for ($i=0; $i<3; ++$i) { + $phone = new CmsPhonenumber; + $phone->phonenumber = 100 + $i; + $user->addPhonenumber($phone); + } + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username='gblanco'"); + $gblanco = $query->getSingleResult(); + + $this->_em->remove($gblanco); + $this->_em->flush(); + + $this->_em->clear(); + + $this->assertEquals(0, $this->_em->createQuery( + "select count(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p") + ->getSingleScalarResult()); + + $this->assertEquals(0, $this->_em->createQuery( + "select count(u.id) from Doctrine\Tests\Models\CMS\CmsUser u") + ->getSingleScalarResult()); + } + + public function testTextColumnSaveAndRetrieve() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $this->_em->persist($user); + + $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article->text = "Lorem ipsum dolor sunt."; + $article->topic = "A Test Article!"; + $article->setAuthor($user); + + $this->_em->persist($article); + $this->_em->flush(); + $articleId = $article->id; + + $this->_em->clear(); + + // test find() with leading backslash at the same time + $articleNew = $this->_em->find('\Doctrine\Tests\Models\CMS\CmsArticle', $articleId); + $this->assertTrue($this->_em->contains($articleNew)); + $this->assertEquals("Lorem ipsum dolor sunt.", $articleNew->text); + + $this->assertNotSame($article, $articleNew); + + $articleNew->text = "Lorem ipsum dolor sunt. And stuff!"; + + $this->_em->flush(); + $this->_em->clear(); + + $articleNew = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $articleId); + $this->assertEquals("Lorem ipsum dolor sunt. And stuff!", $articleNew->text); + $this->assertTrue($this->_em->contains($articleNew)); + } + + public function testFlushDoesNotIssueUnnecessaryUpdates() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $address = new CmsAddress; + $address->country = 'Germany'; + $address->city = 'Berlin'; + $address->zip = '12345'; + + $address->user = $user; + $user->address = $address; + + $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article->text = "Lorem ipsum dolor sunt."; + $article->topic = "A Test Article!"; + $article->setAuthor($user); + + $this->_em->persist($article); + $this->_em->persist($user); + + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('select u,a,ad from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a join u.address ad'); + $user2 = $query->getSingleResult(); + + $this->assertEquals(1, count($user2->articles)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address); + + $oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); + $debugStack = new \Doctrine\DBAL\Logging\DebugStack; + $this->_em->getConnection()->getConfiguration()->setSQLLogger($debugStack); + + $this->_em->flush(); + $this->assertEquals(0, count($debugStack->queries)); + + $this->_em->getConnection()->getConfiguration()->setSQLLogger($oldLogger); + } + + public function testRemoveEntityByReference() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $userRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); + $this->_em->remove($userRef); + $this->_em->flush(); + $this->_em->clear(); + + $this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_users")); + + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(null); + } + + public function testQueryEntityByReference() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $address = new CmsAddress; + $address->country = 'Germany'; + $address->city = 'Berlin'; + $address->zip = '12345'; + + $user->setAddress($address); + + $this->_em->transactional(function($em) use($user) { + $em->persist($user); + }); + $this->_em->clear(); + + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $userRef = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); + $address2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a where a.user = :user') + ->setParameter('user', $userRef) + ->getSingleResult(); + + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->getUser()); + $this->assertTrue($userRef === $address2->getUser()); + $this->assertFalse($userRef->__isInitialized__); + $this->assertEquals('Germany', $address2->country); + $this->assertEquals('Berlin', $address2->city); + $this->assertEquals('12345', $address2->zip); + } + + public function testOneToOneNullUpdate() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + + $address = new CmsAddress(); + $address->city = "Bonn"; + $address->zip = "12354"; + $address->country = "Germany"; + $address->street = "somestreet"; + $address->user = $user; + + $this->_em->persist($address); + $this->_em->persist($user); + $this->_em->flush(); + + $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select 1 from cms_addresses where user_id = ".$user->id)); + + $address->user = null; + $this->_em->flush(); + + $this->assertNotEquals(1, $this->_em->getConnection()->fetchColumn("select 1 from cms_addresses where user_id = ".$user->id)); + } + + /** + * @group DDC-600 + * @group DDC-455 + */ + public function testNewAssociatedEntityDuringFlushThrowsException() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + + $address = new CmsAddress(); + $address->city = "Bonn"; + $address->zip = "12354"; + $address->country = "Germany"; + $address->street = "somestreet"; + $address->user = $user; + + $this->_em->persist($address); + // pretend we forgot to persist $user + try { + $this->_em->flush(); // should raise an exception + $this->fail(); + } catch (\InvalidArgumentException $expected) {} + } + + /** + * @group DDC-600 + * @group DDC-455 + */ + public function testNewAssociatedEntityDuringFlushThrowsException2() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + + $address = new CmsAddress(); + $address->city = "Bonn"; + $address->zip = "12354"; + $address->country = "Germany"; + $address->street = "somestreet"; + $address->user = $user; + + $this->_em->persist($address); + $this->_em->persist($user); + $this->_em->flush(); + + $u2 = new CmsUser; + $u2->username = "beberlei"; + $u2->name = "Benjamin E."; + $u2->status = 'inactive'; + $address->user = $u2; + // pretend we forgot to persist $u2 + try { + $this->_em->flush(); // should raise an exception + $this->fail(); + } catch (\InvalidArgumentException $expected) {} + } + + /** + * @group DDC-600 + * @group DDC-455 + */ + public function testNewAssociatedEntityDuringFlushThrowsException3() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $art = new CmsArticle(); + $art->topic = 'topic'; + $art->text = 'the text'; + + $com = new CmsComment(); + $com->topic = 'Good'; + $com->text = 'Really good!'; + $art->addComment($com); + + $this->_em->persist($art); + // pretend we forgot to persist $com + try { + $this->_em->flush(); // should raise an exception + $this->fail(); + } catch (\InvalidArgumentException $expected) {} + } + + public function testOneToOneOrphanRemoval() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + + $address = new CmsAddress(); + $address->city = "Bonn"; + $address->zip = "12354"; + $address->country = "Germany"; + $address->street = "somestreet"; + $address->user = $user; + $user->address = $address; + + $this->_em->persist($address); + $this->_em->persist($user); + $this->_em->flush(); + $addressId = $address->getId(); + + $user->address = null; + + $this->_em->flush(); + + $this->assertEquals(0, $this->_em->getConnection()->fetchColumn("select count(*) from cms_addresses")); + + // check orphan removal through replacement + $user->address = $address; + $address->user = $user; + + $this->_em->flush(); + $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from cms_addresses")); + + // remove $address to free up unique key id + $this->_em->remove($address); + $this->_em->flush(); + + $newAddress = new CmsAddress(); + $newAddress->city = "NewBonn"; + $newAddress->zip = "12354"; + $newAddress->country = "NewGermany"; + $newAddress->street = "somenewstreet"; + $newAddress->user = $user; + $user->address = $newAddress; + + $this->_em->flush(); + $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from cms_addresses")); + } + + public function testGetPartialReferenceToUpdateObjectWithoutLoadingIt() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + $this->_em->persist($user); + $this->_em->flush(); + $userId = $user->id; + $this->_em->clear(); + + $user = $this->_em->getPartialReference('Doctrine\Tests\Models\CMS\CmsUser', $userId); + $this->assertTrue($this->_em->contains($user)); + $this->assertNull($user->getName()); + $this->assertEquals($userId, $user->id); + + $user->name = 'Stephan'; + $this->_em->flush(); + $this->_em->clear(); + + $this->assertEquals('Benjamin E.', $this->_em->find(get_class($user), $userId)->name); + } + + public function testMergePersistsNewEntities() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + + $managedUser = $this->_em->merge($user); + $this->assertEquals('beberlei', $managedUser->username); + $this->assertEquals('Benjamin E.', $managedUser->name); + $this->assertEquals('active', $managedUser->status); + + $this->assertTrue($user !== $managedUser); + $this->assertTrue($this->_em->contains($managedUser)); + + $this->_em->flush(); + $userId = $managedUser->id; + $this->_em->clear(); + + $user2 = $this->_em->find(get_class($managedUser), $userId); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user2); + } + + public function testMergeThrowsExceptionIfEntityWithGeneratedIdentifierDoesNotExist() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + $user->id = 42; + try { + $this->_em->merge($user); + $this->fail(); + } catch (\Doctrine\ORM\EntityNotFoundException $enfe) {} + } + + /** + * @group DDC-634 + */ + public function testOneToOneMergeSetNull() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + + $ph = new CmsPhonenumber(); + $ph->phonenumber = "12345"; + $user->addPhonenumber($ph); + + $this->_em->persist($user); + $this->_em->persist($ph); + $this->_em->flush(); + + $this->_em->clear(); + + $ph->user = null; + $managedPh = $this->_em->merge($ph); + + $this->_em->flush(); + $this->_em->clear(); + + $this->assertNull($this->_em->find(get_class($ph), $ph->phonenumber)->getUser()); + } + + /** + * @group DDC-952 + */ + public function testManyToOneFetchModeQuery() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin E."; + $user->status = 'active'; + + $article = new CmsArticle(); + $article->topic = "foo"; + $article->text = "bar"; + $article->user = $user; + + $this->_em->persist($article); + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $qc = $this->getCurrentQueryCount(); + $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) + ->getSingleResult(); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $article->user, "It IS a proxy, ..."); + $this->assertTrue($article->user->__isInitialized__, "...but its initialized!"); + $this->assertEquals($qc+2, $this->getCurrentQueryCount()); + } + + /** + * @group DDC-1278 + */ + public function testClearWithEntityName() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $address = new CmsAddress(); + $address->city = "Springfield"; + $address->zip = "12354"; + $address->country = "Germany"; + $address->street = "Foo Street"; + $address->user = $user; + $user->address = $address; + + $article1 = new CmsArticle(); + $article1->topic = 'Foo'; + $article1->text = 'Foo Text'; + + $article2 = new CmsArticle(); + $article2->topic = 'Bar'; + $article2->text = 'Bar Text'; + + $user->addArticle($article1); + $user->addArticle($article2); + + $this->_em->persist($article1); + $this->_em->persist($article2); + $this->_em->persist($address); + $this->_em->persist($user); + $this->_em->flush(); + + $unitOfWork = $this->_em->getUnitOfWork(); + + $this->_em->clear('Doctrine\Tests\Models\CMS\CmsUser'); + + $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($user)); + + $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($address)); + $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($article1)); + $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $unitOfWork->getEntityState($article2)); + + $this->_em->clear(); + + $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_DETACHED, $unitOfWork->getEntityState($address)); + } + + /** + * @group DDC-720 + */ + public function testFlushSingleManagedEntity() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->flush(); + + $user->status = 'administrator'; + $this->_em->flush($user); + $this->_em->clear(); + + $user = $this->_em->find(get_class($user), $user->id); + $this->assertEquals('administrator', $user->status); + } + + /** + * @group DDC-720 + */ + public function testFlushSingleUnmanagedEntity() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $this->setExpectedException('InvalidArgumentException', 'Entity has to be managed for single computation'); + $this->_em->flush($user); + } + + /** + * @group DDC-720 + */ + public function testFlushSingleAndNewEntity() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->flush(); + + $otherUser = new CmsUser; + $otherUser->name = 'Dominik2'; + $otherUser->username = 'domnikl2'; + $otherUser->status = 'developer'; + + $user->status = 'administrator'; + + $this->_em->persist($otherUser); + $this->_em->flush($user); + + $this->assertTrue($this->_em->contains($otherUser), "Other user is contained in EntityManager"); + $this->assertTrue($otherUser->id > 0, "other user has an id"); + } + + /** + * @group DDC-720 + */ + public function testFlushAndCascadePersist() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->flush(); + + $address = new CmsAddress(); + $address->city = "Springfield"; + $address->zip = "12354"; + $address->country = "Germany"; + $address->street = "Foo Street"; + $address->user = $user; + $user->address = $address; + + $this->_em->flush($user); + + $this->assertTrue($this->_em->contains($address), "Other user is contained in EntityManager"); + $this->assertTrue($address->id > 0, "other user has an id"); + } + + /** + * @group DDC-720 + */ + public function testFlushSingleAndNoCascade() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->flush(); + + $article1 = new CmsArticle(); + $article1->topic = 'Foo'; + $article1->text = 'Foo Text'; + $article1->author = $user; + $user->articles[] = $article1; + + $this->setExpectedException('InvalidArgumentException', "A new entity was found through the relationship 'Doctrine\Tests\Models\CMS\CmsUser#articles'"); + $this->_em->flush($user); + } + + /** + * @group DDC-720 + * @group DDC-1612 + */ + public function testFlushSingleNewEntity() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->flush($user); + } + + /** + * @group DDC-720 + */ + public function testProxyIsIgnored() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->getReference(get_class($user), $user->id); + + $otherUser = new CmsUser; + $otherUser->name = 'Dominik2'; + $otherUser->username = 'domnikl2'; + $otherUser->status = 'developer'; + + $this->_em->persist($otherUser); + $this->_em->flush($user); + + $this->assertTrue($this->_em->contains($otherUser), "Other user is contained in EntityManager"); + $this->assertTrue($otherUser->id > 0, "other user has an id"); + } + + /** + * @group DDC-720 + */ + public function testFlushSingleSaveOnlySingle() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + $this->_em->persist($user); + + $user2 = new CmsUser; + $user2->name = 'Dominik'; + $user2->username = 'domnikl2'; + $user2->status = 'developer'; + $this->_em->persist($user2); + + $this->_em->flush(); + + $user->status = 'admin'; + $user2->status = 'admin'; + + $this->_em->flush($user); + $this->_em->clear(); + + $user2 = $this->_em->find(get_class($user2), $user2->id); + $this->assertEquals('developer', $user2->status); + } + + /** + * @group DDC-1585 + */ + public function testWrongAssocationInstance() + { + $user = new CmsUser; + $user->name = 'Dominik'; + $user->username = 'domnikl'; + $user->status = 'developer'; + $user->address = $user; + + $this->_em->persist($user); + + $this->setExpectedException("Doctrine\ORM\ORMException", "Found entity of type Doctrine\Tests\Models\CMS\CmsUser on association Doctrine\Tests\Models\CMS\CmsUser#address, but expecting Doctrine\Tests\Models\CMS\CmsAddress"); + $this->_em->flush(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php new file mode 100644 index 0000000..bd6c794 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -0,0 +1,470 @@ +useModelSet('company'); + parent::setUp(); + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + } + + public function testCRUD() + { + $person = new CompanyPerson; + $person->setName('Roman S. Borschel'); + + $this->_em->persist($person); + + $employee = new CompanyEmployee; + $employee->setName('Roman S. Borschel'); + $employee->setSalary(100000); + $employee->setDepartment('IT'); + + $this->_em->persist($employee); + + $employee->setName('Guilherme Blanco'); + $this->_em->flush(); + + $this->_em->clear(); + + $query = $this->_em->createQuery("select p from Doctrine\Tests\Models\Company\CompanyPerson p order by p.name desc"); + + $entities = $query->getResult(); + + $this->assertEquals(2, count($entities)); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $entities[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[1]); + $this->assertTrue(is_numeric($entities[0]->getId())); + $this->assertTrue(is_numeric($entities[1]->getId())); + $this->assertEquals('Roman S. Borschel', $entities[0]->getName()); + $this->assertEquals('Guilherme Blanco', $entities[1]->getName()); + $this->assertEquals(100000, $entities[1]->getSalary()); + + $this->_em->clear(); + + $query = $this->_em->createQuery("select p from Doctrine\Tests\Models\Company\CompanyEmployee p"); + + $entities = $query->getResult(); + + $this->assertEquals(1, count($entities)); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[0]); + $this->assertTrue(is_numeric($entities[0]->getId())); + $this->assertEquals('Guilherme Blanco', $entities[0]->getName()); + $this->assertEquals(100000, $entities[0]->getSalary()); + + $this->_em->clear(); + + $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(array('name' => 'Guilherme Blanco')); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $guilherme); + $this->assertEquals('Guilherme Blanco', $guilherme->getName()); + + $this->_em->clear(); + + $query = $this->_em->createQuery("update Doctrine\Tests\Models\Company\CompanyEmployee p set p.name = ?1, p.department = ?2 where p.name='Guilherme Blanco' and p.salary = ?3"); + $query->setParameter(1, 'NewName', 'string'); + $query->setParameter(2, 'NewDepartment'); + $query->setParameter(3, 100000); + $query->getSql(); + $numUpdated = $query->execute(); + $this->assertEquals(1, $numUpdated); + + $query = $this->_em->createQuery("delete from Doctrine\Tests\Models\Company\CompanyPerson p"); + $numDeleted = $query->execute(); + $this->assertEquals(2, $numDeleted); + } + + public function testMultiLevelUpdateAndFind() { + $manager = new CompanyManager; + $manager->setName('Roman S. Borschel'); + $manager->setSalary(100000); + $manager->setDepartment('IT'); + $manager->setTitle('CTO'); + $this->_em->persist($manager); + $this->_em->flush(); + + $manager->setName('Roman B.'); + $manager->setSalary(119000); + $manager->setTitle('CEO'); + $this->_em->persist($manager); + $this->_em->flush(); + + $this->_em->clear(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); + + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $manager); + $this->assertEquals('Roman B.', $manager->getName()); + $this->assertEquals(119000, $manager->getSalary()); + $this->assertEquals('CEO', $manager->getTitle()); + $this->assertTrue(is_numeric($manager->getId())); + } + + public function testFindOnBaseClass() { + $manager = new CompanyManager; + $manager->setName('Roman S. Borschel'); + $manager->setSalary(100000); + $manager->setDepartment('IT'); + $manager->setTitle('CTO'); + $this->_em->persist($manager); + $this->_em->flush(); + + $this->_em->clear(); + + $person = $this->_em->find('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId()); + + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $person); + $this->assertEquals('Roman S. Borschel', $person->getName()); + $this->assertEquals(100000, $person->getSalary()); + $this->assertEquals('CTO', $person->getTitle()); + $this->assertTrue(is_numeric($person->getId())); + //$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyCar', $person->getCar()); + } + + public function testSelfReferencingOneToOne() { + $manager = new CompanyManager; + $manager->setName('John Smith'); + $manager->setSalary(100000); + $manager->setDepartment('IT'); + $manager->setTitle('CTO'); + + $wife = new CompanyPerson; + $wife->setName('Mary Smith'); + $wife->setSpouse($manager); + + $this->assertSame($manager, $wife->getSpouse()); + $this->assertSame($wife, $manager->getSpouse()); + + $this->_em->persist($manager); + $this->_em->persist($wife); + + $this->_em->flush(); + + //var_dump($this->_em->getConnection()->fetchAll('select * from company_persons')); + //var_dump($this->_em->getConnection()->fetchAll('select * from company_employees')); + //var_dump($this->_em->getConnection()->fetchAll('select * from company_managers')); + + $this->_em->clear(); + + $query = $this->_em->createQuery('select p, s from Doctrine\Tests\Models\Company\CompanyPerson p join p.spouse s where p.name=\'Mary Smith\''); + + $result = $query->getResult(); + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]); + $this->assertEquals('Mary Smith', $result[0]->getName()); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[0]->getSpouse()); + $this->assertEquals('John Smith', $result[0]->getSpouse()->getName()); + $this->assertSame($result[0], $result[0]->getSpouse()->getSpouse()); + } + + public function testSelfReferencingManyToMany() + { + $person1 = new CompanyPerson; + $person1->setName('Roman'); + + $person2 = new CompanyPerson; + $person2->setName('Jonathan'); + + $person1->addFriend($person2); + + $this->assertEquals(1, count($person1->getFriends())); + $this->assertEquals(1, count($person2->getFriends())); + + + $this->_em->persist($person1); + $this->_em->persist($person2); + + $this->_em->flush(); + + $this->_em->clear(); + + $query = $this->_em->createQuery('select p, f from Doctrine\Tests\Models\Company\CompanyPerson p join p.friends f where p.name=?1'); + $query->setParameter(1, 'Roman'); + + $result = $query->getResult(); + $this->assertEquals(1, count($result)); + $this->assertEquals(1, count($result[0]->getFriends())); + $this->assertEquals('Roman', $result[0]->getName()); + + $friends = $result[0]->getFriends(); + $this->assertEquals('Jonathan', $friends[0]->getName()); + } + + public function testLazyLoading1() + { + $org = new CompanyOrganization; + $event1 = new CompanyAuction; + $event1->setData('auction'); + $org->addEvent($event1); + $event2 = new CompanyRaffle; + $event2->setData('raffle'); + $org->addEvent($event2); + + $this->_em->persist($org); + $this->_em->flush(); + $this->_em->clear(); + + $orgId = $org->getId(); + + $q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyOrganization a where a.id = ?1'); + $q->setParameter(1, $orgId); + + $result = $q->getResult(); + + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]); + $this->assertNull($result[0]->getMainEvent()); + + $events = $result[0]->getEvents(); + + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $events); + $this->assertFalse($events->isInitialized()); + + $this->assertEquals(2, count($events)); + if ($events[0] instanceof CompanyAuction) { + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[1]); + } else { + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $events[1]); + } + } + + + public function testLazyLoading2() + { + $org = new CompanyOrganization; + $event1 = new CompanyAuction; + $event1->setData('auction'); + $org->setMainEvent($event1); + + $this->_em->persist($org); + $this->_em->flush(); + $this->_em->clear(); + + $q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyEvent a where a.id = ?1'); + $q->setParameter(1, $event1->getId()); + + $result = $q->getResult(); + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $result[0], sprintf("Is of class %s",get_class($result[0]))); + + $this->_em->clear(); + + $q = $this->_em->createQuery('select a from Doctrine\Tests\Models\Company\CompanyOrganization a where a.id = ?1'); + $q->setParameter(1, $org->getId()); + + $result = $q->getResult(); + + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]); + + $mainEvent = $result[0]->getMainEvent(); + // mainEvent should have been loaded because it can't be lazy + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $mainEvent); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $mainEvent); + } + + /** + * @group DDC-368 + */ + public function testBulkUpdateIssueDDC368() + { + $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1'; + $this->_em->createQuery($dql)->execute(); + + $this->assertTrue(count($this->_em->createQuery( + 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1') + ->getResult()) > 0); + } + + /** + * @group DDC-1341 + */ + public function testBulkUpdateNonScalarParameterDDC1341() + { + $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.startDate = ?0 WHERE p.department = ?1'; + $query = $this->_em->createQuery($dql) + ->setParameter(0, new \DateTime()) + ->setParameter(1, 'IT'); + + $result = $query->execute(); + + } + + /** + * @group DDC-130 + */ + public function testDeleteJoinTableRecords() + { + #$this->markTestSkipped('Nightmare! friends adds both ID 6-7 and 7-6 into two rows of the join table. How to detect this?'); + + $employee1 = new CompanyEmployee(); + $employee1->setName('gblanco'); + $employee1->setSalary(0); + $employee1->setDepartment('IT'); + + $employee2 = new CompanyEmployee(); + $employee2->setName('jwage'); + $employee2->setSalary(0); + $employee2->setDepartment('IT'); + + $employee1->addFriend($employee2); + + $this->_em->persist($employee1); + $this->_em->persist($employee2); + $this->_em->flush(); + + $employee1Id = $employee1->getId(); + + $this->_em->remove($employee1); + $this->_em->flush(); + + $this->assertNull($this->_em->find(get_class($employee1), $employee1Id)); + } + + /** + * @group DDC-728 + */ + public function testQueryForInheritedSingleValuedAssociation() + { + $manager = new CompanyManager(); + $manager->setName('gblanco'); + $manager->setSalary(1234); + $manager->setTitle('Awesome!'); + $manager->setDepartment('IT'); + + $person = new CompanyPerson(); + $person->setName('spouse'); + + $manager->setSpouse($person); + + $this->_em->persist($manager); + $this->_em->persist($person); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m WHERE m.spouse = ?1"; + $dqlManager = $this->_em->createQuery($dql)->setParameter(1, $person->getId())->getSingleResult(); + + $this->assertEquals($manager->getId(), $dqlManager->getId()); + $this->assertEquals($person->getId(), $dqlManager->getSpouse()->getId()); + } + + /** + * @group DDC-817 + */ + public function testFindByAssociation() + { + $manager = new CompanyManager(); + $manager->setName('gblanco'); + $manager->setSalary(1234); + $manager->setTitle('Awesome!'); + $manager->setDepartment('IT'); + + $person = new CompanyPerson(); + $person->setName('spouse'); + + $manager->setSpouse($person); + + $this->_em->persist($manager); + $this->_em->persist($person); + $this->_em->flush(); + $this->_em->clear(); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager'); + $pmanager = $repos->findOneBy(array('spouse' => $person->getId())); + + $this->assertEquals($manager->getId(), $pmanager->getId()); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson'); + $pmanager = $repos->findOneBy(array('spouse' => $person->getId())); + + $this->assertEquals($manager->getId(), $pmanager->getId()); + } + + /** + * @group DDC-834 + */ + public function testGetReferenceEntityWithSubclasses() + { + $manager = new CompanyManager(); + $manager->setName('gblanco'); + $manager->setSalary(1234); + $manager->setTitle('Awesome!'); + $manager->setDepartment('IT'); + + $this->_em->persist($manager); + $this->_em->flush(); + $this->_em->clear(); + + $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId()); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "Cannot Request a proxy from a class that has subclasses."); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $ref); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $ref, "Direct fetch of the reference has to load the child class Emplyoee directly."); + $this->_em->clear(); + + $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "A proxy can be generated only if no subclasses exists for the requested reference."); + } + + /** + * @group DDC-992 + */ + public function testGetSubClassManyToManyCollection() + { + $manager = new CompanyManager(); + $manager->setName('gblanco'); + $manager->setSalary(1234); + $manager->setTitle('Awesome!'); + $manager->setDepartment('IT'); + + $person = new CompanyPerson(); + $person->setName('friend'); + + $manager->addFriend($person); + + $this->_em->persist($manager); + $this->_em->persist($person); + $this->_em->flush(); + $this->_em->clear(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId()); + $this->assertEquals(1, count($manager->getFriends())); + } + + /** + * @group DDC-1777 + */ + public function testExistsSubclass() + { + $manager = new CompanyManager(); + $manager->setName('gblanco'); + $manager->setSalary(1234); + $manager->setTitle('Awesome!'); + $manager->setDepartment('IT'); + + $this->assertFalse($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + + $this->_em->persist($manager); + $this->_em->flush(); + + $this->assertTrue($this->_em->getUnitOfWork()->getEntityPersister(get_class($manager))->exists($manager)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php new file mode 100644 index 0000000..531b100 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest2.php @@ -0,0 +1,176 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIParent'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIChild'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated2') + )); + } catch (\Exception $ignored) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + + public function testOneToOneAssocToBaseTypeBidirectional() + { + $child = new CTIChild; + $child->setData('hello'); + + $related = new CTIRelated; + $related->setCTIParent($child); + + $this->_em->persist($related); + $this->_em->persist($child); + + $this->_em->flush(); + $this->_em->clear(); + + $relatedId = $related->getId(); + + $related2 = $this->_em->find('Doctrine\Tests\ORM\Functional\CTIRelated', $relatedId); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIRelated', $related2); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $related2->getCTIParent()); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $related2->getCTIParent()); + $this->assertEquals('hello', $related2->getCTIParent()->getData()); + + $this->assertSame($related2, $related2->getCTIParent()->getRelated()); + } + + public function testManyToManyToCTIHierarchy() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); + $mmrel = new CTIRelated2; + $child = new CTIChild; + $child->setData('child'); + $mmrel->addCTIChild($child); + + $this->_em->persist($mmrel); + $this->_em->persist($child); + + $this->_em->flush(); + $this->_em->clear(); + + $mmrel2 = $this->_em->find(get_class($mmrel), $mmrel->getId()); + $this->assertFalse($mmrel2->getCTIChildren()->isInitialized()); + $this->assertEquals(1, count($mmrel2->getCTIChildren())); + $this->assertTrue($mmrel2->getCTIChildren()->isInitialized()); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $mmrel2->getCTIChildren()->get(0)); + } +} + +/** + * @Entity @Table(name="cti_parents") + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="type", type="string") + * @DiscriminatorMap({"parent" = "CTIParent", "child" = "CTIChild"}) + */ +class CTIParent { + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** @OneToOne(targetEntity="CTIRelated", mappedBy="ctiParent") */ + private $related; + + public function getId() { + return $this->id; + } + + public function getRelated() { + return $this->related; + } + + public function setRelated($related) { + $this->related = $related; + $related->setCTIParent($this); + } +} + +/** + * @Entity @Table(name="cti_children") + */ +class CTIChild extends CTIParent { + /** + * @Column(type="string") + */ + private $data; + + public function getData() { + return $this->data; + } + + public function setData($data) { + $this->data = $data; + } + +} + +/** @Entity */ +class CTIRelated { + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @OneToOne(targetEntity="CTIParent") + * @JoinColumn(name="ctiparent_id", referencedColumnName="id") + */ + private $ctiParent; + + public function getId() { + return $this->id; + } + + public function getCTIParent() { + return $this->ctiParent; + } + + public function setCTIParent($ctiParent) { + $this->ctiParent = $ctiParent; + } +} + +/** @Entity */ +class CTIRelated2 +{ + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @ManyToMany(targetEntity="CTIChild") */ + private $ctiChildren; + + + public function __construct() { + $this->ctiChildren = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function getId() { + return $this->id; + } + + public function addCTIChild(CTIChild $child) { + $this->ctiChildren->add($child); + } + + public function getCTIChildren() { + return $this->ctiChildren; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php new file mode 100644 index 0000000..e86edb5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ClearEventTest.php @@ -0,0 +1,40 @@ + + */ +class ClearEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() { + parent::setUp(); + } + + public function testEventIsCalledOnClear() + { + $listener = new OnClearListener; + $this->_em->getEventManager()->addEventListener(Events::onClear, $listener); + + $this->_em->clear(); + + $this->assertTrue($listener->called); + } +} + +class OnClearListener +{ + public $called = false; + + public function onClear(OnClearEventArgs $args) + { + $this->called = true; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php new file mode 100644 index 0000000..4d321ad --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyTest.php @@ -0,0 +1,121 @@ +useModelSet('navigation'); + parent::setUp(); + } + + public function putGermanysBrandenburderTor() + { + $country = new NavCountry("Germany"); + $this->_em->persist($country); + $poi = new NavPointOfInterest(100, 200, "Brandenburger Tor", $country); + $this->_em->persist($poi); + $this->_em->flush(); + $this->_em->clear(); + } + + public function putTripAroundEurope() + { + $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); + + $tour = new NavTour("Trip around Europe"); + $tour->addPointOfInterest($poi); + + $this->_em->persist($tour); + $this->_em->flush(); + $this->_em->clear(); + + return $tour; + } + + public function testPersistCompositePkEntity() + { + $this->putGermanysBrandenburderTor(); + + $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); + + $this->assertInstanceOf('Doctrine\Tests\Models\Navigation\NavPointOfInterest', $poi); + $this->assertEquals(100, $poi->getLat()); + $this->assertEquals(200, $poi->getLong()); + $this->assertEquals('Brandenburger Tor', $poi->getName()); + } + + /** + * @group DDC-1651 + */ + public function testSetParameterCompositeKeyObject() + { + $this->putGermanysBrandenburderTor(); + + $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); + $photo = new NavPhotos($poi, "asdf"); + $this->_em->persist($photo); + $this->_em->flush(); + $this->_em->clear(); + + $dql = 'SELECT t FROM Doctrine\Tests\Models\Navigation\NavPhotos t WHERE t.poi = ?1'; + + $this->setExpectedException('Doctrine\ORM\Query\QueryException', 'A single-valued association path expression to an entity with a composite primary key is not supported.'); + $sql = $this->_em->createQuery($dql)->getSQL(); + } + + public function testManyToManyCompositeRelation() + { + $this->putGermanysBrandenburderTor(); + $tour = $this->putTripAroundEurope(); + + $tour = $this->_em->find('Doctrine\Tests\Models\Navigation\NavTour', $tour->getId()); + + $this->assertEquals(1, count($tour->getPointOfInterests())); + } + + public function testCompositeDqlEagerFetching() + { + $this->putGermanysBrandenburderTor(); + $this->putTripAroundEurope(); + + $dql = 'SELECT t, p, c FROM Doctrine\Tests\Models\Navigation\NavTour t ' . + 'INNER JOIN t.pois p INNER JOIN p.country c'; + $tours = $this->_em->createQuery($dql)->getResult(); + + $this->assertEquals(1, count($tours)); + + $pois = $tours[0]->getPointOfInterests(); + + $this->assertEquals(1, count($pois)); + $this->assertEquals('Brandenburger Tor', $pois[0]->getName()); + } + + public function testCompositeCollectionMemberExpression() + { + $this->markTestSkipped('How to test this?'); + + $this->putGermanysBrandenburderTor(); + $this->putTripAroundEurope(); + + $dql = 'SELECT t FROM Doctrine\Tests\Models\Navigation\NavTour t, Doctrine\Tests\Models\Navigation\NavPointOfInterest p ' . + 'WHERE p MEMBER OF t.pois'; + $tours = $this->_em->createQuery($dql) + ->getResult(); + + $this->assertEquals(1, count($tours)); + } + + public function testSpecifiyUnknownIdentifierPrimaryKeyFails() + { + $this->setExpectedException('Doctrine\ORM\ORMException', '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)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CustomTreeWalkersTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CustomTreeWalkersTest.php new file mode 100644 index 0000000..72fc6d5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/CustomTreeWalkersTest.php @@ -0,0 +1,157 @@ +. + */ + +namespace Doctrine\Tests\ORM\Functional; + +use Doctrine\ORM\Query; + +require_once __DIR__ . '/../../TestInit.php'; + +/** + * Test case for custom AST walking and modification. + * + * @author Roman Borschel + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://www.doctrine-project.org + * @since 2.0 + */ +class CustomTreeWalkersTest extends \Doctrine\Tests\OrmTestCase +{ + private $_em; + + protected function setUp() + { + $this->_em = $this->_getTestEntityManager(); + } + + public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed) + { + try { + $query = $this->_em->createQuery($dqlToBeTested); + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\Tests\ORM\Functional\CustomTreeWalker')) + ->useQueryCache(false); + + $this->assertEquals($sqlToBeConfirmed, $query->getSql()); + $query->free(); + } catch (\Exception $e) { + $this->fail($e->getMessage() . ' at "' . $e->getFile() . '" on line ' . $e->getLine()); + + } + } + + public function testSupportsQueriesWithoutWhere() + { + $this->assertSqlGeneration( + 'select u from Doctrine\Tests\Models\CMS\CmsUser u', + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ WHERE c0_.id = 1" + ); + } + + public function testSupportsQueriesWithMultipleConditionalExpressions() + { + $this->assertSqlGeneration( + 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name or u.name = :otherName', + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ WHERE (c0_.name = ? OR c0_.name = ?) AND c0_.id = 1" + ); + } + + public function testSupportsQueriesWithSimpleConditionalExpression() + { + $this->assertSqlGeneration( + 'select u from Doctrine\Tests\Models\CMS\CmsUser u where u.name = :name', + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ WHERE c0_.name = ? AND c0_.id = 1" + ); + } +} + +class CustomTreeWalker extends Query\TreeWalkerAdapter +{ + public function walkSelectStatement(Query\AST\SelectStatement $selectStatement) + { + // Get the DQL aliases of all the classes we want to modify + $dqlAliases = array(); + + foreach ($this->_getQueryComponents() as $dqlAlias => $comp) { + // Hard-coded check just for demonstration: We want to modify the query if + // it involves the CmsUser class. + if ($comp['metadata']->name == 'Doctrine\Tests\Models\CMS\CmsUser') { + $dqlAliases[] = $dqlAlias; + } + } + + // Create our conditions for all involved classes + $factors = array(); + foreach ($dqlAliases as $alias) { + $pathExpr = new Query\AST\PathExpression(Query\AST\PathExpression::TYPE_STATE_FIELD, $alias, 'id'); + $pathExpr->type = Query\AST\PathExpression::TYPE_STATE_FIELD; + $comparisonExpr = new Query\AST\ComparisonExpression($pathExpr, '=', 1); + + $condPrimary = new Query\AST\ConditionalPrimary; + $condPrimary->simpleConditionalExpression = $comparisonExpr; + + $factor = new Query\AST\ConditionalFactor($condPrimary); + $factors[] = $factor; + } + + if (($whereClause = $selectStatement->whereClause) !== null) { + // There is already a WHERE clause, so append the conditions + $condExpr = $whereClause->conditionalExpression; + + // Since Phase 1 AST optimizations were included, we need to re-add the ConditionalExpression + if ( ! ($condExpr instanceof Query\AST\ConditionalExpression)) { + $condExpr = new Query\AST\ConditionalExpression(array($condExpr)); + + $whereClause->conditionalExpression = $condExpr; + } + + $existingTerms = $whereClause->conditionalExpression->conditionalTerms; + + if (count($existingTerms) > 1) { + // More than one term, so we need to wrap all these terms in a single root term + // i.e: "WHERE u.name = :foo or u.other = :bar" => "WHERE (u.name = :foo or u.other = :bar) AND " + + $primary = new Query\AST\ConditionalPrimary; + $primary->conditionalExpression = new Query\AST\ConditionalExpression($existingTerms); + $existingFactor = new Query\AST\ConditionalFactor($primary); + $term = new Query\AST\ConditionalTerm(array_merge(array($existingFactor), $factors)); + + $selectStatement->whereClause->conditionalExpression->conditionalTerms = array($term); + } else { + // Just one term so we can simply append our factors to that term + $singleTerm = $selectStatement->whereClause->conditionalExpression->conditionalTerms[0]; + + // Since Phase 1 AST optimizations were included, we need to re-add the ConditionalExpression + if ( ! ($singleTerm instanceof Query\AST\ConditionalTerm)) { + $singleTerm = new Query\AST\ConditionalTerm(array($singleTerm)); + + $selectStatement->whereClause->conditionalExpression->conditionalTerms[0] = $singleTerm; + } + + $singleTerm->conditionalFactors = array_merge($singleTerm->conditionalFactors, $factors); + $selectStatement->whereClause->conditionalExpression->conditionalTerms = array($singleTerm); + } + } else { + // Create a new WHERE clause with our factors + $term = new Query\AST\ConditionalTerm($factors); + $condExpr = new Query\AST\ConditionalExpression(array($term)); + $whereClause = new Query\AST\WhereClause($condExpr); + $selectStatement->whereClause = $whereClause; + } + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php new file mode 100644 index 0000000..999d52d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -0,0 +1,166 @@ +useModelSet('cms'); + parent::setUp(); + + $this->_sm = $this->_em->getConnection()->getSchemaManager(); + } + + public function testLoadMetadataFromDatabase() + { + if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped('Platform does not support foreign keys.'); + } + + $table = new \Doctrine\DBAL\Schema\Table("dbdriver_foo"); + $table->addColumn('id', 'integer'); + $table->setPrimaryKey(array('id')); + $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 200)); + + $this->_sm->dropAndCreateTable($table); + + $metadatas = $this->extractClassMetadata(array("DbdriverFoo")); + + $this->assertArrayHasKey('DbdriverFoo', $metadatas); + $metadata = $metadatas['DbdriverFoo']; + + $this->assertArrayHasKey('id', $metadata->fieldMappings); + $this->assertEquals('id', $metadata->fieldMappings['id']['fieldName']); + $this->assertEquals('id', strtolower($metadata->fieldMappings['id']['columnName'])); + $this->assertEquals('integer', (string)$metadata->fieldMappings['id']['type']); + + $this->assertArrayHasKey('bar', $metadata->fieldMappings); + $this->assertEquals('bar', $metadata->fieldMappings['bar']['fieldName']); + $this->assertEquals('bar', strtolower($metadata->fieldMappings['bar']['columnName'])); + $this->assertEquals('string', (string)$metadata->fieldMappings['bar']['type']); + $this->assertEquals(200, $metadata->fieldMappings['bar']['length']); + $this->assertTrue($metadata->fieldMappings['bar']['nullable']); + } + + public function testLoadMetadataWithForeignKeyFromDatabase() + { + if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped('Platform does not support foreign keys.'); + } + + $tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar"); + $tableB->addColumn('id', 'integer'); + $tableB->setPrimaryKey(array('id')); + + $this->_sm->dropAndCreateTable($tableB); + + $tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz"); + $tableA->addColumn('id', 'integer'); + $tableA->setPrimaryKey(array('id')); + $tableA->addColumn('bar_id', 'integer'); + $tableA->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id')); + + $this->_sm->dropAndCreateTable($tableA); + + $metadatas = $this->extractClassMetadata(array("DbdriverBar", "DbdriverBaz")); + + $this->assertArrayHasKey('DbdriverBaz', $metadatas); + $bazMetadata = $metadatas['DbdriverBaz']; + + $this->assertArrayNotHasKey('barId', $bazMetadata->fieldMappings, "The foreign Key field should not be inflected as 'barId' field, its an association."); + $this->assertArrayHasKey('id', $bazMetadata->fieldMappings); + + $bazMetadata->associationMappings = \array_change_key_case($bazMetadata->associationMappings, \CASE_LOWER); + + $this->assertArrayHasKey('bar', $bazMetadata->associationMappings); + $this->assertEquals(ClassMetadataInfo::MANY_TO_ONE, $bazMetadata->associationMappings['bar']['type']); + } + + public function testDetectManyToManyTables() + { + if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped('Platform does not support foreign keys.'); + } + + $metadatas = $this->extractClassMetadata(array("CmsUsers", "CmsGroups")); + + $this->assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); + $this->assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.'); + + $this->assertEquals(2, count($metadatas['CmsUsers']->associationMappings)); + $this->assertArrayHasKey('group', $metadatas['CmsUsers']->associationMappings); + $this->assertEquals(1, count($metadatas['CmsGroups']->associationMappings)); + $this->assertArrayHasKey('user', $metadatas['CmsGroups']->associationMappings); + } + + public function testIgnoreManyToManyTableWithoutFurtherForeignKeyDetails() + { + $tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar"); + $tableB->addColumn('id', 'integer'); + $tableB->setPrimaryKey(array('id')); + + $tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz"); + $tableA->addColumn('id', 'integer'); + $tableA->setPrimaryKey(array('id')); + + $tableMany = new \Doctrine\DBAL\Schema\Table("dbdriver_bar_baz"); + $tableMany->addColumn('bar_id', 'integer'); + $tableMany->addColumn('baz_id', 'integer'); + $tableMany->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id')); + + $metadatas = $this->convertToClassMetadata(array($tableA, $tableB), array($tableMany)); + + $this->assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), "no association mappings should be detected."); + } + + protected function convertToClassMetadata(array $entityTables, array $manyTables = array()) + { + $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->_sm); + $driver->setTables($entityTables, $manyTables); + + $metadatas = array(); + foreach ($driver->getAllClassNames() AS $className) { + $class = new ClassMetadataInfo($className); + $driver->loadMetadataForClass($className, $class); + $metadatas[$className] = $class; + } + + return $metadatas; + } + + /** + * @param string $className + * @return ClassMetadata + */ + protected function extractClassMetadata(array $classNames) + { + $classNames = array_map('strtolower', $classNames); + $metadatas = array(); + + $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->_sm); + foreach ($driver->getAllClassNames() as $className) { + if (!in_array(strtolower($className), $classNames)) { + continue; + } + $class = new ClassMetadataInfo($className); + $driver->loadMetadataForClass($className, $class); + $metadatas[$className] = $class; + } + + if (count($metadatas) != count($classNames)) { + $this->fail("Have not found all classes matching the names '" . implode(", ", $classNames) . "' only tables " . implode(", ", array_keys($metadatas))); + } + return $metadatas; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php new file mode 100644 index 0000000..11511a0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DefaultValuesTest.php @@ -0,0 +1,150 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueUser'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueAddress') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + + public function testSimpleDetachMerge() { + $user = new DefaultValueUser; + $user->name = 'romanb'; + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $userId = $user->id; // e.g. from $_REQUEST + $user2 = $this->_em->getReference(get_class($user), $userId); + + $this->_em->flush(); + $this->assertFalse($user2->__isInitialized__); + + $a = new DefaultValueAddress; + $a->country = 'de'; + $a->zip = '12345'; + $a->city = 'Berlin'; + $a->street = 'Sesamestreet'; + + $a->user = $user2; + $this->_em->persist($a); + $this->_em->flush(); + + $this->assertFalse($user2->__isInitialized__); + $this->_em->clear(); + + $a2 = $this->_em->find(get_class($a), $a->id); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\DefaultValueUser', $a2->getUser()); + $this->assertEquals($userId, $a2->getUser()->getId()); + $this->assertEquals('Poweruser', $a2->getUser()->type); + } + + /** + * @group DDC-1386 + */ + public function testGetPartialReferenceWithDefaultValueNotEvalutedInFlush() + { + $user = new DefaultValueUser; + $user->name = 'romanb'; + $user->type = 'Normaluser'; + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->getPartialReference('Doctrine\Tests\ORM\Functional\DefaultValueUser', $user->id); + $this->assertTrue($this->_em->getUnitOfWork()->isReadOnly($user)); + + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find('Doctrine\Tests\ORM\Functional\DefaultValueUser', $user->id); + + $this->assertEquals('Normaluser', $user->type); + } +} + + +/** + * @Entity @Table(name="defaultvalueuser") + */ +class DefaultValueUser +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + /** + * @Column(type="string") + */ + public $name = ''; + /** + * @Column(type="string") + */ + public $type = 'Poweruser'; + /** + * @OneToOne(targetEntity="DefaultValueAddress", mappedBy="user", cascade={"persist"}) + */ + public $address; + + public function getId() {return $this->id;} +} + +/** + * CmsAddress + * + * @Entity @Table(name="defaultvalueaddresses") + */ +class DefaultValueAddress +{ + /** + * @Column(type="integer") + * @Id @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column(type="string", length=50) + */ + public $country; + + /** + * @Column(type="string", length=50) + */ + public $zip; + + /** + * @Column(type="string", length=50) + */ + public $city; + + /** + * Testfield for Schema Updating Tests. + */ + public $street; + + /** + * @OneToOne(targetEntity="DefaultValueUser") + * @JoinColumn(name="user_id", referencedColumnName="id") + */ + public $user; + + public function getUser() {return $this->user;} +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php new file mode 100644 index 0000000..f5c50eb --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php @@ -0,0 +1,218 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testSimpleDetachMerge() { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + // $user is now detached + + $this->assertFalse($this->_em->contains($user)); + + $user->name = 'Roman B.'; + + //$this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_em->getUnitOfWork()->getEntityState($user)); + + $user2 = $this->_em->merge($user); + + $this->assertFalse($user === $user2); + $this->assertTrue($this->_em->contains($user2)); + $this->assertEquals('Roman B.', $user2->name); + } + + public function testSerializeUnserializeModifyMerge() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $ph1 = new CmsPhonenumber; + $ph1->phonenumber = "1234"; + $user->addPhonenumber($ph1); + + $this->_em->persist($user); + $this->_em->flush(); + $this->assertTrue($this->_em->contains($user)); + $this->assertTrue($user->phonenumbers->isInitialized()); + + $serialized = serialize($user); + $this->_em->clear(); + $this->assertFalse($this->_em->contains($user)); + unset($user); + + $user = unserialize($serialized); + + $this->assertEquals(1, count($user->getPhonenumbers()), "Pre-Condition: 1 Phonenumber"); + + $ph2 = new CmsPhonenumber; + $ph2->phonenumber = "56789"; + $user->addPhonenumber($ph2); + $oldPhonenumbers = $user->getPhonenumbers(); + $this->assertEquals(2, count($oldPhonenumbers), "Pre-Condition: 2 Phonenumbers"); + $this->assertFalse($this->_em->contains($user)); + + $this->_em->persist($ph2); + + // Merge back in + $user = $this->_em->merge($user); // merge cascaded to phonenumbers + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[0]->user); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user->phonenumbers[1]->user); + $im = $this->_em->getUnitOfWork()->getIdentityMap(); + $this->_em->flush(); + + $this->assertTrue($this->_em->contains($user), "Failed to assert that merged user is contained inside EntityManager persistence context."); + $phonenumbers = $user->getPhonenumbers(); + $this->assertNotSame($oldPhonenumbers, $phonenumbers, "Merge should replace the Detached Collection with a new PersistentCollection."); + $this->assertEquals(2, count($phonenumbers), "Failed to assert that two phonenumbers are contained in the merged users phonenumber collection."); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[1]); + $this->assertTrue($this->_em->contains($phonenumbers[1]), "Failed to assert that second phonenumber in collection is contained inside EntityManager persistence context."); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $phonenumbers[0]); + $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($phonenumbers[0])); + $this->assertTrue($this->_em->contains($phonenumbers[0]), "Failed to assert that first phonenumber in collection is contained inside EntityManager persistence context."); + } + + /** + * @group DDC-203 + */ + public function testDetachedEntityThrowsExceptionOnFlush() + { + $ph = new CmsPhonenumber(); + $ph->phonenumber = '12345'; + $this->_em->persist($ph); + $this->_em->flush(); + $this->_em->clear(); + $this->_em->persist($ph); + try { + $this->_em->flush(); + $this->fail(); + } catch (\Exception $expected) {} + } + + public function testUninitializedLazyAssociationsAreIgnoredOnMerge() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $address = new CmsAddress; + $address->city = 'Berlin'; + $address->country = 'Germany'; + $address->street = 'Sesamestreet'; + $address->zip = 12345; + $address->setUser($user); + $this->_em->persist($address); + $this->_em->persist($user); + + $this->_em->flush(); + $this->_em->clear(); + + $address2 = $this->_em->find(get_class($address), $address->id); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->user); + $this->assertFalse($address2->user->__isInitialized__); + $detachedAddress2 = unserialize(serialize($address2)); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $detachedAddress2->user); + $this->assertFalse($detachedAddress2->user->__isInitialized__); + + $managedAddress2 = $this->_em->merge($detachedAddress2); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $managedAddress2->user); + $this->assertFalse($managedAddress2->user === $detachedAddress2->user); + $this->assertFalse($managedAddress2->user->__isInitialized__); + } + + /** + * @group DDC-822 + */ + public function testUseDetachedEntityAsQueryParameter() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $this->_em->persist($user); + + $this->_em->flush(); + $this->_em->detach($user); + + $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"; + $query = $this->_em->createQuery($dql); + $query->setParameter(1, $user); + + $newUser = $query->getSingleResult(); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $newUser); + $this->assertEquals('gblanco', $newUser->username); + } + + /** + * @group DDC-920 + */ + public function testDetachManagedUnpersistedEntity() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $this->_em->persist($user); + $this->_em->detach($user); + + $this->_em->flush(); + + $this->assertFalse($this->_em->contains($user)); + $this->assertFalse($this->_em->getUnitOfWork()->isInIdentityMap($user)); + } + + /** + * @group DDC-1340 + */ + public function testMergeArticleWrongVersion() + { + $article = new CmsArticle(); + $article->topic = "test"; + $article->text = "test"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->_em->detach($article); + + $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->_em->merge($article); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php new file mode 100644 index 0000000..b14ccaa --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -0,0 +1,505 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function tearDown() + { + if ($this->_em) { + $this->_em->getConfiguration()->setEntityNamespaces(array()); + } + parent::tearDown(); + } + + public function loadFixture() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'freak'; + $this->_em->persist($user); + + $user2 = new CmsUser; + $user2->name = 'Guilherme'; + $user2->username = 'gblanco'; + $user2->status = 'dev'; + $this->_em->persist($user2); + + $user3 = new CmsUser; + $user3->name = 'Benjamin'; + $user3->username = 'beberlei'; + $user3->status = null; + $this->_em->persist($user3); + + $this->_em->flush(); + + $user1Id = $user->getId(); + + unset($user); + unset($user2); + unset($user3); + + $this->_em->clear(); + + return $user1Id; + } + + public function loadAssociatedFixture() + { + $address = new CmsAddress(); + $address->city = "Berlin"; + $address->country = "Germany"; + $address->street = "Foostreet"; + $address->zip = "12345"; + + $user = new CmsUser(); + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'freak'; + $user->setAddress($address); + + $this->_em->persist($user); + $this->_em->persist($address); + $this->_em->flush(); + $this->_em->clear(); + + return array($user->id, $address->id); + } + + public function buildUser($name, $username, $status, $address) + { + $user = new CmsUser(); + $user->name = $name; + $user->username = $username; + $user->status = $status; + $user->setAddress($address); + + $this->_em->persist($user); + $this->_em->flush(); + + return $user; + } + + public function buildAddress($country, $city, $street, $zip) + { + $address = new CmsAddress(); + $address->country = $country; + $address->city = $city; + $address->street = $street; + $address->zip = $zip; + + $this->_em->persist($address); + $this->_em->flush(); + + return $address; + } + + public function testBasicFind() + { + $user1Id = $this->loadFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $user = $repos->find($user1Id); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$user); + $this->assertEquals('Roman', $user->name); + $this->assertEquals('freak', $user->status); + } + + public function testFindByField() + { + $user1Id = $this->loadFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $users = $repos->findBy(array('status' => 'dev')); + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]); + $this->assertEquals('Guilherme', $users[0]->name); + $this->assertEquals('dev', $users[0]->status); + } + + public function testFindByAssociationWithIntegerAsParameter() + { + $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456'); + $user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1); + + $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321'); + $user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2); + + $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654'); + $user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3); + + unset($address1); + unset($address2); + unset($address3); + + $this->_em->clear(); + + $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); + $addresses = $repository->findBy(array('user' => array($user1->getId(), $user2->getId()))); + + $this->assertEquals(2, count($addresses)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); + } + + public function testFindByAssociationWithObjectAsParameter() + { + $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456'); + $user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1); + + $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321'); + $user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2); + + $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654'); + $user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3); + + unset($address1); + unset($address2); + unset($address3); + + $this->_em->clear(); + + $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); + $addresses = $repository->findBy(array('user' => array($user1, $user2))); + + $this->assertEquals(2, count($addresses)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); + } + + public function testFindFieldByMagicCall() + { + $user1Id = $this->loadFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $users = $repos->findByStatus('dev'); + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]); + $this->assertEquals('Guilherme', $users[0]->name); + $this->assertEquals('dev', $users[0]->status); + } + + public function testFindAll() + { + $user1Id = $this->loadFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $users = $repos->findAll(); + $this->assertEquals(3, count($users)); + } + + public function testFindByAlias() + { + $user1Id = $this->loadFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); + + $repos = $this->_em->getRepository('CMS:CmsUser'); + + $users = $repos->findAll(); + $this->assertEquals(3, count($users)); + } + + /** + * @expectedException \Doctrine\ORM\ORMException + */ + public function testExceptionIsThrownWhenCallingFindByWithoutParameter() { + $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') + ->findByStatus(); + } + + /** + * @expectedException \Doctrine\ORM\ORMException + */ + public function testExceptionIsThrownWhenUsingInvalidFieldName() { + $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') + ->findByThisFieldDoesNotExist('testvalue'); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testPessimisticReadLockWithoutTransaction_ThrowsException() + { + $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + + $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') + ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testPessimisticWriteLockWithoutTransaction_ThrowsException() + { + $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + + $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') + ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testOptimisticLockUnversionedEntity_ThrowsException() + { + $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); + + $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') + ->find(1, \Doctrine\DBAL\LockMode::OPTIMISTIC); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testIdentityMappedOptimisticLockUnversionedEntity_ThrowsException() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'freak'; + $this->_em->persist($user); + $this->_em->flush(); + + $userId = $user->id; + + $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); + } + + /** + * @group DDC-819 + */ + public function testFindMagicCallByNullValue() + { + $this->loadFixture(); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $users = $repos->findByStatus(null); + $this->assertEquals(1, count($users)); + } + + /** + * @group DDC-819 + */ + public function testInvalidMagicCall() + { + $this->setExpectedException('BadMethodCallException'); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + $repos->foo(); + } + + /** + * @group DDC-817 + */ + public function testFindByAssociationKey_ExceptionOnInverseSide() + { + 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."); + $user = $repos->findBy(array('address' => $addressId)); + } + + /** + * @group DDC-817 + */ + public function testFindOneByAssociationKey() + { + list($userId, $addressId) = $this->loadAssociatedFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); + $address = $repos->findOneBy(array('user' => $userId)); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address); + $this->assertEquals($addressId, $address->id); + } + + /** + * @group DDC-817 + */ + public function testFindByAssociationKey() + { + list($userId, $addressId) = $this->loadAssociatedFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); + $addresses = $repos->findBy(array('user' => $userId)); + + $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses); + $this->assertEquals(1, count($addresses)); + $this->assertEquals($addressId, $addresses[0]->id); + } + + /** + * @group DDC-817 + */ + public function testFindAssociationByMagicCall() + { + list($userId, $addressId) = $this->loadAssociatedFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); + $addresses = $repos->findByUser($userId); + + $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses); + $this->assertEquals(1, count($addresses)); + $this->assertEquals($addressId, $addresses[0]->id); + } + + /** + * @group DDC-817 + */ + public function testFindOneAssociationByMagicCall() + { + list($userId, $addressId) = $this->loadAssociatedFixture(); + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); + $address = $repos->findOneByUser($userId); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address); + $this->assertEquals($addressId, $address->id); + } + + public function testValidNamedQueryRetrieval() + { + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $query = $repos->createNamedQuery('all'); + + $this->assertInstanceOf('Doctrine\ORM\Query', $query); + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL()); + } + + public function testInvalidNamedQueryRetrieval() + { + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + + $repos->createNamedQuery('invalidNamedQuery'); + } + + /** + * @group DDC-1087 + */ + public function testIsNullCriteriaDoesNotGenerateAParameter() + { + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + $users = $repos->findBy(array('status' => null, 'username' => 'romanb')); + + $params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params']; + $this->assertEquals(1, count($params), "Should only execute with one parameter."); + $this->assertEquals(array('romanb'), $params); + } + + public function testIsNullCriteria() + { + $this->loadFixture(); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $users = $repos->findBy(array('status' => null)); + $this->assertEquals(1, count($users)); + } + + /** + * @group DDC-1094 + */ + public function testFindByLimitOffset() + { + $this->loadFixture(); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $users1 = $repos->findBy(array(), null, 1, 0); + $users2 = $repos->findBy(array(), null, 1, 1); + + $this->assertEquals(3, count($repos->findBy(array()))); + $this->assertEquals(1, count($users1)); + $this->assertEquals(1, count($users2)); + $this->assertNotSame($users1[0], $users2[0]); + } + + /** + * @group DDC-1094 + */ + public function testFindByOrderBy() + { + $this->loadFixture(); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + $usersAsc = $repos->findBy(array(), array("username" => "ASC")); + $usersDesc = $repos->findBy(array(), array("username" => "DESC")); + + $this->assertEquals(3, count($usersAsc), "Pre-condition: only three users in fixture"); + $this->assertEquals(3, count($usersDesc), "Pre-condition: only three users in fixture"); + $this->assertSame($usersAsc[0], $usersDesc[2]); + $this->assertSame($usersAsc[2], $usersDesc[0]); + } + + + /** + * @group DDC-753 + */ + public function testDefaultRepositoryClassName() + { + $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); + $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); + $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository'); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository", $repos); + $this->assertTrue($repos->isDefaultRepository()); + + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithCustomRepository'); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753CustomRepository", $repos); + $this->assertTrue($repos->isCustomRepository()); + + $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository"); + $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\ORM\EntityRepository"); + $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); + + } + + + /** + * @group DDC-753 + * @expectedException Doctrine\ORM\ORMException + * @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. it must be a Doctrine\ORM\EntityRepository. + */ + public function testSetDefaultRepositoryInvalidClassError() + { + $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository"); + $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753InvalidRepository"); + } + + /** + * @group DDC-1500 + */ + public function testInvalidOrientation() + { + $this->setExpectedException('Doctrine\ORM\ORMException', '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')); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php new file mode 100644 index 0000000..f8b41e0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php @@ -0,0 +1,583 @@ +useModelSet('cms'); + parent::setUp(); + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); + $class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + + $this->loadFixture(); + } + + public function tearDown() + { + parent::tearDown(); + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'); + $class->associationMappings['users']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + } + + /** + * @group DDC-546 + */ + public function testCountNotInitializesCollection() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->groups->isInitialized()); + $this->assertEquals(3, count($user->groups)); + $this->assertFalse($user->groups->isInitialized()); + + foreach ($user->groups AS $group) { } + + $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); + } + + /** + * @group DDC-546 + */ + public function testCountWhenNewEntityPresent() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $newGroup->name = "Test4"; + + $user->addGroup($newGroup); + $this->_em->persist($newGroup); + + $this->assertFalse($user->groups->isInitialized()); + $this->assertEquals(4, count($user->groups)); + $this->assertFalse($user->groups->isInitialized()); + } + + /** + * @group DDC-546 + */ + public function testCountWhenInitialized() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $queryCount = $this->getCurrentQueryCount(); + + foreach ($user->groups AS $group) { } + + $this->assertTrue($user->groups->isInitialized()); + $this->assertEquals(3, count($user->groups)); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Should only execute one query to initialize colleciton, no extra query for count() more."); + } + + /** + * @group DDC-546 + */ + public function testCountInverseCollection() + { + $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); + $this->assertFalse($group->users->isInitialized(), "Pre-Condition"); + + $this->assertEquals(4, count($group->users)); + $this->assertFalse($group->users->isInitialized(), "Extra Lazy collection should not be initialized by counting the collection."); + } + + /** + * @group DDC-546 + */ + public function testCountOneToMany() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->groups->isInitialized(), "Pre-Condition"); + + $this->assertEquals(2, count($user->articles)); + } + + /** + * @group DDC-546 + */ + public function testFullSlice() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); + + $someGroups = $user->groups->slice(null); + $this->assertEquals(3, count($someGroups)); + } + + /** + * @group DDC-546 + */ + public function testSlice() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); + + $queryCount = $this->getCurrentQueryCount(); + + $someGroups = $user->groups->slice(0, 2); + + $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsGroup', $someGroups); + $this->assertEquals(2, count($someGroups)); + $this->assertFalse($user->groups->isInitialized(), "Slice should not initialize the collection if it wasn't before!"); + + $otherGroup = $user->groups->slice(2, 1); + + $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsGroup', $otherGroup); + $this->assertEquals(1, count($otherGroup)); + $this->assertFalse($user->groups->isInitialized()); + + foreach ($user->groups AS $group) { } + + $this->assertTrue($user->groups->isInitialized()); + $this->assertEquals(3, count($user->groups)); + + $this->assertEquals($queryCount + 3, $this->getCurrentQueryCount()); + } + + /** + * @group DDC-546 + */ + public function testSliceInitializedCollection() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $queryCount = $this->getCurrentQueryCount(); + + foreach ($user->groups AS $group) { } + + $someGroups = $user->groups->slice(0, 2); + + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + + $this->assertEquals(2, count($someGroups)); + $this->assertTrue($user->groups->contains($someGroups[0])); + $this->assertTrue($user->groups->contains($someGroups[1])); + } + + /** + * @group DDC-546 + */ + public function testSliceInverseCollection() + { + $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); + $this->assertFalse($group->users->isInitialized(), "Pre-Condition"); + $queryCount = $this->getCurrentQueryCount(); + + $someUsers = $group->users->slice(0, 2); + $otherUsers = $group->users->slice(2, 2); + + $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $someUsers); + $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $otherUsers); + $this->assertEquals(2, count($someUsers)); + $this->assertEquals(2, count($otherUsers)); + + // +2 queries executed by slice + $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Slicing two parts should only execute two additional queries."); + } + + /** + * @group DDC-546 + */ + public function testSliceOneToMany() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); + + $queryCount = $this->getCurrentQueryCount(); + + $someArticle = $user->articles->slice(0, 1); + $otherArticle = $user->articles->slice(1, 1); + + $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount()); + } + + /** + * @group DDC-546 + */ + public function testContainsOneToMany() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); + + // Test One to Many existance retrieved from DB + $article = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId); + $queryCount = $this->getCurrentQueryCount(); + + $this->assertTrue($user->articles->contains($article)); + $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + + // Test One to Many existance with state new + $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article->topic = "Testnew"; + $article->text = "blub"; + + $queryCount = $this->getCurrentQueryCount(); + $this->assertFalse($user->articles->contains($article)); + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); + + // Test One to Many existance with state clear + $this->_em->persist($article); + $this->_em->flush(); + + $queryCount = $this->getCurrentQueryCount(); + $this->assertFalse($user->articles->contains($article)); + $this->assertEquals($queryCount+1, $this->getCurrentQueryCount(), "Checking for contains of persisted entity should cause one query to be executed."); + $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); + + // Test One to Many existance with state managed + $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article->topic = "How to not fail anymore on tests"; + $article->text = "That is simple! Just write more tests!"; + + $this->_em->persist($article); + + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->articles->contains($article)); + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of managed entity (but not persisted) should cause no query to be executed."); + $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); + } + + /** + * @group DDC-546 + */ + public function testContainsManyToMany() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); + + // Test Many to Many existance retrieved from DB + $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); + $queryCount = $this->getCurrentQueryCount(); + + $this->assertTrue($user->groups->contains($group)); + $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."); + + // Test Many to Many existance with state new + $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group->name = "A New group!"; + + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->groups->contains($group)); + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); + $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); + + // Test Many to Many existance with state clear + $this->_em->persist($group); + $this->_em->flush(); + + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->groups->contains($group)); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Checking for contains of persisted entity should cause one query to be executed."); + $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); + + // Test Many to Many existance with state managed + $group = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group->name = "My managed group"; + + $this->_em->persist($group); + + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->groups->contains($group)); + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of managed entity (but not persisted) should cause no query to be executed."); + $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); + } + + /** + * @group DDC-546 + */ + public function testContainsManyToManyInverse() + { + $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); + $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); + + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $queryCount = $this->getCurrentQueryCount(); + $this->assertTrue($group->users->contains($user)); + $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->name = "A New group!"; + + $queryCount = $this->getCurrentQueryCount(); + $this->assertFalse($group->users->contains($newUser)); + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); + $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); + } + + /** + * + */ + public function testRemoveElementOneToMany() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->articles->isInitialized(), "Pre-Condition: Collection is not initialized."); + + // Test One to Many removal with Entity retrieved from DB + $article = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId); + $queryCount = $this->getCurrentQueryCount(); + + $user->articles->removeElement($article); + + $this->assertFalse($user->articles->isInitialized(), "Post-Condition: Collection is not initialized."); + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); + + // Test One to Many removal with Entity state as new + $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article->topic = "Testnew"; + $article->text = "blub"; + + $queryCount = $this->getCurrentQueryCount(); + + $user->articles->removeElement($article); + + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a new entity should cause no query to be executed."); + + // Test One to Many removal with Entity state as clean + $this->_em->persist($article); + $this->_em->flush(); + + $queryCount = $this->getCurrentQueryCount(); + + $user->articles->removeElement($article); + + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed."); + $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->topic = "How to not fail anymore on tests"; + $article->text = "That is simple! Just write more tests!"; + + $this->_em->persist($article); + + $queryCount = $this->getCurrentQueryCount(); + + $user->articles->removeElement($article); + + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a managed entity should cause no query to be executed."); + } + + /** + * + */ + public function testRemoveElementManyToMany() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $this->assertFalse($user->groups->isInitialized(), "Pre-Condition: Collection is not initialized."); + + // Test Many to Many removal with Entity retrieved from DB + $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); + $queryCount = $this->getCurrentQueryCount(); + + $user->groups->removeElement($group); + + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed."); + $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->name = "A New group!"; + + $queryCount = $this->getCurrentQueryCount(); + + $user->groups->removeElement($group); + + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing new entity should cause no query to be executed."); + $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); + + // Test Many to Many removal with Entity state as clean + $this->_em->persist($group); + $this->_em->flush(); + + $queryCount = $this->getCurrentQueryCount(); + + $user->groups->removeElement($group); + + $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed."); + $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->name = "A New group!"; + + $this->_em->persist($group); + + $queryCount = $this->getCurrentQueryCount(); + + $user->groups->removeElement($group); + + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a managed entity should cause no query to be executed."); + $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); + } + + /** + * + */ + public function testRemoveElementManyToManyInverse() + { + $group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId); + $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); + + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $queryCount = $this->getCurrentQueryCount(); + + $group->users->removeElement($user); + + $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->name = "A New group!"; + + $queryCount = $this->getCurrentQueryCount(); + + $group->users->removeElement($newUser); + + $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a new entity should cause no query to be executed."); + $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); + } + + /** + * @group DDC-1399 + */ + public function testCountAfterAddThenFlush() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $newGroup->name = "Test4"; + + $user->addGroup($newGroup); + $this->_em->persist($newGroup); + + $this->assertFalse($user->groups->isInitialized()); + $this->assertEquals(4, count($user->groups)); + $this->assertFalse($user->groups->isInitialized()); + + $this->_em->flush(); + + $this->assertEquals(4, count($user->groups)); + } + + /** + * @group DDC-1462 + */ + public function testSliceOnDirtyCollection() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + /* @var $user CmsUser */ + + $newGroup = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $newGroup->name = "Test4"; + + $user->addGroup($newGroup); + $this->_em->persist($newGroup); + + $qc = $this->getCurrentQueryCount(); + $groups = $user->groups->slice(0, 10); + + $this->assertEquals(4, count($groups)); + $this->assertEquals($qc + 1, $this->getCurrentQueryCount()); + } + + private function loadFixture() + { + $user1 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user1->username = "beberlei"; + $user1->name = "Benjamin"; + $user1->status = "active"; + + $user2 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user2->username = "jwage"; + $user2->name = "Jonathan"; + $user2->status = "active"; + + $user3 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user3->username = "romanb"; + $user3->name = "Roman"; + $user3->status = "active"; + + $user4 = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user4->username = "gblanco"; + $user4->name = "Guilherme"; + $user4->status = "active"; + + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->persist($user3); + $this->_em->persist($user4); + + $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group1->name = "Test1"; + + $group2 = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group2->name = "Test2"; + + $group3 = new \Doctrine\Tests\Models\CMS\CmsGroup(); + $group3->name = "Test3"; + + $user1->addGroup($group1); + $user1->addGroup($group2); + $user1->addGroup($group3); + + $user2->addGroup($group1); + $user3->addGroup($group1); + $user4->addGroup($group1); + + $this->_em->persist($group1); + $this->_em->persist($group2); + $this->_em->persist($group3); + + $article1 = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article1->topic = "Test"; + $article1->text = "Test"; + $article1->setAuthor($user1); + + $article2 = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article2->topic = "Test"; + $article2->text = "Test"; + $article2->setAuthor($user1); + + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->flush(); + $this->_em->clear(); + + $this->articleId = $article1->id; + $this->userId = $user1->getId(); + $this->groupId = $group1->id; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php new file mode 100644 index 0000000..8167e85 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/FlushEventTest.php @@ -0,0 +1,94 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testPersistNewEntitiesOnPreFlush() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_em->getEventManager()->addEventListener(Events::onFlush, new OnFlushListener); + + $user = new CmsUser; + $user->username = 'romanb'; + $user->name = 'Roman'; + $user->status = 'Dev'; + + $this->_em->persist($user); + + $this->assertEquals(0, $user->phonenumbers->count()); + + $this->_em->flush(); + + $this->assertEquals(1, $user->phonenumbers->count()); + $this->assertTrue($this->_em->contains($user->phonenumbers->get(0))); + $this->assertTrue($user->phonenumbers->get(0)->getUser() === $user); + + $this->assertFalse($user->phonenumbers->isDirty()); + + // Can be used together with SQL Logging to check that a subsequent flush has + // nothing to do. This proofs the correctness of the changes that happened in onFlush. + //echo "SECOND FLUSH"; + //$this->_em->flush(); + } +} + +class OnFlushListener +{ + public function onFlush(OnFlushEventArgs $args) + { + //echo "---preFlush".PHP_EOL; + + $em = $args->getEntityManager(); + $uow = $em->getUnitOfWork(); + + foreach ($uow->getScheduledEntityInsertions() as $entity) { + + if ($entity instanceof CmsUser) { + // Adds a phonenumber to every newly persisted CmsUser ... + + $phone = new CmsPhonenumber; + $phone->phonenumber = 12345; + // Update object model + $entity->addPhonenumber($phone); + // Invoke regular persist call + $em->persist($phone); + // Explicitly calculate the changeset since onFlush is raised + // after changeset calculation! + $uow->computeChangeSet($em->getClassMetadata(get_class($phone)), $phone); + + // Take a snapshot because the UoW wont do this for us, because + // the UoW did not visit this collection. + // Alternatively we could provide an ->addVisitedCollection() method + // on the UoW. + $entity->getPhonenumbers()->takeSnapshot(); + } + + /*foreach ($uow->getEntityChangeSet($entity) as $field => $change) { + list ($old, $new) = $change; + + var_dump($old); + }*/ + + } + } +} + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php new file mode 100644 index 0000000..8974211 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/HydrationCacheTest.php @@ -0,0 +1,86 @@ +useModelSet('cms'); + parent::setUp(); + + $user = new CmsUser; + $user->name = "Benjamin"; + $user->username = "beberlei"; + $user->status = 'active'; + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + } + + public function testHydrationCache() + { + $cache = new ArrayCache(); + $dql = "SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u"; + + $users = $this->_em->createQuery($dql) + ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) + ->getResult(); + + $c = $this->getCurrentQueryCount(); + $users = $this->_em->createQuery($dql) + ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) + ->getResult(); + + $this->assertEquals($c, $this->getCurrentQueryCount(), "Should not execute query. Its cached!"); + + $users = $this->_em->createQuery($dql) + ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) + ->getArrayResult(); + + $this->assertEquals($c + 1, $this->getCurrentQueryCount(), "Hydration is part of cache key."); + + $users = $this->_em->createQuery($dql) + ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)) + ->getArrayResult(); + + $this->assertEquals($c + 1, $this->getCurrentQueryCount(), "Hydration now cached"); + + $users = $this->_em->createQuery($dql) + ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) + ->getArrayResult(); + + $this->assertTrue($cache->contains('cachekey'), 'Explicit cache key'); + + $users = $this->_em->createQuery($dql) + ->setHydrationCacheProfile(new QueryCacheProfile(null, 'cachekey', $cache)) + ->getArrayResult(); + $this->assertEquals($c + 2, $this->getCurrentQueryCount(), "Hydration now cached"); + } + + public function testHydrationParametersSerialization() + { + $cache = new ArrayCache(); + $user = new CmsUser(); + $user->id = 1; + + $dql = "SELECT u FROM Doctrine\Tests\Models\Cms\CmsUser u WHERE u.id = ?1"; + $query = $this->_em->createQuery($dql) + ->setParameter(1, $user) + ->setHydrationCacheProfile(new QueryCacheProfile(null, null, $cache)); + + $query->getResult(); + $c = $this->getCurrentQueryCount(); + $query->getResult(); + $this->assertEquals($c, $this->getCurrentQueryCount(), "Should not execute query. Its cached!"); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php new file mode 100644 index 0000000..84d0064 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php @@ -0,0 +1,288 @@ + + */ +class IdentityMapTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() { + $this->useModelSet('cms'); + parent::setUp(); + } + + public function testBasicIdentityManagement() + { + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'romanb'; + $user->name = 'Roman B.'; + + $address = new CmsAddress; + $address->country = 'de'; + $address->zip = 1234; + $address->city = 'Berlin'; + + $user->setAddress($address); + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $user2 = $this->_em->find(get_class($user), $user->getId()); + $this->assertTrue($user2 !== $user); + $user3 = $this->_em->find(get_class($user), $user->getId()); + $this->assertTrue($user2 === $user3); + + $address2 = $this->_em->find(get_class($address), $address->getId()); + $this->assertTrue($address2 !== $address); + $address3 = $this->_em->find(get_class($address), $address->getId()); + $this->assertTrue($address2 === $address3); + + $this->assertTrue($user2->getAddress() === $address2); // !!! + } + + public function testSingleValuedAssociationIdentityMapBehaviorWithRefresh() + { + $address = new CmsAddress; + $address->country = 'de'; + $address->zip = '12345'; + $address->city = 'Berlin'; + + $user1 = new CmsUser; + $user1->status = 'dev'; + $user1->username = 'romanb'; + $user1->name = 'Roman B.'; + + $user2 = new CmsUser; + $user2->status = 'dev'; + $user2->username = 'gblanco'; + $user2->name = 'Guilherme Blanco'; + + $address->setUser($user1); + + $this->_em->persist($address); + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->flush(); + + $this->assertSame($user1, $address->user); + + //external update to CmsAddress + $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', array($user2->getId())); + + // But we want to have this external change! + // Solution 1: refresh(), broken atm! + $this->_em->refresh($address); + + // Now the association should be "correct", referencing $user2 + $this->assertSame($user2, $address->user); + $this->assertSame($user2->address, $address); // check back reference also + + // Attention! refreshes can result in broken bidirectional associations! this is currently expected! + // $user1 still points to $address! + $this->assertSame($user1->address, $address); + } + + public function testSingleValuedAssociationIdentityMapBehaviorWithRefreshQuery() + { + $address = new CmsAddress; + $address->country = 'de'; + $address->zip = '12345'; + $address->city = 'Berlin'; + + $user1 = new CmsUser; + $user1->status = 'dev'; + $user1->username = 'romanb'; + $user1->name = 'Roman B.'; + + $user2 = new CmsUser; + $user2->status = 'dev'; + $user2->username = 'gblanco'; + $user2->name = 'Guilherme Blanco'; + + $address->setUser($user1); + + $this->_em->persist($address); + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->flush(); + + + $this->assertSame($user1, $address->user); + + //external update to CmsAddress + $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', array($user2->getId())); + + //select + $q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u'); + $address2 = $q->getSingleResult(); + + $this->assertSame($address, $address2); + + // Should still be $user1 + $this->assertSame($user1, $address2->user); + $this->assertTrue($user2->address === null); + + // But we want to have this external change! + // Solution 2: Alternatively, a refresh query should work + $q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u'); + $q->setHint(Query::HINT_REFRESH, true); + $address3 = $q->getSingleResult(); + + $this->assertSame($address, $address3); // should still be the same, always from identity map + + // Now the association should be "correct", referencing $user2 + $this->assertSame($user2, $address2->user); + $this->assertSame($user2->address, $address2); // check back reference also + + // Attention! refreshes can result in broken bidirectional associations! this is currently expected! + // $user1 still points to $address2! + $this->assertSame($user1->address, $address2); + } + + public function testCollectionValuedAssociationIdentityMapBehaviorWithRefreshQuery() + { + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'romanb'; + $user->name = 'Roman B.'; + + $phone1 = new CmsPhonenumber; + $phone1->phonenumber = 123; + + $phone2 = new CmsPhonenumber; + $phone2->phonenumber = 234; + + $phone3 = new CmsPhonenumber; + $phone3->phonenumber = 345; + + $user->addPhonenumber($phone1); + $user->addPhonenumber($phone2); + $user->addPhonenumber($phone3); + + $this->_em->persist($user); // cascaded to phone numbers + $this->_em->flush(); + + $this->assertEquals(3, count($user->getPhonenumbers())); + $this->assertFalse($user->getPhonenumbers()->isDirty()); + + //external update to CmsAddress + $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', array(999, $user->getId())); + + //select + $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); + $user2 = $q->getSingleResult(); + + $this->assertSame($user, $user2); + + // Should still be the same 3 phonenumbers + $this->assertEquals(3, count($user2->getPhonenumbers())); + + // But we want to have this external change! + // Solution 1: refresh(). + //$this->_em->refresh($user2); broken atm! + // Solution 2: Alternatively, a refresh query should work + $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); + $q->setHint(Query::HINT_REFRESH, true); + $user3 = $q->getSingleResult(); + + $this->assertSame($user, $user3); // should still be the same, always from identity map + + // Now the collection should be refreshed with correct count + $this->assertEquals(4, count($user3->getPhonenumbers())); + } + + public function testCollectionValuedAssociationIdentityMapBehaviorWithRefresh() + { + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'romanb'; + $user->name = 'Roman B.'; + + $phone1 = new CmsPhonenumber; + $phone1->phonenumber = 123; + + $phone2 = new CmsPhonenumber; + $phone2->phonenumber = 234; + + $phone3 = new CmsPhonenumber; + $phone3->phonenumber = 345; + + $user->addPhonenumber($phone1); + $user->addPhonenumber($phone2); + $user->addPhonenumber($phone3); + + $this->_em->persist($user); // cascaded to phone numbers + $this->_em->flush(); + + $this->assertEquals(3, count($user->getPhonenumbers())); + + //external update to CmsAddress + $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', array(999, $user->getId())); + + //select + $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); + $user2 = $q->getSingleResult(); + + $this->assertSame($user, $user2); + + // Should still be the same 3 phonenumbers + $this->assertEquals(3, count($user2->getPhonenumbers())); + + // But we want to have this external change! + // Solution 1: refresh(). + $this->_em->refresh($user2); + + $this->assertSame($user, $user2); // should still be the same, always from identity map + + // Now the collection should be refreshed with correct count + $this->assertEquals(4, count($user2->getPhonenumbers())); + } + + public function testReusedSplObjectHashDoesNotConfuseUnitOfWork() + { + $hash1 = $this->subRoutine($this->_em); + // Make sure cycles are collected NOW, because a PersistentCollection references + // its owner, hence without forcing gc on cycles now the object will not (yet) + // be garbage collected and thus the object hash is not reused. + // This is not a memory leak! + gc_collect_cycles(); + + $user1 = new CmsUser; + $user1->status = 'dev'; + $user1->username = 'jwage'; + $user1->name = 'Jonathan W.'; + $hash2 = spl_object_hash($user1); + $this->assertEquals($hash1, $hash2); // Hash reused! + $this->_em->persist($user1); + $this->_em->flush(); + } + + private function subRoutine($em) { + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'romanb'; + $user->name = 'Roman B.'; + $em->persist($user); + $em->flush(); + $em->remove($user); + $em->flush(); + + return spl_object_hash($user); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php new file mode 100644 index 0000000..bca4ea5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/IndexByAssociationTest.php @@ -0,0 +1,105 @@ +useModelSet('stockexchange'); + parent::setUp(); + $this->loadFixture(); + } + + public function loadFixture() + { + $this->market = new Market("Some Exchange"); + $stock1 = new Stock("AAPL", 10, $this->market); + $stock2 = new Stock("GOOG", 20, $this->market); + + $this->bond = new Bond("MyBond"); + $this->bond->addStock($stock1); + $this->bond->addStock($stock2); + + $this->_em->persist($this->market); + $this->_em->persist($stock1); + $this->_em->persist($stock2); + $this->_em->persist($this->bond); + $this->_em->flush(); + $this->_em->clear(); + } + + public function testManyToOneFinder() + { + /* @var $market Doctrine\Tests\Models\StockExchange\Market */ + $market = $this->_em->find('Doctrine\Tests\Models\StockExchange\Market', $this->market->getId()); + + $this->assertEquals(2, count($market->stocks)); + $this->assertTrue(isset($market->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); + $this->assertTrue(isset($market->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); + $this->assertEquals("AAPL", $market->stocks['AAPL']->getSymbol()); + $this->assertEquals("GOOG", $market->stocks['GOOG']->getSymbol()); + } + + public function testManyToOneDQL() + { + $dql = "SELECT m, s FROM Doctrine\Tests\Models\StockExchange\Market m JOIN m.stocks s WHERE m.id = ?1"; + $market = $this->_em->createQuery($dql)->setParameter(1, $this->market->getId())->getSingleResult(); + + $this->assertEquals(2, count($market->stocks)); + $this->assertTrue(isset($market->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); + $this->assertTrue(isset($market->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); + $this->assertEquals("AAPL", $market->stocks['AAPL']->getSymbol()); + $this->assertEquals("GOOG", $market->stocks['GOOG']->getSymbol()); + } + + public function testManyToMany() + { + $bond = $this->_em->find('Doctrine\Tests\Models\StockExchange\Bond', $this->bond->getId()); + + $this->assertEquals(2, count($bond->stocks)); + $this->assertTrue(isset($bond->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); + $this->assertTrue(isset($bond->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); + $this->assertEquals("AAPL", $bond->stocks['AAPL']->getSymbol()); + $this->assertEquals("GOOG", $bond->stocks['GOOG']->getSymbol()); + } + + public function testManytoManyDQL() + { + $dql = "SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s WHERE b.id = ?1"; + $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); + + $this->assertEquals(2, count($bond->stocks)); + $this->assertTrue(isset($bond->stocks['AAPL']), "AAPL symbol has to be key in indexed assocation."); + $this->assertTrue(isset($bond->stocks['GOOG']), "GOOG symbol has to be key in indexed assocation."); + $this->assertEquals("AAPL", $bond->stocks['AAPL']->getSymbol()); + $this->assertEquals("GOOG", $bond->stocks['GOOG']->getSymbol()); + } + + public function testDqlOverrideIndexBy() + { + $dql = "SELECT b, s FROM Doctrine\Tests\Models\StockExchange\Bond b JOIN b.stocks s INDEX BY s.id WHERE b.id = ?1"; + $bond = $this->_em->createQuery($dql)->setParameter(1, $this->bond->getId())->getSingleResult(); + + $this->assertEquals(2, count($bond->stocks)); + $this->assertFalse(isset($bond->stocks['AAPL']), "AAPL symbol not exists in re-indexed assocation."); + $this->assertFalse(isset($bond->stocks['GOOG']), "GOOG symbol not exists in re-indexed assocation."); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php new file mode 100644 index 0000000..230f562 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php @@ -0,0 +1,311 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader'), + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + + public function testPreSavePostSaveCallbacksAreInvoked() + { + $entity = new LifecycleCallbackTestEntity; + $entity->value = 'hello'; + $this->_em->persist($entity); + $this->_em->flush(); + + $this->assertTrue($entity->prePersistCallbackInvoked); + $this->assertTrue($entity->postPersistCallbackInvoked); + + $this->_em->clear(); + + $query = $this->_em->createQuery("select e from Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity e"); + $result = $query->getResult(); + $this->assertTrue($result[0]->postLoadCallbackInvoked); + + $result[0]->value = 'hello again'; + + $this->_em->flush(); + + $this->assertEquals('changed from preUpdate callback!', $result[0]->value); + } + + public function testPreFlushCallbacksAreInvoked() + { + $entity = new LifecycleCallbackTestEntity; + $entity->value = 'hello'; + $this->_em->persist($entity); + + $this->_em->flush(); + + $this->assertTrue($entity->prePersistCallbackInvoked); + $this->assertTrue($entity->preFlushCallbackInvoked); + + $entity->preFlushCallbackInvoked = false; + $this->_em->flush(); + + $this->assertTrue($entity->preFlushCallbackInvoked); + + $entity->value = 'bye'; + $entity->preFlushCallbackInvoked = false; + $this->_em->flush(); + + $this->assertTrue($entity->preFlushCallbackInvoked); + } + + public function testChangesDontGetLost() + { + $user = new LifecycleCallbackTestUser; + $user->setName('Bob'); + $user->setValue('value'); + $this->_em->persist($user); + $this->_em->flush(); + + $user->setName('Alice'); + $this->_em->flush(); // Triggers preUpdate + + $this->_em->clear(); + + $user2 = $this->_em->find(get_class($user), $user->getId()); + + $this->assertEquals('Alice', $user2->getName()); + $this->assertEquals('Hello World', $user2->getValue()); + } + + /** + * @group DDC-194 + */ + public function testGetReferenceWithPostLoadEventIsDelayedUntilProxyTrigger() + { + $entity = new LifecycleCallbackTestEntity; + $entity->value = 'hello'; + $this->_em->persist($entity); + $this->_em->flush(); + $id = $entity->getId(); + + $this->_em->clear(); + + $reference = $this->_em->getReference('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id); + $this->assertFalse($reference->postLoadCallbackInvoked); + + $reference->getValue(); // trigger proxy load + $this->assertTrue($reference->postLoadCallbackInvoked); + } + + /** + * @group DDC-958 + */ + public function testPostLoadTriggeredOnRefresh() + { + $entity = new LifecycleCallbackTestEntity; + $entity->value = 'hello'; + $this->_em->persist($entity); + $this->_em->flush(); + $id = $entity->getId(); + + $this->_em->clear(); + + $reference = $this->_em->find('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity', $id); + $this->assertTrue($reference->postLoadCallbackInvoked); + $reference->postLoadCallbackInvoked = false; + + $this->_em->refresh($reference); + $this->assertTrue($reference->postLoadCallbackInvoked, "postLoad should be invoked when refresh() is called."); + } + + /** + * @group DDC-113 + */ + public function testCascadedEntitiesCallsPrePersist() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $e1 = new LifecycleCallbackTestEntity; + $e2 = new LifecycleCallbackTestEntity; + + $c = new LifecycleCallbackCascader(); + $this->_em->persist($c); + + $c->entities[] = $e1; + $c->entities[] = $e2; + $e1->cascader = $c; + $e2->cascader = $c; + + //$this->_em->persist($c); + $this->_em->flush(); + + $this->assertTrue($e1->prePersistCallbackInvoked); + $this->assertTrue($e2->prePersistCallbackInvoked); + } + + public function testLifecycleCallbacksGetInherited() + { + $childMeta = $this->_em->getClassMetadata(__NAMESPACE__ . '\LifecycleCallbackChildEntity'); + $this->assertEquals(array('prePersist' => array(0 => 'doStuff')), $childMeta->lifecycleCallbacks); + } + + public function testLifecycleListener_ChangeUpdateChangeSet() + { + $listener = new LifecycleListenerPreUpdate; + $this->_em->getEventManager()->addEventListener(array('preUpdate'), $listener); + + $user = new LifecycleCallbackTestUser; + $user->setName('Bob'); + $user->setValue('value'); + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT u FROM Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser u WHERE u.name = 'Bob'"; + $bob = $this->_em->createQuery($dql)->getSingleResult(); + $bob->setName('Alice'); + + $this->_em->flush(); // preUpdate reverts Alice to Bob + $this->_em->clear(); + + $this->_em->getEventManager()->removeEventListener(array('preUpdate'), $listener); + + $bob = $this->_em->createQuery($dql)->getSingleResult(); + + $this->assertEquals('Bob', $bob->getName()); + } +} + +/** @Entity @HasLifecycleCallbacks */ +class LifecycleCallbackTestUser { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @Column(type="string") */ + private $value; + /** @Column(type="string") */ + private $name; + public function getId() {return $this->id;} + public function getValue() {return $this->value;} + public function setValue($value) {$this->value = $value;} + public function getName() {return $this->name;} + public function setName($name) {$this->name = $name;} + /** @PreUpdate */ + public function testCallback() {$this->value = 'Hello World';} +} + +/** + * @Entity + * @HasLifecycleCallbacks + * @Table(name="lc_cb_test_entity") + */ +class LifecycleCallbackTestEntity +{ + /* test stuff */ + public $prePersistCallbackInvoked = false; + public $postPersistCallbackInvoked = false; + public $postLoadCallbackInvoked = false; + + public $preFlushCallbackInvoked = false; + + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + /** + * @Column(type="string", nullable=true) + */ + public $value; + + /** + * @ManyToOne(targetEntity="LifecycleCallbackCascader") + * @JoinColumn(name="cascader_id", referencedColumnName="id") + */ + public $cascader; + + public function getId() { + return $this->id; + } + + public function getValue() { + return $this->value; + } + + /** @PrePersist */ + public function doStuffOnPrePersist() { + $this->prePersistCallbackInvoked = true; + } + + /** @PostPersist */ + public function doStuffOnPostPersist() { + $this->postPersistCallbackInvoked = true; + } + + /** @PostLoad */ + public function doStuffOnPostLoad() { + $this->postLoadCallbackInvoked = true; + } + + /** @PreUpdate */ + public function doStuffOnPreUpdate() { + $this->value = 'changed from preUpdate callback!'; + } + + /** @PreFlush */ + public function doStuffOnPreFlush() { + $this->preFlushCallbackInvoked = true; + } +} + +/** + * @Entity + * @Table(name="lc_cb_test_cascade") + */ +class LifecycleCallbackCascader +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @OneToMany(targetEntity="LifecycleCallbackTestEntity", mappedBy="cascader", cascade={"persist"}) + */ + public $entities; + + public function __construct() + { + $this->entities = new \Doctrine\Common\Collections\ArrayCollection(); + } +} + +/** @MappedSuperclass @HasLifecycleCallbacks */ +class LifecycleCallbackParentEntity { + /** @PrePersist */ + function doStuff() { + + } +} + +/** @Entity @Table(name="lc_cb_childentity") */ +class LifecycleCallbackChildEntity extends LifecycleCallbackParentEntity { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; +} + +class LifecycleListenerPreUpdate +{ + public function preUpdate(PreUpdateEventArgs $eventArgs) + { + $eventArgs->setNewValue('name', 'Bob'); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php new file mode 100644 index 0000000..a67a44d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php @@ -0,0 +1,180 @@ +markTestSkipped('pecl/gearman is required for this test to run.'); + } + + $this->useModelSet('cms'); + parent::setUp(); + $this->tasks = array(); + + $this->gearman = new \GearmanClient(); + $this->gearman->addServer(); + $this->gearman->setCompleteCallback(array($this, "gearmanTaskCompleted")); + + $article = new CmsArticle(); + $article->text = "my article"; + $article->topic = "Hello"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->articleId = $article->id; + } + + public function gearmanTaskCompleted($task) + { + $this->maxRunTime = max($this->maxRunTime, $task->data()); + } + + public function testFindWithLock() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + + $this->assertLockWorked(); + } + + public function testFindWithWriteThenReadLock() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); + + $this->assertLockWorked(); + } + + public function testFindWithReadThenWriteLock() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + + $this->assertLockWorked(); + } + + public function testFindWithOneLock() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::NONE); + + $this->assertLockDoesNotBlock(); + } + + public function testDqlWithLock() + { + $this->asyncDqlWithLock('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a', array(), LockMode::PESSIMISTIC_WRITE); + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + + $this->assertLockWorked(); + } + + public function testLock() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + + $this->assertLockWorked(); + } + + public function testLock2() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); + + $this->assertLockWorked(); + } + + public function testLock3() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_READ); + $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + + $this->assertLockWorked(); + } + + public function testLock4() + { + $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::NONE); + $this->asyncLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); + + $this->assertLockDoesNotBlock(); + } + + protected function assertLockDoesNotBlock() + { + $this->assertLockWorked($onlyForSeconds = 1); + } + + protected function assertLockWorked($forTime = 2, $notLongerThan = null) + { + if ($notLongerThan === null) { + $notLongerThan = $forTime + 1; + } + + $this->gearman->runTasks(); + + $this->assertTrue($this->maxRunTime > $forTime, + "Because of locking this tests should have run at least " . $forTime . " seconds, ". + "but only did for " . $this->maxRunTime . " seconds."); + $this->assertTrue($this->maxRunTime < $notLongerThan, + "The longest task should not run longer than " . $notLongerThan . " seconds, ". + "but did for " . $this->maxRunTime . " seconds." + ); + } + + protected function asyncFindWithLock($entityName, $entityId, $lockMode) + { + $this->startJob('findWithLock', array( + 'entityName' => $entityName, + 'entityId' => $entityId, + 'lockMode' => $lockMode, + )); + } + + protected function asyncDqlWithLock($dql, $params, $lockMode) + { + $this->startJob('dqlWithLock', array( + 'dql' => $dql, + 'dqlParams' => $params, + 'lockMode' => $lockMode, + )); + } + + protected function asyncLock($entityName, $entityId, $lockMode) + { + $this->startJob('lock', array( + 'entityName' => $entityName, + 'entityId' => $entityId, + 'lockMode' => $lockMode, + )); + } + + protected function startJob($fn, $fixture) + { + $this->gearman->addTask($fn, serialize(array( + 'conn' => $this->_em->getConnection()->getParams(), + 'fixture' => $fixture + ))); + + $this->assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php new file mode 100644 index 0000000..146f2db --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php @@ -0,0 +1,112 @@ +addServer(); + $worker->addFunction("findWithLock", array($lockAgent, "findWithLock")); + $worker->addFunction("dqlWithLock", array($lockAgent, "dqlWithLock")); + $worker->addFunction('lock', array($lockAgent, 'lock')); + + while($worker->work()) { + if ($worker->returnCode() != GEARMAN_SUCCESS) { + echo "return_code: " . $worker->returnCode() . "\n"; + break; + } + } + } + + protected function process($job, \Closure $do) + { + $fixture = $this->processWorkload($job); + + $s = microtime(true); + $this->em->beginTransaction(); + $do($fixture, $this->em); + + sleep(1); + $this->em->rollback(); + $this->em->clear(); + $this->em->close(); + $this->em->getConnection()->close(); + + return (microtime(true) - $s); + } + + public function findWithLock($job) + { + return $this->process($job, function($fixture, $em) { + $entity = $em->find($fixture['entityName'], $fixture['entityId'], $fixture['lockMode']); + }); + } + + public function dqlWithLock($job) + { + return $this->process($job, function($fixture, $em) { + /* @var $query Doctrine\ORM\Query */ + $query = $em->createQuery($fixture['dql']); + $query->setLockMode($fixture['lockMode']); + $query->setParameters($fixture['dqlParams']); + $result = $query->getResult(); + }); + } + + public function lock($job) + { + return $this->process($job, function($fixture, $em) { + $entity = $em->find($fixture['entityName'], $fixture['entityId']); + $em->lock($entity, $fixture['lockMode']); + }); + } + + protected function processWorkload($job) + { + echo "Received job: " . $job->handle() . " for function " . $job->functionName() . "\n"; + + $workload = $job->workload(); + $workload = unserialize($workload); + + if (!isset($workload['conn']) || !is_array($workload['conn'])) { + throw new \InvalidArgumentException("Missing Database parameters"); + } + + $this->em = $this->createEntityManager($workload['conn']); + + if (!isset($workload['fixture'])) { + throw new \InvalidArgumentException("Missing Fixture parameters"); + } + return $workload['fixture']; + } + + protected function createEntityManager($conn) + { + $config = new \Doctrine\ORM\Configuration(); + $config->setProxyDir(__DIR__ . '/../../../Proxies'); + $config->setProxyNamespace('MyProject\Proxies'); + $config->setAutoGenerateProxyClasses(true); + + $annotDriver = $config->newDefaultAnnotationDriver(array(__DIR__ . '/../../../Models/')); + $config->setMetadataDriverImpl($annotDriver); + + $cache = new \Doctrine\Common\Cache\ArrayCache(); + $config->setMetadataCacheImpl($cache); + $config->setQueryCacheImpl($cache); + $config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); + + $em = \Doctrine\ORM\EntityManager::create($conn, $config); + + return $em; + } +} + +LockAgentWorker::run(); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php new file mode 100644 index 0000000..2155809 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php @@ -0,0 +1,184 @@ +useModelSet('cms'); + parent::setUp(); + $this->handles = array(); + } + + /** + * @group DDC-178 + * @group locking + */ + public function testLockVersionedEntity() { + $article = new CmsArticle(); + $article->text = "my article"; + $article->topic = "Hello"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version); + } + + /** + * @group DDC-178 + * @group locking + */ + public function testLockVersionedEntity_MissmatchThrowsException() { + $article = new CmsArticle(); + $article->text = "my article"; + $article->topic = "Hello"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); + $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); + } + + /** + * @group DDC-178 + * @group locking + */ + public function testLockUnversionedEntity_ThrowsException() { + $user = new CmsUser(); + $user->name = "foo"; + $user->status = "active"; + $user->username = "foo"; + + $this->_em->persist($user); + $this->_em->flush(); + + $this->setExpectedException('Doctrine\ORM\OptimisticLockException'); + $this->_em->lock($user, LockMode::OPTIMISTIC); + } + + /** + * @group DDC-178 + * @group locking + */ + public function testLockUnmanagedEntity_ThrowsException() { + $article = new CmsArticle(); + + $this->setExpectedException('InvalidArgumentException', 'Entity Doctrine\Tests\Models\CMS\CmsArticle'); + $this->_em->lock($article, LockMode::OPTIMISTIC, $article->version + 1); + } + + /** + * @group DDC-178 + * @group locking + */ + public function testLockPessimisticRead_NoTransaction_ThrowsException() { + $article = new CmsArticle(); + $article->text = "my article"; + $article->topic = "Hello"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + $this->_em->lock($article, LockMode::PESSIMISTIC_READ); + } + + /** + * @group DDC-178 + * @group locking + */ + public function testLockPessimisticWrite_NoTransaction_ThrowsException() { + $article = new CmsArticle(); + $article->text = "my article"; + $article->topic = "Hello"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->setExpectedException('Doctrine\ORM\TransactionRequiredException'); + $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); + } + + /** + * @group DDC-178 + * @group locking + */ + public function testLockPessimisticWrite() { + $writeLockSql = $this->_em->getConnection()->getDatabasePlatform()->getWriteLockSql(); + if (strlen($writeLockSql) == 0) { + $this->markTestSkipped('Database Driver has no Write Lock support.'); + } + + $article = new CmsArticle(); + $article->text = "my article"; + $article->topic = "Hello"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->_em->beginTransaction(); + try { + $this->_em->lock($article, LockMode::PESSIMISTIC_WRITE); + $this->_em->commit(); + } catch (\Exception $e) { + $this->_em->rollback(); + throw $e; + } + + $query = array_pop( $this->_sqlLoggerStack->queries ); + $this->assertContains($writeLockSql, $query['sql']); + } + + /** + * @group DDC-178 + */ + public function testLockPessimisticRead() { + $readLockSql = $this->_em->getConnection()->getDatabasePlatform()->getReadLockSql(); + if (strlen($readLockSql) == 0) { + $this->markTestSkipped('Database Driver has no Write Lock support.'); + } + + $article = new CmsArticle(); + $article->text = "my article"; + $article->topic = "Hello"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->_em->beginTransaction(); + try { + $this->_em->lock($article, LockMode::PESSIMISTIC_READ); + $this->_em->commit(); + } catch (\Exception $e) { + $this->_em->rollback(); + throw $e; + } + + $query = array_pop( $this->_sqlLoggerStack->queries ); + $this->assertContains($readLockSql, $query['sql']); + } + + /** + * @group DDC-1693 + */ + public function testLockOptimisticNonVersionedThrowsExceptionInDQL() + { + $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.'); + $sql = $this->_em->createQuery($dql)->setHint( + \Doctrine\ORM\Query::HINT_LOCK_MODE, \Doctrine\DBAL\LockMode::OPTIMISTIC + )->getSQL(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php new file mode 100644 index 0000000..e2341a1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php @@ -0,0 +1,277 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + $this->_conn = $this->_em->getConnection(); + } + + public function testJoinedChildInsertSetsInitialVersionValue() + { + $test = new OptimisticJoinedChild(); + $test->name = 'child'; + $test->whatever = 'whatever'; + $this->_em->persist($test); + $this->_em->flush(); + + $this->assertEquals(1, $test->version); + + return $test; + } + + /** + * @depends testJoinedChildInsertSetsInitialVersionValue + */ + public function testJoinedChildFailureThrowsException(OptimisticJoinedChild $child) + { + $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild t WHERE t.id = :id'); + $q->setParameter('id', $child->id); + $test = $q->getSingleResult(); + + // Manually update/increment the version so we can try and save the same + // $test and make sure the exception is thrown saying the record was + // changed or updated since you read it + $this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id)); + + // Now lets change a property and try and save it again + $test->whatever = 'ok'; + try { + $this->_em->flush(); + } catch (OptimisticLockException $e) { + $this->assertSame($test, $e->getEntity()); + } + } + + public function testJoinedParentInsertSetsInitialVersionValue() + { + $test = new OptimisticJoinedParent(); + $test->name = 'parent'; + $this->_em->persist($test); + $this->_em->flush(); + + $this->assertEquals(1, $test->version); + + return $test; + } + + /** + * @depends testJoinedParentInsertSetsInitialVersionValue + */ + public function testJoinedParentFailureThrowsException(OptimisticJoinedParent $parent) + { + $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent t WHERE t.id = :id'); + $q->setParameter('id', $parent->id); + $test = $q->getSingleResult(); + + // Manually update/increment the version so we can try and save the same + // $test and make sure the exception is thrown saying the record was + // changed or updated since you read it + $this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id)); + + // Now lets change a property and try and save it again + $test->name = 'WHATT???'; + try { + $this->_em->flush(); + } catch (OptimisticLockException $e) { + $this->assertSame($test, $e->getEntity()); + } + } + + public function testMultipleFlushesDoIncrementalUpdates() + { + $test = new OptimisticStandard(); + + for ($i = 0; $i < 5; $i++) { + $test->name = 'test' . $i; + $this->_em->persist($test); + $this->_em->flush(); + + $this->assertInternalType('int', $test->getVersion()); + $this->assertEquals($i + 1, $test->getVersion()); + } + } + + public function testStandardInsertSetsInitialVersionValue() + { + $test = new OptimisticStandard(); + $test->name = 'test'; + $this->_em->persist($test); + $this->_em->flush(); + + $this->assertInternalType('int', $test->getVersion()); + $this->assertEquals(1, $test->getVersion()); + + return $test; + } + + /** + * @depends testStandardInsertSetsInitialVersionValue + */ + public function testStandardFailureThrowsException(OptimisticStandard $entity) + { + $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard t WHERE t.id = :id'); + $q->setParameter('id', $entity->id); + $test = $q->getSingleResult(); + + // Manually update/increment the version so we can try and save the same + // $test and make sure the exception is thrown saying the record was + // changed or updated since you read it + $this->_conn->executeQuery('UPDATE optimistic_standard SET version = ? WHERE id = ?', array(2, $test->id)); + + // Now lets change a property and try and save it again + $test->name = 'WHATT???'; + try { + $this->_em->flush(); + } catch (OptimisticLockException $e) { + $this->assertSame($test, $e->getEntity()); + } + } + + public function testOptimisticTimestampSetsDefaultValue() + { + $test = new OptimisticTimestamp(); + $test->name = 'Testing'; + + $this->assertNull($test->version, "Pre-Condition"); + + $this->_em->persist($test); + $this->_em->flush(); + + $this->assertInstanceOf('DateTime', $test->version); + + return $test; + } + + /** + * @depends testOptimisticTimestampSetsDefaultValue + */ + public function testOptimisticTimestampFailureThrowsException(OptimisticTimestamp $entity) + { + $q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp t WHERE t.id = :id'); + $q->setParameter('id', $entity->id); + $test = $q->getSingleResult(); + + $this->assertInstanceOf('DateTime', $test->version); + + // Manually increment the version datetime column + $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); + $this->_conn->executeQuery('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', array(date($format, strtotime($test->version->format($format)) + 3600), $test->id)); + + // Try and update the record and it should throw an exception + $test->name = 'Testing again'; + try { + $this->_em->flush(); + } catch (OptimisticLockException $e) { + $this->assertSame($test, $e->getEntity()); + } + } +} + +/** + * @Entity + * @Table(name="optimistic_joined_parent") + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"parent" = "OptimisticJoinedParent", "child" = "OptimisticJoinedChild"}) + */ +class OptimisticJoinedParent +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column(type="string", length=255) + */ + public $name; + + /** + * @Version @Column(type="integer") + */ + public $version; +} + +/** + * @Entity + * @Table(name="optimistic_joined_child") + */ +class OptimisticJoinedChild extends OptimisticJoinedParent +{ + /** + * @Column(type="string", length=255) + */ + public $whatever; +} + +/** + * @Entity + * @Table(name="optimistic_standard") + */ +class OptimisticStandard +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column(type="string", length=255) + */ + public $name; + + /** + * @Version @Column(type="integer") + */ + private $version; + + function getVersion() {return $this->version;} +} + +/** + * @Entity + * @Table(name="optimistic_timestamp") + */ +class OptimisticTimestamp +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column(type="string", length=255) + */ + public $name; + + /** + * @Version @Column(type="datetime") + */ + public $version; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php new file mode 100644 index 0000000..1e1df9d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBasicAssociationTest.php @@ -0,0 +1,380 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testUnsetManyToMany() + { + $user = $this->addCmsUserGblancoWithGroups(1); + + unset($user->groups[0]->users[0]); // inverse side + unset($user->groups[0]); // owning side! + + $this->_em->flush(); + + // Check that the link in the association table has been deleted + $this->assertGblancoGroupCountIs(0); + } + + public function testBasicManyToManyJoin() + { + $user = $this->addCmsUserGblancoWithGroups(1); + $this->_em->clear(); + + $this->assertEquals(0, $this->_em->getUnitOfWork()->size()); + + $query = $this->_em->createQuery("select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g"); + + $result = $query->getResult(); + + $this->assertEquals(2, $this->_em->getUnitOfWork()->size()); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + $this->assertEquals('Guilherme', $result[0]->name); + $this->assertEquals(1, $result[0]->getGroups()->count()); + $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->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups[0]->getUsers()); + + $groups[0]->getUsers()->clear(); + $groups->clear(); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u, g from Doctrine\Tests\Models\CMS\CmsUser u join u.groups g"); + $this->assertEquals(0, count($query->getResult())); + } + + public function testManyToManyAddRemove() + { + $user = $this->addCmsUserGblancoWithGroups(2); + $this->_em->clear(); + + $uRep = $this->_em->getRepository(get_class($user)); + + // Get user + $user = $uRep->findOneById($user->getId()); + + $this->assertNotNull($user, "Has to return exactly one entry."); + + $this->assertFalse($user->getGroups()->isInitialized()); + + // Check groups + $this->assertEquals(2, $user->getGroups()->count()); + + $this->assertTrue($user->getGroups()->isInitialized()); + + // Remove first group + unset($user->groups[0]); + //$user->getGroups()->remove(0); + + $this->_em->flush(); + $this->_em->clear(); + + // Reload same user + $user2 = $uRep->findOneById($user->getId()); + + // Check groups + $this->assertEquals(1, $user2->getGroups()->count()); + } + + public function testManyToManyInverseSideIgnored() + { + $user = $this->addCmsUserGblancoWithGroups(0); + + $group = new CmsGroup; + $group->name = 'Humans'; + + // modify directly, addUser() would also (properly) set the owning side + $group->users[] = $user; + + $this->_em->persist($user); + $this->_em->persist($group); + $this->_em->flush(); + $this->_em->clear(); + + // Association should not exist + $user2 = $this->_em->find(get_class($user), $user->getId()); + + $this->assertNotNull($user2, "Has to return exactly one entry."); + $this->assertEquals(0, $user2->getGroups()->count()); + } + + public function testManyToManyCollectionClearing() + { + $user = $this->addCmsUserGblancoWithGroups($groupCount = 10); + + // Check that there are indeed 10 links in the association table + $this->assertGblancoGroupCountIs($groupCount); + + $user->groups->clear(); + + $this->_em->flush(); + + // Check that the links in the association table have been deleted + $this->assertGblancoGroupCountIs(0); + } + + public function testManyToManyCollectionClearAndAdd() + { + $user = $this->addCmsUserGblancoWithGroups($groupCount = 10); + + $groups = $user->groups->toArray(); + $user->groups->clear(); + + foreach ($groups AS $group) { + $user->groups[] = $group; + } + + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups); + $this->assertTrue($user->groups->isDirty()); + + $this->assertEquals($groupCount, count($user->groups), "There should be 10 groups in the collection."); + + $this->_em->flush(); + + $this->assertGblancoGroupCountIs($groupCount); + } + + /** + * @param int $expectedGroupCount + */ + public function assertGblancoGroupCountIs($expectedGroupCount) + { + $countDql = "SELECT count(g.id) FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g WHERE u.username = 'gblanco'"; + $this->assertEquals( + $expectedGroupCount, + $this->_em->createQuery($countDql)->getSingleScalarResult(), + "Failed to verify that CmsUser with username 'gblanco' has a group count of 10 with a DQL count query." + ); + } + + public function testRetrieveManyToManyAndAddMore() + { + $user = $this->addCmsUserGblancoWithGroups(2); + + $group = new CmsGroup(); + $group->name = 'Developers_Fresh'; + $this->_em->persist($group); + $this->_em->flush(); + + $this->_em->clear(); + + /* @var $freshUser CmsUser */ + $freshUser = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); + $newGroup = new CmsGroup(); + $newGroup->setName('12Monkeys'); + $freshUser->addGroup($newGroup); + + $this->assertFalse($freshUser->groups->isInitialized(), "CmsUser::groups Collection has to be uninitialized for this test."); + + $this->_em->flush(); + + $this->assertFalse($freshUser->groups->isInitialized(), "CmsUser::groups Collection has to be uninitialized for this test."); + $this->assertEquals(3, count($freshUser->getGroups())); + $this->assertEquals(3, count($freshUser->getGroups()->getSnapshot()), "Snapshot of CmsUser::groups should contain 3 entries."); + + $this->_em->clear(); + + $freshUser = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->getId()); + $this->assertEquals(3, count($freshUser->getGroups())); + } + + /** + * @group DDC-130 + */ + public function testRemoveUserWithManyGroups() + { + $user = $this->addCmsUserGblancoWithGroups(2); + $userId = $user->getId(); + + $this->_em->remove($user); + $this->_em->flush(); + + $newUser = $this->_em->find(get_class($user), $userId); + $this->assertNull($newUser); + } + + /** + * @group DDC-130 + */ + public function testRemoveGroupWithUser() + { + $user = $this->addCmsUserGblancoWithGroups(2); + + foreach ($user->getGroups() AS $group) { + $this->_em->remove($group); + } + $this->_em->flush(); + $this->_em->clear(); + + $newUser = $this->_em->find(get_class($user), $user->getId()); + $this->assertEquals(0, count($newUser->getGroups())); + } + + public function testDereferenceCollectionDelete() + { + $user = $this->addCmsUserGblancoWithGroups(2); + $user->groups = null; + + $this->_em->flush(); + $this->_em->clear(); + + $newUser = $this->_em->find(get_class($user), $user->getId()); + $this->assertEquals(0, count($newUser->getGroups())); + } + + /** + * @group DDC-839 + */ + public function testWorkWithDqlHydratedEmptyCollection() + { + $user = $this->addCmsUserGblancoWithGroups(0); + $group = new CmsGroup(); + $group->name = "Developers0"; + $this->_em->persist($group); + + $this->_em->flush(); + $this->_em->clear(); + + $newUser = $this->_em->createQuery('SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.groups g WHERE u.id = ?1') + ->setParameter(1, $user->getId()) + ->getSingleResult(); + $this->assertEquals(0, count($newUser->groups)); + $this->assertInternalType('array', $newUser->groups->getMapping()); + + $newUser->addGroup($group); + + $this->_em->flush(); + $this->_em->clear(); + + $newUser = $this->_em->find(get_class($user), $user->getId()); + $this->assertEquals(1, count($newUser->groups)); + } + + /** + * @param int $groupCount + * @return CmsUser + */ + public function addCmsUserGblancoWithGroups($groupCount = 1) + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + for ($i=0; $i < $groupCount; ++$i) { + $group = new CmsGroup; + $group->name = 'Developers_' . $i; + $user->addGroup($group); + } + + $this->_em->persist($user); + $this->_em->flush(); + + $this->assertNotNull($user->getId(), "User 'gblanco' should have an ID assigned after the persist()/flush() operation."); + + return $user; + } + + /** + * @group DDC-980 + */ + public function testUpdateDeleteSizeSubselectQueries() + { + $this->_em->createQuery("DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) = 10")->execute(); + $this->_em->createQuery("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = 'inactive' WHERE SIZE(u.groups) = 10")->execute(); + } + + /** + * @group DDC-978 + */ + public function testClearAndResetCollection() + { + $user = $this->addCmsUserGblancoWithGroups(2); + $group1 = new CmsGroup; + $group1->name = 'Developers_New1'; + $group2 = new CmsGroup; + $group2->name = 'Developers_New2'; + + $this->_em->persist($group1); + $this->_em->persist($group2); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find(get_class($user), $user->id); + + $coll = new ArrayCollection(array($group1, $group2)); + $user->groups = $coll; + $this->_em->flush(); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups, + "UnitOfWork should have replaced ArrayCollection with PersistentCollection."); + $this->_em->flush(); + + $this->_em->clear(); + + $user = $this->_em->find(get_class($user), $user->id); + $this->assertEquals(2, count($user->groups)); + $this->assertEquals('Developers_New1', $user->groups[0]->name); + $this->assertEquals('Developers_New2', $user->groups[1]->name); + } + + /** + * @group DDC-733 + */ + public function testInitializePersistentCollection() + { + $user = $this->addCmsUserGblancoWithGroups(2); + $this->_em->clear(); + + $user = $this->_em->find(get_class($user), $user->id); + + $this->assertFalse($user->groups->isInitialized(), "Pre-condition: lazy collection"); + $this->_em->getUnitOfWork()->initializeObject($user->groups); + $this->assertTrue($user->groups->isInitialized(), "Collection should be initialized after calling UnitOfWork::initializeObject()"); + } + + /** + * @group DDC-1189 + * @group DDC-956 + */ + public function testClearBeforeLazyLoad() + { + $user = $this->addCmsUserGblancoWithGroups(4); + + $this->_em->clear(); + + $user = $this->_em->find(get_class($user), $user->id); + $user->groups->clear(); + $this->assertEquals(0, count($user->groups)); + + $this->_em->flush(); + + $user = $this->_em->find(get_class($user), $user->id); + $this->assertEquals(0, count($user->groups)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php new file mode 100644 index 0000000..cfe9f1e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php @@ -0,0 +1,202 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->firstProduct = new ECommerceProduct(); + $this->firstProduct->setName("First Product"); + $this->secondProduct = new ECommerceProduct(); + $this->secondProduct->setName("Second Product"); + $this->firstCategory = new ECommerceCategory(); + $this->firstCategory->setName("Business"); + $this->secondCategory = new ECommerceCategory(); + $this->secondCategory->setName("Home"); + } + + public function testSavesAManyToManyAssociationWithCascadeSaveSet() + { + $this->firstProduct->addCategory($this->firstCategory); + $this->firstProduct->addCategory($this->secondCategory); + $this->_em->persist($this->firstProduct); + $this->_em->flush(); + + $this->assertForeignKeysContain($this->firstProduct->getId(), $this->firstCategory->getId()); + $this->assertForeignKeysContain($this->firstProduct->getId(), $this->secondCategory->getId()); + } + + public function testRemovesAManyToManyAssociation() + { + $this->firstProduct->addCategory($this->firstCategory); + $this->firstProduct->addCategory($this->secondCategory); + $this->_em->persist($this->firstProduct); + $this->firstProduct->removeCategory($this->firstCategory); + + $this->_em->flush(); + + $this->assertForeignKeysNotContain($this->firstProduct->getId(), $this->firstCategory->getId()); + $this->assertForeignKeysContain($this->firstProduct->getId(), $this->secondCategory->getId()); + + $this->firstProduct->getCategories()->remove(1); + $this->_em->flush(); + + $this->assertForeignKeysNotContain($this->firstProduct->getId(), $this->secondCategory->getId()); + } + + public function testEagerLoadFromInverseSideAndLazyLoadFromOwningSide() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_createLoadingFixture(); + $categories = $this->_findCategories(); + $this->assertLazyLoadFromOwningSide($categories); + } + + public function testEagerLoadFromOwningSideAndLazyLoadFromInverseSide() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_createLoadingFixture(); + $products = $this->_findProducts(); + $this->assertLazyLoadFromInverseSide($products); + } + + private function _createLoadingFixture() + { + $this->firstProduct->addCategory($this->firstCategory); + $this->firstProduct->addCategory($this->secondCategory); + $this->secondProduct->addCategory($this->firstCategory); + $this->secondProduct->addCategory($this->secondCategory); + $this->_em->persist($this->firstProduct); + $this->_em->persist($this->secondProduct); + + $this->_em->flush(); + $this->_em->clear(); + } + + protected function _findProducts() + { + $query = $this->_em->createQuery('SELECT p, c FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.categories c ORDER BY p.id, c.id'); + //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $result = $query->getResult(); + $this->assertEquals(2, count($result)); + $cats1 = $result[0]->getCategories(); + $cats2 = $result[1]->getCategories(); + $this->assertTrue($cats1->isInitialized()); + $this->assertTrue($cats2->isInitialized()); + $this->assertFalse($cats1[0]->getProducts()->isInitialized()); + $this->assertFalse($cats2[0]->getProducts()->isInitialized()); + + return $result; + } + + protected function _findCategories() + { + $query = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\ECommerce\ECommerceCategory c LEFT JOIN c.products p ORDER BY c.id, p.id'); + //$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $result = $query->getResult(); + $this->assertEquals(2, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[1]); + $prods1 = $result[0]->getProducts(); + $prods2 = $result[1]->getProducts(); + $this->assertTrue($prods1->isInitialized()); + $this->assertTrue($prods2->isInitialized()); + + $this->assertFalse($prods1[0]->getCategories()->isInitialized()); + $this->assertFalse($prods2[0]->getCategories()->isInitialized()); + + return $result; + } + + public function assertLazyLoadFromInverseSide($products) + { + list ($firstProduct, $secondProduct) = $products; + + $firstProductCategories = $firstProduct->getCategories(); + $secondProductCategories = $secondProduct->getCategories(); + + $this->assertEquals(2, count($firstProductCategories)); + $this->assertEquals(2, count($secondProductCategories)); + + $this->assertTrue($firstProductCategories[0] === $secondProductCategories[0]); + $this->assertTrue($firstProductCategories[1] === $secondProductCategories[1]); + + $firstCategoryProducts = $firstProductCategories[0]->getProducts(); + $secondCategoryProducts = $firstProductCategories[1]->getProducts(); + + $this->assertFalse($firstCategoryProducts->isInitialized()); + $this->assertFalse($secondCategoryProducts->isInitialized()); + $this->assertEquals(0, $firstCategoryProducts->unwrap()->count()); + $this->assertEquals(0, $secondCategoryProducts->unwrap()->count()); + + $this->assertEquals(2, count($firstCategoryProducts)); // lazy-load + $this->assertTrue($firstCategoryProducts->isInitialized()); + $this->assertFalse($secondCategoryProducts->isInitialized()); + $this->assertEquals(2, count($secondCategoryProducts)); // lazy-load + $this->assertTrue($secondCategoryProducts->isInitialized()); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[1]); + + $this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts); + } + + public function assertLazyLoadFromOwningSide($categories) + { + list ($firstCategory, $secondCategory) = $categories; + + $firstCategoryProducts = $firstCategory->getProducts(); + $secondCategoryProducts = $secondCategory->getProducts(); + + $this->assertEquals(2, count($firstCategoryProducts)); + $this->assertEquals(2, count($secondCategoryProducts)); + + $this->assertTrue($firstCategoryProducts[0] === $secondCategoryProducts[0]); + $this->assertTrue($firstCategoryProducts[1] === $secondCategoryProducts[1]); + + $firstProductCategories = $firstCategoryProducts[0]->getCategories(); + $secondProductCategories = $firstCategoryProducts[1]->getCategories(); + + $this->assertFalse($firstProductCategories->isInitialized()); + $this->assertFalse($secondProductCategories->isInitialized()); + $this->assertEquals(0, $firstProductCategories->unwrap()->count()); + $this->assertEquals(0, $secondProductCategories->unwrap()->count()); + + $this->assertEquals(2, count($firstProductCategories)); // lazy-load + $this->assertTrue($firstProductCategories->isInitialized()); + $this->assertFalse($secondProductCategories->isInitialized()); + $this->assertEquals(2, count($secondProductCategories)); // lazy-load + $this->assertTrue($secondProductCategories->isInitialized()); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[1]); + + $this->assertCollectionEquals($firstProductCategories, $secondProductCategories); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php new file mode 100644 index 0000000..47c96b1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyEventTest.php @@ -0,0 +1,76 @@ + + */ +class ManyToManyEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + /** + * @var PostUpdateListener + */ + private $listener; + + protected function setUp() + { + $this->useModelSet('cms'); + parent::setUp(); + $this->listener = new PostUpdateListener(); + $evm = $this->_em->getEventManager(); + $evm->addEventListener(Events::postUpdate, $this->listener); + } + + public function testListenerShouldBeNotifiedOnlyWhenUpdating() + { + $user = $this->createNewValidUser(); + $this->_em->persist($user); + $this->_em->flush(); + $this->assertFalse($this->listener->wasNotified); + + $group = new CmsGroup(); + $group->name = "admins"; + $user->addGroup($group); + $this->_em->persist($user); + $this->_em->flush(); + + $this->assertTrue($this->listener->wasNotified); + } + + /** + * @return CmsUser + */ + private function createNewValidUser() + { + $user = new CmsUser(); + $user->username = 'fran6co'; + $user->name = 'Francisco Facioni'; + $group = new CmsGroup(); + $group->name = "users"; + $user->addGroup($group); + return $user; + } +} + +class PostUpdateListener +{ + /** + * @var bool + */ + public $wasNotified = false; + + /** + * @param $args + */ + public function postUpdate($args) + { + $this->wasNotified = true; + } +} + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php new file mode 100644 index 0000000..40518e0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php @@ -0,0 +1,124 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->firstProduct = new ECommerceProduct(); + $this->secondProduct = new ECommerceProduct(); + $this->firstRelated = new ECommerceProduct(); + $this->firstRelated->setName("Business"); + $this->secondRelated = new ECommerceProduct(); + $this->secondRelated->setName("Home"); + } + + public function testSavesAManyToManyAssociationWithCascadeSaveSet() + { + $this->firstProduct->addRelated($this->firstRelated); + $this->firstProduct->addRelated($this->secondRelated); + $this->_em->persist($this->firstProduct); + $this->_em->flush(); + + $this->assertForeignKeysContain($this->firstProduct->getId(), + $this->firstRelated->getId()); + $this->assertForeignKeysContain($this->firstProduct->getId(), + $this->secondRelated->getId()); + } + + public function testRemovesAManyToManyAssociation() + { + $this->firstProduct->addRelated($this->firstRelated); + $this->firstProduct->addRelated($this->secondRelated); + $this->_em->persist($this->firstProduct); + $this->firstProduct->removeRelated($this->firstRelated); + + $this->_em->flush(); + + $this->assertForeignKeysNotContain($this->firstProduct->getId(), + $this->firstRelated->getId()); + $this->assertForeignKeysContain($this->firstProduct->getId(), + $this->secondRelated->getId()); + } + + public function testEagerLoadsOwningSide() + { + $this->_createLoadingFixture(); + $products = $this->_findProducts(); + $this->assertLoadingOfOwningSide($products); + } + + public function testLazyLoadsOwningSide() + { + $this->_createLoadingFixture(); + + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); + $metadata->associationMappings['related']['fetch'] = ClassMetadata::FETCH_LAZY; + + $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); + $products = $query->getResult(); + $this->assertLoadingOfOwningSide($products); + } + + public function assertLoadingOfOwningSide($products) + { + list ($firstProduct, $secondProduct) = $products; + $this->assertEquals(2, count($firstProduct->getRelated())); + $this->assertEquals(2, count($secondProduct->getRelated())); + + $categories = $firstProduct->getRelated(); + $firstRelatedBy = $categories[0]->getRelated(); + $secondRelatedBy = $categories[1]->getRelated(); + + $this->assertEquals(2, count($firstRelatedBy)); + $this->assertEquals(2, count($secondRelatedBy)); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[1]); + + $this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy); + } + + protected function _createLoadingFixture() + { + $this->firstProduct->addRelated($this->firstRelated); + $this->firstProduct->addRelated($this->secondRelated); + $this->secondProduct->addRelated($this->firstRelated); + $this->secondProduct->addRelated($this->secondRelated); + $this->_em->persist($this->firstProduct); + $this->_em->persist($this->secondProduct); + + $this->_em->flush(); + $this->_em->clear(); + } + + protected function _findProducts() + { + $query = $this->_em->createQuery('SELECT p, r FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p LEFT JOIN p.related r ORDER BY p.id, r.id'); + return $query->getResult(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php new file mode 100644 index 0000000..ba83d53 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php @@ -0,0 +1,108 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->firstProduct = new ECommerceProduct(); + $this->firstProduct->setName('Doctrine 1.x Manual'); + $this->secondProduct = new ECommerceProduct(); + $this->secondProduct->setName('Doctrine 2.x Manual'); + $this->firstCart = new ECommerceCart(); + $this->secondCart = new ECommerceCart(); + } + + public function testSavesAManyToManyAssociationWithCascadeSaveSet() + { + $this->firstCart->addProduct($this->firstProduct); + $this->firstCart->addProduct($this->secondProduct); + $this->_em->persist($this->firstCart); + $this->_em->flush(); + + $this->assertForeignKeysContain($this->firstCart->getId(), $this->firstProduct->getId()); + $this->assertForeignKeysContain($this->firstCart->getId(), $this->secondProduct->getId()); + } + + public function testRemovesAManyToManyAssociation() + { + $this->firstCart->addProduct($this->firstProduct); + $this->firstCart->addProduct($this->secondProduct); + $this->_em->persist($this->firstCart); + $this->firstCart->removeProduct($this->firstProduct); + + $this->_em->flush(); + + $this->assertForeignKeysNotContain($this->firstCart->getId(), $this->firstProduct->getId()); + $this->assertForeignKeysContain($this->firstCart->getId(), $this->secondProduct->getId()); + } + + public function testEagerLoad() + { + $this->_createFixture(); + + $query = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\ECommerce\ECommerceCart c LEFT JOIN c.products p ORDER BY c.id, p.id'); + $result = $query->getResult(); + $firstCart = $result[0]; + $products = $firstCart->getProducts(); + $secondCart = $result[1]; + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]); + $this->assertCollectionEquals($products, $secondCart->getProducts()); + //$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName()); + //$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName()); + } + + public function testLazyLoadsCollection() + { + $this->_createFixture(); + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); + $metadata->associationMappings['products']['fetch'] = ClassMetadata::FETCH_LAZY; + + $query = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\ECommerce\ECommerceCart c'); + $result = $query->getResult(); + $firstCart = $result[0]; + $products = $firstCart->getProducts(); + $secondCart = $result[1]; + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]); + $this->assertCollectionEquals($products, $secondCart->getProducts()); + } + + private function _createFixture() + { + $this->firstCart->addProduct($this->firstProduct); + $this->firstCart->addProduct($this->secondProduct); + $this->secondCart->addProduct($this->firstProduct); + $this->secondCart->addProduct($this->secondProduct); + $this->_em->persist($this->firstCart); + $this->_em->persist($this->secondCart); + + $this->_em->flush(); + $this->_em->clear(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php new file mode 100644 index 0000000..f4439b9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/MappedSuperclassTest.php @@ -0,0 +1,47 @@ +useModelSet('directorytree'); + parent::setUp(); + } + + public function testCRUD() + { + $root = new \Doctrine\Tests\Models\DirectoryTree\Directory(); + $root->setName('Root'); + $root->setPath('/root'); + + $directory = new \Doctrine\Tests\Models\DirectoryTree\Directory($root); + $directory->setName('TestA'); + $directory->setPath('/root/dir'); + + $file = new \Doctrine\Tests\Models\DirectoryTree\File($directory); + $file->setName('test-b.html'); + + $this->_em->persist($root); + $this->_em->persist($directory); + $this->_em->persist($file); + + $this->_em->flush(); + $this->_em->clear(); + + $cleanFile = $this->_em->find(get_class($file), $file->getId()); + + $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cleanFile->getParent()); + $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId()); + $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent()); + $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php new file mode 100644 index 0000000..eb46329 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php @@ -0,0 +1,333 @@ +useModelSet('cms'); + parent::setUp(); + $this->platform = $this->_em->getConnection()->getDatabasePlatform(); + } + + public function testBasicNativeQuery() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); + + $query = $this->_em->createNativeQuery('SELECT id, name FROM cms_users WHERE username = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); + $this->assertEquals('Roman', $users[0]->name); + } + + public function testBasicNativeQueryWithMetaResult() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + + $addr = new CmsAddress; + $addr->country = 'germany'; + $addr->zip = 10827; + $addr->city = 'Berlin'; + + + $user->setAddress($addr); + + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('id'), 'id'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city'); + $rsm->addMetaResult('a', $this->platform->getSQLResultCasing('user_id'), 'user_id'); + + $query = $this->_em->createNativeQuery('SELECT a.id, a.country, a.zip, a.city, a.user_id FROM cms_addresses a WHERE a.id = ?', $rsm); + $query->setParameter(1, $addr->id); + + $addresses = $query->getResult(); + + $this->assertEquals(1, count($addresses)); + $this->assertTrue($addresses[0] instanceof CmsAddress); + $this->assertEquals($addr->country, $addresses[0]->country); + $this->assertEquals($addr->zip, $addresses[0]->zip); + $this->assertEquals($addr->city, $addresses[0]->city); + $this->assertEquals($addr->street, $addresses[0]->street); + $this->assertTrue($addresses[0]->user instanceof CmsUser); + } + + public function testJoinedOneToManyNativeQuery() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + + $phone = new CmsPhonenumber; + $phone->phonenumber = 424242; + + $user->addPhonenumber($phone); + + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status'); + $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); + $rsm->addFieldResult('p', $this->platform->getSQLResultCasing('phonenumber'), 'phonenumber'); + + $query = $this->_em->createNativeQuery('SELECT id, name, status, phonenumber FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); + $this->assertEquals('Roman', $users[0]->name); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); + $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); + $this->assertEquals(1, count($users[0]->getPhonenumbers())); + $phones = $users[0]->getPhonenumbers(); + $this->assertEquals(424242, $phones[0]->phonenumber); + $this->assertTrue($phones[0]->getUser() === $users[0]); + + } + + public function testJoinedOneToOneNativeQuery() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + + $addr = new CmsAddress; + $addr->country = 'germany'; + $addr->zip = 10827; + $addr->city = 'Berlin'; + + + $user->setAddress($addr); + + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + + + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('name'), 'name'); + $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('status'), 'status'); + $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('a_id'), 'id'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip'); + $rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city'); + + $query = $this->_em->createNativeQuery('SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); + $this->assertEquals('Roman', $users[0]->name); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); + $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress()); + $this->assertTrue($users[0]->getAddress()->getUser() == $users[0]); + $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); + $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); + $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); + } + + public function testFluentInterface() + { + $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) + ->setResultSetMapping($rsm) + ->expireResultCache(true) + ->setHint('foo', 'bar') + ->setParameter(1, 'foo') + ->setParameters(array(2 => 'bar')) + ->setResultCacheDriver(null) + ->setResultCacheLifetime(3500); + + $this->assertSame($q, $q2); + } + + public function testJoinedOneToManyNativeQueryWithRSMBuilder() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + + $phone = new CmsPhonenumber; + $phone->phonenumber = 424242; + + $user->addPhonenumber($phone); + + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + + $rsm = new ResultSetMappingBuilder($this->_em); + $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); + $query = $this->_em->createNativeQuery('SELECT u.*, p.* FROM cms_users u LEFT JOIN cms_phonenumbers p ON u.id = p.user_id WHERE username = ?', $rsm); + $query->setParameter(1, 'romanb'); + + $users = $query->getResult(); + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); + $this->assertEquals('Roman', $users[0]->name); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); + $this->assertTrue($users[0]->getPhonenumbers()->isInitialized()); + $this->assertEquals(1, count($users[0]->getPhonenumbers())); + $phones = $users[0]->getPhonenumbers(); + $this->assertEquals(424242, $phones[0]->phonenumber); + $this->assertTrue($phones[0]->getUser() === $users[0]); + + $this->_em->clear(); + + $rsm = new ResultSetMappingBuilder($this->_em); + $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p'); + $query = $this->_em->createNativeQuery('SELECT p.* FROM cms_phonenumbers p WHERE p.phonenumber = ?', $rsm); + $query->setParameter(1, $phone->phonenumber); + $phone = $query->getSingleResult(); + + $this->assertNotNull($phone->getUser()); + $this->assertEquals($user->name, $phone->getUser()->getName()); + } + + public function testJoinedOneToOneNativeQueryWithRSMBuilder() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + + $addr = new CmsAddress; + $addr->country = 'germany'; + $addr->zip = 10827; + $addr->city = 'Berlin'; + + + $user->setAddress($addr); + + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + + + $rsm = new ResultSetMappingBuilder($this->_em); + $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address', array('id' => 'a_id')); + + $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'); + + $users = $query->getResult(); + + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); + $this->assertEquals('Roman', $users[0]->name); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers()); + $this->assertFalse($users[0]->getPhonenumbers()->isInitialized()); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress()); + $this->assertTrue($users[0]->getAddress()->getUser() == $users[0]); + $this->assertEquals('germany', $users[0]->getAddress()->getCountry()); + $this->assertEquals(10827, $users[0]->getAddress()->getZipCode()); + $this->assertEquals('Berlin', $users[0]->getAddress()->getCity()); + + $this->_em->clear(); + + $rsm = new ResultSetMappingBuilder($this->_em); + $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a'); + $query = $this->_em->createNativeQuery('SELECT a.* FROM cms_addresses a WHERE a.id = ?', $rsm); + $query->setParameter(1, $addr->getId()); + $address = $query->getSingleResult(); + + $this->assertNotNull($address->getUser()); + $this->assertEquals($user->name, $address->getUser()->getName()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testRSMBuilderThrowsExceptionOnColumnConflict() + { + $rsm = new ResultSetMappingBuilder($this->_em); + $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address'); + } + + /** + * @group PR-39 + */ + public function testUnknownParentAliasThrowsException() + { + $rsm = new ResultSetMappingBuilder($this->_em); + $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'un', 'address', array('id' => 'a_id')); + + $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'." + ); + $users = $query->getResult(); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php new file mode 100644 index 0000000..069e11c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/NotifyPolicyTest.php @@ -0,0 +1,173 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyUser'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyGroup') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + + public function testChangeTracking() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $user = new NotifyUser(); + $group = new NotifyGroup(); + $user->setName('roman'); + $group->setName('dev'); + + $user->getGroups()->add($group); + $group->getUsers()->add($user); + + $this->_em->persist($user); + $this->_em->persist($group); + + $this->assertEquals(1, count($user->listeners)); + $this->assertEquals(1, count($group->listeners)); + + $this->_em->flush(); + $this->_em->clear(); + + $this->assertEquals(1, count($user->listeners)); + $this->assertEquals(1, count($group->listeners)); + + $userId = $user->getId(); + $groupId = $group->getId(); + unset($user, $group); + + $user = $this->_em->find(__NAMESPACE__.'\NotifyUser', $userId); + $this->assertEquals(1, $user->getGroups()->count()); + $group = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $groupId); + $this->assertEquals(1, $group->getUsers()->count()); + + $this->assertEquals(1, count($user->listeners)); + $this->assertEquals(1, count($group->listeners)); + + $group2 = new NotifyGroup(); + $group2->setName('nerds'); + $this->_em->persist($group2); + $user->getGroups()->add($group2); + $group2->getUsers()->add($user); + + $group->setName('geeks'); + + $this->_em->flush(); + $this->_em->clear(); + + $this->assertEquals(1, count($user->listeners)); + $this->assertEquals(1, count($group->listeners)); + + $group2Id = $group2->getId(); + unset($group2, $user); + + $user = $this->_em->find(__NAMESPACE__.'\NotifyUser', $userId); + $this->assertEquals(2, $user->getGroups()->count()); + $group2 = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $group2Id); + $this->assertEquals(1, $group2->getUsers()->count()); + $group = $this->_em->find(__NAMESPACE__.'\NotifyGroup', $groupId); + $this->assertEquals(1, $group->getUsers()->count()); + $this->assertEquals('geeks', $group->getName()); + } +} + +class NotifyBaseEntity implements NotifyPropertyChanged { + public $listeners = array(); + + public function addPropertyChangedListener(PropertyChangedListener $listener) { + $this->listeners[] = $listener; + } + + protected function onPropertyChanged($propName, $oldValue, $newValue) { + if ($this->listeners) { + foreach ($this->listeners as $listener) { + $listener->propertyChanged($this, $propName, $oldValue, $newValue); + } + } + } +} + +/** @Entity @ChangeTrackingPolicy("NOTIFY") */ +class NotifyUser extends NotifyBaseEntity { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + + /** @Column */ + private $name; + + /** @ManyToMany(targetEntity="NotifyGroup") */ + private $groups; + + function __construct() { + $this->groups = new ArrayCollection; + } + + function getId() { + return $this->id; + } + + function getName() { + return $this->name; + } + + function setName($name) { + $this->onPropertyChanged('name', $this->name, $name); + $this->name = $name; + } + + function getGroups() { + return $this->groups; + } +} + +/** @Entity */ +class NotifyGroup extends NotifyBaseEntity { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + + /** @Column */ + private $name; + + /** @ManyToMany(targetEntity="NotifyUser", mappedBy="groups") */ + private $users; + + function __construct() { + $this->users = new ArrayCollection; + } + + function getId() { + return $this->id; + } + + function getName() { + return $this->name; + } + + function setName($name) { + $this->onPropertyChanged('name', $this->name, $name); + $this->name = $name; + } + + function getUsers() { + return $this->users; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php new file mode 100644 index 0000000..a9258da --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php @@ -0,0 +1,171 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->product = new ECommerceProduct(); + $this->product->setName('Doctrine Cookbook'); + $this->firstFeature = new ECommerceFeature(); + $this->firstFeature->setDescription('Model writing tutorial'); + $this->secondFeature = new ECommerceFeature(); + $this->secondFeature->setDescription('Annotations examples'); + } + + public function testSavesAOneToManyAssociationWithCascadeSaveSet() { + $this->product->addFeature($this->firstFeature); + $this->product->addFeature($this->secondFeature); + $this->_em->persist($this->product); + $this->_em->flush(); + + $this->assertFeatureForeignKeyIs($this->product->getId(), $this->firstFeature); + $this->assertFeatureForeignKeyIs($this->product->getId(), $this->secondFeature); + } + + public function testSavesAnEmptyCollection() + { + $this->_em->persist($this->product); + $this->_em->flush(); + + $this->assertEquals(0, count($this->product->getFeatures())); + } + + public function testDoesNotSaveAnInverseSideSet() { + $this->product->brokenAddFeature($this->firstFeature); + $this->_em->persist($this->product); + $this->_em->flush(); + + $this->assertFeatureForeignKeyIs(null, $this->firstFeature); + } + + public function testRemovesOneToOneAssociation() + { + $this->product->addFeature($this->firstFeature); + $this->product->addFeature($this->secondFeature); + $this->_em->persist($this->product); + + $this->product->removeFeature($this->firstFeature); + $this->_em->flush(); + + $this->assertFeatureForeignKeyIs(null, $this->firstFeature); + $this->assertFeatureForeignKeyIs($this->product->getId(), $this->secondFeature); + } + + public function testEagerLoadsOneToManyAssociation() + { + $this->_createFixture(); + $query = $this->_em->createQuery('select p, f from Doctrine\Tests\Models\ECommerce\ECommerceProduct p join p.features f'); + $result = $query->getResult(); + $product = $result[0]; + + $features = $product->getFeatures(); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[0]->getProduct()); + $this->assertSame($product, $features[0]->getProduct()); + $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]); + $this->assertSame($product, $features[1]->getProduct()); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[1]->getProduct()); + $this->assertEquals('Annotations examples', $features[1]->getDescription()); + } + + public function testLazyLoadsObjectsOnTheOwningSide() + { + $this->_createFixture(); + + $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); + $result = $query->getResult(); + $product = $result[0]; + $features = $product->getFeatures(); + + $this->assertFalse($features->isInitialized()); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]); + $this->assertTrue($features->isInitialized()); + $this->assertSame($product, $features[0]->getProduct()); + $this->assertEquals('Model writing tutorial', $features[0]->getDescription()); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]); + $this->assertSame($product, $features[1]->getProduct()); + $this->assertEquals('Annotations examples', $features[1]->getDescription()); + } + + public function testLazyLoadsObjectsOnTheInverseSide() + { + $this->_createFixture(); + + $query = $this->_em->createQuery('select f from Doctrine\Tests\Models\ECommerce\ECommerceFeature f'); + $features = $query->getResult(); + + $product = $features[0]->getProduct(); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $product); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product); + $this->assertFalse($product->__isInitialized__); + $this->assertSame('Doctrine Cookbook', $product->getName()); + $this->assertTrue($product->__isInitialized__); + } + + public function testLazyLoadsObjectsOnTheInverseSide2() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_createFixture(); + + $query = $this->_em->createQuery('select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p'); + $features = $query->getResult(); + + $product = $features[0]->getProduct(); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $product); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product); + $this->assertSame('Doctrine Cookbook', $product->getName()); + + $this->assertFalse($product->getFeatures()->isInitialized()); + + // This would trigger lazy-load + //$this->assertEquals(2, $product->getFeatures()->count()); + //$this->assertTrue($product->getFeatures()->contains($features[0])); + //$this->assertTrue($product->getFeatures()->contains($features[1])); + + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(null); + } + + public function testJoinFromOwningSide() + { + $query = $this->_em->createQuery('select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p'); + $features = $query->getResult(); + $this->assertEquals(0, count($features)); + } + + private function _createFixture() + { + $this->product->addFeature($this->firstFeature); + $this->product->addFeature($this->secondFeature); + $this->_em->persist($this->product); + + $this->_em->flush(); + $this->_em->clear(); + } + + public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature) { + $foreignKey = $this->_em->getConnection()->executeQuery( + 'SELECT product_id FROM ecommerce_features WHERE id=?', + array($feature->getId()) + )->fetchColumn(); + $this->assertEquals($value, $foreignKey); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php new file mode 100644 index 0000000..28101cc --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyOrphanRemovalTest.php @@ -0,0 +1,75 @@ +useModelSet('cms'); + + parent::setUp(); + + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'romanb'; + $user->name = 'Roman B.'; + + $phone = new CmsPhonenumber; + $phone->phonenumber = '123456'; + + $user->addPhonenumber($phone); + + $this->_em->persist($user); + $this->_em->flush(); + + $this->userId = $user->getId(); + $this->_em->clear(); + } + + public function testOrphanRemoval() + { + $userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $this->_em->remove($userProxy); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); + + $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + } + + /** + * @group DDC-1496 + */ + public function testOrphanRemovalUnitializedCollection() + { + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $user->phonenumbers->clear(); + $this->_em->flush(); + + $query = $this->_em->createQuery('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsPhonenumber should be removed by orphanRemoval'); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php new file mode 100644 index 0000000..d162171 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php @@ -0,0 +1,123 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->parent = new ECommerceCategory(); + $this->parent->setName('Programming languages books'); + $this->firstChild = new ECommerceCategory(); + $this->firstChild->setName('Java books'); + $this->secondChild = new ECommerceCategory(); + $this->secondChild->setName('Php books'); + } + + public function testSavesAOneToManyAssociationWithCascadeSaveSet() { + $this->parent->addChild($this->firstChild); + $this->parent->addChild($this->secondChild); + $this->_em->persist($this->parent); + + $this->_em->flush(); + + $this->assertForeignKeyIs($this->parent->getId(), $this->firstChild); + $this->assertForeignKeyIs($this->parent->getId(), $this->secondChild); + } + + public function testSavesAnEmptyCollection() + { + $this->_em->persist($this->parent); + $this->_em->flush(); + + $this->assertEquals(0, count($this->parent->getChildren())); + } + + public function testDoesNotSaveAnInverseSideSet() { + $this->parent->brokenAddChild($this->firstChild); + $this->_em->persist($this->parent); + $this->_em->flush(); + + $this->assertForeignKeyIs(null, $this->firstChild); + } + + public function testRemovesOneToManyAssociation() + { + $this->parent->addChild($this->firstChild); + $this->parent->addChild($this->secondChild); + $this->_em->persist($this->parent); + + $this->parent->removeChild($this->firstChild); + $this->_em->flush(); + + $this->assertForeignKeyIs(null, $this->firstChild); + $this->assertForeignKeyIs($this->parent->getId(), $this->secondChild); + } + + public function testEagerLoadsOneToManyAssociation() + { + $this->_createFixture(); + + $query = $this->_em->createQuery('select c1, c2 from Doctrine\Tests\Models\ECommerce\ECommerceCategory c1 join c1.children c2'); + $result = $query->getResult(); + $this->assertEquals(1, count($result)); + $parent = $result[0]; + $children = $parent->getChildren(); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]); + $this->assertSame($parent, $children[0]->getParent()); + $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]); + $this->assertSame($parent, $children[1]->getParent()); + $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); + } + + public function testLazyLoadsOneToManyAssociation() + { + $this->_createFixture(); + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCategory'); + $metadata->associationMappings['children']['fetch'] = ClassMetadata::FETCH_LAZY; + + $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCategory c order by c.id asc'); + $result = $query->getResult(); + $parent = $result[0]; + $children = $parent->getChildren(); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]); + $this->assertSame($parent, $children[0]->getParent()); + $this->assertEquals(' books', strstr($children[0]->getName(), ' books')); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]); + $this->assertSame($parent, $children[1]->getParent()); + $this->assertEquals(' books', strstr($children[1]->getName(), ' books')); + } + + private function _createFixture() + { + $this->parent->addChild($this->firstChild); + $this->parent->addChild($this->secondChild); + $this->_em->persist($this->parent); + + $this->_em->flush(); + $this->_em->clear(); + } + + public function assertForeignKeyIs($value, ECommerceCategory $child) { + $foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', array($child->getId()))->fetchColumn(); + $this->assertEquals($value, $foreignKey); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php new file mode 100644 index 0000000..42fd292 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToManyUnidirectionalAssociationTest.php @@ -0,0 +1,86 @@ +useModelSet('routing'); + parent::setUp(); + + $locations = array("Berlin", "Bonn", "Brasilia", "Atlanta"); + + foreach ($locations AS $locationName) { + $location = new RoutingLocation(); + $location->name = $locationName; + $this->_em->persist($location); + $this->locations[$locationName] = $location; + } + $this->_em->flush(); + } + + public function testPersistOwning_InverseCascade() + { + $leg = new RoutingLeg(); + $leg->fromLocation = $this->locations['Berlin']; + $leg->toLocation = $this->locations['Bonn']; + $leg->departureDate = new \DateTime("now"); + $leg->arrivalDate = new \DateTime("now +5 hours"); + + $route = new RoutingRoute(); + $route->legs[] = $leg; + + $this->_em->persist($route); + $this->_em->flush(); + $this->_em->clear(); + + $routes = $this->_em->createQuery( + "SELECT r, l, f, t FROM Doctrine\Tests\Models\Routing\RoutingRoute r ". + "JOIN r.legs l JOIN l.fromLocation f JOIN l.toLocation t" + )->getSingleResult(); + + $this->assertEquals(1, count($routes->legs)); + $this->assertEquals("Berlin", $routes->legs[0]->fromLocation->name); + $this->assertEquals("Bonn", $routes->legs[0]->toLocation->name); + } + + public function testLegsAreUniqueToRoutes() + { + $leg = new RoutingLeg(); + $leg->fromLocation = $this->locations['Berlin']; + $leg->toLocation = $this->locations['Bonn']; + $leg->departureDate = new \DateTime("now"); + $leg->arrivalDate = new \DateTime("now +5 hours"); + + $routeA = new RoutingRoute(); + $routeA->legs[] = $leg; + + $routeB = new RoutingRoute(); + $routeB->legs[] = $leg; + + $this->_em->persist($routeA); + $this->_em->persist($routeB); + + $exceptionThrown = false; + try { + // exception depending on the underyling Database Driver + $this->_em->flush(); + } catch(\Exception $e) { + $exceptionThrown = true; + } + + $this->assertTrue($exceptionThrown, "The underlying database driver throws an exception."); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php new file mode 100644 index 0000000..ced524c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php @@ -0,0 +1,151 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->customer = new ECommerceCustomer(); + $this->customer->setName('John Doe'); + $this->cart = new ECommerceCart(); + $this->cart->setPayment('Credit card'); + } + + public function testSavesAOneToOneAssociationWithCascadeSaveSet() { + $this->customer->setCart($this->cart); + $this->_em->persist($this->customer); + $this->_em->flush(); + + $this->assertCartForeignKeyIs($this->customer->getId()); + } + + public function testDoesNotSaveAnInverseSideSet() { + $this->customer->brokenSetCart($this->cart); + $this->_em->persist($this->customer); + $this->_em->flush(); + + $this->assertCartForeignKeyIs(null); + } + + public function testRemovesOneToOneAssociation() + { + $this->customer->setCart($this->cart); + $this->_em->persist($this->customer); + $this->customer->removeCart(); + + $this->_em->flush(); + + $this->assertCartForeignKeyIs(null); + } + + public function testEagerLoad() + { + $this->_createFixture(); + + $query = $this->_em->createQuery('select c, ca from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c join c.cart ca'); + $result = $query->getResult(); + $customer = $result[0]; + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); + $this->assertEquals('paypal', $customer->getCart()->getPayment()); + } + + public function testLazyLoadsObjectsOnTheOwningSide() { + $this->_createFixture(); + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); + $metadata->associationMappings['customer']['fetchMode'] = ClassMetadata::FETCH_LAZY; + + $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCart c'); + $result = $query->getResult(); + $cart = $result[0]; + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart->getCustomer()); + $this->assertEquals('Giorgio', $cart->getCustomer()->getName()); + } + + public function testInverseSideIsNeverLazy() + { + $this->_createFixture(); + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer'); + $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_EAGER; + + $query = $this->_em->createQuery('select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c'); + $result = $query->getResult(); + $customer = $result[0]; + + $this->assertNull($customer->getMentor()); + $this->assertInstanceOF('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart()); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getCart()); + $this->assertEquals('paypal', $customer->getCart()->getPayment()); + } + + public function testUpdateWithProxyObject() + { + $cust = new ECommerceCustomer; + $cust->setName('Roman'); + $cart = new ECommerceCart; + $cart->setPayment('CARD'); + $cust->setCart($cart); + + $this->_em->persist($cust); + $this->_em->flush(); + $this->_em->clear(); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cust->getCart()); + $this->assertEquals('Roman', $cust->getName()); + $this->assertSame($cust, $cart->getCustomer()); + + $query = $this->_em->createQuery('select ca from Doctrine\Tests\Models\ECommerce\ECommerceCart ca where ca.id =?1'); + $query->setParameter(1, $cart->getId()); + + $cart2 = $query->getSingleResult(); + + $cart2->setPayment('CHEQUE'); + + $this->_em->flush(); + $this->_em->clear(); + + $query2 = $this->_em->createQuery('select ca, c from Doctrine\Tests\Models\ECommerce\ECommerceCart ca left join ca.customer c where ca.id =?1'); + $query2->setParameter(1, $cart->getId()); + + $cart3 = $query2->getSingleResult(); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart3->getCustomer()); + $this->assertEquals('Roman', $cart3->getCustomer()->getName()); + } + + protected function _createFixture() + { + $customer = new ECommerceCustomer; + $customer->setName('Giorgio'); + $cart = new ECommerceCart; + $cart->setPayment('paypal'); + $customer->setCart($cart); + + $this->_em->persist($customer); + + $this->_em->flush(); + $this->_em->clear(); + } + + public function assertCartForeignKeyIs($value) { + $foreignKey = $this->_em->getConnection()->executeQuery('SELECT customer_id FROM ecommerce_carts WHERE id=?', array($this->cart->getId()))->fetchColumn(); + $this->assertEquals($value, $foreignKey); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php new file mode 100644 index 0000000..8c6bdf0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneEagerLoadingTest.php @@ -0,0 +1,307 @@ +_em); + try { + $schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Train'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'), + )); + } catch(\Exception $e) {} + } + + public function testEagerLoadOneToOneOwningSide() + { + $train = new Train(new TrainOwner("Alexander")); + $driver = new TrainDriver("Benjamin"); + $waggon = new Waggon(); + + $train->setDriver($driver); + $train->addWaggon($waggon); + + $this->_em->persist($train); // cascades + $this->_em->flush(); + $this->_em->clear(); + + $sqlCount = count($this->_sqlLoggerStack->queries); + + $train = $this->_em->find(get_class($train), $train->id); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $train->driver); + $this->assertEquals("Benjamin", $train->driver->name); + + $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + } + + public function testEagerLoadOneToOneNullOwningSide() + { + $train = new Train(new TrainOwner("Alexander")); + + $this->_em->persist($train); // cascades + $this->_em->flush(); + $this->_em->clear(); + + $sqlCount = count($this->_sqlLoggerStack->queries); + + $train = $this->_em->find(get_class($train), $train->id); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $train->driver); + $this->assertNull($train->driver); + + $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + } + + public function testEagerLoadOneToOneInverseSide() + { + $owner = new TrainOwner("Alexander"); + $train = new Train($owner); + + $this->_em->persist($train); // cascades + $this->_em->flush(); + $this->_em->clear(); + + $sqlCount = count($this->_sqlLoggerStack->queries); + + $driver = $this->_em->find(get_class($owner), $owner->id); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $owner->train); + $this->assertNotNull($owner->train); + + $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + } + + public function testEagerLoadOneToOneNullInverseSide() + { + $driver = new TrainDriver("Dagny Taggert"); + + $this->_em->persist($driver); + $this->_em->flush(); + $this->_em->clear(); + + $this->assertNull($driver->train); + + $sqlCount = count($this->_sqlLoggerStack->queries); + + $driver = $this->_em->find(get_class($driver), $driver->id); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $driver->train); + $this->assertNull($driver->train); + + $this->assertEquals($sqlCount + 1, count($this->_sqlLoggerStack->queries)); + } + + public function testEagerLoadManyToOne() + { + $train = new Train(new TrainOwner("Alexander")); + $waggon = new Waggon(); + $train->addWaggon($waggon); + + $this->_em->persist($train); // cascades + $this->_em->flush(); + $this->_em->clear(); + + $waggon = $this->_em->find(get_class($waggon), $waggon->id); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $waggon->train); + $this->assertNotNull($waggon->train); + } + + public function testEagerLoadWithNullableColumnsGeneratesLeftJoinOnBothSides() + { + $train = new Train(new TrainOwner("Alexander")); + $driver = new TrainDriver("Benjamin"); + $train->setDriver($driver); + + $this->_em->persist($train); + $this->_em->flush(); + $this->_em->clear(); + + $train = $this->_em->find(get_class($train), $train->id); + $this->assertSQLEquals( + "SELECT t0.id AS id1, t0.driver_id AS driver_id2, t3.id AS id4, t3.name AS name5, t0.owner_id AS owner_id6, t7.id AS id8, t7.name AS name9 FROM Train t0 LEFT JOIN TrainDriver t3 ON t0.driver_id = t3.id INNER JOIN TrainOwner t7 ON t0.owner_id = t7.id WHERE t0.id = ?", + $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] + ); + + $this->_em->clear(); + $driver = $this->_em->find(get_class($driver), $driver->id); + $this->assertSQLEquals( + "SELECT t0.id AS id1, t0.name AS name2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id IN (?)", + $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] + ); + } + + public function testEagerLoadWithNonNullableColumnsGeneratesInnerJoinOnOwningSide() + { + $waggon = new Waggon(); + + // It should have a train + $train = new Train(new TrainOwner("Alexander")); + $train->addWaggon($waggon); + + $this->_em->persist($train); + $this->_em->flush(); + $this->_em->clear(); + + $waggon = $this->_em->find(get_class($waggon), $waggon->id); + + // The last query is the eager loading of the owner of the train + $this->assertSQLEquals( + "SELECT t0.id AS id1, t0.name AS name2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id IN (?)", + $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] + ); + + // The one before is the fetching of the waggon and train + $this->assertSQLEquals( + "SELECT t0.id AS id1, t0.train_id AS train_id2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM Waggon t0 INNER JOIN Train t3 ON t0.train_id = t3.id WHERE t0.id = ?", + $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery - 1]['sql'] + ); + } + + public function testEagerLoadWithNonNullableColumnsGeneratesLeftJoinOnNonOwningSide() + { + $owner = new TrainOwner('Alexander'); + $train = new Train($owner); + $this->_em->persist($train); + $this->_em->flush(); + $this->_em->clear(); + + $waggon = $this->_em->find(get_class($owner), $owner->id); + $this->assertSQLEquals( + "SELECT t0.id AS id1, t0.name AS name2, t3.id AS id4, t3.driver_id AS driver_id5, t3.owner_id AS owner_id6 FROM TrainOwner t0 LEFT JOIN Train t3 ON t3.owner_id = t0.id WHERE t0.id = ?", + $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql'] + ); + } +} + +/** + * @Entity + */ +class Train +{ + /** + * @id @column(type="integer") @generatedValue + * @var int + */ + public $id; + /** + * Owning side + * @OneToOne(targetEntity="TrainDriver", inversedBy="train", fetch="EAGER", cascade={"persist"}) + * @JoinColumn(nullable=true) + */ + public $driver; + /** + * Owning side + * @OneToOne(targetEntity="TrainOwner", inversedBy="train", fetch="EAGER", cascade={"persist"}) + * @JoinColumn(nullable=false) + */ + public $owner; + /** + * @oneToMany(targetEntity="Waggon", mappedBy="train", cascade={"persist"}) + */ + public $waggons; + + public function __construct(TrainOwner $owner) + { + $this->waggons = new \Doctrine\Common\Collections\ArrayCollection(); + $this->setOwner($owner); + } + + public function setDriver(TrainDriver $driver) + { + $this->driver = $driver; + $driver->setTrain($this); + } + + public function setOwner(TrainOwner $owner) + { + $this->owner = $owner; + $owner->setTrain($this); + } + + public function addWaggon(Waggon $w) + { + $w->setTrain($this); + $this->waggons[] = $w; + } +} + +/** + * @Entity + */ +class TrainDriver +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @column(type="string") */ + public $name; + /** + * Inverse side + * @OneToOne(targetEntity="Train", mappedBy="driver", fetch="EAGER") + */ + public $train; + + public function __construct($name) + { + $this->name = $name; + } + + public function setTrain(Train $t) + { + $this->train = $t; + } +} + +/** + * @Entity + */ +class TrainOwner +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @column(type="string") */ + public $name; + /** + * Inverse side + * @OneToOne(targetEntity="Train", mappedBy="owner", fetch="EAGER") + */ + public $train; + + public function __construct($name) + { + $this->name = $name; + } + + public function setTrain(Train $t) + { + $this->train = $t; + } +} + +/** + * @Entity + */ +class Waggon +{ + /** @id @generatedValue @column(type="integer") */ + public $id; + /** + * @ManyToOne(targetEntity="Train", inversedBy="waggons", fetch="EAGER") + * @JoinColumn(nullable=false) + */ + public $train; + + public function setTrain($train) + { + $this->train = $train; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php new file mode 100644 index 0000000..6b3d0a2 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneOrphanRemovalTest.php @@ -0,0 +1,94 @@ +useModelSet('cms'); + + parent::setUp(); + } + + public function testOrphanRemoval() + { + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'romanb'; + $user->name = 'Roman B.'; + + $address = new CmsAddress; + $address->country = 'de'; + $address->zip = 1234; + $address->city = 'Berlin'; + + $user->setAddress($address); + + $this->_em->persist($user); + $this->_em->flush(); + + $userId = $user->getId(); + + $this->_em->clear(); + + $userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $userId); + + $this->_em->remove($userProxy); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsUser should be removed by EntityManager'); + + $query = $this->_em->createQuery('SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsAddress should be removed by orphanRemoval'); + } + + public function testOrphanRemovalWhenUnlink() + { + $user = new CmsUser; + $user->status = 'dev'; + $user->username = 'beberlei'; + $user->name = 'Bejamin Eberlei'; + + $email = new CmsEmail; + $email->email = 'beberlei@domain.com'; + + $user->setEmail($email); + + $this->_em->persist($user); + $this->_em->flush(); + + $userId = $user->getId(); + + $this->_em->clear(); + + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); + + $user->setEmail(null); + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('SELECT e FROM Doctrine\Tests\Models\CMS\CmsEmail e'); + $result = $query->getResult(); + + $this->assertEquals(0, count($result), 'CmsEmail should be removed by orphanRemoval'); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php new file mode 100644 index 0000000..326e7ae --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php @@ -0,0 +1,165 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->customer = new ECommerceCustomer(); + $this->customer->setName('Anakin Skywalker'); + $this->mentor = new ECommerceCustomer(); + $this->mentor->setName('Obi-wan Kenobi'); + } + + public function testSavesAOneToOneAssociationWithCascadeSaveSet() { + $this->customer->setMentor($this->mentor); + $this->_em->persist($this->customer); + $this->_em->flush(); + + $this->assertForeignKeyIs($this->mentor->getId()); + } + + public function testRemovesOneToOneAssociation() + { + $this->customer->setMentor($this->mentor); + $this->_em->persist($this->customer); + $this->customer->removeMentor(); + + $this->_em->flush(); + + $this->assertForeignKeyIs(null); + } + + public function testFind() + { + $id = $this->_createFixture(); + + $customer = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $id); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getMentor()); + } + + public function testEagerLoadsAssociation() + { + $this->_createFixture(); + + $query = $this->_em->createQuery('select c, m from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c left join c.mentor m order by c.id asc'); + $result = $query->getResult(); + $customer = $result[0]; + $this->assertLoadingOfAssociation($customer); + } + + /** + * @group mine + * @return unknown_type + */ + public function testLazyLoadsAssociation() + { + $this->_createFixture(); + + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCustomer'); + $metadata->associationMappings['mentor']['fetch'] = ClassMetadata::FETCH_LAZY; + + $query = $this->_em->createQuery("select c from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c where c.name='Luke Skywalker'"); + $result = $query->getResult(); + $customer = $result[0]; + $this->assertLoadingOfAssociation($customer); + } + + public function testMultiSelfReference() + { + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\MultiSelfReference') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + + $entity1 = new MultiSelfReference(); + $this->_em->persist($entity1); + $entity1->setOther1($entity2 = new MultiSelfReference); + $entity1->setOther2($entity3 = new MultiSelfReference); + $this->_em->flush(); + + $this->_em->clear(); + + $entity2 = $this->_em->find(get_class($entity1), $entity1->getId()); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther1()); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther2()); + $this->assertNull($entity2->getOther1()->getOther1()); + $this->assertNull($entity2->getOther1()->getOther2()); + $this->assertNull($entity2->getOther2()->getOther1()); + $this->assertNull($entity2->getOther2()->getOther2()); + } + + public function assertLoadingOfAssociation($customer) + { + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $customer->getMentor()); + $this->assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName()); + } + + public function assertForeignKeyIs($value) { + $foreignKey = $this->_em->getConnection()->executeQuery('SELECT mentor_id FROM ecommerce_customers WHERE id=?', array($this->customer->getId()))->fetchColumn(); + $this->assertEquals($value, $foreignKey); + } + + private function _createFixture() + { + $customer = new ECommerceCustomer; + $customer->setName('Luke Skywalker'); + $mentor = new ECommerceCustomer; + $mentor->setName('Obi-wan Kenobi'); + $customer->setMentor($mentor); + + $this->_em->persist($customer); + + $this->_em->flush(); + $this->_em->clear(); + + return $customer->getId(); + } +} + +/** + * @Entity + */ +class MultiSelfReference { + /** @Id @GeneratedValue(strategy="AUTO") @Column(type="integer") */ + private $id; + /** + * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) + * @JoinColumn(name="other1", referencedColumnName="id") + */ + private $other1; + /** + * @OneToOne(targetEntity="MultiSelfReference", cascade={"persist"}) + * @JoinColumn(name="other2", referencedColumnName="id") + */ + private $other2; + + public function getId() {return $this->id;} + public function setOther1($other1) {$this->other1 = $other1;} + public function getOther1() {return $this->other1;} + public function setOther2($other2) {$this->other2 = $other2;} + public function getOther2() {return $this->other2;} +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php new file mode 100644 index 0000000..1ffae6b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php @@ -0,0 +1,125 @@ +useModelSet('ecommerce'); + parent::setUp(); + $this->product = new ECommerceProduct(); + $this->product->setName('Doctrine 2 Manual'); + $this->shipping = new ECommerceShipping(); + $this->shipping->setDays('5'); + } + + public function testSavesAOneToOneAssociationWithCascadeSaveSet() { + $this->product->setShipping($this->shipping); + $this->_em->persist($this->product); + $this->_em->flush(); + + $this->assertForeignKeyIs($this->shipping->getId()); + } + + public function testRemovesOneToOneAssociation() + { + $this->product->setShipping($this->shipping); + $this->_em->persist($this->product); + $this->product->removeShipping(); + + $this->_em->flush(); + + $this->assertForeignKeyIs(null); + } + + public function _testEagerLoad() + { + $this->_createFixture(); + + $query = $this->_em->createQuery('select p, s from Doctrine\Tests\Models\ECommerce\ECommerceProduct p left join p.shipping s'); + $result = $query->getResult(); + $product = $result[0]; + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping()); + $this->assertEquals(1, $product->getShipping()->getDays()); + } + + public function testLazyLoadsObjects() { + $this->_createFixture(); + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); + $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; + + $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); + $result = $query->getResult(); + $product = $result[0]; + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping()); + $this->assertEquals(1, $product->getShipping()->getDays()); + } + + public function testDoesNotLazyLoadObjectsIfConfigurationDoesNotAllowIt() { + $this->_createFixture(); + + $query = $this->_em->createQuery('select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'); + $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + + $result = $query->getResult(); + $product = $result[0]; + + $this->assertNull($product->getShipping()); + } + + protected function _createFixture() + { + $product = new ECommerceProduct; + $product->setName('Php manual'); + $shipping = new ECommerceShipping; + $shipping->setDays('1'); + $product->setShipping($shipping); + + $this->_em->persist($product); + + $this->_em->flush(); + $this->_em->clear(); + } + + public function assertForeignKeyIs($value) { + $foreignKey = $this->_em->getConnection()->executeQuery( + 'SELECT shipping_id FROM ecommerce_products WHERE id=?', + array($this->product->getId()) + )->fetchColumn(); + $this->assertEquals($value, $foreignKey); + } + + /** + * @group DDC-762 + */ + public function testNullForeignKey() + { + $product = new ECommerceProduct(); + $product->setName('Doctrine 2 Manual'); + + $this->_em->persist($product); + $this->_em->flush(); + + $product = $this->_em->find(get_class($product), $product->getId()); + + $this->assertNull($product->getShipping()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php new file mode 100644 index 0000000..c2e131c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedCollectionTest.php @@ -0,0 +1,113 @@ +useModelSet('routing'); + parent::setUp(); + + $locations = array("Berlin", "Bonn", "Brasilia", "Atlanta"); + + foreach ($locations AS $locationName) { + $location = new RoutingLocation(); + $location->name = $locationName; + $this->_em->persist($location); + $this->locations[$locationName] = $location; + } + $this->_em->flush(); + } + + public function createPersistedRouteWithLegs() + { + $route = new RoutingRoute(); + + $leg1 = new RoutingLeg(); + $leg1->fromLocation = $this->locations['Berlin']; + $leg1->toLocation = $this->locations['Bonn']; + $leg1->departureDate = new \DateTime("now"); + $leg1->arrivalDate = new \DateTime("now +5 hours"); + + $leg2 = new RoutingLeg(); + $leg2->fromLocation = $this->locations['Bonn']; + $leg2->toLocation = $this->locations['Brasilia']; + $leg2->departureDate = new \DateTime("now +6 hours"); + $leg2->arrivalDate = new \DateTime("now +24 hours"); + + $route->legs[] = $leg2; + $route->legs[] = $leg1; + + $this->_em->persist($route); + $this->_em->flush(); + $routeId = $route->id; + $this->_em->clear(); + + return $routeId; + } + + public function testLazyManyToManyCollection_IsRetrievedWithOrderByClause() + { + $routeId = $this->createPersistedRouteWithLegs(); + + $route = $this->_em->find('Doctrine\Tests\Models\Routing\RoutingRoute', $routeId); + + $this->assertEquals(2, count($route->legs)); + $this->assertEquals("Berlin", $route->legs[0]->fromLocation->getName()); + $this->assertEquals("Bonn", $route->legs[1]->fromLocation->getName()); + } + + public function testLazyOneToManyCollection_IsRetrievedWithOrderByClause() + { + $route = new RoutingRoute(); + + $this->_em->persist($route); + $this->_em->flush(); + $routeId = $route->id; + + $booking1 = new RoutingRouteBooking(); + $booking1->passengerName = "Guilherme"; + $booking2 = new RoutingRouteBooking(); + $booking2->passengerName = "Benjamin"; + + $route->bookings[] = $booking1; + $booking1->route = $route; + $route->bookings[] = $booking2; + $booking2->route = $route; + + $this->_em->persist($booking1); + $this->_em->persist($booking2); + + $this->_em->flush(); + $this->_em->clear(); + + $route = $this->_em->find('Doctrine\Tests\Models\Routing\RoutingRoute', $routeId); + + $this->assertEquals(2, count($route->bookings)); + $this->assertEquals('Benjamin', $route->bookings[0]->getPassengerName()); + $this->assertEquals('Guilherme', $route->bookings[1]->getPassengerName()); + } + + public function testOrderedResultFromDqlQuery() + { + $routeId = $this->createPersistedRouteWithLegs(); + + $route = $this->_em->createQuery("SELECT r, l FROM Doctrine\Tests\Models\Routing\RoutingRoute r JOIN r.legs l WHERE r.id = ?1") + ->setParameter(1, $routeId) + ->getSingleResult(); + + $this->assertEquals(2, count($route->legs)); + $this->assertEquals("Berlin", $route->legs[0]->fromLocation->getName()); + $this->assertEquals("Bonn", $route->legs[1]->fromLocation->getName()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php new file mode 100644 index 0000000..8c0d37b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/OrderedJoinedTableInheritanceCollectionTest.php @@ -0,0 +1,133 @@ + + */ +class OrderedJoinedTableInheritanceCollectionTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() { + parent::setUp(); + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Pet'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Cat'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Dog'), + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + + $dog = new OJTIC_Dog(); + $dog->name = "Poofy"; + + $dog1 = new OJTIC_Dog(); + $dog1->name = "Zampa"; + $dog2 = new OJTIC_Dog(); + $dog2->name = "Aari"; + + $dog1->mother = $dog; + $dog2->mother = $dog; + + $dog->children[] = $dog1; + $dog->children[] = $dog2; + + $this->_em->persist($dog); + $this->_em->persist($dog1); + $this->_em->persist($dog2); + $this->_em->flush(); + $this->_em->clear(); + } + + public function testOrderdOneToManyCollection() + { + $poofy = $this->_em->createQuery("SELECT p FROM Doctrine\Tests\ORM\Functional\OJTIC_Pet p WHERE p.name = 'Poofy'")->getSingleResult(); + + $this->assertEquals('Aari', $poofy->children[0]->getName()); + $this->assertEquals('Zampa', $poofy->children[1]->getName()); + + $this->_em->clear(); + + $result = $this->_em->createQuery( + "SELECT p, c FROM Doctrine\Tests\ORM\Functional\OJTIC_Pet p JOIN p.children c WHERE p.name = 'Poofy'") + ->getResult(); + + $this->assertEquals(1, count($result)); + $poofy = $result[0]; + + $this->assertEquals('Aari', $poofy->children[0]->getName()); + $this->assertEquals('Zampa', $poofy->children[1]->getName()); + } +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({ + * "cat" = "OJTIC_Cat", + * "dog" = "OJTIC_Dog"}) + */ +abstract class OJTIC_Pet +{ + /** + * @Id + * @column(type="integer") + * @generatedValue(strategy="AUTO") + */ + public $id; + + /** + * + * @Column + */ + public $name; + + /** + * @ManyToOne(targetEntity="OJTIC_PET") + */ + public $mother; + + /** + * @OneToMany(targetEntity="OJTIC_Pet", mappedBy="mother") + * @OrderBy({"name" = "ASC"}) + */ + public $children; + + /** + * @ManyToMany(targetEntity="OJTIC_Pet") + * @JoinTable(name="OTJIC_Pet_Friends", + * joinColumns={@JoinColumn(name="pet_id", referencedColumnName="id")}, + * inverseJoinColumns={@JoinColumn(name="friend_id", referencedColumnName="id")}) + * @OrderBy({"name" = "ASC"}) + */ + public $friends; + + public function getName() + { + return $this->name; + } +} + +/** + * @Entity + */ +class OJTIC_Cat extends OJTIC_Pet +{ + +} + +/** + * @Entity + */ +class OJTIC_Dog extends OJTIC_Pet +{ + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php new file mode 100644 index 0000000..9903535 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -0,0 +1,105 @@ +useModelSet('cms'); + parent::setUp(); + $this->populate(); + } + + public function testCountSimpleWithoutJoin() + { + $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; + $query = $this->_em->createQuery($dql); + + $paginator = new Paginator($query); + $this->assertEquals(3, count($paginator)); + } + + public function testCountWithFetchJoin() + { + $dql = "SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g"; + $query = $this->_em->createQuery($dql); + + $paginator = new Paginator($query); + $this->assertEquals(3, count($paginator)); + } + + public function testIterateSimpleWithoutJoinFetchJoinHandlingOff() + { + $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; + $query = $this->_em->createQuery($dql); + + $paginator = new Paginator($query, false); + + $data = array(); + foreach ($paginator as $user) { + $data[] = $user; + } + $this->assertEquals(3, count($data)); + } + + public function testIterateSimpleWithoutJoinFetchJoinHandlingOn() + { + $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; + $query = $this->_em->createQuery($dql); + + $paginator = new Paginator($query, true); + + $data = array(); + foreach ($paginator as $user) { + $data[] = $user; + } + $this->assertEquals(3, count($data)); + } + + public function testIterateWithFetchJoin() + { + $dql = "SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g"; + $query = $this->_em->createQuery($dql); + + $paginator = new Paginator($query, true); + + $data = array(); + foreach ($paginator as $user) { + $data[] = $user; + } + $this->assertEquals(3, count($data)); + } + + public function populate() + { + for ($i = 0; $i < 3; $i++) { + $user = new CmsUser(); + $user->name = "Name$i"; + $user->username = "username$i"; + $user->status = "active"; + $this->_em->persist($user); + + for ($j = 0; $j < 3; $j++) {; + $group = new CmsGroup(); + $group->name = "group$j"; + $user->addGroup($group); + $this->_em->persist($group); + } + } + $this->_em->flush(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php new file mode 100644 index 0000000..2125966 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentCollectionTest.php @@ -0,0 +1,98 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionHolder'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionContent'), + )); + } catch (\Exception $e) { + + } + PersistentObject::setObjectManager($this->_em); + } + + public function testPersist() + { + $collectionHolder = new PersistentCollectionHolder(); + $content = new PersistentCollectionContent('first element'); + $collectionHolder->addElement($content); + + $this->_em->persist($collectionHolder); + $this->_em->flush(); + $this->_em->clear(); + + $collectionHolder = $this->_em->find(__NAMESPACE__ . '\PersistentCollectionHolder', $collectionHolder->getId()); + $collectionHolder->getCollection(); + + $content = new PersistentCollectionContent('second element'); + $collectionHolder->addElement($content); + + $this->assertEquals(2, $collectionHolder->getCollection()->count()); + } + +} + +/** + * @Entity + */ +class PersistentCollectionHolder extends PersistentObject +{ + /** + * @Id @Column(type="integer") @GeneratedValue + * @var int + */ + protected $id; + + /** + * @var \Doctrine\Common\Collections\Collection + * @ManyToMany(targetEntity="PersistentCollectionContent", cascade={"all"}) + */ + protected $collection; + + public function __construct() + { + $this->collection = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * @param PersistentCollectionContent $element + */ + public function addElement(PersistentCollectionContent $element) + { + $this->collection->add($element); + } + + /** + * @return \Doctrine\Common\Collections\Collection + */ + public function getCollection() + { + return clone $this->collection; + } + +} + +/** + * @Entity + */ +class PersistentCollectionContent extends PersistentObject +{ + + /** + * @Id @Column(type="integer") @GeneratedValue + * @var int + */ + protected $id; + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php new file mode 100644 index 0000000..88e54ae --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PersistentObjectTest.php @@ -0,0 +1,105 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PersistentEntity'), + )); + } catch (\Exception $e) { + + } + PersistentObject::setObjectManager($this->_em); + } + + public function testPersist() + { + $entity = new PersistentEntity(); + $entity->setName("test"); + + $this->_em->persist($entity); + $this->_em->flush(); + } + + public function testFind() + { + $entity = new PersistentEntity(); + $entity->setName("test"); + + $this->_em->persist($entity); + $this->_em->flush(); + $this->_em->clear(); + + $entity = $this->_em->find(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); + + $this->assertEquals('test', $entity->getName()); + $entity->setName('foobar'); + + $this->_em->flush(); + } + + public function testGetReference() + { + $entity = new PersistentEntity(); + $entity->setName("test"); + + $this->_em->persist($entity); + $this->_em->flush(); + $this->_em->clear(); + + $entity = $this->_em->getReference(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); + + $this->assertEquals('test', $entity->getName()); + } + + public function testSetAssociation() + { + $entity = new PersistentEntity(); + $entity->setName("test"); + $entity->setParent($entity); + + $this->_em->persist($entity); + $this->_em->flush(); + $this->_em->clear(); + + $entity = $this->_em->getReference(__NAMESPACE__ . '\PersistentEntity', $entity->getId()); + $this->assertSame($entity, $entity->getParent()); + } +} + +/** + * @Entity + */ +class PersistentEntity extends PersistentObject +{ + /** + * @Id @Column(type="integer") @GeneratedValue + * @var int + */ + protected $id; + + /** + * @Column(type="string") + * @var string + */ + protected $name; + + /** + * @ManyToOne(targetEntity="PersistentEntity") + * @var PersistentEntity + */ + protected $parent; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php new file mode 100644 index 0000000..8198871 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostFlushEventTest.php @@ -0,0 +1,95 @@ + + */ +class PostFlushEventTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + /** + * @var PostFlushListener + */ + private $listener; + + protected function setUp() + { + $this->useModelSet('cms'); + parent::setUp(); + $this->listener = new PostFlushListener(); + $evm = $this->_em->getEventManager(); + $evm->addEventListener(Events::postFlush, $this->listener); + } + + public function testListenerShouldBeNotified() + { + $this->_em->persist($this->createNewValidUser()); + $this->_em->flush(); + $this->assertTrue($this->listener->wasNotified); + } + + public function testListenerShouldNotBeNotifiedWhenFlushThrowsException() + { + $user = new CmsUser(); + $user->username = 'dfreudenberger'; + $this->_em->persist($user); + $exceptionRaised = false; + + try { + $this->_em->flush(); + } catch (\Exception $ex) { + $exceptionRaised = true; + } + + $this->assertTrue($exceptionRaised); + $this->assertFalse($this->listener->wasNotified); + } + + public function testListenerShouldReceiveEntityManagerThroughArgs() + { + $this->_em->persist($this->createNewValidUser()); + $this->_em->flush(); + $receivedEm = $this->listener->receivedArgs->getEntityManager(); + $this->assertSame($this->_em, $receivedEm); + } + + /** + * @return CmsUser + */ + private function createNewValidUser() + { + $user = new CmsUser(); + $user->username = 'dfreudenberger'; + $user->name = 'Daniel Freudenberger'; + return $user; + } +} + +class PostFlushListener +{ + /** + * @var bool + */ + public $wasNotified = false; + + /** + * @var PostFlushEventArgs + */ + public $receivedArgs; + + /** + * @param PostFlushEventArgs $args + */ + public function postFlush(PostFlushEventArgs $args) + { + $this->wasNotified = true; + $this->receivedArgs = $args; + } +} + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostgreSQLIdentityStrategyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostgreSQLIdentityStrategyTest.php new file mode 100644 index 0000000..4ee7b7c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/PostgreSQLIdentityStrategyTest.php @@ -0,0 +1,53 @@ +_em->getConnection()->getDatabasePlatform()->getName() != 'postgresql') { + $this->markTestSkipped('This test is special to the PostgreSQL IDENTITY key generation strategy.'); + } else { + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PostgreSQLIdentityEntity'), + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + } + + protected function tearDown() { + parent::tearDown(); + // drop sequence manually due to dependency + $this->_em->getConnection()->exec('DROP SEQUENCE postgresqlidentityentity_id_seq CASCADE'); + } + + public function testPreSavePostSaveCallbacksAreInvoked() + { + $entity = new PostgreSQLIdentityEntity(); + $entity->setValue('hello'); + $this->_em->persist($entity); + $this->_em->flush(); + $this->assertTrue(is_numeric($entity->getId())); + $this->assertTrue($entity->getId() > 0); + $this->assertTrue($this->_em->contains($entity)); + } +} + +/** @Entity */ +class PostgreSQLIdentityEntity { + /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */ + private $id; + /** @Column(type="string") */ + private $value; + public function getId() {return $this->id;} + public function getValue() {return $this->value;} + public function setValue($value) {$this->value = $value;} +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php new file mode 100644 index 0000000..3707611 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php @@ -0,0 +1,151 @@ +cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); + $this->cacheDataReflection->setAccessible(true); + $this->useModelSet('cms'); + parent::setUp(); + } + + /** + * @param ArrayCache $cache + * @return integer + */ + private function getCacheSize(ArrayCache $cache) + { + return sizeof($this->cacheDataReflection->getValue($cache)); + } + + + public function testQueryCache_DependsOnHints() + { + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + + $cache = new ArrayCache(); + $query->setQueryCacheDriver($cache); + + $query->getResult(); + $this->assertEquals(1, $this->getCacheSize($cache)); + + $query->setHint('foo', 'bar'); + + $query->getResult(); + $this->assertEquals(2, $this->getCacheSize($cache)); + + return $query; + } + + /** + * @param $query + * @depends testQueryCache_DependsOnHints + */ + public function testQueryCache_DependsOnFirstResult($query) + { + $cache = $query->getQueryCacheDriver(); + $cacheCount = $this->getCacheSize($cache); + + $query->setFirstResult(10); + $query->setMaxResults(9999); + + $query->getResult(); + $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + } + + /** + * @param $query + * @depends testQueryCache_DependsOnHints + */ + public function testQueryCache_DependsOnMaxResults($query) + { + $cache = $query->getQueryCacheDriver(); + $cacheCount = $this->getCacheSize($cache); + + $query->setMaxResults(10); + + $query->getResult(); + $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + } + + /** + * @param $query + * @depends testQueryCache_DependsOnHints + */ + public function testQueryCache_DependsOnHydrationMode($query) + { + $cache = $query->getQueryCacheDriver(); + $cacheCount = $this->getCacheSize($cache); + + $query->getArrayResult(); + $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + } + + public function testQueryCache_NoHitSaveParserResult() + { + $this->_em->getConfiguration()->setQueryCacheImpl(new ArrayCache()); + + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + + $cache = $this->getMock('Doctrine\Common\Cache\ArrayCache', array('doFetch', 'doSave', 'doGetStats')); + $cache->expects($this->at(0)) + ->method('doFetch') + ->with($this->isType('string')) + ->will($this->returnValue(false)); + $cache->expects($this->at(1)) + ->method('doSave') + ->with($this->isType('string'), $this->isInstanceOf('Doctrine\ORM\Query\ParserResult'), $this->equalTo(null)); + + $query->setQueryCacheDriver($cache); + + $users = $query->getResult(); + } + + public function testQueryCache_HitDoesNotSaveParserResult() + { + $this->_em->getConfiguration()->setQueryCacheImpl(new ArrayCache()); + + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + + $sqlExecMock = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute')); + $sqlExecMock->expects($this->once()) + ->method('execute') + ->will($this->returnValue( 10 )); + + $parserResultMock = $this->getMock('Doctrine\ORM\Query\ParserResult'); + $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->expects($this->once()) + ->method('doFetch') + ->with($this->isType('string')) + ->will($this->returnValue($parserResultMock)); + $cache->expects($this->never()) + ->method('doSave'); + + $query->setQueryCacheDriver($cache); + + $users = $query->getResult(); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php new file mode 100644 index 0000000..d62c60a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -0,0 +1,401 @@ +useModelSet('company'); + parent::setUp(); + + $this->generateFixture(); + } + + public function testAggregateSum() + { + $salarySum = $this->_em->createQuery('SELECT SUM(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getSingleResult(); + + $this->assertEquals(1500000, $salarySum['salary']); + } + + public function testAggregateAvg() + { + $salaryAvg = $this->_em->createQuery('SELECT AVG(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getSingleResult(); + + $this->assertEquals(375000, round($salaryAvg['salary'], 0)); + } + + public function testAggregateMin() + { + $salary = $this->_em->createQuery('SELECT MIN(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getSingleResult(); + + $this->assertEquals(100000, $salary['salary']); + } + + public function testAggregateMax() + { + $salary = $this->_em->createQuery('SELECT MAX(m.salary) AS salary FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getSingleResult(); + + $this->assertEquals(800000, $salary['salary']); + } + + public function testAggregateCount() + { + $managerCount = $this->_em->createQuery('SELECT COUNT(m.id) AS managers FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getSingleResult(); + + $this->assertEquals(4, $managerCount['managers']); + } + + public function testFunctionAbs() + { + $result = $this->_em->createQuery('SELECT m, ABS(m.salary * -1) AS abs FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(100000, $result[0]['abs']); + $this->assertEquals(200000, $result[1]['abs']); + $this->assertEquals(400000, $result[2]['abs']); + $this->assertEquals(800000, $result[3]['abs']); + } + + public function testFunctionConcat() + { + $arg = $this->_em->createQuery('SELECT m, CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getArrayResult(); + + $this->assertEquals(4, count($arg)); + $this->assertEquals('Roman B.IT', $arg[0]['namedep']); + $this->assertEquals('Benjamin E.HR', $arg[1]['namedep']); + $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); + $this->assertEquals('Jonathan W.Administration', $arg[3]['namedep']); + } + + public function testFunctionLength() + { + $result = $this->_em->createQuery('SELECT m, LENGTH(CONCAT(m.name, m.department)) AS namedeplength FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(10, $result[0]['namedeplength']); + $this->assertEquals(13, $result[1]['namedeplength']); + $this->assertEquals(32, $result[2]['namedeplength']); + $this->assertEquals(25, $result[3]['namedeplength']); + } + + public function testFunctionLocate() + { + $dql = "SELECT m, LOCATE('e', LOWER(m.name)) AS loc, LOCATE('e', LOWER(m.name), 7) AS loc2 ". + "FROM Doctrine\Tests\Models\Company\CompanyManager m"; + + $result = $this->_em->createQuery($dql) + ->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(0, $result[0]['loc']); + $this->assertEquals(2, $result[1]['loc']); + $this->assertEquals(6, $result[2]['loc']); + $this->assertEquals(0, $result[3]['loc']); + $this->assertEquals(0, $result[0]['loc2']); + $this->assertEquals(10, $result[1]['loc2']); + $this->assertEquals(9, $result[2]['loc2']); + $this->assertEquals(0, $result[3]['loc2']); + } + + public function testFunctionLower() + { + $result = $this->_em->createQuery("SELECT m, LOWER(m.name) AS lowername FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals('roman b.', $result[0]['lowername']); + $this->assertEquals('benjamin e.', $result[1]['lowername']); + $this->assertEquals('guilherme b.', $result[2]['lowername']); + $this->assertEquals('jonathan w.', $result[3]['lowername']); + } + + public function testFunctionMod() + { + $result = $this->_em->createQuery("SELECT m, MOD(m.salary, 3500) AS amod FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(2000, $result[0]['amod']); + $this->assertEquals(500, $result[1]['amod']); + $this->assertEquals(1000, $result[2]['amod']); + $this->assertEquals(2000, $result[3]['amod']); + } + + public function testFunctionSqrt() + { + $result = $this->_em->createQuery("SELECT m, SQRT(m.salary) AS sqrtsalary FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(316, round($result[0]['sqrtsalary'])); + $this->assertEquals(447, round($result[1]['sqrtsalary'])); + $this->assertEquals(632, round($result[2]['sqrtsalary'])); + $this->assertEquals(894, round($result[3]['sqrtsalary'])); + } + + public function testFunctionUpper() + { + $result = $this->_em->createQuery("SELECT m, UPPER(m.name) AS uppername FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals('ROMAN B.', $result[0]['uppername']); + $this->assertEquals('BENJAMIN E.', $result[1]['uppername']); + $this->assertEquals('GUILHERME B.', $result[2]['uppername']); + $this->assertEquals('JONATHAN W.', $result[3]['uppername']); + } + + public function testFunctionSubstring() + { + $dql = "SELECT m, SUBSTRING(m.name, 1, 3) AS str1, SUBSTRING(m.name, 5) AS str2 ". + "FROM Doctrine\Tests\Models\Company\CompanyManager m"; + + $result = $this->_em->createQuery($dql) + ->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals('Rom', $result[0]['str1']); + $this->assertEquals('Ben', $result[1]['str1']); + $this->assertEquals('Gui', $result[2]['str1']); + $this->assertEquals('Jon', $result[3]['str1']); + $this->assertEquals('n B.', $result[0]['str2']); + $this->assertEquals('amin E.', $result[1]['str2']); + $this->assertEquals('herme B.', $result[2]['str2']); + $this->assertEquals('than W.', $result[3]['str2']); + } + + public function testFunctionTrim() + { + $dql = "SELECT m, TRIM(TRAILING '.' FROM m.name) AS str1, ". + " TRIM(LEADING '.' FROM m.name) AS str2, TRIM(CONCAT(' ', CONCAT(m.name, ' '))) AS str3 ". + "FROM Doctrine\Tests\Models\Company\CompanyManager m"; + + $result = $this->_em->createQuery($dql)->getArrayResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals('Roman B', $result[0]['str1']); + $this->assertEquals('Benjamin E', $result[1]['str1']); + $this->assertEquals('Guilherme B', $result[2]['str1']); + $this->assertEquals('Jonathan W', $result[3]['str1']); + $this->assertEquals('Roman B.', $result[0]['str2']); + $this->assertEquals('Benjamin E.', $result[1]['str2']); + $this->assertEquals('Guilherme B.', $result[2]['str2']); + $this->assertEquals('Jonathan W.', $result[3]['str2']); + $this->assertEquals('Roman B.', $result[0]['str3']); + $this->assertEquals('Benjamin E.', $result[1]['str3']); + $this->assertEquals('Guilherme B.', $result[2]['str3']); + $this->assertEquals('Jonathan W.', $result[3]['str3']); + } + + public function testOperatorAdd() + { + $result = $this->_em->createQuery('SELECT m, m.salary+2500 AS add FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(102500, $result[0]['add']); + $this->assertEquals(202500, $result[1]['add']); + $this->assertEquals(402500, $result[2]['add']); + $this->assertEquals(802500, $result[3]['add']); + } + + public function testOperatorSub() + { + $result = $this->_em->createQuery('SELECT m, m.salary-2500 AS sub FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(97500, $result[0]['sub']); + $this->assertEquals(197500, $result[1]['sub']); + $this->assertEquals(397500, $result[2]['sub']); + $this->assertEquals(797500, $result[3]['sub']); + } + + public function testOperatorMultiply() + { + $result = $this->_em->createQuery('SELECT m, m.salary*2 AS op FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(200000, $result[0]['op']); + $this->assertEquals(400000, $result[1]['op']); + $this->assertEquals(800000, $result[2]['op']); + $this->assertEquals(1600000, $result[3]['op']); + } + + /** + * @group test + */ + public function testOperatorDiv() + { + $result = $this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(200000, $result[0]['op']); + $this->assertEquals(400000, $result[1]['op']); + $this->assertEquals(800000, $result[2]['op']); + $this->assertEquals(1600000, $result[3]['op']); + } + + public function testConcatFunction() + { + $arg = $this->_em->createQuery('SELECT CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m order by namedep desc') + ->getArrayResult(); + + $this->assertEquals(4, count($arg)); + $this->assertEquals('Roman B.IT', $arg[0]['namedep']); + $this->assertEquals('Jonathan W.Administration', $arg[1]['namedep']); + $this->assertEquals('Guilherme B.Complaint Department', $arg[2]['namedep']); + $this->assertEquals('Benjamin E.HR', $arg[3]['namedep']); + } + + /** + * @group DDC-1014 + */ + public function testDateDiff() + { + $query = $this->_em->createQuery("SELECT DATE_DIFF(CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day')) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); + $arg = $query->getArrayResult(); + + $this->assertEquals(-10, $arg[0]['diff'], "Should be roughly -10 (or -9)", 1); + + $query = $this->_em->createQuery("SELECT DATE_DIFF(DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day'), CURRENT_TIMESTAMP()) AS diff FROM Doctrine\Tests\Models\Company\CompanyManager m"); + $arg = $query->getArrayResult(); + + $this->assertEquals(10, $arg[0]['diff'], "Should be roughly 10 (or 9)", 1); + } + + /** + * @group DDC-1014 + */ + public function testDateAdd() + { + $arg = $this->_em->createQuery("SELECT DATE_ADD(CURRENT_TIMESTAMP(), 10, 'day') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertTrue(strtotime($arg[0]['add']) > 0); + + $arg = $this->_em->createQuery("SELECT DATE_ADD(CURRENT_TIMESTAMP(), 10, 'month') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertTrue(strtotime($arg[0]['add']) > 0); + } + + /** + * @group DDC-1014 + */ + public function testDateSub() + { + $arg = $this->_em->createQuery("SELECT DATE_SUB(CURRENT_TIMESTAMP(), 10, 'day') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertTrue(strtotime($arg[0]['add']) > 0); + + $arg = $this->_em->createQuery("SELECT DATE_SUB(CURRENT_TIMESTAMP(), 10, 'month') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") + ->getArrayResult(); + + $this->assertTrue(strtotime($arg[0]['add']) > 0); + } + + /** + * @group DDC-1213 + */ + public function testBitOrComparison() + { + $dql = 'SELECT m, ' . + 'BIT_OR(4, 2) AS bit_or,' . + 'BIT_OR( (m.salary/100000) , 2 ) AS salary_bit_or ' . + 'FROM Doctrine\Tests\Models\Company\CompanyManager m ' . + 'ORDER BY ' . + 'm.id ' ; + $result = $this->_em->createQuery($dql)->getArrayResult(); + + $this->assertEquals(4 | 2, $result[0]['bit_or']); + $this->assertEquals(4 | 2, $result[1]['bit_or']); + $this->assertEquals(4 | 2, $result[2]['bit_or']); + $this->assertEquals(4 | 2, $result[3]['bit_or']); + + $this->assertEquals(($result[0][0]['salary']/100000) | 2, $result[0]['salary_bit_or']); + $this->assertEquals(($result[1][0]['salary']/100000) | 2, $result[1]['salary_bit_or']); + $this->assertEquals(($result[2][0]['salary']/100000) | 2, $result[2]['salary_bit_or']); + $this->assertEquals(($result[3][0]['salary']/100000) | 2, $result[3]['salary_bit_or']); + } + + /** + * @group DDC-1213 + */ + public function testBitAndComparison() + { + $dql = 'SELECT m, ' . + 'BIT_AND(4, 2) AS bit_and,' . + 'BIT_AND( (m.salary/100000) , 2 ) AS salary_bit_and ' . + 'FROM Doctrine\Tests\Models\Company\CompanyManager m ' . + 'ORDER BY ' . + 'm.id ' ; + $result = $this->_em->createQuery($dql)->getArrayResult(); + + $this->assertEquals(4 & 2, $result[0]['bit_and']); + $this->assertEquals(4 & 2, $result[1]['bit_and']); + $this->assertEquals(4 & 2, $result[2]['bit_and']); + $this->assertEquals(4 & 2, $result[3]['bit_and']); + + $this->assertEquals(($result[0][0]['salary']/100000) & 2, $result[0]['salary_bit_and']); + $this->assertEquals(($result[1][0]['salary']/100000) & 2, $result[1]['salary_bit_and']); + $this->assertEquals(($result[2][0]['salary']/100000) & 2, $result[2]['salary_bit_and']); + $this->assertEquals(($result[3][0]['salary']/100000) & 2, $result[3]['salary_bit_and']); + } + + protected function generateFixture() + { + $manager1 = new CompanyManager(); + $manager1->setName('Roman B.'); + $manager1->setTitle('Foo'); + $manager1->setDepartment('IT'); + $manager1->setSalary(100000); + + $manager2 = new CompanyManager(); + $manager2->setName('Benjamin E.'); + $manager2->setTitle('Foo'); + $manager2->setDepartment('HR'); + $manager2->setSalary(200000); + + $manager3 = new CompanyManager(); + $manager3->setName('Guilherme B.'); + $manager3->setTitle('Foo'); + $manager3->setDepartment('Complaint Department'); + $manager3->setSalary(400000); + + $manager4 = new CompanyManager(); + $manager4->setName('Jonathan W.'); + $manager4->setTitle('Foo'); + $manager4->setDepartment('Administration'); + $manager4->setSalary(800000); + + $this->_em->persist($manager1); + $this->_em->persist($manager2); + $this->_em->persist($manager3); + $this->_em->persist($manager4); + $this->_em->flush(); + $this->_em->clear(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryTest.php new file mode 100644 index 0000000..ca4c936 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/QueryTest.php @@ -0,0 +1,658 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testSimpleQueries() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u, upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); + + $result = $query->getResult(); + + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); + $this->assertEquals('Guilherme', $result[0][0]->name); + $this->assertEquals('gblanco', $result[0][0]->username); + $this->assertEquals('developer', $result[0][0]->status); + $this->assertEquals('GUILHERME', $result[0][1]); + + $resultArray = $query->getArrayResult(); + $this->assertEquals(1, count($resultArray)); + $this->assertTrue(is_array($resultArray[0][0])); + $this->assertEquals('Guilherme', $resultArray[0][0]['name']); + $this->assertEquals('gblanco', $resultArray[0][0]['username']); + $this->assertEquals('developer', $resultArray[0][0]['status']); + $this->assertEquals('GUILHERME', $resultArray[0][1]); + + $scalarResult = $query->getScalarResult(); + $this->assertEquals(1, count($scalarResult)); + $this->assertEquals('Guilherme', $scalarResult[0]['u_name']); + $this->assertEquals('gblanco', $scalarResult[0]['u_username']); + $this->assertEquals('developer', $scalarResult[0]['u_status']); + $this->assertEquals('GUILHERME', $scalarResult[0][1]); + + $query = $this->_em->createQuery("select upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); + $this->assertEquals('GUILHERME', $query->getSingleScalarResult()); + } + + public function testJoinQueries() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $article1 = new CmsArticle; + $article1->topic = "Doctrine 2"; + $article1->text = "This is an introduction to Doctrine 2."; + $user->addArticle($article1); + + $article2 = new CmsArticle; + $article2->topic = "Symfony 2"; + $article2->text = "This is an introduction to Symfony 2."; + $user->addArticle($article2); + + $this->_em->persist($user); + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a ORDER BY a.topic"); + $users = $query->getResult(); + $this->assertEquals(1, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); + $this->assertEquals(2, count($users[0]->articles)); + $this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic); + $this->assertEquals('Symfony 2', $users[0]->articles[1]->topic); + } + + public function testUsingZeroBasedQueryParameterShouldWork() + { + $user = new CmsUser; + $user->name = 'Jonathan'; + $user->username = 'jwage'; + $user->status = 'developer'; + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?0'); + $q->setParameter(0, 'jwage'); + $user = $q->getSingleResult(); + + $this->assertNotNull($user); + } + + public function testUsingUnknownQueryParameterShouldThrowException() + { + $this->setExpectedException( + "Doctrine\ORM\Query\QueryException", + "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'); + $user = $q->getSingleResult(); + } + + public function testMismatchingParamExpectedParamCount() + { + $this->setExpectedException( + "Doctrine\ORM\Query\QueryException", + "Invalid parameter number: number of bound variables does not match number of tokens" + ); + + $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1'); + $q->setParameter(1, 'jwage'); + $q->setParameter(2, 'jwage'); + + $user = $q->getSingleResult(); + } + + public function testInvalidInputParameterThrowsException() + { + $this->setExpectedException("Doctrine\ORM\Query\QueryException"); + + $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?'); + $q->setParameter(1, 'jwage'); + $user = $q->getSingleResult(); + } + + public function testSetParameters() + { + $q = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = ?1 AND u.status = ?2'); + $q->setParameters(array(1 => 'jwage', 2 => 'active')); + $users = $q->getResult(); + } + + /** + * @group DDC-1070 + */ + public function testIterateResultAsArrayAndParams() + { + $article1 = new CmsArticle; + $article1->topic = "Doctrine 2"; + $article1->text = "This is an introduction to Doctrine 2."; + + $article2 = new CmsArticle; + $article2->topic = "Symfony 2"; + $article2->text = "This is an introduction to Symfony 2."; + + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->flush(); + $this->_em->clear(); + $articleId = $article1->id; + + $query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = ?1"); + $articles = $query->iterate(array(1 => 'Doctrine 2'), Query::HYDRATE_ARRAY); + + $found = array(); + foreach ($articles AS $article) { + $found[] = $article; + } + $this->assertEquals(1, count($found)); + $this->assertEquals(array( + array(array('id' => $articleId, 'topic' => 'Doctrine 2', 'text' => 'This is an introduction to Doctrine 2.', 'version' => 1)) + ), $found); + } + + public function testIterateResult_IterativelyBuildUpUnitOfWork() + { + $article1 = new CmsArticle; + $article1->topic = "Doctrine 2"; + $article1->text = "This is an introduction to Doctrine 2."; + + $article2 = new CmsArticle; + $article2->topic = "Symfony 2"; + $article2->text = "This is an introduction to Symfony 2."; + + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); + $articles = $query->iterate(); + + $iteratedCount = 0; + $topics = array(); + foreach($articles AS $row) { + $article = $row[0]; + $topics[] = $article->topic; + + $identityMap = $this->_em->getUnitOfWork()->getIdentityMap(); + $identityMapCount = count($identityMap['Doctrine\Tests\Models\CMS\CmsArticle']); + $this->assertTrue($identityMapCount>$iteratedCount); + + $iteratedCount++; + } + + $this->assertEquals(array("Doctrine 2", "Symfony 2"), $topics); + $this->assertEquals(2, $iteratedCount); + + $this->_em->flush(); + $this->_em->clear(); + } + + public function testIterateResultClearEveryCycle() + { + $article1 = new CmsArticle; + $article1->topic = "Doctrine 2"; + $article1->text = "This is an introduction to Doctrine 2."; + + $article2 = new CmsArticle; + $article2->topic = "Symfony 2"; + $article2->text = "This is an introduction to Symfony 2."; + + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); + $articles = $query->iterate(); + + $iteratedCount = 0; + $topics = array(); + foreach($articles AS $row) { + $article = $row[0]; + $topics[] = $article->topic; + + $this->_em->clear(); + + $iteratedCount++; + } + + $this->assertEquals(array("Doctrine 2", "Symfony 2"), $topics); + $this->assertEquals(2, $iteratedCount); + + $this->_em->flush(); + } + + /** + * @expectedException \Doctrine\ORM\Query\QueryException + */ + public function testIterateResult_FetchJoinedCollection_ThrowsException() + { + $query = $this->_em->createQuery("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a"); + $articles = $query->iterate(); + } + + /** + * @expectedException Doctrine\ORM\NoResultException + */ + public function testGetSingleResultThrowsExceptionOnNoResult() + { + $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a") + ->getSingleResult(); + } + + /** + * @expectedException Doctrine\ORM\NoResultException + */ + public function testGetSingleScalarResultThrowsExceptionOnNoResult() + { + $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a") + ->getSingleScalarResult(); + } + + /** + * @expectedException Doctrine\ORM\NonUniqueResultException + */ + public function testGetSingleScalarResultThrowsExceptionOnNonUniqueResult() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + + $article1 = new CmsArticle; + $article1->topic = "Doctrine 2"; + $article1->text = "This is an introduction to Doctrine 2."; + $user->addArticle($article1); + + $article2 = new CmsArticle; + $article2->topic = "Symfony 2"; + $article2->text = "This is an introduction to Symfony 2."; + $user->addArticle($article2); + + $this->_em->persist($user); + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->flush(); + $this->_em->clear(); + + $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a") + ->getSingleScalarResult(); + } + + public function testModifiedLimitQuery() + { + for ($i = 0; $i < 5; $i++) { + $user = new CmsUser; + $user->name = 'Guilherme' . $i; + $user->username = 'gblanco' . $i; + $user->status = 'developer'; + $this->_em->persist($user); + } + + $this->_em->flush(); + $this->_em->clear(); + + $data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') + ->setFirstResult(1) + ->setMaxResults(2) + ->getResult(); + + $this->assertEquals(2, count($data)); + $this->assertEquals('gblanco1', $data[0]->username); + $this->assertEquals('gblanco2', $data[1]->username); + + $data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') + ->setFirstResult(3) + ->setMaxResults(2) + ->getResult(); + + $this->assertEquals(2, count($data)); + $this->assertEquals('gblanco3', $data[0]->username); + $this->assertEquals('gblanco4', $data[1]->username); + + $data = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') + ->setFirstResult(3) + ->setMaxResults(2) + ->getScalarResult(); + } + + public function testSupportsQueriesWithEntityNamespaces() + { + $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); + + try { + $query = $this->_em->createQuery('UPDATE CMS:CmsUser u SET u.name = ?1'); + $this->assertEquals('UPDATE cms_users SET name = ?', $query->getSql()); + $query->free(); + } catch (\Exception $e) { + $this->fail($e->getMessage()); + } + + $this->_em->getConfiguration()->setEntityNamespaces(array()); + } + + /** + * @group DDC-604 + */ + public function testEntityParameters() + { + $article = new CmsArticle; + $article->topic = "dr. dolittle"; + $article->text = "Once upon a time ..."; + $author = new CmsUser; + $author->name = "anonymous"; + $author->username = "anon"; + $author->status = "here"; + $article->user = $author; + $this->_em->persist($author); + $this->_em->persist($article); + $this->_em->flush(); + $this->_em->clear(); + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a where a.topic = :topic and a.user = :user") + ->setParameter("user", $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $author->id)) + ->setParameter("topic", "dr. dolittle"); + + $result = $q->getResult(); + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0]); + $this->assertEquals("dr. dolittle", $result[0]->topic); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $result[0]->user); + $this->assertFalse($result[0]->user->__isInitialized__); + } + + /** + * @group DDC-952 + */ + public function testEnableFetchEagerMode() + { + for ($i = 0; $i < 10; $i++) { + $article = new CmsArticle; + $article->topic = "dr. dolittle"; + $article->text = "Once upon a time ..."; + $author = new CmsUser; + $author->name = "anonymous"; + $author->username = "anon".$i; + $author->status = "here"; + $article->user = $author; + $this->_em->persist($author); + $this->_em->persist($article); + } + $this->_em->flush(); + $this->_em->clear(); + + $articles = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a') + ->setFetchMode('Doctrine\Tests\Models\CMS\CmsArticle', 'user', ClassMetadata::FETCH_EAGER) + ->getResult(); + + $this->assertEquals(10, count($articles)); + foreach ($articles AS $article) { + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $article); + } + } + + /** + * @group DDC-991 + */ + public function testgetOneOrNullResult() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); + + $fetchedUser = $query->getOneOrNullResult(); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $fetchedUser); + $this->assertEquals('gblanco', $fetchedUser->username); + + $query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); + $fetchedUsername = $query->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR); + $this->assertEquals('gblanco', $fetchedUsername); + } + + /** + * @group DDC-991 + */ + public function testgetOneOrNullResultSeveralRows() + { + $user = new CmsUser; + $user->name = 'Guilherme'; + $user->username = 'gblanco'; + $user->status = 'developer'; + $this->_em->persist($user); + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'developer'; + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); + + $this->setExpectedException('Doctrine\ORM\NonUniqueResultException'); + $fetchedUser = $query->getOneOrNullResult(); + } + + /** + * @group DDC-991 + */ + public function testgetOneOrNullResultNoRows() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); + $this->assertNull($query->getOneOrNullResult()); + + $query = $this->_em->createQuery("select u.username from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"); + $this->assertNull($query->getOneOrNullResult(Query::HYDRATE_SCALAR)); + } + + /** + * @group DBAL-171 + */ + public function testParameterOrder() + { + $user1 = new CmsUser; + $user1->name = 'Benjamin'; + $user1->username = 'beberlei'; + $user1->status = 'developer'; + $this->_em->persist($user1); + + $user2 = new CmsUser; + $user2->name = 'Roman'; + $user2->username = 'romanb'; + $user2->status = 'developer'; + $this->_em->persist($user2); + + $user3 = new CmsUser; + $user3->name = 'Jonathan'; + $user3->username = 'jwage'; + $user3->status = 'developer'; + $this->_em->persist($user3); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.status = :a AND u.id IN (:b)"); + $query->setParameters(array( + 'b' => array($user1->id, $user2->id, $user3->id), + 'a' => 'developer', + )); + $result = $query->getResult(); + + $this->assertEquals(3, count($result)); + } + + public function testDqlWithAutoInferOfParameters() + { + $user = new CmsUser; + $user->name = 'Benjamin'; + $user->username = 'beberlei'; + $user->status = 'developer'; + $this->_em->persist($user); + + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'developer'; + $this->_em->persist($user); + + $user = new CmsUser; + $user->name = 'Jonathan'; + $user->username = 'jwage'; + $user->status = 'developer'; + $this->_em->persist($user); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username IN (?0)"); + $query->setParameter(0, array('beberlei', 'jwage')); + + $users = $query->execute(); + + $this->assertEquals(2, count($users)); + } + + public function testQueryBuilderWithStringWhereClauseContainingOrAndConditionalPrimary() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->innerJoin('u.articles', 'a') + ->where('(u.id = 0) OR (u.id IS NULL)'); + + $query = $qb->getQuery(); + $users = $query->execute(); + + $this->assertEquals(0, count($users)); + } + + public function testQueryWithArrayOfEntitiesAsParameter() + { + $userA = new CmsUser; + $userA->name = 'Benjamin'; + $userA->username = 'beberlei'; + $userA->status = 'developer'; + $this->_em->persist($userA); + + $userB = new CmsUser; + $userB->name = 'Roman'; + $userB->username = 'romanb'; + $userB->status = 'developer'; + $this->_em->persist($userB); + + $userC = new CmsUser; + $userC->name = 'Jonathan'; + $userC->username = 'jwage'; + $userC->status = 'developer'; + $this->_em->persist($userC); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u IN (?0) OR u.username = ?1"); + $query->setParameter(0, array($userA, $userC)); + $query->setParameter(1, 'beberlei'); + + $users = $query->execute(); + + $this->assertEquals(2, count($users)); + } + + public function testQueryWithHiddenAsSelectExpression() + { + $userA = new CmsUser; + $userA->name = 'Benjamin'; + $userA->username = 'beberlei'; + $userA->status = 'developer'; + $this->_em->persist($userA); + + $userB = new CmsUser; + $userB->name = 'Roman'; + $userB->username = 'romanb'; + $userB->status = 'developer'; + $this->_em->persist($userB); + + $userC = new CmsUser; + $userC->name = 'Jonathan'; + $userC->username = 'jwage'; + $userC->status = 'developer'; + $this->_em->persist($userC); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery("SELECT u, (SELECT COUNT(u2.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) AS HIDDEN total FROM Doctrine\Tests\Models\CMS\CmsUser u"); + $users = $query->execute(); + + $this->assertEquals(3, count($users)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]); + } + + /** + * @group DDC-1651 + */ + public function testSetParameterBindingSingleIdentifierObjectConverted() + { + $userC = new CmsUser; + $userC->name = 'Jonathan'; + $userC->username = 'jwage'; + $userC->status = 'developer'; + $this->_em->persist($userC); + + $this->_em->flush(); + $this->_em->clear(); + + $q = $this->_em->createQuery("SELECT DISTINCT u from Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1"); + $q->setParameter(1, $userC); + + $this->assertEquals($userC->id, $q->getParameter(1)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php new file mode 100644 index 0000000..2519a9c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReadOnlyTest.php @@ -0,0 +1,94 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\ReadOnlyEntity'), + )); + } catch(\Exception $e) { + } + } + + public function testReadOnlyEntityNeverChangeTracked() + { + $readOnly = new ReadOnlyEntity("Test1", 1234); + $this->_em->persist($readOnly); + $this->_em->flush(); + + $readOnly->name = "Test2"; + $readOnly->numericValue = 4321; + + $this->_em->flush(); + $this->_em->clear(); + + $dbReadOnly = $this->_em->find('Doctrine\Tests\ORM\Functional\ReadOnlyEntity', $readOnly->id); + $this->assertEquals("Test1", $dbReadOnly->name); + $this->assertEquals(1234, $dbReadOnly->numericValue); + } + + /** + * @group DDC-1659 + */ + public function testClearReadOnly() + { + $readOnly = new ReadOnlyEntity("Test1", 1234); + $this->_em->persist($readOnly); + $this->_em->flush(); + $this->_em->getUnitOfWork()->markReadOnly($readOnly); + + $this->_em->clear(); + + $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); + } + + /** + * @group DDC-1659 + */ + public function testClearEntitiesReadOnly() + { + $readOnly = new ReadOnlyEntity("Test1", 1234); + $this->_em->persist($readOnly); + $this->_em->flush(); + $this->_em->getUnitOfWork()->markReadOnly($readOnly); + + $this->_em->clear(get_class($readOnly)); + + $this->assertFalse($this->_em->getUnitOfWork()->isReadOnly($readOnly)); + } +} + +/** + * @Entity(readOnly=true) + */ +class ReadOnlyEntity +{ + /** + * @Id @GeneratedValue @Column(type="integer") + * @var int + */ + public $id; + /** @column(type="string") */ + public $name; + /** @Column(type="integer") */ + public $numericValue; + + public function __construct($name, $number) + { + $this->name = $name; + $this->numericValue = $number; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php new file mode 100644 index 0000000..3ce24e7 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php @@ -0,0 +1,250 @@ + + * @author Benjamin Eberlei + */ +class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() + { + $this->useModelSet('ecommerce'); + parent::setUp(); + $this->_factory = new ProxyFactory( + $this->_em, + __DIR__ . '/../../Proxies', + 'Doctrine\Tests\Proxies', + true); + } + + public function createProduct() + { + $product = new ECommerceProduct(); + $product->setName('Doctrine Cookbook'); + $this->_em->persist($product); + + $this->_em->flush(); + $this->_em->clear(); + + return $product->getId(); + } + + public function createAuction() + { + $event = new CompanyAuction(); + $event->setData('Doctrine Cookbook'); + $this->_em->persist($event); + + $this->_em->flush(); + $this->_em->clear(); + + return $event->getId(); + } + + public function testLazyLoadsFieldValuesFromDatabase() + { + $id = $this->createProduct(); + + $productProxy = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct', array('id' => $id)); + $this->assertEquals('Doctrine Cookbook', $productProxy->getName()); + } + + /** + * @group DDC-727 + */ + public function testAccessMetatadaForProxy() + { + $id = $this->createProduct(); + + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + $class = $this->_em->getClassMetadata(get_class($entity)); + + $this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $class->name); + } + + /** + * @group DDC-1033 + */ + public function testReferenceFind() + { + $id = $this->createProduct(); + + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + $entity2 = $this->_em->find('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + + $this->assertSame($entity, $entity2); + $this->assertEquals('Doctrine Cookbook', $entity2->getName()); + } + + /** + * @group DDC-1033 + */ + public function testCloneProxy() + { + $id = $this->createProduct(); + + /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + + /* @var $clone Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $clone = clone $entity; + + $this->assertEquals($id, $entity->getId()); + $this->assertEquals('Doctrine Cookbook', $entity->getName()); + + $this->assertFalse($this->_em->contains($clone), "Cloning a reference proxy should return an unmanaged/detached entity."); + $this->assertEquals($id, $clone->getId(), "Cloning a reference proxy should return same id."); + $this->assertEquals('Doctrine Cookbook', $clone->getName(), "Cloning a reference proxy should return same product name."); + + // domain logic, Product::__clone sets isCloned public property + $this->assertTrue($clone->isCloned); + $this->assertFalse($entity->isCloned); + } + + /** + * @group DDC-733 + */ + public function testInitializeProxy() + { + $id = $this->createProduct(); + + /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + + $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); + $this->_em->getUnitOfWork()->initializeObject($entity); + $this->assertTrue($entity->__isInitialized__, "Should be initialized after called UnitOfWork::initializeObject()"); + } + + /** + * @group DDC-1163 + */ + public function testInitializeChangeAndFlushProxy() + { + $id = $this->createProduct(); + + /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + $entity->setName('Doctrine 2 Cookbook'); + + $this->_em->flush(); + $this->_em->clear(); + + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + $this->assertEquals('Doctrine 2 Cookbook', $entity->getName()); + } + + /** + * @group DDC-1022 + */ + public function testWakeupCalledOnProxy() + { + $id = $this->createProduct(); + + /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + + $this->assertFalse($entity->wakeUp); + + $entity->setName('Doctrine 2 Cookbook'); + + $this->assertTrue($entity->wakeUp, "Loading the proxy should call __wakeup()."); + } + + public function testDoNotInitializeProxyOnGettingTheIdentifier() + { + $id = $this->createProduct(); + + /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + + $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); + $this->assertEquals($id, $entity->getId()); + $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); + } + + /** + * @group DDC-1625 + */ + public function testDoNotInitializeProxyOnGettingTheIdentifier_DDC_1625() + { + $id = $this->createAuction(); + + /* @var $entity Doctrine\Tests\Models\Company\CompanyAuction */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyAuction' , $id); + + $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); + $this->assertEquals($id, $entity->getId()); + $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy when extending."); + } + + public function testDoNotInitializeProxyOnGettingTheIdentifierAndReturnTheRightType() + { + $product = new ECommerceProduct(); + $product->setName('Doctrine Cookbook'); + + $shipping = new ECommerceShipping(); + $shipping->setDays(1); + $product->setShipping($shipping); + $this->_em->persist($product); + $this->_em->flush(); + $this->_em->clear(); + + $id = $shipping->getId(); + + $product = $this->_em->getRepository('Doctrine\Tests\Models\ECommerce\ECommerceProduct')->find($product->getId()); + + $entity = $product->getShipping(); + $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); + $this->assertEquals($id, $entity->getId()); + $this->assertSame($id, $entity->getId(), "Check that the id's are the same value, and type."); + $this->assertFalse($entity->__isInitialized__, "Getting the identifier doesn't initialize the proxy."); + } + + public function testInitializeProxyOnGettingSomethingOtherThanTheIdentifier() + { + $id = $this->createProduct(); + + /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + + $this->assertFalse($entity->__isInitialized__, "Pre-Condition: Object is unitialized proxy."); + $this->assertEquals('Doctrine Cookbook', $entity->getName()); + $this->assertTrue($entity->__isInitialized__, "Getting something other than the identifier initializes the proxy."); + } + + /** + * @group DDC-1604 + */ + public function testCommonPersistenceProxy() + { + $id = $this->createProduct(); + + /* @var $entity Doctrine\Tests\Models\ECommerce\ECommerceProduct */ + $entity = $this->_em->getReference('Doctrine\Tests\Models\ECommerce\ECommerceProduct' , $id); + $className = \Doctrine\Common\Util\ClassUtils::getClass($entity); + + $this->assertInstanceOf('Doctrine\Common\Persistence\Proxy', $entity); + $this->assertFalse($entity->__isInitialized()); + $this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $className); + + $restName = str_replace($this->_em->getConfiguration()->getProxyNamespace(), "", get_class($entity)); + $restName = substr(get_class($entity), strlen($this->_em->getConfiguration()->getProxyNamespace()) +1); + $proxyFileName = $this->_em->getConfiguration()->getProxyDir() . DIRECTORY_SEPARATOR . str_replace("\\", "", $restName) . ".php"; + $this->assertTrue(file_exists($proxyFileName), "Proxy file name cannot be found generically."); + + $entity->__load(); + $this->assertTrue($entity->__isInitialized()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php new file mode 100644 index 0000000..2a50921 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php @@ -0,0 +1,254 @@ +cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); + $this->cacheDataReflection->setAccessible(true); + $this->useModelSet('cms'); + parent::setUp(); + } + + /** + * @param ArrayCache $cache + * @return integer + */ + private function getCacheSize(ArrayCache $cache) + { + return sizeof($this->cacheDataReflection->getValue($cache)); + } + + public function testResultCache() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'dev'; + $this->_em->persist($user); + $this->_em->flush(); + + + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + + $cache = new ArrayCache(); + + $query->setResultCacheDriver($cache)->setResultCacheId('my_cache_id'); + + $this->assertFalse($cache->contains('my_cache_id')); + + $users = $query->getResult(); + + $this->assertTrue($cache->contains('my_cache_id')); + $this->assertEquals(1, count($users)); + $this->assertEquals('Roman', $users[0]->name); + + $this->_em->clear(); + + $query2 = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + $query2->setResultCacheDriver($cache)->setResultCacheId('my_cache_id'); + + $users = $query2->getResult(); + + $this->assertTrue($cache->contains('my_cache_id')); + $this->assertEquals(1, count($users)); + $this->assertEquals('Roman', $users[0]->name); + } + + public function testSetResultCacheId() + { + $cache = new ArrayCache; + + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + $query->setResultCacheDriver($cache); + $query->setResultCacheId('testing_result_cache_id'); + + $this->assertFalse($cache->contains('testing_result_cache_id')); + + $users = $query->getResult(); + + $this->assertTrue($cache->contains('testing_result_cache_id')); + } + + public function testUseResultCache() + { + $cache = new \Doctrine\Common\Cache\ArrayCache(); + + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + $query->useResultCache(true); + $query->setResultCacheDriver($cache); + $query->setResultCacheId('testing_result_cache_id'); + $users = $query->getResult(); + + $this->assertTrue($cache->contains('testing_result_cache_id')); + + $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); + } + + /** + * @group DDC-1026 + */ + public function testUseResultCacheParams() + { + $cache = new \Doctrine\Common\Cache\ArrayCache(); + + $sqlCount = count($this->_sqlLoggerStack->queries); + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux WHERE ux.id = ?1'); + $query->setParameter(1, 1); + $query->setResultCacheDriver($cache); + $query->useResultCache(true); + $query->getResult(); + + $query->setParameter(1, 2); + $query->getResult(); + + $this->assertEquals($sqlCount + 2, count($this->_sqlLoggerStack->queries), "Two non-cached queries."); + + $query->setParameter(1, 1); + $query->useResultCache(true); + $query->getResult(); + + $query->setParameter(1, 2); + $query->getResult(); + + $this->assertEquals($sqlCount + 2, count($this->_sqlLoggerStack->queries), "The next two sql should have been cached, but were not."); + } + + public function testNativeQueryResultCaching() + { + $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); + $rsm->addScalarResult('id', 'u'); + $query = $this->_em->createNativeQuery('select u.id FROM cms_users u WHERE u.id = ?', $rsm); + $query->setParameter(1, 10); + + $cache = new ArrayCache(); + $query->setResultCacheDriver($cache)->useResultCache(true); + + $this->assertEquals(0, $this->getCacheSize($cache)); + $query->getResult(); + $this->assertEquals(1, $this->getCacheSize($cache)); + + return $query; + } + + /** + * @param string $query + * @depends testNativeQueryResultCaching + */ + public function testResultCacheNotDependsOnQueryHints($query) + { + $cache = $query->getResultCacheDriver(); + $cacheCount = $this->getCacheSize($cache); + + $query->setHint('foo', 'bar'); + $query->getResult(); + + $this->assertEquals($cacheCount, $this->getCacheSize($cache)); + } + + /** + * @param $query + * @depends testNativeQueryResultCaching + */ + public function testResultCacheDependsOnParameters($query) + { + $cache = $query->getResultCacheDriver(); + $cacheCount = $this->getCacheSize($cache); + + $query->setParameter(1, 50); + $query->getResult(); + + $this->assertEquals($cacheCount + 1, $this->getCacheSize($cache)); + } + + /** + * @param $query + * @depends testNativeQueryResultCaching + */ + public function testResultCacheNotDependsOnHydrationMode($query) + { + $cache = $query->getResultCacheDriver(); + $cacheCount = $this->getCacheSize($cache); + + $this->assertNotEquals(\Doctrine\ORM\Query::HYDRATE_ARRAY, $query->getHydrationMode()); + $query->getArrayResult(); + + $this->assertEquals($cacheCount, $this->getCacheSize($cache)); + } + + /** + * @group DDC-909 + */ + public function testResultCacheWithObjectParameter() + { + $user1 = new CmsUser; + $user1->name = 'Roman'; + $user1->username = 'romanb'; + $user1->status = 'dev'; + + $user2 = new CmsUser; + $user2->name = 'Benjamin'; + $user2->username = 'beberlei'; + $user2->status = 'dev'; + + $article = new CmsArticle(); + $article->text = "foo"; + $article->topic = "baz"; + $article->user = $user1; + + $this->_em->persist($article); + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->flush(); + + $query = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); + $query->setParameter(1, $user1); + + $cache = new ArrayCache(); + + $query->setResultCacheDriver($cache)->useResultCache(true); + + $articles = $query->getResult(); + + $this->assertEquals(1, count($articles)); + $this->assertEquals('baz', $articles[0]->topic); + + $this->_em->clear(); + + $query2 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); + $query2->setParameter(1, $user1); + + $query2->setResultCacheDriver($cache)->useResultCache(true); + + $articles = $query2->getResult(); + + $this->assertEquals(1, count($articles)); + $this->assertEquals('baz', $articles[0]->topic); + + $query3 = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = ?1'); + $query3->setParameter(1, $user2); + + $query3->setResultCacheDriver($cache)->useResultCache(true); + + $articles = $query3->getResult(); + + $this->assertEquals(0, count($articles)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php new file mode 100644 index 0000000..31ebb2d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -0,0 +1,1047 @@ + + */ +class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + private $userId, $userId2, $articleId, $articleId2; + private $groupId, $groupId2; + private $managerId, $managerId2, $contractId1, $contractId2; + private $organizationId, $eventId1, $eventId2; + + public function setUp() + { + $this->useModelSet('cms'); + $this->useModelSet('company'); + parent::setUp(); + } + + public function tearDown() + { + parent::tearDown(); + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + } + + public function testConfigureFilter() + { + $config = new \Doctrine\ORM\Configuration(); + + $config->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); + + $this->assertEquals("\Doctrine\Tests\ORM\Functional\MyLocaleFilter", $config->getFilterClassName("locale")); + $this->assertNull($config->getFilterClassName("foo")); + } + + public function testEntityManagerEnableFilter() + { + $em = $this->_getEntityManager(); + $this->configureFilters($em); + + // Enable an existing filter + $filter = $em->getFilters()->enable("locale"); + $this->assertTrue($filter instanceof \Doctrine\Tests\ORM\Functional\MyLocaleFilter); + + // Enable the filter again + $filter2 = $em->getFilters()->enable("locale"); + $this->assertEquals($filter, $filter2); + + // Enable a non-existing filter + $exceptionThrown = false; + try { + $filter = $em->getFilters()->enable("foo"); + } catch (\InvalidArgumentException $e) { + $exceptionThrown = true; + } + $this->assertTrue($exceptionThrown); + } + + public function testEntityManagerEnabledFilters() + { + $em = $this->_getEntityManager(); + + // No enabled filters + $this->assertEquals(array(), $em->getFilters()->getEnabledFilters()); + + $this->configureFilters($em); + $filter = $em->getFilters()->enable("locale"); + $filter = $em->getFilters()->enable("soft_delete"); + + // Two enabled filters + $this->assertEquals(2, count($em->getFilters()->getEnabledFilters())); + + } + + public function testEntityManagerDisableFilter() + { + $em = $this->_getEntityManager(); + $this->configureFilters($em); + + // Enable the filter + $filter = $em->getFilters()->enable("locale"); + + // Disable it + $this->assertEquals($filter, $em->getFilters()->disable("locale")); + $this->assertEquals(0, count($em->getFilters()->getEnabledFilters())); + + // Disable a non-existing filter + $exceptionThrown = false; + try { + $filter = $em->getFilters()->disable("foo"); + } catch (\InvalidArgumentException $e) { + $exceptionThrown = true; + } + $this->assertTrue($exceptionThrown); + + // Disable a non-enabled filter + $exceptionThrown = false; + try { + $filter = $em->getFilters()->disable("locale"); + } catch (\InvalidArgumentException $e) { + $exceptionThrown = true; + } + $this->assertTrue($exceptionThrown); + } + + public function testEntityManagerGetFilter() + { + $em = $this->_getEntityManager(); + $this->configureFilters($em); + + // Enable the filter + $filter = $em->getFilters()->enable("locale"); + + // Get the filter + $this->assertEquals($filter, $em->getFilters()->getFilter("locale")); + + // Get a non-enabled filter + $exceptionThrown = false; + try { + $filter = $em->getFilters()->getFilter("soft_delete"); + } catch (\InvalidArgumentException $e) { + $exceptionThrown = true; + } + $this->assertTrue($exceptionThrown); + } + + protected function configureFilters($em) + { + // Add filters to the configuration of the EM + $config = $em->getConfiguration(); + $config->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); + $config->addFilter("soft_delete", "\Doctrine\Tests\ORM\Functional\MySoftDeleteFilter"); + } + + protected function getMockConnection() + { + // Setup connection mock + $conn = $this->getMockBuilder('Doctrine\DBAL\Connection') + ->disableOriginalConstructor() + ->getMock(); + + return $conn; + } + + protected function getMockEntityManager() + { + // Setup connection mock + $em = $this->getMockBuilder('Doctrine\ORM\EntityManager') + ->disableOriginalConstructor() + ->getMock(); + + return $em; + } + + protected function addMockFilterCollection($em) + { + $filterCollection = $this->getMockBuilder('Doctrine\ORM\Query\FilterCollection') + ->disableOriginalConstructor() + ->getMock(); + + $em->expects($this->any()) + ->method('getFilters') + ->will($this->returnValue($filterCollection)); + + return $filterCollection; + } + + public function testSQLFilterGetSetParameter() + { + // Setup mock connection + $conn = $this->getMockConnection(); + $conn->expects($this->once()) + ->method('quote') + ->with($this->equalTo('en')) + ->will($this->returnValue("'en'")); + + $em = $this->getMockEntityManager($conn); + $em->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($conn)); + + $filterCollection = $this->addMockFilterCollection($em); + $filterCollection + ->expects($this->once()) + ->method('setFiltersStateDirty'); + + $filter = new MyLocaleFilter($em); + + $filter->setParameter('locale', 'en', DBALType::STRING); + + $this->assertEquals("'en'", $filter->getParameter('locale')); + } + + public function testSQLFilterSetParameterInfersType() + { + // Setup mock connection + $conn = $this->getMockConnection(); + $conn->expects($this->once()) + ->method('quote') + ->with($this->equalTo('en')) + ->will($this->returnValue("'en'")); + + $em = $this->getMockEntityManager($conn); + $em->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($conn)); + + $filterCollection = $this->addMockFilterCollection($em); + $filterCollection + ->expects($this->once()) + ->method('setFiltersStateDirty'); + + $filter = new MyLocaleFilter($em); + + $filter->setParameter('locale', 'en'); + + $this->assertEquals("'en'", $filter->getParameter('locale')); + } + + public function testSQLFilterAddConstraint() + { + // Set up metadata mock + $targetEntity = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata') + ->disableOriginalConstructor() + ->getMock(); + + $filter = new MySoftDeleteFilter($this->getMockEntityManager()); + + // Test for an entity that gets extra filter data + $targetEntity->name = 'MyEntity\SoftDeleteNewsItem'; + $this->assertEquals('t1_.deleted = 0', $filter->addFilterConstraint($targetEntity, 't1_')); + + // Test for an entity that doesn't get extra filter data + $targetEntity->name = 'MyEntity\NoSoftDeleteNewsItem'; + $this->assertEquals('', $filter->addFilterConstraint($targetEntity, 't1_')); + + } + + public function testSQLFilterToString() + { + $em = $this->getMockEntityManager(); + $filterCollection = $this->addMockFilterCollection($em); + + $filter = new MyLocaleFilter($em); + $filter->setParameter('locale', 'en', DBALType::STRING); + $filter->setParameter('foo', 'bar', DBALType::STRING); + + $filter2 = new MyLocaleFilter($em); + $filter2->setParameter('foo', 'bar', DBALType::STRING); + $filter2->setParameter('locale', 'en', DBALType::STRING); + + $parameters = array( + 'foo' => array('value' => 'bar', 'type' => DBALType::STRING), + 'locale' => array('value' => 'en', 'type' => DBALType::STRING), + ); + + $this->assertEquals(serialize($parameters), ''.$filter); + $this->assertEquals(''.$filter, ''.$filter2); + } + + public function testQueryCache_DependsOnFilters() + { + $cacheDataReflection = new \ReflectionProperty("Doctrine\Common\Cache\ArrayCache", "data"); + $cacheDataReflection->setAccessible(true); + + $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); + + $cache = new ArrayCache(); + $query->setQueryCacheDriver($cache); + + $query->getResult(); + $this->assertEquals(1, sizeof($cacheDataReflection->getValue($cache))); + + $conf = $this->_em->getConfiguration(); + $conf->addFilter("locale", "\Doctrine\Tests\ORM\Functional\MyLocaleFilter"); + $this->_em->getFilters()->enable("locale"); + + $query->getResult(); + $this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache))); + + // Another time doesn't add another cache entry + $query->getResult(); + $this->assertEquals(2, sizeof($cacheDataReflection->getValue($cache))); + } + + public function testQueryGeneration_DependsOnFilters() + { + $query = $this->_em->createQuery('select a from Doctrine\Tests\Models\CMS\CmsAddress a'); + $firstSQLQuery = $query->getSQL(); + + $conf = $this->_em->getConfiguration(); + $conf->addFilter("country", "\Doctrine\Tests\ORM\Functional\CMSCountryFilter"); + $this->_em->getFilters()->enable("country") + ->setParameter("country", "en", DBALType::STRING); + + $this->assertNotEquals($firstSQLQuery, $query->getSQL()); + } + + public function testToOneFilter() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->loadFixtureData(); + + $query = $this->_em->createQuery('select ux, ua from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.address ua'); + + // We get two users before enabling the filter + $this->assertEquals(2, count($query->getResult())); + + $conf = $this->_em->getConfiguration(); + $conf->addFilter("country", "\Doctrine\Tests\ORM\Functional\CMSCountryFilter"); + $this->_em->getFilters()->enable("country")->setParameter("country", "Germany", DBALType::STRING); + + // We get one user after enabling the filter + $this->assertEquals(1, count($query->getResult())); + } + + public function testManyToManyFilter() + { + $this->loadFixtureData(); + $query = $this->_em->createQuery('select ux, ug from Doctrine\Tests\Models\CMS\CmsUser ux JOIN ux.groups ug'); + + // We get two users before enabling the filter + $this->assertEquals(2, count($query->getResult())); + + $conf = $this->_em->getConfiguration(); + $conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter"); + $this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "bar_%", DBALType::STRING); + + // We get one user after enabling the filter + $this->assertEquals(1, count($query->getResult())); + + } + + public function testWhereFilter() + { + $this->loadFixtureData(); + $query = $this->_em->createQuery('select ug from Doctrine\Tests\Models\CMS\CmsGroup ug WHERE 1=1'); + + // We get two users before enabling the filter + $this->assertEquals(2, count($query->getResult())); + + $conf = $this->_em->getConfiguration(); + $conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter"); + $this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "bar_%", DBALType::STRING); + + // We get one user after enabling the filter + $this->assertEquals(1, count($query->getResult())); + } + + + private function loadLazyFixtureData() + { + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $class->associationMappings['articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + $class->associationMappings['groups']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + $this->loadFixtureData(); + } + + private function useCMSArticleTopicFilter() + { + $conf = $this->_em->getConfiguration(); + $conf->addFilter("article_topic", "\Doctrine\Tests\ORM\Functional\CMSArticleTopicFilter"); + $this->_em->getFilters()->enable("article_topic")->setParameter("topic", "Test1", DBALType::STRING); + } + + public function testOneToMany_ExtraLazyCountWithFilter() + { + $this->loadLazyFixtureData(); + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $this->assertFalse($user->articles->isInitialized()); + $this->assertEquals(2, count($user->articles)); + + $this->useCMSArticleTopicFilter(); + + $this->assertEquals(1, count($user->articles)); + } + + public function testOneToMany_ExtraLazyContainsWithFilter() + { + $this->loadLazyFixtureData(); + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + $filteredArticle = $this->_em->find('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId2); + + $this->assertFalse($user->articles->isInitialized()); + $this->assertTrue($user->articles->contains($filteredArticle)); + + $this->useCMSArticleTopicFilter(); + + $this->assertFalse($user->articles->contains($filteredArticle)); + } + + public function testOneToMany_ExtraLazySliceWithFilter() + { + $this->loadLazyFixtureData(); + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); + + $this->assertFalse($user->articles->isInitialized()); + $this->assertEquals(2, count($user->articles->slice(0,10))); + + $this->useCMSArticleTopicFilter(); + + $this->assertEquals(1, count($user->articles->slice(0,10))); + } + + private function useCMSGroupPrefixFilter() + { + $conf = $this->_em->getConfiguration(); + $conf->addFilter("group_prefix", "\Doctrine\Tests\ORM\Functional\CMSGroupPrefixFilter"); + $this->_em->getFilters()->enable("group_prefix")->setParameter("prefix", "foo%", DBALType::STRING); + } + + public function testManyToMany_ExtraLazyCountWithFilter() + { + $this->loadLazyFixtureData(); + + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); + + $this->assertFalse($user->groups->isInitialized()); + $this->assertEquals(2, count($user->groups)); + + $this->useCMSGroupPrefixFilter(); + + $this->assertEquals(1, count($user->groups)); + } + + public function testManyToMany_ExtraLazyContainsWithFilter() + { + $this->loadLazyFixtureData(); + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); + $filteredArticle = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupId2); + + $this->assertFalse($user->groups->isInitialized()); + $this->assertTrue($user->groups->contains($filteredArticle)); + + $this->useCMSGroupPrefixFilter(); + + $this->assertFalse($user->groups->contains($filteredArticle)); + } + + public function testManyToMany_ExtraLazySliceWithFilter() + { + $this->loadLazyFixtureData(); + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId2); + + $this->assertFalse($user->groups->isInitialized()); + $this->assertEquals(2, count($user->groups->slice(0,10))); + + $this->useCMSGroupPrefixFilter(); + + $this->assertEquals(1, count($user->groups->slice(0,10))); + } + + private function loadFixtureData() + { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'developer'; + + $address = new CmsAddress; + $address->country = 'Germany'; + $address->city = 'Berlin'; + $address->zip = '12345'; + + $user->address = $address; // inverse side + $address->user = $user; // owning side! + + $group = new CmsGroup; + $group->name = 'foo_group'; + $user->addGroup($group); + + $article1 = new CmsArticle; + $article1->topic = "Test1"; + $article1->text = "Test"; + $article1->setAuthor($user); + + $article2 = new CmsArticle; + $article2->topic = "Test2"; + $article2->text = "Test"; + $article2->setAuthor($user); + + $this->_em->persist($article1); + $this->_em->persist($article2); + + $this->_em->persist($user); + + $user2 = new CmsUser; + $user2->name = 'Guilherme'; + $user2->username = 'gblanco'; + $user2->status = 'developer'; + + $address2 = new CmsAddress; + $address2->country = 'France'; + $address2->city = 'Paris'; + $address2->zip = '12345'; + + $user->address = $address2; // inverse side + $address2->user = $user2; // owning side! + + $user2->addGroup($group); + $group2 = new CmsGroup; + $group2->name = 'bar_group'; + $user2->addGroup($group2); + + $this->_em->persist($user2); + $this->_em->flush(); + $this->_em->clear(); + + $this->userId = $user->getId(); + $this->userId2 = $user2->getId(); + $this->articleId = $article1->id; + $this->articleId2 = $article2->id; + $this->groupId = $group->id; + $this->groupId2 = $group2->id; + } + + public function testJoinSubclassPersister_FilterOnlyOnRootTableWhenFetchingSubEntity() + { + $this->loadCompanyJoinedSubclassFixtureData(); + // Persister + $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager')->findAll())); + // SQLWalker + $this->assertEquals(2, count($this->_em->createQuery("SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm")->getResult())); + + // Enable the filter + $this->usePersonNameFilter('Guilh%'); + + $managers = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager')->findAll(); + $this->assertEquals(1, count($managers)); + $this->assertEquals("Guilherme", $managers[0]->getName()); + + $this->assertEquals(1, count($this->_em->createQuery("SELECT cm FROM Doctrine\Tests\Models\Company\CompanyManager cm")->getResult())); + } + + public function testJoinSubclassPersister_FilterOnlyOnRootTableWhenFetchingRootEntity() + { + $this->loadCompanyJoinedSubclassFixtureData(); + $this->assertEquals(3, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson')->findAll())); + $this->assertEquals(3, count($this->_em->createQuery("SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp")->getResult())); + + // Enable the filter + $this->usePersonNameFilter('Guilh%'); + + $persons = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson')->findAll(); + $this->assertEquals(1, count($persons)); + $this->assertEquals("Guilherme", $persons[0]->getName()); + + $this->assertEquals(1, count($this->_em->createQuery("SELECT cp FROM Doctrine\Tests\Models\Company\CompanyPerson cp")->getResult())); + } + + private function loadCompanyJoinedSubclassFixtureData() + { + $manager = new CompanyManager; + $manager->setName('Roman'); + $manager->setTitle('testlead'); + $manager->setSalary(42); + $manager->setDepartment('persisters'); + + $manager2 = new CompanyManager; + $manager2->setName('Guilherme'); + $manager2->setTitle('devlead'); + $manager2->setSalary(42); + $manager2->setDepartment('parsers'); + + $person = new CompanyPerson; + $person->setName('Benjamin'); + + $this->_em->persist($manager); + $this->_em->persist($manager2); + $this->_em->persist($person); + $this->_em->flush(); + $this->_em->clear(); + } + + public function testSingleTableInheritance_FilterOnlyOnRootTableWhenFetchingSubEntity() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + // Persister + $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); + // SQLWalker + $this->assertEquals(2, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc")->getResult())); + + // Enable the filter + $conf = $this->_em->getConfiguration(); + $conf->addFilter("completed_contract", "\Doctrine\Tests\ORM\Functional\CompletedContractFilter"); + $this->_em->getFilters() + ->enable("completed_contract") + ->setParameter("completed", true, DBALType::BOOLEAN); + + $this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); + $this->assertEquals(1, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract cfc")->getResult())); + } + + public function testSingleTableInheritance_FilterOnlyOnRootTableWhenFetchingRootEntity() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + $this->assertEquals(4, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); + $this->assertEquals(4, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc")->getResult())); + + // Enable the filter + $conf = $this->_em->getConfiguration(); + $conf->addFilter("completed_contract", "\Doctrine\Tests\ORM\Functional\CompletedContractFilter"); + $this->_em->getFilters() + ->enable("completed_contract") + ->setParameter("completed", true, DBALType::BOOLEAN); + + $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); + $this->assertEquals(2, count($this->_em->createQuery("SELECT cfc FROM Doctrine\Tests\Models\Company\CompanyFlexContract cfc")->getResult())); + } + + private function loadCompanySingleTableInheritanceFixtureData() + { + $contract1 = new CompanyFlexUltraContract; + $contract2 = new CompanyFlexUltraContract; + $contract2->markCompleted(); + + $contract3 = new CompanyFlexContract; + $contract4 = new CompanyFlexContract; + $contract4->markCompleted(); + + $manager = new CompanyManager; + $manager->setName('Alexander'); + $manager->setSalary(42); + $manager->setDepartment('Doctrine'); + $manager->setTitle('Filterer'); + + $manager2 = new CompanyManager; + $manager2->setName('Benjamin'); + $manager2->setSalary(1337); + $manager2->setDepartment('Doctrine'); + $manager2->setTitle('Maintainer'); + + $contract1->addManager($manager); + $contract2->addManager($manager); + $contract3->addManager($manager); + $contract4->addManager($manager); + + $contract1->addManager($manager2); + + $contract1->setSalesPerson($manager); + $contract2->setSalesPerson($manager); + + $this->_em->persist($manager); + $this->_em->persist($manager2); + $this->_em->persist($contract1); + $this->_em->persist($contract2); + $this->_em->persist($contract3); + $this->_em->persist($contract4); + $this->_em->flush(); + $this->_em->clear(); + + $this->managerId = $manager->getId(); + $this->managerId2 = $manager2->getId(); + $this->contractId1 = $contract1->getId(); + $this->contractId2 = $contract2->getId(); + } + + private function useCompletedContractFilter() + { + $conf = $this->_em->getConfiguration(); + $conf->addFilter("completed_contract", "\Doctrine\Tests\ORM\Functional\CompletedContractFilter"); + $this->_em->getFilters() + ->enable("completed_contract") + ->setParameter("completed", true, DBALType::BOOLEAN); + } + + public function testManyToMany_ExtraLazyCountWithFilterOnSTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); + + $this->assertFalse($manager->managedContracts->isInitialized()); + $this->assertEquals(4, count($manager->managedContracts)); + + // Enable the filter + $this->useCompletedContractFilter(); + + $this->assertFalse($manager->managedContracts->isInitialized()); + $this->assertEquals(2, count($manager->managedContracts)); + } + + public function testManyToMany_ExtraLazyContainsWithFilterOnSTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); + $contract1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId1); + $contract2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId2); + + $this->assertFalse($manager->managedContracts->isInitialized()); + $this->assertTrue($manager->managedContracts->contains($contract1)); + $this->assertTrue($manager->managedContracts->contains($contract2)); + + // Enable the filter + $this->useCompletedContractFilter(); + + $this->assertFalse($manager->managedContracts->isInitialized()); + $this->assertFalse($manager->managedContracts->contains($contract1)); + $this->assertTrue($manager->managedContracts->contains($contract2)); + } + + public function testManyToMany_ExtraLazySliceWithFilterOnSTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); + + $this->assertFalse($manager->managedContracts->isInitialized()); + $this->assertEquals(4, count($manager->managedContracts->slice(0, 10))); + + // Enable the filter + $this->useCompletedContractFilter(); + + $this->assertFalse($manager->managedContracts->isInitialized()); + $this->assertEquals(2, count($manager->managedContracts->slice(0, 10))); + } + + private function usePersonNameFilter($name) + { + // Enable the filter + $conf = $this->_em->getConfiguration(); + $conf->addFilter("person_name", "\Doctrine\Tests\ORM\Functional\CompanyPersonNameFilter"); + $this->_em->getFilters() + ->enable("person_name") + ->setParameter("name", $name, DBALType::STRING); + } + + public function testManyToMany_ExtraLazyCountWithFilterOnCTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); + + $this->assertFalse($contract->managers->isInitialized()); + $this->assertEquals(2, count($contract->managers)); + + // Enable the filter + $this->usePersonNameFilter('Benjamin'); + + $this->assertFalse($contract->managers->isInitialized()); + $this->assertEquals(1, count($contract->managers)); + } + + public function testManyToMany_ExtraLazyContainsWithFilterOnCTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); + $manager1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); + $manager2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId2); + + $this->assertFalse($contract->managers->isInitialized()); + $this->assertTrue($contract->managers->contains($manager1)); + $this->assertTrue($contract->managers->contains($manager2)); + + // Enable the filter + $this->usePersonNameFilter('Benjamin'); + + $this->assertFalse($contract->managers->isInitialized()); + $this->assertFalse($contract->managers->contains($manager1)); + $this->assertTrue($contract->managers->contains($manager2)); + } + + public function testManyToMany_ExtraLazySliceWithFilterOnCTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $this->contractId1); + + $this->assertFalse($contract->managers->isInitialized()); + $this->assertEquals(2, count($contract->managers->slice(0, 10))); + + // Enable the filter + $this->usePersonNameFilter('Benjamin'); + + $this->assertFalse($contract->managers->isInitialized()); + $this->assertEquals(1, count($contract->managers->slice(0, 10))); + } + + public function testOneToMany_ExtraLazyCountWithFilterOnSTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); + + $this->assertFalse($manager->soldContracts->isInitialized()); + $this->assertEquals(2, count($manager->soldContracts)); + + // Enable the filter + $this->useCompletedContractFilter(); + + $this->assertFalse($manager->soldContracts->isInitialized()); + $this->assertEquals(1, count($manager->soldContracts)); + } + + public function testOneToMany_ExtraLazyContainsWithFilterOnSTI() + { + $this->loadCompanySingleTableInheritanceFixtureData(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); + $contract1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId1); + $contract2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->contractId2); + + $this->assertFalse($manager->soldContracts->isInitialized()); + $this->assertTrue($manager->soldContracts->contains($contract1)); + $this->assertTrue($manager->soldContracts->contains($contract2)); + + // Enable the filter + $this->useCompletedContractFilter(); + + $this->assertFalse($manager->soldContracts->isInitialized()); + $this->assertFalse($manager->soldContracts->contains($contract1)); + $this->assertTrue($manager->soldContracts->contains($contract2)); + } + + public function testOneToMany_ExtraLazySliceWithFilterOnSTI() + { + + $this->loadCompanySingleTableInheritanceFixtureData(); + + $manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $this->managerId); + + $this->assertFalse($manager->soldContracts->isInitialized()); + $this->assertEquals(2, count($manager->soldContracts->slice(0, 10))); + + // Enable the filter + $this->useCompletedContractFilter(); + + $this->assertFalse($manager->soldContracts->isInitialized()); + $this->assertEquals(1, count($manager->soldContracts->slice(0, 10))); + } + private function loadCompanyOrganizationEventJoinedSubclassFixtureData() + { + $organization = new CompanyOrganization; + + $event1 = new CompanyAuction; + $event1->setData('foo'); + + $event2 = new CompanyAuction; + $event2->setData('bar'); + + $organization->addEvent($event1); + $organization->addEvent($event2); + + $this->_em->persist($organization); + $this->_em->flush(); + $this->_em->clear(); + + $this->organizationId = $organization->getId(); + $this->eventId1 = $event1->getId(); + $this->eventId2 = $event2->getId(); + } + + private function useCompanyEventIdFilter() + { + // Enable the filter + $conf = $this->_em->getConfiguration(); + $conf->addFilter("event_id", "\Doctrine\Tests\ORM\Functional\CompanyEventFilter"); + $this->_em->getFilters() + ->enable("event_id") + ->setParameter("id", $this->eventId2); + } + + + public function testOneToMany_ExtraLazyCountWithFilterOnCTI() + { + $this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); + + $organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); + + $this->assertFalse($organization->events->isInitialized()); + $this->assertEquals(2, count($organization->events)); + + // Enable the filter + $this->useCompanyEventIdFilter(); + + $this->assertFalse($organization->events->isInitialized()); + $this->assertEquals(1, count($organization->events)); + } + + public function testOneToMany_ExtraLazyContainsWithFilterOnCTI() + { + $this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); + + $organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); + + $event1 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyEvent', $this->eventId1); + $event2 = $this->_em->find('Doctrine\Tests\Models\Company\CompanyEvent', $this->eventId2); + + $this->assertFalse($organization->events->isInitialized()); + $this->assertTrue($organization->events->contains($event1)); + $this->assertTrue($organization->events->contains($event2)); + + // Enable the filter + $this->useCompanyEventIdFilter(); + + $this->assertFalse($organization->events->isInitialized()); + $this->assertFalse($organization->events->contains($event1)); + $this->assertTrue($organization->events->contains($event2)); + } + + public function testOneToMany_ExtraLazySliceWithFilterOnCTI() + { + $this->loadCompanyOrganizationEventJoinedSubclassFixtureData(); + + $organization = $this->_em->find('Doctrine\Tests\Models\Company\CompanyOrganization', $this->organizationId); + + $this->assertFalse($organization->events->isInitialized()); + $this->assertEquals(2, count($organization->events->slice(0, 10))); + + // Enable the filter + $this->useCompanyEventIdFilter(); + + $this->assertFalse($organization->events->isInitialized()); + $this->assertEquals(1, count($organization->events->slice(0, 10))); + } +} + +class MySoftDeleteFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + { + if ($targetEntity->name != "MyEntity\SoftDeleteNewsItem") { + return ""; + } + + return $targetTableAlias.'.deleted = 0'; + } +} + +class MyLocaleFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + { + if (!in_array("LocaleAware", $targetEntity->reflClass->getInterfaceNames())) { + return ""; + } + + return $targetTableAlias.'.locale = ' . $this->getParameter('locale'); // getParam uses connection to quote the value. + } +} + +class CMSCountryFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + { + if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsAddress") { + return ""; + } + + return $targetTableAlias.'.country = ' . $this->getParameter('country'); // getParam uses connection to quote the value. + } +} + +class CMSGroupPrefixFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + { + if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsGroup") { + return ""; + } + + return $targetTableAlias.'.name LIKE ' . $this->getParameter('prefix'); // getParam uses connection to quote the value. + } +} + +class CMSArticleTopicFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) + { + if ($targetEntity->name != "Doctrine\Tests\Models\CMS\CmsArticle") { + return ""; + } + + return $targetTableAlias.'.topic = ' . $this->getParameter('topic'); // getParam uses connection to quote the value. + } +} + +class CompanyPersonNameFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') + { + if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyPerson") { + return ""; + } + + return $targetTableAlias.'.name LIKE ' . $this->getParameter('name'); + } +} + +class CompletedContractFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') + { + if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyContract") { + return ""; + } + + return $targetTableAlias.'.completed = ' . $this->getParameter('completed'); + } +} + +class CompanyEventFilter extends SQLFilter +{ + public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias, $targetTable = '') + { + if ($targetEntity->name != "Doctrine\Tests\Models\Company\CompanyEvent") { + return ""; + } + + return $targetTableAlias.'.id = ' . $this->getParameter('id'); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php new file mode 100644 index 0000000..a1e6dac --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/CompanySchemaTest.php @@ -0,0 +1,68 @@ +useModelSet('company'); + parent::setUp(); + } + + /** + * @group DDC-966 + * @return Schema + */ + public function testGeneratedSchema() + { + $schema = $this->_em->getConnection()->getSchemaManager()->createSchema(); + + $this->assertTrue($schema->hasTable('company_contracts')); + + return $schema; + } + + /** + * @group DDC-966 + * @depends testGeneratedSchema + */ + public function testSingleTableInheritance(Schema $schema) + { + $table = $schema->getTable('company_contracts'); + + // Check nullability constraints + $this->assertTrue($table->getColumn('id')->getNotnull()); + $this->assertTrue($table->getColumn('completed')->getNotnull()); + $this->assertFalse($table->getColumn('salesPerson_id')->getNotnull()); + $this->assertTrue($table->getColumn('discr')->getNotnull()); + $this->assertFalse($table->getColumn('fixPrice')->getNotnull()); + $this->assertFalse($table->getColumn('hoursWorked')->getNotnull()); + $this->assertFalse($table->getColumn('pricePerHour')->getNotnull()); + $this->assertFalse($table->getColumn('maxPrice')->getNotnull()); + } + + /** + * @group DBAL-115 + */ + public function testDropPartSchemaWithForeignKeys() + { + if (!$this->_em->getConnection()->getDatabasePlatform()->supportsForeignKeyConstraints()) { + $this->markTestSkipped("Foreign Key test"); + } + + $sql = $this->_schemaTool->getDropSchemaSQL(array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyManager'), + )); + $this->assertEquals(4, count($sql)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php new file mode 100644 index 0000000..eae3d4b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/DDC214Test.php @@ -0,0 +1,90 @@ +_em->getConnection(); + + if (strpos($conn->getDriver()->getName(), "sqlite") !== false) { + $this->markTestSkipped('SQLite does not support ALTER TABLE statements.'); + } + $this->schemaTool = new Tools\SchemaTool($this->_em); + } + + /** + * @group DDC-214 + */ + public function testCmsAddressModel() + { + $this->classes = array( + 'Doctrine\Tests\Models\CMS\CmsUser', + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'Doctrine\Tests\Models\CMS\CmsAddress', + 'Doctrine\Tests\Models\CMS\CmsGroup', + 'Doctrine\Tests\Models\CMS\CmsArticle' + ); + + $this->assertCreatedSchemaNeedsNoUpdates($this->classes); + } + + /** + * @group DDC-214 + */ + public function testCompanyModel() + { + $this->classes = array( + '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' + ); + + $this->assertCreatedSchemaNeedsNoUpdates($this->classes); + } + + public function assertCreatedSchemaNeedsNoUpdates($classes) + { + $classMetadata = array(); + foreach ($classes AS $class) { + $classMetadata[] = $this->_em->getClassMetadata($class); + } + + try { + $this->schemaTool->createSchema($classMetadata); + } catch(\Exception $e) { + // was already created + } + + $sm = $this->_em->getConnection()->getSchemaManager(); + + $fromSchema = $sm->createSchema(); + $toSchema = $this->schemaTool->getSchemaFromMetadata($classMetadata); + + $comparator = new \Doctrine\DBAL\Schema\Comparator(); + $schemaDiff = $comparator->compare($fromSchema, $toSchema); + + $sql = $schemaDiff->toSql($this->_em->getConnection()->getDatabasePlatform()); + $sql = array_filter($sql, function($sql) { return strpos($sql, 'DROP') === false; }); + + $this->assertEquals(0, count($sql), "SQL: " . implode(PHP_EOL, $sql)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php new file mode 100644 index 0000000..0c1f0ae --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/MySqlSchemaToolTest.php @@ -0,0 +1,92 @@ +_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of mysql.'); + } + } + + public function testGetCreateSchemaSql() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + $this->assertEquals("CREATE TABLE cms_addresses (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, UNIQUE INDEX UNIQ_ACAC157BA76ED395 (user_id), PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]); + $this->assertEquals("CREATE TABLE cms_users (id INT AUTO_INCREMENT NOT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_3AF03EC5F85E0677 (username), UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 (email_id), PRIMARY KEY(id)) ENGINE = InnoDB", $sql[1]); + $this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_7EA9409AA76ED395 (user_id), INDEX IDX_7EA9409AFE54D947 (group_id), PRIMARY KEY(user_id, group_id)) ENGINE = InnoDB", $sql[2]); + $this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, INDEX IDX_F21F790FA76ED395 (user_id), PRIMARY KEY(phonenumber)) ENGINE = InnoDB", $sql[3]); + $this->assertEquals("ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)", $sql[4]); + $this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)", $sql[5]); + $this->assertEquals("ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id)", $sql[6]); + + $this->assertEquals(7, count($sql)); + } + + public function testGetCreateSchemaSql2() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\DecimalModel') + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("CREATE TABLE decimal_model (id INT AUTO_INCREMENT NOT NULL, `decimal` NUMERIC(5, 2) NOT NULL, `high_scale` NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]); + } + + public function testGetCreateSchemaSql3() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\BooleanModel') + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + $this->assertEquals(1, count($sql)); + $this->assertEquals("CREATE TABLE boolean_model (id INT AUTO_INCREMENT NOT NULL, booleanField TINYINT(1) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB", $sql[0]); + } + + /** + * @group DBAL-204 + */ + public function testGetCreateSchemaSql4() + { + $classes = array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\MysqlSchemaNamespacedEntity') + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + $this->assertEquals(0, count($sql)); + } + +} + +/** + * @Entity + * @Table("namespace.entity") + */ +class MysqlSchemaNamespacedEntity +{ + /** @Column(type="integer") @Id @GeneratedValue */ + public $id; +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php new file mode 100644 index 0000000..79e7af9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaTool/PostgreSqlSchemaToolTest.php @@ -0,0 +1,108 @@ +_em->getConnection()->getDatabasePlatform()->getName() !== 'postgresql') { + $this->markTestSkipped('The ' . __CLASS__ .' requires the use of postgresql.'); + } + } + + public function testPostgresMetadataSequenceIncrementedBy10() + { + $address = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); + $this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']); + } + + public function testGetCreateSchemaSql() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + $sqlCount = count($sql); + + $this->assertEquals("CREATE TABLE cms_addresses (id INT NOT NULL, user_id INT DEFAULT NULL, country VARCHAR(50) NOT NULL, zip VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, PRIMARY KEY(id))", array_shift($sql)); + $this->assertEquals("CREATE UNIQUE INDEX UNIQ_ACAC157BA76ED395 ON cms_addresses (user_id)", array_shift($sql)); + $this->assertEquals("CREATE TABLE cms_users (id INT NOT NULL, email_id INT DEFAULT NULL, status VARCHAR(50) DEFAULT NULL, username VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))", array_shift($sql)); + $this->assertEquals("CREATE UNIQUE INDEX UNIQ_3AF03EC5F85E0677 ON cms_users (username)", array_shift($sql)); + $this->assertEquals("CREATE UNIQUE INDEX UNIQ_3AF03EC5A832C1C9 ON cms_users (email_id)", array_shift($sql)); + $this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))", array_shift($sql)); + $this->assertEquals("CREATE INDEX IDX_7EA9409AA76ED395 ON cms_users_groups (user_id)", array_shift($sql)); + $this->assertEquals("CREATE INDEX IDX_7EA9409AFE54D947 ON cms_users_groups (group_id)", array_shift($sql)); + $this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))", array_shift($sql)); + $this->assertEquals("CREATE INDEX IDX_F21F790FA76ED395 ON cms_phonenumbers (user_id)", array_shift($sql)); + $this->assertEquals("CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1", array_shift($sql)); + $this->assertEquals("CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1", array_shift($sql)); + $this->assertEquals("ALTER TABLE cms_addresses ADD CONSTRAINT FK_ACAC157BA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); + $this->assertEquals("ALTER TABLE cms_users ADD CONSTRAINT FK_3AF03EC5A832C1C9 FOREIGN KEY (email_id) REFERENCES cms_emails (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); + $this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); + $this->assertEquals("ALTER TABLE cms_users_groups ADD CONSTRAINT FK_7EA9409AFE54D947 FOREIGN KEY (group_id) REFERENCES cms_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); + $this->assertEquals("ALTER TABLE cms_phonenumbers ADD CONSTRAINT FK_F21F790FA76ED395 FOREIGN KEY (user_id) REFERENCES cms_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE", array_shift($sql)); + + $this->assertEquals(array(), $sql, "SQL Array should be empty now."); + $this->assertEquals(17, $sqlCount, "Total of 17 queries should be executed"); + } + + public function testGetCreateSchemaSql2() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\DecimalModel') + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + $this->assertEquals(2, count($sql)); + + $this->assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]); + $this->assertEquals("CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]); + } + + public function testGetCreateSchemaSql3() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\Generic\BooleanModel') + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + $this->assertEquals(2, count($sql)); + $this->assertEquals("CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))", $sql[0]); + $this->assertEquals("CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]); + } + + public function testGetDropSchemaSql() + { + $classes = array( + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), + $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), + ); + + $tool = new SchemaTool($this->_em); + $sql = $tool->getDropSchemaSQL($classes); + + $this->assertEquals(14, count($sql)); + $dropSequenceSQLs = 0; + foreach ($sql AS $stmt) { + if (strpos($stmt, "DROP SEQUENCE") === 0) { + $dropSequenceSQLs++; + } + } + $this->assertEquals(4, $dropSequenceSQLs, "Expect 4 sequences to be dropped."); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php new file mode 100644 index 0000000..a575db0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SchemaValidatorTest.php @@ -0,0 +1,50 @@ + $classes) { + if ($modelSet == "customtype") { + continue; + } + $modelSets[] = array($modelSet); + } + return $modelSets; + } + + /** + * @dataProvider dataValidateModelSets + */ + public function testValidateModelSets($modelSet) + { + $validator = new SchemaValidator($this->_em); + + $classes = array(); + foreach (self::$_modelSets[$modelSet] as $className) { + $classes[] = $this->_em->getClassMetadata($className); + } + + foreach ($classes as $class) { + $ce = $validator->validateClass($class); + + foreach ($ce as $key => $error) { + if (strpos($error, "must be private or protected. Public fields may break lazy-loading.") !== false) { + unset($ce[$key]); + } + } + + $this->assertEquals(0, count($ce), "Invalid Modelset: " . $modelSet . " class " . $class->name . ": ". implode("\n", $ce)); + } + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php new file mode 100644 index 0000000..8a71cc1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SequenceGeneratorTest.php @@ -0,0 +1,53 @@ +_em->getConnection()->getDatabasePlatform()->supportsSequences()) { + $this->markTestSkipped('Only working for Databases that support sequences.'); + } + + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\SequenceEntity'), + )); + } catch(\Exception $e) { + + } + } + + public function testHighAllocationSizeSequence() + { + for ($i = 0; $i < 11; $i++) { + $e = new SequenceEntity(); + $this->_em->persist($e); + } + $this->_em->flush(); + } +} + +/** + * @Entity + */ +class SequenceEntity +{ + /** + * @Id + * @column(type="integer") + * @GeneratedValue(strategy="SEQUENCE") + * @SequenceGenerator(allocationSize=5,sequenceName="person_id_seq") + */ + public $id; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php new file mode 100644 index 0000000..7271f42 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -0,0 +1,370 @@ +useModelSet('company'); + parent::setUp(); + } + + public function persistRelatedEmployees() + { + $this->salesPerson = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $this->salesPerson->setName('Poor Sales Guy'); + $this->salesPerson->setDepartment('Sales'); + $this->salesPerson->setSalary(100); + + $engineer1 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer1->setName('Roman B.'); + $engineer1->setDepartment('IT'); + $engineer1->setSalary(100); + $this->engineers[] = $engineer1; + + $engineer2 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer2->setName('Jonathan W.'); + $engineer2->setDepartment('IT'); + $engineer2->setSalary(100); + $this->engineers[] = $engineer2; + + $engineer3 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer3->setName('Benjamin E.'); + $engineer3->setDepartment('IT'); + $engineer3->setSalary(100); + $this->engineers[] = $engineer3; + + $engineer4 = new \Doctrine\Tests\Models\Company\CompanyEmployee(); + $engineer4->setName('Guilherme B.'); + $engineer4->setDepartment('IT'); + $engineer4->setSalary(100); + $this->engineers[] = $engineer4; + + $this->_em->persist($this->salesPerson); + $this->_em->persist($engineer1); + $this->_em->persist($engineer2); + $this->_em->persist($engineer3); + $this->_em->persist($engineer4); + } + + public function loadFullFixture() + { + $this->persistRelatedEmployees(); + + $this->fix = new \Doctrine\Tests\Models\Company\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->setSalesPerson($this->salesPerson); + $this->flex->setHoursWorked(100); + $this->flex->setPricePerHour(100); + $this->flex->addEngineer($this->engineers[2]); + $this->flex->addEngineer($this->engineers[1]); + $this->flex->addEngineer($this->engineers[3]); + $this->flex->markCompleted(); + + $this->ultra = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); + $this->ultra->setSalesPerson($this->salesPerson); + $this->ultra->setHoursWorked(150); + $this->ultra->setPricePerHour(150); + $this->ultra->setMaxPrice(7000); + $this->ultra->addEngineer($this->engineers[3]); + $this->ultra->addEngineer($this->engineers[0]); + + $this->_em->persist($this->fix); + $this->_em->persist($this->flex); + $this->_em->persist($this->ultra); + $this->_em->flush(); + $this->_em->clear(); + } + + public function testPersistChildOfBaseClass() + { + $this->persistRelatedEmployees(); + + $fixContract = new \Doctrine\Tests\Models\Company\CompanyFixContract(); + $fixContract->setFixPrice(1000); + $fixContract->setSalesPerson($this->salesPerson); + + $this->_em->persist($fixContract); + $this->_em->flush(); + $this->_em->clear(); + + $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFixContract', $fixContract->getId()); + + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); + $this->assertEquals(1000, $contract->getFixPrice()); + $this->assertEquals($this->salesPerson->getId(), $contract->getSalesPerson()->getId()); + } + + public function testPersistDeepChildOfBaseClass() + { + $this->persistRelatedEmployees(); + + $ultraContract = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); + $ultraContract->setSalesPerson($this->salesPerson); + $ultraContract->setHoursWorked(100); + $ultraContract->setPricePerHour(50); + $ultraContract->setMaxPrice(7000); + + $this->_em->persist($ultraContract); + $this->_em->flush(); + $this->_em->clear(); + + $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $ultraContract->getId()); + + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFlexUltraContract', $contract); + $this->assertEquals(7000, $contract->getMaxPrice()); + $this->assertEquals(100, $contract->getHoursWorked()); + $this->assertEquals(50, $contract->getPricePerHour()); + } + + public function testChildClassLifecycleUpdate() + { + $this->loadFullFixture(); + + $fix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); + $fix->setFixPrice(2500); + + $this->_em->flush(); + $this->_em->clear(); + + $newFix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); + $this->assertEquals(2500, $newFix->getFixPrice()); + } + + public function testChildClassLifecycleRemove() + { + $this->loadFullFixture(); + + $fix = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); + $this->_em->remove($fix); + $this->_em->flush(); + + $this->assertNull($this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId())); + } + + public function testFindAllForAbstractBaseClass() + { + $this->loadFullFixture(); + $contracts = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyContract')->findAll(); + + $this->assertEquals(3, count($contracts)); + $this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); + } + + public function testFindAllForChildClass() + { + $this->loadFullFixture(); + + $this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFixContract')->findAll())); + $this->assertEquals(2, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexContract')->findAll())); + $this->assertEquals(1, count($this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyFlexUltraContract')->findAll())); + } + + public function testFindForAbstractBaseClass() + { + $this->loadFullFixture(); + + $contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); + + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); + $this->assertEquals(1000, $contract->getFixPrice()); + } + + public function testQueryForAbstractBaseClass() + { + $this->loadFullFixture(); + + $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); + + $this->assertEquals(3, count($contracts)); + $this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); + } + + public function testQueryForChildClass() + { + $this->loadFullFixture(); + + $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c')->getResult())); + $this->assertEquals(2, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexContract c')->getResult())); + $this->assertEquals(1, count($this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract c')->getResult())); + } + + public function testQueryBaseClassWithJoin() + { + $this->loadFullFixture(); + + $contracts = $this->_em->createQuery('SELECT c, p FROM Doctrine\Tests\Models\Company\CompanyContract c JOIN c.salesPerson p')->getResult(); + $this->assertEquals(3, count($contracts)); + $this->assertContainsOnly('Doctrine\Tests\Models\Company\CompanyContract', $contracts); + } + + public function testQueryScalarWithDiscrimnatorValue() + { + $this->loadFullFixture(); + + $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c ORDER BY c.id')->getScalarResult(); + + $discrValues = \array_map(function($a) { + return $a['c_discr']; + }, $contracts); + + sort($discrValues); + + $this->assertEquals(array('fix', 'flexible', 'flexultra'), $discrValues); + } + + public function testQueryChildClassWithCondition() + { + $this->loadFullFixture(); + + $dql = 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyFixContract c WHERE c.fixPrice = ?1'; + $contract = $this->_em->createQuery($dql)->setParameter(1, 1000)->getSingleResult(); + + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $contract); + $this->assertEquals(1000, $contract->getFixPrice()); + } + + public function testUpdateChildClassWithCondition() + { + $this->loadFullFixture(); + + $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyFlexContract c SET c.hoursWorked = c.hoursWorked * 2 WHERE c.hoursWorked = 150'; + $affected = $this->_em->createQuery($dql)->execute(); + + $this->assertEquals(1, $affected); + + $flexContract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->flex->getId()); + $ultraContract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyContract', $this->ultra->getId()); + + $this->assertEquals(300, $ultraContract->getHoursWorked()); + $this->assertEquals(100, $flexContract->getHoursWorked()); + } + + public function testUpdateBaseClassWithCondition() + { + $this->loadFullFixture(); + + $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = true WHERE c.completed = false'; + $affected = $this->_em->createQuery($dql)->execute(); + + $this->assertEquals(1, $affected); + + $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyContract c SET c.completed = false'; + $affected = $this->_em->createQuery($dql)->execute(); + + $this->assertEquals(3, $affected); + } + + public function testDeleteByChildClassCondition() + { + $this->loadFullFixture(); + + $dql = 'DELETE Doctrine\Tests\Models\Company\CompanyFlexContract c'; + $affected = $this->_em->createQuery($dql)->execute(); + + $this->assertEquals(2, $affected); + } + + public function testDeleteByBaseClassCondition() + { + $this->loadFullFixture(); + + $dql = "DELETE Doctrine\Tests\Models\Company\CompanyContract c WHERE c.completed = true"; + $affected = $this->_em->createQuery($dql)->execute(); + + $this->assertEquals(2, $affected); + + $contracts = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c')->getResult(); + $this->assertEquals(1, count($contracts)); + + $this->assertFalse($contracts[0]->isCompleted(), "Only non completed contracts should be left."); + } + + /** + * @group DDC-130 + */ + public function testDeleteJoinTableRecords() + { + $this->loadFullFixture(); + + // remove managed copy of the fix contract + $this->_em->remove($this->_em->find(get_class($this->fix), $this->fix->getId())); + $this->_em->flush(); + + $this->assertNull($this->_em->find(get_class($this->fix), $this->fix->getId()), "Contract should not be present in the database anymore."); + } + + /** + * @group DDC-817 + */ + public function testFindByAssociation() + { + $this->loadFullFixture(); + + $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyContract"); + $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); + $this->assertEquals(3, count($contracts), "There should be 3 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyContract'"); + + $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFixContract"); + $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); + $this->assertEquals(1, count($contracts), "There should be 1 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFixContract'"); + + $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFlexContract"); + $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); + $this->assertEquals(2, count($contracts), "There should be 2 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexContract'"); + + $repos = $this->_em->getRepository("Doctrine\Tests\Models\Company\CompanyFlexUltraContract"); + $contracts = $repos->findBy(array('salesPerson' => $this->salesPerson->getId())); + $this->assertEquals(1, count($contracts), "There should be 1 entities related to " . $this->salesPerson->getId() . " for 'Doctrine\Tests\Models\Company\CompanyFlexUltraContract'"); + } + + /** + * @group DDC-834 + */ + public function testGetReferenceEntityWithSubclasses() + { + $this->loadFullFixture(); + + $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyContract', $this->fix->getId()); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "Cannot Request a proxy from a class that has subclasses."); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyContract', $ref); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyFixContract', $ref, "Direct fetch of the reference has to load the child class Emplyoee directly."); + $this->_em->clear(); + + $ref = $this->_em->getReference('Doctrine\Tests\Models\Company\CompanyFixContract', $this->fix->getId()); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $ref, "A proxy can be generated only if no subclasses exists for the requested reference."); + } + + /** + * @group DDC-952 + */ + public function testEagerLoadInheritanceHierachy() + { + $this->loadFullFixture(); + + $dql = 'SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1'; + $contract = $this->_em->createQuery($dql) + ->setFetchMode('Doctrine\Tests\Models\Company\CompanyFixContract', 'salesPerson', ClassMetadata::FETCH_EAGER) + ->setParameter(1, $this->fix->getId()) + ->getSingleResult(); + + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $contract->getSalesPerson()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php new file mode 100644 index 0000000..de103eb --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/StandardEntityPersisterTest.php @@ -0,0 +1,110 @@ + + */ +class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() + { + $this->useModelSet('ecommerce'); + parent::setUp(); + } + + public function testAcceptsForeignKeysAsCriteria() + { + $customer = new ECommerceCustomer(); + $customer->setName('John Doe'); + $cart = new ECommerceCart(); + $cart->setPayment('Credit card'); + $customer->setCart($cart); + $this->_em->persist($customer); + $this->_em->flush(); + $this->_em->clear(); + $cardId = $cart->getId(); + unset($cart); + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); + + $persister = $this->_em->getUnitOfWork()->getEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceCart'); + $newCart = new ECommerceCart(); + $this->_em->getUnitOfWork()->registerManaged($newCart, array('id' => $cardId), array()); + $persister->load(array('customer_id' => $customer->getId()), $newCart, $class->associationMappings['customer']); + $this->assertEquals('Credit card', $newCart->getPayment()); + } + + /** + * Ticket #2478 from Damon Jones (dljones) + */ + public function testAddPersistRetrieve() + { + $f1 = new ECommerceFeature; + $f1->setDescription('AC-3'); + + $f2 = new ECommerceFeature; + $f2->setDescription('DTS'); + + $p = new ECommerceProduct; + $p->addFeature($f1); + $p->addfeature($f2); + $this->_em->persist($p); + + $this->_em->flush(); + + $this->assertEquals(2, count($p->getFeatures())); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures()); + + $q = $this->_em->createQuery( + 'SELECT p, f + FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p + JOIN p.features f' + ); + + $res = $q->getResult(); + + $this->assertEquals(2, count($p->getFeatures())); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures()); + + // Check that the features are the same instances still + foreach ($p->getFeatures() as $feature) { + if ($feature->getDescription() == 'AC-3') { + $this->assertTrue($feature === $f1); + } else { + $this->assertTrue($feature === $f2); + } + } + + // Now we test how Hydrator affects IdentityMap + // (change from ArrayCollection to PersistentCollection) + $f3 = new ECommerceFeature(); + $f3->setDescription('XVID'); + $p->addFeature($f3); + + // Now we persist the Feature #3 + $this->_em->persist($p); + $this->_em->flush(); + + $q = $this->_em->createQuery( + 'SELECT p, f + FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p + JOIN p.features f' + ); + + $res = $q->getResult(); + + // Persisted Product now must have 3 Feature items + $this->assertEquals(3, count($res[0]->getFeatures())); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php new file mode 100644 index 0000000..93dc0ee --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1040Test.php @@ -0,0 +1,81 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testReuseNamedEntityParameter() + { + $user = new CmsUser(); + $user->name = "John Galt"; + $user->username = "jgalt"; + $user->status = "inactive"; + + $article = new CmsArticle(); + $article->topic = "This is John Galt speaking!"; + $article->text = "Yadda Yadda!"; + $article->setAuthor($user); + + $this->_em->persist($user); + $this->_em->persist($article); + $this->_em->flush(); + + $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = :author"; + $this->_em->createQuery($dql) + ->setParameter('author', $user) + ->getResult(); + + $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.user = :author AND a.user = :author"; + $this->_em->createQuery($dql) + ->setParameter('author', $user) + ->getResult(); + + $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = :topic AND a.user = :author AND a.user = :author"; + $farticle = $this->_em->createQuery($dql) + ->setParameter('author', $user) + ->setParameter('topic', 'This is John Galt speaking!') + ->getSingleResult(); + + $this->assertSame($article, $farticle); + } + + public function testUseMultiplePositionalParameters() + { + $user = new CmsUser(); + $user->name = "John Galt"; + $user->username = "jgalt"; + $user->status = "inactive"; + + $article = new CmsArticle(); + $article->topic = "This is John Galt speaking!"; + $article->text = "Yadda Yadda!"; + $article->setAuthor($user); + + $this->_em->persist($user); + $this->_em->persist($article); + $this->_em->flush(); + + $dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = ?1 AND a.user = ?2 AND a.user = ?3"; + $farticle = $this->_em->createQuery($dql) + ->setParameter(1, 'This is John Galt speaking!') + ->setParameter(2, $user) + ->setParameter(3, $user) + ->getSingleResult(); + + $this->assertSame($article, $farticle); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php new file mode 100644 index 0000000..5b30c04 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php @@ -0,0 +1,33 @@ +useModelSet('company'); + parent::setUp(); + } + + public function testGrabWrongSubtypeReturnsNull() + { + $fix = new \Doctrine\Tests\Models\Company\CompanyFixContract(); + $fix->setFixPrice(2000); + + $this->_em->persist($fix); + $this->_em->flush(); + + $id = $fix->getId(); + + $this->assertNull($this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexContract', $id)); + $this->assertNull($this->_em->getReference('Doctrine\Tests\Models\Company\CompanyFlexContract', $id)); + $this->assertNull($this->_em->getPartialReference('Doctrine\Tests\Models\Company\CompanyFlexContract', $id)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php new file mode 100644 index 0000000..31bd835 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php @@ -0,0 +1,36 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testChangeSetPlusWeirdPHPCastingIntCastingRule() + { + $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user->name = "John Galt"; + $user->username = "jgalt"; + $user->status = "+44"; + + $this->_em->persist($user); + $this->_em->flush(); + + $user->status = "44"; + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find("Doctrine\Tests\Models\CMS\CmsUser", $user->id); + $this->assertSame("44", $user->status); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php new file mode 100644 index 0000000..31c0733 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1050Test.php @@ -0,0 +1,37 @@ +markTestSkipped('performance skipped'); + $this->useModelSet('cms'); + parent::setUp(); + } + + public function testPerformance() + { + for ($i = 2; $i < 10000; ++$i) { + $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user->status = 'developer'; + $user->username = 'jwage'+$i; + $user->name = 'Jonathan'; + $this->_em->persist($user); + } + $this->_em->flush(); + $this->_em->clear(); + + $s = microtime(true); + $users = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php new file mode 100644 index 0000000..2b9d579 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1080Test.php @@ -0,0 +1,317 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080Foo'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080Bar'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080FooBar'), + )); + + $foo1 = new DDC1080Foo(); + $foo1->setFooTitle('foo title 1'); + $foo2 = new DDC1080Foo(); + $foo2->setFooTitle('foo title 2'); + + $bar1 = new DDC1080Bar(); + $bar1->setBarTitle('bar title 1'); + $bar2 = new DDC1080Bar(); + $bar2->setBarTitle('bar title 2'); + $bar3 = new DDC1080Bar(); + $bar3->setBarTitle('bar title 3'); + + $foobar1 = new DDC1080FooBar(); + $foobar1->setFoo($foo1); + $foobar1->setBar($bar1); + $foobar1->setOrderNr(0); + + $foobar2 = new DDC1080FooBar(); + $foobar2->setFoo($foo1); + $foobar2->setBar($bar2); + $foobar2->setOrderNr(0); + + $foobar3 = new DDC1080FooBar(); + $foobar3->setFoo($foo1); + $foobar3->setBar($bar3); + $foobar3->setOrderNr(0); + + $this->_em->persist($foo1); + $this->_em->persist($foo2); + $this->_em->persist($bar1); + $this->_em->persist($bar2); + $this->_em->persist($bar3); + $this->_em->flush(); + + $this->_em->persist($foobar1); + $this->_em->persist($foobar2); + $this->_em->persist($foobar3); + $this->_em->flush(); + $this->_em->clear(); + + $foo = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC1080Foo', $foo1->getFooId()); + $fooBars = $foo->getFooBars(); + + $this->assertEquals(3, count($fooBars), "Should return three foobars."); + } +} + + +/** + * @Entity + * @Table(name="foo") + */ +class DDC1080Foo +{ + + /** + * @Id + * @Column(name="fooID", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $_fooID; + /** + * @Column(name="fooTitle", type="string") + */ + protected $_fooTitle; + /** + * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="_foo", + * cascade={"persist"}) + * @OrderBy({"_orderNr"="ASC"}) + */ + protected $_fooBars; + + public function __construct() + { + $this->_fooBars = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * @return the $fooID + */ + public function getFooID() + { + return $this->_fooID; + } + + /** + * @return the $fooTitle + */ + public function getFooTitle() + { + return $this->_fooTitle; + } + + /** + * @return the $fooBars + */ + public function getFooBars() + { + return $this->_fooBars; + } + + /** + * @param field_type $fooID + */ + public function setFooID($fooID) + { + $this->_fooID = $fooID; + } + + /** + * @param field_type $fooTitle + */ + public function setFooTitle($fooTitle) + { + $this->_fooTitle = $fooTitle; + } + + /** + * @param field_type $fooBars + */ + public function setFooBars($fooBars) + { + $this->_fooBars = $fooBars; + } + +} +/** + * @Entity + * @Table(name="bar") + */ +class DDC1080Bar +{ + + /** + * @Id + * @Column(name="barID", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $_barID; + /** + * @Column(name="barTitle", type="string") + */ + protected $_barTitle; + /** + * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="_bar", + * cascade={"persist"}) + * @OrderBy({"_orderNr"="ASC"}) + */ + protected $_fooBars; + + public function __construct() + { + $this->_fooBars = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * @return the $barID + */ + public function getBarID() + { + return $this->_barID; + } + + /** + * @return the $barTitle + */ + public function getBarTitle() + { + return $this->_barTitle; + } + + /** + * @return the $fooBars + */ + public function getFooBars() + { + return $this->_fooBars; + } + + /** + * @param field_type $barID + */ + public function setBarID($barID) + { + $this->_barID = $barID; + } + + /** + * @param field_type $barTitle + */ + public function setBarTitle($barTitle) + { + $this->_barTitle = $barTitle; + } + + /** + * @param field_type $fooBars + */ + public function setFooBars($fooBars) + { + $this->_fooBars = $fooBars; + } + +} + +/** + * @Table(name="fooBar") + * @Entity + */ +class DDC1080FooBar +{ + + /** + * @ManyToOne(targetEntity="DDC1080Foo") + * @JoinColumn(name="fooID", referencedColumnName="fooID") + * @Id + */ + protected $_foo = null; + /** + * @ManyToOne(targetEntity="DDC1080Bar") + * @JoinColumn(name="barID", referencedColumnName="barID") + * @Id + */ + protected $_bar = null; + /** + * @var integer orderNr + * @Column(name="orderNr", type="integer", nullable=false) + */ + protected $_orderNr = null; + + /** + * Retrieve the foo property + * + * @return DDC1080Foo + */ + public function getFoo() + { + return $this->_foo; + } + + /** + * Set the foo property + * + * @param DDC1080Foo $foo + * @return DDC1080FooBar + */ + public function setFoo($foo) + { + $this->_foo = $foo; + return $this; + } + + /** + * Retrieve the bar property + * + * @return DDC1080Bar + */ + public function getBar() + { + return $this->_bar; + } + + /** + * Set the bar property + * + * @param DDC1080Bar $bar + * @return DDC1080FooBar + */ + public function setBar($bar) + { + $this->_bar = $bar; + return $this; + } + + /** + * Retrieve the orderNr property + * + * @return integer|null + */ + public function getOrderNr() + { + return $this->_orderNr; + } + + /** + * Set the orderNr property + * + * @param integer|null $orderNr + * @return DDC1080FooBar + */ + public function setOrderNr($orderNr) + { + $this->_orderNr = $orderNr; + return $this; + } + +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php new file mode 100644 index 0000000..3e8a2fc --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -0,0 +1,99 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Engine'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Vehicle'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Car'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1113Bus'), + )); + } catch (\Exception $e) { + + } + } + + public function testIssue() + { + $car = new DDC1113Car(); + $car->engine = new DDC1113Engine(); + + $bus = new DDC1113Bus(); + $bus->engine = new DDC1113Engine(); + + $this->_em->persist($car); + $this->_em->flush(); + + $this->_em->persist($bus); + $this->_em->flush(); + + $this->_em->remove($bus); + $this->_em->remove($car); + $this->_em->flush(); + } + +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorMap({"car" = "DDC1113Car", "bus" = "DDC1113Bus"}) + */ +class DDC1113Vehicle +{ + + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + + /** + * @ManyToOne(targetEntity="DDC1113Vehicle") + */ + public $parent; + + /** @OneToOne(targetEntity="DDC1113Engine", cascade={"persist", "remove"}) */ + public $engine; + +} + +/** + * @Entity + */ +class DDC1113Car extends DDC1113Vehicle +{ + +} + +/** + * @Entity + */ +class DDC1113Bus extends DDC1113Vehicle +{ + +} + +/** + * @Entity + */ +class DDC1113Engine +{ + + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php new file mode 100644 index 0000000..c481aa3 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php @@ -0,0 +1,46 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testVersionFieldIgnoredInChangesetComputation() + { + $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article->text = "I don't know."; + $article->topic = "Who is John Galt?"; + + $this->_em->persist($article); + $this->_em->flush(); + + $this->assertEquals(1, $article->version); + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'); + $uow = $this->_em->getUnitOfWork(); + + $uow->computeChangeSet($class, $article); + $changeSet = $uow->getEntityChangeSet($article); + $this->assertEquals(0, count($changeSet), "No changesets should be computed."); + + $article->text = "This is John Galt speaking."; + $this->_em->flush(); + + $this->assertEquals(2, $article->version); + + $uow->computeChangeSet($class, $article); + $changeSet = $uow->getEntityChangeSet($article); + $this->assertEquals(0, count($changeSet), "No changesets should be computed."); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php new file mode 100644 index 0000000..51a2d45 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1151Test.php @@ -0,0 +1,56 @@ +_em->getConnection()->getDatabasePlatform()->getName() != 'postgresql') { + $this->markTestSkipped("This test is useful for all databases, but designed only for postgresql."); + } + + $sql = $this->_schemaTool->getCreateSchemaSql(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1151User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1151Group'), + )); + + $this->assertEquals("CREATE TABLE \"User\" (id INT NOT NULL, PRIMARY KEY(id))", $sql[0]); + $this->assertEquals("CREATE TABLE ddc1151user_ddc1151group (ddc1151user_id INT NOT NULL, ddc1151group_id INT NOT NULL, PRIMARY KEY(ddc1151user_id, ddc1151group_id))", $sql[1]); + $this->assertEquals("CREATE INDEX IDX_88A3259AC5AD08A ON ddc1151user_ddc1151group (ddc1151user_id)", $sql[2]); + $this->assertEquals("CREATE INDEX IDX_88A32597357E0B1 ON ddc1151user_ddc1151group (ddc1151group_id)", $sql[3]); + $this->assertEquals("CREATE TABLE \"Group\" (id INT NOT NULL, PRIMARY KEY(id))", $sql[4]); + $this->assertEquals("CREATE SEQUENCE User_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[5]); + $this->assertEquals("CREATE SEQUENCE Group_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[6]); + $this->assertEquals("ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A3259AC5AD08A FOREIGN KEY (ddc1151user_id) REFERENCES \"User\" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[7]); + $this->assertEquals("ALTER TABLE ddc1151user_ddc1151group ADD CONSTRAINT FK_88A32597357E0B1 FOREIGN KEY (ddc1151group_id) REFERENCES \"Group\" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[8]); + } +} + +/** + * @Entity + * @Table(name="`User`") + */ +class DDC1151User +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** @ManyToMany(targetEntity="DDC1151Group") */ + public $groups; +} + +/** + * @Entity + * @Table(name="`Group`") + */ +class DDC1151Group +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php new file mode 100644 index 0000000..1e8cae6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1163Test.php @@ -0,0 +1,215 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163Product'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163SpecialProduct'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163ProxyHolder'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1163Tag'), + )); + } + + public function testIssue() + { + $this->createSpecialProductAndProxyHolderReferencingIt(); + $this->_em->clear(); + + $this->createProxyForSpecialProduct(); + + $this->setPropertyAndAssignTagToSpecialProduct(); + + // fails + $this->_em->flush(); + } + + private function createSpecialProductAndProxyHolderReferencingIt() + { + $specialProduct = new DDC1163SpecialProduct(); + $this->_em->persist($specialProduct); + + $proxyHolder = new DDC1163ProxyHolder(); + $this->_em->persist($proxyHolder); + + $proxyHolder->setSpecialProduct($specialProduct); + + $this->_em->flush(); + + $this->productId = $specialProduct->getId(); + $this->proxyHolderId = $proxyHolder->getId(); + } + + /** + * We want Doctrine to instantiate a lazy-load proxy for the previously created + * 'SpecialProduct' and register it. + * + * When Doctrine loads the 'ProxyHolder', it will do just that because the 'ProxyHolder' + * references the 'SpecialProduct'. + */ + private function createProxyForSpecialProduct() + { + /* @var $proxyHolder ProxyHolder */ + $proxyHolder = $this->_em->find(__NAMESPACE__ . '\\DDC1163ProxyHolder', $this->proxyHolderId); + + $this->assertInstanceOf(__NAMESPACE__.'\\DDC1163SpecialProduct', $proxyHolder->getSpecialProduct()); + } + + private function setPropertyAndAssignTagToSpecialProduct() + { + /* @var $specialProduct SpecialProduct */ + $specialProduct = $this->_em->find(__NAMESPACE__ . '\\DDC1163SpecialProduct', $this->productId); + + $this->assertInstanceOf(__NAMESPACE__.'\\DDC1163SpecialProduct', $specialProduct); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $specialProduct); + + $specialProduct->setSubclassProperty('foobar'); + + // this screams violation of law of demeter ;) + $this->assertEquals( + __NAMESPACE__.'\\DDC1163SpecialProduct', + $this->_em->getUnitOfWork()->getEntityPersister(get_class($specialProduct))->getClassMetadata()->name + ); + + $tag = new DDC1163Tag('Foo'); + $this->_em->persist($tag); + $tag->setProduct($specialProduct); + } +} + +/** + * @Entity + */ +class DDC1163ProxyHolder +{ + + /** + * @var int + * @Column(name="id", type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + private $id; + /** + * @var SpecialProduct + * @OneToOne(targetEntity="DDC1163SpecialProduct") + */ + private $specialProduct; + + public function getId() + { + return $this->id; + } + + public function setSpecialProduct(DDC1163SpecialProduct $specialProduct) + { + $this->specialProduct = $specialProduct; + } + + public function getSpecialProduct() + { + return $this->specialProduct; + } + +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="type", type="string") + * @DiscriminatorMap({"special" = "DDC1163SpecialProduct"}) + */ +abstract class DDC1163Product +{ + + /** + * @var int + * @Column(name="id", type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + + public function getId() + { + return $this->id; + } + +} + +/** + * @Entity + */ +class DDC1163SpecialProduct extends DDC1163Product +{ + + /** + * @var string + * @Column(name="subclass_property", type="string", nullable=true) + */ + private $subclassProperty; + + /** + * @param string $value + */ + public function setSubclassProperty($value) + { + $this->subclassProperty = $value; + } + +} + +/** + * @Entity + */ +class DDC1163Tag +{ + + /** + * @var int + * @Column(name="id", type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + private $id; + /** + * @var string + * @Column(name="name", type="string") + */ + private $name; + /** + * @var Product + * @ManyToOne(targetEntity="DDC1163Product", inversedBy="tags") + * @JoinColumns({ + * @JoinColumn(name="product_id", referencedColumnName="id") + * }) + */ + private $product; + + /** + * @param string $name + */ + public function __construct($name) + { + $this->name = $name; + } + + /** + * @param Product $product + */ + public function setProduct(DDC1163Product $product) + { + $this->product = $product; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php new file mode 100644 index 0000000..6ae4595 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php @@ -0,0 +1,464 @@ +useModelSet('ddc117'); + parent::setUp(); + + $this->article1 = new DDC117Article("Foo"); + $this->article2 = new DDC117Article("Bar"); + + $this->_em->persist($this->article1); + $this->_em->persist($this->article2); + $this->_em->flush(); + + $this->reference = new DDC117Reference($this->article1, $this->article2, "Test-Description"); + $this->_em->persist($this->reference); + + $this->translation = new DDC117Translation($this->article1, "en", "Bar"); + $this->_em->persist($this->translation); + + $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text"); + $this->_em->persist($this->articleDetails); + $this->_em->flush(); + + $this->_em->clear(); + } + + /** + * @group DDC-117 + */ + public function testAssociationOnlyCompositeKey() + { + $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); + + $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $mapRef); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->target()); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->source()); + $this->assertSame($mapRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); + + $this->_em->clear(); + + $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE r.source = ?1"; + $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 1)->getSingleResult(); + + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $mapRef); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->target()); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $mapRef->source()); + $this->assertSame($dqlRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); + + $this->_em->clear(); + + $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; + $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); + + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $dqlRef); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $dqlRef->target()); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Article", $dqlRef->source()); + $this->assertSame($dqlRef, $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); + + $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; + $dqlRef = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getSingleResult(); + + $this->_em->contains($dqlRef); + } + + /** + * @group DDC-117 + */ + public function testUpdateAssocationEntity() + { + $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); + + $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); + $this->assertNotNull($mapRef); + $mapRef->setDescription("New Description!!"); + $this->_em->flush(); + $this->_em->clear(); + + $mapRef = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); + + $this->assertEquals('New Description!!', $mapRef->getDescription()); + } + + /** + * @group DDC-117 + */ + public function testFetchDql() + { + $dql = "SELECT r, s FROM "."Doctrine\Tests\Models\DDC117\DDC117Reference r JOIN r.source s WHERE s.title = ?1"; + $refs = $this->_em->createQuery($dql)->setParameter(1, 'Foo')->getResult(); + + $this->assertTrue(count($refs) > 0, "Has to contain at least one Reference."); + + foreach ($refs AS $ref) { + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $ref, "Contains only Reference instances."); + $this->assertTrue($this->_em->contains($ref), "Contains Reference in the IdentityMap."); + } + } + + /** + * @group DDC-117 + */ + public function testRemoveCompositeElement() + { + $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); + + $refRep = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); + + $this->_em->remove($refRep); + $this->_em->flush(); + $this->_em->clear(); + + $this->assertNull($this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); + } + + /** + * @group DDC-117 + */ + public function testDqlRemoveCompositeElement() + { + $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); + + $dql = "DELETE "."Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = ?1 AND r.target = ?2"; + $this->_em->createQuery($dql) + ->setParameter(1, $this->article1->id()) + ->setParameter(2, $this->article2->id()) + ->execute(); + + $this->assertNull($this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria)); + } + + /** + * @group DDC-117 + */ + public function testInverseSideAccess() + { + $this->article1 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article1->id()); + + $this->assertEquals(1, count($this->article1->references())); + + foreach ($this->article1->references() AS $this->reference) { + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $this->reference); + $this->assertSame($this->article1, $this->reference->source()); + } + + $this->_em->clear(); + + $dql = 'SELECT a, r FROM '. 'Doctrine\Tests\Models\DDC117\DDC117Article a INNER JOIN a.references r WHERE a.id = ?1'; + $articleDql = $this->_em->createQuery($dql) + ->setParameter(1, $this->article1->id()) + ->getSingleResult(); + + $this->assertEquals(1, count($this->article1->references())); + + foreach ($this->article1->references() AS $this->reference) { + $this->assertInstanceOf("Doctrine\Tests\Models\DDC117\DDC117Reference", $this->reference); + $this->assertSame($this->article1, $this->reference->source()); + } + } + + /** + * @group DDC-117 + */ + public function testMixedCompositeKey() + { + $idCriteria = array('article' => $this->article1->id(), 'language' => 'en'); + + $this->translation = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria); + $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $this->translation); + + $this->assertSame($this->translation, $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria)); + + $this->_em->clear(); + + $dql = 'SELECT t, a FROM ' . 'Doctrine\Tests\Models\DDC117\DDC117Translation t JOIN t.article a WHERE t.article = ?1 AND t.language = ?2'; + $dqlTrans = $this->_em->createQuery($dql) + ->setParameter(1, $this->article1->id()) + ->setParameter(2, 'en') + ->getSingleResult(); + + $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $this->translation); + } + + /** + * @group DDC-117 + */ + public function testMixedCompositeKeyViolateUniqueness() + { + $this->article1 = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Article', $this->article1->id()); + $this->article1->addTranslation('en', 'Bar'); + $this->article1->addTranslation('en', 'Baz'); + + $exceptionThrown = false; + try { + // exception depending on the underyling Database Driver + $this->_em->flush(); + } catch(\Exception $e) { + $exceptionThrown = true; + } + + $this->assertTrue($exceptionThrown, "The underlying database driver throws an exception."); + } + + /** + * @group DDC-117 + */ + public function testOneToOneForeignObjectId() + { + $this->article1 = new DDC117Article("Foo"); + $this->_em->persist($this->article1); + $this->_em->flush(); + + $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text"); + $this->_em->persist($this->articleDetails); + $this->_em->flush(); + + $this->articleDetails->update("not so very long text!"); + $this->_em->flush(); + $this->_em->clear(); + + /* @var $article DDC117Article */ + $article = $this->_em->find(get_class($this->article1), $this->article1->id()); + $this->assertEquals('not so very long text!', $article->getText()); + } + + /** + * @group DDC-117 + */ + public function testOneToOneCascadeRemove() + { + $article = $this->_em->find(get_class($this->article1), $this->article1->id()); + $this->_em->remove($article); + $this->_em->flush(); + + $this->assertFalse($this->_em->contains($article->getDetails())); + } + + /** + * @group DDC-117 + */ + public function testOneToOneCascadePersist() + { + if (!$this->_em->getConnection()->getDatabasePlatform()->prefersSequences()) { + $this->markTestSkipped('Test only works with databases that prefer sequences as ID strategy.'); + } + + $this->article1 = new DDC117Article("Foo"); + + $this->articleDetails = new DDC117ArticleDetails($this->article1, "Very long text"); + + $this->_em->persist($this->article1); + $this->_em->flush(); + } + + /** + * @group DDC-117 + */ + public function testReferencesToForeignKeyEntities() + { + $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); + $reference = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); + + $idCriteria = array('article' => $this->article1->id(), 'language' => 'en'); + $translation = $this->_em->find('Doctrine\Tests\Models\DDC117\DDC117Translation', $idCriteria); + + $approveChanges = new DDC117ApproveChanges($reference->source()->getDetails(), $reference, $translation); + $this->_em->persist($approveChanges); + $this->_em->flush(); + $this->_em->clear(); + + $approveChanges = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117ApproveChanges", $approveChanges->getId()); + + $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', $approveChanges->getArticleDetails()); + $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Reference', $approveChanges->getReference()); + $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $approveChanges->getTranslation()); + } + + /** + * @group DDC-117 + */ + public function testLoadOneToManyCollectionOfForeignKeyEntities() + { + /* @var $article DDC117Article */ + $article = $this->_em->find(get_class($this->article1), $this->article1->id()); + + $translations = $article->getTranslations(); + $this->assertFalse($translations->isInitialized()); + $this->assertContainsOnly('Doctrine\Tests\Models\DDC117\DDC117Translation', $translations); + $this->assertTrue($translations->isInitialized()); + } + + /** + * @group DDC-117 + */ + public function testLoadManyToManyCollectionOfForeignKeyEntities() + { + $editor = $this->loadEditorFixture(); + + $this->assertFalse($editor->reviewingTranslations->isInitialized()); + $this->assertContainsOnly("Doctrine\Tests\Models\DDC117\DDC117Translation", $editor->reviewingTranslations); + $this->assertTrue($editor->reviewingTranslations->isInitialized()); + + $this->_em->clear(); + + $dql = "SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE e.id = ?1"; + $editor = $this->_em->createQuery($dql)->setParameter(1, $editor->id)->getSingleResult(); + $this->assertTrue($editor->reviewingTranslations->isInitialized()); + $this->assertContainsOnly("Doctrine\Tests\Models\DDC117\DDC117Translation", $editor->reviewingTranslations); + } + + /** + * @group DDC-117 + */ + public function testClearManyToManyCollectionOfForeignKeyEntities() + { + $editor = $this->loadEditorFixture(); + $this->assertEquals(3, count($editor->reviewingTranslations)); + + $editor->reviewingTranslations->clear(); + $this->_em->flush(); + $this->_em->clear(); + + $editor = $this->_em->find(get_class($editor), $editor->id); + $this->assertEquals(0, count($editor->reviewingTranslations)); + } + + /** + * @group DDC-117 + */ + public function testLoadInverseManyToManyCollection() + { + $editor = $this->loadEditorFixture(); + + $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $editor->reviewingTranslations[0]); + + $reviewedBy = $editor->reviewingTranslations[0]->getReviewedByEditors(); + $this->assertEquals(1, count($reviewedBy)); + $this->assertSame($editor, $reviewedBy[0]); + + $this->_em->clear(); + + $dql = "SELECT t, e FROM Doctrine\Tests\Models\DDC117\DDC117Translation t ". + "JOIN t.reviewedByEditors e WHERE t.article = ?1 AND t.language = ?2"; + $trans = $this->_em->createQuery($dql) + ->setParameter(1, $this->translation->getArticleId()) + ->setParameter(2, $this->translation->getLanguage()) + ->getSingleResult(); + + $this->assertInstanceOf('Doctrine\Tests\Models\DDC117\DDC117Translation', $trans); + $this->assertContainsOnly('Doctrine\Tests\Models\DDC117\DDC117Editor', $trans->reviewedByEditors); + $this->assertEquals(1, count($trans->reviewedByEditors)); + } + + /** + * @group DDC-117 + */ + public function testLoadOneToManyOfSourceEntityWithAssociationIdentifier() + { + $editor = $this->loadEditorFixture(); + + $editor->addLastTranslation($editor->reviewingTranslations[0]); + $this->_em->flush(); + $this->_em->clear(); + + $editor = $this->_em->find(get_class($editor), $editor->id); + $lastTranslatedBy = $editor->reviewingTranslations[0]->getLastTranslatedBy(); + $lastTranslatedBy->count(); + + $this->assertEquals(1, count($lastTranslatedBy)); + } + + /** + * @return DDC117Editor + */ + private function loadEditorFixture() + { + $editor = new DDC117Editor("beberlei"); + + /* @var $article1 DDC117Article */ + $article1 = $this->_em->find(get_class($this->article1), $this->article1->id()); + foreach ($article1->getTranslations() AS $translation) { + $editor->reviewingTranslations[] = $translation; + } + + /* @var $article2 DDC117Article */ + $article2 = $this->_em->find(get_class($this->article2), $this->article2->id()); + $article2->addTranslation("de", "Vanille-Krapferl"); // omnomnom + $article2->addTranslation("fr", "Sorry can't speak french!"); + + foreach ($article2->getTranslations() AS $translation) { + $this->_em->persist($translation); // otherwise persisting the editor won't work, reachability! + $editor->reviewingTranslations[] = $translation; + } + + $this->_em->persist($editor); + $this->_em->flush(); + $this->_em->clear(); + + return $this->_em->find(get_class($editor), $editor->id); + } + + /** + * @group DDC-1519 + */ + public function testMergeForeignKeyIdentifierEntity() + { + $idCriteria = array('source' => $this->article1->id(), 'target' => $this->article2->id()); + + $refRep = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Reference", $idCriteria); + + $this->_em->detach($refRep); + $refRep = $this->_em->merge($refRep); + + $this->assertEquals($this->article1->id(), $refRep->source()->id()); + $this->assertEquals($this->article2->id(), $refRep->target()->id()); + } + + /** + * @group DDC-1652 + */ + public function testArrayHydrationWithCompositeKey() + { + $dql = "SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t"; + $before = count($this->_em->createQuery($dql)->getResult()); + + $this->article1 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article1->id()); + $this->article2 = $this->_em->find("Doctrine\Tests\Models\DDC117\DDC117Article", $this->article2->id()); + + $this->reference = new DDC117Reference($this->article2, $this->article1, "Test-Description"); + $this->_em->persist($this->reference); + + $this->reference = new DDC117Reference($this->article1, $this->article1, "Test-Description"); + $this->_em->persist($this->reference); + + $this->reference = new DDC117Reference($this->article2, $this->article2, "Test-Description"); + $this->_em->persist($this->reference); + + $this->_em->flush(); + + $dql = "SELECT r,s,t FROM Doctrine\Tests\Models\DDC117\DDC117Reference r INNER JOIN r.source s INNER JOIN r.target t"; + $data = $this->_em->createQuery($dql)->getArrayResult(); + + $this->assertEquals($before + 3, count($data)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php new file mode 100644 index 0000000..32856ac --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1181Test.php @@ -0,0 +1,101 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1181Hotel'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1181Booking'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1181Room'), + )); + } + + /** + * @group DDC-1181 + */ + public function testIssue() + { + $hotel = new DDC1181Hotel(); + $room1 = new DDC1181Room(); + $room2 = new DDC1181Room(); + + $this->_em->persist($hotel); + $this->_em->persist($room1); + $this->_em->persist($room2); + $this->_em->flush(); + + $booking1 = new DDC1181Booking; + $booking1->hotel = $hotel; + $booking1->room = $room1; + $booking2 = new DDC1181Booking; + $booking2->hotel = $hotel; + $booking2->room = $room2; + $hotel->bookings[] = $booking1; + $hotel->bookings[] = $booking2; + + $this->_em->persist($booking1); + $this->_em->persist($booking2); + $this->_em->flush(); + + $this->_em->remove($hotel); + $this->_em->flush(); + } +} + +/** + * @Entity + */ +class DDC1181Hotel +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** + * @oneToMany(targetEntity="DDC1181Booking", mappedBy="hotel", cascade={"remove"}) + * @var Booking[] + */ + public $bookings; + +} + +/** + * @Entity + */ +class DDC1181Booking +{ + /** + * @var Hotel + * + * @Id + * @ManyToOne(targetEntity="DDC1181Hotel", inversedBy="bookings") + * @JoinColumns({ + * @JoinColumn(name="hotel_id", referencedColumnName="id") + * }) + */ + public $hotel; + /** + * @var Room + * + * @Id + * @ManyToOne(targetEntity="DDC1181Room") + * @JoinColumns({ + * @JoinColumn(name="room_id", referencedColumnName="id") + * }) + */ + public $room; +} + +/** + * @Entity + */ +class DDC1181Room +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php new file mode 100644 index 0000000..6465fa6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1193Test.php @@ -0,0 +1,93 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Company'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Person'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Account') + )); + } + + /** + * @group DDC-1193 + */ + public function testIssue() + { + $company = new DDC1193Company(); + $person = new DDC1193Person(); + $account = new DDC1193Account(); + + $person->account = $account; + $person->company = $company; + + $company->member = $person; + + $this->_em->persist($company); + + $this->_em->flush(); + + $companyId = $company->id; + $accountId = $account->id; + $this->_em->clear(); + + $company = $this->_em->find(get_class($company), $companyId); + + $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), "Company is in identity map."); + $this->assertFalse($company->member->__isInitialized__, "Pre-Condition"); + $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), "Member is in identity map."); + + $this->_em->remove($company); + $this->_em->flush(); + + $this->assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0); + } +} + +/** @Entity */ +class DDC1193Company { + /** + * @Id @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** @OneToOne(targetEntity="DDC1193Person", cascade={"persist", "remove"}) */ + public $member; + +} + +/** @Entity */ +class DDC1193Person { + /** + * @Id @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC1193Account", cascade={"persist", "remove"}) + */ + public $account; +} + +/** @Entity */ +class DDC1193Account { + /** + * @Id @Column(type="integer") + * @GeneratedValue + */ + public $id; + +} + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php new file mode 100644 index 0000000..bddbbdf --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php @@ -0,0 +1,125 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_1'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_2'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_3') + )); + } catch(\Exception $e) { + } + } + + /** + * @group DDC-1209 + */ + public function testIdentifierCanHaveCustomType() + { + $this->_em->persist(new DDC1209_3()); + $this->_em->flush(); + } + + /** + * @group DDC-1209 + */ + public function testCompositeIdentifierCanHaveCustomType() + { + $future1 = new DDC1209_1(); + $this->_em->persist($future1); + + $this->_em->flush(); + + $future2 = new DDC1209_2($future1); + $this->_em->persist($future2); + + $this->_em->flush(); + } +} + +/** + * @Entity + */ +class DDC1209_1 +{ + /** + * @Id @GeneratedValue @Column(type="integer") + */ + private $id; + + public function getId() + { + return $this->id; + } +} + +/** + * @Entity + */ +class DDC1209_2 +{ + /** + * @Id + * @ManyToOne(targetEntity="DDC1209_1") + * @JoinColumn(referencedColumnName="id", nullable=false) + */ + private $future1; + /** + * @Id + * @Column(type="datetime", nullable=false) + */ + private $starting_datetime; + /** + * @Id + * @Column(type="datetime", nullable=false) + */ + private $during_datetime; + /** + * @Id + * @Column(type="datetime", nullable=false) + */ + private $ending_datetime; + + public function __construct(DDC1209_1 $future1) + { + $this->future1 = $future1; + $this->starting_datetime = new DateTime2(); + $this->during_datetime = new DateTime2(); + $this->ending_datetime = new DateTime2(); + } +} + +/** + * @Entity + */ +class DDC1209_3 +{ + /** + * @Id + * @Column(type="datetime", name="somedate") + */ + private $date; + + public function __construct() + { + $this->date = new DateTime2(); + } +} + +class DateTime2 extends \DateTime +{ + public function __toString() + { + return $this->format('Y'); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php new file mode 100644 index 0000000..95dcc2b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1225Test.php @@ -0,0 +1,85 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity1'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity2'), + )); + } catch(\PDOException $e) { + + } + } + + public function testIssue() + { + $qb = $this->_em->createQueryBuilder(); + $qb->from('Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity1', 'te1') + ->select('te1') + ->where('te1.testEntity2 = ?1') + ->setParameter(1, 0); + + $this->assertEquals( + strtolower('SELECT t0_.test_entity2_id AS test_entity2_id0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?'), + strtolower($qb->getQuery()->getSQL()) + ); + } +} + +/** + * @Entity + * @Table(name="te1") + */ +class DDC1225_TestEntity1 +{ + /** + * @Id + * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity2") + * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false) + */ + private $testEntity2; + + /** + * @param DDC1225_TestEntity2 $testEntity2 + */ + public function setTestEntity2(DDC1225_TestEntity2 $testEntity2) + { + $this->testEntity2 = $testEntity2; + } + + /** + * @return DDC1225_TestEntity2 + */ + public function getTestEntity2() + { + return $this->testEntity2; + } +} + +/** + * @Entity + * @Table(name="te2") + */ +class DDC1225_TestEntity2 +{ + /** + * @Id + * @GeneratedValue(strategy="AUTO") + * @Column(type="integer") + */ + private $id; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php new file mode 100644 index 0000000..6e14e21 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1228Test.php @@ -0,0 +1,136 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228Profile'), + )); + } catch(\Exception $e) { + + } + } + + public function testOneToOnePersist() + { + $user = new DDC1228User; + $profile = new DDC1228Profile(); + $profile->name = "Foo"; + $user->profile = $profile; + + $this->_em->persist($user); + $this->_em->persist($profile); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id); + + $this->assertFalse($user->getProfile()->__isInitialized__, "Proxy is not initialized"); + $user->getProfile()->setName("Bar"); + $this->assertTrue($user->getProfile()->__isInitialized__, "Proxy is not initialized"); + + $this->assertEquals("Bar", $user->getProfile()->getName()); + $this->assertEquals(array("id" => 1, "name" => "Foo"), $this->_em->getUnitOfWork()->getOriginalEntityData($user->getProfile())); + + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id); + $this->assertEquals("Bar", $user->getProfile()->getName()); + } + + public function testRefresh() + { + $user = new DDC1228User; + $profile = new DDC1228Profile(); + $profile->name = "Foo"; + $user->profile = $profile; + + $this->_em->persist($user); + $this->_em->persist($profile); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1228User', $user->id); + + $this->_em->refresh($user); + $user->name = "Baz"; + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find(__NAMESPACE__ . '\\DDC1228User', $user->id); + $this->assertEquals("Baz", $user->name); + } +} + +/** + * @Entity + */ +class DDC1228User +{ + /** + * @Id @Column(type="integer") @GeneratedValue + * @var int + */ + public $id; + + /** + * @Column(type="string") + * @var string + */ + public $name = 'Bar'; + + /** + * @OneToOne(targetEntity="DDC1228Profile") + * @var Profile + */ + public $profile; + + public function getProfile() + { + return $this->profile; + } +} + +/** + * @Entity + */ +class DDC1228Profile +{ + /** + * @Id @Column(type="integer") @GeneratedValue + * @var int + */ + public $id; + + /** + * @column(type="string") + * @var string + */ + public $name; + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php new file mode 100644 index 0000000..6783928 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1238Test.php @@ -0,0 +1,100 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1238User'), + )); + } catch(\Exception $e) { + + } + } + + public function testIssue() + { + $user = new DDC1238User; + $user->setName("test"); + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $userId = $user->getId(); + $this->_em->clear(); + + $user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId); + $this->_em->clear(); + + $userId2 = $user->getId(); + $this->assertEquals($userId, $userId2, "This proxy can still be initialized."); + } + + public function testIssueProxyClear() + { + $user = new DDC1238User; + $user->setName("test"); + + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + // force proxy load, getId() doesn't work anymore + $user->getName(); + $userId = $user->getId(); + $this->_em->clear(); + + $user = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId); + $this->_em->clear(); + + $user2 = $this->_em->getReference(__NAMESPACE__ . '\\DDC1238User', $userId); + + // force proxy load, getId() doesn't work anymore + $user->getName(); + $this->assertNull($user->getId(), "Now this is null, we already have a user instance of that type"); + } +} + +/** + * @Entity + */ +class DDC1238User +{ + /** @Id @GeneratedValue @Column(type="integer") */ + private $id; + + /** + * @Column + * @var string + */ + private $name; + + public function getId() + { + return $this->id; + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php new file mode 100644 index 0000000..3a756da --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1250Test.php @@ -0,0 +1,96 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1250ClientHistory'), + )); + } catch(\PDOException $e) { + + } + } + + public function testIssue() + { + $c1 = new DDC1250ClientHistory; + $c2 = new DDC1250ClientHistory; + $c1->declinedClientsHistory = $c2; + $c1->declinedBy = $c2; + $c2->declinedBy = $c1; + $c2->declinedClientsHistory= $c1; + + $this->_em->persist($c1); + $this->_em->persist($c2); + $this->_em->flush(); + $this->_em->clear(); + + $history = $this->_em->createQuery('SELECT h FROM ' . __NAMESPACE__ . '\\DDC1250ClientHistory h WHERE h.id = ?1') + ->setParameter(1, $c2->id)->getSingleResult(); + + $this->assertInstanceOf(__NAMESPACE__ . '\\DDC1250ClientHistory', $history); + } +} + +/** + * @Entity + */ +class DDC1250ClientHistory +{ + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + + /** @OneToOne(targetEntity="DDC1250ClientHistory", inversedBy="declinedBy") + * @JoinColumn(name="declined_clients_history_id", referencedColumnName="id") + */ + public $declinedClientsHistory; + + /** + * @OneToOne(targetEntity="DDC1250ClientHistory", mappedBy="declinedClientsHistory") + * @var + */ + public $declinedBy; +} + +/** + * +Entities\ClientsHistory: +type: entity +table: clients_history +fields: +id: +id: true +type: integer +unsigned: false +nullable: false +generator: +strategy: IDENTITY +[...skiped...] +oneToOne: +declinedClientsHistory: +targetEntity: Entities\ClientsHistory +joinColumn: +name: declined_clients_history_id +referencedColumnName: id +inversedBy: declinedBy +declinedBy: +targetEntity: Entities\ClientsHistory +mappedBy: declinedClientsHistory +lifecycleCallbacks: { } +repositoryClass: Entities\ClientsHistoryRepository + + + */ \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php new file mode 100644 index 0000000..a4f54b5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1276Test.php @@ -0,0 +1,50 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testIssue() + { + $user = new CmsUser(); + $user->name = "Benjamin"; + $user->username = "beberlei"; + $user->status = "active"; + $this->_em->persist($user); + + for ($i = 0; $i < 2; $i++) { + $group = new CmsGroup(); + $group->name = "group".$i; + $user->groups[] = $group; + $this->_em->persist($group); + } + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id); + $cloned = clone $user; + + $this->assertSame($user->groups, $cloned->groups); + $this->assertEquals(2, count($user->groups)); + $this->_em->merge($cloned); + + $this->assertEquals(2, count($user->groups)); + + $this->_em->flush(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php new file mode 100644 index 0000000..38278dc --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1300Test.php @@ -0,0 +1,108 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300Foo'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300FooLocale'), + )); + } + + public function testIssue() + { + $foo = new DDC1300Foo(); + $foo->_fooReference = "foo"; + + $this->_em->persist($foo); + $this->_em->flush(); + + $locale = new DDC1300FooLocale(); + $locale->_foo = $foo; + $locale->_locale = "en"; + $locale->_title = "blub"; + + $this->_em->persist($locale); + $this->_em->flush(); + + $query = $this->_em->createQuery('SELECT f, fl FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1300Foo f JOIN f._fooLocaleRefFoo fl'); + $result = $query->getResult(); + + $this->assertEquals(1, count($result)); + } +} + +/** + * @Entity + */ +class DDC1300Foo +{ + /** + * @var integer fooID + * @Column(name="fooID", type="integer", nullable=false) + * @GeneratedValue(strategy="AUTO") + * @Id + */ + public $_fooID = null; + + /** + * @var string fooReference + * @Column(name="fooReference", type="string", nullable=true, length=45) + */ + public $_fooReference = null; + + /** + * @OneToMany(targetEntity="DDC1300FooLocale", mappedBy="_foo", + * cascade={"persist"}) + */ + public $_fooLocaleRefFoo = null; + + /** + * Constructor + * + * @param array|Zend_Config|null $options + * @return Bug_Model_Foo + */ + public function __construct($options = null) + { + $this->_fooLocaleRefFoo = new \Doctrine\Common\Collections\ArrayCollection(); + } + +} + +/** + * @Entity + */ +class DDC1300FooLocale +{ + + /** + * @ManyToOne(targetEntity="DDC1300Foo") + * @JoinColumn(name="fooID", referencedColumnName="fooID") + * @Id + */ + public $_foo = null; + + /** + * @var string locale + * @Column(name="locale", type="string", nullable=false, length=5) + * @Id + */ + public $_locale = null; + + /** + * @var string title + * @Column(name="title", type="string", nullable=true, length=150) + */ + public $_title = null; + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php new file mode 100644 index 0000000..94d02f9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1301Test.php @@ -0,0 +1,148 @@ +useModelSet('legacy'); + parent::setUp(); + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\Legacy\LegacyUser'); + $class->associationMappings['_articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + $class->associationMappings['_references']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + $class->associationMappings['_cars']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY; + + $this->loadFixture(); + } + + public function tearDown() + { + parent::tearDown(); + + $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\Legacy\LegacyUser'); + $class->associationMappings['_articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + $class->associationMappings['_references']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + $class->associationMappings['_cars']['fetch'] = ClassMetadataInfo::FETCH_LAZY; + } + + public function testCountNotInitializesLegacyCollection() + { + $user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId); + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->_articles->isInitialized()); + $this->assertEquals(2, count($user->_articles)); + $this->assertFalse($user->_articles->isInitialized()); + + foreach ($user->_articles AS $article) { } + + $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); + } + + public function testCountNotInitializesLegacyCollectionWithForeignIdentifier() + { + $user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId); + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->_references->isInitialized()); + $this->assertEquals(2, count($user->_references)); + $this->assertFalse($user->_references->isInitialized()); + + foreach ($user->_references AS $reference) { } + + $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); + } + + public function testCountNotInitializesLegacyManyToManyCollection() + { + $user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId); + $queryCount = $this->getCurrentQueryCount(); + + $this->assertFalse($user->_cars->isInitialized()); + $this->assertEquals(3, count($user->_cars)); + $this->assertFalse($user->_cars->isInitialized()); + + foreach ($user->_cars AS $reference) { } + + $this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); + } + + public function loadFixture() + { + $user1 = new \Doctrine\Tests\Models\Legacy\LegacyUser(); + $user1->_username = "beberlei"; + $user1->_name = "Benjamin"; + $user1->_status = "active"; + + $user2 = new \Doctrine\Tests\Models\Legacy\LegacyUser(); + $user2->_username = "jwage"; + $user2->_name = "Jonathan"; + $user2->_status = "active"; + + $user3 = new \Doctrine\Tests\Models\Legacy\LegacyUser(); + $user3->_username = "romanb"; + $user3->_name = "Roman"; + $user3->_status = "active"; + + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->persist($user3); + + $article1 = new \Doctrine\Tests\Models\Legacy\LegacyArticle(); + $article1->_topic = "Test"; + $article1->_text = "Test"; + $article1->setAuthor($user1); + + $article2 = new \Doctrine\Tests\Models\Legacy\LegacyArticle(); + $article2->_topic = "Test"; + $article2->_text = "Test"; + $article2->setAuthor($user1); + + $this->_em->persist($article1); + $this->_em->persist($article2); + + $car1 = new \Doctrine\Tests\Models\Legacy\LegacyCar(); + $car1->_description = "Test1"; + + $car2 = new \Doctrine\Tests\Models\Legacy\LegacyCar(); + $car2->_description = "Test2"; + + $car3 = new \Doctrine\Tests\Models\Legacy\LegacyCar(); + $car3->_description = "Test3"; + + $user1->addCar($car1); + $user1->addCar($car2); + $user1->addCar($car3); + + $user2->addCar($car1); + $user3->addCar($car1); + + $this->_em->persist($car1); + $this->_em->persist($car2); + $this->_em->persist($car3); + + $this->_em->flush(); + + $detail1 = new \Doctrine\Tests\Models\Legacy\LegacyUserReference($user1, $user2, "foo"); + $detail2 = new \Doctrine\Tests\Models\Legacy\LegacyUserReference($user1, $user3, "bar"); + + $this->_em->persist($detail1); + $this->_em->persist($detail2); + + $this->_em->flush(); + $this->_em->clear(); + + $this->userId = $user1->getId(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php new file mode 100644 index 0000000..b143b00 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1306Test.php @@ -0,0 +1,54 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testIssue() + { + $phone = new CmsPhonenumber(); + $phone->phonenumber = "1234"; + + // puts user and phone into commit order calculator + $this->_em->persist($phone); + $this->_em->flush(); + + $address = new \Doctrine\Tests\Models\CMS\CmsAddress(); + $address->city = "bonn"; + $address->country = "Germany"; + $address->street = "somestreet!"; + $address->zip = 12345; + + $this->_em->persist($address); + + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "benjamin"; + $user->status = "active"; + $user->setAddress($address); + + // puts user and address into commit order calculator, but does not calculate user dependencies new + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->remove($user->getAddress()); + $this->_em->remove($user); + $this->_em->flush(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php new file mode 100644 index 0000000..0500a0e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1335Test.php @@ -0,0 +1,218 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1335User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1335Phone'), + )); + $this->loadFixture(); + } catch(\Exception $e) { + } + } + + + public function testDql() + { + $dql = 'SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id'; + $query = $this->_em->createQuery($dql); + $result = $query->getResult(); + + $this->assertEquals(sizeof($result), 3); + $this->assertArrayHasKey(1, $result); + $this->assertArrayHasKey(2, $result); + $this->assertArrayHasKey(3, $result); + + $dql = 'SELECT u, p FROM '.__NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id'; + $query = $this->_em->createQuery($dql); + $result = $query->getResult(); + + $this->assertEquals(sizeof($result), 3); + $this->assertArrayHasKey('foo@foo.com', $result); + $this->assertArrayHasKey('bar@bar.com', $result); + $this->assertArrayHasKey('foobar@foobar.com', $result); + + $this->assertEquals(sizeof($result['foo@foo.com']->phones), 3); + $this->assertEquals(sizeof($result['bar@bar.com']->phones), 3); + $this->assertEquals(sizeof($result['foobar@foobar.com']->phones), 3); + + $foo = $result['foo@foo.com']->phones->toArray(); + $bar = $result['bar@bar.com']->phones->toArray(); + $foobar = $result['foobar@foobar.com']->phones->toArray(); + + $this->assertArrayHasKey(1, $foo); + $this->assertArrayHasKey(2, $foo); + $this->assertArrayHasKey(3, $foo); + + $this->assertArrayHasKey(4, $bar); + $this->assertArrayHasKey(5, $bar); + $this->assertArrayHasKey(6, $bar); + + $this->assertArrayHasKey(7, $foobar); + $this->assertArrayHasKey(8, $foobar); + $this->assertArrayHasKey(9, $foobar); + } + + public function testTicket() + { + $builder = $this->_em->createQueryBuilder(); + $builder->select('u')->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.id'); + + $dql = $builder->getQuery()->getDQL(); + $result = $builder->getQuery()->getResult(); + + $this->assertEquals(sizeof($result), 3); + $this->assertArrayHasKey(1, $result); + $this->assertArrayHasKey(2, $result); + $this->assertArrayHasKey(3, $result); + $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id', $dql); + } + + public function testIndexByUnique() + { + $builder = $this->_em->createQueryBuilder(); + $builder->select('u')->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.email'); + + $dql = $builder->getQuery()->getDQL(); + $result = $builder->getQuery()->getResult(); + + $this->assertEquals(sizeof($result), 3); + $this->assertArrayHasKey('foo@foo.com', $result); + $this->assertArrayHasKey('bar@bar.com', $result); + $this->assertArrayHasKey('foobar@foobar.com', $result); + $this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email', $dql); + } + + public function testIndexWithJoin() + { + $builder = $this->_em->createQueryBuilder(); + $builder->select('u','p') + ->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.email') + ->join('u.phones', 'p', null, null, 'p.id'); + + $dql = $builder->getQuery()->getDQL(); + $result = $builder->getQuery()->getResult(); + + $this->assertEquals(sizeof($result), 3); + $this->assertArrayHasKey('foo@foo.com', $result); + $this->assertArrayHasKey('bar@bar.com', $result); + $this->assertArrayHasKey('foobar@foobar.com', $result); + + $this->assertEquals(sizeof($result['foo@foo.com']->phones), 3); + $this->assertEquals(sizeof($result['bar@bar.com']->phones), 3); + $this->assertEquals(sizeof($result['foobar@foobar.com']->phones), 3); + + $this->assertArrayHasKey(1, $result['foo@foo.com']->phones->toArray()); + $this->assertArrayHasKey(2, $result['foo@foo.com']->phones->toArray()); + $this->assertArrayHasKey(3, $result['foo@foo.com']->phones->toArray()); + + $this->assertArrayHasKey(4, $result['bar@bar.com']->phones->toArray()); + $this->assertArrayHasKey(5, $result['bar@bar.com']->phones->toArray()); + $this->assertArrayHasKey(6, $result['bar@bar.com']->phones->toArray()); + + $this->assertArrayHasKey(7, $result['foobar@foobar.com']->phones->toArray()); + $this->assertArrayHasKey(8, $result['foobar@foobar.com']->phones->toArray()); + $this->assertArrayHasKey(9, $result['foobar@foobar.com']->phones->toArray()); + + $this->assertEquals('SELECT u, p FROM '.__NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql); + } + + private function loadFixture() + { + $p1 = array('11 xxxx-xxxx','11 yyyy-yyyy','11 zzzz-zzzz'); + $p2 = array('22 xxxx-xxxx','22 yyyy-yyyy','22 zzzz-zzzz'); + $p3 = array('33 xxxx-xxxx','33 yyyy-yyyy','33 zzzz-zzzz'); + + $u1 = new DDC1335User("foo@foo.com", "Foo",$p1); + $u2 = new DDC1335User("bar@bar.com", "Bar",$p2); + $u3 = new DDC1335User("foobar@foobar.com", "Foo Bar",$p3); + + $this->_em->persist($u1); + $this->_em->persist($u2); + $this->_em->persist($u3); + $this->_em->flush(); + $this->_em->clear(); + } + +} + +/** + * @Entity + */ +class DDC1335User +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @Column(type="string", unique=true) + */ + public $email; + + /** + * @Column(type="string") + */ + public $name; + + /** + * @OneToMany(targetEntity="DDC1335Phone", mappedBy="user", cascade={"persist", "remove"}) + */ + public $phones; + + public function __construct($email, $name, array $numbers = array()) + { + $this->name = $name; + $this->email = $email; + $this->phones = new \Doctrine\Common\Collections\ArrayCollection(); + + foreach ($numbers as $number) { + $this->phones->add(new DDC1335Phone($this,$number)); + } + } +} + +/** + * @Entity + */ +class DDC1335Phone +{ + /** + * @Id + * @Column(name="id", type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @Column(name="numericalValue", type="string", nullable = false) + */ + public $numericalValue; + + /** + * @ManyToOne(targetEntity="DDC1335User", inversedBy="phones") + * @JoinColumn(name="user_id", referencedColumnName="id", nullable = false) + */ + public $user; + + public function __construct($user, $number) + { + $this->user = $user; + $this->numericalValue = $number; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php new file mode 100644 index 0000000..f95f77e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1360Test.php @@ -0,0 +1,37 @@ +_em->getConnection()->getDatabasePlatform()->getName() != "postgresql") { + $this->markTestSkipped("PostgreSQL only test."); + } + + $sql = $this->_schemaTool->getCreateSchemaSQL(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1360DoubleQuote') + )); + + $this->assertEquals(array( + 'CREATE TABLE "user"."user" (id INT NOT NULL, PRIMARY KEY(id))', + 'CREATE SEQUENCE "user".user_id_seq INCREMENT BY 1 MINVALUE 1 START 1', + ), $sql); + } +} + +/** + * @Entity @Table(name="`user`.`user`") + */ +class DDC1360DoubleQuote +{ + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php new file mode 100644 index 0000000..f6b5a24 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1383Test.php @@ -0,0 +1,99 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1383AbstractEntity'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1383Entity'), + )); + } catch(\Exception $ignored) {} + } + + public function testFailingCase() + { + $parent = new DDC1383Entity(); + $child = new DDC1383Entity(); + + $child->setReference($parent); + + $this->_em->persist($parent); + $this->_em->persist($child); + + $id = $child->getId(); + + $this->_em->flush(); + $this->_em->clear(); + + // Try merging the parent entity + $child = $this->_em->merge($child); + $parent = $child->getReference(); + + // Parent is not instance of the abstract class + self::assertTrue($parent instanceof DDC1383AbstractEntity, + "Entity class is " . get_class($parent) . ', "DDC1383AbstractEntity" was expected'); + + // Parent is NOT instance of entity + self::assertTrue($parent instanceof DDC1383Entity, + "Entity class is " . get_class($parent) . ', "DDC1383Entity" was expected'); + } +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="integer") + * @DiscriminatorMap({1 = "DDC1383Entity"}) + */ +abstract class DDC1383AbstractEntity +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + protected $id; + + public function getId() + { + return $this->id; + } + + public function setId($id) + { + $this->id = $id; + } +} + +/** + * @Entity + */ +class DDC1383Entity extends DDC1383AbstractEntity +{ + /** + * @ManyToOne(targetEntity="DDC1383AbstractEntity") + */ + protected $reference; + + public function getReference() + { + return $this->reference; + } + + public function setReference(DDC1383AbstractEntity $reference) + { + $this->reference = $reference; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php new file mode 100644 index 0000000..095b197 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1392Test.php @@ -0,0 +1,127 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1392File'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1392Picture'), + )); + } catch (\Exception $ignored) { + } + } + + public function testFailingCase() + { + $file = new DDC1392File; + + $picture = new DDC1392Picture; + $picture->setFile($file); + + $em = $this->_em; + $em->persist($picture); + $em->flush(); + $em->clear(); + + $fileId = $file->getFileId(); + $pictureId = $picture->getPictureId(); + + $this->assertTrue($fileId > 0); + + $picture = $em->find(__NAMESPACE__ . '\DDC1392Picture', $pictureId); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), "Lazy Proxy should be marked MANAGED."); + + $file = $picture->getFile(); + + // With this activated there will be no problem + //$file->__load(); + + $picture->setFile(null); + + $em->clear(); + + $em->merge($file); + + $em->flush(); + + $q = $this->_em->createQuery("SELECT COUNT(e) FROM " . __NAMESPACE__ . '\DDC1392File e'); + $result = $q->getSingleScalarResult(); + + self::assertEquals(1, $result); + } +} + +/** + * @Entity + */ +class DDC1392Picture +{ + /** + * @Column(name="picture_id", type="integer") + * @Id @GeneratedValue + */ + private $pictureId; + + /** + * @ManyToOne(targetEntity="DDC1392File", cascade={"persist", "remove"}) + * @JoinColumn(name="file_id", referencedColumnName="file_id") + */ + private $file; + + /** + * Get pictureId + */ + public function getPictureId() + { + return $this->pictureId; + } + + /** + * Set file + */ + public function setFile($value = null) + { + $this->file = $value; + } + + /** + * Get file + */ + public function getFile() + { + return $this->file; + } +} + +/** + * @Entity + */ +class DDC1392File +{ + /** + * @Column(name="file_id", type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + public $fileId; + + /** + * Get fileId + */ + public function getFileId() + { + return $this->fileId; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php new file mode 100644 index 0000000..2523b5b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1400Test.php @@ -0,0 +1,131 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1400Article'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1400User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1400UserState'), + )); + } catch (\Exception $ignored) { + } + } + + public function testFailingCase() + { + $article = new DDC1400Article; + $user1 = new DDC1400User; + $user2 = new DDC1400User; + + $this->_em->persist($article); + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->flush(); + + $userState1 = new DDC1400UserState; + $userState1->article = $article; + $userState1->articleId = $article->id; + $userState1->user = $user1; + $userState1->userId = $user1->id; + + $userState2 = new DDC1400UserState; + $userState2->article = $article; + $userState2->articleId = $article->id; + $userState2->user = $user2; + $userState2->userId = $user2->id; + + $this->_em->persist($userState1); + $this->_em->persist($userState2); + + $this->_em->flush(); + $this->_em->clear(); + + $user1 = $this->_em->getReference(__NAMESPACE__.'\DDC1400User', $user1->id); + + $q = $this->_em->createQuery("SELECT a, s FROM ".__NAMESPACE__."\DDC1400Article a JOIN a.userStates s WITH s.user = :activeUser"); + $q->setParameter('activeUser', $user1); + $articles = $q->getResult(); + + $this->_em->flush(); + } +} + +/** + * @Entity + */ +class DDC1400Article +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @OneToMany(targetEntity="DDC1400UserState", mappedBy="article", indexBy="userId", fetch="EXTRA_LAZY") + */ + public $userStates; +} + +/** + * @Entity + */ +class DDC1400User +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @OneToMany(targetEntity="DDC1400UserState", mappedBy="user", indexBy="articleId", fetch="EXTRA_LAZY") + */ + public $userStates; +} + +/** + * @Entity + */ +class DDC1400UserState +{ + + /** + * @Id + * @ManyToOne(targetEntity="DDC1400Article", inversedBy="userStates") + */ + public $article; + + /** + * @Id + * @ManyToOne(targetEntity="DDC1400User", inversedBy="userStates") + */ + public $user; + + /** + * @Column(name="user_id", type="integer") + */ + public $userId; + + /** + * @Column(name="article_id", type="integer") + */ + public $articleId; + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php new file mode 100644 index 0000000..cc1d7c9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1404Test.php @@ -0,0 +1,129 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1404ParentEntity'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1404ChildEntity'), + )); + + $this->loadFixtures(); + + } catch (Exception $exc) { + } + } + + public function testTicket() + { + $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1404ChildEntity'); + $queryAll = $repository->createNamedQuery('all'); + $queryFirst = $repository->createNamedQuery('first'); + $querySecond = $repository->createNamedQuery('second'); + + + $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p', $queryAll->getDQL()); + $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 1', $queryFirst->getDQL()); + $this->assertEquals('SELECT p FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1404ChildEntity p WHERE p.id = 2', $querySecond->getDQL()); + + + $this->assertEquals(sizeof($queryAll->getResult()), 2); + $this->assertEquals(sizeof($queryFirst->getResult()), 1); + $this->assertEquals(sizeof($querySecond->getResult()), 1); + } + + + public function loadFixtures() + { + $c1 = new DDC1404ChildEntity("ChildEntity 1"); + $c2 = new DDC1404ChildEntity("ChildEntity 2"); + + $this->_em->persist($c1); + $this->_em->persist($c2); + + $this->_em->flush(); + } + +} + +/** + * @MappedSuperclass + * + * @NamedQueries({ + * @NamedQuery(name="all", query="SELECT p FROM __CLASS__ p"), + * @NamedQuery(name="first", query="SELECT p FROM __CLASS__ p WHERE p.id = 1"), + * }) + */ +class DDC1404ParentEntity +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue() + */ + protected $id; + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + +} + +/** + * @Entity + * + * @NamedQueries({ + * @NamedQuery(name="first", query="SELECT p FROM __CLASS__ p WHERE p.id = 1"), + * @NamedQuery(name="second", query="SELECT p FROM __CLASS__ p WHERE p.id = 2") + * }) + */ +class DDC1404ChildEntity extends DDC1404ParentEntity +{ + + /** + * @column(type="string") + */ + private $name; + + /** + * @param string $name + */ + public function __construct($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php new file mode 100644 index 0000000..cb16e91 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1430Test.php @@ -0,0 +1,297 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1430Order'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1430OrderProduct'), + )); + $this->loadFixtures(); + } catch (\Exception $exc) { + + } + } + + public function testOrderByFields() + { + $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1430Order'); + $builder = $repository->createQueryBuilder('o'); + $query = $builder->select('o.id, o.date, COUNT(p.id) AS p_count') + ->leftJoin('o.products', 'p') + ->groupBy('o.id, o.date') + ->orderBy('o.id') + ->getQuery(); + + $this->assertEquals('SELECT o.id, o.date, COUNT(p.id) AS p_count FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order o LEFT JOIN o.products p GROUP BY o.id, o.date ORDER BY o.id ASC', $query->getDQL()); + $this->assertSQLEquals('SELECT d0_.order_id AS order_id0, d0_.created_at AS created_at1, COUNT(d1_.id) AS sclr2 FROM DDC1430Order d0_ LEFT JOIN DDC1430OrderProduct d1_ ON d0_.order_id = d1_.order_id GROUP BY d0_.order_id, d0_.created_at ORDER BY d0_.order_id ASC', $query->getSQL()); + + + $result = $query->getResult(); + + $this->assertEquals(2, sizeof($result)); + + $this->assertArrayHasKey('id', $result[0]); + $this->assertArrayHasKey('id', $result[1]); + + $this->assertArrayHasKey('p_count', $result[0]); + $this->assertArrayHasKey('p_count', $result[1]); + + $this->assertEquals(1, $result[0]['id']); + $this->assertEquals(2, $result[1]['id']); + + $this->assertEquals(2, $result[0]['p_count']); + $this->assertEquals(3, $result[1]['p_count']); + } + + public function testOrderByAllObjectFields() + { + $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1430Order'); + $builder = $repository->createQueryBuilder('o'); + $query = $builder->select('o, COUNT(p.id) AS p_count') + ->leftJoin('o.products', 'p') + ->groupBy('o.id, o.date, o.status') + ->orderBy('o.id') + ->getQuery(); + + + $this->assertEquals('SELECT o, COUNT(p.id) AS p_count FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order o LEFT JOIN o.products p GROUP BY o.id, o.date, o.status ORDER BY o.id ASC', $query->getDQL()); + $this->assertSQLEquals('SELECT d0_.order_id AS order_id0, d0_.created_at AS created_at1, d0_.order_status AS order_status2, COUNT(d1_.id) AS sclr3 FROM DDC1430Order d0_ LEFT JOIN DDC1430OrderProduct d1_ ON d0_.order_id = d1_.order_id GROUP BY d0_.order_id, d0_.created_at, d0_.order_status ORDER BY d0_.order_id ASC', $query->getSQL()); + + $result = $query->getResult(); + + + $this->assertEquals(2, sizeof($result)); + + $this->assertTrue($result[0][0] instanceof DDC1430Order); + $this->assertTrue($result[1][0] instanceof DDC1430Order); + + $this->assertEquals($result[0][0]->getId(), 1); + $this->assertEquals($result[1][0]->getId(), 2); + + $this->assertEquals($result[0]['p_count'], 2); + $this->assertEquals($result[1]['p_count'], 3); + } + + public function testTicket() + { + $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC1430Order'); + $builder = $repository->createQueryBuilder('o'); + $query = $builder->select('o, COUNT(p.id) AS p_count') + ->leftJoin('o.products', 'p') + ->groupBy('o') + ->orderBy('o.id') + ->getQuery(); + + + $this->assertEquals('SELECT o, COUNT(p.id) AS p_count FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1430Order o LEFT JOIN o.products p GROUP BY o ORDER BY o.id ASC', $query->getDQL()); + $this->assertSQLEquals('SELECT d0_.order_id AS order_id0, d0_.created_at AS created_at1, d0_.order_status AS order_status2, COUNT(d1_.id) AS sclr3 FROM DDC1430Order d0_ LEFT JOIN DDC1430OrderProduct d1_ ON d0_.order_id = d1_.order_id GROUP BY d0_.order_id, d0_.created_at, d0_.order_status ORDER BY d0_.order_id ASC', $query->getSQL()); + + + $result = $query->getResult(); + + $this->assertEquals(2, sizeof($result)); + + $this->assertTrue($result[0][0] instanceof DDC1430Order); + $this->assertTrue($result[1][0] instanceof DDC1430Order); + + $this->assertEquals($result[0][0]->getId(), 1); + $this->assertEquals($result[1][0]->getId(), 2); + + $this->assertEquals($result[0]['p_count'], 2); + $this->assertEquals($result[1]['p_count'], 3); + } + + public function loadFixtures() + { + $o1 = new DDC1430Order('NEW'); + $o2 = new DDC1430Order('OK'); + + $o1->addProduct(new DDC1430OrderProduct(1.1)); + $o1->addProduct(new DDC1430OrderProduct(1.2)); + + $o2->addProduct(new DDC1430OrderProduct(2.1)); + $o2->addProduct(new DDC1430OrderProduct(2.2)); + $o2->addProduct(new DDC1430OrderProduct(2.3)); + + $this->_em->persist($o1); + $this->_em->persist($o2); + + $this->_em->flush(); + } + +} + +/** + * @Entity + */ +class DDC1430Order +{ + + /** + * @Id + * @Column(name="order_id", type="integer") + * @GeneratedValue() + */ + protected $id; + + /** + * @Column(name="created_at", type="datetime") + */ + private $date; + + /** + * @Column(name="order_status", type="string") + */ + private $status; + + /** + * @OneToMany(targetEntity="DDC1430OrderProduct", mappedBy="order", cascade={"persist", "remove"}) + * + * @var \Doctrine\Common\Collections\ArrayCollection $products + */ + private $products; + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + + public function __construct($status) + { + $this->status = $status; + $this->date = new \DateTime(); + $this->products = new \Doctrine\Common\Collections\ArrayCollection(); + } + /** + * @return \DateTime + */ + public function getDate() + { + return $this->date; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function getProducts() + { + return $this->products; + } + + /** + * @param DDC1430OrderProduct $product + */ + public function addProduct(DDC1430OrderProduct $product) + { + $product->setOrder($this); + $this->products->add($product); + } +} + +/** + * @Entity + */ +class DDC1430OrderProduct +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue() + */ + protected $id; + + /** + * @var DDC1430Order $order + * + * @ManyToOne(targetEntity="DDC1430Order", inversedBy="products") + * @JoinColumn(name="order_id", referencedColumnName="order_id", nullable = false) + */ + private $order; + + /** + * @column(type="float") + */ + private $value; + + /** + * @param float $value + */ + public function __construct($value) + { + $this->value = $value; + } + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * @return DDC1430Order + */ + public function getOrder() + { + return $this->order; + } + + /** + * @param DDC1430Order $order + */ + public function setOrder(DDC1430Order $order) + { + $this->order = $order; + } + + /** + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * @param float $value + */ + public function setValue($value) + { + $this->value = $value; + } + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php new file mode 100644 index 0000000..906290c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1436Test.php @@ -0,0 +1,89 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1436Page'), + )); + } catch (\Exception $ignored) { + } + } + + public function testIdentityMap() + { + // fixtures + $parent = null; + for ($i = 0; $i < 3; $i++) { + $page = new DDC1436Page(); + $page->setParent($parent); + $this->_em->persist($page); + $parent = $page; + } + $this->_em->flush(); + $this->_em->clear(); + + $id = $parent->getId(); + + // step 1 + $page = $this->_em + ->createQuery('SELECT p, parent FROM ' . __NAMESPACE__ . '\DDC1436Page p LEFT JOIN p.parent parent WHERE p.id = :id') + ->setParameter('id', $id) + ->getOneOrNullResult(); + + $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page); + + // step 2 + $page = $this->_em->find(__NAMESPACE__ . '\DDC1436Page', $id); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page->getParent()); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC1436Page', $page->getParent()->getParent()); + } +} + +/** + * @Entity + */ +class DDC1436Page +{ + /** + * @Id + * @GeneratedValue + * @Column(type="integer", name="id") + */ + protected $id; + /** + * @ManyToOne(targetEntity="DDC1436Page") + * @JoinColumn(name="pid", referencedColumnName="id") + */ + protected $parent; + + public function getId() + { + return $this->id; + } + + /** + * @return DDC1436Page + */ + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php new file mode 100644 index 0000000..dd6391a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC144Test.php @@ -0,0 +1,64 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC144FlowElement'), + // $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC144Expression'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC144Operand'), + )); + + } + + /** + * @group DDC-144 + */ + public function testIssue() + { + + $operand = new DDC144Operand; + $operand->property = 'flowValue'; + $operand->operandProperty = 'operandValue'; + $this->_em->persist($operand); + $this->_em->flush(); + + } +} + +/** + * @Entity + * @Table(name="ddc144_flowelements") + * @InheritanceType("JOINED") + * @DiscriminatorColumn(type="string", name="discr") + * @DiscriminatorMap({"flowelement" = "DDC144FlowElement", "operand" = "DDC144Operand"}) + */ +class DDC144FlowElement { + /** + * @Id @Column(type="integer") @GeneratedValue + * @var integer + */ + public $id; + /** @Column */ + public $property; +} + +abstract class DDC144Expression extends DDC144FlowElement { + abstract function method(); +} + +/** @Entity @Table(name="ddc144_operands") */ +class DDC144Operand extends DDC144Expression { + /** @Column */ + public $operandProperty; + function method() {} +} + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php new file mode 100644 index 0000000..aef2d10 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -0,0 +1,127 @@ +useModelSet('cms'); + parent::setUp(); + + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityA'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityB'), + )); + } catch (\Exception $ignored) { + } + } + + public function testIssue() + { + $a1 = new DDC1452EntityA(); + $a1->title = "foo"; + + $a2 = new DDC1452EntityA(); + $a2->title = "bar"; + + $b = new DDC1452EntityB(); + $b->entityAFrom = $a1; + $b->entityATo = $a2; + + $this->_em->persist($a1); + $this->_em->persist($a2); + $this->_em->persist($b); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT a, b, ba FROM " . __NAMESPACE__ . "\DDC1452EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba"; + $results = $this->_em->createQuery($dql)->setMaxResults(1)->getResult(); + + $this->assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom); + $this->assertFalse( $results[0]->entitiesB[0]->entityATo instanceof \Doctrine\ORM\Proxy\Proxy ); + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results[0]->entitiesB[0]->entityATo->getEntitiesB()); + } + + public function testFetchJoinOneToOneFromInverse() + { + $address = new \Doctrine\Tests\Models\CMS\CmsAddress(); + $address->city = "Bonn"; + $address->country = "Germany"; + $address->street = "Somestreet"; + $address->zip = 12345; + + $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user->name = "beberlei"; + $user->username = "beberlei"; + $user->status = "active"; + $user->address = $address; + $address->user = $user; + + $this->_em->persist($address); + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT a, u FROM Doctrine\Tests\Models\CMS\CmsAddress a INNER JOIN a.user u"; + $data = $this->_em->createQuery($dql)->getResult(); + $this->_em->clear(); + + $this->assertFalse($data[0]->user instanceof \Doctrine\ORM\Proxy\Proxy); + + $dql = "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.address a"; + $data = $this->_em->createQuery($dql)->getResult(); + + $this->assertFalse($data[0]->address instanceof \Doctrine\ORM\Proxy\Proxy); + } +} + +/** + * @Entity + */ +class DDC1452EntityA +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column */ + public $title; + /** @ManyToMany(targetEntity="DDC1452EntityB", mappedBy="entityAFrom") */ + public $entitiesB; + + public function __construct() + { + $this->entitiesB = new ArrayCollection(); + } + + public function getEntitiesB() + { + return $this->entitiesB; + } +} + +/** + * @Entity + */ +class DDC1452EntityB +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** + * @ManyToOne(targetEntity="DDC1452EntityA", inversedBy="entitiesB") + */ + public $entityAFrom; + /** + * @ManyToOne(targetEntity="DDC1452EntityA") + */ + public $entityATo; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php new file mode 100644 index 0000000..eaf9dd3 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -0,0 +1,69 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1454File'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1454Picture'), + )); + } catch (\Exception $ignored) { + + } + } + + public function testFailingCase() + { + $pic = new DDC1454Picture(); + $this->_em->getUnitOfWork()->getEntityState($pic); + } + +} + +/** + * @Entity + */ +class DDC1454Picture extends DDC1454File +{ + +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"picture" = "DDC1454Picture"}) + */ +class DDC1454File +{ + /** + * @Column(name="file_id", type="integer") + * @Id + */ + public $fileId; + + public function __construct() { + $this->fileId = rand(); + } + + /** + * Get fileId + */ + public function getFileId() { + return $this->fileId; + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php new file mode 100644 index 0000000..745b51c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1458Test.php @@ -0,0 +1,131 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\TestEntity'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\TestAdditionalEntity') + )); + } + + public function testIssue() + { + $testEntity = new TestEntity(); + $testEntity->setValue(3); + $testEntity->setAdditional(new TestAdditionalEntity()); + $this->_em->persist($testEntity); + $this->_em->flush(); + $this->_em->clear(); + + // So here the value is 3 + $this->assertEquals(3, $testEntity->getValue()); + + $test = $this->_em->getRepository(__NAMESPACE__ . '\TestEntity')->find(1); + + // New value is set + $test->setValue(5); + + // So here the value is 5 + $this->assertEquals(5, $test->getValue()); + + // Get the additional entity + $additional = $test->getAdditional(); + + // Still 5.. + $this->assertEquals(5, $test->getValue()); + + // Force the proxy to load + $additional->getBool(); + + // The value should still be 5 + $this->assertEquals(5, $test->getValue()); + } +} + + +/** + * @Entity + */ +class TestEntity +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + /** + * @Column(type="integer") + */ + protected $value; + /** + * @OneToOne(targetEntity="TestAdditionalEntity", inversedBy="entity", orphanRemoval=true, cascade={"persist", "remove"}) + */ + protected $additional; + + public function getValue() + { + return $this->value; + } + + public function setValue($value) + { + $this->value = $value; + } + + public function getAdditional() + { + return $this->additional; + } + + public function setAdditional($additional) + { + $this->additional = $additional; + } +} +/** + * @Entity + */ +class TestAdditionalEntity +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + /** + * @OneToOne(targetEntity="TestEntity", mappedBy="additional") + */ + protected $entity; + /** + * @Column(type="boolean") + */ + protected $bool; + + public function __construct() + { + $this->bool = false; + } + + public function getBool() + { + return $this->bool; + } + + public function setBool($bool) + { + $this->bool = $bool; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php new file mode 100644 index 0000000..e6aa2e6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1461Test.php @@ -0,0 +1,86 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1461TwitterAccount'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1461User') + )); + } catch(\Exception $e) { + + } + } + + public function testChangeDetectionDeferredExplicit() + { + $user = new DDC1461User; + $this->_em->persist($user); + $this->_em->flush(); + + $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user, \Doctrine\ORM\UnitOfWork::STATE_NEW), "Entity should be managed."); + $this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($user), "Entity should be managed."); + + $acc = new DDC1461TwitterAccount; + $user->twitterAccount = $acc; + + $this->_em->persist($user); + $this->_em->flush(); + + $user = $this->_em->find(get_class($user), $user->id); + $this->assertNotNull($user->twitterAccount); + } +} + +/** + * @Entity + * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") + */ +class DDC1461User +{ + /** + * @Id + * @GeneratedValue(strategy="AUTO") + * @Column(type="integer") + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC1461TwitterAccount", orphanRemoval=true, fetch="EAGER", cascade = {"persist"}, inversedBy="user") + * @var TwitterAccount + */ + public $twitterAccount; +} + +/** + * @Entity + * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") + */ +class DDC1461TwitterAccount +{ + /** + * @Id + * @GeneratedValue(strategy="AUTO") + * @Column(type="integer") + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC1461User", fetch="EAGER") + */ + public $user; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php new file mode 100644 index 0000000..6ba0cd4 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php @@ -0,0 +1,146 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509AbstractFile'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509File'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1509Picture'), + )); + } catch (\Exception $ignored) { + + } + } + + public function testFailingCase() + { + $file = new DDC1509File; + $thumbnail = new DDC1509File; + + $picture = new DDC1509Picture; + $picture->setFile($file); + $picture->setThumbnail($thumbnail); + + + /* @var $em \Doctrine\ORM\EntityManager */ + $em = $this->_em; + $em->persist($picture); + $em->flush(); + $em->clear(); + + $id = $picture->getPictureId(); + + $pic = $em->merge($picture); + /* @var $pic DDC1509Picture */ + + $this->assertNotNull($pic->getThumbnail()); + $this->assertNotNull($pic->getFile()); + } + +} + +/** + * @Entity + */ +class DDC1509Picture +{ + + /** + * @Column(type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @ManyToOne(targetEntity="DDC1509AbstractFile", cascade={"persist", "remove"}) + */ + private $thumbnail; + + /** + * @ManyToOne(targetEntity="DDC1509AbstractFile", cascade={"persist", "remove"}) + */ + private $file; + + /** + * Get pictureId + */ + public function getPictureId() + { + return $this->id; + } + + /** + * Set file + */ + public function setFile($value = null) + { + $this->file = $value; + } + + /** + * Get file + */ + public function getFile() + { + return $this->file; + } + + public function getThumbnail() + { + return $this->thumbnail; + } + + public function setThumbnail($thumbnail) + { + $this->thumbnail = $thumbnail; + } + +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"file" = "DDC1509File"}) + */ +class DDC1509AbstractFile +{ + + /** + * @Column(type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * Get fileId + */ + public function getFileId() + { + return $this->id; + } + +} + +/** + * @Entity + */ +class DDC1509File extends DDC1509AbstractFile +{ + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php new file mode 100644 index 0000000..17b0288 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1514Test.php @@ -0,0 +1,113 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1514EntityA'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1514EntityB'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1514EntityC'), + )); + } catch (\Exception $ignored) { + } + } + + public function testIssue() + { + $a1 = new DDC1514EntityA(); + $a1->title = "foo"; + + $a2 = new DDC1514EntityA(); + $a2->title = "bar"; + + $b1 = new DDC1514EntityB(); + $b1->entityAFrom = $a1; + $b1->entityATo = $a2; + + $b2 = new DDC1514EntityB(); + $b2->entityAFrom = $a2; + $b2->entityATo = $a1; + + $c = new DDC1514EntityC(); + $c->title = "baz"; + $a2->entityC = $c; + + $this->_em->persist($a1); + $this->_em->persist($a2); + $this->_em->persist($b1); + $this->_em->persist($b2); + $this->_em->persist($c); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT a, b, ba, c FROM " . __NAMESPACE__ . "\DDC1514EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba LEFT JOIN a.entityC AS c"; + $results = $this->_em->createQuery($dql)->getResult(); + + $this->assertInternalType('array', $results); + $this->assertTrue(count($results) >= 1, "At least one result expected in array"); + $this->assertEquals($c->title, $results[1]->entityC->title); + } +} + +/** + * @Entity + */ +class DDC1514EntityA +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column */ + public $title; + /** @ManyToMany(targetEntity="DDC1514EntityB", mappedBy="entityAFrom") */ + public $entitiesB; + /** @ManyToOne(targetEntity="DDC1514EntityC") */ + public $entityC; + + public function __construct() + { + $this->entitiesB = new ArrayCollection(); + } +} + +/** + * @Entity + */ +class DDC1514EntityB +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** + * @ManyToOne(targetEntity="DDC1514EntityA", inversedBy="entitiesB") + */ + public $entityAFrom; + /** + * @ManyToOne(targetEntity="DDC1514EntityA") + */ + public $entityATo; +} + +/** + * @Entity + */ +class DDC1514EntityC +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column */ + public $title; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php new file mode 100644 index 0000000..9bd3360 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1515Test.php @@ -0,0 +1,64 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Foo'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1515Bar'), + )); + } + + public function testIssue() + { + $bar = new DDC1515Bar(); + $this->_em->persist($bar); + $this->_em->flush(); + + $foo = new DDC1515Foo(); + $foo->bar = $bar; + $this->_em->persist($foo); + $this->_em->flush(); + $this->_em->clear(); + + $bar = $this->_em->find(__NAMESPACE__ . '\DDC1515Bar', $bar->id); + $this->assertInstanceOf(__NAMESPACE__.'\DDC1515Foo', $bar->foo); + } +} + +/** + * @Entity + */ +class DDC1515Foo +{ + /** + * @OneToOne(targetEntity="DDC1515Bar", inversedBy="foo") @Id + */ + public $bar; +} + +/** + * @Entity + */ +class DDC1515Bar +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC1515Foo", mappedBy="bar") + */ + public $foo; +} + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php new file mode 100644 index 0000000..27d0a87 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1526Test.php @@ -0,0 +1,67 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1526Menu'), + )); + } + + public function testIssue() + { + $parents = array(); + for ($i = 0; $i < 9; $i++) { + $entity = new DDC1526Menu; + + if (isset ($parents[($i % 3)])) { + $entity->parent = $parents[($i%3)]; + } + + $this->_em->persist($entity); + $parents[$i] = $entity; + } + $this->_em->flush(); + $this->_em->clear(); + + + $dql = "SELECT m, c + FROM " . __NAMESPACE__ . "\DDC1526Menu m + LEFT JOIN m.children c"; + $menus = $this->_em->createQuery($dql)->getResult(); + + // All Children collection now have to be initiailzed + foreach ($menus as $menu) { + $this->assertTrue($menu->children->isInitialized()); + } + } +} + +/** + * @Entity + */ +class DDC1526Menu +{ + /** + * @Column(type="integer") + * @Id + * @GeneratedValue + */ + public $id; + /** + * @ManyToOne(targetEntity="DDC1526Menu", inversedBy="children") + */ + public $parent; + + /** + * @OneToMany(targetEntity="DDC1526Menu", mappedBy="parent") + */ + public $children; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php new file mode 100644 index 0000000..6af9cc5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1545Test.php @@ -0,0 +1,201 @@ +useModelSet('cms'); + parent::setUp(); + } + + private function initDb($link) + { + $article = new CmsArticle(); + $article->topic = 'foo'; + $article->text = 'foo'; + + $user = new CmsUser(); + $user->status = 'foo'; + $user->username = 'foo'; + $user->name = 'foo'; + + $user2 = new CmsUser(); + $user2->status = 'bar'; + $user2->username = 'bar'; + $user2->name = 'bar'; + + if ($link) { + $article->user = $user; + } + + $this->_em->persist($article); + $this->_em->persist($user); + $this->_em->persist($user2); + $this->_em->flush(); + $this->_em->clear(); + + $this->articleId = $article->id; + $this->userId = $user->id; + $this->user2Id = $user2->id; + } + + public function testLinkObjects() + { + $this->initDb(false); + + // don't join association + $article = $this->_em->find('Doctrine\Tests\Models\Cms\CmsArticle', $this->articleId); + + $user = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->userId); + + $article->user = $user; + + $this->_em->flush(); + $this->_em->clear(); + + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $this->assertNotNull($article->user); + $this->assertEquals($user->id, $article->user->id); + } + + public function testLinkObjectsWithAssociationLoaded() + { + $this->initDb(false); + + // join association + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $user = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->userId); + + $article->user = $user; + + $this->_em->flush(); + $this->_em->clear(); + + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $this->assertNotNull($article->user); + $this->assertEquals($user->id, $article->user->id); + } + + public function testUnlinkObjects() + { + $this->initDb(true); + + // don't join association + $article = $this->_em->find('Doctrine\Tests\Models\Cms\CmsArticle', $this->articleId); + + $article->user = null; + + $this->_em->flush(); + $this->_em->clear(); + + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $this->assertNull($article->user); + } + + public function testUnlinkObjectsWithAssociationLoaded() + { + $this->initDb(true); + + // join association + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $article->user = null; + + $this->_em->flush(); + $this->_em->clear(); + + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $this->assertNull($article->user); + } + + public function testChangeLink() + { + $this->initDb(false); + + // don't join association + $article = $this->_em->find('Doctrine\Tests\Models\Cms\CmsArticle', $this->articleId); + + $user2 = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->user2Id); + + $article->user = $user2; + + $this->_em->flush(); + $this->_em->clear(); + + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $this->assertNotNull($article->user); + $this->assertEquals($user2->id, $article->user->id); + } + + public function testChangeLinkWithAssociationLoaded() + { + $this->initDb(false); + + // join association + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $user2 = $this->_em->find('Doctrine\Tests\Models\Cms\CmsUser', $this->user2Id); + + $article->user = $user2; + + $this->_em->flush(); + $this->_em->clear(); + + $article = $this->_em + ->createQuery('SELECT a, u FROM Doctrine\Tests\Models\Cms\CmsArticle a LEFT JOIN a.user u WHERE a.id = :id') + ->setParameter('id', $this->articleId) + ->getOneOrNullResult(); + + $this->assertNotNull($article->user); + $this->assertEquals($user2->id, $article->user->id); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php new file mode 100644 index 0000000..74c1fe1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1548Test.php @@ -0,0 +1,81 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548E1'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548E2'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548Rel'), + )); + } + + public function testIssue() + { + $rel = new DDC1548Rel(); + $this->_em->persist($rel); + $this->_em->flush(); + + $e1 = new DDC1548E1(); + $e1->rel = $rel; + $this->_em->persist($e1); + $this->_em->flush(); + $this->_em->clear(); + + $obt = $this->_em->find(__NAMESPACE__ . '\DDC1548Rel', $rel->id); + + $this->assertNull($obt->e2); + } +} + +/** + * @Entity + */ +class DDC1548E1 +{ + /** + * @Id + * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e1") + */ + public $rel; +} + +/** + * @Entity + */ +class DDC1548E2 +{ + /** + * @Id + * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e2") + */ + public $rel; +} + +/** + * @Entity + */ +class DDC1548Rel +{ + /** + * @Id @GeneratedValue + * @Column(type="integer") + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC1548E1", mappedBy="rel") + */ + public $e1; + /** + * @OneToOne(targetEntity="DDC1548E2", mappedBy="rel") + */ + public $e2; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php new file mode 100644 index 0000000..b8dec40 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1594Test.php @@ -0,0 +1,45 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testIssue() + { + $user = new CmsUser(); + $user->status = 'foo'; + $user->username = 'foo'; + $user->name = 'foo'; + + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->clear(); + $detachedUser = clone $user; + $detachedUser->name = 'bar'; + $detachedUser->status = 'bar'; + + $newUser = $this->_em->getReference(get_class($user), $user->id); + + $mergedUser = $this->_em->merge($detachedUser); + + $this->assertNotSame($mergedUser, $detachedUser); + $this->assertEquals('bar', $detachedUser->getName()); + $this->assertEquals('bar', $mergedUser->getName()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php new file mode 100644 index 0000000..d3116ce --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1595Test.php @@ -0,0 +1,111 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack); + + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1595BaseInheritance'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1595InheritedEntity1'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1595InheritedEntity2'), + )); + } + + public function testIssue() + { + $e1 = new DDC1595InheritedEntity1(); + + $this->_em->persist($e1); + $this->_em->flush(); + $this->_em->clear(); + + $sqlLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger(); + $repository = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1595InheritedEntity1'); + + $entity1 = $repository->find($e1->id); + + // DDC-1596 + $this->assertSQLEquals( + "SELECT t0.id AS id1, t0.type FROM base t0 WHERE t0.id = ? AND t0.type IN ('Entity1')", + $sqlLogger->queries[count($sqlLogger->queries)]['sql'] + ); + + $entities = $entity1->getEntities()->getValues(); + + $this->assertSQLEquals( + "SELECT t0.id AS id1, t0.type FROM base t0 INNER JOIN entity1_entity2 ON t0.id = entity1_entity2.item WHERE entity1_entity2.parent = ? AND t0.type IN ('Entity2')", + $sqlLogger->queries[count($sqlLogger->queries)]['sql'] + ); + + $this->_em->clear(); + + $entity1 = $repository->find($e1->id); + $entities = $entity1->getEntities()->count(); + + $this->assertSQLEquals( + "SELECT COUNT(*) FROM entity1_entity2 t WHERE parent = ?", + $sqlLogger->queries[count($sqlLogger->queries)]['sql'] + ); + } +} + +/** + * @Entity + * @Table(name="base") + * + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorColumn(name="type", type="string") + * @DiscriminatorMap({ + * "Entity1" = "DDC1595InheritedEntity1", + * "Entity2" = "DDC1595InheritedEntity2" + * }) + */ +abstract class DDC1595BaseInheritance +{ + /** + * @Id @GeneratedValue + * @Column(type="integer") + * + * @var integer + */ + public $id; +} + +/** + * @Entity + * @Table(name="entity1") + */ +class DDC1595InheritedEntity1 extends DDC1595BaseInheritance +{ + /** + * @ManyToMany(targetEntity="DDC1595InheritedEntity2", fetch="EXTRA_LAZY") + * @JoinTable(name="entity1_entity2", + * joinColumns={@JoinColumn(name="parent", referencedColumnName="id")}, + * inverseJoinColumns={@JoinColumn(name="item", referencedColumnName="id")} + * ) + */ + protected $entities; + + public function getEntities() + { + return $this->entities; + } +} + +/** + * @Entity + * @Table(name="entity2") + */ +class DDC1595InheritedEntity2 extends DDC1595BaseInheritance +{ +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php new file mode 100644 index 0000000..3126d54 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC163Test.php @@ -0,0 +1,65 @@ +useModelSet('company'); + parent::setUp(); + } + + /** + * @group DDC-163 + */ + public function testQueryWithOrConditionUsingTwoRelationOnSameEntity() + { + $p1 = new CompanyPerson; + $p1->setName('p1'); + + $p2 = new CompanyPerson; + $p2->setName('p2'); + + $p3 = new CompanyPerson; + $p3->setName('p3'); + + $p4 = new CompanyPerson; + $p4->setName('p4'); + + $p1->setSpouse($p3); + $p1->addFriend($p2); + $p2->addFriend($p3); + + $p3->addFriend($p4); + + $this->_em->persist($p1); + $this->_em->persist($p2); + $this->_em->persist($p3); + $this->_em->persist($p4); + + $this->_em->flush(); + $this->_em->clear(); + + $dql = 'SELECT PARTIAL person.{id,name}, PARTIAL spouse.{id,name}, PARTIAL friend.{id,name} + FROM Doctrine\Tests\Models\Company\CompanyPerson person + LEFT JOIN person.spouse spouse + LEFT JOIN person.friends friend + LEFT JOIN spouse.friends spouse_friend + LEFT JOIN friend.friends friend_friend + WHERE person.name=:name AND (spouse_friend.name=:name2 OR friend_friend.name=:name2)'; + + $q = $this->_em->createQuery($dql); + $q->setParameter('name', "p1"); + $q->setParameter('name2', "p4"); + $result = $q->getScalarResult(); + + $this->assertEquals('p3', $result[0]['spouse_name']); + $this->assertEquals('p1', $result[0]['person_name']); + $this->assertEquals('p2', $result[0]['friend_name']); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php new file mode 100644 index 0000000..53d6bb6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1643Test.php @@ -0,0 +1,121 @@ +useModelSet('cms'); + parent::setUp(); + + $user1 = new CmsUser(); + $user1->username = "beberlei"; + $user1->name = "Benjamin"; + $user1->status = "active"; + $group1 = new CmsGroup(); + $group1->name = "test"; + $group2 = new CmsGroup(); + $group2->name = "test"; + $user1->addGroup($group1); + $user1->addGroup($group2); + $user2 = new CmsUser(); + $user2->username = "romanb"; + $user2->name = "Roman"; + $user2->status = "active"; + + $this->_em->persist($user1); + $this->_em->persist($user2); + $this->_em->persist($group1); + $this->_em->persist($group2); + $this->_em->flush(); + $this->_em->clear(); + + $this->user1 = $this->_em->find(get_class($user1), $user1->id); + $this->user2 = $this->_em->find(get_class($user1), $user2->id); + } + + public function testClonePersistentCollectionAndReuse() + { + $user1 = $this->user1; + + $user1->groups = clone $user1->groups; + + $this->_em->flush(); + $this->_em->clear(); + + $user1 = $this->_em->find(get_class($user1), $user1->id); + + $this->assertEquals(2, count($user1->groups)); + } + + public function testClonePersistentCollectionAndShare() + { + $user1 = $this->user1; + $user2 = $this->user2; + + $user2->groups = clone $user1->groups; + + $this->_em->flush(); + $this->_em->clear(); + + $user1 = $this->_em->find(get_class($user1), $user1->id); + $user2 = $this->_em->find(get_class($user1), $user2->id); + + $this->assertEquals(2, count($user1->groups)); + $this->assertEquals(2, count($user2->groups)); + } + + public function testCloneThenDirtyPersistentCollection() + { + $user1 = $this->user1; + $user2 = $this->user2; + + $group3 = new CmsGroup(); + $group3->name = "test"; + $user2->groups = clone $user1->groups; + $user2->groups->add($group3); + + $this->_em->persist($group3); + $this->_em->flush(); + $this->_em->clear(); + + $user1 = $this->_em->find(get_class($user1), $user1->id); + $user2 = $this->_em->find(get_class($user1), $user2->id); + + $this->assertEquals(3, count($user2->groups)); + $this->assertEquals(2, count($user1->groups)); + } + + public function testNotCloneAndPassAroundFlush() + { + $user1 = $this->user1; + $user2 = $this->user2; + + $group3 = new CmsGroup(); + $group3->name = "test"; + $user2->groups = $user1->groups; + $user2->groups->add($group3); + + $this->assertEQuals(1, count($user1->groups->getInsertDiff())); + + $this->_em->persist($group3); + $this->_em->flush(); + $this->_em->clear(); + + $user1 = $this->_em->find(get_class($user1), $user1->id); + $user2 = $this->_em->find(get_class($user1), $user2->id); + + $this->assertEquals(3, count($user2->groups)); + $this->assertEquals(3, count($user1->groups)); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php new file mode 100644 index 0000000..0169619 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1654Test.php @@ -0,0 +1,103 @@ +setUpEntitySchema(array( + __NAMESPACE__ . '\\DDC1654Post', + __NAMESPACE__ . '\\DDC1654Comment', + )); + } + + public function testManyToManyRemoveFromCollectionOrphanRemoval() + { + $post = new DDC1654Post(); + $post->comments[] = new DDC1654Comment(); + $post->comments[] = new DDC1654Comment(); + + $this->_em->persist($post); + $this->_em->flush(); + + $post->comments->remove(0); + $post->comments->remove(1); + + $this->_em->flush(); + $this->_em->clear(); + + $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll(); + $this->assertEquals(0, count($comments)); + } + + public function testManyToManyRemoveElementFromCollectionOrphanRemoval() + { + $post = new DDC1654Post(); + $post->comments[] = new DDC1654Comment(); + $post->comments[] = new DDC1654Comment(); + + $this->_em->persist($post); + $this->_em->flush(); + + $post->comments->removeElement($post->comments[0]); + $post->comments->removeElement($post->comments[1]); + + $this->_em->flush(); + $this->_em->clear(); + + $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll(); + $this->assertEquals(0, count($comments)); + } + + public function testManyToManyClearCollectionOrphanRemoval() + { + $post = new DDC1654Post(); + $post->comments[] = new DDC1654Comment(); + $post->comments[] = new DDC1654Comment(); + + $this->_em->persist($post); + $this->_em->flush(); + + $post->comments->clear(); + + $this->_em->flush(); + $this->_em->clear(); + + $comments = $this->_em->getRepository(__NAMESPACE__ . '\\DDC1654Comment')->findAll(); + $this->assertEquals(0, count($comments)); + + } +} + +/** + * @Entity + */ +class DDC1654Post +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; + + /** + * @ManyToMany(targetEntity="DDC1654Comment", orphanRemoval=true, + * cascade={"persist"}) + */ + public $comments = array(); +} + +/** + * @Entity + */ +class DDC1654Comment +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php new file mode 100644 index 0000000..22b20e7 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1655Test.php @@ -0,0 +1,144 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Foo'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Bar'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1655Baz'), + )); + } catch(\Exception $e) { + + } + } + + public function testPostLoadOneToManyInheritance() + { + $cm = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1655Foo'); + $this->assertEquals(array("postLoad" => array("postLoad")), $cm->lifecycleCallbacks); + + $cm = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1655Bar'); + $this->assertEquals(array("postLoad" => array("postLoad", "postSubLoaded")), $cm->lifecycleCallbacks); + + $baz = new DDC1655Baz(); + $foo = new DDC1655Foo(); + $foo->baz = $baz; + $bar = new DDC1655Bar(); + $bar->baz = $baz; + + $this->_em->persist($foo); + $this->_em->persist($bar); + $this->_em->persist($baz); + $this->_em->flush(); + $this->_em->clear(); + + $baz = $this->_em->find(get_class($baz), $baz->id); + foreach ($baz->foos as $foo) { + $this->assertEquals(1, $foo->loaded, "should have loaded callback counter incremented for " . get_class($foo)); + } + } + + /** + * Check that post load is not executed several times when the entity + * is rehydrated again although its already known. + */ + public function testPostLoadInheritanceChild() + { + $bar = new DDC1655Bar(); + + $this->_em->persist($bar); + $this->_em->flush(); + $this->_em->clear(); + + $bar = $this->_em->find(get_class($bar), $bar->id); + $this->assertEquals(1, $bar->loaded); + $this->assertEquals(1, $bar->subLoaded); + + $bar = $this->_em->find(get_class($bar), $bar->id); + $this->assertEquals(1, $bar->loaded); + $this->assertEquals(1, $bar->subLoaded); + + $dql = "SELECT b FROM " . __NAMESPACE__ . "\DDC1655Bar b WHERE b.id = ?1"; + $bar = $this->_em->createQuery($dql)->setParameter(1, $bar->id)->getSingleResult(); + + $this->assertEquals(1, $bar->loaded); + $this->assertEquals(1, $bar->subLoaded); + + $this->_em->refresh($bar); + + $this->assertEquals(2, $bar->loaded); + $this->assertEquals(2, $bar->subLoaded); + } +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorMap({ + * "foo" = "DDC1655Foo", + * "bar" = "DDC1655Bar" + * }) + * @HasLifecycleCallbacks + */ +class DDC1655Foo +{ + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + + public $loaded = 0; + + /** + * @ManyToOne(targetEntity="DDC1655Baz", inversedBy="foos") + */ + public $baz; + + /** + * @PostLoad + */ + public function postLoad() + { + $this->loaded++; + } +} + +/** + * @Entity + * @HasLifecycleCallbacks + */ +class DDC1655Bar extends DDC1655Foo +{ + public $subLoaded; + + /** + * @PostLoad + */ + public function postSubLoaded() + { + $this->subLoaded++; + } +} + +/** + * @Entity + */ +class DDC1655Baz +{ + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + + /** + * @OneToMany(targetEntity="DDC1655Foo", mappedBy="baz") + */ + public $foos = array(); +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php new file mode 100644 index 0000000..0b53780 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php @@ -0,0 +1,64 @@ +useModelSet('company'); + parent::setUp(); + + $this->oldMetadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee'); + + $metadata = clone $this->oldMetadata; + ksort($metadata->reflFields); + $this->_em->getMetadataFactory()->setMetadataFor('Doctrine\Tests\Models\Company\CompanyEmployee', $metadata); + } + + public function tearDown() + { + $this->_em->getMetadataFactory()->setMetadataFor('Doctrine\Tests\Models\Company\CompanyEmployee', $this->oldMetadata); + parent::tearDown(); + } + + /** + * @group DDC-168 + */ + public function testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $spouse = new CompanyEmployee; + $spouse->setName("Blub"); + $spouse->setDepartment("Accounting"); + $spouse->setSalary(500); + + $employee = new CompanyEmployee; + $employee->setName("Foo"); + $employee->setDepartment("bar"); + $employee->setSalary(1000); + $employee->setSpouse($spouse); + + $this->_em->persist($spouse); + $this->_em->persist($employee); + + $this->_em->flush(); + $this->_em->clear(); + + $q = $this->_em->createQuery("SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e WHERE e.name = ?1"); + $q->setParameter(1, "Foo"); + $theEmployee = $q->getSingleResult(); + + $this->assertEquals("bar", $theEmployee->getDepartment()); + $this->assertEquals("Foo", $theEmployee->getName()); + $this->assertEquals(1000, $theEmployee->getSalary()); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee); + $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee->getSpouse()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php new file mode 100644 index 0000000..dc1f884 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1695Test.php @@ -0,0 +1,158 @@ +_em->getConnection()->getDatabasePlatform()->getName() != "sqlite") { + $this->markTestSkipped("Only with sqlite"); + } + $dql = "SELECT n.smallText, n.publishDate FROM " . __NAMESPACE__ . "\\DDC1695News n"; + $sql = $this->_em->createQuery($dql)->getSQL(); + + $this->assertEquals( + 'SELECT d0_."SmallText" AS SmallText0, d0_."PublishDate" AS PublishDate1 FROM "DDC1695News" d0_', + $sql + ); + } +} + +/** + * @Table(name="`DDC1695News`") + * @Entity + */ +class DDC1695News +{ + /** + * @var integer $idNews + * + * @Column(name="`IdNews`", type="integer", nullable=false) + * @Id + * @GeneratedValue + */ + private $idNews; + + /** + * @var bigint $iduser + * + * @Column(name="`IdUser`", type="bigint", nullable=false) + */ + private $idUser; + + /** + * @var integer $idLanguage + * + * @Column(name="`IdLanguage`", type="integer", nullable=false) + */ + private $idLanguage; + + /** + * @var integer $idCondition + * + * @Column(name="`IdCondition`", type="integer", nullable=true) + */ + private $idCondition; + + /** + * @var integer $idHealthProvider + * + * @Column(name="`IdHealthProvider`", type="integer", nullable=true) + */ + private $idHealthProvider; + + /** + * @var integer $idSpeciality + * + * @Column(name="`IdSpeciality`", type="integer", nullable=true) + */ + private $idSpeciality; + + /** + * @var integer $idMedicineType + * + * @Column(name="`IdMedicineType`", type="integer", nullable=true) + */ + private $idMedicineType; + + /** + * @var integer $idTreatment + * + * @Column(name="`IdTreatment`", type="integer", nullable=true) + */ + private $idTreatment; + + /** + * @var string $title + * + * @Column(name="`Title`", type="string", nullable=true) + */ + private $title; + + /** + * @var string $smallText + * + * @Column(name="`SmallText`", type="string", nullable=true) + */ + private $smallText; + + /** + * @var string $longText + * + * @Column(name="`LongText`", type="string", nullable=true) + */ + private $longText; + + /** + * @var datetimetz $publishDate + * + * @Column(name="`PublishDate`", type="datetimetz", nullable=true) + */ + private $publishDate; + + /** + * @var tsvector $idxNews + * + * @Column(name="`IdxNews`", type="tsvector", nullable=true) + */ + private $idxNews; + + /** + * @var boolean $highlight + * + * @Column(name="`Highlight`", type="boolean", nullable=false) + */ + private $highlight; + + /** + * @var integer $order + * + * @Column(name="`Order`", type="integer", nullable=false) + */ + private $order; + + /** + * @var boolean $deleted + * + * @Column(name="`Deleted`", type="boolean", nullable=false) + */ + private $deleted; + + /** + * @var boolean $active + * + * @Column(name="`Active`", type="boolean", nullable=false) + */ + private $active; + + /** + * @var boolean $updateToHighlighted + * + * @Column(name="`UpdateToHighlighted`", type="boolean", nullable=true) + */ + private $updateToHighlighted; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php new file mode 100644 index 0000000..aebc642 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1778Test.php @@ -0,0 +1,74 @@ +useModelSet('cms'); + parent::setUp(); + + $this->user = new CmsUser(); + $this->user->username = "beberlei"; + $this->user->name = "Benjamin"; + $this->user->status = "active"; + + $this->phone = new CmsPhoneNumber(); + $this->phone->phonenumber = '0123456789'; + $this->user->addPhoneNumber($this->phone); + + $this->_em->persist($this->user); + $this->_em->persist($this->phone); + $this->_em->flush(); + $this->_em->clear(); + + $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); + $this->phone = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsPhonenumber', $this->phone->phonenumber); + } + + public function testClear() + { + $clonedNumbers = clone $this->user->getPhonenumbers(); + $clonedNumbers->clear(); + $this->_em->flush(); + $this->_em->clear(); + + $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); + + $this->assertCount(1, $this->user->getPhonenumbers()); + } + + public function testRemove() + { + $clonedNumbers = clone $this->user->getPhonenumbers(); + $clonedNumbers->remove(0); + $this->_em->flush(); + $this->_em->clear(); + + $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); + + $this->assertCount(1, $this->user->getPhonenumbers()); + } + + public function testRemoveElement() + { + $clonedNumbers = clone $this->user->getPhonenumbers(); + $clonedNumbers->removeElement($this->phone); + $this->_em->flush(); + $this->_em->clear(); + + $this->user = $this->_em->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', $this->user->getId()); + + $this->assertCount(1, $this->user->getPhonenumbers()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php new file mode 100644 index 0000000..18eb769 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC192Test.php @@ -0,0 +1,65 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC192User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC192Phonenumber') + )); + } +} + + +/** + * @Entity @Table(name="ddc192_users") + */ +class DDC192User +{ + /** + * @Id @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column(name="name", type="string") + */ + public $name; +} + + +/** + * @Entity @Table(name="ddc192_phonenumbers") + */ +class DDC192Phonenumber +{ + /** + * @Id @Column(name="phone", type="string", length=40) + */ + protected $phone; + + /** + * @Id + * @ManyToOne(targetEntity="DDC192User") + * @JoinColumn(name="userId", referencedColumnName="id") + */ + protected $User; + + + public function setPhone($value) { $this->phone = $value; } + + public function getPhone() { return $this->phone; } + + public function setUser(User $user) + { + $this->User = $user; + } + + public function getUser() { return $this->User; } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php new file mode 100644 index 0000000..9084ec0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC199Test.php @@ -0,0 +1,100 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC199ParentClass'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC199ChildClass'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC199RelatedClass') + )); + } + + public function testPolymorphicLoading() + { + $child = new DDC199ChildClass; + $child->parentData = 'parentData'; + $child->childData = 'childData'; + $this->_em->persist($child); + + $related1 = new DDC199RelatedClass; + $related1->relatedData = 'related1'; + $related1->parent = $child; + $this->_em->persist($related1); + + $related2 = new DDC199RelatedClass; + $related2->relatedData = 'related2'; + $related2->parent = $child; + $this->_em->persist($related2); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('select e,r from Doctrine\Tests\ORM\Functional\Ticket\DDC199ParentClass e join e.relatedEntities r'); + $result = $query->getResult(); + + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199ParentClass', $result[0]); + $this->assertTrue($result[0]->relatedEntities->isInitialized()); + $this->assertEquals(2, $result[0]->relatedEntities->count()); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199RelatedClass', $result[0]->relatedEntities[0]); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199RelatedClass', $result[0]->relatedEntities[1]); + } +} + + +/** + * @Entity @Table(name="ddc199_entities") + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"parent" = "DDC199ParentClass", "child" = "DDC199ChildClass"}) + */ +class DDC199ParentClass +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column(type="string") + */ + public $parentData; + + /** + * @OneToMany(targetEntity="DDC199RelatedClass", mappedBy="parent") + */ + public $relatedEntities; +} + + +/** @Entity */ +class DDC199ChildClass extends DDC199ParentClass +{ + /** + * @Column + */ + public $childData; +} + +/** @Entity @Table(name="ddc199_relatedclass") */ +class DDC199RelatedClass +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column */ + public $relatedData; + + /** + * @ManyToOne(targetEntity="DDC199ParentClass", inversedBy="relatedEntities") + * @JoinColumn(name="parent_id", referencedColumnName="id") + */ + public $parent; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php new file mode 100644 index 0000000..6104c9c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php @@ -0,0 +1,116 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC211User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC211Group') + )); + } + + public function testIssue() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $user = new DDC211User; + $user->setName('John Doe'); + + $this->_em->persist($user); + $this->_em->flush(); + + $groupNames = array('group 1', 'group 2', 'group 3', 'group 4'); + foreach ($groupNames as $name) { + + $group = new DDC211Group; + $group->setName($name); + $this->_em->persist($group); + $this->_em->flush(); + + if (!$user->getGroups()->contains($group)) { + $user->getGroups()->add($group); + $group->getUsers()->add($user); + $this->_em->flush(); + } + } + + $this->assertEquals(4, $user->getGroups()->count()); + + } +} + + +/** + * @Entity + * @Table(name="ddc211_users") +*/ +class DDC211User +{ + /** + * @Id + * @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + + /** + * @Column(name="name", type="string") + */ + protected $name; + + /** + * @ManyToMany(targetEntity="DDC211Group", inversedBy="users") + * @JoinTable(name="user_groups", + * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, + * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} + * ) + */ + protected $groups; + + public function __construct() { + $this->groups = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function setName($name) { $this->name = $name; } + + public function getGroups() { return $this->groups; } +} + +/** + * @Entity + * @Table(name="ddc211_groups") + */ +class DDC211Group +{ + /** + * @Id + * @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + + /** + * @Column(name="name", type="string") + */ + protected $name; + + /** + * @ManyToMany(targetEntity="DDC211User", mappedBy="groups") + */ + protected $users; + + public function __construct() { + $this->users = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function setName($name) { $this->name = $name; } + + public function getUsers() { return $this->users; } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php new file mode 100644 index 0000000..413e564 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC237Test.php @@ -0,0 +1,112 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC237EntityX'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC237EntityY'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC237EntityZ') + )); + } + + public function testUninitializedProxyIsInitializedOnFetchJoin() + { + $x = new DDC237EntityX; + $y = new DDC237EntityY; + $z = new DDC237EntityZ; + + $x->data = 'X'; + $y->data = 'Y'; + $z->data = 'Z'; + + $x->y = $y; + $z->y = $y; + + $this->_em->persist($x); + $this->_em->persist($y); + $this->_em->persist($z); + + $this->_em->flush(); + $this->_em->clear(); + + $x2 = $this->_em->find(get_class($x), $x->id); // proxy injected for Y + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $x2->y); + $this->assertFalse($x2->y->__isInitialized__); + + // proxy for Y is in identity map + + $z2 = $this->_em->createQuery('select z,y from ' . get_class($z) . ' z join z.y y where z.id = ?1') + ->setParameter(1, $z->id) + ->getSingleResult(); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $z2->y); + $this->assertTrue($z2->y->__isInitialized__); + $this->assertEquals('Y', $z2->y->data); + $this->assertEquals($y->id, $z2->y->id); + + // since the Y is the same, the instance from the identity map is + // used, even if it is a proxy. + + $this->assertNotSame($x, $x2); + $this->assertNotSame($z, $z2); + $this->assertSame($z2->y, $x2->y); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $z2->y); + + } +} + + +/** + * @Entity @Table(name="ddc237_x") + */ +class DDC237EntityX +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; + /** + * @Column(type="string") + */ + public $data; + /** + * @OneToOne(targetEntity="DDC237EntityY") + * @JoinColumn(name="y_id", referencedColumnName="id") + */ + public $y; +} + + +/** @Entity @Table(name="ddc237_y") */ +class DDC237EntityY +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; + /** + * @Column(type="string") + */ + public $data; +} + +/** @Entity @Table(name="ddc237_z") */ +class DDC237EntityZ +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column(type="string") */ + public $data; + + /** + * @OneToOne(targetEntity="DDC237EntityY") + * @JoinColumn(name="y_id", referencedColumnName="id") + */ + public $y; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php new file mode 100644 index 0000000..0d766ea --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC258Test.php @@ -0,0 +1,142 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Super'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class1'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class2'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC258Class3'), + )); + } + + /** + * @group DDC-258 + */ + public function testIssue() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $c1 = new DDC258Class1(); + $c1->title = "Foo"; + $c1->description = "Foo"; + + $c2 = new DDC258Class2(); + $c2->title = "Bar"; + $c2->description = "Bar"; + $c2->text = "Bar"; + + $c3 = new DDC258Class3(); + $c3->apples = "Baz"; + $c3->bananas = "Baz"; + + $this->_em->persist($c1); + $this->_em->persist($c2); + $this->_em->persist($c3); + $this->_em->flush(); + $this->_em->clear(); + + $e2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC258Super', $c2->id); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC258Class2', $e2); + $this->assertEquals('Bar', $e2->title); + $this->assertEquals('Bar', $e2->description); + $this->assertEquals('Bar', $e2->text); + + $all = $this->_em->getRepository(__NAMESPACE__.'\DDC258Super')->findAll(); + + foreach ($all as $obj) { + if ($obj instanceof DDC258Class1) { + $this->assertEquals('Foo', $obj->title); + $this->assertEquals('Foo', $obj->description); + } else if ($obj instanceof DDC258Class2) { + $this->assertTrue($e2 === $obj); + $this->assertEquals('Bar', $obj->title); + $this->assertEquals('Bar', $obj->description); + $this->assertEquals('Bar', $obj->text); + } else if ($obj instanceof DDC258Class3) { + $this->assertEquals('Baz', $obj->apples); + $this->assertEquals('Baz', $obj->bananas); + } else { + $this->fail('Instance of DDC258Class1, DDC258Class2 or DDC258Class3 expected.'); + } + } + } +} + +/** + * @Entity + * @Table(name="DDC258Super") + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="type", type="string") + * @DiscriminatorMap({"class1" = "DDC258Class1", "class2" = "DDC258Class2", "class3"="DDC258Class3"}) + */ +abstract class DDC258Super +{ + /** + * @Id @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; +} + +/** + * @Entity + */ +class DDC258Class1 extends DDC258Super +{ + /** + * @Column(name="title", type="string", length=150) + */ + public $title; + + /** + * @Column(name="content", type="string", length=500) + */ + public $description; +} + +/** + * @Entity + */ +class DDC258Class2 extends DDC258Super +{ + /** + * @Column(name="title", type="string", length=150) + */ + public $title; + + /** + * @Column(name="content", type="string", length=500) + */ + public $description; + + /** + * @Column(name="text", type="text") + */ + public $text; +} + +/** + * An extra class to demonstrate why title and description aren't in Super + * + * @Entity + */ +class DDC258Class3 extends DDC258Super +{ + /** + * @Column(name="title", type="string", length=150) + */ + public $apples; + + /** + * @Column(name="content", type="string", length=500) + */ + public $bananas; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php new file mode 100644 index 0000000..6d41ea8 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC279Test.php @@ -0,0 +1,133 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityXAbstract'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityX'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityY'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC279EntityZ'), + )); + } + + /** + * @group DDC-279 + */ + public function testDDC279() + { + $x = new DDC279EntityX(); + $y = new DDC279EntityY(); + $z = new DDC279EntityZ(); + + $x->data = 'X'; + $y->data = 'Y'; + $z->data = 'Z'; + + $x->y = $y; + $y->z = $z; + + $this->_em->persist($x); + $this->_em->persist($y); + $this->_em->persist($z); + + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery( + 'SELECT x, y, z FROM Doctrine\Tests\ORM\Functional\Ticket\DDC279EntityX x '. + 'INNER JOIN x.y y INNER JOIN y.z z WHERE x.id = ?1' + )->setParameter(1, $x->id); + + $result = $query->getResult(); + + $expected1 = 'Y'; + $expected2 = 'Z'; + + $this->assertEquals(1, count($result)); + + $this->assertEquals($expected1, $result[0]->y->data); + $this->assertEquals($expected2, $result[0]->y->z->data); + } +} + + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"DDC279EntityX" = "DDC279EntityX"}) + */ +abstract class DDC279EntityXAbstract +{ + /** + * @Id + * @GeneratedValue + * @Column(name="id", type="integer") + */ + public $id; + + /** + * @column(type="string") + */ + public $data; + +} + +/** + * @Entity + */ +class DDC279EntityX extends DDC279EntityXAbstract +{ + /** + * @OneToOne(targetEntity="DDC279EntityY") + * @JoinColumn(name="y_id", referencedColumnName="id") + */ + public $y; +} + +/** + * @Entity + */ +class DDC279EntityY +{ + /** + * @Id @GeneratedValue + * @Column(name="id", type="integer") + */ + public $id; + + /** + * @column(type="string") + */ + public $data; + + /** + * @OneToOne(targetEntity="DDC279EntityZ") + * @JoinColumn(name="z_id", referencedColumnName="id") + */ + public $z; +} + +/** + * @Entity + */ +class DDC279EntityZ +{ + /** + * @Id @GeneratedValue + * @Column(name="id", type="integer") + */ + public $id; + + /** + * @column(type="string") + */ + public $data; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php new file mode 100644 index 0000000..325ce8d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC309Test.php @@ -0,0 +1,73 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309Country'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309User'), + )); + } + + public function testTwoIterateHydrations() + { + $c1 = new DDC309Country(); + $c2 = new DDC309Country(); + $u1 = new DDC309User(); + $u2 = new DDC309User(); + + $this->_em->persist($c1); + $this->_em->persist($c2); + $this->_em->persist($u1); + $this->_em->persist($u2); + $this->_em->flush(); + $this->_em->clear(); + + $q = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c')->iterate(); + $c = $q->next(); + + $this->assertEquals(1, $c[0]->id); + + $r = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u')->iterate(); + $u = $r->next(); // This line breaks + + $this->assertEquals(1, $u[0]->id); + + $c = $q->next(); + $u = $r->next(); + + $this->assertEquals(2, $c[0]->id); + $this->assertEquals(2, $u[0]->id); + } +} + +/** + * @Entity + */ +class DDC309Country +{ + /** + * @Id + * @Column(name="id", type="integer") + * @GeneratedValue + */ + public $id; +} + +/** + * @Entity + */ +class DDC309User +{ + /** + * @Id + * @Column(name="id", type="integer") + * @GeneratedValue + */ + public $id; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php new file mode 100644 index 0000000..2db32b9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC331Test.php @@ -0,0 +1,39 @@ + + */ +class DDC331Test extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() { + $this->useModelSet('company'); + parent::setUp(); + } + + /** + * @group DDC-331 + */ + public function testSelectFieldOnRootEntity() + { + $q = $this->_em->createQuery('SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e'); + $this->assertEquals( + strtolower('SELECT c0_.name AS name0 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()) + ); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php new file mode 100644 index 0000000..757b5ab --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC345Test.php @@ -0,0 +1,157 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC345User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC345Group'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC345Membership'), + )); + } + + public function testTwoIterateHydrations() + { + // Create User + $user = new DDC345User; + $user->name = 'Test User'; + $this->_em->persist($user); // $em->flush() does not change much here + + // Create Group + $group = new DDC345Group; + $group->name = 'Test Group'; + $this->_em->persist($group); // $em->flush() does not change much here + + $membership = new DDC345Membership; + $membership->group = $group; + $membership->user = $user; + $membership->state = 'active'; + + //$this->_em->persist($membership); // COMMENT OUT TO SEE BUG + /* + This should be not necessary, but without, its PrePersist is called twice, + $membership seems to be persisted twice, but all properties but the + ones set by LifecycleCallbacks are deleted. + */ + + $user->Memberships->add($membership); + $group->Memberships->add($membership); + + $this->_em->flush(); + + $this->assertEquals(1, $membership->prePersistCallCount); + $this->assertEquals(0, $membership->preUpdateCallCount); + $this->assertInstanceOf('DateTime', $membership->updated); + } +} + +/** + * @Entity + */ +class DDC345User +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** @Column(type="string") */ + public $name; + + /** @OneToMany(targetEntity="DDC345Membership", mappedBy="user", cascade={"persist"}) */ + public $Memberships; + + public function __construct() + { + $this->Memberships = new \Doctrine\Common\Collections\ArrayCollection; + } +} + +/** + * @Entity + */ +class DDC345Group +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** @Column(type="string") */ + public $name; + + /** @OneToMany(targetEntity="DDC345Membership", mappedBy="group", cascade={"persist"}) */ + public $Memberships; + + + public function __construct() + { + $this->Memberships = new \Doctrine\Common\Collections\ArrayCollection; + } +} + +/** + * @Entity + * @HasLifecycleCallbacks + * @Table(name="ddc345_memberships", uniqueConstraints={ + * @UniqueConstraint(name="ddc345_memship_fks", columns={"user_id","group_id"}) + * }) + */ +class DDC345Membership +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC345User", inversedBy="Memberships") + * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) + */ + public $user; + + /** + * @OneToOne(targetEntity="DDC345Group", inversedBy="Memberships") + * @JoinColumn(name="group_id", referencedColumnName="id", nullable=false) + */ + public $group; + + /** @Column(type="string") */ + public $state; + + /** @Column(type="datetime") */ + public $updated; + + public $prePersistCallCount = 0; + public $preUpdateCallCount = 0; + + /** @PrePersist */ + public function doStuffOnPrePersist() + { + //echo "***** PrePersist\n"; + ++$this->prePersistCallCount; + $this->updated = new \DateTime; + } + + /** @PreUpdate */ + public function doStuffOnPreUpdate() + { + //echo "***** PreUpdate\n"; + ++$this->preUpdateCallCount; + $this->updated = new \DateTime; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php new file mode 100644 index 0000000..df78359 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC353Test.php @@ -0,0 +1,150 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC353File'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC353Picture'), + )); + } catch(\Exception $ignored) {} + } + + public function testWorkingCase() + { + $file = new DDC353File; + + $picture = new DDC353Picture; + $picture->setFile($file); + + $em = $this->_em; + $em->persist($picture); + $em->flush(); + $em->clear(); + + $fileId = $file->getFileId(); + $this->assertTrue($fileId > 0); + + $file = $em->getReference('Doctrine\Tests\ORM\Functional\Ticket\DDC353File', $fileId); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($file), "Reference Proxy should be marked MANAGED."); + + $picture = $em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC353Picture', $picture->getPictureId()); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), "Lazy Proxy should be marked MANAGED."); + + $em->remove($picture); + $em->flush(); + } + + public function testFailingCase() + { + $file = new DDC353File; + + $picture = new DDC353Picture; + $picture->setFile($file); + + $em = $this->_em; + $em->persist($picture); + $em->flush(); + $em->clear(); + + $fileId = $file->getFileId(); + $pictureId = $picture->getPictureId(); + + $this->assertTrue($fileId > 0); + + $picture = $em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC353Picture', $pictureId); + $this->assertEquals(UnitOfWork::STATE_MANAGED, $em->getUnitOfWork()->getEntityState($picture->getFile()), "Lazy Proxy should be marked MANAGED."); + + $em->remove($picture); + $em->flush(); + } +} + +/** + * @Entity + */ +class DDC353Picture +{ + /** + * @Column(name="picture_id", type="integer") + * @Id @GeneratedValue + */ + private $pictureId; + + /** + * @ManyToOne(targetEntity="DDC353File", cascade={"persist", "remove"}) + * @JoinColumns({ + * @JoinColumn(name="file_id", referencedColumnName="file_id") + * }) + */ + private $file; + + /** + * Get pictureId + */ + public function getPictureId() + { + return $this->pictureId; + } + + /** + * Set product + */ + public function setProduct($value) + { + $this->product = $value; + } + + /** + * Get product + */ + public function getProduct() + { + return $this->product; + } + + /** + * Set file + */ + public function setFile($value) + { + $this->file = $value; + } + + /** + * Get file + */ + public function getFile() + { + return $this->file; + } +} + +/** + * @Entity + */ +class DDC353File +{ + /** + * @Column(name="file_id", type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + public $fileId; + + /** + * Get fileId + */ + public function getFileId() + { + return $this->fileId; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php new file mode 100644 index 0000000..54f76b1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -0,0 +1,69 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Parent'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Child') + )); + } + + public function testIssue() + { + $parent = new DDC371Parent; + $parent->data = 'parent'; + $parent->children = new \Doctrine\Common\Collections\ArrayCollection; + + $child = new DDC371Child; + $child->data = 'child'; + + $child->parent = $parent; + $parent->children->add($child); + + $this->_em->persist($parent); + $this->_em->persist($child); + + $this->_em->flush(); + $this->_em->clear(); + + $children = $this->_em->createQuery('select c,p from '.__NAMESPACE__.'\DDC371Child c ' + . 'left join c.parent p where c.id = 1 and p.id = 1') + ->setHint(Query::HINT_REFRESH, true) + ->getResult(); + + $this->assertEquals(1, count($children)); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $children[0]->parent); + $this->assertFalse($children[0]->parent->children->isInitialized()); + $this->assertEquals(0, $children[0]->parent->children->unwrap()->count()); + } +} + +/** @Entity */ +class DDC371Child { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @Column(type="string") */ + public $data; + /** @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") @JoinColumn(name="parentId") */ + public $parent; +} + +/** @Entity */ +class DDC371Parent { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @Column(type="string") */ + public $data; + /** @OneToMany(targetEntity="DDC371Child", mappedBy="parent") */ + public $children; +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php new file mode 100644 index 0000000..9b47bc8 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC381Test.php @@ -0,0 +1,63 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC381Entity'), + )); + } catch(\Exception $e) { + + } + } + + public function testCallUnserializedProxyMethods() + { + $entity = new DDC381Entity(); + + $this->_em->persist($entity); + $this->_em->flush(); + $this->_em->clear(); + $persistedId = $entity->getId(); + + $entity = $this->_em->getReference('Doctrine\Tests\ORM\Functional\Ticket\DDC381Entity', $persistedId); + + // explicitly load proxy (getId() does not trigger reload of proxy) + $id = $entity->getOtherMethod(); + + $data = serialize($entity); + $entity = unserialize($data); + + $this->assertEquals($persistedId, $entity->getId()); + } +} + +/** + * @Entity + */ +class DDC381Entity +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + protected $id; + + public function getId() + { + return $this->id; + } + + public function getOtherMethod() + { + + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php new file mode 100644 index 0000000..3a6dbdb --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC422Test.php @@ -0,0 +1,75 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Guest'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Customer'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Contact') + )); + } + + /** + * @group DDC-422 + */ + public function testIssue() + { + $customer = new DDC422Customer; + $this->_em->persist($customer); + $this->_em->flush(); + $this->_em->clear(); + + $customer = $this->_em->find(get_class($customer), $customer->id); + + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $customer->contacts); + $this->assertFalse($customer->contacts->isInitialized()); + $contact = new DDC422Contact; + $customer->contacts->add($contact); + $this->assertTrue($customer->contacts->isDirty()); + $this->assertFalse($customer->contacts->isInitialized()); + $this->_em->flush(); + + $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from ddc422_customers_contacts")); + } +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"guest" = "DDC422Guest", "customer" = "DDC422Customer"}) + */ +class DDC422Guest { + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; +} + +/** @Entity */ +class DDC422Customer extends DDC422Guest { + /** + * @ManyToMany(targetEntity="DDC422Contact", cascade={"persist","remove"}) + * @JoinTable(name="ddc422_customers_contacts", + * joinColumns={@JoinColumn(name="customer_id", referencedColumnName="id", onDelete="cascade" )}, + * inverseJoinColumns={@JoinColumn(name="contact_id", referencedColumnName="id", onDelete="cascade" )} + * ) + */ + public $contacts; + + public function __construct() { + $this->contacts = new \Doctrine\Common\Collections\ArrayCollection; + } +} + +/** @Entity */ +class DDC422Contact { + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php new file mode 100644 index 0000000..084da56 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC425Test.php @@ -0,0 +1,43 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC425Entity'), + //$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC425Other') + )); + } + + /** + * @group DDC-425 + */ + public function testIssue() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $num = $this->_em->createQuery('DELETE '.__NAMESPACE__.'\DDC425Entity e WHERE e.someDatetimeField > ?1') + ->setParameter(1, new DateTime, Type::DATETIME) + ->getResult(); + $this->assertEquals(0, $num); + } +} + +/** @Entity */ +class DDC425Entity { + /** + * @Id @Column(type="integer") + * @GeneratedValue + */ + public $id; + + /** @Column(type="datetime") */ + public $someDatetimeField; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php new file mode 100644 index 0000000..2b374a8 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC440Test.php @@ -0,0 +1,216 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + + /** + * @group DDC-440 + */ + public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations() + { + + + /* The key of the problem is that the first phone is fetched via two association, main_phone and phones. + * + * You will notice that the original_entity_datas are not loaded for the first phone. (They are for the second) + * + * In the Client entity definition, if you define the main_phone relation after the phones relation, both assertions pass. + * (for the sake or this test, I defined the main_phone relation before the phones relation) + * + */ + + //Initialize some data + $client = new DDC440Client; + $client->setName('Client1'); + + $phone = new DDC440Phone; + $phone->setNumber('418 111-1111'); + $phone->setClient($client); + + $phone2 = new DDC440Phone; + $phone2->setNumber('418 222-2222'); + $phone2->setClient($client); + + $client->setMainPhone($phone); + + $this->_em->persist($client); + $this->_em->flush(); + $id = $client->getId(); + $this->_em->clear(); + + $uw = $this->_em->getUnitOfWork(); + $client = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client', $id); + $clientPhones = $client->getPhones(); + $p1 = $clientPhones[0]; + $p2 = $clientPhones[1]; + + // Test the first phone. The assertion actually failed because original entity data is not set properly. + // This was because it is also set as MainPhone and that one is created as a proxy, not the + // original object when the find on Client is called. However loading proxies did not work correctly. + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p1); + $originalData = $uw->getOriginalEntityData($p1); + $this->assertEquals($phone->getNumber(), $originalData['number']); + + + //If you comment out previous test, this one should pass + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p2); + $originalData = $uw->getOriginalEntityData($p2); + $this->assertEquals($phone2->getNumber(), $originalData['number']); + } + +} + +/** + * @Entity + * @Table(name="phone") + */ +class DDC440Phone +{ + + /** + * @Column(name="id", type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + /** + * @ManyToOne(targetEntity="DDC440Client",inversedBy="phones") + * @JoinColumns({ + * @JoinColumn(name="client_id", referencedColumnName="id") + * }) + */ + protected $client; + /** + * @Column(name="phonenumber", type="string") + */ + protected $number; + + public function setNumber($value) + { + $this->number = $value; + } + + public function getNumber() + { + return $this->number; + } + + public function setClient(DDC440Client $value, $update_inverse=true) + { + $this->client = $value; + if ($update_inverse) { + $value->addPhone($this); + } + } + + public function getClient() + { + return $this->client; + } + + public function getId() + { + return $this->id; + } + + public function setId($value) + { + $this->id = $value; + } + +} + +/** + * @Entity + * @Table(name="client") + */ +class DDC440Client +{ + + /** + * @Column(name="id", type="integer") + * @Id + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + /** + * @OneToOne(targetEntity="DDC440Phone", fetch="EAGER") + * @JoinColumns({ + * @JoinColumn(name="main_phone_id", referencedColumnName="id",onDelete="SET NULL") + * }) + */ + protected $main_phone; + /** + * @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER") + * @orderBy({"number"="ASC"}) + */ + protected $phones; + /** + * @Column(name="name", type="string") + */ + protected $name; + + public function __construct() + { + + } + + public function setName($value) + { + $this->name = $value; + } + + public function getName() + { + return $this->name; + } + + public function addPhone(DDC440Phone $value) + { + $this->phones[] = $value; + $value->setClient($this, false); + } + + public function getPhones() + { + return $this->phones; + } + + public function setMainPhone(DDC440Phone $value) + { + $this->main_phone = $value; + } + + public function getMainPhone() + { + return $this->main_phone; + } + + public function getId() + { + return $this->id; + } + + public function setId($value) + { + $this->id = $value; + } + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php new file mode 100644 index 0000000..d89e67a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php @@ -0,0 +1,77 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC444User'), + )); + } + + public function testExplicitPolicy() + { + $classname = __NAMESPACE__ . "\DDC444User"; + + $u = new $classname; + $u->name = "Initial value"; + + $this->_em->persist($u); + $this->_em->flush(); + $this->_em->clear(); + + $q = $this->_em->createQuery("SELECT u FROM $classname u"); + $u = $q->getSingleResult(); + $this->assertEquals("Initial value", $u->name); + + $u->name = "Modified value"; + + // This should be NOOP as the change hasn't been persisted + $this->_em->flush(); + $this->_em->clear(); + + + $u = $this->_em->createQuery("SELECT u FROM $classname u"); + $u = $q->getSingleResult(); + + $this->assertEquals("Initial value", $u->name); + + + $u->name = "Modified value"; + $this->_em->persist($u); + // Now we however persisted it, and this should have updated our friend + $this->_em->flush(); + + $q = $this->_em->createQuery("SELECT u FROM $classname u"); + $u = $q->getSingleResult(); + + $this->assertEquals("Modified value", $u->name); + } +} + + +/** + * @Entity @Table(name="ddc444") + * @ChangeTrackingPolicy("DEFERRED_EXPLICIT") + */ +class DDC444User +{ + /** + * @Id @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @Column(name="name", type="string") + */ + public $name; +} + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php new file mode 100644 index 0000000..4ea8308 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC448Test.php @@ -0,0 +1,74 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC448MainTable'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC448ConnectedClass'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC448SubTable'), + )); + } + + public function testIssue() + { + $q = $this->_em->createQuery("select b from ".__NAMESPACE__."\\DDC448SubTable b where b.connectedClassId = ?1"); + $this->assertEquals( + strtolower('SELECT d0_.id AS id0, d0_.discr AS discr1, d0_.connectedClassId AS connectedClassId2 FROM SubTable s1_ INNER JOIN DDC448MainTable d0_ ON s1_.id = d0_.id WHERE d0_.connectedClassId = ?'), + strtolower($q->getSQL()) + ); + } +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="smallint") + * @DiscriminatorMap({ + * "0" = "DDC448MainTable", + * "1" = "DDC448SubTable" + * }) + */ +class DDC448MainTable +{ + /** + * @Id + * @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @ManyToOne(targetEntity="DDC448ConnectedClass", cascade={"all"}, fetch="EAGER") + * @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", nullable=true) + */ + private $connectedClassId; +} + +/** + * @Entity + * @Table(name="connectedClass") + * @HasLifecycleCallbacks + */ +class DDC448ConnectedClass +{ + /** + * @Id + * @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $id; // connected with DDC448MainTable +} + +/** + * @Entity + * @Table(name="SubTable") + */ +class DDC448SubTable extends DDC448MainTable +{ +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php new file mode 100644 index 0000000..9e8d58b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC493Test.php @@ -0,0 +1,72 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Customer'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Distributor'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Contact') + )); + } + + public function testIssue() + { + $q = $this->_em->createQuery("select u, c.data from ".__NAMESPACE__."\\DDC493Distributor u JOIN u.contact c"); + $this->assertEquals( + strtolower('SELECT d0_.id AS id0, d1_.data AS data1, d0_.discr AS discr2, d0_.contact AS contact3 FROM DDC493Distributor d2_ INNER JOIN DDC493Customer d0_ ON d2_.id = d0_.id INNER JOIN DDC493Contact d1_ ON d0_.contact = d1_.id'), + strtolower($q->getSQL()) + ); + } +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"distributor" = "DDC493Distributor", "customer" = "DDC493Customer"}) + */ +class DDC493Customer { + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + /** + * @OneToOne(targetEntity="DDC493Contact", cascade={"remove","persist"}) + * @JoinColumn(name="contact", referencedColumnName="id") + */ + public $contact; + +} + +/** + * @Entity + */ +class DDC493Distributor extends DDC493Customer { +} + +/** + * @Entity + */ +class DDC493Contact +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + /** @Column(type="string") */ + public $data; +} + + + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php new file mode 100644 index 0000000..22897ee --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC501Test.php @@ -0,0 +1,124 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testMergeUnitializedManyToManyAndOneToManyCollections() + { + // Create User + $user = $this->createAndPersistUser(); + $this->_em->flush(); + + $this->assertTrue($this->_em->contains($user)); + $this->_em->clear(); + $this->assertFalse($this->_em->contains($user)); + + unset($user); + + // Reload User from DB *without* any associations (i.e. an uninitialized PersistantCollection) + $userReloaded = $this->loadUserFromEntityManager(); + + $this->assertTrue($this->_em->contains($userReloaded)); + $this->_em->clear(); + $this->assertFalse($this->_em->contains($userReloaded)); + + // freeze and unfreeze + $userClone = unserialize(serialize($userReloaded)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $userClone); + + // detached user can't know about his phonenumbers + $this->assertEquals(0, count($userClone->getPhonenumbers())); + $this->assertFalse($userClone->getPhonenumbers()->isInitialized(), "User::phonenumbers should not be marked initialized."); + + // detached user can't know about his groups either + $this->assertEquals(0, count($userClone->getGroups())); + $this->assertFalse($userClone->getGroups()->isInitialized(), "User::groups should not be marked initialized."); + + // Merge back and flush + $userClone = $this->_em->merge($userClone); + + // Back in managed world I would expect to have my phonenumbers back but they aren't! + // Remember I didn't touch (and propably didn't need) them at all while in detached mode. + $this->assertEquals(4, count($userClone->getPhonenumbers()), 'Phonenumbers are not available anymore'); + + // This works fine as long as cmUser::groups doesn't cascade "merge" + $this->assertEquals(2, count($userClone->getGroups())); + + $this->_em->flush(); + $this->_em->clear(); + + $this->assertFalse($this->_em->contains($userClone)); + + // Reload user from DB + $userFromEntityManager = $this->loadUserFromEntityManager(); + + //Strange: Now the phonenumbers are back again + $this->assertEquals(4, count($userFromEntityManager->getPhonenumbers())); + + // This works fine as long as cmUser::groups doesn't cascade "merge" + // Otherwise group memberships are physically deleted now! + $this->assertEquals(2, count($userClone->getGroups())); + } + + protected function createAndPersistUser() + { + $user = new CmsUser(); + $user->name = 'Luka'; + $user->username = 'lukacho'; + $user->status = 'developer'; + + foreach(array(1111,2222,3333,4444) as $number) { + $phone = new CmsPhonenumber; + $phone->phonenumber = $number; + $user->addPhonenumber($phone); + } + + foreach(array('Moshers', 'Headbangers') as $groupName) { + $group = new CmsGroup; + $group->setName($groupName); + $user->addGroup($group); + } + + $this->_em->persist($user); + + return $user; + } + + /** + * @return Doctrine\Tests\Models\CMS\CmsUser + */ + protected function loadUserFromEntityManager() + { + return $this->_em + ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name like :name') + ->setParameter('name', 'Luka') + ->getSingleResult(); + } + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php new file mode 100644 index 0000000..97245ef --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC512Test.php @@ -0,0 +1,94 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512Customer'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512OfferItem'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512Item'), + )); + } + + public function testIssue() + { + $customer1 = new DDC512Customer(); + $item = new DDC512OfferItem(); + $customer1->item = $item; + $this->_em->persist($customer1); + + $customer2 = new DDC512Customer(); + $this->_em->persist($customer2); + + $this->_em->flush(); + $this->_em->clear(); + + $q = $this->_em->createQuery("select u,i from ".__NAMESPACE__."\\DDC512Customer u left join u.item i"); + $result = $q->getResult(); + + $this->assertEquals(2, count($result)); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC512Customer', $result[0]); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC512Customer', $result[1]); + if ($result[0]->id == $customer1->id) { + $this->assertInstanceOf(__NAMESPACE__ . '\DDC512OfferItem', $result[0]->item); + $this->assertEquals($item->id, $result[0]->item->id); + $this->assertNull($result[1]->item); + } else { + $this->assertInstanceOf(__NAMESPACE__ . '\DDC512OfferItem', $result[1]->item); + $this->assertNull($result[0]->item); + } + } +} + +/** + * @Entity + */ +class DDC512Customer { + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * NOTE that we can currently not name the join column the same as the field + * (item = item), this currently confuses Doctrine. + * + * @OneToOne(targetEntity="DDC512OfferItem", cascade={"remove","persist"}) + * @JoinColumn(name="item_id", referencedColumnName="id") + */ + public $item; +} + +/** + * @Entity + */ +class DDC512OfferItem extends DDC512Item +{ +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"item" = "DDC512Item", "offerItem" = "DDC512OfferItem"}) + */ +class DDC512Item +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; +} + + + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php new file mode 100644 index 0000000..b71d674 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC513Test.php @@ -0,0 +1,74 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC513OfferItem'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC513Item'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC513Price'), + )); + } + + public function testIssue() + { + $q = $this->_em->createQuery("select u from ".__NAMESPACE__."\\DDC513OfferItem u left join u.price p"); + $this->assertEquals( + strtolower('SELECT d0_.id AS id0, d0_.discr AS discr1, d0_.price AS price2 FROM DDC513OfferItem d1_ INNER JOIN DDC513Item d0_ ON d1_.id = d0_.id LEFT JOIN DDC513Price d2_ ON d0_.price = d2_.id'), + strtolower($q->getSQL()) + ); + } +} + +/** + * @Entity + */ +class DDC513OfferItem extends DDC513Item +{ +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"item" = "DDC513Item", "offerItem" = "DDC513OfferItem"}) + */ +class DDC513Item +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @OneToOne(targetEntity="DDC513Price", cascade={"remove","persist"}) + * @JoinColumn(name="price", referencedColumnName="id") + */ + public $price; +} + +/** + * @Entity + */ +class DDC513Price { + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** @Column(type="string") */ + public $data; +} + + + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php new file mode 100644 index 0000000..2a34506 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC518Test.php @@ -0,0 +1,36 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testMergeWithRelatedNew() + { + $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); + $article->text = "foo"; + $article->topic = "bar"; + + $this->_em->persist($article); + $this->_em->flush(); + $this->_em->detach($article); + $this->_em->clear(); + + $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin Eberlei"; + $user->status = "active"; + $article->user = $user; + + $this->_em->persist($user); + $managedArticle = $this->_em->merge($article); + + $this->assertSame($article->user, $managedArticle->user); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php new file mode 100644 index 0000000..f029e95 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC522Test.php @@ -0,0 +1,121 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522Customer'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522Cart'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC522ForeignKeyTest') + )); + } catch(\Exception $e) { + + } + } + + /** + * @group DDC-522 + */ + public function testJoinColumnWithSameNameAsAssociationField() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $cust = new DDC522Customer; + $cust->name = "name"; + $cart = new DDC522Cart; + $cart->total = 0; + $cust->cart = $cart; + $cart->customer = $cust; + $this->_em->persist($cust); + $this->_em->persist($cart); + $this->_em->flush(); + + $this->_em->clear(); + + $r = $this->_em->createQuery("select ca,c from ".get_class($cart)." ca join ca.customer c") + ->getResult(); + + $this->assertInstanceOf(__NAMESPACE__ . '\DDC522Cart', $r[0]); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC522Customer', $r[0]->customer); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $r[0]->customer); + $this->assertEquals('name', $r[0]->customer->name); + + $fkt = new DDC522ForeignKeyTest(); + $fkt->cartId = $r[0]->id; // ignored for persistence + $fkt->cart = $r[0]; // must be set properly + $this->_em->persist($fkt); + $this->_em->flush(); + $this->_em->clear(); + + $fkt2 = $this->_em->find(get_class($fkt), $fkt->id); + $this->assertEquals($fkt->cart->id, $fkt2->cartId); + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $fkt2->cart); + $this->assertFalse($fkt2->cart->__isInitialized__); + } + + /** + * @group DDC-522 + * @group DDC-762 + */ + public function testJoinColumnWithNullSameNameAssociationField() + { + $fkCust = new DDC522ForeignKeyTest; + $fkCust->name = "name"; + $fkCust->cart = null; + + $this->_em->persist($fkCust); + $this->_em->flush(); + $this->_em->clear(); + + $newCust = $this->_em->find(get_class($fkCust), $fkCust->id); + } +} + +/** @Entity */ +class DDC522Customer { + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column */ + public $name; + /** @OneToOne(targetEntity="DDC522Cart", mappedBy="customer") */ + public $cart; +} + +/** @Entity */ +class DDC522Cart { + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column(type="integer") */ + public $total; + /** + * @OneToOne(targetEntity="DDC522Customer", inversedBy="cart") + * @JoinColumn(name="customer", referencedColumnName="id") + */ + public $customer; +} + +/** @Entity */ +class DDC522ForeignKeyTest { + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column(type="integer", name="cart_id", nullable=true) */ + public $cartId; + /** + * @OneToOne(targetEntity="DDC522Cart") + * @JoinColumn(name="cart_id", referencedColumnName="id") + */ + public $cart; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php new file mode 100644 index 0000000..5e22c2c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -0,0 +1,88 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC531Item'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC531SubItem'), + )); + } + + public function testIssue() + { + $item1 = new DDC531Item; + $item2 = new DDC531Item; + $item2->parent = $item1; + $item1->getChildren()->add($item2); + $this->_em->persist($item1); + $this->_em->persist($item2); + $this->_em->flush(); + $this->_em->clear(); + + $item3 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item2->id); // Load child item first (id 2) + // parent will already be loaded, cannot be lazy because it has mapped subclasses and we would not + // know which proxy type to put in. + $this->assertInstanceOf(__NAMESPACE__ . '\DDC531Item', $item3->parent); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $item3->parent); + $item4 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item1->id); // Load parent item (id 1) + $this->assertNull($item4->parent); + $this->assertNotNull($item4->getChildren()); + $this->assertTrue($item4->getChildren()->contains($item3)); // lazy-loads children + } +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorColumn(name="type", type="integer") + * @DiscriminatorMap({"0" = "DDC531Item", "1" = "DDC531SubItem"}) + */ +class DDC531Item +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @OneToMany(targetEntity="DDC531Item", mappedBy="parent") + */ + protected $children; + + /** + * @ManyToOne(targetEntity="DDC531Item", inversedBy="children") + * @JoinColumn(name="parentId", referencedColumnName="id") + */ + public $parent; + + public function __construct() + { + $this->children = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function getParent() + { + return $this->parent; + } + + public function getChildren() + { + return $this->children; + } +} + +/** + * @Entity + */ +class DDC531SubItem extends DDC531Item +{ +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php new file mode 100644 index 0000000..3f899d7 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC588Test.php @@ -0,0 +1,48 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC588Site'), + )); + } + + public function testIssue() + { + $site = new DDC588Site('Foo'); + + $this->_em->persist($site); + $this->_em->flush(); + // Following should not result in exception + $this->_em->refresh($site); + } +} + +/** + * @Entity + */ +class DDC588Site +{ + /** + * @Id + * @Column(type="integer", name="site_id") + * @GeneratedValue + */ + public $id; + + /** + * @Column(type="string", length=45) + */ + protected $name = null; + + public function __construct($name = '') + { + $this->name = $name; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php new file mode 100644 index 0000000..b342796 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC599Test.php @@ -0,0 +1,132 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Item'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Subitem'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Child'), + )); + } catch (\Exception $ignored) {} + } + + public function testCascadeRemoveOnInheritanceHierachy() + { + $item = new DDC599Subitem; + $item->elem = "foo"; + $child = new DDC599Child; + $child->parent = $item; + $item->getChildren()->add($child); + $this->_em->persist($item); + $this->_em->persist($child); + $this->_em->flush(); + $this->_em->clear(); + + $item = $this->_em->find(__NAMESPACE__ . '\DDC599Item', $item->id); + + $this->_em->remove($item); + $this->_em->flush(); // Should not fail + + $this->assertFalse($this->_em->contains($item)); + $children = $item->getChildren(); + $this->assertFalse($this->_em->contains($children[0])); + + $this->_em->clear(); + + + $item2 = new DDC599Subitem; + $item2->elem = "bar"; + $this->_em->persist($item2); + $this->_em->flush(); + + $child2 = new DDC599Child; + $child2->parent = $item2; + $item2->getChildren()->add($child2); + $this->_em->persist($child2); + $this->_em->flush(); + + $this->_em->remove($item2); + $this->_em->flush(); // should not fail + + $this->assertFalse($this->_em->contains($item)); + $children = $item->getChildren(); + $this->assertFalse($this->_em->contains($children[0])); + } + + public function testCascadeRemoveOnChildren() + { + $class = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC599Subitem'); + + $this->assertArrayHasKey('children', $class->associationMappings); + $this->assertTrue($class->associationMappings['children']['isCascadeRemove']); + } +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorColumn(name="type", type="integer") + * @DiscriminatorMap({"0" = "DDC599Item", "1" = "DDC599Subitem"}) + */ +class DDC599Item +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @OneToMany(targetEntity="DDC599Child", mappedBy="parent", cascade={"remove"}) + */ + protected $children; + + public function __construct() + { + $this->children = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function getChildren() + { + return $this->children; + } +} + +/** + * @Entity + */ +class DDC599Subitem extends DDC599Item +{ + /** + * @Column(type="string") + */ + public $elem; +} + +/** + * @Entity + */ +class DDC599Child +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @ManyToOne(targetEntity="DDC599Item", inversedBy="children") + * @JoinColumn(name="parentId", referencedColumnName="id") + */ + public $parent; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php new file mode 100644 index 0000000..b51ed39 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC618Test.php @@ -0,0 +1,185 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC618Author'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC618Book') + )); + + // Create author 10/Joe with two books 22/JoeA and 20/JoeB + $author = new DDC618Author(); + $author->id = 10; + $author->name = 'Joe'; + $this->_em->persist($author); + + // Create author 11/Alice with two books 21/AliceA and 23/AliceB + $author = new DDC618Author(); + $author->id = 11; + $author->name = 'Alice'; + $author->addBook('In Wonderland'); + $author->addBook('Reloaded'); + $author->addBook('Test'); + + $this->_em->persist($author); + + $this->_em->flush(); + $this->_em->clear(); + } catch(\Exception $e) { + + } + } + + public function testIndexByHydrateObject() + { + $dql = 'SELECT A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.name ORDER BY A.name ASC'; + $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); + + $joe = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 10); + $alice = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 11); + + $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); + $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); + } + + public function testIndexByHydrateArray() + { + $dql = 'SELECT A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.name ORDER BY A.name ASC'; + $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); + + $joe = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 10); + $alice = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', 11); + + $this->assertArrayHasKey('Joe', $result, "INDEX BY A.name should return an index by the name of 'Joe'."); + $this->assertArrayHasKey('Alice', $result, "INDEX BY A.name should return an index by the name of 'Alice'."); + } + + /** + * @group DDC-1018 + */ + public function testIndexByJoin() + { + $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A '. + 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; + $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); + + $this->assertEquals(3, count($result[0]->books)); // Alice, Joe doesnt appear because he has no books. + $this->assertEquals('Alice', $result[0]->name); + $this->assertTrue( isset($result[0]->books["In Wonderland"] ), "Indexing by title should have books by title."); + $this->assertTrue( isset($result[0]->books["Reloaded"] ), "Indexing by title should have books by title."); + $this->assertTrue( isset($result[0]->books["Test"] ), "Indexing by title should have books by title."); + + $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); + + $this->assertEquals(3, count($result[0]['books'])); // Alice, Joe doesnt appear because he has no books. + $this->assertEquals('Alice', $result[0]['name']); + $this->assertTrue( isset($result[0]['books']["In Wonderland"] ), "Indexing by title should have books by title."); + $this->assertTrue( isset($result[0]['books']["Reloaded"] ), "Indexing by title should have books by title."); + $this->assertTrue( isset($result[0]['books']["Test"] ), "Indexing by title should have books by title."); + } + + /** + * @group DDC-1018 + */ + public function testIndexByToOneJoinSilentlyIgnored() + { + $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B '. + 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; + $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC618Book', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC618Author', $result[0]->author); + + $dql = 'SELECT B, A FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Book B '. + 'INNER JOIN B.author A INDEX BY A.name ORDER BY A.name ASC'; + $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); + + $this->assertEquals("Alice", $result[0]['author']['name']); + } + + /** + * @group DDC-1018 + */ + public function testCombineIndexBy() + { + $dql = 'SELECT A, B FROM Doctrine\Tests\ORM\Functional\Ticket\DDC618Author A INDEX BY A.id '. + 'INNER JOIN A.books B INDEX BY B.title ORDER BY A.name ASC'; + $result = $this->_em->createQuery($dql)->getResult(\Doctrine\ORM\Query::HYDRATE_OBJECT); + + $this->assertArrayHasKey(11, $result); // Alice + + $this->assertEquals(3, count($result[11]->books)); // Alice, Joe doesnt appear because he has no books. + $this->assertEquals('Alice', $result[11]->name); + $this->assertTrue( isset($result[11]->books["In Wonderland"] ), "Indexing by title should have books by title."); + $this->assertTrue( isset($result[11]->books["Reloaded"] ), "Indexing by title should have books by title."); + $this->assertTrue( isset($result[11]->books["Test"] ), "Indexing by title should have books by title."); + } +} + +/** + * @Entity + */ +class DDC618Author +{ + /** + * @Id + * @Column(type="integer") + */ + public $id; + + /** @Column(type="string") */ + public $name; + + /** + * @OneToMany(targetEntity="DDC618Book", mappedBy="author", cascade={"persist"}) + */ + public $books; + + public function __construct() + { + $this->books = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function addBook($title) + { + $book = new DDC618Book($title, $this); + $this->books[] = $book; + } +} + +/** + * @Entity + */ +class DDC618Book +{ + /** + * @Id @GeneratedValue + * @Column(type="integer") + */ + public $id; + + /** @column(type="string") */ + public $title; + + /** @ManyToOne(targetEntity="DDC618Author", inversedBy="books") */ + public $author; + + function __construct($title, $author) + { + $this->title = $title; + $this->author = $author; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php new file mode 100644 index 0000000..2ec4383 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC633Test.php @@ -0,0 +1,102 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Patient'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Appointment'), + )); + } catch(\Exception $e) { + + } + } + + /** + * @group DDC-633 + * @group DDC-952 + * @group DDC-914 + */ + public function testOneToOneEager() + { + $app = new DDC633Appointment(); + $pat = new DDC633Patient(); + $app->patient = $pat; + $pat->appointment = $app; + + $this->_em->persist($app); + $this->_em->persist($pat); + $this->_em->flush(); + $this->_em->clear(); + + $eagerAppointment = $this->_em->find(__NAMESPACE__ . '\DDC633Appointment', $app->id); + + // Eager loading of one to one leads to fetch-join + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient); + $this->assertTrue($this->_em->contains($eagerAppointment->patient)); + } + + /** + * @group DDC-633 + * @group DDC-952 + */ + public function testDQLDeferredEagerLoad() + { + for ($i = 0; $i < 10; $i++) { + $app = new DDC633Appointment(); + $pat = new DDC633Patient(); + $app->patient = $pat; + $pat->appointment = $app; + + $this->_em->persist($app); + $this->_em->persist($pat); + } + $this->_em->flush(); + $this->_em->clear(); + + $appointments = $this->_em->createQuery("SELECT a FROM " . __NAMESPACE__ . "\DDC633Appointment a")->getResult(); + + foreach ($appointments AS $eagerAppointment) { + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient); + $this->assertTrue($eagerAppointment->patient->__isInitialized__, "Proxy should already be initialized due to eager loading!"); + } + } +} + +/** + * @Entity + */ +class DDC633Appointment +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** + * @OneToOne(targetEntity="DDC633Patient", inversedBy="appointment", fetch="EAGER") + */ + public $patient; + +} + +/** + * @Entity + */ +class DDC633Patient +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** + * @OneToOne(targetEntity="DDC633Appointment", mappedBy="patient") + */ + public $appointment; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php new file mode 100644 index 0000000..f2bbc2a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC656Test.php @@ -0,0 +1,82 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC656Entity') + )); + } catch(\Exception $e) { + + } + } + + public function testRecomputeSingleEntityChangeSet_PreservesFieldOrder() + { + $entity = new DDC656Entity(); + $entity->setName('test1'); + $entity->setType('type1'); + $this->_em->persist($entity); + + $this->_em->getUnitOfWork()->computeChangeSet($this->_em->getClassMetadata(get_class($entity)), $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); + + $this->assertEquals(array_keys($data1), array_keys($data2)); + + $this->_em->flush(); + $this->_em->clear(); + + $persistedEntity = $this->_em->find(get_class($entity), $entity->specificationId); + $this->assertEquals('type2', $persistedEntity->getType()); + $this->assertEquals('test1', $persistedEntity->getName()); + } +} + +/** + * @Entity + */ +class DDC656Entity +{ + /** + * @Column(type="string") + */ + public $name; + + /** + * @Column(type="string") + */ + public $type; + + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $specificationId; + + public function getName() { + return $this->name; + } + + public function setName($name) { + $this->name = $name; + } + + public function getType() { + return $this->type; + } + + public function setType($type) { + $this->type = $type; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php new file mode 100644 index 0000000..cf3e5bd --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC657Test.php @@ -0,0 +1,118 @@ +useModelSet('generic'); + parent::setUp(); + + $this->loadFixtures(); + } + + public function testEntitySingleResult() + { + $query = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d'); + $datetime = $query->setMaxResults(1)->getSingleResult(); + + $this->assertTrue($datetime instanceof DateTimeModel); + + $this->assertTrue($datetime->datetime instanceof \DateTime); + $this->assertTrue($datetime->time instanceof \DateTime); + $this->assertTrue($datetime->date instanceof \DateTime); + } + + public function testScalarResult() + { + $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); + $result = $query->getScalarResult(); + + $this->assertCount(2,$result); + + $this->assertContains('11:11:11', $result[0]['time']); + $this->assertContains('2010-01-01', $result[0]['date']); + $this->assertContains('2010-01-01 11:11:11', $result[0]['datetime']); + + $this->assertContains('12:12:12', $result[1]['time']); + $this->assertContains('2010-02-02', $result[1]['date']); + $this->assertContains('2010-02-02 12:12:12', $result[1]['datetime']); + } + + public function testaTicketEntityArrayResult() + { + $query = $this->_em->createQuery('SELECT d FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); + $result = $query->getArrayResult(); + + $this->assertCount(2,$result); + + $this->assertTrue($result[0]['datetime'] instanceof \DateTime); + $this->assertTrue($result[0]['time'] instanceof \DateTime); + $this->assertTrue($result[0]['date'] instanceof \DateTime); + + $this->assertTrue($result[1]['datetime'] instanceof \DateTime); + $this->assertTrue($result[1]['time'] instanceof \DateTime); + $this->assertTrue($result[1]['date'] instanceof \DateTime); + } + + public function testTicketSingleResult() + { + $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); + $datetime = $query->setMaxResults(1)->getSingleResult(); + + $this->assertTrue(is_array($datetime)); + + $this->assertTrue($datetime['datetime'] instanceof \DateTime); + $this->assertTrue($datetime['time'] instanceof \DateTime); + $this->assertTrue($datetime['date'] instanceof \DateTime); + } + + public function testTicketResult() + { + $query = $this->_em->createQuery('SELECT d.id, d.time, d.date, d.datetime FROM ' . self::NS . '\DateTimeModel d ORDER BY d.date ASC'); + $result = $query->getResult(); + + $this->assertCount(2,$result); + + $this->assertTrue($result[0]['time'] instanceof \DateTime); + $this->assertTrue($result[0]['date'] instanceof \DateTime); + $this->assertTrue($result[0]['datetime'] instanceof \DateTime); + $this->assertEquals('2010-01-01 11:11:11', $result[0]['datetime']->format('Y-m-d G:i:s')); + + $this->assertTrue($result[1]['time'] instanceof \DateTime); + $this->assertTrue($result[1]['date'] instanceof \DateTime); + $this->assertTrue($result[1]['datetime'] instanceof \DateTime); + $this->assertEquals('2010-02-02 12:12:12', $result[1]['datetime']->format('Y-m-d G:i:s')); + } + + public function loadFixtures() + { + $timezone = new \DateTimeZone('America/Sao_Paulo'); + + $dateTime1 = new DateTimeModel(); + $dateTime2 = new DateTimeModel(); + + $dateTime1->date = new \DateTime('2010-01-01', $timezone); + $dateTime1->time = new \DateTime('2010-01-01 11:11:11', $timezone); + $dateTime1->datetime= new \DateTime('2010-01-01 11:11:11', $timezone); + + $dateTime2->date = new \DateTime('2010-02-02', $timezone); + $dateTime2->time = new \DateTime('2010-02-02 12:12:12', $timezone); + $dateTime2->datetime= new \DateTime('2010-02-02 12:12:12', $timezone); + + $this->_em->persist($dateTime1); + $this->_em->persist($dateTime2); + + $this->_em->flush(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php new file mode 100644 index 0000000..4786cc1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC698Test.php @@ -0,0 +1,107 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC698Role'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC698Privilege') + )); + } catch(\Exception $e) { + + } + } + + public function testTicket() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('p', 'r') + ->from(__NAMESPACE__ . '\DDC698Privilege', 'p') + ->leftJoin('p.roles', 'r'); + + $sql = $qb->getQuery()->getSQL(); + + $this->assertEquals( + strtolower('SELECT p0_.privilegeID AS privilegeID0, p0_.name AS name1, r1_.roleID AS roleID2, r1_.name AS name3, r1_.shortName AS shortName4 FROM Privileges p0_ LEFT JOIN RolePrivileges r2_ ON p0_.privilegeID = r2_.privilegeID LEFT JOIN Roles r1_ ON r1_.roleID = r2_.roleID'), + strtolower($sql) + ); + } +} + +/** + * + * @Table(name="Roles") + * @Entity + */ +class DDC698Role +{ + /** + * @Id @Column(name="roleID", type="integer") + * @GeneratedValue(strategy="AUTO") + * + */ + protected $roleID; + + /** + * @Column(name="name", type="string", length=45) + * + * + */ + protected $name; + + /** + * @Column(name="shortName", type="string", length=45) + * + * + */ + protected $shortName; + + + + /** + * @ManyToMany(targetEntity="DDC698Privilege", inversedBy="roles") + * @JoinTable(name="RolePrivileges", + * joinColumns={@JoinColumn(name="roleID", referencedColumnName="roleID")}, + * inverseJoinColumns={@JoinColumn(name="privilegeID", referencedColumnName="privilegeID")} + * ) + */ + protected $privilege; + +} + + +/** + * + * @Table(name="Privileges") + * @Entity() + */ +class DDC698Privilege +{ + /** + * @Id @Column(name="privilegeID", type="integer") + * @GeneratedValue(strategy="AUTO") + * + */ + protected $privilegeID; + + /** + * @Column(name="name", type="string", length=45) + * + * + */ + protected $name; + + /** + * @ManyToMany(targetEntity="DDC698Role", mappedBy="privilege") + */ + protected $roles; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php new file mode 100644 index 0000000..6bd18ef --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -0,0 +1,112 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC719Group'), + )); + } + + public function testIsEmptySqlGeneration() + { + $q = $this->_em->createQuery('SELECT g, c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC719Group g LEFT JOIN g.children c WHERE g.parents IS EMPTY'); + + $this->assertEquals( + strtolower('SELECT g0_.name AS name0, g0_.description AS description1, g0_.id AS id2, g1_.name AS name3, g1_.description AS description4, g1_.id AS id5 FROM groups g0_ LEFT JOIN groups_groups g2_ ON g0_.id = g2_.parent_id LEFT JOIN groups g1_ ON g1_.id = g2_.child_id WHERE (SELECT COUNT(*) FROM groups_groups g3_ WHERE g3_.child_id = g0_.id) = 0'), + strtolower($q->getSQL()) + ); + } +} + +/** + * @MappedSuperclass + */ +class Entity +{ + /** + * @Id @GeneratedValue + * @Column(type="integer") + */ + protected $id; + + public function getId() { return $this->id; } +} + +/** + * @Entity + * @Table(name="groups") + */ +class DDC719Group extends Entity { + /** @Column(type="string", nullable=false) */ + protected $name; + + /** @Column(type="string", nullable=true) */ + protected $description; + + /** + * @ManyToMany(targetEntity="DDC719Group", inversedBy="parents") + * @JoinTable(name="groups_groups", + * joinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")}, + * inverseJoinColumns={@JoinColumn(name="child_id", referencedColumnName="id")} + * ) + */ + protected $children = NULL; + + /** + * @ManyToMany(targetEntity="DDC719Group", mappedBy="children") + */ + protected $parents = NULL; + + /** + * construct + */ + public function __construct() { + parent::__construct(); + + $this->channels = new ArrayCollection(); + $this->children = new ArrayCollection(); + $this->parents = new ArrayCollection(); + } + + /** + * adds group as new child + * + * @param Group $child + */ + public function addGroup(Group $child) { + if ( ! $this->children->contains($child)) { + $this->children->add($child); + $child->addGroup($this); + } + } + + /** + * adds channel as new child + * + * @param Channel $child + */ + public function addChannel(Channel $child) { + if ( ! $this->channels->contains($child)) { + $this->channels->add($child); + } + } + + /** + * getter & setter + */ + public function getName() { return $this->name; } + public function setName($name) { $this->name = $name; } + public function getDescription() { return $this->description; } + public function setDescription($description) { $this->description = $description; } + public function getChildren() { return $this->children; } + public function getParents() { return $this->parents; } + public function getChannels() { return $this->channels; } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php new file mode 100644 index 0000000..3762497 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC729Test.php @@ -0,0 +1,182 @@ +_em); + $schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC729A'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC729B'), + )); + } catch(\Exception $e) { + + } + } + + public function testMergeManyToMany() + { + $a = new DDC729A(); + $b = new DDC729B(); + $a->related[] = $b; + + $this->_em->persist($a); + $this->_em->persist($b); + $this->_em->flush(); + $this->_em->clear(); + $aId = $a->id; + + $a = new DDC729A(); + $a->id = $aId; + + $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $a->related); + + $a = $this->_em->merge($a); + + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $a->related); + + $this->assertFalse($a->related->isInitialized(), "Collection should not be marked initialized."); + $this->assertFalse($a->related->isDirty(), "Collection should not be marked as dirty."); + + $this->_em->flush(); + $this->_em->clear(); + + $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); + $this->assertEquals(1, count($a->related)); + } + + public function testUnidirectionalMergeManyToMany() + { + $a = new DDC729A(); + $b1 = new DDC729B(); + $b2 = new DDC729B(); + $a->related[] = $b1; + + $this->_em->persist($a); + $this->_em->persist($b1); + $this->_em->persist($b2); + $this->_em->flush(); + $this->_em->clear(); + $aId = $a->id; + + $a = new DDC729A(); + $a->id = $aId; + + $a = $this->_em->merge($a); + + $a->related->set(0, $this->_em->merge($b1)); + + $a->related->set(1, $this->_em->merge($b2)); + + $this->_em->flush(); + $this->_em->clear(); + + $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); + $this->assertEquals(2, count($a->related)); + } + + public function testBidirectionalMergeManyToMany() + { + $a = new DDC729A(); + $b1 = new DDC729B(); + $b2 = new DDC729B(); + $a->related[] = $b1; + + $this->_em->persist($a); + $this->_em->persist($b1); + $this->_em->persist($b2); + $this->_em->flush(); + $this->_em->clear(); + $aId = $a->id; + + $a = new DDC729A(); + $a->id = $aId; + + $a = $this->_em->merge($a); + + $a->related->set(0, $this->_em->merge($b1)); + $b1->related->set(0, $a); + + $a->related->set(1, $this->_em->merge($b2)); + $b2->related->set(0, $a); + + $this->_em->flush(); + $this->_em->clear(); + + $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); + $this->assertEquals(2, count($a->related)); + } + + public function testBidirectionalMultiMergeManyToMany() + { + $a = new DDC729A(); + $b1 = new DDC729B(); + $b2 = new DDC729B(); + $a->related[] = $b1; + + $this->_em->persist($a); + $this->_em->persist($b1); + $this->_em->persist($b2); + $this->_em->flush(); + $this->_em->clear(); + $aId = $a->id; + + $a = new DDC729A(); + $a->id = $aId; + + $a = $this->_em->merge($a); + + $a->related->set(0, $this->_em->merge($b1)); + $b1->related->set(0, $this->_em->merge($a)); + + $a->related->set(1, $this->_em->merge($b2)); + $b2->related->set(0, $this->_em->merge($a)); + + $this->_em->flush(); + $this->_em->clear(); + + $a = $this->_em->find(__NAMESPACE__ . '\DDC729A', $aId); + $this->assertEquals(2, count($a->related)); + } +} + +/** + * @Entity + */ +class DDC729A +{ + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + + /** @ManyToMany(targetEntity="DDC729B", inversedBy="related") */ + public $related; + + public function __construct() + { + $this->related = new \Doctrine\Common\Collections\ArrayCollection(); + } +} + +/** + * @Entity + */ +class DDC729B +{ + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + + /** @ManyToMany(targetEntity="DDC729B", mappedBy="related") */ + public $related; + + public function __construct() + { + $this->related = new \Doctrine\Common\Collections\ArrayCollection(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php new file mode 100644 index 0000000..77ef6e1 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC735Test.php @@ -0,0 +1,122 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC735Product'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC735Review') + )); + } catch(\Exception $e) { + + } + } + + public function testRemoveElement_AppliesOrphanRemoval() + { + // Create a product and its first review + $product = new DDC735Product; + $review = new DDC735Review($product); + + // Persist and flush + $this->_em->persist($product); + $this->_em->flush(); + + // Now you see it + $this->assertEquals(1, count($product->getReviews())); + + // Remove the review + $reviewId = $review->getId(); + $product->removeReview($review); + $this->_em->flush(); + + // Now you don't + $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should be 0 after removing its only Review'); + + // Refresh + $this->_em->refresh($product); + + // It should still be 0 + $this->assertEquals(0, count($product->getReviews()), 'count($reviews) should still be 0 after the refresh'); + + // Review should also not be available anymore + $this->assertNull($this->_em->find(__NAMESPACE__.'\DDC735Review', $reviewId)); + } +} + +/** + * @Entity + */ +class DDC735Product +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + protected $id; + + /** + * @OneToMany( + * targetEntity="DDC735Review", + * mappedBy="product", + * cascade={"persist"}, + * orphanRemoval=true + * ) + */ + protected $reviews; + + public function __construct() + { + $this->reviews = new ArrayCollection; + } + + public function getReviews() + { + return $this->reviews; + } + + public function addReview(DDC735Review $review) + { + $this->reviews->add($review); + } + + public function removeReview(DDC735Review $review) + { + $this->reviews->removeElement($review); + } +} + +/** + * @Entity + */ +class DDC735Review +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + protected $id; + + /** + * @ManyToOne(targetEntity="DDC735Product", inversedBy="reviews") + */ + protected $product; + + public function __construct(DDC735Product $product) + { + $this->product = $product; + $product->addReview($this); + } + + public function getId() + { + return $this->id; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php new file mode 100644 index 0000000..2dfeeec --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC736Test.php @@ -0,0 +1,100 @@ +useModelSet('ecommerce'); + parent::setUp(); + } + + /** + * @group DDC-736 + */ + public function testReorderEntityFetchJoinForHydration() + { + $cust = new ECommerceCustomer; + $cust->setName('roman'); + + $cart = new ECommerceCart; + $cart->setPayment('cash'); + $cart->setCustomer($cust); + + $this->_em->persist($cust); + $this->_em->persist($cart); + $this->_em->flush(); + $this->_em->clear(); + + $result = $this->_em->createQuery("select c, c.name, ca, ca.payment from Doctrine\Tests\Models\ECommerce\ECommerceCart ca join ca.customer c") + ->getSingleResult(/*\Doctrine\ORM\Query::HYDRATE_ARRAY*/); + + $cart2 = $result[0]; + unset($result[0]); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cart2); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer()); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart2->getCustomer()); + $this->assertEquals(array('name' => 'roman', 'payment' => 'cash'), $result); + } + + /** + * @group DDC-736 + * @group DDC-925 + * @group DDC-915 + */ + public function testDqlTreeWalkerReordering() + { + $cust = new ECommerceCustomer; + $cust->setName('roman'); + + $cart = new ECommerceCart; + $cart->setPayment('cash'); + $cart->setCustomer($cust); + + $this->_em->persist($cust); + $this->_em->persist($cart); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "select c, c.name, ca, ca.payment from Doctrine\Tests\Models\ECommerce\ECommerceCart ca join ca.customer c"; + $result = $this->_em->createQuery($dql) + ->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\Tests\ORM\Functional\Ticket\DisableFetchJoinTreeWalker')) + ->getResult(); + + /* @var $cart2 Doctrine\Tests\Models\ECommerce\ECommerceCart */ + $cart2 = $result[0][0]; + $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer()); + } +} + +class DisableFetchJoinTreeWalker extends \Doctrine\ORM\Query\TreeWalkerAdapter +{ + public function walkSelectStatement(AST\SelectStatement $AST) + { + $this->walkSelectClause($AST->selectClause); + } + + /** + * @param \Doctrine\ORM\Query\AST\SelectClause $selectClause + */ + public function walkSelectClause($selectClause) + { + foreach ($selectClause->selectExpressions AS $key => $selectExpr) { + /* @var $selectExpr \Doctrine\ORM\Query\AST\SelectExpression */ + if ($selectExpr->expression == "c") { + unset($selectClause->selectExpressions[$key]); + break; + } + } + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php new file mode 100644 index 0000000..7e6e200 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC742Test.php @@ -0,0 +1,130 @@ +addServer('localhost'); + $memcache->flush(); + + $cacheDriver = new \Doctrine\Common\Cache\MemcacheCache(); + $cacheDriver->setMemcache($memcache); + + $this->_em->getMetadataFactory()->setCacheDriver($cacheDriver); + } else if (\extension_loaded('apc')) { + $this->_em->getMetadataFactory()->setCacheDriver(new \Doctrine\Common\Cache\ApcCache()); + } + + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC742User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC742Comment') + )); + } catch(\Exception $e) { + + } + + // make sure classes will be deserialized from caches + $this->_em->getMetadataFactory()->setMetadataFor(__NAMESPACE__ . '\DDC742User', null); + $this->_em->getMetadataFactory()->setMetadataFor(__NAMESPACE__ . '\DDC742Comment', null); + } + + public function testIssue() + { + $user = new DDC742User(); + $user->title = "Foo"; + $user->favoriteComments = new ArrayCollection(); + + $comment1 = new DDC742Comment(); + $comment1->content = "foo"; + + $comment2 = new DDC742Comment(); + $comment2->content = "bar"; + + $comment3 = new DDC742Comment(); + $comment3->content = "baz"; + + $user->favoriteComments->add($comment1); + $user->favoriteComments->add($comment2); + + $this->_em->persist($user); + $this->_em->persist($comment1); + $this->_em->persist($comment2); + $this->_em->persist($comment3); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find(get_class($user), $user->id); + $comment3 = $this->_em->find(get_class($comment3), $comment3->id); + $user->favoriteComments->add($comment3); + $this->_em->flush(); + } +} + +/** + * @Entity + * @Table(name="users") + */ +class DDC742User +{ + /** + * User Id + * + * @Id + * @GeneratedValue(strategy="AUTO") + * @Column(type="integer") + * @var integer + */ + public $id; + /** + * @Column(length=100, type="string") + * @var string + */ + public $title; + /** + * @ManyToMany(targetEntity="DDC742Comment", cascade={"persist"}, fetch="EAGER") + * @JoinTable( + * name="user_comments", + * joinColumns={@JoinColumn(name="user_id",referencedColumnName="id")}, + * inverseJoinColumns={@JoinColumn(name="comment_id", referencedColumnName="id")} + * ) + * + * @var Doctrine\ORM\PersistentCollection + */ + public $favoriteComments; +} + +/** + * @Entity + * @Table(name="comments") + */ +class DDC742Comment +{ + /** + * User Id + * + * @Id + * @GeneratedValue(strategy="AUTO") + * @Column(type="integer") + * @var integer + */ + public $id; + /** + * @Column(length=100, type="string") + * @var string + */ + public $content; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php new file mode 100644 index 0000000..9954a69 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC748Test.php @@ -0,0 +1,64 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testRefreshWithManyToOne() + { + $user = new CmsUser(); + $user->name = "beberlei"; + $user->status = "active"; + $user->username = "beberlei"; + + $article = new CmsArticle(); + $article->setAuthor($user); + $article->text = "foo"; + $article->topic = "bar"; + + $this->_em->persist($user); + $this->_em->persist($article); + $this->_em->flush(); + + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles); + $this->_em->refresh($article); + $this->assertTrue($article !== $user->articles, "The article should not be replaced on the inverse side of the relation."); + $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles); + } + + public function testRefreshOneToOne() + { + $user = new CmsUser(); + $user->name = "beberlei"; + $user->status = "active"; + $user->username = "beberlei"; + + $address = new CmsAddress(); + $address->city = "Bonn"; + $address->country = "Germany"; + $address->street = "A street"; + $address->zip = 12345; + $address->setUser($user); + + $this->_em->persist($user); + $this->_em->persist($address); + $this->_em->flush(); + + $this->_em->refresh($address); + $this->assertSame($user, $address->user); + $this->assertSame($user->address, $address); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php new file mode 100644 index 0000000..76bb3bb --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC758Test.php @@ -0,0 +1,185 @@ +markTestSkipped('Destroys testsuite'); + $this->useModelSet("cms"); + + parent::setUp(); + } + + /** + * Helper method to set cascade to merge only + */ + private function setCascadeMergeFor($class) + { + $metadata = $this->_em->getMetadataFactory()->getMetaDataFor($class); + foreach ($metadata->associationMappings as $key => $associationMapping) { + $metadata->associationMappings[$key]["isCascadePersist"] = false; + $metadata->associationMappings[$key]["isCascadeMerge"] = true; + $metadata->associationMappings[$key]["isCascadeRemove"] = false; + $metadata->associationMappings[$key]["isCascadeDetach"] = false; + } + } + + /** + * Test that changing associations on detached entities and then cascade merging them + * causes the database to be updated with the new associations. + * This specifically tests adding new associations. + */ + public function testManyToManyMergeAssociationAdds() + { + $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsUser'); + $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsGroup'); + + // Put entities in the database + $cmsUser = new CmsUser(); + $cmsUser->username = "dave"; + $cmsUser->name = "Dave Keen"; + $cmsUser->status = "testing"; + + $group1 = new CmsGroup(); + $group1->name = "Group 1"; + + $group2 = new CmsGroup(); + $group2->name = "Group 2"; + + $this->_em->persist($cmsUser); + $this->_em->persist($group1); + $this->_em->persist($group2); + $this->_em->flush(); + + $cmsUserId = $cmsUser->id; + $group1Id = $group1->id; + $group2Id = $group2->id; + + $this->_em->clear(); + + // Now create detached versions of the entities with some new associations. + $cmsUser = new CmsUser(); + $cmsUser->id = $cmsUserId; + $cmsUser->username = "dave"; + $cmsUser->name = "Dave Keen"; + $cmsUser->status = "testing"; + $cmsUser->groups = new ArrayCollection(); + + $group1 = new CmsGroup(); + $group1->id = $group1Id; + $group1->name = "Group 1"; + $group1->users = new ArrayCollection(); + + $group2 = new CmsGroup(); + $group2->id = $group2Id; + $group2->name = "Group 2"; + $group2->users = new ArrayCollection(); + + $cmsUser->addGroup($group1); + $cmsUser->addGroup($group2); + + // Cascade merge of cmsUser followed by a flush should add in the birectional new many-to-many associations between the user and the groups + $this->_em->merge($cmsUser); + $this->_em->flush(); + + $this->_em->clear(); + + $cmsUsers = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); + $cmsGroups = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); + + // Check the entities are in the database + $this->assertEquals(1, sizeof($cmsUsers)); + $this->assertEquals(2, sizeof($cmsGroups)); + + // Check the associations between the entities are now in the database + $this->assertEquals(2, sizeof($cmsUsers[0]->groups)); + $this->assertEquals(1, sizeof($cmsGroups[0]->users)); + $this->assertEquals(1, sizeof($cmsGroups[1]->users)); + + $this->assertSame($cmsUsers[0]->groups[0], $cmsGroups[0]); + $this->assertSame($cmsUsers[0]->groups[1], $cmsGroups[1]); + $this->assertSame($cmsGroups[0]->users[0], $cmsUsers[0]); + $this->assertSame($cmsGroups[1]->users[0], $cmsUsers[0]); + } + + /** + * Test that changing associations on detached entities and then cascade merging them causes the + * database to be updated with the new associations. + */ + public function testManyToManyMergeAssociationRemoves() + { + $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsUser'); + $this->setCascadeMergeFor('Doctrine\Tests\Models\CMS\CmsGroup'); + + $cmsUser = new CmsUser(); + $cmsUser->username = "dave"; + $cmsUser->name = "Dave Keen"; + $cmsUser->status = "testing"; + + $group1 = new CmsGroup(); + $group1->name = "Group 1"; + + $group2 = new CmsGroup(); + $group2->name = "Group 2"; + + $cmsUser->addGroup($group1); + $cmsUser->addGroup($group2); + + $this->_em->persist($cmsUser); + $this->_em->persist($group1); + $this->_em->persist($group2); + $this->_em->flush(); + + $cmsUserId = $cmsUser->id; + $group1Id = $group1->id; + $group2Id = $group2->id; + + $this->_em->clear(); + + // Now create detached versions of the entities with NO associations. + $cmsUser = new CmsUser(); + $cmsUser->id = $cmsUserId; + $cmsUser->username = "dave"; + $cmsUser->name = "Dave Keen"; + $cmsUser->status = "testing"; + $cmsUser->groups = new ArrayCollection(); + + $group1 = new CmsGroup(); + $group1->id = $group1Id; + $group1->name = "Group 1"; + $group1->users = new ArrayCollection(); + + $group2 = new CmsGroup(); + $group2->id = $group2Id; + $group2->name = "Group 2"; + $group2->users = new ArrayCollection(); + + // Cascade merge of cmsUser followed by a flush should result in the association array collection being empty + $this->_em->merge($cmsUser); + $this->_em->flush(); + + $this->_em->clear(); + + $cmsUsers = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); + $cmsGroups = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); + + // Check the entities are in the database + $this->assertEquals(1, sizeof($cmsUsers)); + $this->assertEquals(2, sizeof($cmsGroups)); + + // Check the associations between the entities are now in the database + $this->assertEquals(0, sizeof($cmsUsers[0]->groups)); + $this->assertEquals(0, sizeof($cmsGroups[0]->users)); + $this->assertEquals(0, sizeof($cmsGroups[1]->users)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php new file mode 100644 index 0000000..7ba337e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php @@ -0,0 +1,74 @@ +useModelSet('cms'); + parent::setUp(); + } + + /** + * @group DDC-767 + */ + public function testCollectionChangesInsideTransaction() + { + $user = new CmsUser(); + $user->name = "beberlei"; + $user->status = "active"; + $user->username = "beberlei"; + + $group1 = new CmsGroup(); + $group1->name = "foo"; + + $group2 = new CmsGroup(); + $group2->name = "bar"; + + $group3 = new CmsGroup(); + $group3->name = "baz"; + + $user->addGroup($group1); + $user->addGroup($group2); + + $this->_em->persist($user); + $this->_em->persist($group1); + $this->_em->persist($group2); + $this->_em->persist($group3); + + $this->_em->flush(); + $this->_em->clear(); + + /* @var $pUser CmsUser */ + $pUser = $this->_em->find(get_class($user), $user->id); + + $this->assertNotNull($pUser, "User not retrieved from database."); + + $groups = array(2, 3); + + try { + $this->_em->beginTransaction(); + + $pUser->groups->clear(); + + $this->_em->flush(); + + // Add new + foreach ($groups as $groupId) { + $pUser->addGroup($this->_em->find(get_class($group1), $groupId)); + } + + $this->_em->flush(); + $this->_em->commit(); + } catch(\Exception $e) { + $this->_em->rollback(); + } + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php new file mode 100644 index 0000000..c586afa --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC809Test.php @@ -0,0 +1,109 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC809Variant'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC809SpecificationValue') + )); + + $conn = $this->_em->getConnection(); + $conn->insert('specification_value_test', array('specification_value_id' => 94589)); + $conn->insert('specification_value_test', array('specification_value_id' => 94593)); + $conn->insert('specification_value_test', array('specification_value_id' => 94606)); + $conn->insert('specification_value_test', array('specification_value_id' => 94607)); + $conn->insert('specification_value_test', array('specification_value_id' => 94609)); + $conn->insert('specification_value_test', array('specification_value_id' => 94711)); + + $conn->insert('variant_test', array('variant_id' => 545208)); + $conn->insert('variant_test', array('variant_id' => 545209)); + + $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94606)); + $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94607)); + $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94609)); + $conn->insert('var_spec_value_test', array('variant_id' => 545208, 'specification_value_id' => 94711)); + + $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94589)); + $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94593)); + $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94606)); + $conn->insert('var_spec_value_test', array('variant_id' => 545209, 'specification_value_id' => 94607)); + } + + /** + * @group DDC-809 + */ + public function testIssue() + { + $result = $this->_em->createQueryBuilder() + ->select('Variant, SpecificationValue') + ->from('Doctrine\Tests\ORM\Functional\Ticket\DDC809Variant', 'Variant') + ->leftJoin('Variant.SpecificationValues', 'SpecificationValue') + ->getQuery() + ->getResult(); + + $this->assertEquals(4, count($result[0]->getSpecificationValues()), "Works in test-setup."); + $this->assertEquals(4, count($result[1]->getSpecificationValues()), "Only returns 2 in the case of the hydration bug."); + } +} + +/** + * @Table(name="variant_test") + * @Entity + */ +class DDC809Variant +{ + /** + * @Column(name="variant_id", type="integer") + * @Id + */ + protected $variantId; + + /** + * @ManyToMany(targetEntity="DDC809SpecificationValue", inversedBy="Variants") + * @JoinTable(name="var_spec_value_test", + * joinColumns={ + * @JoinColumn(name="variant_id", referencedColumnName="variant_id") + * }, + * inverseJoinColumns={ + * @JoinColumn(name="specification_value_id", referencedColumnName="specification_value_id") + * } + * ) + */ + protected $SpecificationValues; + + public function getSpecificationValues() + { + return $this->SpecificationValues; + } +} + +/** + * @Table(name="specification_value_test") + * @Entity + */ +class DDC809SpecificationValue +{ + /** + * @Column(name="specification_value_id", type="integer") + * @Id + */ + protected $specificationValueId; + + /** + * @var Variant + * + * @ManyToMany(targetEntity="DDC809Variant", mappedBy="SpecificationValues") + */ + protected $Variants; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php new file mode 100644 index 0000000..4a80358 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC812Test.php @@ -0,0 +1,48 @@ +useModelSet('cms'); + parent::setUp(); + } + + /** + * @group DDC-812 + */ + public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManagedEntity() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $article = new CmsArticle; + $article->topic = "hello"; + $article->text = "talk talk talk"; + + $comment = new CmsComment; + $comment->topic = "good!"; + $comment->text = "stuff!"; + $comment->article = $article; + + $this->_em->persist($article); + $this->_em->persist($comment); + $this->_em->flush(); + $this->_em->clear(); + + $article2 = $this->_em->find(get_class($article), $article->id); + + $article2Again = $this->_em->createQuery( + "select a, c from Doctrine\Tests\Models\CMS\CmsArticle a join a.comments c where a.id = ?1") + ->setParameter(1, $article->id) + ->getSingleResult(); + + $this->assertTrue($article2Again === $article2); + $this->assertTrue($article2Again->comments->isInitialized()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php new file mode 100644 index 0000000..599218b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC832Test.php @@ -0,0 +1,194 @@ +_em->getConnection()->getDatabasePlatform(); + if ($platform->getName() == "oracle") { + $this->markTestSkipped('Doesnt run on Oracle.'); + } + + $this->_em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); + try { + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832JoinedIndex'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832JoinedTreeIndex'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832Like'), + )); + } catch(\Exception $e) { + + } + } + + public function tearDown() + { + /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ + $platform = $this->_em->getConnection()->getDatabasePlatform(); + $sm = $this->_em->getConnection()->getSchemaManager(); + $sm->dropTable($platform->quoteIdentifier('TREE_INDEX')); + $sm->dropTable($platform->quoteIdentifier('INDEX')); + $sm->dropTable($platform->quoteIdentifier('LIKE')); + } + + /** + * @group DDC-832 + */ + public function testQuotedTableBasicUpdate() + { + $like = new DDC832Like("test"); + $this->_em->persist($like); + $this->_em->flush(); + + $like->word = "test2"; + $this->_em->flush(); + } + + /** + * @group DDC-832 + */ + public function testQuotedTableBasicRemove() + { + $like = new DDC832Like("test"); + $this->_em->persist($like); + $this->_em->flush(); + + $this->_em->remove($like); + $this->_em->flush(); + } + + /** + * @group DDC-832 + */ + public function testQuotedTableJoinedUpdate() + { + $index = new DDC832JoinedIndex("test"); + $this->_em->persist($index); + $this->_em->flush(); + + $index->name = "asdf"; + $this->_em->flush(); + } + + /** + * @group DDC-832 + */ + public function testQuotedTableJoinedRemove() + { + $index = new DDC832JoinedIndex("test"); + $this->_em->persist($index); + $this->_em->flush(); + + $this->_em->remove($index); + $this->_em->flush(); + } + + /** + * @group DDC-832 + */ + public function testQuotedTableJoinedChildUpdate() + { + $index = new DDC832JoinedTreeIndex("test", 1, 2); + $this->_em->persist($index); + $this->_em->flush(); + + $index->name = "asdf"; + $this->_em->flush(); + } + + /** + * @group DDC-832 + */ + public function testQuotedTableJoinedChildRemove() + { + $index = new DDC832JoinedTreeIndex("test", 1, 2); + $this->_em->persist($index); + $this->_em->flush(); + + $this->_em->remove($index); + $this->_em->flush(); + } +} + +/** + * @Entity + * @Table(name="`LIKE`") + */ +class DDC832Like +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; + + /** @Column(type="string") */ + public $word; + + /** + * @version + * @Column(type="integer") + */ + public $version; + + public function __construct($word) + { + $this->word = $word; + } +} + +/** + * @Entity + * @Table(name="`INDEX`") + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="discr", type="string") + * @DiscriminatorMap({"like" = "DDC832JoinedIndex", "fuzzy" = "DDC832JoinedTreeIndex"}) + */ +class DDC832JoinedIndex +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + public $id; + + /** @Column(type="string") */ + public $name; + + /** + * @version + * @Column(type="integer") + */ + public $version; + + public function __construct($name) + { + $this->name = $name; + } +} + +/** + * @Entity + * @Table(name="`TREE_INDEX`") + */ +class DDC832JoinedTreeIndex extends DDC832JoinedIndex +{ + /** @Column(type="integer") */ + public $lft; + /** @Column(type="integer") */ + public $rgt; + + public function __construct($name, $lft, $rgt) + { + $this->name = $name; + $this->lft = $lft; + $this->rgt = $rgt; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php new file mode 100644 index 0000000..d44c3af --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC837Test.php @@ -0,0 +1,198 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Super'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Class1'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Class2'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Class3'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC837Aggregate'), + )); + } + + /** + * @group DDC-837 + */ + public function testIssue() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + + $c1 = new DDC837Class1(); + $c1->title = "Foo"; + $c1->description = "Foo"; + $aggregate1 = new DDC837Aggregate('test1'); + $c1->aggregate = $aggregate1; + + $c2 = new DDC837Class2(); + $c2->title = "Bar"; + $c2->description = "Bar"; + $c2->text = "Bar"; + $aggregate2 = new DDC837Aggregate('test2'); + $c2->aggregate = $aggregate2; + + $c3 = new DDC837Class3(); + $c3->apples = "Baz"; + $c3->bananas = "Baz"; + + $this->_em->persist($c1); + $this->_em->persist($aggregate1); + $this->_em->persist($c2); + $this->_em->persist($aggregate2); + $this->_em->persist($c3); + $this->_em->flush(); + $this->_em->clear(); + + // Test Class1 + $e1 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC837Super', $c1->id); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class1', $e1); + $this->assertEquals('Foo', $e1->title); + $this->assertEquals('Foo', $e1->description); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC837Aggregate', $e1->aggregate); + $this->assertEquals('test1', $e1->aggregate->getSysname()); + + // Test Class 2 + $e2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC837Super', $c2->id); + + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class2', $e2); + $this->assertEquals('Bar', $e2->title); + $this->assertEquals('Bar', $e2->description); + $this->assertEquals('Bar', $e2->text); + $this->assertInstanceOf(__NAMESPACE__ . '\DDC837Aggregate', $e2->aggregate); + $this->assertEquals('test2', $e2->aggregate->getSysname()); + + $all = $this->_em->getRepository(__NAMESPACE__.'\DDC837Super')->findAll(); + + foreach ($all as $obj) { + if ($obj instanceof DDC837Class1) { + $this->assertEquals('Foo', $obj->title); + $this->assertEquals('Foo', $obj->description); + } else if ($obj instanceof DDC837Class2) { + $this->assertTrue($e2 === $obj); + $this->assertEquals('Bar', $obj->title); + $this->assertEquals('Bar', $obj->description); + $this->assertEquals('Bar', $obj->text); + } else if ($obj instanceof DDC837Class3) { + $this->assertEquals('Baz', $obj->apples); + $this->assertEquals('Baz', $obj->bananas); + } else { + $this->fail('Instance of DDC837Class1, DDC837Class2 or DDC837Class3 expected.'); + } + } + } +} + +/** + * @Entity + * @Table(name="DDC837Super") + * @InheritanceType("JOINED") + * @DiscriminatorColumn(name="type", type="string") + * @DiscriminatorMap({"class1" = "DDC837Class1", "class2" = "DDC837Class2", "class3"="DDC837Class3"}) + */ +abstract class DDC837Super +{ + /** + * @Id @Column(name="id", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; +} + +/** + * @Entity + */ +class DDC837Class1 extends DDC837Super +{ + /** + * @Column(name="title", type="string", length=150) + */ + public $title; + + /** + * @Column(name="content", type="string", length=500) + */ + public $description; + + /** + * @OneToOne(targetEntity="DDC837Aggregate") + */ + public $aggregate; +} + +/** + * @Entity + */ +class DDC837Class2 extends DDC837Super +{ + /** + * @Column(name="title", type="string", length=150) + */ + public $title; + + /** + * @Column(name="content", type="string", length=500) + */ + public $description; + + /** + * @Column(name="text", type="text") + */ + public $text; + + /** + * @OneToOne(targetEntity="DDC837Aggregate") + */ + public $aggregate; +} + +/** + * An extra class to demonstrate why title and description aren't in Super + * + * @Entity + */ +class DDC837Class3 extends DDC837Super +{ + /** + * @Column(name="title", type="string", length=150) + */ + public $apples; + + /** + * @Column(name="content", type="string", length=500) + */ + public $bananas; +} + +/** + * @Entity + */ +class DDC837Aggregate +{ + /** + * @Id @Column(name="id", type="integer") + * @GeneratedValue + */ + public $id; + + /** + * @Column(name="sysname", type="string") + */ + protected $sysname; + + public function __construct($sysname) + { + $this->sysname = $sysname; + } + + public function getSysname() + { + return $this->sysname; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php new file mode 100644 index 0000000..b17e605 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC849Test.php @@ -0,0 +1,84 @@ +useModelSet('cms'); + parent::setUp(); + + $this->user = new CmsUser(); + $this->user->username = "beberlei"; + $this->user->name = "Benjamin"; + $this->user->status = "active"; + + $this->group1 = new CmsGroup(); + $this->group1->name = "Group 1"; + $this->group2 = new CmsGroup(); + $this->group2->name = "Group 2"; + + $this->user->addGroup($this->group1); + $this->user->addGroup($this->group2); + + $this->_em->persist($this->user); + $this->_em->persist($this->group1); + $this->_em->persist($this->group2); + + $this->_em->flush(); + $this->_em->clear(); + + $this->user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->user->getId()); + } + + public function testRemoveContains() + { + $group1 = $this->user->groups[0]; + $group2 = $this->user->groups[1]; + + $this->assertTrue($this->user->groups->contains($group1)); + $this->assertTrue($this->user->groups->contains($group2)); + + $this->user->groups->removeElement($group1); + $this->user->groups->remove(1); + + $this->assertFalse($this->user->groups->contains($group1)); + $this->assertFalse($this->user->groups->contains($group2)); + } + + public function testClearCount() + { + $this->user->addGroup(new CmsGroup); + $this->assertEquals(3, count($this->user->groups)); + + $this->user->groups->clear(); + + $this->assertEquals(0, $this->user->groups->count()); + $this->assertEquals(0, count($this->user->groups)); + } + + public function testClearContains() + { + $group1 = $this->user->groups[0]; + $group2 = $this->user->groups[1]; + + $this->assertTrue($this->user->groups->contains($group1)); + $this->assertTrue($this->user->groups->contains($group2)); + + $this->user->groups->clear(); + + $this->assertFalse($this->user->groups->contains($group1)); + $this->assertFalse($this->user->groups->contains($group2)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php new file mode 100644 index 0000000..4ef3c08 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC881Test.php @@ -0,0 +1,215 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC881User'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC881Phonenumber'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC881Phonecall'), + )); + } catch (\Exception $e) { + + } + } + + /** + * @group DDC-117 + * @group DDC-881 + */ + public function testIssue() + { + /* Create two test users: albert and alfons */ + $albert = new DDC881User; + $albert->setName("albert"); + $this->_em->persist($albert); + + $alfons = new DDC881User; + $alfons->setName("alfons"); + $this->_em->persist($alfons); + + $this->_em->flush(); + + /* Assign two phone numbers to each user */ + $phoneAlbert1 = new DDC881PhoneNumber(); + $phoneAlbert1->setUser($albert); + $phoneAlbert1->setId(1); + $phoneAlbert1->setPhoneNumber("albert home: 012345"); + $this->_em->persist($phoneAlbert1); + + $phoneAlbert2 = new DDC881PhoneNumber(); + $phoneAlbert2->setUser($albert); + $phoneAlbert2->setId(2); + $phoneAlbert2->setPhoneNumber("albert mobile: 67890"); + $this->_em->persist($phoneAlbert2); + + $phoneAlfons1 = new DDC881PhoneNumber(); + $phoneAlfons1->setId(1); + $phoneAlfons1->setUser($alfons); + $phoneAlfons1->setPhoneNumber("alfons home: 012345"); + $this->_em->persist($phoneAlfons1); + + $phoneAlfons2 = new DDC881PhoneNumber(); + $phoneAlfons2->setId(2); + $phoneAlfons2->setUser($alfons); + $phoneAlfons2->setPhoneNumber("alfons mobile: 67890"); + $this->_em->persist($phoneAlfons2); + + /* We call alfons and albert once on their mobile numbers */ + $call1 = new DDC881PhoneCall(); + $call1->setPhoneNumber($phoneAlfons2); + $this->_em->persist($call1); + + $call2 = new DDC881PhoneCall(); + $call2->setPhoneNumber($phoneAlbert2); + $this->_em->persist($call2); + + $this->_em->flush(); + $this->_em->clear(); + + // fetch-join that foreign-key/primary-key entity association + $dql = "SELECT c, p FROM " . __NAMESPACE__ . "\DDC881PhoneCall c JOIN c.phonenumber p"; + $calls = $this->_em->createQuery($dql)->getResult(); + + $this->assertEquals(2, count($calls)); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $calls[0]->getPhoneNumber()); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $calls[1]->getPhoneNumber()); + + $dql = "SELECT p, c FROM " . __NAMESPACE__ . "\DDC881PhoneNumber p JOIN p.calls c"; + $numbers = $this->_em->createQuery($dql)->getResult(); + + $this->assertEquals(2, count($numbers)); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $numbers[0]->getCalls()); + $this->assertTrue($numbers[0]->getCalls()->isInitialized()); + } + +} + +/** + * @Entity + */ +class DDC881User +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + /** + * @Column(type="string") + */ + private $name; + /** + * @OneToMany(targetEntity="DDC881PhoneNumber",mappedBy="id") + */ + private $phoneNumbers; + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } +} + +/** + * @Entity + */ +class DDC881PhoneNumber +{ + + /** + * @Id + * @Column(type="integer") + */ + private $id; + /** + * @Id + * @ManyToOne(targetEntity="DDC881User",cascade={"all"}) + */ + private $user; + /** + * @Column(type="string") + */ + private $phonenumber; + + /** + * @OneToMany(targetEntity="DDC881PhoneCall", mappedBy="phonenumber") + */ + private $calls; + + public function __construct() + { + $this->calls = new \Doctrine\Common\Collections\ArrayCollection(); + } + + public function setId($id) + { + $this->id = $id; + } + + public function setUser(DDC881User $user) + { + $this->user = $user; + } + + public function setPhoneNumber($phoneNumber) + { + $this->phonenumber = $phoneNumber; + } + + public function getCalls() + { + return $this->calls; + } +} + +/** + * @Entity + */ +class DDC881PhoneCall +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + /** + * @ManyToOne(targetEntity="DDC881PhoneNumber", inversedBy="calls", cascade={"all"}) + * @JoinColumns({ + * @JoinColumn(name="phonenumber_id", referencedColumnName="id"), + * @JoinColumn(name="user_id", referencedColumnName="user_id") + * }) + */ + private $phonenumber; + /** + * @Column(type="string",nullable=true) + */ + private $callDate; + + public function setPhoneNumber(DDC881PhoneNumber $phoneNumber) + { + $this->phonenumber = $phoneNumber; + } + + public function getPhoneNumber() + { + return $this->phonenumber; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php new file mode 100644 index 0000000..cd2b584 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC933Test.php @@ -0,0 +1,39 @@ +useModelSet('company'); + parent::setUp(); + } + + /** + * @group DDC-933 + */ + public function testLockCTIClass() + { + //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger()); + + $manager = new \Doctrine\Tests\Models\Company\CompanyManager(); + $manager->setName('beberlei'); + $manager->setSalary(1234); + $manager->setTitle('Vice Precident of This Test'); + $manager->setDepartment("Foo"); + + $this->_em->persist($manager); + $this->_em->flush(); + + $this->_em->beginTransaction(); + $this->_em->lock($manager, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ); + $this->_em->rollback(); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php new file mode 100644 index 0000000..a3734b7 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC949Test.php @@ -0,0 +1,43 @@ +useModelSet('generic'); + parent::setUp(); + } + + /** + * @group DDC-949 + */ + public function testBooleanThroughRepository() + { + $true = new BooleanModel(); + $true->booleanField = true; + + $false = new BooleanModel(); + $false->booleanField = false; + + $this->_em->persist($true); + $this->_em->persist($false); + $this->_em->flush(); + $this->_em->clear(); + + $true = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => true)); + $false = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => false)); + + $this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $true, "True model not found"); + $this->assertTrue($true->booleanField, "True Boolean Model should be true."); + + $this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $false, "False model not found"); + $this->assertFalse($false->booleanField, "False Boolean Model should be false."); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php new file mode 100644 index 0000000..99a29a5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC960Test.php @@ -0,0 +1,92 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC960Root'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC960Child') + )); + } catch(\Exception $e) { + + } + } + + /** + * @group DDC-960 + */ + public function testUpdateRootVersion() + { + $child = new DDC960Child('Test'); + $this->_em->persist($child); + $this->_em->flush(); + + $child->setName("Test2"); + + $this->_em->flush(); + + $this->assertEquals(2, $child->getVersion()); + } +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorMap({ + * "root" = "DDC960Root", + * "child" = "DDC960Child" + * }) + */ +class DDC960Root +{ + /** + * @Id @GeneratedValue @Column(type="integer") + */ + private $id; + + /** + * @Column(type="integer") @Version + */ + private $version; + + public function getId() + { + return $this->id; + } + + public function getVersion() + { + return $this->version; + } +} + +/** + * @Entity + */ +class DDC960Child extends DDC960Root +{ + /** + * @column(type="string") + * @var string + */ + private $name; + + public function __construct($name) + { + $this->name = $name; + } + + public function setName($name) + { + $this->name = $name; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php new file mode 100644 index 0000000..001e380 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC992Test.php @@ -0,0 +1,147 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC992Role'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC992Parent'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC992Child'), + )); + } catch(\Exception $e) { + + } + } + + public function testIssue() + { + $role = new DDC992Role(); + $role->name = "Parent"; + $child = new DDC992Role(); + $child->name = "child"; + + $role->extendedBy[] = $child; + $child->extends[] = $role; + + $this->_em->persist($role); + $this->_em->persist($child); + $this->_em->flush(); + $this->_em->clear(); + + $child = $this->_em->getRepository(get_class($role))->find($child->roleID); + $parents = count($child->extends); + $this->assertEquals(1, $parents); + foreach ($child->extends AS $parent) { + $this->assertEquals($role->getRoleID(), $parent->getRoleID()); + } + } + + public function testOneToManyChild() + { + $parent = new DDC992Parent(); + $child = new DDC992Child(); + $child->parent = $parent; + $parent->childs[] = $child; + + $this->_em->persist($parent); + $this->_em->persist($child); + $this->_em->flush(); + $this->_em->clear(); + + $parentRepository = $this->_em->getRepository(get_class($parent)); + $childRepository = $this->_em->getRepository(get_class($child)); + + $parent = $parentRepository->find($parent->id); + $this->assertEquals(1, count($parent->childs)); + $this->assertEquals(0, count($parent->childs[0]->childs())); + + $child = $parentRepository->findOneBy(array("id" => $child->id)); + $this->assertSame($parent->childs[0], $child); + + $this->_em->clear(); + + $child = $parentRepository->find($child->id); + $this->assertEquals(0, count($child->childs)); + + $this->_em->clear(); + + $child = $childRepository->find($child->id); + $this->assertEquals(0, count($child->childs)); + } +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorMap({"child" = "DDC992Child", "parent" = "DDC992Parent"}) + */ +class DDC992Parent +{ + /** @Id @GeneratedValue @Column(type="integer") */ + public $id; + /** @ManyToOne(targetEntity="DDC992Parent", inversedBy="childs") */ + public $parent; + /** @OneToMany(targetEntity="DDC992Child", mappedBy="parent") */ + public $childs; +} + +/** + * @Entity + */ +class DDC992Child extends DDC992Parent +{ + public function childs() + { + return $this->childs; + } +} + +/** + * @Entity + */ +class DDC992Role +{ + public function getRoleID() + { + return $this->roleID; + } + + /** + * @Id @Column(name="roleID", type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $roleID; + /** + * @Column (name="name", type="string", length=45) + */ + public $name; + /** + * @ManyToMany (targetEntity="DDC992Role", mappedBy="extends") + */ + public $extendedBy; + /** + * @ManyToMany (targetEntity="DDC992Role", inversedBy="extendedBy") + * @JoinTable (name="RoleRelations", + * joinColumns={@JoinColumn(name="roleID", referencedColumnName="roleID")}, + * inverseJoinColumns={@JoinColumn(name="extendsRoleID", referencedColumnName="roleID")} + * ) + */ + public $extends; + + public function __construct() { + $this->extends = new ArrayCollection; + $this->extendedBy = new ArrayCollection; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php new file mode 100644 index 0000000..e183102 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php @@ -0,0 +1,44 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\Ticket2481Product') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + $this->_conn = $this->_em->getConnection(); + } + + public function testEmptyInsert() + { + $test = new Ticket2481Product(); + $this->_em->persist($test); + $this->_em->flush(); + + $this->assertTrue($test->id > 0); + } +} + +/** + * @Entity + * @Table(name="ticket_2481_products") + */ +class Ticket2481Product +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php new file mode 100644 index 0000000..1ca3511 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket69.php @@ -0,0 +1,427 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\Lemma'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\Relation'), + $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\RelationType') + )); + } catch (\Exception $e) { + // Swallow all exceptions. We do not test the schema tool here. + } + } + + public function testIssue() + { + //setup + $lemma1 = new Lemma; + $lemma1->setLemma('foo'); + + $lemma2 = new Lemma; + $lemma2->setLemma('bar'); + + $lemma3 = new Lemma; + $lemma3->setLemma('batz'); + + $lemma4 = new Lemma; + $lemma4->setLemma('bla'); + + $type1 = new RelationType; + $type1->setType('nonsense'); + $type1->setAbbreviation('non'); + + $type2 = new RelationType; + $type2->setType('quatsch'); + $type2->setAbbreviation('qu'); + + $relation1 = new Relation; + $relation1->setParent($lemma1); + $relation1->setChild($lemma2); + $relation1->setType($type1); + + $relation2 = new Relation; + $relation2->setParent($lemma1); + $relation2->setChild($lemma3); + $relation2->setType($type1); + + $relation3 = new Relation; + $relation3->setParent($lemma1); + $relation3->setChild($lemma4); + $relation3->setType($type2); + + $lemma1->addRelation($relation1); + $lemma1->addRelation($relation2); + $lemma1->addRelation($relation3); + + $this->_em->persist($type1); + $this->_em->persist($type2); + $this->_em->persist($lemma1); + $this->_em->persist($lemma2); + $this->_em->persist($lemma3); + $this->_em->persist($lemma4); + + $this->_em->flush(); + $this->_em->clear(); + //end setup + + // test One To Many + $query = $this->_em->createQuery("SELECT l FROM Doctrine\Tests\ORM\Functional\Ticket\Lemma l Where l.lemma = 'foo'"); + $res = $query->getResult(); + $lemma = $res[0]; + + $this->assertEquals('foo', $lemma->getLemma()); + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\Lemma', $lemma); + $relations = $lemma->getRelations(); + + foreach($relations as $relation) { + $this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\Relation', $relation); + $this->assertTrue($relation->getType()->getType() != ''); + } + + $this->_em->clear(); + + } +} + +/** + * @Entity + * @Table(name="lemma") + */ +class Lemma { + + const CLASS_NAME = __CLASS__; + + /** + * @var int + * @Id + * @Column(type="integer", name="lemma_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * + * @var string + * @Column(type="string", name="lemma_name", unique=true, length=255) + */ + private $lemma; + + + /** + * @var kateglo\application\utilities\collections\ArrayCollection + * @OneToMany(targetEntity="Relation", mappedBy="parent", cascade={"persist"}) + */ + private $relations; + + public function __construct() { + $this->types = new \Doctrine\Common\Collections\ArrayCollection(); + $this->relations = new \Doctrine\Common\Collections\ArrayCollection(); + } + + + /** + * + * @return int + */ + public function getId() { + return $this->id; + } + + /** + * + * @param string $lemma + * @return void + */ + public function setLemma($lemma) { + $this->lemma = $lemma; + } + + /** + * + * @return string + */ + public function getLemma() { + return $this->lemma; + } + + + /** + * + * @param Relation $relation + * @return void + */ + public function addRelation(Relation $relation) { + $this->relations[] = $relation; + $relation->setParent($this); + } + + /** + * + * @param Relation $relation + * @return void + */ + public function removeRelation(Relation $relation) { + /*@var $removed Relation */ + $removed = $this->relations->removeElement($relation); + if ($removed !== null) { + $removed->removeParent(); + } + } + + /** + * + * @return kateglo\application\utilities\collections\ArrayCollection + */ + public function getRelations() { + return $this->relations; + } + +} + +/** + * + * @Entity + * @Table(name="relation") + */ +class Relation { + + const CLASS_NAME = __CLASS__; + + /** + * @var int + * @Id + * @Column(type="integer", name="relation_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @var Lemma + * @ManyToOne(targetEntity="Lemma", inversedBy="relations") + * @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id") + */ + private $parent; + + /** + * @var Lemma + * @OneToOne(targetEntity="Lemma") + * @JoinColumn(name="relation_child_id", referencedColumnName="lemma_id") + */ + private $child; + + /** + * @var RelationType + * @ManyToOne(targetEntity="RelationType", inversedBy="relations") + * @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id") + */ + private $type; + + /** + * + * @param Lemma $parent + * @return void + */ + public function setParent(Lemma $parent) { + $this->parent = $parent; + } + + /** + * + * @return Phrase + */ + public function getParent() { + return $this->parent; + } + + /** + * + * @return void + */ + public function removeParent() { + if ($this->lemma !== null) { + /*@var $phrase Lemma */ + $lemma = $this->parent; + $this->parent = null; + $lemma->removeRelation($this); + } + } + + /** + * + * @param Lemma $child + * @return void + */ + public function setChild(Lemma $child) { + $this->child = $child; + } + + /** + * + * @return Lemma + */ + public function getChild() { + return $this->child; + } + + /** + * + * @param RelationType $type + * @return void + */ + public function setType(RelationType $type) { + $this->type = $type; + } + + /** + * + * @return RelationType + */ + public function getType() { + return $this->type; + } + + /** + * + * @return void + */ + public function removeType() { + if ($this->type !== null) { + /*@var $phrase RelationType */ + $type = $this->type; + $this->type = null; + $type->removeRelation($this); + } + } +} + +/** + * + * @Entity + * @Table(name="relation_type") + */ +class RelationType { + + const CLASS_NAME = __CLASS__; + + /** + * + * @var int + * @Id + * @Column(type="integer", name="relation_type_id") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * + * @var string + * @Column(type="string", name="relation_type_name", unique=true, length=255) + */ + private $type; + + /** + * + * @var string + * @Column(type="string", name="relation_type_abbreviation", unique=true, length=255) + */ + private $abbreviation; + + /** + * @var kateglo\application\utilities\collections\ArrayCollection + * @OneToMany(targetEntity="Relation", mappedBy="type", cascade={"persist"}) + */ + private $relations; + + public function __construct() { + $relations = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * + * @return int + */ + public function getId() { + return $this->id; + } + + /** + * + * @param string $type + * @return void + */ + public function setType($type) { + $this->type = $type; + } + + /** + * + * @return string + */ + public function getType() { + return $this->type; + } + + /** + * + * @param string $abbreviation + * @return void + */ + public function setAbbreviation($abbreviation) { + $this->abbreviation = $abbreviation; + } + + /** + * + * @return string + */ + public function getAbbreviation() { + return $this->abbreviation; + } + + /** + * + * @param Relation $relation + * @return void + */ + public function addRelation(Relation $relation) { + $this->relations[] = $relation; + $relation->setType($this); + } + + /** + * + * @param Relation $relation + * @return void + */ + public function removeRelation(Relation $relation) { + /*@var $removed Relation */ + $removed = $this->relations->removeElement($relation); + if ($removed !== null) { + $removed->removeLemma(); + } + } + + /** + * + * @return kateglo\application\utilities\collections\ArrayCollection + */ + public function getRelations() { + return $this->relations; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeTest.php new file mode 100644 index 0000000..9ed8cf0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeTest.php @@ -0,0 +1,182 @@ +useModelSet('generic'); + parent::setUp(); + } + + public function testDecimal() + { + $decimal = new DecimalModel(); + $decimal->decimal = 0.15; + $decimal->highScale = 0.1515; + + $this->_em->persist($decimal); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT d FROM Doctrine\Tests\Models\Generic\DecimalModel d"; + $decimal = $this->_em->createQuery($dql)->getSingleResult(); + + $this->assertEquals(0.15, $decimal->decimal); + $this->assertEquals(0.1515, $decimal->highScale); + } + + /** + * @group DDC-1394 + * @return void + */ + public function testBoolean() + { + $bool = new BooleanModel(); + $bool->booleanField = true; + + $this->_em->persist($bool); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true"; + $bool = $this->_em->createQuery($dql)->getSingleResult(); + + $this->assertTrue($bool->booleanField); + + $bool->booleanField = false; + + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false"; + $bool = $this->_em->createQuery($dql)->getSingleResult(); + + $this->assertFalse($bool->booleanField); + } + + public function testArray() + { + $serialize = new SerializationModel(); + $serialize->array["foo"] = "bar"; + $serialize->array["bar"] = "baz"; + + $this->_em->persist($serialize); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT s FROM Doctrine\Tests\Models\Generic\SerializationModel s"; + $serialize = $this->_em->createQuery($dql)->getSingleResult(); + + $this->assertEquals(array("foo" => "bar", "bar" => "baz"), $serialize->array); + } + + public function testObject() + { + $serialize = new SerializationModel(); + $serialize->object = new \stdClass(); + + $this->_em->persist($serialize); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT s FROM Doctrine\Tests\Models\Generic\SerializationModel s"; + $serialize = $this->_em->createQuery($dql)->getSingleResult(); + + $this->assertInstanceOf('stdClass', $serialize->object); + } + + public function testDate() + { + $dateTime = new DateTimeModel(); + $dateTime->date = new \DateTime('2009-10-01', new \DateTimeZone('Europe/Berlin')); + + $this->_em->persist($dateTime); + $this->_em->flush(); + $this->_em->clear(); + + $dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id); + + $this->assertInstanceOf('DateTime', $dateTimeDb->date); + $this->assertEquals('2009-10-01', $dateTimeDb->date->format('Y-m-d')); + } + + public function testDateTime() + { + $dateTime = new DateTimeModel(); + $dateTime->datetime = new \DateTime('2009-10-02 20:10:52', new \DateTimeZone('Europe/Berlin')); + + $this->_em->persist($dateTime); + $this->_em->flush(); + $this->_em->clear(); + + $dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id); + + $this->assertInstanceOf('DateTime', $dateTimeDb->datetime); + $this->assertEquals('2009-10-02 20:10:52', $dateTimeDb->datetime->format('Y-m-d H:i:s')); + + $articles = $this->_em->getRepository( 'Doctrine\Tests\Models\Generic\DateTimeModel' )->findBy( array( 'datetime' => new \DateTime( "now" ) ) ); + $this->assertEquals( 0, count( $articles ) ); + } + + public function testDqlQueryBindDateTimeInstance() + { + $date = new \DateTime('2009-10-02 20:10:52', new \DateTimeZone('Europe/Berlin')); + + $dateTime = new DateTimeModel(); + $dateTime->datetime = $date; + + $this->_em->persist($dateTime); + $this->_em->flush(); + $this->_em->clear(); + + $dateTimeDb = $this->_em->createQuery('SELECT d FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime = ?1') + ->setParameter(1, $date, DBALType::DATETIME) + ->getSingleResult(); + } + + public function testDqlQueryBuilderBindDateTimeInstance() + { + $date = new \DateTime('2009-10-02 20:10:52', new \DateTimeZone('Europe/Berlin')); + + $dateTime = new DateTimeModel(); + $dateTime->datetime = $date; + + $this->_em->persist($dateTime); + $this->_em->flush(); + $this->_em->clear(); + + $dateTimeDb = $this->_em->createQueryBuilder() + ->select('d') + ->from('Doctrine\Tests\Models\Generic\DateTimeModel', 'd') + ->where('d.datetime = ?1') + ->setParameter(1, $date, DBALType::DATETIME) + ->getQuery()->getSingleResult(); + } + + public function testTime() + { + $dateTime = new DateTimeModel(); + $dateTime->time = new \DateTime('2010-01-01 19:27:20'); + + $this->_em->persist($dateTime); + $this->_em->flush(); + $this->_em->clear(); + + $dateTimeDb = $this->_em->find('Doctrine\Tests\Models\Generic\DateTimeModel', $dateTime->id); + + $this->assertInstanceOf('DateTime', $dateTime->time); + $this->assertEquals('19:27:20', $dateTime->time->format('H:i:s')); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php new file mode 100644 index 0000000..1bd5184 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php @@ -0,0 +1,105 @@ +useModelSet('customtype'); + parent::setUp(); + } + + public function testUpperCaseStringType() + { + $entity = new CustomTypeUpperCase(); + $entity->lowerCaseString = 'foo'; + + $this->_em->persist($entity); + $this->_em->flush(); + + $id = $entity->id; + + $this->_em->clear(); + + $entity = $this->_em->find('\Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', $id); + + $this->assertEquals('foo', $entity->lowerCaseString, 'Entity holds lowercase string'); + $this->assertEquals('FOO', $this->_em->getConnection()->fetchColumn("select lowerCaseString from customtype_uppercases where id=".$entity->id.""), 'Database holds uppercase string'); + } + + public function testTypeValueSqlWithAssociations() + { + $parent = new CustomTypeParent(); + $parent->customInteger = -1; + $parent->child = new CustomTypeChild(); + + $friend1 = new CustomTypeParent(); + $friend2 = new CustomTypeParent(); + + $parent->addMyFriend($friend1); + $parent->addMyFriend($friend2); + + $this->_em->persist($parent); + $this->_em->persist($friend1); + $this->_em->persist($friend2); + $this->_em->flush(); + + $parentId = $parent->id; + + $this->_em->clear(); + + $entity = $this->_em->find('Doctrine\Tests\Models\CustomType\CustomTypeParent', $parentId); + + $this->assertTrue($entity->customInteger < 0, 'Fetched customInteger negative'); + $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select customInteger from customtype_parents where id=".$entity->id.""), 'Database has stored customInteger positive'); + + $this->assertNotNull($parent->child, 'Child attached'); + $this->assertCount(2, $entity->getMyFriends(), '2 friends attached'); + } + + public function testSelectDQL() + { + $parent = new CustomTypeParent(); + $parent->customInteger = -1; + $parent->child = new CustomTypeChild(); + + $this->_em->persist($parent); + $this->_em->flush(); + + $parentId = $parent->id; + + $this->_em->clear(); + + $query = $this->_em->createQuery("SELECT p, p.customInteger, c from Doctrine\Tests\Models\CustomType\CustomTypeParent p JOIN p.child c where p.id = " . $parentId); + + $result = $query->getResult(); + + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\CustomType\CustomTypeParent', $result[0][0]); + $this->assertEquals(-1, $result[0][0]->customInteger); + + $this->assertEquals(-1, $result[0]['customInteger']); + + $this->assertEquals('foo', $result[0][0]->child->lowerCaseString); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php new file mode 100644 index 0000000..08e3720 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/UnitOfWorkLifecycleTest.php @@ -0,0 +1,71 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testScheduleInsertManaged() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin"; + $user->status = "active"; + $this->_em->persist($user); + $this->_em->flush(); + + $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "A managed+dirty entity Doctrine\Tests\Models\CMS\CmsUser"); + $this->_em->getUnitOfWork()->scheduleForInsert($user); + } + + public function testScheduleInsertDeleted() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin"; + $user->status = "active"; + $this->_em->persist($user); + $this->_em->flush(); + + $this->_em->remove($user); + + $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Removed entity Doctrine\Tests\Models\CMS\CmsUser"); + $this->_em->getUnitOfWork()->scheduleForInsert($user); + } + + public function testScheduleInsertTwice() + { + $user = new CmsUser(); + $user->username = "beberlei"; + $user->name = "Benjamin"; + $user->status = "active"; + + $this->_em->getUnitOfWork()->scheduleForInsert($user); + + $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "Entity Doctrine\Tests\Models\CMS\CmsUser"); + $this->_em->getUnitOfWork()->scheduleForInsert($user); + } + + public function testAddToIdentityMapWithoutIdentity() + { + $user = new CmsUser(); + + $this->setExpectedException("Doctrine\ORM\ORMInvalidArgumentException", "The given entity of type 'Doctrine\Tests\Models\CMS\CmsUser' (Doctrine\Tests\Models\CMS\CmsUser@"); + $this->_em->getUnitOfWork()->registerManaged($user, array(), array()); + } + + public function testMarkReadOnlyNonManaged() + { + $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->_em->getUnitOfWork()->markReadOnly($user); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php new file mode 100644 index 0000000..b72e361 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php @@ -0,0 +1,1147 @@ +addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(is_array($result)); + + $this->assertEquals(1, $result[0]['id']); + $this->assertEquals('romanb', $result[0]['name']); + + $this->assertEquals(2, $result[1]['id']); + $this->assertEquals('jwage', $result[1]['name']); + } + + /** + * SELECT PARTIAL u.{id, name} AS user + * FROM Doctrine\Tests\Models\CMS\CmsUser u + */ + public function testSimpleEntityQueryWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(is_array($result)); + + $this->assertArrayHasKey('user', $result[0]); + $this->assertEquals(1, $result[0]['user']['id']); + $this->assertEquals('romanb', $result[0]['user']['name']); + + $this->assertArrayHasKey('user', $result[1]); + $this->assertEquals(2, $result[1]['user']['id']); + $this->assertEquals('jwage', $result[1]['user']['name']); + } + + /** + * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQuery() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(4, count($result)); + + $this->assertEquals(1, $result[0]['id']); + $this->assertEquals('romanb', $result[0]['name']); + + $this->assertEquals(1, $result[1]['id']); + $this->assertEquals('Cool things.', $result[1]['topic']); + + $this->assertEquals(2, $result[2]['id']); + $this->assertEquals('jwage', $result[2]['name']); + + $this->assertEquals(2, $result[3]['id']); + $this->assertEquals('Cool things II.', $result[3]['topic']); + } + + /** + * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(4, count($result)); + + $this->assertArrayHasKey('user', $result[0]); + $this->assertEquals(1, $result[0]['user']['id']); + $this->assertEquals('romanb', $result[0]['user']['name']); + + $this->assertArrayHasKey(0, $result[1]); + $this->assertEquals(1, $result[1][0]['id']); + $this->assertEquals('Cool things.', $result[1][0]['topic']); + + $this->assertArrayHasKey('user', $result[2]); + $this->assertEquals(2, $result[2]['user']['id']); + $this->assertEquals('jwage', $result[2]['user']['name']); + + $this->assertArrayHasKey(0, $result[3]); + $this->assertEquals(2, $result[3][0]['id']); + $this->assertEquals('Cool things II.', $result[3][0]['topic']); + } + + /** + * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} AS article + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(4, count($result)); + + $this->assertArrayHasKey(0, $result[0]); + $this->assertEquals(1, $result[0][0]['id']); + $this->assertEquals('romanb', $result[0][0]['name']); + + $this->assertArrayHasKey('article', $result[1]); + $this->assertEquals(1, $result[1]['article']['id']); + $this->assertEquals('Cool things.', $result[1]['article']['topic']); + + $this->assertArrayHasKey(0, $result[2]); + $this->assertEquals(2, $result[2][0]['id']); + $this->assertEquals('jwage', $result[2][0]['name']); + + $this->assertArrayHasKey('article', $result[3]); + $this->assertEquals(2, $result[3]['article']['id']); + $this->assertEquals('Cool things II.', $result[3]['article']['topic']); + } + + /** + * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} AS article + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQueryWithAliasedEntities() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(4, count($result)); + + $this->assertArrayHasKey('user', $result[0]); + $this->assertEquals(1, $result[0]['user']['id']); + $this->assertEquals('romanb', $result[0]['user']['name']); + + $this->assertArrayHasKey('article', $result[1]); + $this->assertEquals(1, $result[1]['article']['id']); + $this->assertEquals('Cool things.', $result[1]['article']['topic']); + + $this->assertArrayHasKey('user', $result[2]); + $this->assertEquals(2, $result[2]['user']['id']); + $this->assertEquals('jwage', $result[2]['user']['name']); + + $this->assertArrayHasKey('article', $result[3]); + $this->assertEquals(2, $result[3]['article']['id']); + $this->assertEquals('Cool things II.', $result[3]['article']['topic']); + } + + /** + * SELECT PARTIAL u.{id, status}, COUNT(p.phonenumber) AS numPhones + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * JOIN u.phonenumbers p + * GROUP BY u.status, u.id + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryNormalJoin($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'numPhones'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => '2', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => '1', + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[0])); + $this->assertTrue(is_array($result[1])); + + // first user => 2 phonenumbers + $this->assertArrayHasKey($userEntityKey, $result[0]); + $this->assertEquals(2, $result[0]['numPhones']); + + // second user => 1 phonenumber + $this->assertArrayHasKey($userEntityKey, $result[1]); + $this->assertEquals(1, $result[1]['numPhones']); + } + + /** + * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) AS nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * JOIN u.phonenumbers p + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryFetchJoin($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[0])); + $this->assertTrue(is_array($result[1])); + + // first user => 2 phonenumbers + $this->assertEquals(2, count($result[0][$userEntityKey]['phonenumbers'])); + $this->assertEquals('ROMANB', $result[0]['nameUpper']); + + // second user => 1 phonenumber + $this->assertEquals(1, count($result[1][$userEntityKey]['phonenumbers'])); + $this->assertEquals('JWAGE', $result[1]['nameUpper']); + + $this->assertEquals(42, $result[0][$userEntityKey]['phonenumbers'][0]['phonenumber']); + $this->assertEquals(43, $result[0][$userEntityKey]['phonenumbers'][1]['phonenumber']); + $this->assertEquals(91, $result[1][$userEntityKey]['phonenumbers'][0]['phonenumber']); + } + + /** + * SELECT PARTIAL u.{id, status}, UPPER(u.name) nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * INDEX BY u.id + * JOIN u.phonenumbers p + * INDEX BY p.phonenumber + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryFetchJoinCustomIndex($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addIndexBy('u', 'id'); + $rsm->addIndexBy('p', 'phonenumber'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91' + ) + ); + + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[1])); + $this->assertTrue(is_array($result[2])); + + // test the scalar values + $this->assertEquals('ROMANB', $result[1]['nameUpper']); + $this->assertEquals('JWAGE', $result[2]['nameUpper']); + + // first user => 2 phonenumbers. notice the custom indexing by user id + $this->assertEquals(2, count($result[1][$userEntityKey]['phonenumbers'])); + + // second user => 1 phonenumber. notice the custom indexing by user id + $this->assertEquals(1, count($result[2][$userEntityKey]['phonenumbers'])); + + // test the custom indexing of the phonenumbers + $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['42'])); + $this->assertTrue(isset($result[1][$userEntityKey]['phonenumbers']['43'])); + $this->assertTrue(isset($result[2][$userEntityKey]['phonenumbers']['91'])); + } + + /** + * select u.id, u.status, p.phonenumber, upper(u.name) nameUpper, a.id, a.topic + * from User u + * join u.phonenumbers p + * join u.articles a + * = + * select u.id, u.status, p.phonenumber, upper(u.name) as u__0, a.id, a.topic + * from USERS u + * inner join PHONENUMBERS p ON u.id = p.user_id + * inner join ARTICLES a ON u.id = a.user_id + */ + public function testMixedQueryMultipleFetchJoin() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsArticle', + 'a', + 'u', + 'articles' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '1', + 'a__topic' => 'Getting things done!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '1', + 'a__topic' => 'Getting things done!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '2', + 'a__topic' => 'ZendCon' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '2', + 'a__topic' => 'ZendCon' + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '3', + 'a__topic' => 'LINQ' + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '4', + 'a__topic' => 'PHP6' + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[0])); + $this->assertTrue(is_array($result[1])); + // first user => 2 phonenumbers, 2 articles + $this->assertEquals(2, count($result[0][0]['phonenumbers'])); + $this->assertEquals(2, count($result[0][0]['articles'])); + $this->assertEquals('ROMANB', $result[0]['nameUpper']); + // second user => 1 phonenumber, 2 articles + $this->assertEquals(1, count($result[1][0]['phonenumbers'])); + $this->assertEquals(2, count($result[1][0]['articles'])); + $this->assertEquals('JWAGE', $result[1]['nameUpper']); + + $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); + $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); + $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); + + $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); + $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); + $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); + $this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']); + } + + /** + * select u.id, u.status, p.phonenumber, upper(u.name) nameUpper, a.id, a.topic, + * c.id, c.topic + * from User u + * join u.phonenumbers p + * join u.articles a + * left join a.comments c + * = + * select u.id, u.status, p.phonenumber, upper(u.name) as u__0, a.id, a.topic, + * c.id, c.topic + * from USERS u + * inner join PHONENUMBERS p ON u.id = p.user_id + * inner join ARTICLES a ON u.id = a.user_id + * left outer join COMMENTS c ON a.id = c.article_id + */ + public function testMixedQueryMultipleDeepMixedFetchJoin() + { + + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsArticle', + 'a', + 'u', + 'articles' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsComment', + 'c', + 'a', + 'comments' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + $rsm->addFieldResult('c', 'c__id', 'id'); + $rsm->addFieldResult('c', 'c__topic', 'topic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '1', + 'a__topic' => 'Getting things done!', + 'c__id' => '1', + 'c__topic' => 'First!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '1', + 'a__topic' => 'Getting things done!', + 'c__id' => '1', + 'c__topic' => 'First!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '2', + 'a__topic' => 'ZendCon', + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '2', + 'a__topic' => 'ZendCon', + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '3', + 'a__topic' => 'LINQ', + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '4', + 'a__topic' => 'PHP6', + 'c__id' => null, + 'c__topic' => null + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[0])); + $this->assertTrue(is_array($result[1])); + + // first user => 2 phonenumbers, 2 articles, 1 comment on first article + $this->assertEquals(2, count($result[0][0]['phonenumbers'])); + $this->assertEquals(2, count($result[0][0]['articles'])); + $this->assertEquals(1, count($result[0][0]['articles'][0]['comments'])); + $this->assertEquals('ROMANB', $result[0]['nameUpper']); + // second user => 1 phonenumber, 2 articles, no comments + $this->assertEquals(1, count($result[1][0]['phonenumbers'])); + $this->assertEquals(2, count($result[1][0]['articles'])); + $this->assertEquals('JWAGE', $result[1]['nameUpper']); + + $this->assertEquals(42, $result[0][0]['phonenumbers'][0]['phonenumber']); + $this->assertEquals(43, $result[0][0]['phonenumbers'][1]['phonenumber']); + $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']); + + $this->assertEquals('Getting things done!', $result[0][0]['articles'][0]['topic']); + $this->assertEquals('ZendCon', $result[0][0]['articles'][1]['topic']); + $this->assertEquals('LINQ', $result[1][0]['articles'][0]['topic']); + $this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']); + + $this->assertEquals('First!', $result[0][0]['articles'][0]['comments'][0]['topic']); + + $this->assertTrue(isset($result[0][0]['articles'][0]['comments'])); + + // empty comment collections + $this->assertTrue(is_array($result[0][0]['articles'][1]['comments'])); + $this->assertEquals(0, count($result[0][0]['articles'][1]['comments'])); + $this->assertTrue(is_array($result[1][0]['articles'][0]['comments'])); + $this->assertEquals(0, count($result[1][0]['articles'][0]['comments'])); + $this->assertTrue(is_array($result[1][0]['articles'][1]['comments'])); + $this->assertEquals(0, count($result[1][0]['articles'][1]['comments'])); + } + + /** + * Tests that the hydrator does not rely on a particular order of the rows + * in the result set. + * + * DQL: + * select c.id, c.position, c.name, b.id, b.position + * from \Doctrine\Tests\Models\Forum\ForumCategory c inner join c.boards b + * order by c.position asc, b.position asc + * + * Checks whether the boards are correctly assigned to the categories. + * + * The 'evil' result set that confuses the object population is displayed below. + * + * c.id | c.position | c.name | boardPos | b.id | b.category_id (just for clarity) + * 1 | 0 | First | 0 | 1 | 1 + * 2 | 0 | Second | 0 | 2 | 2 <-- + * 1 | 0 | First | 1 | 3 | 1 + * 1 | 0 | First | 2 | 4 | 1 + */ + public function testEntityQueryCustomResultSetOrder() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\Forum\ForumBoard', + 'b', + 'c', + 'boards' + ); + + $rsm->addFieldResult('c', 'c__id', 'id'); + $rsm->addFieldResult('c', 'c__position', 'position'); + $rsm->addFieldResult('c', 'c__name', 'name'); + $rsm->addFieldResult('b', 'b__id', 'id'); + $rsm->addFieldResult('b', 'b__position', 'position'); + + // Faked result set + $resultSet = array( + array( + 'c__id' => '1', + 'c__position' => '0', + 'c__name' => 'First', + 'b__id' => '1', + 'b__position' => '0', + //'b__category_id' => '1' + ), + array( + 'c__id' => '2', + 'c__position' => '0', + 'c__name' => 'Second', + 'b__id' => '2', + 'b__position' => '0', + //'b__category_id' => '2' + ), + array( + 'c__id' => '1', + 'c__position' => '0', + 'c__name' => 'First', + 'b__id' => '3', + 'b__position' => '1', + //'b__category_id' => '1' + ), + array( + 'c__id' => '1', + 'c__position' => '0', + 'c__name' => 'First', + 'b__id' => '4', + 'b__position' => '2', + //'b__category_id' => '1' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[0])); + $this->assertTrue(is_array($result[1])); + $this->assertTrue(isset($result[0]['boards'])); + $this->assertEquals(3, count($result[0]['boards'])); + $this->assertTrue(isset($result[1]['boards'])); + $this->assertEquals(1, count($result[1]['boards'])); + } + + /** + * SELECT PARTIAL u.{id,status}, a.id, a.topic, c.id as cid, c.topic as ctopic + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * LEFT JOIN u.articles a + * LEFT JOIN a.comments c + * + * @dataProvider provideDataForUserEntityResult + */ + public function testChainedJoinWithScalars($entityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $entityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('a__id', 'id'); + $rsm->addScalarResult('a__topic', 'topic'); + $rsm->addScalarResult('c__id', 'cid'); + $rsm->addScalarResult('c__topic', 'ctopic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => '1', + 'a__topic' => 'The First', + 'c__id' => '1', + 'c__topic' => 'First Comment' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => '1', + 'a__topic' => 'The First', + 'c__id' => '2', + 'c__topic' => 'Second Comment' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => '42', + 'a__topic' => 'The Answer', + 'c__id' => null, + 'c__topic' => null + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(3, count($result)); + + $this->assertEquals(2, count($result[0][$entityKey])); // User array + $this->assertEquals(1, $result[0]['id']); + $this->assertEquals('The First', $result[0]['topic']); + $this->assertEquals(1, $result[0]['cid']); + $this->assertEquals('First Comment', $result[0]['ctopic']); + + $this->assertEquals(2, count($result[1][$entityKey])); // User array, duplicated + $this->assertEquals(1, $result[1]['id']); // duplicated + $this->assertEquals('The First', $result[1]['topic']); // duplicated + $this->assertEquals(2, $result[1]['cid']); + $this->assertEquals('Second Comment', $result[1]['ctopic']); + + $this->assertEquals(2, count($result[2][$entityKey])); // User array, duplicated + $this->assertEquals(42, $result[2]['id']); + $this->assertEquals('The Answer', $result[2]['topic']); + $this->assertNull($result[2]['cid']); + $this->assertNull($result[2]['ctopic']); + } + + /** + * SELECT PARTIAL u.{id, status} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + */ + public function testResultIteration() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $iterator = $hydrator->iterate($stmt, $rsm); + $rowNum = 0; + + while (($row = $iterator->next()) !== false) { + $this->assertEquals(1, count($row)); + $this->assertTrue(is_array($row[0])); + + if ($rowNum == 0) { + $this->assertEquals(1, $row[0]['id']); + $this->assertEquals('romanb', $row[0]['name']); + } else if ($rowNum == 1) { + $this->assertEquals(2, $row[0]['id']); + $this->assertEquals('jwage', $row[0]['name']); + } + + ++$rowNum; + } + } + + /** + * SELECT PARTIAL u.{id, status} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + */ + public function testResultIterationWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $iterator = $hydrator->iterate($stmt, $rsm); + $rowNum = 0; + + while (($row = $iterator->next()) !== false) { + $this->assertEquals(1, count($row)); + $this->assertArrayHasKey(0, $row); + $this->assertArrayHasKey('user', $row[0]); + + if ($rowNum == 0) { + $this->assertEquals(1, $row[0]['user']['id']); + $this->assertEquals('romanb', $row[0]['user']['name']); + } else if ($rowNum == 1) { + $this->assertEquals(2, $row[0]['user']['id']); + $this->assertEquals('jwage', $row[0]['user']['name']); + } + + ++$rowNum; + } + } + + /** + * SELECT PARTIAL u.{id, name} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @group DDC-644 + */ + public function testSkipUnknownColumns() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'foo' => 'bar', // unknown! + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(1, count($result)); + $this->assertArrayHasKey('id', $result[0]); + $this->assertArrayHasKey('name', $result[0]); + $this->assertArrayNotHasKey('foo', $result[0]); + } + + /** + * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @group DDC-1358 + * @dataProvider provideDataForUserEntityResult + */ + public function testMissingIdForRootEntity($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => null, + 'u__status' => null, + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + ), + array( + 'u__id' => null, + 'u__status' => null, + 'sclr0' => 'JWAGE', + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(4, count($result), "Should hydrate four results."); + + $this->assertEquals('ROMANB', $result[0]['nameUpper']); + $this->assertEquals('ROMANB', $result[1]['nameUpper']); + $this->assertEquals('JWAGE', $result[2]['nameUpper']); + $this->assertEquals('JWAGE', $result[3]['nameUpper']); + + $this->assertEquals(array('id' => 1, 'status' => 'developer'), $result[0][$userEntityKey]); + $this->assertNull($result[1][$userEntityKey]); + $this->assertEquals(array('id' => 2, 'status' => 'developer'), $result[2][$userEntityKey]); + $this->assertNull($result[3][$userEntityKey]); + } + + /** + * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * INDEX BY u.id + * + * @group DDC-1385 + * @dataProvider provideDataForUserEntityResult + */ + public function testIndexByAndMixedResult($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addIndexBy('u', 'id'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(isset($result[1])); + $this->assertEquals(1, $result[1][$userEntityKey]['id']); + + $this->assertTrue(isset($result[2])); + $this->assertEquals(2, $result[2][$userEntityKey]['id']); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php new file mode 100644 index 0000000..09be6bc --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php @@ -0,0 +1,29 @@ +_getTestEntityManager(); + $config = $em->getConfiguration(); + $config->addCustomHydrationMode('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator'); + + $hydrator = $em->newHydrator('CustomHydrator'); + $this->assertInstanceOf('Doctrine\Tests\ORM\Hydration\CustomHydrator', $hydrator); + $this->assertNull($config->getCustomHydrationMode('does not exist')); + } +} + +class CustomHydrator extends AbstractHydrator +{ + protected function hydrateAllData() + { + return $this->_stmt->fetchAll(PDO::FETCH_ASSOC); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php new file mode 100644 index 0000000..6602403 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php @@ -0,0 +1,30 @@ +_em = $this->_getTestEntityManager(); + } + + /** Helper method */ + protected function _createParserResult($resultSetMapping, $isMixedQuery = false) + { + $parserResult = new ParserResult; + $parserResult->setResultSetMapping($resultSetMapping); + //$parserResult->setDefaultQueryComponentAlias(key($queryComponents)); + //$parserResult->setTableAliasMap($tableToClassAliasMap); + $parserResult->setMixedQuery($isMixedQuery); + return $parserResult; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php new file mode 100644 index 0000000..b6bc7cd --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -0,0 +1,1866 @@ +addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]); + + $this->assertEquals(1, $result[0]->id); + $this->assertEquals('romanb', $result[0]->name); + + $this->assertEquals(2, $result[1]->id); + $this->assertEquals('jwage', $result[1]->name); + } + + /** + * SELECT PARTIAL u.{id,name} AS user + * FROM Doctrine\Tests\Models\CMS\CmsUser u + */ + public function testSimpleEntityQueryWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertArrayHasKey('user', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); + + $this->assertArrayHasKey('user', $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['user']); + + $this->assertEquals(1, $result[0]['user']->id); + $this->assertEquals('romanb', $result[0]['user']->name); + + $this->assertEquals(2, $result[1]['user']->id); + $this->assertEquals('jwage', $result[1]['user']->name); + } + + /** + * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQuery() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(4, count($result)); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]); + + $this->assertEquals(1, $result[0]->id); + $this->assertEquals('romanb', $result[0]->name); + + $this->assertEquals(1, $result[1]->id); + $this->assertEquals('Cool things.', $result[1]->topic); + + $this->assertEquals(2, $result[2]->id); + $this->assertEquals('jwage', $result[2]->name); + + $this->assertEquals(2, $result[3]->id); + $this->assertEquals('Cool things II.', $result[3]->topic); + } + + /** + * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQueryWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(4, count($result)); + + $this->assertArrayHasKey('user', $result[0]); + $this->assertArrayNotHasKey(0, $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); + $this->assertEquals(1, $result[0]['user']->id); + $this->assertEquals('romanb', $result[0]['user']->name); + + $this->assertArrayHasKey(0, $result[1]); + $this->assertArrayNotHasKey('user', $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]); + $this->assertEquals(1, $result[1][0]->id); + $this->assertEquals('Cool things.', $result[1][0]->topic); + + $this->assertArrayHasKey('user', $result[2]); + $this->assertArrayNotHasKey(0, $result[2]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]['user']); + $this->assertEquals(2, $result[2]['user']->id); + $this->assertEquals('jwage', $result[2]['user']->name); + + $this->assertArrayHasKey(0, $result[3]); + $this->assertArrayNotHasKey('user', $result[3]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3][0]); + $this->assertEquals(2, $result[3][0]->id); + $this->assertEquals('Cool things II.', $result[3][0]->topic); + } + + /** + * SELECT PARTIAL u.{id, name}, PARTIAL a.{id, topic} AS article + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQueryWithAliasedArticleEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(4, count($result)); + + $this->assertArrayHasKey(0, $result[0]); + $this->assertArrayNotHasKey('article', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); + $this->assertEquals(1, $result[0][0]->id); + $this->assertEquals('romanb', $result[0][0]->name); + + $this->assertArrayHasKey('article', $result[1]); + $this->assertArrayNotHasKey(0, $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]['article']); + $this->assertEquals(1, $result[1]['article']->id); + $this->assertEquals('Cool things.', $result[1]['article']->topic); + + $this->assertArrayHasKey(0, $result[2]); + $this->assertArrayNotHasKey('article', $result[2]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][0]); + $this->assertEquals(2, $result[2][0]->id); + $this->assertEquals('jwage', $result[2][0]->name); + + $this->assertArrayHasKey('article', $result[3]); + $this->assertArrayNotHasKey(0, $result[3]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]['article']); + $this->assertEquals(2, $result[3]['article']->id); + $this->assertEquals('Cool things II.', $result[3]['article']->topic); + } + + /** + * SELECT PARTIAL u.{id, name} AS user, PARTIAL a.{id, topic} AS article + * FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a + */ + public function testSimpleMultipleRootEntityQueryWithAliasedEntities() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsArticle', 'a', 'article'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'a__id' => '1', + 'a__topic' => 'Cool things.' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'a__id' => '2', + 'a__topic' => 'Cool things II.' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(4, count($result)); + + $this->assertArrayHasKey('user', $result[0]); + $this->assertArrayNotHasKey('article', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); + $this->assertEquals(1, $result[0]['user']->id); + $this->assertEquals('romanb', $result[0]['user']->name); + + $this->assertArrayHasKey('article', $result[1]); + $this->assertArrayNotHasKey('user', $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]['article']); + $this->assertEquals(1, $result[1]['article']->id); + $this->assertEquals('Cool things.', $result[1]['article']->topic); + + $this->assertArrayHasKey('user', $result[2]); + $this->assertArrayNotHasKey('article', $result[2]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]['user']); + $this->assertEquals(2, $result[2]['user']->id); + $this->assertEquals('jwage', $result[2]['user']->name); + + $this->assertArrayHasKey('article', $result[3]); + $this->assertArrayNotHasKey('user', $result[3]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]['article']); + $this->assertEquals(2, $result[3]['article']->id); + $this->assertEquals('Cool things II.', $result[3]['article']->topic); + } + + /** + * SELECT PARTIAL u.{id, status}, COUNT(p.phonenumber) numPhones + * FROM User u + * JOIN u.phonenumbers p + * GROUP BY u.id + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryNormalJoin($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'numPhones'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => '2', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => '1', + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInternalType('array', $result); + $this->assertInternalType('array', $result[0]); + $this->assertInternalType('array', $result[1]); + + // first user => 2 phonenumbers + $this->assertEquals(2, $result[0]['numPhones']); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); + + // second user => 1 phonenumber + $this->assertEquals(1, $result[1]['numPhones']); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); + } + + /** + * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * JOIN u.phonenumbers p + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryFetchJoin($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'p__phonenumber' => '42', + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'p__phonenumber' => '43', + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'p__phonenumber' => '91', + 'sclr0' => 'JWAGE', + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInternalType('array', $result); + $this->assertInternalType('array', $result[0]); + $this->assertInternalType('array', $result[1]); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[0]); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[1]); + + // first user => 2 phonenumbers + $this->assertEquals(2, count($result[0][$userEntityKey]->phonenumbers)); + $this->assertEquals('ROMANB', $result[0]['nameUpper']); + + // second user => 1 phonenumber + $this->assertEquals(1, count($result[1][$userEntityKey]->phonenumbers)); + $this->assertEquals('JWAGE', $result[1]['nameUpper']); + + $this->assertEquals(42, $result[0][$userEntityKey]->phonenumbers[0]->phonenumber); + $this->assertEquals(43, $result[0][$userEntityKey]->phonenumbers[1]->phonenumber); + $this->assertEquals(91, $result[1][$userEntityKey]->phonenumbers[0]->phonenumber); + } + + /** + * SELECT u, p, UPPER(u.name) nameUpper + * FROM User u + * INDEX BY u.id + * JOIN u.phonenumbers p + * INDEX BY p.phonenumber + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryFetchJoinCustomIndex($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addIndexBy('u', 'id'); + $rsm->addIndexBy('p', 'phonenumber'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91' + ) + ); + + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInternalType('array', $result); + $this->assertInternalType('array', $result[1]); + $this->assertInternalType('array', $result[2]); + + // test the scalar values + $this->assertEquals('ROMANB', $result[1]['nameUpper']); + $this->assertEquals('JWAGE', $result[2]['nameUpper']); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][$userEntityKey]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); + + // first user => 2 phonenumbers. notice the custom indexing by user id + $this->assertEquals(2, count($result[1][$userEntityKey]->phonenumbers)); + + // second user => 1 phonenumber. notice the custom indexing by user id + $this->assertEquals(1, count($result[2][$userEntityKey]->phonenumbers)); + + // test the custom indexing of the phonenumbers + $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['42'])); + $this->assertTrue(isset($result[1][$userEntityKey]->phonenumbers['43'])); + $this->assertTrue(isset($result[2][$userEntityKey]->phonenumbers['91'])); + } + + /** + * SELECT u, p, UPPER(u.name) nameUpper, a + * FROM User u + * JOIN u.phonenumbers p + * JOIN u.articles a + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryMultipleFetchJoin($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsArticle', + 'a', + 'u', + 'articles' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '1', + 'a__topic' => 'Getting things done!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '1', + 'a__topic' => 'Getting things done!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '2', + 'a__topic' => 'ZendCon' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '2', + 'a__topic' => 'ZendCon' + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '3', + 'a__topic' => 'LINQ' + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '4', + 'a__topic' => 'PHP6' + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[0])); + $this->assertTrue(is_array($result[1])); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[1]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[1]); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][$userEntityKey]->phonenumbers[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[1]); + } + + /** + * SELECT u, p, UPPER(u.name) nameUpper, a, c + * FROM User u + * JOIN u.phonenumbers p + * JOIN u.articles a + * LEFT JOIN a.comments c + * + * @dataProvider provideDataForUserEntityResult + */ + public function testMixedQueryMultipleDeepMixedFetchJoin($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsArticle', + 'a', + 'u', + 'articles' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsComment', + 'c', + 'a', + 'comments' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + $rsm->addFieldResult('c', 'c__id', 'id'); + $rsm->addFieldResult('c', 'c__topic', 'topic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '1', + 'a__topic' => 'Getting things done!', + 'c__id' => '1', + 'c__topic' => 'First!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '1', + 'a__topic' => 'Getting things done!', + 'c__id' => '1', + 'c__topic' => 'First!' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '2', + 'a__topic' => 'ZendCon', + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + 'a__id' => '2', + 'a__topic' => 'ZendCon', + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '3', + 'a__topic' => 'LINQ', + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91', + 'a__id' => '4', + 'a__topic' => 'PHP6', + 'c__id' => null, + 'c__topic' => null + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(is_array($result)); + $this->assertTrue(is_array($result[0])); + $this->assertTrue(is_array($result[1])); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][$userEntityKey]); + + // phonenumbers + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][$userEntityKey]->phonenumbers[1]); + + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][$userEntityKey]->phonenumbers[0]); + + // articles + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][$userEntityKey]->articles[1]); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][$userEntityKey]->articles[1]); + + // article comments + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles[0]->comments); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsComment', $result[0][$userEntityKey]->articles[0]->comments[0]); + + // empty comment collections + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][$userEntityKey]->articles[1]->comments); + $this->assertEquals(0, count($result[0][$userEntityKey]->articles[1]->comments)); + + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->articles[0]->comments); + $this->assertEquals(0, count($result[1][$userEntityKey]->articles[0]->comments)); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][$userEntityKey]->articles[1]->comments); + $this->assertEquals(0, count($result[1][$userEntityKey]->articles[1]->comments)); + } + + /** + * Tests that the hydrator does not rely on a particular order of the rows + * in the result set. + * + * DQL: + * select c, b from Doctrine\Tests\Models\Forum\ForumCategory c inner join c.boards b + * order by c.position asc, b.position asc + * + * Checks whether the boards are correctly assigned to the categories. + * + * The 'evil' result set that confuses the object population is displayed below. + * + * c.id | c.position | c.name | boardPos | b.id | b.category_id (just for clarity) + * 1 | 0 | First | 0 | 1 | 1 + * 2 | 0 | Second | 0 | 2 | 2 <-- + * 1 | 0 | First | 1 | 3 | 1 + * 1 | 0 | First | 2 | 4 | 1 + */ + public function testEntityQueryCustomResultSetOrder() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\Forum\ForumCategory', 'c'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\Forum\ForumBoard', + 'b', + 'c', + 'boards' + ); + $rsm->addFieldResult('c', 'c__id', 'id'); + $rsm->addFieldResult('c', 'c__position', 'position'); + $rsm->addFieldResult('c', 'c__name', 'name'); + $rsm->addFieldResult('b', 'b__id', 'id'); + $rsm->addFieldResult('b', 'b__position', 'position'); + + // Faked result set + $resultSet = array( + array( + 'c__id' => '1', + 'c__position' => '0', + 'c__name' => 'First', + 'b__id' => '1', + 'b__position' => '0', + //'b__category_id' => '1' + ), + array( + 'c__id' => '2', + 'c__position' => '0', + 'c__name' => 'Second', + 'b__id' => '2', + 'b__position' => '0', + //'b__category_id' => '2' + ), + array( + 'c__id' => '1', + 'c__position' => '0', + 'c__name' => 'First', + 'b__id' => '3', + 'b__position' => '1', + //'b__category_id' => '1' + ), + array( + 'c__id' => '1', + 'c__position' => '0', + 'c__name' => 'First', + 'b__id' => '4', + 'b__position' => '2', + //'b__category_id' => '1' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[1]); + + $this->assertTrue($result[0] !== $result[1]); + + $this->assertEquals(1, $result[0]->getId()); + $this->assertEquals(2, $result[1]->getId()); + + $this->assertTrue(isset($result[0]->boards)); + $this->assertEquals(3, count($result[0]->boards)); + + $this->assertTrue(isset($result[1]->boards)); + $this->assertEquals(1, count($result[1]->boards)); + } + + /** + * SELECT PARTIAL u.{id,name} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @group DDC-644 + */ + public function testSkipUnknownColumns() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'foo' => 'bar', // unknown! + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(1, count($result)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + } + + /** + * SELECT u.id, u.name + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @dataProvider provideDataForUserEntityResult + */ + public function testScalarQueryWithoutResultVariables($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addScalarResult('sclr0', 'id'); + $rsm->addScalarResult('sclr1', 'name'); + + // Faked result set + $resultSet = array( + array( + 'sclr0' => '1', + 'sclr1' => 'romanb' + ), + array( + 'sclr0' => '2', + 'sclr1' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInternalType('array', $result[0]); + $this->assertInternalType('array', $result[1]); + + $this->assertEquals(1, $result[0]['id']); + $this->assertEquals('romanb', $result[0]['name']); + + $this->assertEquals(2, $result[1]['id']); + $this->assertEquals('jwage', $result[1]['name']); + } + + /** + * SELECT p + * FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p + */ + public function testCreatesProxyForLazyLoadingWithForeignKeys() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p'); + $rsm->addFieldResult('p', 'p__id', 'id'); + $rsm->addFieldResult('p', 'p__name', 'name'); + $rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id'); + + // Faked result set + $resultSet = array( + array( + 'p__id' => '1', + 'p__name' => 'Doctrine Book', + 'p__shipping_id' => 42 + ) + ); + + $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->expects($this->once()) + ->method('getProxy') + ->with($this->equalTo('Doctrine\Tests\Models\ECommerce\ECommerceShipping'), array('id' => 42)) + ->will($this->returnValue($proxyInstance)); + + $this->_em->setProxyFactory($proxyFactory); + + // configuring lazy loading + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); + $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(1, count($result)); + + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $result[0]); + } + + /** + * SELECT p AS product + * FROM Doctrine\Tests\Models\ECommerce\ECommerceProduct p + */ + public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\ECommerce\ECommerceProduct', 'p', 'product'); + $rsm->addFieldResult('p', 'p__id', 'id'); + $rsm->addFieldResult('p', 'p__name', 'name'); + $rsm->addMetaResult('p', 'p__shipping_id', 'shipping_id'); + + // Faked result set + $resultSet = array( + array( + 'p__id' => '1', + 'p__name' => 'Doctrine Book', + 'p__shipping_id' => 42 + ) + ); + + $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->expects($this->once()) + ->method('getProxy') + ->with($this->equalTo('Doctrine\Tests\Models\ECommerce\ECommerceShipping'), array('id' => 42)) + ->will($this->returnValue($proxyInstance)); + + $this->_em->setProxyFactory($proxyFactory); + + // configuring lazy loading + $metadata = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); + $metadata->associationMappings['shipping']['fetch'] = ClassMetadata::FETCH_LAZY; + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertEquals(1, count($result)); + + $this->assertInternalType('array', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $result[0]['product']); + } + + /** + * SELECT PARTIAL u.{id, status}, PARTIAL a.{id, topic}, PARTIAL c.{id, topic} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * LEFT JOIN u.articles a + * LEFT JOIN a.comments c + */ + public function testChainedJoinWithEmptyCollections() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsArticle', + 'a', + 'u', + 'articles' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsComment', + 'c', + 'a', + 'comments' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + $rsm->addFieldResult('c', 'c__id', 'id'); + $rsm->addFieldResult('c', 'c__topic', 'topic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => null, + 'a__topic' => null, + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'a__id' => null, + 'a__topic' => null, + 'c__id' => null, + 'c__topic' => null + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]); + + $this->assertEquals(0, $result[0]->articles->count()); + $this->assertEquals(0, $result[1]->articles->count()); + } + + /** + * SELECT PARTIAL u.{id, status} AS user, PARTIAL a.{id, topic}, PARTIAL c.{id, topic} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * LEFT JOIN u.articles a + * LEFT JOIN a.comments c + */ + public function testChainedJoinWithEmptyCollectionsWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsArticle', + 'a', + 'u', + 'articles' + ); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsComment', + 'c', + 'a', + 'comments' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__topic', 'topic'); + $rsm->addFieldResult('c', 'c__id', 'id'); + $rsm->addFieldResult('c', 'c__topic', 'topic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => null, + 'a__topic' => null, + 'c__id' => null, + 'c__topic' => null + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'a__id' => null, + 'a__topic' => null, + 'c__id' => null, + 'c__topic' => null + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInternalType('array', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); + + $this->assertInternalType('array', $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['user']); + + $this->assertEquals(0, $result[0]['user']->articles->count()); + $this->assertEquals(0, $result[1]['user']->articles->count()); + } + + /** + * SELECT PARTIAL u.{id,status}, a.id, a.topic, c.id as cid, c.topic as ctopic + * FROM CmsUser u + * LEFT JOIN u.articles a + * LEFT JOIN a.comments c + * + * @group bubu + * @dataProvider provideDataForUserEntityResult + */ + /*public function testChainedJoinWithScalars($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('a__id', 'id'); + $rsm->addScalarResult('a__topic', 'topic'); + $rsm->addScalarResult('c__id', 'cid'); + $rsm->addScalarResult('c__topic', 'ctopic'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => '1', + 'a__topic' => 'The First', + 'c__id' => '1', + 'c__topic' => 'First Comment' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => '1', + 'a__topic' => 'The First', + 'c__id' => '2', + 'c__topic' => 'Second Comment' + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'a__id' => '42', + 'a__topic' => 'The Answer', + 'c__id' => null, + 'c__topic' => null + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + \Doctrine\Common\Util\Debug::dump($result, 3); + + $this->assertEquals(1, count($result)); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); // User object + $this->assertEquals(42, $result[0]['id']); + $this->assertEquals('The First', $result[0]['topic']); + $this->assertEquals(1, $result[0]['cid']); + $this->assertEquals('First Comment', $result[0]['ctopic']); + }*/ + + /** + * SELECT PARTIAL u.{id, name} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + */ + public function testResultIteration() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $iterableResult = $hydrator->iterate($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + $rowNum = 0; + + while (($row = $iterableResult->next()) !== false) { + $this->assertEquals(1, count($row)); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $row[0]); + + if ($rowNum == 0) { + $this->assertEquals(1, $row[0]->id); + $this->assertEquals('romanb', $row[0]->name); + } else if ($rowNum == 1) { + $this->assertEquals(2, $row[0]->id); + $this->assertEquals('jwage', $row[0]->name); + } + + ++$rowNum; + } + } + + /** + * SELECT PARTIAL u.{id, name} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + */ + public function testResultIterationWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $iterableResult = $hydrator->iterate($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + $rowNum = 0; + + while (($row = $iterableResult->next()) !== false) { + $this->assertEquals(1, count($row)); + $this->assertArrayHasKey(0, $row); + $this->assertArrayHasKey('user', $row[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $row[0]['user']); + + if ($rowNum == 0) { + $this->assertEquals(1, $row[0]['user']->id); + $this->assertEquals('romanb', $row[0]['user']->name); + } else if ($rowNum == 1) { + $this->assertEquals(2, $row[0]['user']->id); + $this->assertEquals('jwage', $row[0]['user']->name); + } + + ++$rowNum; + } + } + + /** + * Checks if multiple joined multiple-valued collections is hydrated correctly. + * + * SELECT PARTIAL u.{id, status}, PARTIAL g.{id, name}, PARTIAL p.{phonenumber} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @group DDC-809 + */ + public function testManyToManyHydration() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsGroup', 'g', 'u', 'groups'); + $rsm->addFieldResult('g', 'g__id', 'id'); + $rsm->addFieldResult('g', 'g__name', 'name'); + $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 1111, + ), + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 1111, + ), + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 2222, + ), + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 2222, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '2', + 'g__name' => 'TestGroupA', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '4', + 'g__name' => 'TestGroupC', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '2', + 'g__name' => 'TestGroupA', + 'p__phonenumber' => 4444, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 4444, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '4', + 'g__name' => 'TestGroupC', + 'p__phonenumber' => 4444, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 4444, + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $result); + + $this->assertEquals(2, count($result[0]->groups)); + $this->assertEquals(2, count($result[0]->phonenumbers)); + + $this->assertEquals(4, count($result[1]->groups)); + $this->assertEquals(2, count($result[1]->phonenumbers)); + } + + /** + * Checks if multiple joined multiple-valued collections is hydrated correctly. + * + * SELECT PARTIAL u.{id, status} As user, PARTIAL g.{id, name}, PARTIAL p.{phonenumber} + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @group DDC-809 + */ + public function testManyToManyHydrationWithAliasedUserEntity() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', 'user'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsGroup', 'g', 'u', 'groups'); + $rsm->addFieldResult('g', 'g__id', 'id'); + $rsm->addFieldResult('g', 'g__name', 'name'); + $rsm->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p', 'u', 'phonenumbers'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 1111, + ), + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 1111, + ), + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 2222, + ), + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 2222, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '2', + 'g__name' => 'TestGroupA', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '4', + 'g__name' => 'TestGroupC', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 3333, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '2', + 'g__name' => 'TestGroupA', + 'p__phonenumber' => 4444, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '3', + 'g__name' => 'TestGroupB', + 'p__phonenumber' => 4444, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '4', + 'g__name' => 'TestGroupC', + 'p__phonenumber' => 4444, + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage', + 'g__id' => '5', + 'g__name' => 'TestGroupD', + 'p__phonenumber' => 4444, + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInternalType('array', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['user']); + $this->assertInternalType('array', $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['user']); + + $this->assertEquals(2, count($result[0]['user']->groups)); + $this->assertEquals(2, count($result[0]['user']->phonenumbers)); + + $this->assertEquals(4, count($result[1]['user']->groups)); + $this->assertEquals(2, count($result[1]['user']->phonenumbers)); + } + + /** + * SELECT PARTIAL u.{id, status}, UPPER(u.name) as nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @group DDC-1358 + * @dataProvider provideDataForUserEntityResult + */ + public function testMissingIdForRootEntity($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => null, + 'u__status' => null, + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + ), + array( + 'u__id' => null, + 'u__status' => null, + 'sclr0' => 'JWAGE', + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(4, count($result), "Should hydrate four results."); + + $this->assertEquals('ROMANB', $result[0]['nameUpper']); + $this->assertEquals('ROMANB', $result[1]['nameUpper']); + $this->assertEquals('JWAGE', $result[2]['nameUpper']); + $this->assertEquals('JWAGE', $result[3]['nameUpper']); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][$userEntityKey]); + $this->assertNull($result[1][$userEntityKey]); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][$userEntityKey]); + $this->assertNull($result[3][$userEntityKey]); + } + + /** + * SELECT PARTIAL u.{id, status}, PARTIAL p.{phonenumber}, UPPER(u.name) AS nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * LEFT JOIN u.phonenumbers u + * + * @group DDC-1358 + * @dataProvider provideDataForUserEntityResult + */ + public function testMissingIdForCollectionValuedChildEntity($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => null + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91' + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => null + ) + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertEquals(1, $result[0][$userEntityKey]->phonenumbers->count()); + $this->assertEquals(1, $result[1][$userEntityKey]->phonenumbers->count()); + } + + /** + * SELECT PARTIAL u.{id, status}, PARTIAL a.{id, city}, UPPER(u.name) AS nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * JOIN u.address a + * + * @group DDC-1358 + * @dataProvider provideDataForUserEntityResult + */ + public function testMissingIdForSingleValuedChildEntity($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsAddress', + 'a', + 'u', + 'address' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('a', 'a__id', 'id'); + $rsm->addFieldResult('a', 'a__city', 'city'); + $rsm->addMetaResult('a', 'user_id', 'user_id'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + 'a__id' => 1, + 'a__city' => 'Berlin', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'BENJAMIN', + 'a__id' => null, + 'a__city' => null, + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $result[0][$userEntityKey]->address); + $this->assertNull($result[1][$userEntityKey]->address); + } + + /** + * SELECT PARTIAL u.{id, status}, UPPER(u.name) AS nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * INDEX BY u.id + * + * @group DDC-1385 + * @dataProvider provideDataForUserEntityResult + */ + public function testIndexByAndMixedResult($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addIndexBy('u', 'id'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'sclr0' => 'ROMANB', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'sclr0' => 'JWAGE', + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals(2, count($result)); + + $this->assertTrue(isset($result[1])); + $this->assertEquals(1, $result[1][$userEntityKey]->id); + + $this->assertTrue(isset($result[2])); + $this->assertEquals(2, $result[2][$userEntityKey]->id); + } + + /** + * SELECT UPPER(u.name) AS nameUpper + * FROM Doctrine\Tests\Models\CMS\CmsUser u + * + * @group DDC-1385 + * @dataProvider provideDataForUserEntityResult + */ + public function testIndexByScalarsOnly($userEntityKey) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u', $userEntityKey ?: null); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addIndexByScalar('sclr0'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'sclr0' => 'ROMANB', + ), + array( + 'sclr0' => 'JWAGE', + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + + $this->assertEquals( + array( + 'ROMANB' => array('nameUpper' => 'ROMANB'), + 'JWAGE' => array('nameUpper' => 'JWAGE') + ), + $result + ); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php new file mode 100644 index 0000000..785c19b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ResultSetMappingTest.php @@ -0,0 +1,97 @@ +_rsm = new ResultSetMapping; + $this->_em = $this->_getTestEntityManager(); + } + + /** + * For SQL: SELECT id, status, username, name FROM cms_users + */ + public function testBasicResultSetMapping() + { + $this->_rsm->addEntityResult( + 'Doctrine\Tests\Models\CMS\CmsUser', + 'u' + ); + $this->_rsm->addFieldResult('u', 'id', 'id'); + $this->_rsm->addFieldResult('u', 'status', 'status'); + $this->_rsm->addFieldResult('u', 'username', 'username'); + $this->_rsm->addFieldResult('u', 'name', 'name'); + + $this->assertFalse($this->_rsm->isScalarResult('id')); + $this->assertFalse($this->_rsm->isScalarResult('status')); + $this->assertFalse($this->_rsm->isScalarResult('username')); + $this->assertFalse($this->_rsm->isScalarResult('name')); + + $this->assertTrue($this->_rsm->getClassName('u') == 'Doctrine\Tests\Models\CMS\CmsUser'); + $class = $this->_rsm->getDeclaringClass('id'); + $this->assertTrue($class == 'Doctrine\Tests\Models\CMS\CmsUser'); + + $this->assertEquals('u', $this->_rsm->getEntityAlias('id')); + $this->assertEquals('u', $this->_rsm->getEntityAlias('status')); + $this->assertEquals('u', $this->_rsm->getEntityAlias('username')); + $this->assertEquals('u', $this->_rsm->getEntityAlias('name')); + + $this->assertEquals('id', $this->_rsm->getFieldName('id')); + $this->assertEquals('status', $this->_rsm->getFieldName('status')); + $this->assertEquals('username', $this->_rsm->getFieldName('username')); + $this->assertEquals('name', $this->_rsm->getFieldName('name')); + } + + /** + * @group DDC-1057 + * + * Fluent interface test, not a real result set mapping + */ + public function testFluentInterface() + { + $rms = $this->_rsm; + + $rms->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser','u') + ->addJoinedEntityResult('Doctrine\Tests\Models\CMS\CmsPhonenumber','p','u','phonenumbers') + ->addFieldResult('u', 'id', 'id') + ->addFieldResult('u', 'name', 'name') + ->setDiscriminatorColumn('name', 'name') + ->addIndexByColumn('id', 'id') + ->addIndexBy('username', 'username') + ->addIndexByScalar('sclr0') + ->addScalarResult('sclr0', 'numPhones') + ->addMetaResult('a', 'user_id', 'user_id'); + + + $this->assertTrue($rms->hasIndexBy('id')); + $this->assertTrue($rms->isFieldResult('id')); + $this->assertTrue($rms->isFieldResult('name')); + $this->assertTrue($rms->isScalarResult('sclr0')); + $this->assertTrue($rms->isRelation('p')); + $this->assertTrue($rms->hasParentAlias('p')); + $this->assertTrue($rms->isMixedResult()); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php new file mode 100644 index 0000000..c8c376f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php @@ -0,0 +1,101 @@ +addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ), + array( + 'u__id' => '2', + 'u__name' => 'jwage' + ) + ); + + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); + + $result = $hydrator->hydrateAll($stmt, $rsm); + + $this->assertTrue(is_array($result)); + $this->assertEquals(2, count($result)); + $this->assertEquals('romanb', $result[0]['u_name']); + $this->assertEquals(1, $result[0]['u_id']); + $this->assertEquals('jwage', $result[1]['u_name']); + $this->assertEquals(2, $result[1]['u_id']); + } + + /** + * @group DDC-407 + */ + public function testHydrateScalarResults() + { + $rsm = new ResultSetMapping(); + $rsm->addScalarResult('foo1', 'foo'); + $rsm->addScalarResult('bar2', 'bar'); + $rsm->addScalarResult('baz3', 'baz'); + + $resultSet = array( + array( + 'foo1' => 'A', + 'bar2' => 'B', + 'baz3' => 'C', + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); + + $result = $hydrator->hydrateAll($stmt, $rsm); + } + + /** + * @group DDC-644 + */ + public function testSkipUnknownColumns() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addScalarResult('foo1', 'foo'); + $rsm->addScalarResult('bar2', 'bar'); + $rsm->addScalarResult('baz3', 'baz'); + + $resultSet = array( + array( + 'u__id' => '1', + 'u__name' => 'romanb', + 'foo1' => 'A', + 'bar2' => 'B', + 'baz3' => 'C', + 'foo' => 'bar', // Unknown! + ), + ); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); + + $result = $hydrator->hydrateAll($stmt, $rsm); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php new file mode 100644 index 0000000..f6abe24 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php @@ -0,0 +1,78 @@ + 'result1', + 'resultSet' => array( + array( + 'u__name' => 'romanb' + ) + )), + // valid + array('name' => 'result2', + 'resultSet' => array( + array( + 'u__id' => '1' + ) + )), + // invalid + array('name' => 'result3', + 'resultSet' => array( + array( + 'u__id' => '1', + 'u__name' => 'romanb' + ) + )), + // invalid + array('name' => 'result4', + 'resultSet' => array( + array( + 'u__id' => '1' + ), + array( + 'u__id' => '2' + ) + )), + ); + } + + /** + * select u.name from CmsUser u where u.id = 1 + * + * @dataProvider singleScalarResultSetProvider + */ + public function testHydrateSingleScalar($name, $resultSet) + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\SingleScalarHydrator($this->_em); + + if ($name == 'result1') { + $result = $hydrator->hydrateAll($stmt, $rsm); + $this->assertEquals('romanb', $result); + } else if ($name == 'result2') { + $result = $hydrator->hydrateAll($stmt, $rsm); + $this->assertEquals(1, $result); + } else if ($name == 'result3' || $name == 'result4') { + try { + $result = $hydrator->hydrateAll($stmt, $rsm); + $this->fail(); + } catch (\Doctrine\ORM\NonUniqueResultException $e) {} + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php new file mode 100644 index 0000000..3a009e5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/AssignedGeneratorTest.php @@ -0,0 +1,67 @@ +_em = $this->_getTestEntityManager(); + $this->_assignedGen = new AssignedGenerator; + } + + public function testThrowsExceptionIfIdNotAssigned() + { + try { + $entity = new AssignedSingleIdEntity; + $this->_assignedGen->generate($this->_em, $entity); + $this->fail('Assigned generator did not throw exception even though ID was missing.'); + } catch (\Doctrine\ORM\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) {} + } + + public function testCorrectIdGeneration() + { + $entity = new AssignedSingleIdEntity; + $entity->myId = 1; + $id = $this->_assignedGen->generate($this->_em, $entity); + $this->assertEquals(array('myId' => 1), $id); + + $entity = new AssignedCompositeIdEntity; + $entity->myId2 = 2; + $entity->myId1 = 4; + $id = $this->_assignedGen->generate($this->_em, $entity); + $this->assertEquals(array('myId1' => 4, 'myId2' => 2), $id); + } +} + +/** @Entity */ +class AssignedSingleIdEntity { + /** @Id @Column(type="integer") */ + public $myId; +} + +/** @Entity */ +class AssignedCompositeIdEntity { + /** @Id @Column(type="integer") */ + public $myId1; + /** @Id @Column(type="integer") */ + public $myId2; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php new file mode 100644 index 0000000..6e50d5a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php @@ -0,0 +1,40 @@ +_em = $this->_getTestEntityManager(); + $this->_seqGen = new SequenceGenerator('seq', 10); + } + + public function testGeneration() + { + for ($i=0; $i < 42; ++$i) { + if ($i % 10 == 0) { + $this->_em->getConnection()->setFetchOneResult((int)($i / 10) * 10); + } + $id = $this->_seqGen->generate($this->_em, null); + $this->assertEquals($i, $id); + $this->assertEquals((int)($i / 10) * 10 + 10, $this->_seqGen->getCurrentMaxValue()); + $this->assertEquals($i + 1, $this->_seqGen->getNextValue()); + } + + + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php new file mode 100644 index 0000000..6d14c2a --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -0,0 +1,685 @@ +_loadDriver(); + + $class = new ClassMetadata($entityClassName); + $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $mappingDriver->loadMetadataForClass($entityClassName, $class); + + return $class; + } + + public function testLoadMapping() + { + $entityClassName = 'Doctrine\Tests\ORM\Mapping\User'; + return $this->createClassMetadata($entityClassName); + } + + /** + * @depends testLoadMapping + * @param ClassMetadata $class + */ + public function testEntityTableNameAndInheritance($class) + { + $this->assertEquals('cms_users', $class->getTableName()); + $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType); + + return $class; + } + + /** + * @depends testEntityTableNameAndInheritance + * @param ClassMetadata $class + */ + public function testEntityIndexes($class) + { + $this->assertArrayHasKey('indexes', $class->table, 'ClassMetadata should have indexes key in table property.'); + $this->assertEquals(array( + 'name_idx' => array('columns' => array('name')), + 0 => array('columns' => array('user_email')) + ), $class->table['indexes']); + + return $class; + } + + /** + * @depends testEntityTableNameAndInheritance + * @param ClassMetadata $class + */ + public function testEntityUniqueConstraints($class) + { + $this->assertArrayHasKey('uniqueConstraints', $class->table, + 'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.'); + + $this->assertEquals(array( + "search_idx" => array("columns" => array("name", "user_email")) + ), $class->table['uniqueConstraints']); + + return $class; + } + + /** + * @depends testEntityTableNameAndInheritance + * @param ClassMetadata $class + */ + public function testEntitySequence($class) + { + $this->assertInternalType('array', $class->sequenceGeneratorDefinition, 'No Sequence Definition set on this driver.'); + $this->assertEquals( + array( + 'sequenceName' => 'tablename_seq', + 'allocationSize' => 100, + 'initialValue' => 1, + ), + $class->sequenceGeneratorDefinition + ); + } + + + /** + * @depends testEntityTableNameAndInheritance + * @param ClassMetadata $class + */ + public function testFieldMappings($class) + { + $this->assertEquals(3, count($class->fieldMappings)); + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['name'])); + $this->assertTrue(isset($class->fieldMappings['email'])); + + return $class; + } + + /** + * @depends testEntityTableNameAndInheritance + * @param ClassMetadata $class + */ + public function testFieldMappingsColumnNames($class) + { + $this->assertEquals("id", $class->fieldMappings['id']['columnName']); + $this->assertEquals("name", $class->fieldMappings['name']['columnName']); + $this->assertEquals("user_email", $class->fieldMappings['email']['columnName']); + + return $class; + } + + /** + * @depends testEntityTableNameAndInheritance + * @param ClassMetadata $class + */ + public function testStringFieldMappings($class) + { + $this->assertEquals('string', $class->fieldMappings['name']['type']); + $this->assertEquals(50, $class->fieldMappings['name']['length']); + $this->assertTrue($class->fieldMappings['name']['nullable']); + $this->assertTrue($class->fieldMappings['name']['unique']); + + return $class; + } + + /** + * @depends testFieldMappings + * @param ClassMetadata $class + */ + public function testIdentifier($class) + { + $this->assertEquals(array('id'), $class->identifier); + $this->assertEquals('integer', $class->fieldMappings['id']['type']); + $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, "ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO"); + + return $class; + } + + /** + * @depends testIdentifier + * @param ClassMetadata $class + */ + public function testAssocations($class) + { + $this->assertEquals(3, count($class->associationMappings)); + + return $class; + } + + /** + * @depends testAssocations + * @param ClassMetadata $class + */ + public function testOwningOneToOneAssocation($class) + { + $this->assertTrue(isset($class->associationMappings['address'])); + $this->assertTrue($class->associationMappings['address']['isOwningSide']); + $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); + // Check cascading + $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); + $this->assertFalse($class->associationMappings['address']['isCascadePersist']); + $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); + $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); + $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); + + return $class; + } + + /** + * @depends testOwningOneToOneAssocation + * @param ClassMetadata $class + */ + public function testInverseOneToManyAssociation($class) + { + $this->assertTrue(isset($class->associationMappings['phonenumbers'])); + $this->assertFalse($class->associationMappings['phonenumbers']['isOwningSide']); + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']); + $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + + // Test Order By + $this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']); + + return $class; + } + + /** + * @depends testInverseOneToManyAssociation + * @param ClassMetadata $class + */ + public function testManyToManyAssociationWithCascadeAll($class) + { + $this->assertTrue(isset($class->associationMappings['groups'])); + $this->assertTrue($class->associationMappings['groups']['isOwningSide']); + // Make sure that cascade-all works as expected + $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); + $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); + $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); + $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); + $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); + + $this->assertFalse(isset($class->associationMappings['groups']['orderBy'])); + + return $class; + } + + /** + * @depends testManyToManyAssociationWithCascadeAll + * @param ClassMetadata $class + */ + public function testLifecycleCallbacks($class) + { + $this->assertEquals(count($class->lifecycleCallbacks), 2); + $this->assertEquals($class->lifecycleCallbacks['prePersist'][0], 'doStuffOnPrePersist'); + $this->assertEquals($class->lifecycleCallbacks['postPersist'][0], 'doStuffOnPostPersist'); + + return $class; + } + + /** + * @depends testManyToManyAssociationWithCascadeAll + * @param ClassMetadata $class + */ + public function testLifecycleCallbacksSupportMultipleMethodNames($class) + { + $this->assertEquals(count($class->lifecycleCallbacks['prePersist']), 2); + $this->assertEquals($class->lifecycleCallbacks['prePersist'][1], 'doOtherStuffOnPrePersistToo'); + + return $class; + } + + /** + * @depends testLifecycleCallbacksSupportMultipleMethodNames + * @param ClassMetadata $class + */ + public function testJoinColumnUniqueAndNullable($class) + { + // Non-Nullability of Join Column + $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['nullable']); + $this->assertFalse($class->associationMappings['groups']['joinTable']['joinColumns'][0]['unique']); + + return $class; + } + + /** + * @depends testJoinColumnUniqueAndNullable + * @param ClassMetadata $class + */ + public function testColumnDefinition($class) + { + $this->assertEquals("CHAR(32) NOT NULL", $class->fieldMappings['email']['columnDefinition']); + $this->assertEquals("INT NULL", $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); + + return $class; + } + + /** + * @depends testColumnDefinition + * @param ClassMetadata $class + */ + public function testJoinColumnOnDelete($class) + { + $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); + + return $class; + } + + /** + * @group DDC-514 + */ + public function testDiscriminatorColumnDefaults() + { + if (strpos(get_class($this), 'PHPMappingDriver') !== false) { + $this->markTestSkipped('PHP Mapping Drivers have no defaults.'); + } + + $class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\Animal'); + + $this->assertEquals( + array('name' => 'dtype', 'type' => 'string', 'length' => 255, 'fieldName' => 'dtype'), + $class->discriminatorColumn + ); + } + + /** + * @group DDC-869 + */ + public function testMappedSuperclassWithRepository() + { + $driver = $this->_loadDriver(); + $em = $this->_getTestEntityManager(); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + + $em->getConfiguration()->setMetadataDriverImpl($driver); + $factory->setEntityManager($em); + + + $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment'); + + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['value'])); + $this->assertTrue(isset($class->fieldMappings['creditCardNumber'])); + $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository", + $em->getRepository("Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment")); + $this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue()); + + + + $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869ChequePayment'); + + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['value'])); + $this->assertTrue(isset($class->fieldMappings['serialNumber'])); + $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); + $this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository", + $em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")); + $this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue()); + } + + /** + * @group DDC-1476 + */ + public function testDefaultFieldType() + { + $driver = $this->_loadDriver(); + $em = $this->_getTestEntityManager(); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + + $em->getConfiguration()->setMetadataDriverImpl($driver); + $factory->setEntityManager($em); + + + $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType'); + + + $this->assertArrayHasKey('id', $class->fieldMappings); + $this->assertArrayHasKey('name', $class->fieldMappings); + + + $this->assertArrayHasKey('type', $class->fieldMappings['id']); + $this->assertArrayHasKey('type', $class->fieldMappings['name']); + + $this->assertEquals('string', $class->fieldMappings['id']['type']); + $this->assertEquals('string', $class->fieldMappings['name']['type']); + + + + $this->assertArrayHasKey('fieldName', $class->fieldMappings['id']); + $this->assertArrayHasKey('fieldName', $class->fieldMappings['name']); + + $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); + $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); + + + + $this->assertArrayHasKey('columnName', $class->fieldMappings['id']); + $this->assertArrayHasKey('columnName', $class->fieldMappings['name']); + + $this->assertEquals('id', $class->fieldMappings['id']['columnName']); + $this->assertEquals('name', $class->fieldMappings['name']['columnName']); + + $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType); + } + + /** + * @group DDC-1170 + */ + public function testIdentifierColumnDefinition() + { + + $class = $this->createClassMetadata(__NAMESPACE__ . '\DDC1170Entity'); + + + $this->assertArrayHasKey('id', $class->fieldMappings); + $this->assertArrayHasKey('value', $class->fieldMappings); + + $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['id']); + $this->assertArrayHasKey('columnDefinition', $class->fieldMappings['value']); + + $this->assertEquals("INT unsigned NOT NULL", $class->fieldMappings['id']['columnDefinition']); + $this->assertEquals("VARCHAR(255) NOT NULL", $class->fieldMappings['value']['columnDefinition']); + } +} + +/** + * @Entity + * @HasLifecycleCallbacks + * @Table( + * name="cms_users", + * uniqueConstraints={@UniqueConstraint(name="search_idx", columns={"name", "user_email"})}, + * indexes={@Index(name="name_idx", columns={"name"}), @Index(name="0", columns={"user_email"})} + * ) + */ +class User +{ + /** + * @Id + * @Column(type="integer") + * @generatedValue(strategy="AUTO") + * @SequenceGenerator(sequenceName="tablename_seq", initialValue=1, allocationSize=100) + **/ + public $id; + + /** + * @Column(length=50, nullable=true, unique=true) + */ + public $name; + + /** + * @Column(name="user_email", columnDefinition="CHAR(32) NOT NULL") + */ + public $email; + + /** + * @OneToOne(targetEntity="Address", cascade={"remove"}, inversedBy="user") + * @JoinColumn(onDelete="CASCADE") + */ + public $address; + + /** + * @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"}, orphanRemoval=true) + * @OrderBy({"number"="ASC"}) + */ + public $phonenumbers; + + /** + * @ManyToMany(targetEntity="Group", cascade={"all"}) + * @JoinTable(name="cms_user_groups", + * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id", nullable=false, unique=false)}, + * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id", columnDefinition="INT NULL")} + * ) + */ + public $groups; + + + /** + * @PrePersist + */ + public function doStuffOnPrePersist() + { + } + + /** + * @PrePersist + */ + public function doOtherStuffOnPrePersistToo() { + } + + /** + * @PostPersist + */ + public function doStuffOnPostPersist() + { + + } + + public static function loadMetadata(ClassMetadataInfo $metadata) + { + $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); + $metadata->setPrimaryTable(array( + 'name' => 'cms_users', + )); + $metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); + $metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); + $metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist'); + $metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist'); + $metadata->mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'type' => 'integer', + 'columnName' => 'id', + )); + $metadata->mapField(array( + 'fieldName' => 'name', + 'type' => 'string', + 'length' => 50, + 'unique' => true, + 'nullable' => true, + 'columnName' => 'name', + )); + $metadata->mapField(array( + 'fieldName' => 'email', + 'type' => 'string', + 'columnName' => 'user_email', + 'columnDefinition' => 'CHAR(32) NOT NULL', + )); + $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); + $metadata->mapOneToOne(array( + 'fieldName' => 'address', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Address', + 'cascade' => + array( + 0 => 'remove', + ), + 'mappedBy' => NULL, + 'inversedBy' => 'user', + 'joinColumns' => + array( + 0 => + array( + 'name' => 'address_id', + 'referencedColumnName' => 'id', + 'onDelete' => 'CASCADE', + ), + ), + 'orphanRemoval' => false, + )); + $metadata->mapOneToMany(array( + 'fieldName' => 'phonenumbers', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber', + 'cascade' => + array( + 1 => 'persist', + ), + 'mappedBy' => 'user', + 'orphanRemoval' => true, + 'orderBy' => + array( + 'number' => 'ASC', + ), + )); + $metadata->mapManyToMany(array( + 'fieldName' => 'groups', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Group', + 'cascade' => + array( + 0 => 'remove', + 1 => 'persist', + 2 => 'refresh', + 3 => 'merge', + 4 => 'detach', + ), + 'mappedBy' => NULL, + 'joinTable' => + array( + 'name' => 'cms_users_groups', + 'joinColumns' => + array( + 0 => + array( + 'name' => 'user_id', + 'referencedColumnName' => 'id', + 'unique' => false, + 'nullable' => false, + ), + ), + 'inverseJoinColumns' => + array( + 0 => + array( + 'name' => 'group_id', + 'referencedColumnName' => 'id', + 'columnDefinition' => 'INT NULL', + ), + ), + ), + 'orderBy' => NULL, + )); + $metadata->table['uniqueConstraints'] = array( + 'search_idx' => array('columns' => array('name', 'user_email')), + ); + $metadata->table['indexes'] = array( + 'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email')) + ); + $metadata->setSequenceGeneratorDefinition(array( + 'sequenceName' => 'tablename_seq', + 'allocationSize' => 100, + 'initialValue' => 1, + )); + } +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorMap({"cat" = "Cat", "dog" = "Dog"}) + */ +abstract class Animal +{ + /** + * @Id @Column(type="string") @GeneratedValue + */ + public $id; + + public static function loadMetadata(ClassMetadataInfo $metadata) + { + + } +} + +/** @Entity */ +class Cat extends Animal +{ + public static function loadMetadata(ClassMetadataInfo $metadata) + { + + } +} + +/** @Entity */ +class Dog extends Animal +{ + public static function loadMetadata(ClassMetadataInfo $metadata) + { + + } +} + + +/** + * @Entity + */ +class DDC1170Entity +{ + + /** + * @param string $value + */ + function __construct($value = null) + { + $this->value = $value; + } + + /** + * @Id + * @GeneratedValue(strategy="NONE") + * @Column(type="integer", columnDefinition = "INT unsigned NOT NULL") + **/ + private $id; + + /** + * @Column(columnDefinition = "VARCHAR(255) NOT NULL") + */ + private $value; + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + public static function loadMetadata(ClassMetadataInfo $metadata) + { + $metadata->mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'columnDefinition' => 'INT unsigned NOT NULL', + )); + + $metadata->mapField(array( + 'fieldName' => 'value', + 'columnDefinition' => 'VARCHAR(255) NOT NULL' + )); + + $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); + } + +} + +class Address {} +class Phonenumber {} +class Group {} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php new file mode 100644 index 0000000..4d7715e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -0,0 +1,340 @@ +initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache()); + $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $annotationDriver->loadMetadataForClass('stdClass', $cm); + } + + /** + * @group DDC-268 + */ + public function testColumnWithMissingTypeDefaultsToString() + { + $cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ColumnWithoutType'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $annotationDriver = $this->_loadDriver(); + + $annotationDriver->loadMetadataForClass('Doctrine\Tests\ORM\Mapping\InvalidColumn', $cm); + $this->assertEquals('string', $cm->fieldMappings['id']['type']); + } + + /** + * @group DDC-318 + */ + public function testGetAllClassNamesIsIdempotent() + { + $annotationDriver = $this->_loadDriverForCMSModels(); + $original = $annotationDriver->getAllClassNames(); + + $annotationDriver = $this->_loadDriverForCMSModels(); + $afterTestReset = $annotationDriver->getAllClassNames(); + + $this->assertEquals($original, $afterTestReset); + } + + /** + * @group DDC-318 + */ + public function testGetAllClassNamesIsIdempotentEvenWithDifferentDriverInstances() + { + $annotationDriver = $this->_loadDriverForCMSModels(); + $original = $annotationDriver->getAllClassNames(); + + $annotationDriver = $this->_loadDriverForCMSModels(); + $afterTestReset = $annotationDriver->getAllClassNames(); + + $this->assertEquals($original, $afterTestReset); + } + + /** + * @group DDC-318 + */ + public function testGetAllClassNamesReturnsAlreadyLoadedClassesIfAppropriate() + { + $rightClassName = 'Doctrine\Tests\Models\CMS\CmsUser'; + $this->_ensureIsLoaded($rightClassName); + + $annotationDriver = $this->_loadDriverForCMSModels(); + $classes = $annotationDriver->getAllClassNames(); + + $this->assertContains($rightClassName, $classes); + } + + /** + * @group DDC-318 + */ + public function testGetClassNamesReturnsOnlyTheAppropriateClasses() + { + $extraneousClassName = 'Doctrine\Tests\Models\ECommerce\ECommerceCart'; + $this->_ensureIsLoaded($extraneousClassName); + + $annotationDriver = $this->_loadDriverForCMSModels(); + $classes = $annotationDriver->getAllClassNames(); + + $this->assertNotContains($extraneousClassName, $classes); + } + + protected function _loadDriverForCMSModels() + { + $annotationDriver = $this->_loadDriver(); + $annotationDriver->addPaths(array(__DIR__ . '/../../Models/CMS/')); + return $annotationDriver; + } + + protected function _loadDriver() + { + return $this->createAnnotationDriver(); + } + + protected function _ensureIsLoaded($entityClassName) + { + new $entityClassName; + } + + /** + * @group DDC-671 + * + * Entities for this test are in AbstractMappingDriverTest + */ + public function testJoinTablesWithMappedSuperclassForAnnotationDriver() + { + $annotationDriver = $this->_loadDriver(); + $annotationDriver->addPaths(array(__DIR__ . '/../../Models/DirectoryTree/')); + + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory->setEntityManager($em); + + $classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File'); + $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\File', $classPage->associationMappings['parentDirectory']['sourceEntity']); + + $classDirectory = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\Directory'); + $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']); + } + + /** + * @group DDC-945 + */ + public function testInvalidMappedSuperClassWithManyToManyAssociation() + { + $annotationDriver = $this->_loadDriver(); + + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $factory = new \Doctrine\ORM\Mapping\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'"); + $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\UsingInvalidMappedSuperClass'); + } + + /** + * @group DDC-1050 + */ + public function testInvalidMappedSuperClassWithInheritanceInformation() + { + $annotationDriver = $this->_loadDriver(); + + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory->setEntityManager($em); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', + "Its not supported to define inheritance information on a mapped ". + "superclass 'Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'."); + $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'); + } + + /** + * @group DDC-1034 + */ + public function testInheritanceSkipsParentLifecycleCallbacks() + { + $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->setEntityManager($em); + + $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\AnnotationChild'); + $this->assertEquals(array("postLoad" => array("postLoad"), "preUpdate" => array("preUpdate")), $cm->lifecycleCallbacks); + + $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\AnnotationParent'); + $this->assertEquals(array("postLoad" => array("postLoad"), "preUpdate" => array("preUpdate")), $cm->lifecycleCallbacks); + } + + /** + * @group DDC-1156 + */ + public function testMappedSuperclassInMiddleOfInheritanceHierachy() + { + $annotationDriver = $this->_loadDriver(); + + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory->setEntityManager($em); + + $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\ChildEntity'); + } + + public function testInvalidFetchOptionThrowsException() + { + $annotationDriver = $this->_loadDriver(); + + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory->setEntityManager($em); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', + "Entity 'Doctrine\Tests\ORM\Mapping\InvalidFetchOption' has a mapping with invalid fetch mode 'eager"); + $cm = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\InvalidFetchOption'); + } +} + +/** + * @Entity + */ +class ColumnWithoutType +{ + /** @Id @Column */ + public $id; +} + +/** + * @MappedSuperclass + */ +class InvalidMappedSuperClass +{ + /** + * @ManyToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", mappedBy="invalid") + */ + private $users; +} + +/** + * @Entity + */ +class UsingInvalidMappedSuperClass extends InvalidMappedSuperClass +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + private $id; +} + +/** + * @MappedSuperclass + * @InheritanceType("JOINED") + * @DiscriminatorMap({"test" = "ColumnWithoutType"}) + */ +class MappedSuperClassInheritence +{ + +} + +/** + * @Entity + * @InheritanceType("JOINED") + * @DiscriminatorMap({"parent" = "AnnotationParent", "child" = "AnnotationChild"}) + * @HasLifecycleCallbacks + */ +class AnnotationParent +{ + /** + * @Id @Column(type="integer") @GeneratedValue + */ + private $id; + + /** + * @PostLoad + */ + public function postLoad() + { + + } + + /** + * @PreUpdate + */ + public function preUpdate() + { + + } +} + +/** + * @Entity + * @HasLifecycleCallbacks + */ +class AnnotationChild extends AnnotationParent +{ + +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorMap({"s"="SuperEntity", "c"="ChildEntity"}) + */ +class SuperEntity +{ + /** @Id @Column(type="string") */ + private $id; +} + +/** + * @MappedSuperclass + */ +class MiddleMappedSuperclass extends SuperEntity +{ + /** @Column(type="string") */ + private $name; +} + +/** + * @Entity + */ +class ChildEntity extends MiddleMappedSuperclass +{ + /** + * @Column(type="string") + */ + private $text; +} + +/** + * @Entity + */ +class InvalidFetchOption +{ + /** + * @OneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", fetch="eager") + */ + private $collection; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php new file mode 100644 index 0000000..ff7f040 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php @@ -0,0 +1,319 @@ +_factory = new ClassMetadataFactory(); + $this->_factory->setEntityManager($this->_getTestEntityManager()); + } + + /** + * @expectedException Doctrine\ORM\Mapping\MappingException + */ + public function testGetMetadataForTransientClassThrowsException() + { + $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\TransientBaseClass'); + } + + public function testGetMetadataForSubclassWithTransientBaseClass() + { + $class = $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\EntitySubClass'); + + $this->assertTrue(empty($class->subClasses)); + $this->assertTrue(empty($class->parentClasses)); + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['name'])); + } + + public function testGetMetadataForSubclassWithMappedSuperclass() + { + $class = $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\EntitySubClass2'); + + $this->assertTrue(empty($class->subClasses)); + $this->assertTrue(empty($class->parentClasses)); + + $this->assertTrue(isset($class->fieldMappings['mapped1'])); + $this->assertTrue(isset($class->fieldMappings['mapped2'])); + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['name'])); + + $this->assertFalse(isset($class->fieldMappings['mapped1']['inherited'])); + $this->assertFalse(isset($class->fieldMappings['mapped2']['inherited'])); + $this->assertFalse(isset($class->fieldMappings['transient'])); + + $this->assertTrue(isset($class->associationMappings['mappedRelated1'])); + } + + /** + * @group DDC-869 + */ + public function testGetMetadataForSubclassWithMappedSuperclassWhithRepository() + { + $class = $this->_factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment'); + + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['value'])); + $this->assertTrue(isset($class->fieldMappings['creditCardNumber'])); + $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); + + + $class = $this->_factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869ChequePayment'); + + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['value'])); + $this->assertTrue(isset($class->fieldMappings['serialNumber'])); + $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); + + + // override repositoryClass + $class = $this->_factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\SubclassWithRepository'); + + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['value'])); + $this->assertEquals($class->customRepositoryClassName, "Doctrine\ORM\EntityRepository"); + } + + /** + * @group DDC-388 + */ + public function testSerializationWithPrivateFieldsFromMappedSuperclass() + { + + $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\EntitySubClass2'); + + $class2 = unserialize(serialize($class)); + $class2->wakeupReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $this->assertTrue(isset($class2->reflFields['mapped1'])); + $this->assertTrue(isset($class2->reflFields['mapped2'])); + $this->assertTrue(isset($class2->reflFields['mappedRelated1'])); + } + + /** + * @group DDC-1203 + */ + public function testUnmappedSuperclassInHierachy() + { + $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyD'); + + $this->assertTrue(isset($class->fieldMappings['id'])); + $this->assertTrue(isset($class->fieldMappings['a'])); + $this->assertTrue(isset($class->fieldMappings['d'])); + } + + /** + * @group DDC-1204 + */ + public function testUnmappedEntityInHierachy() + { + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "Entity 'Doctrine\Tests\ORM\Mapping\HierachyBEntity' has to be part of the discriminator map of 'Doctrine\Tests\ORM\Mapping\HierachyBase' to be properly mapped in the inheritance hierachy. Alternatively you can make 'Doctrine\Tests\ORM\Mapping\HierachyBEntity' an abstract class to avoid this exception from occuring."); + + $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyE'); + } + + /** + * @group DDC-1204 + * @group DDC-1203 + */ + public function testMappedSuperclassWithId() + { + $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\SuperclassEntity'); + + $this->assertTrue(isset($class->fieldMappings['id'])); + } + + /** + * @group DDC-1156 + * @group DDC-1218 + */ + public function testGeneratedValueFromMappedSuperclass() + { + $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\SuperclassEntity'); + /* @var $class ClassMetadataInfo */ + + $this->assertInstanceOf('Doctrine\ORM\Id\SequenceGenerator', $class->idGenerator); + $this->assertEquals(array('allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'), $class->sequenceGeneratorDefinition); + } + + /** + * @group DDC-1156 + * @group DDC-1218 + */ + public function testSequenceDefinitionInHierachyWithSandwichMappedSuperclass() + { + $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyD'); + /* @var $class ClassMetadataInfo */ + + $this->assertInstanceOf('Doctrine\ORM\Id\SequenceGenerator', $class->idGenerator); + $this->assertEquals(array('allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'), $class->sequenceGeneratorDefinition); + } + + /** + * @group DDC-1156 + * @group DDC-1218 + */ + public function testMultipleMappedSuperclasses() + { + $class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\MediumSuperclassEntity'); + /* @var $class ClassMetadataInfo */ + + $this->assertInstanceOf('Doctrine\ORM\Id\SequenceGenerator', $class->idGenerator); + $this->assertEquals(array('allocationSize' => 1, 'initialValue' => 10, 'sequenceName' => 'foo'), $class->sequenceGeneratorDefinition); + } +} + +class TransientBaseClass { + private $transient1; + private $transient2; +} + +/** @Entity */ +class EntitySubClass extends TransientBaseClass +{ + /** @Id @Column(type="integer") */ + private $id; + /** @Column(type="string") */ + private $name; +} + +/** @MappedSuperclass */ +class MappedSuperclassBase { + /** @Column(type="integer") */ + private $mapped1; + /** @Column(type="string") */ + private $mapped2; + /** + * @OneToOne(targetEntity="MappedSuperclassRelated1") + * @JoinColumn(name="related1_id", referencedColumnName="id") + */ + private $mappedRelated1; + private $transient; +} +class MappedSuperclassRelated1 {} + +/** @Entity */ +class EntitySubClass2 extends MappedSuperclassBase { + /** @Id @Column(type="integer") */ + private $id; + /** @Column(type="string") */ + private $name; +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorColumn(name="type", type="string", length=20) + * @DiscriminatorMap({ + * "c" = "HierachyC", + * "d" = "HierachyD", + * "e" = "HierachyE" + * }) + */ +abstract class HierachyBase +{ + /** + * @Column(type="integer") @Id @GeneratedValue(strategy="SEQUENCE") + * @SequenceGenerator(sequenceName="foo", initialValue=10) + * @var int + */ + public $id; +} + +/** + * @MappedSuperclass + */ +abstract class HierachyASuperclass extends HierachyBase +{ + /** @Column(type="string") */ + public $a; +} + +/** + * @Entity + */ +class HierachyBEntity extends HierachyBase +{ + /** @Column(type="string") */ + public $b; +} + +/** + * @Entity + */ +class HierachyC extends HierachyBase +{ + /** @Column(type="string") */ + public $c; +} + +/** + * @Entity + */ +class HierachyD extends HierachyASuperclass +{ + /** @Column(type="string") */ + public $d; +} + +/** + * @Entity + */ +class HierachyE extends HierachyBEntity +{ + /** @Column(type="string") */ + public $e; +} + +/** + * @Entity + */ +class SuperclassEntity extends SuperclassBase +{ + +} + +/** + * @MappedSuperclass + */ +abstract class SuperclassBase +{ + /** + * @Column(type="integer") @Id @GeneratedValue(strategy="SEQUENCE") + * @SequenceGenerator(sequenceName="foo", initialValue=10) + * @var int + */ + public $id; +} + +/** + * @MappedSuperclass + */ +abstract class MediumSuperclassBase extends SuperclassBase +{ + +} + +/** + * @Entity + */ +class MediumSuperclassEntity extends MediumSuperclassBase +{ + +} + +/** + * @Entity(repositoryClass = "Doctrine\ORM\EntityRepository") + */ +class SubclassWithRepository extends \Doctrine\Tests\Models\DDC869\DDC869Payment +{ + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php new file mode 100644 index 0000000..f14b60b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -0,0 +1,428 @@ +. + */ + + +namespace Doctrine\Tests\ORM\Mapping; + +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; + +/** + * @group DDC-659 + */ +class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase +{ + /** + * @var ClassMetadata + */ + private $cm; + /** + * @var ClassMetadataBuilder + */ + private $builder; + + public function setUp() + { + $this->cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $this->cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->builder = new ClassMetadataBuilder($this->cm); + } + + public function testSetMappedSuperClass() + { + $this->assertIsFluent($this->builder->setMappedSuperClass()); + $this->assertTrue($this->cm->isMappedSuperclass); + } + + public function testSetCustomRepositoryClass() + { + $this->assertIsFluent($this->builder->setCustomRepositoryClass('Doctrine\Tests\Models\CMS\CmsGroup')); + $this->assertEquals('Doctrine\Tests\Models\CMS\CmsGroup', $this->cm->customRepositoryClassName); + } + + public function testSetReadOnly() + { + $this->assertIsFluent($this->builder->setReadOnly()); + $this->assertTrue($this->cm->isReadOnly); + } + + public function testSetTable() + { + $this->assertIsFluent($this->builder->setTable('users')); + $this->assertEquals('users', $this->cm->table['name']); + } + + public function testAddIndex() + { + $this->assertIsFluent($this->builder->addIndex(array('username', 'name'), 'users_idx')); + $this->assertEquals(array('users_idx' => array('columns' => array('username', 'name'))), $this->cm->table['indexes']); + } + + public function testAddUniqueConstraint() + { + $this->assertIsFluent($this->builder->addUniqueConstraint(array('username', 'name'), 'users_idx')); + $this->assertEquals(array('users_idx' => array('columns' => array('username', 'name'))), $this->cm->table['uniqueConstraints']); + } + + public function testSetPrimaryTableRelated() + { + $this->builder->addUniqueConstraint(array('username', 'name'), 'users_idx'); + $this->builder->addIndex(array('username', 'name'), 'users_idx'); + $this->builder->setTable('users'); + + $this->assertEquals( + array( + 'name' => 'users', + 'indexes' => array('users_idx' => array('columns' => array('username', 'name'))), + 'uniqueConstraints' => array('users_idx' => array('columns' => array('username', 'name'))), + ), + $this->cm->table + ); + } + + public function testSetInheritanceJoined() + { + $this->assertIsFluent($this->builder->setJoinedTableInheritance()); + $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_JOINED, $this->cm->inheritanceType); + } + + public function testSetInheritanceSingleTable() + { + $this->assertIsFluent($this->builder->setSingleTableInheritance()); + $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE, $this->cm->inheritanceType); + } + + public function testSetDiscriminatorColumn() + { + $this->assertIsFluent($this->builder->setDiscriminatorColumn('discr', 'string', '124')); + $this->assertEquals(array('fieldName' => 'discr', 'name' => 'discr', 'type' => 'string', 'length' => '124'), $this->cm->discriminatorColumn); + } + + public function testAddDiscriminatorMapClass() + { + $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test', 'Doctrine\Tests\Models\CMS\CmsUser')); + $this->assertIsFluent($this->builder->addDiscriminatorMapClass('test2', 'Doctrine\Tests\Models\CMS\CmsGroup')); + + $this->assertEquals(array('test' => 'Doctrine\Tests\Models\CMS\CmsUser', 'test2' => 'Doctrine\Tests\Models\CMS\CmsGroup'), $this->cm->discriminatorMap); + $this->assertEquals('test', $this->cm->discriminatorValue); + } + + public function testChangeTrackingPolicyExplicit() + { + $this->assertIsFluent($this->builder->setChangeTrackingPolicyDeferredExplicit()); + $this->assertEquals(ClassMetadata::CHANGETRACKING_DEFERRED_EXPLICIT, $this->cm->changeTrackingPolicy); + } + + public function testChangeTrackingPolicyNotify() + { + $this->assertIsFluent($this->builder->setChangeTrackingPolicyNotify()); + $this->assertEquals(ClassMetadata::CHANGETRACKING_NOTIFY, $this->cm->changeTrackingPolicy); + } + + public function testAddField() + { + $this->assertIsFluent($this->builder->addField('name', 'string')); + $this->assertEquals(array('columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'), $this->cm->fieldMappings['name']); + } + + public function testCreateField() + { + $fieldBuilder = ($this->builder->createField('name', 'string')); + $this->assertInstanceOf('Doctrine\ORM\Mapping\Builder\FieldBuilder', $fieldBuilder); + + $this->assertFalse(isset($this->cm->fieldMappings['name'])); + $this->assertIsFluent($fieldBuilder->build()); + $this->assertEquals(array('columnName' => 'name', 'fieldName' => 'name', 'type' => 'string'), $this->cm->fieldMappings['name']); + } + + public function testCreateVersionedField() + { + $this->builder->createField('name', 'integer')->columnName('username')->length(124)->nullable()->columnDefinition('foobar')->unique()->isVersionField()->build(); + $this->assertEquals(array( + 'columnDefinition' => 'foobar', + 'columnName' => 'username', + 'default' => 1, + 'fieldName' => 'name', + 'length' => 124, + 'type' => 'integer', + 'nullable' => true, + 'unique' => true, + ), $this->cm->fieldMappings['name']); + } + + public function testCreatePrimaryField() + { + $this->builder->createField('id', 'integer')->isPrimaryKey()->generatedValue()->build(); + + $this->assertEquals(array('id'), $this->cm->identifier); + $this->assertEquals(array('columnName' => 'id', 'fieldName' => 'id', 'id' => true, 'type' => 'integer'), $this->cm->fieldMappings['id']); + } + + public function testAddLifecycleEvent() + { + $this->builder->addLifecycleEvent('getStatus', 'postLoad'); + + $this->assertEquals(array('postLoad' => array('getStatus')), $this->cm->lifecycleCallbacks); + } + + public function testCreateManyToOne() + { + $this->assertIsFluent( + $this->builder->createManyToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') + ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') + ->cascadeAll() + ->fetchExtraLazy() + ->build() + ); + + $this->assertEquals(array('groups' => array ( + 'fieldName' => 'groups', + 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', + 'cascade' => array ( + 0 => 'remove', + 1 => 'persist', + 2 => 'refresh', + 3 => 'merge', + 4 => 'detach', + ), + 'fetch' => 4, + 'joinColumns' => array ( + 0 => + array ( + 'name' => 'group_id', + 'referencedColumnName' => 'id', + 'nullable' => true, + 'unique' => false, + 'onDelete' => 'CASCADE', + 'columnDefinition' => NULL, + ), + ), + 'type' => 2, + 'mappedBy' => NULL, + 'inversedBy' => NULL, + 'isOwningSide' => true, + 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', + 'isCascadeRemove' => true, + 'isCascadePersist' => true, + 'isCascadeRefresh' => true, + 'isCascadeMerge' => true, + 'isCascadeDetach' => true, + 'sourceToTargetKeyColumns' => + array ( + 'group_id' => 'id', + ), + 'joinColumnFieldNames' => + array ( + 'group_id' => 'group_id', + ), + 'targetToSourceKeyColumns' => + array ( + 'id' => 'group_id', + ), + 'orphanRemoval' => false, + ), + ), $this->cm->associationMappings); + } + + public function testCreateOneToOne() + { + $this->assertIsFluent( + $this->builder->createOneToOne('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') + ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') + ->cascadeAll() + ->fetchExtraLazy() + ->build() + ); + + $this->assertEquals(array('groups' => array ( + 'fieldName' => 'groups', + 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', + 'cascade' => array ( + 0 => 'remove', + 1 => 'persist', + 2 => 'refresh', + 3 => 'merge', + 4 => 'detach', + ), + 'fetch' => 4, + 'joinColumns' => array ( + 0 => + array ( + 'name' => 'group_id', + 'referencedColumnName' => 'id', + 'nullable' => true, + 'unique' => true, + 'onDelete' => 'CASCADE', + 'columnDefinition' => NULL, + ), + ), + 'type' => 1, + 'mappedBy' => NULL, + 'inversedBy' => NULL, + 'isOwningSide' => true, + 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', + 'isCascadeRemove' => true, + 'isCascadePersist' => true, + 'isCascadeRefresh' => true, + 'isCascadeMerge' => true, + 'isCascadeDetach' => true, + 'sourceToTargetKeyColumns' => + array ( + 'group_id' => 'id', + ), + 'joinColumnFieldNames' => + array ( + 'group_id' => 'group_id', + ), + 'targetToSourceKeyColumns' => + array ( + 'id' => 'group_id', + ), + 'orphanRemoval' => false, + ), + ), $this->cm->associationMappings); + } + + public function testCreateManyToMany() + { + $this->assertIsFluent( + $this->builder->createManyToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') + ->setJoinTable('groups_users') + ->addJoinColumn('group_id', 'id', true, false, 'CASCADE') + ->addInverseJoinColumn('user_id', 'id') + ->cascadeAll() + ->fetchExtraLazy() + ->build() + ); + + $this->assertEquals(array( + 'groups' => + array( + 'fieldName' => 'groups', + 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', + 'cascade' => + array( + 0 => 'remove', + 1 => 'persist', + 2 => 'refresh', + 3 => 'merge', + 4 => 'detach', + ), + 'fetch' => 4, + 'joinTable' => + array( + 'joinColumns' => + array( + 0 => + array( + 'name' => 'group_id', + 'referencedColumnName' => 'id', + 'nullable' => true, + 'unique' => false, + 'onDelete' => 'CASCADE', + 'columnDefinition' => NULL, + ), + ), + 'inverseJoinColumns' => + array( + 0 => + array( + 'name' => 'user_id', + 'referencedColumnName' => 'id', + 'nullable' => true, + 'unique' => false, + 'onDelete' => NULL, + 'columnDefinition' => NULL, + ), + ), + 'name' => 'groups_users', + ), + 'type' => 8, + 'mappedBy' => NULL, + 'inversedBy' => NULL, + 'isOwningSide' => true, + 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', + 'isCascadeRemove' => true, + 'isCascadePersist' => true, + 'isCascadeRefresh' => true, + 'isCascadeMerge' => true, + 'isCascadeDetach' => true, + 'isOnDeleteCascade' => true, + 'relationToSourceKeyColumns' => + array( + 'group_id' => 'id', + ), + 'joinTableColumns' => + array( + 0 => 'group_id', + 1 => 'user_id', + ), + 'relationToTargetKeyColumns' => + array( + 'user_id' => 'id', + ), + 'orphanRemoval' => false, + ), + ), $this->cm->associationMappings); + } + + public function testCreateOneToMany() + { + $this->assertIsFluent( + $this->builder->createOneToMany('groups', 'Doctrine\Tests\Models\CMS\CmsGroup') + ->mappedBy('test') + ->setOrderBy(array('test')) + ->setIndexBy('test') + ->build() + ); + + $this->assertEquals(array( + 'groups' => + array( + 'fieldName' => 'groups', + 'targetEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsGroup', + 'mappedBy' => 'test', + 'orderBy' => + array( + 0 => 'test', + ), + 'indexBy' => 'test', + 'type' => 4, + 'inversedBy' => NULL, + 'isOwningSide' => false, + 'sourceEntity' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', + 'fetch' => 2, + 'cascade' => + array( + ), + 'isCascadeRemove' => false, + 'isCascadePersist' => false, + 'isCascadeRefresh' => false, + 'isCascadeMerge' => false, + 'isCascadeDetach' => false, + 'orphanRemoval' => false, + ), + ), $this->cm->associationMappings); + } + + public function assertIsFluent($ret) + { + $this->assertSame($this->builder, $ret, "Return Value has to be same instance as used builder"); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php new file mode 100644 index 0000000..cd1e4f3 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -0,0 +1,181 @@ +_createEntityManager($mockDriver); + + $conn = $entityManager->getConnection(); + $mockPlatform = $conn->getDatabasePlatform(); + $mockPlatform->setPrefersSequences(true); + $mockPlatform->setPrefersIdentityColumns(false); + + // Self-made metadata + $cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1'); + $cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm1->setPrimaryTable(array('name' => '`group`')); + // Add a mapped field + $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar')); + // Add a mapped field + $cm1->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); + // and a mapped association + $cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'TestEntity1', 'mappedBy' => 'this')); + // and an association on the owning side + $joinColumns = array( + array('name' => 'other_id', 'referencedColumnName' => 'id') + ); + $cm1->mapOneToOne(array('fieldName' => 'association', 'targetEntity' => 'TestEntity1', 'joinColumns' => $joinColumns)); + // and an id generator type + $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); + + // SUT + $cmf = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $cmf->setEntityManager($entityManager); + $cmf->setMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1', $cm1); + + // Prechecks + $this->assertEquals(array(), $cm1->parentClasses); + $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType); + $this->assertTrue($cm1->hasField('name')); + $this->assertEquals(2, count($cm1->associationMappings)); + $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType); + $this->assertEquals('group', $cm1->table['name']); + + // Go + $cmMap1 = $cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1'); + + $this->assertSame($cm1, $cmMap1); + $this->assertEquals('group', $cmMap1->table['name']); + $this->assertTrue($cmMap1->table['quoted']); + $this->assertEquals(array(), $cmMap1->parentClasses); + $this->assertTrue($cmMap1->hasField('name')); + } + + public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized() + { + require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; + + $metadataDriver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/Global/')); + + $entityManager = $this->_createEntityManager($metadataDriver); + + $mf = $entityManager->getMetadataFactory(); + $m1 = $mf->getMetadataFor("DoctrineGlobal_Article"); + $h1 = $mf->hasMetadataFor("DoctrineGlobal_Article"); + $h2 = $mf->hasMetadataFor("\DoctrineGlobal_Article"); + $m2 = $mf->getMetadataFor("\DoctrineGlobal_Article"); + + $this->assertNotSame($m1, $m2); + $this->assertFalse($h2); + $this->assertTrue($h1); + } + + /** + * @group DDC-1512 + */ + public function testIsTransient() + { + $cmf = new ClassMetadataFactory(); + $driver = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver->expects($this->at(0)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) + ->will($this->returnValue(true)); + $driver->expects($this->at(1)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) + ->will($this->returnValue(false)); + + $em = $this->_createEntityManager($driver); + + $this->assertTrue($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsUser')); + $this->assertFalse($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsArticle')); + } + + /** + * @group DDC-1512 + */ + public function testIsTransientEntityNamespace() + { + $cmf = new ClassMetadataFactory(); + $driver = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver->expects($this->at(0)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsUser')) + ->will($this->returnValue(true)); + $driver->expects($this->at(1)) + ->method('isTransient') + ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) + ->will($this->returnValue(false)); + + $em = $this->_createEntityManager($driver); + $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); + + $this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); + $this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); + } + + protected function _createEntityManager($metadataDriver) + { + $driverMock = new DriverMock(); + $config = new \Doctrine\ORM\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); + } +} + +/* Test subject class with overriden factory method for mocking purposes */ +class ClassMetadataFactoryTestSubject extends \Doctrine\ORM\Mapping\ClassMetadataFactory +{ + private $mockMetadata = array(); + private $requestedClasses = array(); + + /** @override */ + protected function newClassMetadataInstance($className) + { + $this->requestedClasses[] = $className; + if ( ! isset($this->mockMetadata[$className])) { + throw new InvalidArgumentException("No mock metadata found for class $className."); + } + return $this->mockMetadata[$className]; + } + + public function setMetadataForClass($className, $metadata) + { + $this->mockMetadata[$className] = $metadata; + } + + public function getRequestedClasses() + { + return $this->requestedClasses; + } +} + +class TestEntity1 +{ + private $id; + private $name; + private $other; + private $association; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php new file mode 100644 index 0000000..70aae70 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -0,0 +1,56 @@ +_getTestEntityManager(); + $metadataFactory = $em->getMetadataFactory(); + $evm = $em->getEventManager(); + $evm->addEventListener(Events::loadClassMetadata, $this); + $classMetadata = $metadataFactory->getMetadataFor('Doctrine\Tests\ORM\Mapping\LoadEventTestEntity'); + $this->assertTrue($classMetadata->hasField('about')); + $this->assertArrayHasKey('about', $classMetadata->reflFields); + $this->assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); + } + + public function loadClassMetadata(\Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs) + { + $classMetadata = $eventArgs->getClassMetadata(); + $field = array( + 'fieldName' => 'about', + 'type' => 'string', + 'length' => 255 + ); + $classMetadata->mapField($field); + } +} + +/** + * @Entity + * @Table(name="load_event_test_entity") + */ +class LoadEventTestEntity +{ + /** + * @Id @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + /** + * @Column(type="string", length=255) + */ + private $name; + + private $about; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php new file mode 100644 index 0000000..d100f6f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -0,0 +1,553 @@ +initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + // Test initial state + $this->assertTrue(count($cm->getReflectionProperties()) == 0); + $this->assertInstanceOf('ReflectionClass', $cm->reflClass); + $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name); + $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->rootEntityName); + $this->assertEquals(array(), $cm->subClasses); + $this->assertEquals(array(), $cm->parentClasses); + $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm->inheritanceType); + + // Customize state + $cm->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE); + $cm->setSubclasses(array("One", "Two", "Three")); + $cm->setParentClasses(array("UserParent")); + $cm->setCustomRepositoryClass("UserRepository"); + $cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer')); + $cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'CmsAddress', 'mappedBy' => 'foo')); + $cm->markReadOnly(); + $cm->addNamedQuery(array('name' => 'dql', 'query' => 'foo')); + $this->assertEquals(1, count($cm->associationMappings)); + + $serialized = serialize($cm); + $cm = unserialize($serialized); + $cm->wakeupReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + // Check state + $this->assertTrue(count($cm->getReflectionProperties()) > 0); + $this->assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace); + $this->assertInstanceOf('ReflectionClass', $cm->reflClass); + $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name); + $this->assertEquals('UserParent', $cm->rootEntityName); + $this->assertEquals(array('Doctrine\Tests\Models\CMS\One', 'Doctrine\Tests\Models\CMS\Two', 'Doctrine\Tests\Models\CMS\Three'), $cm->subClasses); + $this->assertEquals(array('UserParent'), $cm->parentClasses); + $this->assertEquals('Doctrine\Tests\Models\CMS\UserRepository', $cm->customRepositoryClassName); + $this->assertEquals(array('name' => 'disc', 'type' => 'integer', 'fieldName' => 'disc'), $cm->discriminatorColumn); + $this->assertTrue($cm->associationMappings['phonenumbers']['type'] == ClassMetadata::ONE_TO_ONE); + $this->assertEquals(1, count($cm->associationMappings)); + $oneOneMapping = $cm->getAssociationMapping('phonenumbers'); + $this->assertTrue($oneOneMapping['fetch'] == ClassMetadata::FETCH_LAZY); + $this->assertEquals('phonenumbers', $oneOneMapping['fieldName']); + $this->assertEquals('Doctrine\Tests\Models\CMS\CmsAddress', $oneOneMapping['targetEntity']); + $this->assertTrue($cm->isReadOnly); + $this->assertEquals(array('dql' => array('name'=>'dql','query'=>'foo','dql'=>'foo')), $cm->namedQueries); + } + + public function testFieldIsNullable() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + // Explicit Nullable + $cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50)); + $this->assertTrue($cm->isNullable('status')); + + // Explicit Not Nullable + $cm->mapField(array('fieldName' => 'username', 'nullable' => false, 'type' => 'string', 'length' => 50)); + $this->assertFalse($cm->isNullable('username')); + + // Implicit Not Nullable + $cm->mapField(array('fieldName' => 'name', 'type' => 'string', 'length' => 50)); + $this->assertFalse($cm->isNullable('name'), "By default a field should not be nullable."); + } + + /** + * @group DDC-115 + */ + public function testMapAssocationInGlobalNamespace() + { + require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; + + $cm = new ClassMetadata('DoctrineGlobal_Article'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapManyToMany(array( + 'fieldName' => 'author', + 'targetEntity' => 'DoctrineGlobal_User', + 'joinTable' => array( + 'name' => 'bar', + 'joinColumns' => array(array('name' => 'bar_id', 'referencedColumnName' => 'id')), + 'inverseJoinColumns' => array(array('name' => 'baz_id', 'referencedColumnName' => 'id')), + ), + )); + + $this->assertEquals("DoctrineGlobal_User", $cm->associationMappings['author']['targetEntity']); + } + + public function testMapManyToManyJoinTableDefaults() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapManyToMany( + array( + 'fieldName' => 'groups', + 'targetEntity' => 'CmsGroup' + )); + + $assoc = $cm->associationMappings['groups']; + //$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $assoc); + $this->assertEquals(array( + 'name' => 'cmsuser_cmsgroup', + 'joinColumns' => array(array('name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')), + 'inverseJoinColumns' => array(array('name' => 'cmsgroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')) + ), $assoc['joinTable']); + $this->assertTrue($assoc['isOnDeleteCascade']); + } + + public function testSerializeManyToManyJoinTableCascade() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapManyToMany( + array( + 'fieldName' => 'groups', + 'targetEntity' => 'CmsGroup' + )); + + /* @var $assoc \Doctrine\ORM\Mapping\ManyToManyMapping */ + $assoc = $cm->associationMappings['groups']; + $assoc = unserialize(serialize($assoc)); + + $this->assertTrue($assoc['isOnDeleteCascade']); + } + + /** + * @group DDC-115 + */ + public function testSetDiscriminatorMapInGlobalNamespace() + { + require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; + + $cm = new ClassMetadata('DoctrineGlobal_User'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->setDiscriminatorMap(array('descr' => 'DoctrineGlobal_Article', 'foo' => 'DoctrineGlobal_User')); + + $this->assertEquals("DoctrineGlobal_Article", $cm->discriminatorMap['descr']); + $this->assertEquals("DoctrineGlobal_User", $cm->discriminatorMap['foo']); + } + + /** + * @group DDC-115 + */ + public function testSetSubClassesInGlobalNamespace() + { + require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; + + $cm = new ClassMetadata('DoctrineGlobal_User'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->setSubclasses(array('DoctrineGlobal_Article')); + + $this->assertEquals("DoctrineGlobal_Article", $cm->subClasses[0]); + } + + /** + * @group DDC-268 + */ + public function testSetInvalidVersionMapping_ThrowsException() + { + $field = array(); + $field['fieldName'] = 'foo'; + $field['type'] = 'string'; + + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->setVersionMapping($field); + } + + public function testGetSingleIdentifierFieldName_MultipleIdentifierEntity_ThrowsException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->isIdentifierComposite = true; + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->getSingleIdentifierFieldName(); + } + + public function testDuplicateAssociationMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $a1 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'); + $a2 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'); + + $cm->addInheritedAssociationMapping($a1); + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->addInheritedAssociationMapping($a2); + } + + public function testDuplicateColumnName_ThrowsMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapField(array('fieldName' => 'username', 'columnName' => 'name')); + } + + public function testDuplicateColumnName_DiscriminatorColumn_ThrowsMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->setDiscriminatorColumn(array('name' => 'name')); + } + + public function testDuplicateColumnName_DiscriminatorColumn2_ThrowsMappingException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->setDiscriminatorColumn(array('name' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + } + + public function testDuplicateFieldAndAssocationMapping1_ThrowsException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); + } + + public function testDuplicateFieldAndAssocationMapping2_ThrowsException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); + } + + /** + * @group DDC-1224 + */ + public function testGetTemporaryTableNameSchema() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->setTableName('foo.bar'); + + $this->assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName()); + } + + public function testDefaultTableName() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + // When table's name is not given + $primaryTable = array(); + $cm->setPrimaryTable($primaryTable); + + $this->assertEquals('CmsUser', $cm->getTableName()); + $this->assertEquals('CmsUser', $cm->table['name']); + + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + // When joinTable's name is not given + $cm->mapManyToMany(array( + 'fieldName' => 'user', + 'targetEntity' => 'CmsUser', + 'inversedBy' => 'users', + 'joinTable' => array('joinColumns' => array(array('referencedColumnName' => 'id')), + 'inverseJoinColumns' => array(array('referencedColumnName' => 'id'))))); + $this->assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']); + } + + public function testDefaultJoinColumnName() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + // this is really dirty, but it's the simpliest way to test whether + // joinColumn's name will be automatically set to user_id + $cm->mapOneToOne(array( + 'fieldName' => 'user', + 'targetEntity' => 'CmsUser', + 'joinColumns' => array(array('referencedColumnName' => 'id')))); + $this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); + + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapManyToMany(array( + 'fieldName' => 'user', + 'targetEntity' => 'CmsUser', + 'inversedBy' => 'users', + 'joinTable' => array('name' => 'user_CmsUser', + 'joinColumns' => array(array('referencedColumnName' => 'id')), + 'inverseJoinColumns' => array(array('referencedColumnName' => 'id'))))); + $this->assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']); + $this->assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']); + } + + /** + * @group DDC-886 + */ + public function testSetMultipleIdentifierSetsComposite() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapField(array('fieldName' => 'name')); + $cm->mapField(array('fieldName' => 'username')); + + $cm->setIdentifier(array('name', 'username')); + $this->assertTrue($cm->isIdentifierComposite); + } + + /** + * @group DDC-944 + */ + public function testMappingNotFound() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "No mapping found for field 'foo' on class 'Doctrine\Tests\Models\CMS\CmsUser'."); + $cm->getFieldMapping('foo'); + } + + /** + * @group DDC-961 + */ + public function testJoinTableMappingDefaults() + { + $cm = new ClassMetadata('DoctrineGlobal_Article'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapManyToMany(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsUser')); + + $this->assertEquals('doctrineglobal_article_cmsuser', $cm->associationMappings['author']['joinTable']['name']); + } + + /** + * @group DDC-117 + */ + public function testMapIdentifierAssociation() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapOneToOne(array( + 'fieldName' => 'article', + 'id' => true, + 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', + 'joinColumns' => array(), + )); + + $this->assertTrue($cm->containsForeignIdentifier, "Identifier Association should set 'containsForeignIdentifier' boolean flag."); + $this->assertEquals(array("article"), $cm->identifier); + } + + /** + * @group DDC-117 + */ + public function testOrphanRemovalIdentifierAssociation() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'The orphan removal option is not allowed on an association that'); + $cm->mapOneToOne(array( + 'fieldName' => 'article', + 'id' => true, + 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', + 'orphanRemoval' => true, + 'joinColumns' => array(), + )); + } + + /** + * @group DDC-117 + */ + public function testInverseIdentifierAssocation() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'An inverse association is not allowed to be identifier in'); + $cm->mapOneToOne(array( + 'fieldName' => 'article', + 'id' => true, + 'mappedBy' => 'details', // INVERSE! + 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', + 'joinColumns' => array(), + )); + } + + /** + * @group DDC-117 + */ + public function testIdentifierAssocationManyToMany() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + + $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, + 'targetEntity' => 'Doctrine\Tests\Models\DDC117\DDC117Article', + 'joinColumns' => array(), + )); + } + + /** + * @group DDC-996 + */ + 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'."); + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $cm->mapField(array('fieldName' => '')); + } + + public function testRetrievalOfNamedQueries() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + + $this->assertEquals(0, count($cm->getNamedQueries())); + + $cm->addNamedQuery(array( + 'name' => 'userById', + 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' + )); + + $this->assertEquals(1, count($cm->getNamedQueries())); + } + + public function testExistanceOfNamedQuery() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + + $cm->addNamedQuery(array( + 'name' => 'all', + 'query' => 'SELECT u FROM __CLASS__ u' + )); + + $this->assertTrue($cm->hasNamedQuery('all')); + $this->assertFalse($cm->hasNamedQuery('userById')); + } + + public function testRetrieveOfNamedQuery() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + + $cm->addNamedQuery(array( + 'name' => 'userById', + 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' + )); + + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', $cm->getNamedQuery('userById')); + } + + public function testNamingCollisionNamedQueryShouldThrowException() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + + $cm->addNamedQuery(array( + 'name' => 'userById', + 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' + )); + + $cm->addNamedQuery(array( + 'name' => 'userById', + 'query' => 'SELECT u FROM __CLASS__ u WHERE u.id = ?1' + )); + } + + /** + * @group DDC-1068 + */ + public function testClassCaseSensitivity() + { + $user = new \Doctrine\Tests\Models\CMS\CmsUser(); + $cm = new ClassMetadata('DOCTRINE\TESTS\MODELS\CMS\CMSUSER'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name); + } + + /** + * @group DDC-659 + */ + public function testLifecycleCallbackNotFound() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\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."); + $cm->validateLifecycleCallbacks(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + } + + /** + * @group ImproveErrorMessages + */ + public function testTargetEntityNotFound() + { + $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\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'."); + $cm->validateAssocations(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php new file mode 100644 index 0000000..2383db6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php @@ -0,0 +1,96 @@ +getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver1->expects($this->never()) + ->method('loadMetadataForClass'); + $driver1->expectS($this->never()) + ->method('isTransient'); + + $driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver2->expects($this->at(0)) + ->method('loadMetadataForClass') + ->with($this->equalTo($className), $this->equalTo($classMetadata)); + $driver2->expects($this->at(1)) + ->method('isTransient') + ->with($this->equalTo($className)) + ->will($this->returnValue( true )); + + $chain->addDriver($driver1, 'Doctrine\Tests\Models\Company'); + $chain->addDriver($driver2, 'Doctrine\Tests\ORM\Mapping'); + + $chain->loadMetadataForClass($className, $classMetadata); + + $this->assertTrue( $chain->isTransient($className) ); + } + + public function testLoadMetadata_NoDelegatorFound_ThrowsMappingException() + { + $className = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity'; + $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); + + $chain = new DriverChain(); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); + $chain->loadMetadataForClass($className, $classMetadata); + } + + public function testGatherAllClassNames() + { + $className = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity'; + $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); + + $chain = new DriverChain(); + + $driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver1->expects($this->once()) + ->method('getAllClassNames') + ->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); + + $driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver2->expects($this->once()) + ->method('getAllClassNames') + ->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz'))); + + $chain->addDriver($driver1, 'Doctrine\Tests\Models\Company'); + $chain->addDriver($driver2, 'Doctrine\Tests\ORM\Mapping'); + + $this->assertEquals(array( + 'Doctrine\Tests\Models\Company\Foo', + 'Doctrine\Tests\ORM\Mapping\Bar', + 'Doctrine\Tests\ORM\Mapping\Baz' + ), $chain->getAllClassNames()); + } + + /** + * @group DDC-706 + */ + public function testIsTransient() + { + $chain = new DriverChain(); + $chain->addDriver($this->createAnnotationDriver(), 'Doctrine\Tests\Models\CMS'); + + $this->assertTrue($chain->isTransient('stdClass'), "stdClass isTransient"); + $this->assertFalse($chain->isTransient('Doctrine\Tests\Models\CMS\CmsUser'), "CmsUser is not Transient"); + } +} + +class DriverChainEntity +{ + +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php new file mode 100644 index 0000000..b346973 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php @@ -0,0 +1,31 @@ +addMappingSource(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'); + + $exporter = $cme->getExporter('php', $path); + $exporter->setMetadatas($cme->getMetadatas()); + $exporter->export(); + */ + + return new PHPDriver($path); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php new file mode 100644 index 0000000..1a5a207 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php @@ -0,0 +1,17 @@ +. +*/ + +namespace Doctrine\Tests\ORM\Mapping\Symfony; + +/** + * @group DDC-1418 + */ +abstract class AbstractDriverTest extends \PHPUnit_Framework_TestCase +{ + public function testFindMappingFile() + { + $driver = $this->getDriver(array( + 'MyNamespace\MySubnamespace\EntityFoo' => 'foo', + 'MyNamespace\MySubnamespace\Entity' => $this->dir, + )); + + touch($filename = $this->dir.'/Foo'.$this->getFileExtension()); + $this->assertEquals($filename, $this->invoke($driver, '_findMappingFile', array('MyNamespace\MySubnamespace\Entity\Foo'))); + } + + public function testFindMappingFileInSubnamespace() + { + $driver = $this->getDriver(array( + 'MyNamespace\MySubnamespace\Entity' => $this->dir, + )); + + touch($filename = $this->dir.'/Foo.Bar'.$this->getFileExtension()); + $this->assertEquals($filename, $this->invoke($driver, '_findMappingFile', array('MyNamespace\MySubnamespace\Entity\Foo\Bar'))); + } + + public function testFindMappingFileNamespacedFoundFileNotFound() + { + $this->setExpectedException( + 'Doctrine\ORM\Mapping\MappingException', + "No mapping file found named '".$this->dir."/Foo".$this->getFileExtension()."' for class 'MyNamespace\MySubnamespace\Entity\Foo'." + ); + + $driver = $this->getDriver(array( + 'MyNamespace\MySubnamespace\Entity' => $this->dir, + )); + + $this->invoke($driver, '_findMappingFile', array('MyNamespace\MySubnamespace\Entity\Foo')); + } + + public function testFindMappingNamespaceNotFound() + { + $this->setExpectedException( + 'Doctrine\ORM\Mapping\MappingException', + "No mapping file found named 'Foo".$this->getFileExtension()."' for class 'MyOtherNamespace\MySubnamespace\Entity\Foo'." + ); + + $driver = $this->getDriver(array( + 'MyNamespace\MySubnamespace\Entity' => $this->dir, + )); + + $this->invoke($driver, '_findMappingFile', array('MyOtherNamespace\MySubnamespace\Entity\Foo')); + } + + protected function setUp() + { + $this->dir = sys_get_temp_dir().'/abstract_driver_test'; + @mkdir($this->dir, 0777, true); + } + + protected function tearDown() + { + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->dir), \RecursiveIteratorIterator::CHILD_FIRST); + + foreach ($iterator as $path) { + if ($path->isDir()) { + @rmdir($path); + } else { + @unlink($path); + } + } + + @rmdir($this->dir); + } + + 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/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php new file mode 100644 index 0000000..5908b67 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/XmlDriverTest.php @@ -0,0 +1,40 @@ +. +*/ + +namespace Doctrine\Tests\ORM\Mapping\Symfony; + +use \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver; + +/** + * @group DDC-1418 + */ +class XmlDriverTest extends AbstractDriverTest +{ + protected function getFileExtension() + { + return '.orm.xml'; + } + + protected function getDriver(array $paths = array()) + { + $driver = new SimplifiedXmlDriver(array_flip($paths)); + + return $driver; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php new file mode 100644 index 0000000..c5d8d1c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/Symfony/YamlDriverTest.php @@ -0,0 +1,40 @@ +. +*/ + +namespace Doctrine\Tests\ORM\Mapping\Symfony; + +use \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver; + +/** + * @group DDC-1418 + */ +class YamlDriverTest extends AbstractDriverTest +{ + protected function getFileExtension() + { + return '.orm.yml'; + } + + protected function getDriver(array $paths = array()) + { + $driver = new SimplifiedYamlDriver(array_flip($paths)); + + return $driver; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php new file mode 100644 index 0000000..6a852bc --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -0,0 +1,96 @@ +_loadDriver(); + + $class = new ClassMetadata($className); + $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $mappingDriver->loadMetadataForClass($className, $class); + + $expectedMap = array( + "foo" => "Doctrine\Tests\ORM\Mapping\CTIFoo", + "bar" => "Doctrine\Tests\ORM\Mapping\CTIBar", + "baz" => "Doctrine\Tests\ORM\Mapping\CTIBaz", + ); + + $this->assertEquals(3, count($class->discriminatorMap)); + $this->assertEquals($expectedMap, $class->discriminatorMap); + } + + public function testIdentifierWithAssociationKey() + { + $driver = $this->_loadDriver(); + $em = $this->_getTestEntityManager(); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + + $em->getConfiguration()->setMetadataDriverImpl($driver); + $factory->setEntityManager($em); + + $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC117\DDC117Translation'); + + $this->assertEquals(array('language', 'article'), $class->identifier); + $this->assertArrayHasKey('article', $class->associationMappings); + + $this->assertArrayHasKey('id', $class->associationMappings['article']); + $this->assertTrue($class->associationMappings['article']['id']); + } + + /** + * @group DDC-1468 + * + * @expectedException Doctrine\ORM\Mapping\MappingException + * @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'. + */ + public function testInvalidMappingFileException() + { + $this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel'); + } + + /** + * @param string $xmlMappingFile + * @dataProvider dataValidSchema + */ + public function testValidateXmlSchema($xmlMappingFile) + { + $xsdSchemaFile = __DIR__ . "/../../../../../doctrine-mapping.xsd"; + + $dom = new \DOMDocument('UTF-8'); + $dom->load($xmlMappingFile); + $this->assertTrue($dom->schemaValidate($xsdSchemaFile)); + } + + static public function dataValidSchema() + { + return array( + array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml"), + array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml"), + array(__DIR__ . "/xml/CatNoId.dcm.xml"), + ); + } +} + +class CTI +{ + public $id; +} + +class CTIFoo extends CTI {} +class CTIBar extends CTI {} +class CTIBaz extends CTI {} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php new file mode 100644 index 0000000..2757259 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -0,0 +1,57 @@ +markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + } + + return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'); + } + + /** + * @group DDC-671 + * + * Entities for this test are in AbstractMappingDriverTest + */ + public function testJoinTablesWithMappedSuperclassForYamlDriver() + { + $yamlDriver = $this->_loadDriver(); + $yamlDriver->addPaths(array(__DIR__ . DIRECTORY_SEPARATOR . 'yaml')); + + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl($yamlDriver); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory->setEntityManager($em); + + $classPage = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\File'); + $classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File'); + $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\File', $classPage->associationMappings['parentDirectory']['sourceEntity']); + + $classDirectory = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\Directory'); + $classDirectory = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\Directory'); + $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']); + } + + /** + * @group DDC-1468 + * + * @expectedException Doctrine\ORM\Mapping\MappingException + * @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'. + */ + public function testInvalidMappingFileException() + { + $this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel'); + } + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php new file mode 100644 index 0000000..56a9963 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.php @@ -0,0 +1,12 @@ +mapField(array( + 'id' => true, + 'fieldName' => 'id', +)); +$metadata->mapField(array( + 'fieldName' => 'name' +)); +$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php new file mode 100644 index 0000000..ad8b86d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.php @@ -0,0 +1,5 @@ +mapField(array( + 'fieldName' => 'serialNumber', + 'type' => 'string', +)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php new file mode 100644 index 0000000..1318333 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.php @@ -0,0 +1,5 @@ +mapField(array( + 'fieldName' => 'creditCardNumber', + 'type' => 'string', +)); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php new file mode 100644 index 0000000..1d1f551 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.Models.DDC869.DDC869Payment.php @@ -0,0 +1,17 @@ +mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'type' => 'integer', + 'columnName' => 'id', +)); +$metadata->mapField(array( + 'fieldName' => 'value', + 'type' => 'float', + )); +$metadata->isMappedSuperclass = true; +$metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); +$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php new file mode 100644 index 0000000..97f4624 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.DDC1170Entity.php @@ -0,0 +1,16 @@ +mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'columnDefinition' => 'INT unsigned NOT NULL', +)); + +$metadata->mapField(array( + 'fieldName' => 'value', + 'columnDefinition' => 'VARCHAR(255) NOT NULL' +)); + +$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php new file mode 100644 index 0000000..33020aa --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/php/Doctrine.Tests.ORM.Mapping.User.php @@ -0,0 +1,119 @@ +setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); +$metadata->setPrimaryTable(array( + 'name' => 'cms_users', + )); +$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); +$metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); +$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist'); +$metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist'); +$metadata->addNamedQuery(array( + 'name' => 'all', + 'query' => 'SELECT u FROM __CLASS__ u' +)); +$metadata->mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'type' => 'integer', + 'columnName' => 'id', + )); +$metadata->mapField(array( + 'fieldName' => 'name', + 'type' => 'string', + 'length' => 50, + 'unique' => true, + 'nullable' => true, + 'columnName' => 'name', + )); +$metadata->mapField(array( + 'fieldName' => 'email', + 'type' => 'string', + 'columnName' => 'user_email', + 'columnDefinition' => 'CHAR(32) NOT NULL', + )); +$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); +$metadata->mapOneToOne(array( + 'fieldName' => 'address', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Address', + 'cascade' => + array( + 0 => 'remove', + ), + 'mappedBy' => NULL, + 'inversedBy' => 'user', + 'joinColumns' => + array( + 0 => + array( + 'name' => 'address_id', + 'referencedColumnName' => 'id', + 'onDelete' => 'CASCADE', + ), + ), + 'orphanRemoval' => false, + )); +$metadata->mapOneToMany(array( + 'fieldName' => 'phonenumbers', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber', + 'cascade' => + array( + 1 => 'persist', + ), + 'mappedBy' => 'user', + 'orphanRemoval' => true, + 'orderBy' => + array( + 'number' => 'ASC', + ), + )); +$metadata->mapManyToMany(array( + 'fieldName' => 'groups', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Group', + 'cascade' => + array( + 0 => 'remove', + 1 => 'persist', + 2 => 'refresh', + 3 => 'merge', + 4 => 'detach', + ), + 'mappedBy' => NULL, + 'joinTable' => + array( + 'name' => 'cms_users_groups', + 'joinColumns' => + array( + 0 => + array( + 'name' => 'user_id', + 'referencedColumnName' => 'id', + 'unique' => false, + 'nullable' => false, + ), + ), + 'inverseJoinColumns' => + array( + 0 => + array( + 'name' => 'group_id', + 'referencedColumnName' => 'id', + 'columnDefinition' => 'INT NULL', + ), + ), + ), + 'orderBy' => NULL, + )); +$metadata->table['uniqueConstraints'] = array( + 'search_idx' => array('columns' => array('name', 'user_email')), +); +$metadata->table['indexes'] = array( + 'name_idx' => array('columns' => array('name')), 0 => array('columns' => array('user_email')) +); +$metadata->setSequenceGeneratorDefinition(array( + 'sequenceName' => 'tablename_seq', + 'allocationSize' => 100, + 'initialValue' => 1, + )); \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml new file mode 100644 index 0000000..6025d35 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml new file mode 100644 index 0000000..c0df088 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC117.DDC117Translation.dcm.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml new file mode 100644 index 0000000..29b5f1d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml new file mode 100644 index 0000000..05e2540 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml new file mode 100644 index 0000000..daf01f0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml new file mode 100644 index 0000000..be9f760 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml new file mode 100644 index 0000000..36af855 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml new file mode 100644 index 0000000..6c2a235 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.Animal.dcm.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml new file mode 100644 index 0000000..14abaef --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml new file mode 100644 index 0000000..9f5ad7f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml new file mode 100644 index 0000000..f116fb0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml new file mode 100644 index 0000000..3437a9b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC1476.DDC1476EntityWithDefaultFieldType.dcm.yml @@ -0,0 +1,8 @@ +Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType: + type: entity + id: + id: + generator: + strategy: NONE + fields: + name: \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml new file mode 100644 index 0000000..94f2698 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869ChequePayment.dcm.yml @@ -0,0 +1,5 @@ +Doctrine\Tests\Models\DDC869\DDC869ChequePayment: + type: entity + fields: + serialNumber: + type: string \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml new file mode 100644 index 0000000..153a99f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869CreditCardPayment.dcm.yml @@ -0,0 +1,5 @@ +Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment: + type: entity + fields: + creditCardNumber: + type: string \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml new file mode 100644 index 0000000..b776664 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DDC869.DDC869Payment.dcm.yml @@ -0,0 +1,12 @@ +Doctrine\Tests\Models\DDC869\DDC869Payment: + type: mappedSuperclass + repositoryClass : Doctrine\Tests\Models\DDC869\DDC869PaymentRepository + id: + id: + type: integer + unsigned: true + generator: + strategy: AUTO + fields: + value: + type: float \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml new file mode 100644 index 0000000..9c573a5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.AbstractContentItem.dcm.yml @@ -0,0 +1,14 @@ +Doctrine\Tests\Models\DirectoryTree\AbstractContentItem: + type: mappedSuperclass + id: + id: + type: integer + unsigned: true + generator: + strategy: AUTO + fields: + name: + type: string + manyToOne: + parentDirectory: + targetEntity: Doctrine\Tests\Models\DirectoryTree\Directory diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml new file mode 100644 index 0000000..d2b93d4 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.Directory.dcm.yml @@ -0,0 +1,6 @@ +Doctrine\Tests\Models\DirectoryTree\Directory: + type: entity + fields: + path: + type: string + length: 255 diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml new file mode 100644 index 0000000..cbc8edf --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.DirectoryTree.File.dcm.yml @@ -0,0 +1,6 @@ +Doctrine\Tests\Models\DirectoryTree\File: + type: entity + fields: + extension: + type: string + length: 10 diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml new file mode 100644 index 0000000..64f74b5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml @@ -0,0 +1,13 @@ +\stdClass: + type: entity + id: + id: + type: integer + unsigned: true + generator: + strategy: AUTO + fields: + array: + type: array + object: + type: object \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml new file mode 100644 index 0000000..cd6ec29 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Animal.dcm.yml @@ -0,0 +1,6 @@ +Doctrine\Tests\ORM\Mapping\Animal: + type: entity + inheritanceType: SINGLE_TABLE + discriminatorMap: + cat: Cat + dog: Dog \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml new file mode 100644 index 0000000..8b2ac51 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.DDC1170Entity.dcm.yml @@ -0,0 +1,10 @@ +Doctrine\Tests\ORM\Mapping\DDC1170Entity: + type: entity + id: + id: + columnDefinition: INT unsigned NOT NULL + generator: + strategy: NONE + fields: + value: + columnDefinition: VARCHAR(255) NOT NULL \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml new file mode 100644 index 0000000..3334749 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.User.dcm.yml @@ -0,0 +1,68 @@ +Doctrine\Tests\ORM\Mapping\User: + type: entity + table: cms_users + namedQueries: + all: SELECT u FROM __CLASS__ u + id: + id: + type: integer + generator: + strategy: AUTO + sequenceGenerator: + sequenceName: tablename_seq + allocationSize: 100 + initialValue: 1 + fields: + name: + type: string + length: 50 + nullable: true + unique: true + email: + type: string + column: user_email + columnDefinition: CHAR(32) NOT NULL + oneToOne: + address: + targetEntity: Address + inversedBy: user + joinColumn: + name: address_id + referencedColumnName: id + onDelete: CASCADE + cascade: [ remove ] + oneToMany: + phonenumbers: + targetEntity: Phonenumber + orphanRemoval: true + mappedBy: user + orderBy: + number: ASC + cascade: [ persist ] + manyToMany: + groups: + targetEntity: Group + joinTable: + name: cms_users_groups + joinColumns: + user_id: + referencedColumnName: id + nullable: false + unique: false + inverseJoinColumns: + group_id: + referencedColumnName: id + columnDefinition: INT NULL + cascade: + - all + lifecycleCallbacks: + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] + uniqueConstraints: + search_idx: + columns: name,user_email + indexes: + name_idx: + columns: name + 0: + columns: user_email \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php new file mode 100644 index 0000000..07a202e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/HydrationPerformanceTest.php @@ -0,0 +1,461 @@ + 0.7 seconds] + * + * MAXIMUM TIME: 1 second + */ + public function testSimpleQueryScalarHydrationPerformance10000Rows() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('u', 'u__username', 'username'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ) + ); + + for ($i = 4; $i < 10000; ++$i) { + $resultSet[] = array( + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + ); + } + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em); + + $this->setMaxRunningTime(1); + $s = microtime(true); + $result = $hydrator->hydrateAll($stmt, $rsm); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } + + /** + * Times for comparison: + * + * [romanb: 10000 rows => 1 second] + * + * MAXIMUM TIME: 2 seconds + */ + public function testSimpleQueryArrayHydrationPerformance10000Rows() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('u', 'u__username', 'username'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ) + ); + + for ($i = 4; $i < 10000; ++$i) { + $resultSet[] = array( + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + ); + } + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + + $this->setMaxRunningTime(2); + $s = microtime(true); + $result = $hydrator->hydrateAll($stmt, $rsm); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } + + /** + * Times for comparison: + * + * [romanb: 10000 rows => 1.4 seconds] + * + * MAXIMUM TIME: 3 seconds + */ + public function testMixedQueryFetchJoinArrayHydrationPerformance10000Rows() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('u', 'u__username', 'username'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91' + ) + ); + + for ($i = 4; $i < 10000; ++$i) { + $resultSet[] = array( + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + 'sclr0' => 'JWAGE' . $i, + 'p__phonenumber' => '91' + ); + } + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ArrayHydrator($this->_em); + + $this->setMaxRunningTime(3); + $s = microtime(true); + $result = $hydrator->hydrateAll($stmt, $rsm); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } + + /** + * [romanb: 10000 rows => 1.5 seconds] + * + * MAXIMUM TIME: 3 seconds + */ + public function testSimpleQueryPartialObjectHydrationPerformance10000Rows() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('u', 'u__username', 'username'); + $rsm->addFieldResult('u', 'u__name', 'name'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + ) + ); + + for ($i = 4; $i < 10000; ++$i) { + $resultSet[] = array( + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + ); + } + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + + $this->setMaxRunningTime(3); + $s = microtime(true); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } + + /** + * [romanb: 10000 rows => 3 seconds] + * + * MAXIMUM TIME: 4.5 seconds + */ + public function testSimpleQueryFullObjectHydrationPerformance10000Rows() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('u', 'u__username', 'username'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsAddress', + 'a', + 'u', + 'address' + ); + $rsm->addFieldResult('a', 'a__id', 'id'); + //$rsm->addFieldResult('a', 'a__country', 'country'); + //$rsm->addFieldResult('a', 'a__zip', 'zip'); + //$rsm->addFieldResult('a', 'a__city', 'city'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'a__id' => '1' + ) + ); + + for ($i = 2; $i < 10000; ++$i) { + $resultSet[] = array( + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + 'a__id' => $i + ); + } + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + + $this->setMaxRunningTime(5); + $s = microtime(true); + $result = $hydrator->hydrateAll($stmt, $rsm); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } + + /** + * [romanb: 2000 rows => 0.4 seconds] + * + * MAXIMUM TIME: 1 second + */ + public function testMixedQueryFetchJoinPartialObjectHydrationPerformance2000Rows() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('u', 'u__username', 'username'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + ), + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '43', + ), + array( + 'u__id' => '2', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'JWAGE', + 'p__phonenumber' => '91' + ) + ); + + for ($i = 4; $i < 2000; ++$i) { + $resultSet[] = array( + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + 'sclr0' => 'JWAGE' . $i, + 'p__phonenumber' => '91' + ); + } + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + + $this->setMaxRunningTime(1); + $s = microtime(true); + $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } + + /** + * [romanb: 2000 rows => 0.6 seconds] + * + * MAXIMUM TIME: 1 second + */ + public function testMixedQueryFetchJoinFullObjectHydrationPerformance2000Rows() + { + $rsm = new ResultSetMapping; + $rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'p', + 'u', + 'phonenumbers' + ); + $rsm->addFieldResult('u', 'u__id', 'id'); + $rsm->addFieldResult('u', 'u__status', 'status'); + $rsm->addFieldResult('u', 'u__username', 'username'); + $rsm->addFieldResult('u', 'u__name', 'name'); + $rsm->addScalarResult('sclr0', 'nameUpper'); + $rsm->addFieldResult('p', 'p__phonenumber', 'phonenumber'); + $rsm->addJoinedEntityResult( + 'Doctrine\Tests\Models\CMS\CmsAddress', + 'a', + 'u', + 'address' + ); + $rsm->addFieldResult('a', 'a__id', 'id'); + + // Faked result set + $resultSet = array( + //row1 + array( + 'u__id' => '1', + 'u__status' => 'developer', + 'u__username' => 'romanb', + 'u__name' => 'Roman', + 'sclr0' => 'ROMANB', + 'p__phonenumber' => '42', + 'a__id' => '1' + ) + ); + + for ($i = 2; $i < 2000; ++$i) { + $resultSet[] = array( + 'u__id' => $i, + 'u__status' => 'developer', + 'u__username' => 'jwage', + 'u__name' => 'Jonathan', + 'sclr0' => 'JWAGE' . $i, + 'p__phonenumber' => '91', + 'a__id' => $i + ); + } + + $stmt = new HydratorMockStatement($resultSet); + $hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em); + + $this->setMaxRunningTime(1); + $s = microtime(true); + $result = $hydrator->hydrateAll($stmt, $rsm); + $e = microtime(true); + echo __FUNCTION__ . " - " . ($e - $s) . " seconds" . PHP_EOL; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php new file mode 100644 index 0000000..1c19264 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InheritancePersisterPerformanceTest.php @@ -0,0 +1,66 @@ +useModelSet('company'); + parent::setUp(); + } + + public function testCompanyContract() + { + $person = new \Doctrine\Tests\Models\Company\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->setFixPrice(1000); + $fix->setSalesPerson($person); + $fix->markCompleted(); + $this->_em->persist($fix); + + $flex = new \Doctrine\Tests\Models\Company\CompanyFlexContract(); + $flex->setSalesPerson($person); + $flex->setHoursWorked(100); + $flex->setPricePerHour(100); + $flex->markCompleted(); + $this->_em->persist($flex); + + $ultra = new \Doctrine\Tests\Models\Company\CompanyFlexUltraContract(); + $ultra->setSalesPerson($person); + $ultra->setHoursWorked(150); + $ultra->setPricePerHour(150); + $ultra->setMaxPrice(7000); + $this->_em->persist($ultra); + } + + $this->_em->flush(); + $this->_em->clear(); + + $start = microtime(true); + $contracts = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyContract')->findAll(); + echo "99 CompanyContract: " . number_format(microtime(true) - $start, 6) . "\n"; + $this->assertEquals(99, count($contracts)); + + $this->_em->clear(); + + $start = microtime(true); + $contracts = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyContract')->findAll(); + echo "99 CompanyContract: " . number_format(microtime(true) - $start, 6) . "\n"; + $this->assertEquals(99, count($contracts)); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php new file mode 100644 index 0000000..1c378df --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php @@ -0,0 +1,56 @@ +useModelSet('cms'); + parent::setUp(); + } + + /** + * [romanb: 10000 objects in ~8 seconds] + */ + public function testInsertPerformance() + { + $s = microtime(true); + + $conn = $this->_em->getConnection(); + + $this->setMaxRunningTime(10); + + //echo "Memory usage before: " . (memory_get_usage() / 1024) . " KB" . PHP_EOL; + + $batchSize = 20; + for ($i=1; $i<=10000; ++$i) { + $user = new CmsUser; + $user->status = 'user'; + $user->username = 'user' . $i; + $user->name = 'Mr.Smith-' . $i; + $this->_em->persist($user); + if (($i % $batchSize) == 0) { + $this->_em->flush(); + $this->_em->clear(); + } + } + + //gc_collect_cycles(); + //echo "Memory usage after: " . (memory_get_usage() / 1024) . " KB" . PHP_EOL; + + $e = microtime(true); + + echo ' Inserted 10000 objects in ' . ($e - $s) . ' seconds' . PHP_EOL; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php new file mode 100644 index 0000000..ec43268 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/PersisterPerformanceTest.php @@ -0,0 +1,121 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testFindCmsArticle() + { + $author = new CmsUser(); + $author->name = "beberlei"; + $author->status = "active"; + $author->username = "beberlei"; + $this->_em->persist($author); + + $ids = array(); + for ($i = 0; $i < 100; $i++) { + $article = new CmsArticle(); + $article->text = "foo"; + $article->topic = "bar"; + $article->user = $author; + $this->_em->persist($article); + $ids[] = $article; + } + $this->_em->flush(); + $this->_em->clear(); + + $start = microtime(true); + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->findAll(); + echo "100 CmsArticle findAll(): " . number_format(microtime(true) - $start, 6) . "\n"; + + $this->_em->clear(); + + $start = microtime(true); + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->findAll(); + echo "100 CmsArticle findAll(): " . number_format(microtime(true) - $start, 6) . "\n"; + + $this->_em->clear(); + + $start = microtime(true); + for ($i = 0; $i < 100; $i++) { + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->find($ids[$i]->id); + } + echo "100 CmsArticle find(): " . number_format(microtime(true) - $start, 6) . "\n"; + + $this->_em->clear(); + + $start = microtime(true); + for ($i = 0; $i < 100; $i++) { + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle')->find($ids[$i]->id); + } + echo "100 CmsArticle find(): " . number_format(microtime(true) - $start, 6) . "\n"; + } + + public function testFindCmsGroup() + { + for ($i = 0; $i < 100; $i++) { + $group = new CmsGroup(); + $group->name = "foo" . $i; + $this->_em->persist($group); + } + $this->_em->flush(); + $this->_em->clear(); + + $start = microtime(true); + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); + echo "100 CmsGroup: " . number_format(microtime(true) - $start, 6) . "\n"; + + $this->_em->clear(); + + $start = microtime(true); + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll(); + echo "100 CmsGroup: " . number_format(microtime(true) - $start, 6) . "\n"; + } + + public function testFindCmsUser() + { + for ($i = 0; $i < 100; $i++) { + $user = new CmsUser(); + $user->name = "beberlei"; + $user->status = "active"; + $user->username = "beberlei".$i; + $this->_em->persist($user); + } + + $this->_em->flush(); + $this->_em->clear(); + + $start = microtime(true); + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); + echo "100 CmsUser: " . number_format(microtime(true) - $start, 6) . "\n"; + + $this->_em->clear(); + + $start = microtime(true); + $articles = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll(); + echo "100 CmsUser: " . number_format(microtime(true) - $start, 6) . "\n"; + } +} + + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php new file mode 100644 index 0000000..9320828 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Performance/UnitOfWorkPerformanceTest.php @@ -0,0 +1,51 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testComputeChanges() + { + $n = 100; + + $users = array(); + for ($i=1; $i<=$n; ++$i) { + $user = new CmsUser; + $user->status = 'user'; + $user->username = 'user' . $i; + $user->name = 'Mr.Smith-' . $i; + $this->_em->persist($user); + $users[] = $user; + } + $this->_em->flush(); + + + foreach ($users AS $user) { + $user->status = 'other'; + $user->username = $user->username . '++'; + $user->name = str_replace('Mr.', 'Mrs.', $user->name); + } + + $s = microtime(true); + $this->_em->flush(); + $e = microtime(true); + + echo ' Compute ChangeSet '.$n.' objects in ' . ($e - $s) . ' seconds' . PHP_EOL; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php new file mode 100644 index 0000000..fd0dffb --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -0,0 +1,37 @@ + + */ +class PersistentCollectionTest extends \Doctrine\Tests\OrmTestCase +{ + private $_connectionMock; + private $_emMock; + + protected function setUp() + { + parent::setUp(); + // SUT + $this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock()); + $this->_emMock = EntityManagerMock::create($this->_connectionMock); + } + + public function testCanBePutInLazyLoadingMode() + { + $class = $this->_emMock->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct'); + $collection = new PersistentCollection($this->_emMock, $class, new ArrayCollection); + $collection->setInitialized(false); + $this->assertFalse($collection->isInitialized()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php new file mode 100644 index 0000000..d1fe9a6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterTypeValueSqlTest.php @@ -0,0 +1,79 @@ +_em = $this->_getTestEntityManager(); + + $this->_persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata("Doctrine\Tests\Models\CustomType\CustomTypeParent")); + } + + public function testGetInsertSQLUsesTypeValuesSQL() + { + $method = new \ReflectionMethod($this->_persister, '_getInsertSQL'); + $method->setAccessible(true); + + $sql = $method->invoke($this->_persister); + + $this->assertEquals('INSERT INTO customtype_parents (customInteger, child_id) VALUES (ABS(?), ?)', $sql); + } + + public function testUpdateUsesTypeValuesSQL() + { + $child = new CustomTypeChild(); + + $parent = new CustomTypeParent(); + $parent->customInteger = 1; + $parent->child = $child; + + $this->_em->getUnitOfWork()->registerManaged($parent, array('id' => 1), array('customInteger' => 0, 'child' => null)); + $this->_em->getUnitOfWork()->registerManaged($child, array('id' => 1), array()); + + $this->_em->getUnitOfWork()->propertyChanged($parent, 'customInteger', 0, 1); + $this->_em->getUnitOfWork()->propertyChanged($parent, 'child', null, $child); + + $this->_persister->update($parent); + + $executeUpdates = $this->_em->getConnection()->getExecuteUpdates(); + + $this->assertEquals('UPDATE customtype_parents SET customInteger = ABS(?), child_id = ? WHERE id = ?', $executeUpdates[0]['query']); + } + + public function testGetSelectConditionSQLUsesTypeValuesSQL() + { + $method = new \ReflectionMethod($this->_persister, '_getSelectConditionSQL'); + $method->setAccessible(true); + + $sql = $method->invoke($this->_persister, array('customInteger' => 1, 'child' => 1)); + + $this->assertEquals('t0.customInteger = ABS(?) AND t0.child_id = ?', $sql); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/AutoloaderTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/AutoloaderTest.php new file mode 100644 index 0000000..ff5bf0f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/AutoloaderTest.php @@ -0,0 +1,62 @@ +. + */ + +namespace Doctrine\Tests\ORM\Proxy; + +use Doctrine\Tests\OrmTestCase; +use Doctrine\ORM\Proxy\Autoloader; + +/** + * @group DDC-1698 + */ +class AutoloaderTest extends OrmTestCase +{ + static public function dataResolveFile() + { + return array( + array('/tmp', 'MyProxy', 'MyProxy\__CG__\RealClass', '/tmp/__CG__RealClass.php'), + array('/tmp', 'MyProxy\Subdir', 'MyProxy\Subdir\__CG__\RealClass', '/tmp/__CG__RealClass.php'), + array('/tmp', 'MyProxy', 'MyProxy\__CG__\Other\RealClass', '/tmp/__CG__OtherRealClass.php'), + ); + } + + /** + * @dataProvider dataResolveFile + */ + public function testResolveFile($proxyDir, $proxyNamespace, $className, $expectedProxyFile) + { + $actualProxyFile = Autoloader::resolveFile($proxyDir, $proxyNamespace, $className); + $this->assertEquals($expectedProxyFile, $actualProxyFile); + } + + public function testAutoload() + { + if (file_exists(sys_get_temp_dir() ."/AutoloaderTestClass.php")) { + unlink(sys_get_temp_dir() ."/AutoloaderTestClass.php"); + } + + $autoloader = Autoloader::register(sys_get_temp_dir(), 'ProxyAutoloaderTest', function($proxyDir, $proxyNamespace, $className) { + file_put_contents(sys_get_temp_dir() . "/AutoloaderTestClass.php", "assertTrue(class_exists('ProxyAutoloaderTest\AutoloaderTestClass', true)); + unlink(sys_get_temp_dir() ."/AutoloaderTestClass.php"); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php new file mode 100644 index 0000000..894d500 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php @@ -0,0 +1,204 @@ + + */ +class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase +{ + private $_connectionMock; + private $_uowMock; + private $_emMock; + + /** + * @var \Doctrine\ORM\Proxy\ProxyFactory + */ + private $_proxyFactory; + + protected function setUp() + { + parent::setUp(); + $this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock()); + $this->_emMock = EntityManagerMock::create($this->_connectionMock); + $this->_uowMock = new UnitOfWorkMock($this->_emMock); + $this->_emMock->setUnitOfWork($this->_uowMock); + // SUT + $this->_proxyFactory = new ProxyFactory($this->_emMock, __DIR__ . '/generated', 'Proxies', true); + } + + protected function tearDown() + { + foreach (new \DirectoryIterator(__DIR__ . '/generated') as $file) { + if (strstr($file->getFilename(), '.php')) { + unlink($file->getPathname()); + } + } + } + + public function testReferenceProxyDelegatesLoadingToThePersister() + { + $identifier = array('id' => 42); + $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; + $persister = $this->_getMockPersister(); + $this->_uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); + + $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $identifier); + + $persister->expects($this->atLeastOnce()) + ->method('load') + ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) + ->will($this->returnValue(new \stdClass())); // fake return of entity instance + + $proxy->getDescription(); + } + + public function testReferenceProxyExecutesLoadingOnlyOnce() + { + $identifier = array('id' => 42); + $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; + $persister = $this->_getMockPersister(); + $this->_uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); + $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $identifier); + + $persister->expects($this->atLeastOnce()) + ->method('load') + ->with($this->equalTo($identifier), $this->isInstanceOf($proxyClass)) + ->will($this->returnValue(new \stdClass())); // fake return of entity instance + $proxy->getDescription(); + $proxy->getProduct(); + } + + public function testReferenceProxyRespectsMethodsParametersTypeHinting() + { + $proxyClass = 'Proxies\DoctrineTestsModelsECommerceECommerceFeatureProxy'; + $persister = $this->_getMockPersister(); + $this->_uowMock->setEntityPersister('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $persister); + $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\ECommerce\ECommerceFeature', null); + + $method = new \ReflectionMethod(get_class($proxy), 'setProduct'); + $params = $method->getParameters(); + + $this->assertEquals(1, count($params)); + $this->assertEquals('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $params[0]->getClass()->getName()); + } + + /** + * Test that the proxy behaves in regard to methods like &foo() correctly + */ + public function testProxyRespectsMethodsWhichReturnValuesByReference() { + $proxy = $this->_proxyFactory->getProxy('Doctrine\Tests\Models\Forum\ForumEntry', null); + $method = new \ReflectionMethod(get_class($proxy), 'getTopicByReference'); + + $this->assertTrue($method->returnsReference()); + } + + public function testCreatesAssociationProxyAsSubclassOfTheOriginalOne() + { + $proxyClass = 'Proxies\__CG__\Doctrine\Tests\Models\ECommerce\ECommerceFeature'; + $this->assertTrue(is_subclass_of($proxyClass, 'Doctrine\Tests\Models\ECommerce\ECommerceFeature')); + } + + + public function testAllowsConcurrentCreationOfBothProxyTypes() + { + $referenceProxyClass = 'Proxies\DoctrineTestsModelsECommerceECommerceFeatureProxy'; + $associationProxyClass = 'Proxies\DoctrineTestsModelsECommerceECommerceFeatureAProxy'; + $this->assertNotEquals($referenceProxyClass, $associationProxyClass); + } + + public function testNonNamespacedProxyGeneration() + { + require_once dirname(__FILE__)."/fixtures/NonNamespacedProxies.php"; + + $className = "\DoctrineOrmTestEntity"; + $proxyName = "DoctrineOrmTestEntity"; + $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); + $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer')); + $classMetadata->setIdentifier(array('id')); + + $this->_proxyFactory->generateProxyClasses(array($classMetadata)); + + $classCode = file_get_contents(dirname(__FILE__)."/generated/__CG__".$proxyName.".php"); + + $this->assertNotContains("class DoctrineOrmTestEntity extends \\\\DoctrineOrmTestEntity", $classCode); + $this->assertContains("class DoctrineOrmTestEntity extends \\DoctrineOrmTestEntity", $classCode); + } + + public function testClassWithSleepProxyGeneration() + { + $className = "\Doctrine\Tests\ORM\Proxy\SleepClass"; + $proxyName = "DoctrineTestsORMProxySleepClass"; + $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); + $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer')); + $classMetadata->setIdentifier(array('id')); + + $this->_proxyFactory->generateProxyClasses(array($classMetadata)); + + $classCode = file_get_contents(dirname(__FILE__)."/generated/__CG__".$proxyName.".php"); + + $this->assertEquals(1, substr_count($classCode, 'function __sleep')); + } + + /** + * @group DDC-1771 + */ + public function testSkipAbstractClassesOnGeneration() + { + $cm = new \Doctrine\ORM\Mapping\ClassMetadata(__NAMESPACE__ . '\\AbstractClass'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->assertNotNull($cm->reflClass); + + $num = $this->_proxyFactory->generateProxyClasses(array($cm)); + + $this->assertEquals(0, $num, "No proxies generated."); + } + + public function testNoConfigDir_ThrowsException() + { + $this->setExpectedException('Doctrine\ORM\Proxy\ProxyException'); + new ProxyFactory($this->_getTestEntityManager(), null, null); + } + + public function testNoNamespace_ThrowsException() + { + $this->setExpectedException('Doctrine\ORM\Proxy\ProxyException'); + new ProxyFactory($this->_getTestEntityManager(), __DIR__ . '/generated', null); + } + + protected function _getMockPersister() + { + $persister = $this->getMock('Doctrine\ORM\Persisters\BasicEntityPersister', array('load'), array(), '', false); + return $persister; + } +} + +class SleepClass +{ + public $id; + + public function __sleep() + { + return array('id'); + } +} + +abstract class AbstractClass +{ + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php new file mode 100644 index 0000000..88c06e4 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Proxy/fixtures/NonNamespacedProxies.php @@ -0,0 +1,13 @@ +. + */ + +namespace Doctrine\Tests\ORM\Query; + +require_once __DIR__ . '/../../TestInit.php'; + +/** + * Test case for testing the saving and referencing of query identifiers. + * + * @author Guilherme Blanco + * @author Janne Vanhala + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://www.phpdoctrine.org + * @since 2.0 + * @version $Revision$ + * @todo 1) [romanb] We might want to split the SQL generation tests into multiple + * 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 +{ + private $_em; + + protected function setUp() { + $this->_em = $this->_getTestEntityManager(); + } + + public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed) + { + try { + $query = $this->_em->createQuery($dqlToBeTested); + parent::assertEquals($sqlToBeConfirmed, $query->getSql()); + $query->free(); + } catch (\Exception $e) { + $this->fail($e->getMessage()); + } + } + + public function testSupportsDeleteWithoutWhereAndFrom() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u', + 'DELETE FROM cms_users' + ); + } + + public function testSupportsDeleteWithoutWhere() + { + $this->assertSqlGeneration( + 'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'DELETE FROM cms_users' + ); + } + + public function testSupportsWhereClause() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', + 'DELETE FROM cms_users WHERE id = ?' + ); + } + + public function testSupportsWhereOrExpressions() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 OR u.name = ?2', + 'DELETE FROM cms_users WHERE username = ? OR name = ?' + ); + } + + public function testSupportsWhereNestedConditionalExpressions() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR ( u.username = ?2 OR u.name = ?3)', + 'DELETE FROM cms_users WHERE id = ? OR (username = ? OR name = ?)' + ); + + //$this->assertSqlGeneration( + // 'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser WHERE id = ?1', + // 'DELETE FROM cms_users WHERE id = ?' + //); + } + + public function testIsCaseAgnostic() + { + $this->assertSqlGeneration( + "delete from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1", + "DELETE FROM cms_users WHERE username = ?" + ); + } + + public function testSupportsAndCondition() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 AND u.name = ?2", + "DELETE FROM cms_users WHERE username = ? AND name = ?" + ); + } + + public function testSupportsWhereNot() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT u.id != ?1", + "DELETE FROM cms_users WHERE NOT id <> ?" + ); + } + + public function testSupportsWhereNotWithParentheses() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 )", + "DELETE FROM cms_users WHERE NOT (id <> ?)" + ); + } + + public function testSupportsWhereNotWithAndExpression() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 AND u.username = ?2 )", + "DELETE FROM cms_users WHERE NOT (id <> ? AND username = ?)" + ); + } + + // ConditionalPrimary was already tested (see testSupportsWhereClause() and testSupportsWhereNot()) + + public function testSupportsGreaterThanComparisonClause() + { + // id = ? was already tested (see testDeleteWithWhere()) + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ?1", + "DELETE FROM cms_users WHERE id > ?" + ); + } + + public function testSupportsGreaterThanOrEqualToComparisonClause() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id >= ?1", + "DELETE FROM cms_users WHERE id >= ?" + ); + } + + public function testSupportsLessThanComparisonClause() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id < ?1", + "DELETE FROM cms_users WHERE id < ?" + ); + } + + public function testSupportsLessThanOrEqualToComparisonClause() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <= ?1", + "DELETE FROM cms_users WHERE id <= ?" + ); + } + + public function testSupportsNotEqualToComparisonClause() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <> ?1", + "DELETE FROM cms_users WHERE id <> ?" + ); + } + + public function testSupportsNotEqualToComparisonClauseExpressedWithExclamationMark() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id != ?1", + "DELETE FROM cms_users WHERE id <> ?" + ); + } + + public function testSupportsNotBetweenClause() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT BETWEEN ?1 AND ?2", + "DELETE FROM cms_users WHERE id NOT BETWEEN ? AND ?" + ); + } + + public function testSupportsBetweenClauseUsedWithAndClause() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2 AND u.username != ?3", + "DELETE FROM cms_users WHERE id BETWEEN ? AND ? AND username <> ?" + ); + } + + public function testSupportsNotLikeClause() + { + // "WHERE" Expression LikeExpression + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username NOT LIKE ?1', + 'DELETE FROM cms_users WHERE username NOT LIKE ?' + ); + } + + public function testSupportsLikeClauseWithEscapeExpression() + { + $this->assertSqlGeneration( + "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username LIKE ?1 ESCAPE '\\'", + "DELETE FROM cms_users WHERE username LIKE ? ESCAPE '\\'" + ); + } + + public function testSupportsIsNullClause() + { + // "WHERE" Expression NullComparisonExpression + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NULL', + 'DELETE FROM cms_users WHERE name IS NULL' + ); + } + + public function testSupportsIsNotNullClause() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NOT NULL', + 'DELETE FROM cms_users WHERE name IS NOT NULL' + ); + } + + public function testSupportsAtomExpressionAsClause() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE 1 = 1', + 'DELETE FROM cms_users WHERE 1 = 1' + ); + } + + public function testSupportsParameterizedAtomExpression() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE ?1 = 1', + 'DELETE FROM cms_users WHERE ? = 1' + ); + } + + public function testSupportsInClause() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN ( ?1, ?2, ?3, ?4 )', + 'DELETE FROM cms_users WHERE id IN (?, ?, ?, ?)' + ); + } + + public function testSupportsNotInClause() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN ( ?1, ?2 )', + 'DELETE FROM cms_users WHERE id NOT IN (?, ?)' + ); + } + + /** + * @group DDC-980 + */ + public function testSubselectTableAliasReferencing() + { + $this->assertSqlGeneration( + 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) = 10', + 'DELETE FROM cms_users WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10' + ); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ExprTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ExprTest.php new file mode 100644 index 0000000..265b2ba --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ExprTest.php @@ -0,0 +1,348 @@ +. + */ + +namespace Doctrine\Tests\ORM\Query; + +use Doctrine\ORM\Query\Expr; +use Doctrine\ORM\Query; + +require_once __DIR__ . '/../../TestInit.php'; + +/** + * Test case for the DQL Expr class used for generating DQL snippets through + * a programmatic interface + * + * @author Jonathan H. Wage + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://www.phpdoctrine.org + * @since 2.0 + * @version $Revision$ + */ +class ExprTest extends \Doctrine\Tests\OrmTestCase +{ + private $_em; + + protected function setUp() + { + $this->_em = $this->_getTestEntityManager(); + $this->_expr = new Expr; + } + + public function testAvgExpr() + { + $this->assertEquals('AVG(u.id)', (string) $this->_expr->avg('u.id')); + } + + public function testMaxExpr() + { + $this->assertEquals('MAX(u.id)', (string) $this->_expr->max('u.id')); + } + + public function testMinExpr() + { + $this->assertEquals('MIN(u.id)', (string) $this->_expr->min('u.id')); + } + + public function testCountExpr() + { + $this->assertEquals('MAX(u.id)', (string) $this->_expr->max('u.id')); + } + + public function testCountDistinctExpr() + { + $this->assertEquals('COUNT(DISTINCT u.id)', (string) $this->_expr->countDistinct('u.id')); + } + + public function testExistsExpr() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u')->from('User', 'u')->where('u.name = ?1'); + + $this->assertEquals('EXISTS(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->exists($qb)); + } + + public function testAllExpr() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u')->from('User', 'u')->where('u.name = ?1'); + + $this->assertEquals('ALL(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->all($qb)); + } + + public function testSomeExpr() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u')->from('User', 'u')->where('u.name = ?1'); + + $this->assertEquals('SOME(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->some($qb)); + } + + public function testAnyExpr() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u')->from('User', 'u')->where('u.name = ?1'); + + $this->assertEquals('ANY(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->any($qb)); + } + + public function testNotExpr() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u')->from('User', 'u')->where('u.name = ?1'); + + $this->assertEquals('NOT(SELECT u FROM User u WHERE u.name = ?1)', (string) $this->_expr->not($qb)); + } + + public function testAndExpr() + { + $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)) + ); + } + + 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))); + } + + public function testAbsExpr() + { + $this->assertEquals('ABS(1)', (string) $this->_expr->abs(1)); + } + + public function testProdExpr() + { + $this->assertEquals('1 * 2', (string) $this->_expr->prod(1, 2)); + } + + public function testDiffExpr() + { + $this->assertEquals('1 - 2', (string) $this->_expr->diff(1, 2)); + } + + public function testSumExpr() + { + $this->assertEquals('1 + 2', (string) $this->_expr->sum(1, 2)); + } + + public function testQuotientExpr() + { + $this->assertEquals('10 / 2', (string) $this->_expr->quot(10, 2)); + } + + public function testScopeInArithmeticExpr() + { + $this->assertEquals('(100 - 20) / 2', (string) $this->_expr->quot($this->_expr->diff(100, 20), 2)); + $this->assertEquals('100 - (20 / 2)', (string) $this->_expr->diff(100, $this->_expr->quot(20, 2))); + } + + public function testSquareRootExpr() + { + $this->assertEquals('SQRT(1)', (string) $this->_expr->sqrt(1)); + } + + public function testEqualExpr() + { + $this->assertEquals('1 = 1', (string) $this->_expr->eq(1, 1)); + } + + public function testLikeExpr() + { + $this->assertEquals('a.description LIKE :description', (string) $this->_expr->like('a.description', ':description')); + } + + public function testConcatExpr() + { + $this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.last_name')); + } + + public function testSubstringExpr() + { + $this->assertEquals('SUBSTRING(a.title, 0, 25)', (string) $this->_expr->substring('a.title', 0, 25)); + } + + /** + * @group regression + * @group DDC-612 + */ + public function testSubstringExprAcceptsTwoArguments() + { + $this->assertEquals('SUBSTRING(a.title, 5)', (string) $this->_expr->substring('a.title', 5)); + } + + public function testLowerExpr() + { + $this->assertEquals('LOWER(u.first_name)', (string) $this->_expr->lower('u.first_name')); + } + + public function testUpperExpr() + { + $this->assertEquals('UPPER(u.first_name)', (string) $this->_expr->upper('u.first_name')); + } + + public function testLengthExpr() + { + $this->assertEquals('LENGTH(u.first_name)', (string) $this->_expr->length('u.first_name')); + } + + public function testGreaterThanExpr() + { + $this->assertEquals('5 > 2', (string) $this->_expr->gt(5, 2)); + } + + public function testLessThanExpr() + { + $this->assertEquals('2 < 5', (string) $this->_expr->lt(2, 5)); + } + + public function testStringLiteralExpr() + { + $this->assertEquals("'word'", (string) $this->_expr->literal('word')); + } + + public function testNumericLiteralExpr() + { + $this->assertEquals(5, (string) $this->_expr->literal(5)); + } + + /** + * @group regression + * @group DDC-610 + */ + public function testLiteralExprProperlyQuotesStrings() + { + $this->assertEquals("'00010001'", (string) $this->_expr->literal('00010001')); + } + + public function testGreaterThanOrEqualToExpr() + { + $this->assertEquals('5 >= 2', (string) $this->_expr->gte(5, 2)); + } + + public function testLessThanOrEqualTo() + { + $this->assertEquals('2 <= 5', (string) $this->_expr->lte(2, 5)); + } + + public function testBetweenExpr() + { + $this->assertEquals('u.id BETWEEN 3 AND 6', (string) $this->_expr->between('u.id', 3, 6)); + } + + public function testTrimExpr() + { + $this->assertEquals('TRIM(u.id)', (string) $this->_expr->trim('u.id')); + } + + public function testIsNullExpr() + { + $this->assertEquals('u.id IS NULL', (string) $this->_expr->isNull('u.id')); + } + + public function testIsNotNullExpr() + { + $this->assertEquals('u.id IS NOT NULL', (string) $this->_expr->isNotNull('u.id')); + } + + public function testInExpr() + { + $this->assertEquals('u.id IN(1, 2, 3)', (string) $this->_expr->in('u.id', array(1, 2, 3))); + } + + public function testInLiteralExpr() + { + $this->assertEquals("u.type IN('foo', 'bar')", (string) $this->_expr->in('u.type', array('foo', 'bar'))); + } + + public function testNotInExpr() + { + $this->assertEquals('u.id NOT IN(1, 2, 3)', (string) $this->_expr->notIn('u.id', array(1, 2, 3))); + } + + public function testNotInLiteralExpr() + { + $this->assertEquals("u.type NOT IN('foo', 'bar')", (string) $this->_expr->notIn('u.type', array('foo', 'bar'))); + } + + public function testAndxOrxExpr() + { + $andExpr = $this->_expr->andx(); + $andExpr->add($this->_expr->eq(1, 1)); + $andExpr->add($this->_expr->lt(1, 5)); + + $orExpr = $this->_expr->orx(); + $orExpr->add($andExpr); + $orExpr->add($this->_expr->eq(1, 1)); + + $this->assertEquals('(1 = 1 AND 1 < 5) OR 1 = 1', (string) $orExpr); + } + + public function testOrxExpr() + { + $orExpr = $this->_expr->orx(); + $orExpr->add($this->_expr->eq(1, 1)); + $orExpr->add($this->_expr->lt(1, 5)); + + $this->assertEquals('1 = 1 OR 1 < 5', (string) $orExpr); + } + + public function testOrderByCountExpr() + { + $orderExpr = $this->_expr->desc('u.username'); + + $this->assertEquals($orderExpr->count(), 1); + $this->assertEquals('u.username DESC', (string) $orderExpr); + } + + public function testOrderByOrder() + { + $orderExpr = $this->_expr->desc('u.username'); + $this->assertEquals('u.username DESC', (string) $orderExpr); + } + + public function testOrderByAsc() + { + $orderExpr = $this->_expr->asc('u.username'); + $this->assertEquals('u.username ASC', (string) $orderExpr); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testAddThrowsException() + { + $orExpr = $this->_expr->orx(); + $orExpr->add($this->_expr->quot(5, 2)); + } + + /** + * @group DDC-1683 + */ + public function testBooleanLiteral() + { + $this->assertEquals('true', $this->_expr->literal(true)); + $this->assertEquals('false', $this->_expr->literal(false)); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php new file mode 100644 index 0000000..2305287 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php @@ -0,0 +1,601 @@ +_em = $this->_getTestEntityManager(); + } + + public function assertValidDQL($dql, $debug = false) + { + try { + $parserResult = $this->parseDql($dql); + } catch (QueryException $e) { + if ($debug) { + echo $e->getTraceAsString() . PHP_EOL; + } + + $this->fail($e->getMessage()); + } + } + + public function assertInvalidDQL($dql, $debug = false) + { + try { + $parserResult = $this->parseDql($dql); + + $this->fail('No syntax errors were detected, when syntax errors were expected'); + } catch (QueryException $e) { + if ($debug) { + echo $e->getMessage() . PHP_EOL; + echo $e->getTraceAsString() . PHP_EOL; + } + } + } + + public function parseDql($dql, $hints = array()) + { + $query = $this->_em->createQuery($dql); + $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true); + $query->setDql($dql); + + foreach ($hints as $key => $value) { + $query->setHint($key, $value); + } + + $parser = new \Doctrine\ORM\Query\Parser($query); + + // We do NOT test SQL output here. That only unnecessarily slows down the tests! + $parser->setCustomOutputTreeWalker('Doctrine\Tests\Mocks\MockTreeWalker'); + + return $parser->parse(); + } + + public function testEmptyQueryString() + { + $this->assertInvalidDQL(''); + } + + public function testPlainFromClauseWithAlias() + { + $this->assertValidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testSelectSingleComponentWithAsterisk() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testSelectSingleComponentWithMultipleColumns() + { + $this->assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testSelectMultipleComponentsUsingMultipleFrom() + { + $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user'); + } + + public function testSelectMultipleComponentsWithAsterisk() + { + $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p'); + } + + public function testSelectDistinctIsSupported() + { + $this->assertValidDQL('SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testAggregateFunctionInSelect() + { + $this->assertValidDQL('SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testDuplicatedAliasInAggregateFunction() + { + $this->assertInvalidDQL('SELECT COUNT(u.id) AS num, SUM(u.id) AS num FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testAggregateFunctionWithDistinctInSelect() + { + $this->assertValidDQL('SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testFunctionalExpressionsSupportedInWherePart() + { + $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'"); + } + + public function testArithmeticExpressionsSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000'); + } + + public function testInExpressionSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)'); + } + + public function testInExpressionWithoutSpacesSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1,2,3)'); + } + + public function testNotInExpressionSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)'); + } + + public function testInExpressionWithSingleValuedAssociationPathExpression() + { + $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)"); + } + + public function testInvalidInExpressionWithCollectionValuedAssociationPathExpression() + { + $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IN (?1, ?2)"); + } + + public function testInstanceOfExpressionSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee'); + } + + public function testInstanceOfExpressionWithInputParamSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1'); + } + + public function testNotInstanceOfExpressionSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1'); + } + + public function testExistsExpressionSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)'); + } + + public function testNotExistsExpressionSupportedInWherePart() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234)'); + } + + public function testAggregateFunctionInHavingClause() + { + $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING COUNT(p.phonenumber) > 2'); + $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p HAVING MAX(u.name) = 'romanb'"); + } + + public function testLeftJoin() + { + $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p'); + } + + public function testJoin() + { + $this->assertValidDQL('SELECT u,p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p'); + } + + public function testInnerJoin() + { + $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p'); + } + + public function testMultipleLeftJoin() + { + $this->assertValidDQL('SELECT u, a, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a LEFT JOIN u.phonenumbers p'); + } + + public function testMultipleInnerJoin() + { + $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a INNER JOIN u.phonenumbers p'); + } + + public function testMixingOfJoins() + { + $this->assertValidDQL('SELECT u.name, a.topic, p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a LEFT JOIN u.phonenumbers p'); + } + + public function testOrderBySingleColumn() + { + $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name'); + } + + public function testOrderBySingleColumnAscending() + { + $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name ASC'); + } + + public function testOrderBySingleColumnDescending() + { + $this->assertValidDQL('SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.name DESC'); + } + + public function testOrderByMultipleColumns() + { + $this->assertValidDQL('SELECT u.name, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username DESC, u.name DESC'); + } + + public function testSubselectInInExpression() + { + $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = 'zYne')"); + } + + public function testSubselectInSelectPart() + { + $this->assertValidDQL("SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); + } + + public function testArithmeticExpressionInSelectPart() + { + $this->assertValidDQL("SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u"); + } + + public function testArithmeticExpressionInSubselectPart() + { + $this->assertValidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); + } + + public function testArithmeticExpressionWithParenthesisInSubselectPart() + { + $this->assertValidDQL("SELECT (SELECT (SUM(u.id) / COUNT(u.id)) FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); + } + + /** + * @group DDC-1079 + */ + public function testSelectLiteralInSubselect() + { + $this->assertValidDQL('SELECT (SELECT 1 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); + $this->assertValidDQL('SELECT (SELECT 0 FROM Doctrine\Tests\Models\CMS\CmsUser u2) value FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + /** + * @group DDC-1077 + */ + public function testConstantValueInSelect() + { + $this->assertValidDQL("SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", true); + } + + public function testDuplicateAliasInSubselectPart() + { + $this->assertInvalidDQL("SELECT (SELECT SUM(u.id) / COUNT(u.id) AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u2) foo FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'"); + } + + public function testPositionalInputParameter() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1'); + } + + public function testNamedInputParameter() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id'); + } + + public function testJoinConditionOverrideNotSupported() + { + $this->assertInvalidDQL("SELECT u.name, p FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.phonenumbers p ON p.phonenumber = '123 123'"); + } + + public function testIndexByClauseWithOneComponent() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id'); + } + + public function testIndexBySupportsJoins() + { + $this->assertValidDQL('SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a INDEX BY a.id'); // INDEX BY is now referring to articles + } + + public function testIndexBySupportsJoins2() + { + $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p INDEX BY p.phonenumber'); + } + + public function testBetweenExpressionSupported() + { + $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name BETWEEN 'jepso' AND 'zYne'"); + } + + public function testNotBetweenExpressionSupported() + { + $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'"); + } + + public function testLikeExpression() + { + $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z%'"); + } + + public function testNotLikeExpression() + { + $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name NOT LIKE 'z%'"); + } + + public function testLikeExpressionWithCustomEscapeCharacter() + { + $this->assertValidDQL("SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE 'z|%' ESCAPE '|'"); + } + + public function testFieldComparisonWithoutAlias() + { + $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE id = 1"); + } + + public function testDuplicatedAliasDeclaration() + { + $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles u WHERE u.id = 1"); + } + + public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression() + { + // This should be allowed because avatar is a single-value association. + // SQL: SELECT ... FROM forum_user fu INNER JOIN forum_avatar fa ON fu.avatar_id = fa.id WHERE fa.id = ? + $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a WHERE a.id = ?1"); + } + + public function testImplicitJoinInWhereOnCollectionValuedPathExpression() + { + // This should be forbidden, because articles is a collection + $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a WHERE a.title = ?"); + } + + public function testInvalidSyntaxIsRejected() + { + $this->assertInvalidDQL("FOOBAR CmsUser"); + $this->assertInvalidDQL("DELETE FROM Doctrine\Tests\Models\CMS\CmsUser.articles"); + $this->assertInvalidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles.comments"); + + // Currently UNDEFINED OFFSET error + $this->assertInvalidDQL("SELECT c FROM CmsUser.articles.comments c"); + } + + public function testUpdateWorksWithOneField() + { + $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone'"); + } + + public function testUpdateWorksWithMultipleFields() + { + $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone', u.username = 'some'"); + } + + public function testUpdateSupportsConditions() + { + $this->assertValidDQL("UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = 'someone' WHERE u.id = 5"); + } + + public function testDeleteAll() + { + $this->assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testDeleteWithCondition() + { + $this->assertValidDQL('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = 3'); + } + + /** + * The main use case for this generalized style of join is when a join condition + * does not involve a foreign key relationship that is mapped to an entity relationship. + */ + public function testImplicitJoinWithCartesianProductAndConditionInWhere() + { + $this->assertValidDQL("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.name = a.topic"); + } + + public function testAllExpressionWithCorrelatedSubquery() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)'); + } + + public function testCustomJoinsAndWithKeywordSupported() + { + $this->assertValidDQL('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p WITH p.phonenumber = 123 WHERE u.id = 1'); + } + + public function testAnyExpressionWithCorrelatedSubquery() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ANY (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)'); + } + + public function testSomeExpressionWithCorrelatedSubquery() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > SOME (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)'); + } + + public function testArithmeticExpressionWithoutParenthesisInWhereClause() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) + 1 > 10'); + } + + public function testMemberOfExpression() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers'); + //$this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE 'Joe' MEMBER OF u.nicknames"); + } + + public function testSizeFunction() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1'); + } + + public function testEmptyCollectionComparisonExpression() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY'); + } + + public function testSingleValuedAssociationFieldInWhere() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1'); + $this->assertValidDQL('SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1'); + } + + public function testBooleanLiteralInWhere() + { + $this->assertValidDQL('SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true'); + } + + public function testSubqueryInSelectExpression() + { + $this->assertValidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testUsageOfQComponentOutsideSubquery() + { + $this->assertInvalidDQL('select u, (select max(p.phonenumber) from Doctrine\Tests\Models\CMS\CmsPhonenumber p) maxId from Doctrine\Tests\Models\CMS\CmsUser u WHERE p.user = ?1'); + } + + public function testUnknownAbstractSchemaName() + { + $this->assertInvalidDQL('SELECT u FROM UnknownClassName u'); + } + + public function testCorrectPartialObjectLoad() + { + $this->assertValidDQL('SELECT PARTIAL u.{id,name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testIncorrectPartialObjectLoadBecauseOfMissingIdentifier() + { + $this->assertInvalidDQL('SELECT PARTIAL u.{name} FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testScalarExpressionInSelect() + { + $this->assertValidDQL('SELECT u, 42 + u.id AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testInputParameterInSelect() + { + $this->assertValidDQL('SELECT u, u.id + ?1 AS someNumber FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + /** + * @group DDC-1091 + */ + public function testCustomFunctionsReturningStringInStringPrimary() + { + $this->_em->getConfiguration()->addCustomStringFunction('CC', 'Doctrine\ORM\Query\AST\Functions\ConcatFunction'); + + $this->assertValidDQL("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CC('%', u.name) LIKE '%foo%'", true); + } + + /** + * @group DDC-505 + */ + public function testDQLKeywordInJoinIsAllowed() + { + $this->assertValidDQL('SELECT u FROM ' . __NAMESPACE__ . '\DQLKeywordsModelUser u JOIN u.group g'); + } + + /** + * @group DDC-505 + */ + public function testDQLKeywordInConditionIsAllowed() + { + $this->assertValidDQL('SELECT g FROM ' . __NAMESPACE__ . '\DQLKeywordsModelGroup g WHERE g.from=0'); + } + + /* The exception is currently thrown in the SQLWalker, not earlier. + public function testInverseSideSingleValuedAssociationPathNotAllowed() + { + $this->assertInvalidDQL('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address = ?1'); + } + */ + + /** + * @group DDC-617 + */ + public function testSelectOnlyNonRootEntityAlias() + { + $this->assertInvalidDQL('SELECT g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g'); + } + + /** + * @group DDC-1108 + */ + public function testInputParameterSingleChar() + { + $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = :q'); + } + + /** + * @group DDC-1053 + */ + public function testGroupBy() + { + $this->assertValidDQL('SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id'); + } + + /** + * @group DDC-1053 + */ + public function testGroupByIdentificationVariable() + { + $this->assertValidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g'); + } + + /** + * @group DDC-1053 + */ + public function testGroupByUnknownIdentificationVariable() + { + $this->assertInvalidDQL('SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY m'); + } + + /** + * @group DDC-117 + */ + public function testSizeOfForeignKeyOneToManyPrimaryKeyEntity() + { + $this->assertValidDQL("SELECT a, t FROM Doctrine\Tests\Models\DDC117\DDC117Article a JOIN a.translations t WHERE SIZE(a.translations) > 0"); + } + + /** + * @group DDC-117 + */ + public function testSizeOfForeignKeyManyToManyPrimaryKeyEntity() + { + $this->assertValidDQL("SELECT e, t FROM Doctrine\Tests\Models\DDC117\DDC117Editor e JOIN e.reviewingTranslations t WHERE SIZE(e.reviewingTranslations) > 0"); + } + + public function testCaseSupportContainingNullIfExpression() + { + $this->assertValidDQL("SELECT u.id, NULLIF(u.name, u.name) AS shouldBeNull FROM Doctrine\Tests\Models\CMS\CmsUser u"); + } + + public function testCaseSupportContainingCoalesceExpression() + { + $this->assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u"); + } +} + +/** @Entity */ +class DQLKeywordsModelUser +{ + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @OneToOne(targetEntity="DQLKeywordsModelGroup") */ + private $group; +} + +/** @Entity */ +class DQLKeywordsModelGroup +{ + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @Column */ + private $from; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LexerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LexerTest.php new file mode 100644 index 0000000..29bba4b --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/LexerTest.php @@ -0,0 +1,234 @@ +moveNext(); + $token = $lexer->lookahead; + + $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); + $this->assertEquals('u', $token['value']); + } + + public function testScannerRecognizesIdentifierConsistingOfLetters() + { + $lexer = new Lexer('someIdentifier'); + + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); + $this->assertEquals('someIdentifier', $token['value']); + } + + public function testScannerRecognizesIdentifierIncludingDigits() + { + $lexer = new Lexer('s0m31d3nt1f13r'); + + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); + $this->assertEquals('s0m31d3nt1f13r', $token['value']); + } + + public function testScannerRecognizesIdentifierIncludingUnderscore() + { + $lexer = new Lexer('some_identifier'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_IDENTIFIER, $token['type']); + $this->assertEquals('some_identifier', $token['value']); + } + + public function testScannerRecognizesDecimalInteger() + { + $lexer = new Lexer('1234'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_INTEGER, $token['type']); + $this->assertEquals(1234, $token['value']); + } + + public function testScannerRecognizesFloat() + { + $lexer = new Lexer('1.234'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_FLOAT, $token['type']); + $this->assertEquals(1.234, $token['value']); + } + + public function testScannerRecognizesFloatWithExponent() + { + $lexer = new Lexer('1.2e3'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_FLOAT, $token['type']); + $this->assertEquals(1.2e3, $token['value']); + } + + public function testScannerRecognizesFloatWithExponent2() + { + $lexer = new Lexer('0.2e3'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_FLOAT, $token['type']); + $this->assertEquals(.2e3, $token['value']); + } + + public function testScannerRecognizesFloatWithNegativeExponent() + { + $lexer = new Lexer('7E-10'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_FLOAT, $token['type']); + $this->assertEquals(7E-10, $token['value']); + } + + public function testScannerRecognizesFloatBig() + { + $lexer = new Lexer('123456789.01'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_FLOAT, $token['type']); + $this->assertEquals(1.2345678901e8, $token['value']); + } + + public function testScannerRecognizesFloatContainingWhitespace() + { + $lexer = new Lexer('- 1.234e2'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_MINUS, $token['type']); + $this->assertEquals('-', $token['value']); + + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_FLOAT, $token['type']); + $this->assertNotEquals(-1.234e2, $token['value']); + $this->assertEquals(1.234e2, $token['value']); + } + + public function testScannerRecognizesStringContainingWhitespace() + { + $lexer = new Lexer("'This is a string.'"); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_STRING, $token['type']); + $this->assertEquals("This is a string.", $token['value']); + } + + public function testScannerRecognizesStringContainingSingleQuotes() + { + $lexer = new Lexer("'abc''defg'''"); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_STRING, $token['type']); + $this->assertEquals("abc'defg'", $token['value']); + } + + public function testScannerRecognizesInputParameter() + { + $lexer = new Lexer('?1'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + $this->assertEquals('?1', $token['value']); + } + + public function testScannerRecognizesNamedInputParameter() + { + $lexer = new Lexer(':name'); + $lexer->moveNext(); + $token = $lexer->lookahead; + $this->assertEquals(Lexer::T_INPUT_PARAMETER, $token['type']); + $this->assertEquals(':name', $token['value']); + } + + public function testScannerTokenizesASimpleQueryCorrectly() + { + $dql = "SELECT u FROM My\Namespace\User u WHERE u.name = 'Jack O''Neil'"; + $lexer = new Lexer($dql); + + $tokens = array( + array( + 'value' => 'SELECT', + 'type' => Lexer::T_SELECT, + 'position' => 0 + ), + array( + 'value' => 'u', + 'type' => Lexer::T_IDENTIFIER, + 'position' => 7 + ), + array( + 'value' => 'FROM', + 'type' => Lexer::T_FROM, + 'position' => 9 + ), + array( + 'value' => 'My\Namespace\User', + 'type' => Lexer::T_IDENTIFIER, + 'position' => 14 + ), + array( + 'value' => 'u', + 'type' => Lexer::T_IDENTIFIER, + 'position' => 32 + ), + array( + 'value' => 'WHERE', + 'type' => Lexer::T_WHERE, + 'position' => 34 + ), + array( + 'value' => 'u', + 'type' => Lexer::T_IDENTIFIER, + 'position' => 40 + ), + array( + 'value' => '.', + 'type' => Lexer::T_DOT, + 'position' => 41 + ), + array( + 'value' => 'name', + 'type' => Lexer::T_IDENTIFIER, + 'position' => 42 + ), + array( + 'value' => '=', + 'type' => Lexer::T_EQUALS, + 'position' => 47 + ), + array( + 'value' => "Jack O'Neil", + 'type' => Lexer::T_STRING, + 'position' => 49 + ) + ); + + foreach ($tokens as $expected) { + $lexer->moveNext(); + $actual = $lexer->lookahead; + $this->assertEquals($expected['value'], $actual['value']); + $this->assertEquals($expected['type'], $actual['type']); + $this->assertEquals($expected['position'], $actual['position']); + } + + $this->assertFalse($lexer->moveNext()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php new file mode 100644 index 0000000..64f3afb --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/ParserResultTest.php @@ -0,0 +1,48 @@ +parserResult = new ParserResult(); + } + + public function testGetRsm() + { + $this->assertInstanceOf( + 'Doctrine\ORM\Query\ResultSetMapping', + $this->parserResult->getResultSetMapping() + ); + } + + public function testSetGetSqlExecutor() + { + $this->assertNull($this->parserResult->getSqlExecutor()); + + $executor = $this->getMock('Doctrine\ORM\Query\Exec\AbstractSqlExecutor', array('execute')); + $this->parserResult->setSqlExecutor($executor); + $this->assertSame($executor, $this->parserResult->getSqlExecutor()); + } + + public function testGetSqlParameterPosition() + { + $this->parserResult->addParameterMapping(1, 1); + $this->parserResult->addParameterMapping(1, 2); + $this->assertEquals(array(1, 2), $this->parserResult->getSqlParameterPositions(1)); + } + + public function testGetParameterMappings() + { + $this->assertInternalType('array', $this->parserResult->getParameterMappings()); + + $this->parserResult->addParameterMapping(1, 1); + $this->parserResult->addParameterMapping(1, 2); + $this->assertEquals(array(1 => array(1, 2)), $this->parserResult->getParameterMappings()); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/QueryTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/QueryTest.php new file mode 100644 index 0000000..f975af3 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/QueryTest.php @@ -0,0 +1,128 @@ +_em = $this->_getTestEntityManager(); + } + + public function testGetParameters() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); + $this->assertEquals(array(), $query->getParameters()); + } + + public function testGetParameters_HasSomeAlready() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); + $query->setParameter(2, 84); + $this->assertEquals(array(2 => 84), $query->getParameters()); + } + + public function testSetParameters() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); + $query->setParameters(array(1 => 'foo', 2 => 'bar')); + $this->assertEquals(array(1 => 'foo', 2 => 'bar'), $query->getParameters()); + } + + public function testFree() + { + $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"); + $query->setParameter(2, 84, \PDO::PARAM_INT); + + $query->free(); + + $this->assertEquals(array(), $query->getParameters()); + } + + public function testClone() + { + $dql = "select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1"; + + $query = $this->_em->createQuery($dql); + $query->setParameter(2, 84, \PDO::PARAM_INT); + $query->setHint('foo', 'bar'); + + $cloned = clone $query; + + $this->assertEquals($dql, $cloned->getDql()); + $this->assertEquals(array(), $cloned->getParameters()); + $this->assertFalse($cloned->getHint('foo')); + } + + public function testFluentQueryInterface() + { + $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); + $q2 = $q->expireQueryCache(true) + ->setQueryCacheLifetime(3600) + ->setQueryCacheDriver(null) + ->expireResultCache(true) + ->setHint('foo', 'bar') + ->setHint('bar', 'baz') + ->setParameter(1, 'bar') + ->setParameters(array(2 => 'baz')) + ->setResultCacheDriver(null) + ->setResultCacheId('foo') + ->setDql('foo') + ->setFirstResult(10) + ->setMaxResults(10); + + $this->assertSame($q2, $q); + } + + /** + * @group DDC-968 + */ + public function testHints() + { + $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); + $q->setHint('foo', 'bar')->setHint('bar', 'baz'); + + $this->assertEquals('bar', $q->getHint('foo')); + $this->assertEquals('baz', $q->getHint('bar')); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $q->getHints()); + } + + /** + * @group DDC-1588 + */ + public function testQueryDefaultResultCache() + { + $this->_em->getConfiguration()->setResultCacheImpl(new ArrayCache()); + $q = $this->_em->createQuery("select a from Doctrine\Tests\Models\CMS\CmsArticle a"); + $q->useResultCache(true); + $this->assertSame($this->_em->getConfiguration()->getResultCacheImpl(), $q->getQueryCacheProfile()->getResultCacheDriver()); + } + + /** + * @expectedException Doctrine\ORM\Query\QueryException + **/ + public function testIterateWithNoDistinctAndWrongSelectClause() + { + $q = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a"); + $q->iterate(); + } + + /** + * @expectedException Doctrine\ORM\Query\QueryException + **/ + public function testIterateWithNoDistinctAndWithValidSelectClause() + { + $q = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a"); + $q->iterate(); + } + + public function testIterateWithDistinct() + { + $q = $this->_em->createQuery("SELECT DISTINCT u from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a"); + $q->iterate(); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php new file mode 100644 index 0000000..3362ec9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -0,0 +1,1601 @@ +_em = $this->_getTestEntityManager(); + } + + /** + * Assert a valid SQL generation. + * + * @param string $dqlToBeTested + * @param string $sqlToBeConfirmed + * @param array $queryHints + * @param array $queryParams + */ + public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed, array $queryHints = array(), array $queryParams = array()) + { + try { + $query = $this->_em->createQuery($dqlToBeTested); + + foreach ($queryParams AS $name => $value) { + $query->setParameter($name, $value); + } + + $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) + ->useQueryCache(false); + + foreach ($queryHints AS $name => $value) { + $query->setHint($name, $value); + } + + $sqlGenerated = $query->getSQL(); + + parent::assertEquals( + $sqlToBeConfirmed, + $sqlGenerated, + sprintf('"%s" is not equal of "%s"', $sqlGenerated, $sqlToBeConfirmed) + ); + + $query->free(); + } catch (\Exception $e) { + $this->fail($e->getMessage() ."\n".$e->getTraceAsString()); + } + } + + /** + * Asser an invalid SQL generation. + * + * @param string $dqlToBeTested + * @param string $expectedException + * @param array $queryHints + * @param array $queryParams + */ + public function assertInvalidSqlGeneration($dqlToBeTested, $expectedException, array $queryHints = array(), array $queryParams = array()) + { + $this->setExpectedException($expectedException); + + $query = $this->_em->createQuery($dqlToBeTested); + + foreach ($queryParams AS $name => $value) { + $query->setParameter($name, $value); + } + + $query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) + ->useQueryCache(false); + + foreach ($queryHints AS $name => $value) { + $query->setHint($name, $value); + } + + $sql = $query->getSql(); + $query->free(); + + // If we reached here, test failed + $this->fail($sql); + } + + + public function testSupportsSelectForAllFields() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_' + ); + } + + public function testSupportsSelectForOneField() + { + $this->assertSqlGeneration( + 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT c0_.id AS id0 FROM cms_users c0_' + ); + } + + public function testSupportsSelectForOneNestedField() + { + $this->assertSqlGeneration( + 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u', + 'SELECT c0_.id AS id0 FROM cms_articles c1_ INNER JOIN cms_users c0_ ON c1_.user_id = c0_.id' + ); + } + + public function testSupportsSelectForAllNestedField() + { + $this->assertSqlGeneration( + 'SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u ORDER BY u.name ASC', + 'SELECT c0_.id AS id0, c0_.topic AS topic1, c0_.text AS text2, c0_.version AS version3 FROM cms_articles c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id ORDER BY c1_.name ASC' + ); + } + + public function testSupportsSelectForMultipleColumnsOfASingleComponent() + { + $this->assertSqlGeneration( + 'SELECT u.username, u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT c0_.username AS username0, c0_.name AS name1 FROM cms_users c0_' + ); + } + + public function testSupportsSelectUsingMultipleFromComponents() + { + $this->assertSqlGeneration( + 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE u = p.user', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.phonenumber AS phonenumber4 FROM cms_users c0_, cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id' + ); + } + + public function testSupportsSelectWithCollectionAssociationJoin() + { + $this->assertSqlGeneration( + 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.phonenumber AS phonenumber4 FROM cms_users c0_ INNER JOIN cms_phonenumbers c1_ ON c0_.id = c1_.user_id' + ); + } + + public function testSupportsSelectWithSingleValuedAssociationJoin() + { + $this->assertSqlGeneration( + 'SELECT u, a FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a', + 'SELECT f0_.id AS id0, f0_.username AS username1, f1_.id AS id2 FROM forum_users f0_ INNER JOIN forum_avatars f1_ ON f0_.avatar_id = f1_.id' + ); + } + + public function testSelectCorrelatedSubqueryComplexMathematicalExpression() + { + $this->assertSqlGeneration( + 'SELECT (SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = u.id) AS c FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT (SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr1 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = c2_.id) AS sclr0 FROM cms_users c2_' + ); + } + + public function testSelectComplexMathematicalExpression() + { + $this->assertSqlGeneration( + 'SELECT (count(p.phonenumber)+5)*10 FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p JOIN p.user ui WHERE ui.id = ?1', + 'SELECT (count(c0_.phonenumber) + 5) * 10 AS sclr0 FROM cms_phonenumbers c0_ INNER JOIN cms_users c1_ ON c0_.user_id = c1_.id WHERE c1_.id = ?' + ); + } + + /* NOT (YET?) SUPPORTED. + Can be supported if SimpleSelectExpresion supports SingleValuedPathExpression instead of StateFieldPathExpression. + + public function testSingleAssociationPathExpressionInSubselect() + { + $this->assertSqlGeneration( + 'SELECT (SELECT p.user FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = u) user_id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', + 'SELECT (SELECT c0_.user_id FROM cms_phonenumbers c0_ WHERE c0_.user_id = c1_.id) AS sclr0 FROM cms_users c1_ WHERE c1_.id = ?' + ); + }*/ + + /** + * @group DDC-1077 + */ + public function testConstantValueInSelect() + { + $this->assertSqlGeneration( + "SELECT u.name, 'foo' AS bar FROM Doctrine\Tests\Models\CMS\CmsUser u", + "SELECT c0_.name AS name0, 'foo' AS sclr1 FROM cms_users c0_" + ); + } + + public function testSupportsOrderByWithAscAsDefault() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ ORDER BY f0_.id ASC' + ); + } + + public function testSupportsOrderByAsc() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id asc', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ ORDER BY f0_.id ASC' + ); + } + public function testSupportsOrderByDesc() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u ORDER BY u.id desc', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ ORDER BY f0_.id DESC' + ); + } + + public function testSupportsSelectDistinct() + { + $this->assertSqlGeneration( + 'SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT DISTINCT c0_.name AS name0 FROM cms_users c0_' + ); + } + + public function testSupportsAggregateFunctionInSelectedFields() + { + $this->assertSqlGeneration( + 'SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id', + 'SELECT COUNT(c0_.id) AS sclr0 FROM cms_users c0_ GROUP BY c0_.id' + ); + } + + public function testSupportsAggregateFunctionWithSimpleArithmetic() + { + $this->assertSqlGeneration( + 'SELECT MAX(u.id + 4) * 2 FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT MAX(c0_.id + 4) * 2 AS sclr0 FROM cms_users c0_' + ); + } + + public function testSupportsWhereClauseWithPositionalParameter() + { + $this->assertSqlGeneration( + 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.id = ?1', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.id = ?' + ); + } + + public function testSupportsWhereClauseWithNamedParameter() + { + $this->assertSqlGeneration( + 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.username = ?' + ); + } + + public function testSupportsWhereAndClauseWithNamedParameters() + { + $this->assertSqlGeneration( + 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name and u.username = :name2', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.username = ? AND f0_.username = ?' + ); + } + + public function testSupportsCombinedWhereClauseWithNamedParameter() + { + $this->assertSqlGeneration( + 'select u from Doctrine\Tests\Models\Forum\ForumUser u where (u.username = :name OR u.username = :name2) AND u.id = :id', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE (f0_.username = ? OR f0_.username = ?) AND f0_.id = ?' + ); + } + + public function testSupportsAggregateFunctionInASelectDistinct() + { + $this->assertSqlGeneration( + 'SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT COUNT(DISTINCT c0_.name) AS sclr0 FROM cms_users c0_' + ); + } + + // Ticket #668 + public function testSupportsASqlKeywordInAStringLiteralParam() + { + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE '%foo OR bar%'", + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.name LIKE '%foo OR bar%'" + ); + } + + public function testSupportsArithmeticExpressionsInWherePart() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id + 5000) * c0_.id + 3 < 10000000' + ); + } + + public function testSupportsMultipleEntitiesInFromClause() + { + $this->assertSqlGeneration( + 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a JOIN a.user u2 WHERE u.id = u2.id', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.id AS id4, c1_.topic AS topic5, c1_.text AS text6, c1_.version AS version7 FROM cms_users c0_, cms_articles c1_ INNER JOIN cms_users c2_ ON c1_.user_id = c2_.id WHERE c0_.id = c2_.id' + ); + } + + public function testSupportsMultipleEntitiesInFromClauseUsingPathExpression() + { + $this->assertSqlGeneration( + 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.id = a.user', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.id AS id4, c1_.topic AS topic5, c1_.text AS text6, c1_.version AS version7 FROM cms_users c0_, cms_articles c1_ WHERE c0_.id = c1_.user_id' + ); + } + + public function testSupportsPlainJoinWithoutClause() + { + $this->assertSqlGeneration( + 'SELECT u.id, a.id from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a', + 'SELECT c0_.id AS id0, c1_.id AS id1 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id' + ); + $this->assertSqlGeneration( + 'SELECT u.id, a.id from Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a', + 'SELECT c0_.id AS id0, c1_.id AS id1 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id' + ); + } + + /** + * @group DDC-135 + */ + public function testSupportsJoinAndWithClauseRestriction() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic LIKE '%foo%'", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')" + ); + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a WITH a.topic LIKE '%foo%'", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic LIKE '%foo%')" + ); + } + + /** + * @group DDC-135 + * @group DDC-177 + */ + public function testJoinOnClause_NotYetSupported_ThrowsException() + { + $this->setExpectedException('Doctrine\ORM\Query\QueryException'); + + $sql = $this->_em->createQuery( + "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a ON a.topic LIKE '%foo%'" + )->getSql(); + } + + public function testSupportsMultipleJoins() + { + $this->assertSqlGeneration( + 'SELECT u.id, a.id, p.phonenumber, c.id from Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a JOIN u.phonenumbers p JOIN a.comments c', + 'SELECT c0_.id AS id0, c1_.id AS id1, c2_.phonenumber AS phonenumber2, c3_.id AS id3 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id INNER JOIN cms_phonenumbers c2_ ON c0_.id = c2_.user_id INNER JOIN cms_comments c3_ ON c1_.id = c3_.article_id' + ); + } + + public function testSupportsTrimFunction() + { + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(TRAILING ' ' FROM u.name) = 'someone'", + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE TRIM(TRAILING ' ' FROM c0_.name) = 'someone'" + ); + } + + // Ticket 894 + public function testSupportsBetweenClauseWithPositionalParameters() + { + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2", + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.id BETWEEN ? AND ?" + ); + } + + public function testSupportsFunctionalExpressionsInWherePart() + { + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'", + // String quoting in the SQL usually depends on the database platform. + // This test works with a mock connection which uses ' for string quoting. + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE TRIM(c0_.name) = 'someone'" + ); + } + + public function testSupportsInstanceOfExpressionsInWherePart() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee", + "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')" + ); + } + + public function testSupportsInstanceOfExpressionInWherePartWithMultipleValues() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF (Doctrine\Tests\Models\Company\CompanyEmployee, \Doctrine\Tests\Models\Company\CompanyManager)", + "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee', 'manager')" + ); + } + + /** + * @group DDC-1194 + */ + public function testSupportsInstanceOfExpressionsInWherePartPrefixedSlash() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\Company\CompanyEmployee", + "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')" + ); + } + + /** + * @group DDC-1194 + */ + public function testSupportsInstanceOfExpressionsInWherePartWithUnrelatedClass() + { + $this->assertInvalidSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\CMS\CmsUser", + "Doctrine\ORM\Query\QueryException" + ); + } + + public function testSupportsInstanceOfExpressionsInWherePartInDeeperLevel() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\Company\CompanyEmployee u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager", + "SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id WHERE c0_.discr IN ('manager')" + ); + } + + public function testSupportsInstanceOfExpressionsInWherePartInDeepestLevel() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\Company\CompanyManager u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager", + "SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id WHERE c0_.discr IN ('manager')" + ); + } + + public function testSupportsInstanceOfExpressionsUsingInputParameterInWherePart() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1", + "SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')", + array(), array(1 => $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee')) + ); + } + + // Ticket #973 + public function testSupportsSingleValuedInExpressionWithoutSpacesInWherePart() + { + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE IDENTITY(u.email) IN(46)", + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE c0_.email_id IN (46)" + ); + } + + public function testSupportsMultipleValuedInExpressionInWherePart() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id IN (1, 2)' + ); + } + + public function testSupportsNotInExpressionInWherePart() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :id NOT IN (1)', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE ? NOT IN (1)' + ); + } + + public function testInExpressionWithSingleValuedAssociationPathExpressionInWherePart() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\Forum\ForumUser u WHERE u.avatar IN (?1, ?2)', + 'SELECT f0_.id AS id0, f0_.username AS username1 FROM forum_users f0_ WHERE f0_.avatar_id IN (?, ?)' + ); + } + + public function testInvalidInExpressionWithSingleValuedAssociationPathExpressionOnInverseSide() + { + // We do not support SingleValuedAssociationPathExpression on inverse side + $this->assertInvalidSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address IN (?1, ?2)", + "Doctrine\ORM\Query\QueryException" + ); + } + + public function testSupportsConcatFunctionForMysqlAndPostgresql() + { + $connMock = $this->_em->getConnection(); + $orgPlatform = $connMock->getDatabasePlatform(); + + $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); + $this->assertSqlGeneration( + "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", + "SELECT c0_.id AS id0 FROM cms_users c0_ WHERE CONCAT(c0_.name, 's') = ?" + ); + $this->assertSqlGeneration( + "SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1", + "SELECT CONCAT(c0_.id, c0_.name) AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?" + ); + + $connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); + $this->assertSqlGeneration( + "SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1", + "SELECT c0_.id AS id0 FROM cms_users c0_ WHERE c0_.name || 's' = ?" + ); + $this->assertSqlGeneration( + "SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1", + "SELECT c0_.id || c0_.name AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?" + ); + + $connMock->setDatabasePlatform($orgPlatform); + } + + public function testSupportsExistsExpressionInWherePartWithCorrelatedSubquery() + { + $this->assertSqlGeneration( + 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = u.id)', + 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT c1_.phonenumber FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = c0_.id)' + ); + } + + /** + * @group DDC-593 + */ + public function testSubqueriesInComparisonExpression() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id >= (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = :name)) AND (u.id <= (SELECT u3.id FROM Doctrine\Tests\Models\CMS\CmsUser u3 WHERE u3.name = :name))', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id >= (SELECT c1_.id FROM cms_users c1_ WHERE c1_.name = ?)) AND (c0_.id <= (SELECT c2_.id FROM cms_users c2_ WHERE c2_.name = ?))' + ); + } + + public function testSupportsMemberOfExpressionOneToMany() + { + // "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); + + $phone = new \Doctrine\Tests\Models\CMS\CmsPhonenumber; + $phone->phonenumber = 101; + $q->setParameter('param', $phone); + + $this->assertEquals( + 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_phonenumbers c1_ WHERE c0_.id = c1_.user_id AND c1_.phonenumber = ?)', + $q->getSql() + ); + } + + public function testSupportsMemberOfExpressionManyToMany() + { + // "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); + + $group = new \Doctrine\Tests\Models\CMS\CmsGroup; + $group->id = 101; + $q->setParameter('param', $group); + + $this->assertEquals( + 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.group_id = c2_.id WHERE c1_.user_id = c0_.id AND c2_.id = ?)', + $q->getSql() + ); + } + + public function testSupportsMemberOfExpressionSelfReferencing() + { + // "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; + $this->_em->getClassMetadata(get_class($person))->setIdentifierValues($person, array('id' => 101)); + $q->setParameter('param', $person); + $this->assertEquals( + 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c2_.salary AS salary3, c2_.department AS department4, c2_.startDate AS startDate5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c1_.car_id AS car_id8 FROM company_persons c0_ LEFT JOIN company_managers c1_ ON c0_.id = c1_.id LEFT JOIN company_employees c2_ ON c0_.id = c2_.id WHERE EXISTS (SELECT 1 FROM company_persons_friends c3_ INNER JOIN company_persons c4_ ON c3_.friend_id = c4_.id WHERE c3_.person_id = c0_.id AND c4_.id = ?)', + $q->getSql() + ); + } + + public function testSupportsMemberOfWithSingleValuedAssociation() + { + // Impossible example, but it illustrates the purpose + $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.email MEMBER OF u.groups'); + + $this->assertEquals( + 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.group_id = c2_.id WHERE c1_.user_id = c0_.id AND c2_.id = c0_.email_id)', + $q->getSql() + ); + } + + public function testSupportsMemberOfWithIdentificationVariable() + { + // Impossible example, but it illustrates the purpose + $q = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u MEMBER OF u.groups'); + + $this->assertEquals( + 'SELECT c0_.id AS id0 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_users_groups c1_ INNER JOIN cms_groups c2_ ON c1_.group_id = c2_.id WHERE c1_.user_id = c0_.id AND c2_.id = c0_.id)', + $q->getSql() + ); + } + + 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); + $this->assertEquals('SELECT d0_.id AS id0 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); + $this->assertEquals('SELECT d0_.id AS id0 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); + $this->assertEquals('SELECT d0_.id AS id0 FROM date_time_model d0_ WHERE d0_.col_datetime > CURRENT_TIMESTAMP', $q->getSql()); + } + + public function testExistsExpressionInWhereCorrelatedSubqueryAssocCondition() + { + $this->assertSqlGeneration( + // DQL + // The result of this query consists of all employees whose spouses are also employees. + 'SELECT DISTINCT emp FROM Doctrine\Tests\Models\CMS\CmsEmployee emp + WHERE EXISTS ( + SELECT spouseEmp + FROM Doctrine\Tests\Models\CMS\CmsEmployee spouseEmp + WHERE spouseEmp = emp.spouse)', + // SQL + 'SELECT DISTINCT c0_.id AS id0, c0_.name AS name1 FROM cms_employees c0_' + . ' WHERE EXISTS (' + . 'SELECT c1_.id FROM cms_employees c1_ WHERE c1_.id = c0_.spouse_id' + . ')' + ); + } + + public function testExistsExpressionWithSimpleSelectReturningScalar() + { + $this->assertSqlGeneration( + // DQL + // The result of this query consists of all employees whose spouses are also employees. + 'SELECT DISTINCT emp FROM Doctrine\Tests\Models\CMS\CmsEmployee emp + WHERE EXISTS ( + SELECT 1 + FROM Doctrine\Tests\Models\CMS\CmsEmployee spouseEmp + WHERE spouseEmp = emp.spouse)', + // SQL + 'SELECT DISTINCT c0_.id AS id0, c0_.name AS name1 FROM cms_employees c0_' + . ' WHERE EXISTS (' + . 'SELECT 1 AS sclr2 FROM cms_employees c1_ WHERE c1_.id = c0_.spouse_id' + . ')' + ); + } + + public function testLimitFromQueryClass() + { + $q = $this->_em + ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') + ->setMaxResults(10); + + $this->assertEquals('SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ LIMIT 10', $q->getSql()); + } + + public function testLimitAndOffsetFromQueryClass() + { + $q = $this->_em + ->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u') + ->setMaxResults(10) + ->setFirstResult(0); + + $this->assertEquals('SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.email_id AS email_id4 FROM cms_users c0_ LIMIT 10 OFFSET 0', $q->getSql()); + } + + public function testSizeFunction() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.phonenumbers) > 1", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 1" + ); + } + + public function testSizeFunctionSupportsManyToMany() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE SIZE(u.groups) > 1", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_users_groups c1_ WHERE c1_.user_id = c0_.id) > 1" + ); + } + + public function testEmptyCollectionComparisonExpression() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS EMPTY", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) = 0" + ); + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.phonenumbers IS NOT EMPTY", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (SELECT COUNT(*) FROM cms_phonenumbers c1_ WHERE c1_.user_id = c0_.id) > 0" + ); + } + + public function testNestedExpressions() + { + $this->assertSqlGeneration( + "select u from Doctrine\Tests\Models\CMS\CmsUser u where u.id > 10 and u.id < 42 and ((u.id * 2) > 5)", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id > 10 AND c0_.id < 42 AND (c0_.id * 2 > 5)" + ); + } + + public function testNestedExpressions2() + { + $this->assertSqlGeneration( + "select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id < 42 and ((u.id * 2) > 5)) or u.id <> 42", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id < 42 AND (c0_.id * 2 > 5)) OR c0_.id <> 42" + ); + } + + public function testNestedExpressions3() + { + $this->assertSqlGeneration( + "select u from Doctrine\Tests\Models\CMS\CmsUser u where (u.id > 10) and (u.id between 1 and 10 or u.id in (1, 2, 3, 4, 5))", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id > 10) AND (c0_.id BETWEEN 1 AND 10 OR c0_.id IN (1, 2, 3, 4, 5))" + ); + } + + public function testOrderByCollectionAssociationSize() + { + $this->assertSqlGeneration( + "select u, size(u.articles) as numArticles from Doctrine\Tests\Models\CMS\CmsUser u order by numArticles", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT COUNT(*) FROM cms_articles c1_ WHERE c1_.user_id = c0_.id) AS sclr4 FROM cms_users c0_ ORDER BY sclr4 ASC" + ); + } + + public function testOrderBySupportsSingleValuedPathExpressionOwningSide() + { + $this->assertSqlGeneration( + "select a from Doctrine\Tests\Models\CMS\CmsArticle a order by a.user", + "SELECT c0_.id AS id0, c0_.topic AS topic1, c0_.text AS text2, c0_.version AS version3 FROM cms_articles c0_ ORDER BY c0_.user_id ASC" + ); + } + + /** + * @expectedException Doctrine\ORM\Query\QueryException + */ + public function testOrderBySupportsSingleValuedPathExpressionInverseSide() + { + $q = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u order by u.address"); + $q->getSQL(); + } + + public function testBooleanLiteralInWhereOnSqlite() + { + $oldPlat = $this->_em->getConnection()->getDatabasePlatform(); + $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SqlitePlatform); + + $this->assertSqlGeneration( + "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true", + "SELECT b0_.id AS id0, b0_.booleanField AS booleanField1 FROM boolean_model b0_ WHERE b0_.booleanField = 1" + ); + + $this->assertSqlGeneration( + "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false", + "SELECT b0_.id AS id0, b0_.booleanField AS booleanField1 FROM boolean_model b0_ WHERE b0_.booleanField = 0" + ); + + $this->_em->getConnection()->setDatabasePlatform($oldPlat); + } + + public function testBooleanLiteralInWhereOnPostgres() + { + $oldPlat = $this->_em->getConnection()->getDatabasePlatform(); + $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); + + $this->assertSqlGeneration( + "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = true", + "SELECT b0_.id AS id0, b0_.booleanField AS booleanfield1 FROM boolean_model b0_ WHERE b0_.booleanField = true" + ); + + $this->assertSqlGeneration( + "SELECT b FROM Doctrine\Tests\Models\Generic\BooleanModel b WHERE b.booleanField = false", + "SELECT b0_.id AS id0, b0_.booleanField AS booleanfield1 FROM boolean_model b0_ WHERE b0_.booleanField = false" + ); + + $this->_em->getConnection()->setDatabasePlatform($oldPlat); + } + + public function testSingleValuedAssociationFieldInWhere() + { + $this->assertSqlGeneration( + "SELECT p FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.user = ?1", + "SELECT c0_.phonenumber AS phonenumber0 FROM cms_phonenumbers c0_ WHERE c0_.user_id = ?" + ); + } + + public function testSingleValuedAssociationNullCheckOnOwningSide() + { + $this->assertSqlGeneration( + "SELECT a FROM Doctrine\Tests\Models\CMS\CmsAddress a WHERE a.user IS NULL", + "SELECT c0_.id AS id0, c0_.country AS country1, c0_.zip AS zip2, c0_.city AS city3 FROM cms_addresses c0_ WHERE c0_.user_id IS NULL" + ); + } + + // Null check on inverse side has to happen through explicit JOIN. + // "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.address IS NULL" + // where the CmsUser is the inverse side is not supported. + public function testSingleValuedAssociationNullCheckOnInverseSide() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.address a WHERE a.id IS NULL", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL" + ); + } + + /** + * @group DDC-339 + */ + public function testStringFunctionLikeExpression() + { + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE '%foo OR bar%'", + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE '%foo OR bar%'" + ); + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) LIKE :str", + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) LIKE ?" + ); + $this->assertSqlGeneration( + "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(UPPER(u.name), '_moo') LIKE :str", + "SELECT c0_.name AS name0 FROM cms_users c0_ WHERE UPPER(c0_.name) || '_moo' LIKE ?" + ); + } + + /** + * @group DDC-338 + */ + public function testOrderedCollectionFetchJoined() + { + $this->assertSqlGeneration( + "SELECT r, l FROM Doctrine\Tests\Models\Routing\RoutingRoute r JOIN r.legs l", + "SELECT r0_.id AS id0, r1_.id AS id1, r1_.departureDate AS departureDate2, r1_.arrivalDate AS arrivalDate3 FROM RoutingRoute r0_ INNER JOIN RoutingRouteLegs r2_ ON r0_.id = r2_.route_id INNER JOIN RoutingLeg r1_ ON r1_.id = r2_.leg_id ". + "ORDER BY r1_.departureDate ASC" + ); + } + + public function testSubselectInSelect() + { + $this->assertSqlGeneration( + "SELECT u.name, (SELECT COUNT(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = 1234) pcount FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name = 'jon'", + "SELECT c0_.name AS name0, (SELECT COUNT(c1_.phonenumber) AS dctrn__1 FROM cms_phonenumbers c1_ WHERE c1_.phonenumber = 1234) AS sclr1 FROM cms_users c0_ WHERE c0_.name = 'jon'" + ); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testPessimisticWriteLockQueryHint() + { + if ($this->_em->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { + $this->markTestSkipped('SqLite does not support Row locking at all.'); + } + + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". + "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", + array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) + ); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testPessimisticReadLockQueryHintPostgreSql() + { + $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); + + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". + "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR SHARE", + array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) + ); + } + + /** + * @group DDC-1693 + * @group locking + */ + public function testLockModeNoneQueryHint() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". + "FROM cms_users c0_ WHERE c0_.username = 'gblanco'", + array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::NONE) + ); + } + + /** + * @group DDC-430 + */ + public function testSupportSelectWithMoreThan10InputParameters() + { + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR u.id = ?2 OR u.id = ?3 OR u.id = ?4 OR u.id = ?5 OR u.id = ?6 OR u.id = ?7 OR u.id = ?8 OR u.id = ?9 OR u.id = ?10 OR u.id = ?11", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ? OR c0_.id = ?" + ); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testPessimisticReadLockQueryHintMySql() + { + $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform); + + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 ". + "FROM cms_users c0_ WHERE c0_.username = 'gblanco' LOCK IN SHARE MODE", + array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) + ); + } + + /** + * @group locking + * @group DDC-178 + */ + public function testPessimisticReadLockQueryHintOracle() + { + $this->_em->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\OraclePlatform); + + $this->assertSqlGeneration( + "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 'gblanco'", + "SELECT c0_.id AS ID0, c0_.status AS STATUS1, c0_.username AS USERNAME2, c0_.name AS NAME3 ". + "FROM cms_users c0_ WHERE c0_.username = 'gblanco' FOR UPDATE", + array(Query::HINT_LOCK_MODE => \Doctrine\DBAL\LockMode::PESSIMISTIC_READ) + ); + } + + /** + * @group DDC-431 + */ + public function testSupportToCustomDQLFunctions() + { + $config = $this->_em->getConfiguration(); + $config->addCustomNumericFunction('MYABS', 'Doctrine\Tests\ORM\Query\MyAbsFunction'); + + $this->assertSqlGeneration( + 'SELECT MYABS(p.phonenumber) FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p', + 'SELECT ABS(c0_.phonenumber) AS sclr0 FROM cms_phonenumbers c0_' + ); + + $config->setCustomNumericFunctions(array()); + } + + /** + * @group DDC-826 + */ + public function testMappedSuperclassAssociationJoin() + { + $this->assertSqlGeneration( + 'SELECT f FROM Doctrine\Tests\Models\DirectoryTree\File f JOIN f.parentDirectory d WHERE f.id = ?1', + 'SELECT f0_.id AS id0, f0_.extension AS extension1, f0_.name AS name2 FROM "file" f0_ INNER JOIN Directory d1_ ON f0_.parentDirectory_id = d1_.id WHERE f0_.id = ?' + ); + } + + /** + * @group DDC-1053 + */ + public function testGroupBy() + { + $this->assertSqlGeneration( + 'SELECT g.id, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g.id', + 'SELECT c0_.id AS id0, count(c1_.id) AS sclr1 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id' + ); + } + + /** + * @group DDC-1053 + */ + public function testGroupByIdentificationVariable() + { + $this->assertSqlGeneration( + 'SELECT g, count(u.id) FROM Doctrine\Tests\Models\CMS\CmsGroup g JOIN g.users u GROUP BY g', + 'SELECT c0_.id AS id0, c0_.name AS name1, count(c1_.id) AS sclr2 FROM cms_groups c0_ INNER JOIN cms_users_groups c2_ ON c0_.id = c2_.group_id INNER JOIN cms_users c1_ ON c1_.id = c2_.user_id GROUP BY c0_.id, c0_.name' + ); + } + + public function testCaseContainingNullIf() + { + $this->assertSqlGeneration( + "SELECT NULLIF(g.id, g.name) AS NullIfEqual FROM Doctrine\Tests\Models\CMS\CmsGroup g", + 'SELECT NULLIF(c0_.id, c0_.name) AS sclr0 FROM cms_groups c0_' + ); + } + + public function testCaseContainingCoalesce() + { + $this->assertSqlGeneration( + "SELECT COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u", + "SELECT COALESCE(NULLIF(c0_.name, ''), c0_.username) AS sclr0 FROM cms_users c0_" + ); + } + + /** + * Test that the right discriminator data is inserted in a subquery. + */ + public function testSubSelectDiscriminator() + { + $this->assertSqlGeneration( + "SELECT u.name, (SELECT COUNT(cfc.id) total FROM Doctrine\Tests\Models\Company\CompanyFixContract cfc) as cfc_count FROM Doctrine\Tests\Models\CMS\CmsUser u", + "SELECT c0_.name AS name0, (SELECT COUNT(c1_.id) AS dctrn__total FROM company_contracts c1_ WHERE c1_.discr IN ('fix')) AS sclr1 FROM cms_users c0_" + ); + } + + public function testIdVariableResultVariableReuse() + { + $exceptionThrown = false; + try { + $query = $this->_em->createQuery("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN (SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u)"); + + $query->getSql(); + $query->free(); + } catch (\Exception $e) { + $exceptionThrown = true; + } + + $this->assertTrue($exceptionThrown); + + } + + public function testSubSelectAliasesFromOuterQuery() + { + $this->assertSqlGeneration( + "SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr4 FROM cms_users c0_" + ); + } + + public function testSubSelectAliasesFromOuterQueryWithSubquery() + { + $this->assertSqlGeneration( + "SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id AND ui.name IN (SELECT uii.name FROM Doctrine\Tests\Models\CMS\CmsUser uii)) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id AND c1_.name IN (SELECT c2_.name FROM cms_users c2_)) AS sclr4 FROM cms_users c0_" + ); + } + + public function testSubSelectAliasesFromOuterQueryReuseInWhereClause() + { + $this->assertSqlGeneration( + "SELECT uo, (SELECT ui.name FROM Doctrine\Tests\Models\CMS\CmsUser ui WHERE ui.id = uo.id) AS bar FROM Doctrine\Tests\Models\CMS\CmsUser uo WHERE bar = ?0", + "SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id) AS sclr4 FROM cms_users c0_ WHERE sclr4 = ?" + ); + } + + /** + * @group DDC-1298 + */ + public function testSelectForeignKeyPKWithoutFields() + { + $this->assertSqlGeneration( + "SELECT t, s, l FROM Doctrine\Tests\Models\DDC117\DDC117Link l INNER JOIN l.target t INNER JOIN l.source s", + "SELECT d0_.article_id AS article_id0, d0_.title AS title1, d1_.article_id AS article_id2, d1_.title AS title3, d2_.source_id AS source_id4, d2_.target_id AS target_id5 FROM DDC117Link d2_ INNER JOIN DDC117Article d0_ ON d2_.target_id = d0_.article_id INNER JOIN DDC117Article d1_ ON d2_.source_id = d1_.article_id" + ); + } + + public function testGeneralCaseWithSingleWhenClause() + { + $this->assertSqlGeneration( + "SELECT g.id, CASE WHEN ((g.id / 2) > 18) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g", + "SELECT c0_.id AS id0, CASE WHEN (c0_.id / 2 > 18) THEN 1 ELSE 0 END AS sclr1 FROM cms_groups c0_" + ); + } + + public function testGeneralCaseWithMultipleWhenClause() + { + $this->assertSqlGeneration( + "SELECT g.id, CASE WHEN (g.id / 2 < 10) THEN 2 WHEN ((g.id / 2) > 20) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g", + "SELECT c0_.id AS id0, CASE WHEN (c0_.id / 2 < 10) THEN 2 WHEN (c0_.id / 2 > 20) THEN 1 ELSE 0 END AS sclr1 FROM cms_groups c0_" + ); + } + + public function testSimpleCaseWithSingleWhenClause() + { + $this->assertSqlGeneration( + "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = CASE g.name WHEN 'admin' THEN 1 ELSE 2 END", + "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN admin THEN 1 ELSE 2 END" + ); + } + + public function testSimpleCaseWithMultipleWhenClause() + { + $this->assertSqlGeneration( + "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = (CASE g.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END)", + "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN admin THEN 1 WHEN moderator THEN 2 ELSE 3 END" + ); + } + + public function testGeneralCaseWithSingleWhenClauseInSubselect() + { + $this->assertSqlGeneration( + "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE WHEN ((g2.id / 2) > 18) THEN 2 ELSE 1 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", + "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN (c1_.id / 2 > 18) THEN 2 ELSE 1 END AS sclr2 FROM cms_groups c1_)" + ); + } + + public function testGeneralCaseWithMultipleWhenClauseInSubselect() + { + $this->assertSqlGeneration( + "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE WHEN (g.id / 2 < 10) THEN 3 WHEN ((g.id / 2) > 20) THEN 2 ELSE 1 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", + "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE WHEN (c0_.id / 2 < 10) THEN 3 WHEN (c0_.id / 2 > 20) THEN 2 ELSE 1 END AS sclr2 FROM cms_groups c1_)" + ); + } + + public function testSimpleCaseWithSingleWhenClauseInSubselect() + { + $this->assertSqlGeneration( + "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE g2.name WHEN 'admin' THEN 1 ELSE 2 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", + "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN admin THEN 1 ELSE 2 END AS sclr2 FROM cms_groups c1_)" + ); + } + + public function testSimpleCaseWithMultipleWhenClauseInSubselect() + { + $this->assertSqlGeneration( + "SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id IN (SELECT CASE g2.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END FROM Doctrine\Tests\Models\CMS\CmsGroup g2)", + "SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id IN (SELECT CASE c1_.name WHEN admin THEN 1 WHEN moderator THEN 2 ELSE 3 END AS sclr2 FROM cms_groups c1_)" + ); + } + + /** + * @group DDC-1339 + */ + public function testIdentityFunctionInSelectClause() + { + $this->assertSqlGeneration( + "SELECT IDENTITY(u.email) as email_id FROM Doctrine\Tests\Models\CMS\CmsUser u", + "SELECT c0_.email_id AS sclr0 FROM cms_users c0_" + ); + } + + /** + * @group DDC-1339 + */ + public function testIdentityFunctionDoesNotAcceptStateField() + { + $this->assertInvalidSqlGeneration( + "SELECT IDENTITY(u.name) as name FROM Doctrine\Tests\Models\CMS\CmsUser u", + "Doctrine\ORM\Query\QueryException" + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeJoinInRootClassWithDisabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', + 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c2_.salary AS salary3, c2_.department AS department4, c2_.startDate AS startDate5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c1_.car_id AS car_id8 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) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeJoinInRootClassWithEnabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT p FROM Doctrine\Tests\Models\Company\CompanyPerson p', + 'SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_', + array(Query::HINT_FORCE_PARTIAL_LOAD => true) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeJoinInChildClassWithDisabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', + 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c2_.car_id AS car_id8 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) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeJoinInChildClassWithEnabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT e FROM Doctrine\Tests\Models\Company\CompanyEmployee e', + 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c0_.discr AS discr5 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id', + array(Query::HINT_FORCE_PARTIAL_LOAD => true) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeJoinInLeafClassWithDisabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', + 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6, c0_.spouse_id AS spouse_id7, c2_.car_id AS car_id8 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) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeJoinInLeafClassWithEnabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT m FROM Doctrine\Tests\Models\Company\CompanyManager m', + 'SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c1_.startDate AS startDate4, c2_.title AS title5, c0_.discr AS discr6 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) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeSingleTableInRootClassWithDisabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', + "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.fixPrice AS fixPrice2, c0_.hoursWorked AS hoursWorked3, c0_.pricePerHour AS pricePerHour4, c0_.maxPrice AS maxPrice5, c0_.discr AS discr6, c0_.salesPerson_id AS salesPerson_id7 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", + array(Query::HINT_FORCE_PARTIAL_LOAD => false) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeSingleTableInRootClassWithEnabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT c FROM Doctrine\Tests\Models\Company\CompanyContract c', + "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.fixPrice AS fixPrice2, c0_.hoursWorked AS hoursWorked3, c0_.pricePerHour AS pricePerHour4, c0_.maxPrice AS maxPrice5, c0_.discr AS discr6 FROM company_contracts c0_ WHERE c0_.discr IN ('fix', 'flexible', 'flexultra')", + array(Query::HINT_FORCE_PARTIAL_LOAD => true) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeSingleTableInChildClassWithDisabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', + "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5, c0_.salesPerson_id AS salesPerson_id6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", + array(Query::HINT_FORCE_PARTIAL_LOAD => false) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeSingleTableInChildClassWithEnabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT fc FROM Doctrine\Tests\Models\Company\CompanyFlexContract fc', + "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexible', 'flexultra')", + array(Query::HINT_FORCE_PARTIAL_LOAD => true) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeSingleTableInLeafClassWithDisabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', + "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5, c0_.salesPerson_id AS salesPerson_id6 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", + array(Query::HINT_FORCE_PARTIAL_LOAD => false) + ); + } + + /** + * @group DDC-1389 + */ + public function testInheritanceTypeSingleTableInLeafClassWithEnabledForcePartialLoad() + { + $this->assertSqlGeneration( + 'SELECT fuc FROM Doctrine\Tests\Models\Company\CompanyFlexUltraContract fuc', + "SELECT c0_.id AS id0, c0_.completed AS completed1, c0_.hoursWorked AS hoursWorked2, c0_.pricePerHour AS pricePerHour3, c0_.maxPrice AS maxPrice4, c0_.discr AS discr5 FROM company_contracts c0_ WHERE c0_.discr IN ('flexultra')", + array(Query::HINT_FORCE_PARTIAL_LOAD => true) + ); + } + + /** + * @group DDC-1161 + */ + public function testSelfReferenceWithOneToOneDoesNotDuplicateAlias() + { + $this->assertSqlGeneration( + 'SELECT p, pp FROM Doctrine\Tests\Models\Company\CompanyPerson p JOIN p.spouse pp', + "SELECT c0_.id AS id0, c0_.name AS name1, c1_.title AS title2, c2_.salary AS salary3, c2_.department AS department4, c2_.startDate AS startDate5, c3_.id AS id6, c3_.name AS name7, c4_.title AS title8, c5_.salary AS salary9, c5_.department AS department10, c5_.startDate AS startDate11, c0_.discr AS discr12, c0_.spouse_id AS spouse_id13, c1_.car_id AS car_id14, c3_.discr AS discr15, c3_.spouse_id AS spouse_id16, c4_.car_id AS car_id17 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) + ); + } + + /** + * @group DDC-1384 + */ + public function testAliasDoesNotExceedPlatformDefinedLength() + { + $this->assertSqlGeneration( + 'SELECT m FROM ' . __NAMESPACE__ . '\\DDC1384Model m', + "SELECT d0_.aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalker_fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo AS fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo0 FROM DDC1384Model d0_" + ); + } + + /** + * @group DDC-331 + * @group DDC-1384 + */ + public function testIssue331() + { + $this->assertSqlGeneration( + 'SELECT e.name FROM Doctrine\Tests\Models\Company\CompanyEmployee e', + 'SELECT c0_.name AS name0 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id' + ); + } + /** + * @group DDC-1435 + */ + public function testForeignKeyAsPrimaryKeySubselect() + { + $this->assertSqlGeneration( + "SELECT s FROM Doctrine\Tests\Models\DDC117\DDC117Article s WHERE EXISTS (SELECT r FROM Doctrine\Tests\Models\DDC117\DDC117Reference r WHERE r.source = s)", + "SELECT d0_.article_id AS article_id0, d0_.title AS title1 FROM DDC117Article d0_ WHERE EXISTS (SELECT d1_.source_id, d1_.target_id FROM DDC117Reference d1_ WHERE d1_.source_id = d0_.article_id)" + ); + } + + /** + * @group DDC-1474 + */ + public function testSelectWithArithmeticExpressionBeforeField() + { + $this->assertSqlGeneration( + 'SELECT - e.value AS value, e.id FROM ' . __NAMESPACE__ . '\DDC1474Entity e', + 'SELECT -d0_.value AS sclr0, d0_.id AS id1 FROM DDC1474Entity d0_' + ); + + $this->assertSqlGeneration( + 'SELECT e.id, + e.value AS value FROM ' . __NAMESPACE__ . '\DDC1474Entity e', + 'SELECT d0_.id AS id0, +d0_.value AS sclr1 FROM DDC1474Entity d0_' + ); + } + + /** + * @group DDC-1430 + */ + public function testGroupByAllFieldsWhenObjectHasForeignKeys() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ GROUP BY c0_.id, c0_.status, c0_.username, c0_.name, c0_.email_id' + ); + + $this->assertSqlGeneration( + 'SELECT e FROM Doctrine\Tests\Models\CMS\CmsEmployee e GROUP BY e', + 'SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_employees c0_ GROUP BY c0_.id, c0_.name, c0_.spouse_id' + ); + } + + /** + * @group DDC-1236 + */ + public function testGroupBySupportsResultVariable() + { + $this->assertSqlGeneration( + 'SELECT u, u.status AS st FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY st', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.status AS status4 FROM cms_users c0_ GROUP BY status4' + ); + } + + /** + * @group DDC-1236 + */ + public function testGroupBySupportsIdentificationVariable() + { + $this->assertSqlGeneration( + 'SELECT u AS user FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY user', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ GROUP BY id0, status1, username2, name3' + ); + } + + /** + * @group DDC-1213 + */ + public function testSupportsBitComparison() + { + $this->assertSqlGeneration( + 'SELECT BIT_OR(4,2), BIT_AND(4,2), u FROM Doctrine\Tests\Models\CMS\CmsUser u', + 'SELECT (4 | 2) AS sclr0, (4 & 2) AS sclr1, c0_.id AS id2, c0_.status AS status3, c0_.username AS username4, c0_.name AS name5 FROM cms_users c0_' + ); + $this->assertSqlGeneration( + 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_OR(u.id,2) > 0', + 'SELECT (c0_.id | 2) AS sclr0, (c0_.id & 2) AS sclr1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0' + ); + $this->assertSqlGeneration( + 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_AND(u.id , 4) > 0', + 'SELECT (c0_.id | 2) AS sclr0, (c0_.id & 2) AS sclr1 FROM cms_users c0_ WHERE (c0_.id & 4) > 0' + ); + $this->assertSqlGeneration( + 'SELECT BIT_OR(u.id,2), BIT_AND(u.id,2) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE BIT_OR(u.id , 2) > 0 OR BIT_AND(u.id , 4) > 0', + 'SELECT (c0_.id | 2) AS sclr0, (c0_.id & 2) AS sclr1 FROM cms_users c0_ WHERE (c0_.id | 2) > 0 OR (c0_.id & 4) > 0' + ); + } + + /** + * @group DDC-1539 + */ + public function testParenthesesOnTheLeftHandOfComparison() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where ( (u.id + u.id) * u.id ) > 100', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100' + ); + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where (u.id + u.id) * u.id > 100', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE (c0_.id + c0_.id) * c0_.id > 100' + ); + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u where 100 < (u.id + u.id) * u.id ', + 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE 100 < (c0_.id + c0_.id) * c0_.id' + ); + } + + public function testCustomTypeValueSql() + { + if (DBALType::hasType('negative_to_positive')) { + DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } else { + DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } + + $this->assertSqlGeneration( + 'SELECT p.customInteger FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p WHERE p.id = 1', + 'SELECT -(c0_.customInteger) AS customInteger0 FROM customtype_parents c0_ WHERE c0_.id = 1' + ); + } + + public function testCustomTypeValueSqlIgnoresIdentifierColumn() + { + if (DBALType::hasType('negative_to_positive')) { + DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } else { + DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } + + $this->assertSqlGeneration( + 'SELECT p.id FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p WHERE p.id = 1', + 'SELECT c0_.id AS id0 FROM customtype_parents c0_ WHERE c0_.id = 1' + ); + } + + public function testCustomTypeValueSqlForAllFields() + { + if (DBALType::hasType('negative_to_positive')) { + DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } else { + DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } + + $this->assertSqlGeneration( + 'SELECT p FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', + 'SELECT c0_.id AS id0, -(c0_.customInteger) AS customInteger1 FROM customtype_parents c0_' + ); + } + + public function testCustomTypeValueSqlForPartialObject() + { + if (DBALType::hasType('negative_to_positive')) { + DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } else { + DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } + + $this->assertSqlGeneration( + 'SELECT partial p.{id, customInteger} FROM Doctrine\Tests\Models\CustomType\CustomTypeParent p', + 'SELECT c0_.id AS id0, -(c0_.customInteger) AS customInteger1 FROM customtype_parents c0_' + ); + } +} + + +class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode +{ + public $simpleArithmeticExpression; + + /** + * @override + */ + public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + { + return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) . ')'; + } + + /** + * @override + */ + public function parse(\Doctrine\ORM\Query\Parser $parser) + { + $lexer = $parser->getLexer(); + + $parser->match(\Doctrine\ORM\Query\Lexer::T_IDENTIFIER); + $parser->match(\Doctrine\ORM\Query\Lexer::T_OPEN_PARENTHESIS); + + $this->simpleArithmeticExpression = $parser->SimpleArithmeticExpression(); + + $parser->match(\Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS); + } +} +/** + * @Entity + */ +class DDC1384Model +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + protected $aVeryLongIdentifierThatShouldBeShortenedByTheSQLWalker_fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; +} + + +/** + * @Entity + */ +class DDC1474Entity +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue() + */ + protected $id; + + /** + * @column(type="float") + */ + private $value; + + /** + * @param string $float + */ + public function __construct($float) + { + $this->value = $float; + } + + /** + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getValue() + { + return $this->value; + } + + /** + * @param float $value + */ + public function setValue($value) + { + $this->value = $value; + } + +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php new file mode 100644 index 0000000..a65efe0 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -0,0 +1,205 @@ +. + */ + +namespace Doctrine\Tests\ORM\Query; + +use Doctrine\DBAL\Types\Type as DBALType; + +require_once __DIR__ . '/../../TestInit.php'; + +/** + * Test case for testing the saving and referencing of query identifiers. + * + * @author Guilherme Blanco + * @author Janne Vanhala + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link http://www.phpdoctrine.org + * @since 2.0 + * @version $Revision$ + * @todo 1) [romanb] We might want to split the SQL generation tests into multiple + * 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 +{ + private $_em; + + protected function setUp() { + if (DBALType::hasType('negative_to_positive')) { + DBALType::overrideType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } else { + DBALType::addType('negative_to_positive', 'Doctrine\Tests\DbalTypes\NegativeToPositiveType'); + } + + $this->_em = $this->_getTestEntityManager(); + } + + public function assertSqlGeneration($dqlToBeTested, $sqlToBeConfirmed) + { + try { + $query = $this->_em->createQuery($dqlToBeTested); + parent::assertEquals($sqlToBeConfirmed, $query->getSql()); + $query->free(); + } catch (\Exception $e) { + $this->fail($e->getMessage()); + } + } + + public function testSupportsQueriesWithoutWhere() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1', + 'UPDATE cms_users SET name = ?' + ); + } + + public function testSupportsMultipleFieldsWithoutWhere() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1, u.username = ?2', + 'UPDATE cms_users SET name = ?, username = ?' + ); + } + + public function testSupportsWhereClauses() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id = ?2', + 'UPDATE cms_users SET name = ? WHERE id = ?' + ); + } + + public function testSupportsWhereClausesOnTheUpdatedField() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.name = ?2', + 'UPDATE cms_users SET name = ? WHERE name = ?' + ); + } + + public function testSupportsMultipleWhereClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.name = ?2 AND u.status = ?3', + 'UPDATE cms_users SET name = ? WHERE name = ? AND status = ?' + ); + } + + public function testSupportsInClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id IN (1, 3, 4)', + 'UPDATE cms_users SET name = ? WHERE id IN (1, 3, 4)' + ); + } + + public function testSupportsParametrizedInClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id IN (?2, ?3, ?4)', + 'UPDATE cms_users SET name = ? WHERE id IN (?, ?, ?)' + ); + } + + public function testSupportsNotInClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1 WHERE u.id NOT IN (1, 3, 4)', + 'UPDATE cms_users SET name = ? WHERE id NOT IN (1, 3, 4)' + ); + } + + public function testSupportsGreatherThanClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id > ?2', + 'UPDATE cms_users SET status = ? WHERE id > ?' + ); + } + + public function testSupportsGreatherThanOrEqualToClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id >= ?2', + 'UPDATE cms_users SET status = ? WHERE id >= ?' + ); + } + + public function testSupportsLessThanClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id < ?2', + 'UPDATE cms_users SET status = ? WHERE id < ?' + ); + } + + public function testSupportsLessThanOrEqualToClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id <= ?2', + 'UPDATE cms_users SET status = ? WHERE id <= ?' + ); + } + + public function testSupportsBetweenClause() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = ?1 WHERE u.id BETWEEN :from AND :to', + 'UPDATE cms_users SET status = ? WHERE id BETWEEN ? AND ?' + ); + } + + public function testSingleValuedAssociationFieldInWhere() + { + $this->assertSqlGeneration( + "UPDATE Doctrine\Tests\Models\CMS\CmsPhonenumber p SET p.phonenumber = 1234 WHERE p.user = ?1", + "UPDATE cms_phonenumbers SET phonenumber = 1234 WHERE user_id = ?" + ); + } + + public function testSingleValuedAssociationFieldInSetClause() + { + $this->assertSqlGeneration( + "update Doctrine\Tests\Models\CMS\CmsComment c set c.article = null where c.article=?1", + "UPDATE cms_comments SET article_id = NULL WHERE article_id = ?" + ); + } + + /** + * @group DDC-980 + */ + public function testSubselectTableAliasReferencing() + { + $this->assertSqlGeneration( + "UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.status = 'inactive' WHERE SIZE(u.groups) = 10", + "UPDATE cms_users SET status = 'inactive' WHERE (SELECT COUNT(*) FROM cms_users_groups c0_ WHERE c0_.user_id = cms_users.id) = 10" + ); + } + + public function testCustomTypeValueSqlCompletelyIgnoredInUpdateStatements() + { + $this->assertSqlGeneration( + 'UPDATE Doctrine\Tests\Models\CustomType\CustomTypeParent p SET p.customInteger = 1 WHERE p.id = 1', + 'UPDATE customtype_parents SET customInteger = 1 WHERE id = 1' + ); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/QueryBuilderTest.php new file mode 100644 index 0000000..f078b89 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -0,0 +1,748 @@ +. + */ + +namespace Doctrine\Tests\ORM; + +use Doctrine\ORM\QueryBuilder, + Doctrine\ORM\Query\Expr; + +require_once __DIR__ . '/../TestInit.php'; + +/** + * Test case for the QueryBuilder class used to build DQL query string in a + * object oriented way. + * + * @author Jonathan H. Wage + * @author Roman Borschel _em = $this->_getTestEntityManager(); + } + + protected function assertValidQueryBuilder(QueryBuilder $qb, $expectedDql) + { + $dql = $qb->getDql(); + $q = $qb->getQuery(); + + $this->assertEquals($expectedDql, $dql); + } + + public function testSelectSetsType() + { + $qb = $this->_em->createQueryBuilder() + ->delete('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->select('u.id', 'u.username'); + + $this->assertEquals($qb->getType(), QueryBuilder::SELECT); + } + + public function testEmptySelectSetsType() + { + $qb = $this->_em->createQueryBuilder() + ->delete('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->select(); + + $this->assertEquals($qb->getType(), QueryBuilder::SELECT); + } + + public function testDeleteSetsType() + { + $qb = $this->_em->createQueryBuilder() + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->delete(); + + $this->assertEquals($qb->getType(), QueryBuilder::DELETE); + } + + public function testUpdateSetsType() + { + $qb = $this->_em->createQueryBuilder() + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->update(); + + $this->assertEquals($qb->getType(), QueryBuilder::UPDATE); + } + + public function testSimpleSelect() + { + $qb = $this->_em->createQueryBuilder() + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->select('u.id', 'u.username'); + + $this->assertValidQueryBuilder($qb, 'SELECT u.id, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testSimpleDelete() + { + $qb = $this->_em->createQueryBuilder() + ->delete('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + + $this->assertValidQueryBuilder($qb, 'DELETE Doctrine\Tests\Models\CMS\CmsUser u'); + } + + public function testSimpleUpdate() + { + $qb = $this->_em->createQueryBuilder() + ->update('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->set('u.username', ':username'); + + $this->assertValidQueryBuilder($qb, 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.username = :username'); + } + + public function testInnerJoin() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'a') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->innerJoin('u.articles', 'a'); + + $this->assertValidQueryBuilder($qb, 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a'); + } + + public function testComplexInnerJoin() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'a') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->innerJoin('u.articles', 'a', 'ON', 'u.id = a.author_id'); + + $this->assertValidQueryBuilder( + $qb, + 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id' + ); + } + + public function testLeftJoin() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'a') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->leftJoin('u.articles', 'a'); + + $this->assertValidQueryBuilder($qb, 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a'); + } + + public function testLeftJoinWithIndexBy() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'a') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->leftJoin('u.articles', 'a', null, null, 'a.name'); + + $this->assertValidQueryBuilder($qb, 'SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a INDEX BY a.name'); + } + + public function testMultipleFrom() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'g') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->from('Doctrine\Tests\Models\CMS\CmsGroup', 'g'); + + $this->assertValidQueryBuilder($qb, 'SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsGroup g'); + } + + public function testMultipleFromWithJoin() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'g') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->from('Doctrine\Tests\Models\CMS\CmsGroup', 'g') + ->innerJoin('u.articles', 'a', 'ON', 'u.id = a.author_id'); + + $this->assertValidQueryBuilder($qb, 'SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.articles a ON u.id = a.author_id, Doctrine\Tests\Models\CMS\CmsGroup g'); + } + + public function testMultipleFromWithMultipleJoin() + { + $qb = $this->_em->createQueryBuilder() + ->select('u', 'g') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->from('Doctrine\Tests\Models\CMS\CmsArticle', 'a') + ->innerJoin('u.groups', 'g') + ->leftJoin('u.address', 'ad') + ->innerJoin('a.comments', 'c'); + + $this->assertValidQueryBuilder($qb, 'SELECT u, g FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g LEFT JOIN u.address ad, Doctrine\Tests\Models\CMS\CmsArticle a INNER JOIN a.comments c'); + } + + public function testWhere() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid'); + } + + public function testComplexAndWhere() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid OR u.id = :uid2 OR u.id = :uid3') + ->andWhere('u.name = :name'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (u.id = :uid OR u.id = :uid2 OR u.id = :uid3) AND u.name = :name'); + } + + public function testAndWhere() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid') + ->andWhere('u.id = :uid2'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id = :uid2'); + } + + public function testOrWhere() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid') + ->orWhere('u.id = :uid2'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id = :uid2'); + } + + public function testComplexAndWhereOrWhereNesting() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid') + ->orWhere('u.id = :uid2') + ->andWhere('u.id = :uid3') + ->orWhere('u.name = :name1', 'u.name = :name2') + ->andWhere('u.name <> :noname'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE (((u.id = :uid OR u.id = :uid2) AND u.id = :uid3) OR u.name = :name1 OR u.name = :name2) AND u.name <> :noname'); + } + + public function testAndWhereIn() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid') + ->andWhere($qb->expr()->in('u.id', array(1, 2, 3))); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id IN(1, 2, 3)'); + } + + public function testOrWhereIn() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid') + ->orWhere($qb->expr()->in('u.id', array(1, 2, 3))); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id IN(1, 2, 3)'); + } + + public function testAndWhereNotIn() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid') + ->andWhere($qb->expr()->notIn('u.id', array(1, 2, 3))); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id NOT IN(1, 2, 3)'); + } + + public function testOrWhereNotIn() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid') + ->orWhere($qb->expr()->notIn('u.id', array(1, 2, 3))); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id NOT IN(1, 2, 3)'); + } + + public function testGroupBy() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->groupBy('u.id') + ->addGroupBy('u.username'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id, u.username'); + } + + public function testHaving() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->groupBy('u.id') + ->having('COUNT(u.id) > 1'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id HAVING COUNT(u.id) > 1'); + } + + public function testAndHaving() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->groupBy('u.id') + ->having('COUNT(u.id) > 1') + ->andHaving('COUNT(u.id) < 1'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id HAVING COUNT(u.id) > 1 AND COUNT(u.id) < 1'); + } + + public function testOrHaving() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->groupBy('u.id') + ->having('COUNT(u.id) > 1') + ->andHaving('COUNT(u.id) < 1') + ->orHaving('COUNT(u.id) > 1'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id HAVING (COUNT(u.id) > 1 AND COUNT(u.id) < 1) OR COUNT(u.id) > 1'); + } + + public function testOrderBy() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->orderBy('u.username', 'ASC'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username ASC'); + } + + public function testOrderByWithExpression() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->orderBy($qb->expr()->asc('u.username')); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username ASC'); + } + + public function testAddOrderBy() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->orderBy('u.username', 'ASC') + ->addOrderBy('u.username', 'DESC'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u ORDER BY u.username ASC, u.username DESC'); + } + + public function testGetQuery() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $q = $qb->getQuery(); + + $this->assertEquals('Doctrine\ORM\Query', get_class($q)); + } + + public function testSetParameter() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :id') + ->setParameter('id', 1); + + $this->assertEquals(array('id' => 1), $qb->getParameters()); + } + + public function testSetParameters() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($qb->expr()->orx('u.username = :username', 'u.username = :username2')); + + $qb->setParameters(array('username' => 'jwage', 'username2' => 'jonwage')); + + $this->assertEquals(array('username' => 'jwage', 'username2' => 'jonwage'), $qb->getQuery()->getParameters()); + } + + + public function testGetParameters() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :id'); + + $qb->setParameters(array('id' => 1)); + $this->assertEquals(array('id' => 1), $qb->getParameters()); + } + + public function testGetParameter() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :id'); + + $qb->setParameters(array('id' => 1)); + $this->assertEquals(1, $qb->getParameter('id')); + } + + public function testMultipleWhere() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.id = :uid', 'u.id = :uid2'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id = :uid2'); + } + + public function testMultipleAndWhere() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->andWhere('u.id = :uid', 'u.id = :uid2'); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid AND u.id = :uid2'); + } + + public function testMultipleOrWhere() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->orWhere('u.id = :uid', $qb->expr()->eq('u.id', ':uid2')); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid OR u.id = :uid2'); + } + + public function testComplexWhere() + { + $qb = $this->_em->createQueryBuilder(); + $orExpr = $qb->expr()->orX(); + $orExpr->add($qb->expr()->eq('u.id', ':uid3')); + $orExpr->add($qb->expr()->in('u.id', array(1))); + + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($orExpr); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid3 OR u.id IN(1)'); + } + + public function testWhereInWithStringLiterals() + { + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($qb->expr()->in('u.name', array('one', 'two', 'three'))); + + $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('one', 'two', 'three')"); + + $qb->where($qb->expr()->in('u.name', array("O'Reilly", "O'Neil", 'Smith'))); + + $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('O''Reilly', 'O''Neil', 'Smith')"); + } + + public function testWhereInWithObjectLiterals() + { + $qb = $this->_em->createQueryBuilder(); + $expr = $this->_em->getExpressionBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($expr->in('u.name', array($expr->literal('one'), $expr->literal('two'), $expr->literal('three')))); + + $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('one', 'two', 'three')"); + + $qb->where($expr->in('u.name', array($expr->literal("O'Reilly"), $expr->literal("O'Neil"), $expr->literal('Smith')))); + + $this->assertValidQueryBuilder($qb, "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IN('O''Reilly', 'O''Neil', 'Smith')"); + } + + public function testNegation() + { + $expr = $this->_em->getExpressionBuilder(); + $orExpr = $expr->orX(); + $orExpr->add($expr->eq('u.id', ':uid3')); + $orExpr->add($expr->not($expr->in('u.id', array(1)))); + + $qb = $this->_em->createQueryBuilder(); + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($orExpr); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :uid3 OR NOT(u.id IN(1))'); + } + + public function testSomeAllAny() + { + $qb = $this->_em->createQueryBuilder(); + $expr = $this->_em->getExpressionBuilder(); + + //$subquery = $qb->subquery('Doctrine\Tests\Models\CMS\CmsArticle', 'a')->select('a.id'); + + $qb->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($expr->gt('u.id', $expr->all('select a.id from Doctrine\Tests\Models\CMS\CmsArticle a'))); + + $this->assertValidQueryBuilder($qb, 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL(select a.id from Doctrine\Tests\Models\CMS\CmsArticle a)'); + + } + + public function testMultipleIsolatedQueryConstruction() + { + $qb = $this->_em->createQueryBuilder(); + $expr = $this->_em->getExpressionBuilder(); + + $qb->select('u')->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + $qb->where($expr->eq('u.name', ':name')); + $qb->setParameter('name', 'romanb'); + + $q1 = $qb->getQuery(); + $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 + $qb->andWhere($expr->eq('u.id', ':id')); + $qb->setParameter('id', 42); + + $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->assertTrue($q1 !== $q2); // two different, independent queries + $this->assertEquals(2, count($q2->getParameters())); + $this->assertEquals(1, count($q1->getParameters())); // $q1 unaffected + } + + public function testGetEntityManager() + { + $qb = $this->_em->createQueryBuilder(); + $this->assertEquals($this->_em, $qb->getEntityManager()); + } + + public function testInitialStateIsClean() + { + $qb = $this->_em->createQueryBuilder(); + $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState()); + } + + public function testAlteringQueryChangesStateToDirty() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + + $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState()); + } + + public function testSelectWithFuncExpression() + { + $qb = $this->_em->createQueryBuilder(); + $expr = $qb->expr(); + $qb->select($expr->count('e.id')); + + $this->assertValidQueryBuilder($qb, 'SELECT COUNT(e.id)'); + } + + public function testResetDQLPart() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.username = ?1')->orderBy('u.username'); + + $this->assertEquals('u.username = ?1', (string)$qb->getDQLPart('where')); + $this->assertEquals(1, count($qb->getDQLPart('orderBy'))); + + $qb->resetDqlPart('where')->resetDqlPart('orderBy'); + + $this->assertNull($qb->getDQLPart('where')); + $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + } + + public function testResetDQLParts() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.username = ?1')->orderBy('u.username'); + + $qb->resetDQLParts(array('where', 'orderBy')); + + $this->assertEquals(1, count($qb->getDQLPart('select'))); + $this->assertNull($qb->getDQLPart('where')); + $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + } + + public function testResetAllDQLParts() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where('u.username = ?1')->orderBy('u.username'); + + $qb->resetDQLParts(); + + $this->assertEquals(0, count($qb->getDQLPart('select'))); + $this->assertNull($qb->getDQLPart('where')); + $this->assertEquals(0, count($qb->getDQLPart('orderBy'))); + } + + /** + * @group DDC-867 + */ + public function testDeepClone() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->andWhere('u.username = ?1') + ->andWhere('u.status = ?2'); + + $expr = $qb->getDQLPart('where'); + $this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one."); + + $qb2 = clone $qb; + $qb2->andWhere('u.name = ?3'); + + $this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one."); + } + + public function testGetRootAlias() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + + $this->assertEquals('u', $qb->getRootAlias()); + } + + public function testGetRootAliases() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + + $this->assertEquals(array('u'), $qb->getRootAliases()); + } + + public function testGetRootEntities() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + + $this->assertEquals(array('Doctrine\Tests\Models\CMS\CmsUser'), $qb->getRootEntities()); + } + + public function testGetSeveralRootAliases() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u2'); + + $this->assertEquals(array('u', 'u2'), $qb->getRootAliases()); + $this->assertEquals('u', $qb->getRootAlias()); + } + + public function testBCAddJoinWithoutRootAlias() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->add('join', array('INNER JOIN u.groups g'), true); + + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.groups g', $qb->getDQL()); + } + + /** + * @group DDC-1211 + */ + public function testEmptyStringLiteral() + { + $expr = $this->_em->getExpressionBuilder(); + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($expr->eq('u.username', $expr->literal(""))); + + $this->assertEquals("SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ''", $qb->getDQL()); + } + + /** + * @group DDC-1211 + */ + public function testEmptyNumericLiteral() + { + $expr = $this->_em->getExpressionBuilder(); + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u') + ->where($expr->eq('u.username', $expr->literal(0))); + + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = 0', $qb->getDQL()); + } + + /** + * @group DDC-1227 + */ + public function testAddFromString() + { + $qb = $this->_em->createQueryBuilder() + ->add('select', 'u') + ->add('from', 'Doctrine\Tests\Models\CMS\CmsUser u'); + + $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); + } + + /** + * @group DDC-1619 + */ + public function testAddDistinct() + { + $qb = $this->_em->createQueryBuilder() + ->select('u') + ->distinct() + ->from('Doctrine\Tests\Models\CMS\CmsUser', 'u'); + + $this->assertEquals('SELECT DISTINCT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $qb->getDQL()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php new file mode 100644 index 0000000..a170731 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Console/Command/ConvertDoctrine1SchemaCommandTest.php @@ -0,0 +1,23 @@ +getMock('Doctrine\ORM\Tools\EntityGenerator'); + $metadataExporter = $this->getMock('Doctrine\ORM\Tools\Export\ClassMetadataExporter'); + $command = new ConvertDoctrine1SchemaCommand(); + $command->setEntityGenerator($entityGenerator); + + $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + $output->expects($this->once()) + ->method('write') + ->with($this->equalTo('No Metadata Classes to process.' . PHP_EOL)); + + $command->convertDoctrine1Schema($this->_getTestEntityManager(), array(), sys_get_temp_dir(), 'annotation', 4, null, $output); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php new file mode 100644 index 0000000..c0af3a7 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ConvertDoctrine1SchemaTest.php @@ -0,0 +1,108 @@ +. + */ + +namespace Doctrine\Tests\ORM\Tools; + +use Doctrine\ORM\Tools\Export\ClassMetadataExporter; +use Doctrine\ORM\Tools\ConvertDoctrine1Schema; +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; + +require_once __DIR__ . '/../../TestInit.php'; + +/** + * Test case for converting a Doctrine 1 style schema to Doctrine 2 mapping files + * + * @author Jonathan H. Wage + * @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); + } + + public function testTest() + { + if ( ! class_exists('Symfony\Component\Yaml\Yaml', true)) { + $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + } + + $cme = new ClassMetadataExporter(); + $converter = new ConvertDoctrine1Schema(__DIR__ . '/doctrine1schema'); + + $exporter = $cme->getExporter('yml', __DIR__ . '/convert'); + $exporter->setOverwriteExistingFiles(true); + $exporter->setMetadata($converter->getMetadata()); + $exporter->export(); + + $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'); + $em = $this->_createEntityManager($metadataDriver); + $cmf = new DisconnectedClassMetadataFactory(); + $cmf->setEntityManager($em); + $metadata = $cmf->getAllMetadata(); + $profileClass = $cmf->getMetadataFor('Profile'); + $userClass = $cmf->getMetadataFor('User'); + + $this->assertEquals(2, count($metadata)); + $this->assertEquals('Profile', $profileClass->name); + $this->assertEquals('User', $userClass->name); + $this->assertEquals(4, count($profileClass->fieldMappings)); + $this->assertEquals(5, count($userClass->fieldMappings)); + $this->assertEquals('text', $userClass->fieldMappings['clob']['type']); + $this->assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']); + $this->assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']); + + $this->assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']); + $this->assertEquals('User', $profileClass->associationMappings['User']['targetEntity']); + + $this->assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]); + } + + public function tearDown() + { + @unlink(__DIR__ . '/convert/User.dcm.yml'); + @unlink(__DIR__ . '/convert/Profile.dcm.yml'); + @rmdir(__DIR__ . '/convert'); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php new file mode 100644 index 0000000..185c7f9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -0,0 +1,294 @@ +_namespace = uniqid("doctrine_"); + $this->_tmpDir = \sys_get_temp_dir(); + \mkdir($this->_tmpDir . \DIRECTORY_SEPARATOR . $this->_namespace); + $this->_generator = new EntityGenerator(); + $this->_generator->setAnnotationPrefix(""); + $this->_generator->setGenerateAnnotations(true); + $this->_generator->setGenerateStubMethods(true); + $this->_generator->setRegenerateEntityIfExists(false); + $this->_generator->setUpdateEntityIfExists(true); + } + + public function tearDown() + { + $ri = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->_tmpDir . '/' . $this->_namespace)); + foreach ($ri AS $file) { + /* @var $file \SplFileInfo */ + if ($file->isFile()) { + \unlink($file->getPathname()); + } + } + rmdir($this->_tmpDir . '/' . $this->_namespace); + } + + public function generateBookEntityFixture() + { + $metadata = new ClassMetadataInfo($this->_namespace . '\EntityGeneratorBook'); + $metadata->namespace = $this->_namespace; + $metadata->customRepositoryClassName = $this->_namespace . '\EntityGeneratorBookRepository'; + + $metadata->table['name'] = 'book'; + $metadata->table['uniqueConstraints']['name_uniq'] = array('columns' => array('name')); + $metadata->table['indexes']['status_idx'] = array('columns' => array('status')); + $metadata->mapField(array('fieldName' => 'name', 'type' => 'string')); + $metadata->mapField(array('fieldName' => 'status', 'type' => 'string', 'default' => 'published')); + $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); + $metadata->mapOneToOne(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', 'mappedBy' => 'book')); + $joinColumns = array( + array('name' => 'author_id', 'referencedColumnName' => 'id') + ); + $metadata->mapManyToMany(array( + 'fieldName' => 'comments', + 'targetEntity' => 'Doctrine\Tests\ORM\Tools\EntityGeneratorComment', + 'joinTable' => array( + 'name' => 'book_comment', + 'joinColumns' => array(array('name' => 'book_id', 'referencedColumnName' => 'id')), + 'inverseJoinColumns' => array(array('name' => 'comment_id', 'referencedColumnName' => 'id')), + ), + )); + $metadata->addLifecycleCallback('loading', 'postLoad'); + $metadata->addLifecycleCallback('willBeRemoved', 'preRemove'); + $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); + + $this->_generator->writeEntityClass($metadata, $this->_tmpDir); + + return $metadata; + } + + /** + * @param ClassMetadataInfo $metadata + * @return EntityGeneratorBook + */ + public function newInstance($metadata) + { + $path = $this->_tmpDir . '/'. $this->_namespace . '/EntityGeneratorBook.php'; + $this->assertFileExists($path); + require_once $path; + + return new $metadata->name; + } + + public function testGeneratedEntityClass() + { + $metadata = $this->generateBookEntityFixture(); + + $book = $this->newInstance($metadata); + + $this->assertTrue(class_exists($metadata->name), "Class does not exist."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', '__construct'), "EntityGeneratorBook::__construct() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getId'), "EntityGeneratorBook::getId() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setName'), "EntityGeneratorBook::setName() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getName'), "EntityGeneratorBook::getName() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'setAuthor'), "EntityGeneratorBook::setAuthor() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getAuthor'), "EntityGeneratorBook::getAuthor() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'getComments'), "EntityGeneratorBook::getComments() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'addComment'), "EntityGeneratorBook::addComment() missing."); + $this->assertTrue(method_exists($metadata->namespace . '\EntityGeneratorBook', 'removeComment'), "EntityGeneratorBook::removeComment() missing."); + + $this->assertEquals('published', $book->getStatus()); + + $book->setName('Jonathan H. Wage'); + $this->assertEquals('Jonathan H. Wage', $book->getName()); + + $author = new EntityGeneratorAuthor(); + $book->setAuthor($author); + $this->assertEquals($author, $book->getAuthor()); + + $comment = new EntityGeneratorComment(); + $book->addComment($comment); + $this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $book->getComments()); + $this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array($comment)), $book->getComments()); + $book->removeComment($comment); + $this->assertEquals(new \Doctrine\Common\Collections\ArrayCollection(array()), $book->getComments()); + } + + public function testEntityUpdatingWorks() + { + $metadata = $this->generateBookEntityFixture(); + $metadata->mapField(array('fieldName' => 'test', 'type' => 'string')); + + $this->_generator->writeEntityClass($metadata, $this->_tmpDir); + + $this->assertFileExists($this->_tmpDir . "/" . $this->_namespace . "/EntityGeneratorBook.php~"); + + $book = $this->newInstance($metadata); + $reflClass = new \ReflectionClass($metadata->name); + + $this->assertTrue($reflClass->hasProperty('name'), "Regenerating keeps property 'name'."); + $this->assertTrue($reflClass->hasProperty('status'), "Regenerating keeps property 'status'."); + $this->assertTrue($reflClass->hasProperty('id'), "Regenerating keeps property 'id'."); + + $this->assertTrue($reflClass->hasProperty('test'), "Check for property test failed."); + $this->assertTrue($reflClass->getProperty('test')->isPrivate(), "Check for private property test failed."); + $this->assertTrue($reflClass->hasMethod('getTest'), "Check for method 'getTest' failed."); + $this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); + $this->assertTrue($reflClass->hasMethod('setTest'), "Check for method 'getTest' failed."); + $this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); + } + + public function testEntityExtendsStdClass() + { + $this->_generator->setClassToExtend('stdClass'); + $metadata = $this->generateBookEntityFixture(); + + $book = $this->newInstance($metadata); + $this->assertInstanceOf('stdClass', $book); + } + + public function testLifecycleCallbacks() + { + $metadata = $this->generateBookEntityFixture(); + + $book = $this->newInstance($metadata); + $reflClass = new \ReflectionClass($metadata->name); + + $this->assertTrue($reflClass->hasMethod('loading'), "Check for postLoad lifecycle callback."); + $this->assertTrue($reflClass->hasMethod('willBeRemoved'), "Check for preRemove lifecycle callback."); + } + + public function testLoadMetadata() + { + $metadata = $this->generateBookEntityFixture(); + + $book = $this->newInstance($metadata); + + $cm = new \Doctrine\ORM\Mapping\ClassMetadata($metadata->name); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $driver = $this->createAnnotationDriver(); + $driver->loadMetadataForClass($cm->name, $cm); + + $this->assertEquals($cm->columnNames, $metadata->columnNames); + $this->assertEquals($cm->getTableName(), $metadata->getTableName()); + $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + $this->assertEquals($cm->identifier, $metadata->identifier); + $this->assertEquals($cm->idGenerator, $metadata->idGenerator); + $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); + } + + public function testLoadPrefixedMetadata() + { + $this->_generator->setAnnotationPrefix('ORM\\'); + $metadata = $this->generateBookEntityFixture(); + + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array()); + + $book = $this->newInstance($metadata); + + $cm = new \Doctrine\ORM\Mapping\ClassMetadata($metadata->name); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + + $driver->loadMetadataForClass($cm->name, $cm); + + $this->assertEquals($cm->columnNames, $metadata->columnNames); + $this->assertEquals($cm->getTableName(), $metadata->getTableName()); + $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks); + $this->assertEquals($cm->identifier, $metadata->identifier); + $this->assertEquals($cm->idGenerator, $metadata->idGenerator); + $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName); + } + + /** + * @dataProvider getParseTokensInEntityFileData + */ + public function testParseTokensInEntityFile($php, $classes) + { + $r = new \ReflectionObject($this->_generator); + $m = $r->getMethod('_parseTokensInEntityFile'); + $m->setAccessible(true); + + $p = $r->getProperty('_staticReflection'); + $p->setAccessible(true); + + $ret = $m->invoke($this->_generator, $php); + $this->assertEquals($classes, array_keys($p->getValue($this->_generator))); + } + + /** + * @group DDC-1784 + */ + public function testGenerateEntityWithSequenceGenerator() + { + $metadata = new ClassMetadataInfo($this->_namespace . '\DDC1784Entity'); + $metadata->namespace = $this->_namespace; + $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); + $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); + $metadata->setSequenceGeneratorDefinition(array( + 'sequenceName' => 'DDC1784_ID_SEQ', + 'allocationSize' => 1, + 'initialValue' => 2 + )); + $this->_generator->writeEntityClass($metadata, $this->_tmpDir); + + $filename = $this->_tmpDir . DIRECTORY_SEPARATOR + . $this->_namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php'; + + $this->assertFileExists($filename); + require_once $filename; + + + $reflection = new \ReflectionProperty($metadata->name, 'id'); + $docComment = $reflection->getDocComment(); + + $this->assertContains('@Id', $docComment); + $this->assertContains('@Column(name="id", type="integer")', $docComment); + $this->assertContains('@GeneratedValue(strategy="SEQUENCE")', $docComment); + $this->assertContains('@SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment); + } + + + public function getParseTokensInEntityFileData() + { + return array( + array( + '. + */ + +namespace Doctrine\Tests\ORM\Tools\Export; + +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; + +require_once __DIR__ . '/../../../TestInit.php'; + +/** + * Test case for ClassMetadataExporter + * + * @author Jonathan H. Wage + * @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); + } + + protected function _createMetadataDriver($type, $path) + { + $mappingDriver = array( + 'php' => 'PHPDriver', + 'annotation' => 'AnnotationDriver', + 'xml' => 'XmlDriver', + 'yaml' => 'YamlDriver', + ); + $this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); + $driverName = $mappingDriver[$type]; + + $class = 'Doctrine\ORM\Mapping\Driver\\' . $driverName; + if ($type === 'annotation') { + $driver = $this->createAnnotationDriver(array($path)); + } else { + $driver = new $class($path); + } + return $driver; + } + + protected function _createClassMetadataFactory($em, $type) + { + if ($type === 'annotation') { + $factory = new ClassMetadataFactory(); + } else { + $factory = new DisconnectedClassMetadataFactory(); + } + $factory->setEntityManager($em); + return $factory; + } + + public function testExportDirectoryAndFilesAreCreated() + { + $this->_deleteDirectory(__DIR__ . '/export/'.$this->_getType()); + + $type = $this->_getType(); + $metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/' . $type); + $em = $this->_createEntityManager($metadataDriver); + $cmf = $this->_createClassMetadataFactory($em, $type); + $metadata = $cmf->getAllMetadata(); + + $metadata[0]->name = 'Doctrine\Tests\ORM\Tools\Export\ExportedUser'; + + $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\ExportedUser', $metadata[0]->name); + + $type = $this->_getType(); + $cme = new ClassMetadataExporter(); + $exporter = $cme->getExporter($type, __DIR__ . '/export/' . $type); + if ($type === 'annotation') { + $entityGenerator = new EntityGenerator(); + $entityGenerator->setAnnotationPrefix(""); + $exporter->setEntityGenerator($entityGenerator); + } + $this->_extension = $exporter->getExtension(); + + $exporter->setMetadata($metadata); + $exporter->export(); + + if ($type == 'annotation') { + $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/'.str_replace('\\', '/', 'Doctrine\Tests\ORM\Tools\Export\ExportedUser').$this->_extension)); + } else { + $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser'.$this->_extension)); + } + } + + /** + * @depends testExportDirectoryAndFilesAreCreated + */ + public function testExportedMetadataCanBeReadBackIn() + { + $type = $this->_getType(); + + $metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/export/' . $type); + $em = $this->_createEntityManager($metadataDriver); + $cmf = $this->_createClassMetadataFactory($em, $type); + $metadata = $cmf->getAllMetadata(); + + $this->assertEquals(1, count($metadata)); + + $class = current($metadata); + + $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\ExportedUser', $class->name); + + return $class; + } + + /** + * @depends testExportedMetadataCanBeReadBackIn + * @param ClassMetadataInfo $class + */ + public function testTableIsExported($class) + { + $this->assertEquals('cms_users', $class->table['name']); + + return $class; + } + + /** + * @depends testTableIsExported + * @param ClassMetadataInfo $class + */ + public function testTypeIsExported($class) + { + $this->assertFalse($class->isMappedSuperclass); + + return $class; + } + + /** + * @depends testTypeIsExported + * @param ClassMetadataInfo $class + */ + public function testIdentifierIsExported($class) + { + $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY, $class->generatorType); + $this->assertEquals(array('id'), $class->identifier); + $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); + + return $class; + } + + /** + * @depends testIdentifierIsExported + * @param ClassMetadataInfo $class + */ + public function testFieldsAreExported($class) + { + $this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true); + $this->assertEquals('id', $class->fieldMappings['id']['fieldName']); + $this->assertEquals('integer', $class->fieldMappings['id']['type']); + $this->assertEquals('id', $class->fieldMappings['id']['columnName']); + + $this->assertEquals('name', $class->fieldMappings['name']['fieldName']); + $this->assertEquals('string', $class->fieldMappings['name']['type']); + $this->assertEquals(50, $class->fieldMappings['name']['length']); + $this->assertEquals('name', $class->fieldMappings['name']['columnName']); + + $this->assertEquals('email', $class->fieldMappings['email']['fieldName']); + $this->assertEquals('string', $class->fieldMappings['email']['type']); + $this->assertEquals('user_email', $class->fieldMappings['email']['columnName']); + $this->assertEquals('CHAR(32) NOT NULL', $class->fieldMappings['email']['columnDefinition']); + + return $class; + } + + /** + * @depends testFieldsAreExported + * @param ClassMetadataInfo $class + */ + public function testOneToOneAssociationsAreExported($class) + { + $this->assertTrue(isset($class->associationMappings['address'])); + $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Address', $class->associationMappings['address']['targetEntity']); + $this->assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); + $this->assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); + $this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']); + + $this->assertTrue($class->associationMappings['address']['isCascadeRemove']); + $this->assertTrue($class->associationMappings['address']['isCascadePersist']); + $this->assertFalse($class->associationMappings['address']['isCascadeRefresh']); + $this->assertFalse($class->associationMappings['address']['isCascadeMerge']); + $this->assertFalse($class->associationMappings['address']['isCascadeDetach']); + $this->assertTrue($class->associationMappings['address']['orphanRemoval']); + + return $class; + } + + /** + * @depends testFieldsAreExported + */ + public function testManyToOneAssociationsAreExported($class) + { + $this->assertTrue(isset($class->associationMappings['mainGroup'])); + $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Group', $class->associationMappings['mainGroup']['targetEntity']); + } + + /** + * @depends testOneToOneAssociationsAreExported + * @param ClassMetadataInfo $class + */ + public function testOneToManyAssociationsAreExported($class) + { + $this->assertTrue(isset($class->associationMappings['phonenumbers'])); + //$this->assertInstanceOf('Doctrine\ORM\Mapping\OneToManyMapping', $class->associationMappings['phonenumbers']); + $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Phonenumber', $class->associationMappings['phonenumbers']['targetEntity']); + $this->assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); + $this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']); + + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); + $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + + return $class; + } + + /** + * @depends testOneToManyAssociationsAreExported + * @param ClassMetadataInfo $metadata + */ + public function testManyToManyAssociationsAreExported($class) + { + $this->assertTrue(isset($class->associationMappings['groups'])); + //$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $class->associationMappings['groups']); + $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Group', $class->associationMappings['groups']['targetEntity']); + $this->assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']); + + $this->assertEquals('user_id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['name']); + $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['joinColumns'][0]['referencedColumnName']); + + $this->assertEquals('group_id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['name']); + $this->assertEquals('id', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['referencedColumnName']); + $this->assertEquals('INT NULL', $class->associationMappings['groups']['joinTable']['inverseJoinColumns'][0]['columnDefinition']); + + $this->assertTrue($class->associationMappings['groups']['isCascadeRemove']); + $this->assertTrue($class->associationMappings['groups']['isCascadePersist']); + $this->assertTrue($class->associationMappings['groups']['isCascadeRefresh']); + $this->assertTrue($class->associationMappings['groups']['isCascadeMerge']); + $this->assertTrue($class->associationMappings['groups']['isCascadeDetach']); + + return $class; + } + + /** + * @depends testManyToManyAssociationsAreExported + * @param ClassMetadataInfo $class + */ + public function testLifecycleCallbacksAreExported($class) + { + $this->assertTrue(isset($class->lifecycleCallbacks['prePersist'])); + $this->assertEquals(2, count($class->lifecycleCallbacks['prePersist'])); + $this->assertEquals('doStuffOnPrePersist', $class->lifecycleCallbacks['prePersist'][0]); + $this->assertEquals('doOtherStuffOnPrePersistToo', $class->lifecycleCallbacks['prePersist'][1]); + + $this->assertTrue(isset($class->lifecycleCallbacks['postPersist'])); + $this->assertEquals(1, count($class->lifecycleCallbacks['postPersist'])); + $this->assertEquals('doStuffOnPostPersist', $class->lifecycleCallbacks['postPersist'][0]); + + return $class; + } + + /** + * @depends testLifecycleCallbacksAreExported + * @param ClassMetadataInfo $class + */ + public function testCascadeIsExported($class) + { + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadePersist']); + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeMerge']); + $this->assertTrue($class->associationMappings['phonenumbers']['isCascadeRemove']); + $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']); + $this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']); + $this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']); + + return $class; + } + + /** + * @depends testCascadeIsExported + * @param ClassMetadataInfo $class + */ + public function testInversedByIsExported($class) + { + $this->assertEquals('user', $class->associationMappings['address']['inversedBy']); + } + /** + * @depends testExportDirectoryAndFilesAreCreated + */ + public function testCascadeAllCollapsed() + { + $type = $this->_getType(); + if ($type == 'xml') { + $xml = simplexml_load_file(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml'); + + $xml->registerXPathNamespace("d", "http://doctrine-project.org/schemas/orm/doctrine-mapping"); + $nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:one-to-many[@field='interests']/d:cascade/d:*"); + $this->assertEquals(1, count($nodes)); + + $this->assertEquals('cascade-all', $nodes[0]->getName()); + } elseif ($type == 'yaml') { + + $yaml = new \Symfony\Component\Yaml\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'])); + $this->assertEquals(1, count($value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'])); + $this->assertEquals('all', $value['Doctrine\Tests\ORM\Tools\Export\ExportedUser']['oneToMany']['interests']['cascade'][0]); + + } else { + $this->markTestSkipped('Test aviable only for '.$type.' dirver'); + } + } + public function __destruct() + { +# $this->_deleteDirectory(__DIR__ . '/export/'.$this->_getType()); + } + + protected function _deleteDirectory($path) + { + if (is_file($path)) { + return unlink($path); + } else if (is_dir($path)) { + $files = glob(rtrim($path,'/').'/*'); + foreach ($files as $file){ + $this->_deleteDirectory($file); + } + return rmdir($path); + } + } +} + +class Address +{ + +} +class Phonenumber +{ + +} +class Group +{ + +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php new file mode 100644 index 0000000..c60281c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/AnnotationClassMetadataExporterTest.php @@ -0,0 +1,42 @@ +. + */ + +namespace Doctrine\Tests\ORM\Tools\Export; + +require_once __DIR__ . '/../../../TestInit.php'; + +/** + * Test case for AnnotationClassMetadataExporterTest + * + * @author Jonathan H. Wage + * @author Roman Borschel . + */ + +namespace Doctrine\Tests\ORM\Tools\Export; + +require_once __DIR__ . '/../../../TestInit.php'; + +/** + * Test case for PhpClassMetadataExporterTest + * + * @author Jonathan H. Wage + * @author Roman Borschel . + */ + +namespace Doctrine\Tests\ORM\Tools\Export; + +require_once __DIR__ . '/../../../TestInit.php'; + +/** + * Test case for XmlClassMetadataExporterTest + * + * @author Jonathan H. Wage + * @author Roman Borschel . + */ + +namespace Doctrine\Tests\ORM\Tools\Export; + +require_once __DIR__ . '/../../../TestInit.php'; + +/** + * Test case for YamlClassMetadataExporterTest + * + * @author Jonathan H. Wage + * @author Roman Borschel markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.'); + } + + return 'yaml'; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php new file mode 100644 index 0000000..5a82cc6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/annotation/Doctrine.Tests.ORM.Tools.Export.User.php @@ -0,0 +1,73 @@ +setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE); +$metadata->setPrimaryTable(array( + 'name' => 'cms_users', + )); +$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT); +$metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist'); +$metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist'); +$metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist'); +$metadata->mapField(array( + 'id' => true, + 'fieldName' => 'id', + 'type' => 'integer', + 'columnName' => 'id', + )); +$metadata->mapField(array( + 'fieldName' => 'name', + 'type' => 'string', + 'length' => 50, + 'unique' => true, + 'nullable' => true, + 'columnName' => 'name', + )); +$metadata->mapField(array( + 'fieldName' => 'email', + 'type' => 'string', + 'columnName' => 'user_email', + 'columnDefinition' => 'CHAR(32) NOT NULL', + )); +$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); +$metadata->mapManyToOne(array( + 'fieldName' => 'mainGroup', + 'targetEntity' => 'Doctrine\\Tests\\ORM\Tools\\Export\\Group', +)); +$metadata->mapOneToOne(array( + 'fieldName' => 'address', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Address', + 'inversedBy' => 'user', + 'cascade' => + array( + 0 => 'persist', + ), + 'mappedBy' => NULL, + 'joinColumns' => + array( + 0 => + array( + 'name' => 'address_id', + 'referencedColumnName' => 'id', + 'onDelete' => 'CASCADE', + ), + ), + 'orphanRemoval' => true, + )); +$metadata->mapOneToMany(array( + 'fieldName' => 'phonenumbers', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Phonenumber', + 'cascade' => + array( + 1 => 'persist', + 2 => 'merge', + ), + 'mappedBy' => 'user', + 'orphanRemoval' => true, + 'orderBy' => + array( + 'number' => 'ASC', + ), + )); +$metadata->mapManyToMany(array( + 'fieldName' => 'groups', + 'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Group', + 'cascade' => + array( + 0 => 'remove', + 1 => 'persist', + 2 => 'refresh', + 3 => 'merge', + 4 => 'detach', + ), + 'mappedBy' => NULL, + 'joinTable' => + array( + 'name' => 'cms_users_groups', + 'joinColumns' => + array( + 0 => + array( + 'name' => 'user_id', + 'referencedColumnName' => 'id', + 'unique' => false, + 'nullable' => false, + ), + ), + 'inverseJoinColumns' => + array( + 0 => + array( + 'name' => 'group_id', + 'referencedColumnName' => 'id', + 'columnDefinition' => 'INT NULL', + ), + ), + ), + 'orderBy' => NULL, + )); diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml new file mode 100644 index 0000000..22d2852 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/xml/Doctrine.Tests.ORM.Tools.Export.User.dcm.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml new file mode 100644 index 0000000..25071d9 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Export/yaml/Doctrine.Tests.ORM.Tools.Export.User.dcm.yml @@ -0,0 +1,63 @@ +Doctrine\Tests\ORM\Tools\Export\User: + type: entity + table: cms_users + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type: string + length: 50 + nullable: true + unique: true + email: + type: string + column: user_email + columnDefinition: CHAR(32) NOT NULL + oneToOne: + address: + targetEntity: Doctrine\Tests\ORM\Tools\Export\Address + joinColumn: + name: address_id + referencedColumnName: id + onDelete: CASCADE + cascade: [ persist ] + inversedBy: user + orphanRemoval: true + manyToOne: + mainGroup: + targetEntity: Doctrine\Tests\ORM\Tools\Export\Group + oneToMany: + phonenumbers: + targetEntity: Doctrine\Tests\ORM\Tools\Export\Phonenumber + mappedBy: user + orderBy: + number: ASC + cascade: [ persist, merge ] + orphanRemoval: true + interests: + targetEntity: Doctrine\Tests\ORM\Tools\Export\Interests + mappedBy: user + cascade: [ persist, merge, remove, refresh, detach ] + orphanRemoval: true + manyToMany: + groups: + targetEntity: Doctrine\Tests\ORM\Tools\Export\Group + joinTable: + name: cms_users_groups + joinColumns: + user_id: + referencedColumnName: id + nullable: false + unique: false + inverseJoinColumns: + group_id: + referencedColumnName: id + columnDefinition: INT NULL + cascade: + - all + lifecycleCallbacks: + prePersist: [ doStuffOnPrePersist, doOtherStuffOnPrePersistToo ] + postPersist: [ doStuffOnPostPersist ] diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php new file mode 100644 index 0000000..816339d --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -0,0 +1,78 @@ +entityManager->createQuery( + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a'); + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); + $query->setHint(CountWalker::HINT_DISTINCT, true); + $query->setFirstResult(null)->setMaxResults(null); + + $this->assertEquals( + "SELECT count(DISTINCT b0_.id) AS sclr0 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() + ); + } + + public function testCountQuery_MixedResultsWithName() + { + $query = $this->entityManager->createQuery( + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); + $query->setHint(CountWalker::HINT_DISTINCT, true); + $query->setFirstResult(null)->setMaxResults(null); + + $this->assertEquals( + "SELECT count(DISTINCT a0_.id) AS sclr0 FROM Author a0_", $query->getSql() + ); + } + + public function testCountQuery_KeepsGroupBy() + { + $query = $this->entityManager->createQuery( + 'SELECT b FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost b GROUP BY b.id'); + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); + $query->setHint(CountWalker::HINT_DISTINCT, true); + $query->setFirstResult(null)->setMaxResults(null); + + $this->assertEquals( + "SELECT count(DISTINCT b0_.id) AS sclr0 FROM BlogPost b0_ GROUP BY b0_.id", $query->getSql() + ); + } + + public function testCountQuery_RemovesOrderBy() + { + $query = $this->entityManager->createQuery( + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a ORDER BY a.name'); + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); + $query->setHint(CountWalker::HINT_DISTINCT, true); + $query->setFirstResult(null)->setMaxResults(null); + + $this->assertEquals( + "SELECT count(DISTINCT b0_.id) AS sclr0 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() + ); + } + + public function testCountQuery_RemovesLimits() + { + $query = $this->entityManager->createQuery( + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a'); + $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); + $query->setHint(CountWalker::HINT_DISTINCT, true); + $query->setFirstResult(null)->setMaxResults(null); + + $this->assertEquals( + "SELECT count(DISTINCT b0_.id) AS sclr0 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/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php new file mode 100644 index 0000000..f166ddd --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php @@ -0,0 +1,36 @@ +entityManager->createQuery( + 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a'); + $limitQuery = clone $query; + $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker')); + + $this->assertEquals( + "SELECT DISTINCT m0_.id AS id0 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() + ); + } + + public function testCountQuery_MixedResultsWithName() + { + $query = $this->entityManager->createQuery( + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); + $limitQuery = clone $query; + $limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker')); + + $this->assertEquals( + "SELECT DISTINCT a0_.id AS id0, sum(a0_.name) AS sclr1 FROM Author a0_", $limitQuery->getSql() + ); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php new file mode 100644 index 0000000..a6e4c67 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/PaginationTestCase.php @@ -0,0 +1,142 @@ +entityManager = $this->_getTestEntityManager(); + } +} + + +/** +* @Entity +*/ +class MyBlogPost +{ + + /** @Id @column(type="integer") @generatedValue */ + public $id; + /** + * @ManyToOne(targetEntity="Author") + */ + public $author; + /** + * @ManyToOne(targetEntity="Category") + */ + public $category; +} + +/** + * @Entity + */ +class MyAuthor +{ + + /** @Id @column(type="integer") @generatedValue */ + public $id; + +} + +/** +* @Entity +*/ +class MyCategory +{ + + /** @id @column(type="integer") @generatedValue */ + public $id; + +} + + +/** + * @Entity + */ +class BlogPost +{ + + /** @Id @column(type="integer") @generatedValue */ + public $id; + /** + * @ManyToOne(targetEntity="Author") + */ + public $author; + /** + * @ManyToOne(targetEntity="Category") + */ + public $category; +} + +/** + * @Entity + */ +class Author +{ + + /** @Id @column(type="integer") @generatedValue */ + public $id; + /** @Column(type="string") */ + public $name; + +} + +/** + * @Entity + */ +class Person +{ + + /** @Id @column(type="integer") @generatedValue */ + public $id; + /** @Column(type="string") */ + public $name; + /** @Column(type="string") */ + public $biography; + +} + +/** + * @Entity + */ +class Category +{ + + /** @id @column(type="integer") @generatedValue */ + public $id; + +} + + +/** @Entity @Table(name="groups") */ +class Group +{ + + /** @Id @column(type="integer") @generatedValue */ + public $id; + /** @ManyToMany(targetEntity="User", mappedBy="groups") */ + public $users; +} + +/** @Entity */ +class User +{ + + /** @Id @column(type="integer") @generatedValue */ + public $id; + /** + * @ManyToMany(targetEntity="Group", inversedBy="users") + * @JoinTable( + * name="user_group", + * joinColumns = {@JoinColumn(name="user_id", referencedColumnName="id")}, + * inverseJoinColumns = {@JoinColumn(name="group_id", referencedColumnName="id")} + * ) + */ + public $groups; +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php new file mode 100644 index 0000000..d7bcd0e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php @@ -0,0 +1,111 @@ +entityManager->createQuery( + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g' + ); + $whereInQuery = clone $query; + $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); + + $this->assertEquals( + "SELECT u0_.id AS id0, g1_.id AS id1 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() + ); + } + + public function testCountQuery_MixedResultsWithName() + { + $query = $this->entityManager->createQuery( + 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a' + ); + $whereInQuery = clone $query; + $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); + + $this->assertEquals( + "SELECT a0_.id AS id0, a0_.name AS name1, sum(a0_.name) AS sclr2 FROM Author a0_ WHERE a0_.id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $whereInQuery->getSql() + ); + } + + public function testWhereInQuery_SingleWhere() + { + $query = $this->entityManager->createQuery( + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1' + ); + $whereInQuery = clone $query; + $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); + + $this->assertEquals( + "SELECT u0_.id AS id0, g1_.id AS id1 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() + ); + } + + public function testWhereInQuery_MultipleWhereWithAnd() + { + $query = $this->entityManager->createQuery( + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2' + ); + $whereInQuery = clone $query; + $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); + + $this->assertEquals( + "SELECT u0_.id AS id0, g1_.id AS id1 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() + ); + } + + public function testWhereInQuery_MultipleWhereWithOr() + { + $query = $this->entityManager->createQuery( + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 OR 2 = 2' + ); + $whereInQuery = clone $query; + $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); + + $this->assertEquals( + "SELECT u0_.id AS id0, g1_.id AS id1 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() + ); + } + + public function testWhereInQuery_MultipleWhereWithMixed_1() + { + $query = $this->entityManager->createQuery( + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE (1 = 1 OR 2 = 2) AND 3 = 3' + ); + $whereInQuery = clone $query; + $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); + + $this->assertEquals( + "SELECT u0_.id AS id0, g1_.id AS id1 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() + ); + } + + public function testWhereInQuery_MultipleWhereWithMixed_2() + { + $query = $this->entityManager->createQuery( + 'SELECT u, g FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g WHERE 1 = 1 AND 2 = 2 OR 3 = 3' + ); + $whereInQuery = clone $query; + $whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\WhereInWalker')); + $whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10); + + $this->assertEquals( + "SELECT u0_.id AS id0, g1_.id AS id1 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() + ); + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php new file mode 100644 index 0000000..3cb627f --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -0,0 +1,129 @@ +createAnnotationDriver(); + + $this->em = $this->_getTestEntityManager(); + $this->em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $this->factory = new ClassMetadataFactory; + $this->factory->setEntityManager($this->em); + $this->listener = new ResolveTargetEntityListener; + } + + /** + * @group DDC-1544 + */ + public function testResolveTargetEntityListenerCanResolveTargetEntity() + { + $evm = $this->em->getEventManager(); + $this->listener->addResolveTargetEntity( + 'Doctrine\Tests\ORM\Tools\ResolveTargetInterface', + 'Doctrine\Tests\ORM\Tools\ResolveTargetEntity', + array() + ); + $this->listener->addResolveTargetEntity( + 'Doctrine\Tests\ORM\Tools\TargetInterface', + 'Doctrine\Tests\ORM\Tools\TargetEntity', + array() + ); + $evm->addEventListener(Events::loadClassMetadata, $this->listener); + $cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity'); + $meta = $cm->associationMappings; + $this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['manyToMany']['targetEntity']); + $this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['manyToOne']['targetEntity']); + $this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['oneToMany']['targetEntity']); + $this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['oneToOne']['targetEntity']); + } +} + +interface ResolveTargetInterface +{ + public function getId(); +} + +interface TargetInterface extends ResolveTargetInterface +{ +} + +/** + * @Entity + */ +class ResolveTargetEntity implements ResolveTargetInterface +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + /** + * @ManyToMany(targetEntity="Doctrine\Tests\ORM\Tools\TargetInterface") + */ + private $manyToMany; + + /** + * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTargetInterface", inversedBy="oneToMany") + */ + private $manyToOne; + + /** + * @OneToMany(targetEntity="Doctrine\Tests\ORM\Tools\ResolveTargetInterface", mappedBy="manyToOne") + */ + private $oneToMany; + + /** + * @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\TargetInterface") + * @JoinColumn(name="target_entity_id", referencedColumnName="id") + */ + private $oneToOne; + + public function getId() + { + return $this->id; + } +} + +/** + * @Entity + */ +class TargetEntity implements TargetInterface +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + private $id; + + public function getId() + { + return $this->id; + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php new file mode 100644 index 0000000..6e4b62e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -0,0 +1,132 @@ +_getTestEntityManager(); + $schemaTool = new SchemaTool($em); + + $classes = array( + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsComment'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmployee'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), + ); + + $schema = $schemaTool->getSchemaFromMetadata($classes); + + $this->assertTrue($schema->hasTable('cms_users'), "Table cms_users should exist."); + $this->assertTrue($schema->getTable('cms_users')->columnsAreIndexed(array('username')), "username column should be indexed."); + } + + public function testColumnAnnotationOptionsAttribute() + { + $em = $this->_getTestEntityManager(); + $schemaTool = new SchemaTool($em); + + $classes = array( + $em->getClassMetadata(__NAMESPACE__ . '\\TestEntityWithColumnAnnotationOptionsAttribute'), + ); + + $schema = $schemaTool->getSchemaFromMetadata($classes); + + $expected = array('foo' => 'bar', 'baz' => array('key' => 'val')); + $this->assertEquals($expected, $schema->getTable('TestEntityWithColumnAnnotationOptionsAttribute')->getColumn('test')->getCustomSchemaOptions(), "options annotation are passed to the columns customSchemaOptions"); + } + + /** + * @group DDC-200 + */ + public function testPassColumnDefinitionToJoinColumn() + { + $customColumnDef = "MEDIUMINT(6) UNSIGNED NOT NULL"; + + $em = $this->_getTestEntityManager(); + $schemaTool = new SchemaTool($em); + + $avatar = $em->getClassMetadata('Doctrine\Tests\Models\Forum\ForumAvatar'); + $avatar->fieldMappings['id']['columnDefinition'] = $customColumnDef; + $user = $em->getClassMetadata('Doctrine\Tests\Models\Forum\ForumUser'); + + $classes = array($avatar, $user); + + $schema = $schemaTool->getSchemaFromMetadata($classes); + + $this->assertTrue($schema->hasTable('forum_users')); + $table = $schema->getTable("forum_users"); + $this->assertTrue($table->hasColumn('avatar_id')); + $this->assertEquals($customColumnDef, $table->getColumn('avatar_id')->getColumnDefinition()); + } + + /** + * @group DDC-283 + */ + public function testPostGenerateEvents() + { + $listener = new GenerateSchemaEventListener(); + + $em = $this->_getTestEntityManager(); + $em->getEventManager()->addEventListener( + array(ToolEvents::postGenerateSchemaTable, ToolEvents::postGenerateSchema), $listener + ); + $schemaTool = new SchemaTool($em); + + $classes = array( + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsComment'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmployee'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), + $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), + ); + + $schema = $schemaTool->getSchemaFromMetadata($classes); + + $this->assertEquals(count($classes), $listener->tableCalls); + $this->assertTrue($listener->schemaCalled); + } +} + +/** + * @Entity + */ +class TestEntityWithColumnAnnotationOptionsAttribute +{ + /** @Id @Column */ + private $id; + + /** + * @Column(type="string", options={"foo": "bar", "baz": {"key": "val"}}) + */ + private $test; +} + +class GenerateSchemaEventListener +{ + public $tableCalls = 0; + public $schemaCalled = false; + + public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs) + { + $this->tableCalls++; + } + + public function postGenerateSchema(GenerateSchemaEventArgs $eventArgs) + { + $this->schemaCalled = true; + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php new file mode 100644 index 0000000..6f2e912 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -0,0 +1,267 @@ +em = $this->_getTestEntityManager(); + $this->validator = new SchemaValidator($this->em); + } + + public function testCmsModelSet() + { + $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( + __DIR__ . "/../../Models/CMS" + )); + $this->validator->validateMapping(); + } + + public function testCompanyModelSet() + { + $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( + __DIR__ . "/../../Models/Company" + )); + $this->validator->validateMapping(); + } + + public function testECommerceModelSet() + { + $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( + __DIR__ . "/../../Models/ECommerce" + )); + $this->validator->validateMapping(); + } + + public function testForumModelSet() + { + $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( + __DIR__ . "/../../Models/Forum" + )); + $this->validator->validateMapping(); + } + + public function testNavigationModelSet() + { + $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( + __DIR__ . "/../../Models/Navigation" + )); + $this->validator->validateMapping(); + } + + public function testRoutingModelSet() + { + $this->em->getConfiguration()->getMetadataDriverImpl()->addPaths(array( + __DIR__ . "/../../Models/Routing" + )); + $this->validator->validateMapping(); + } + + /** + * @group DDC-1439 + */ + public function testInvalidManyToManyJoinColumnSchema() + { + $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity1'); + $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity2'); + + $ce = $this->validator->validateClass($class1); + + $this->assertEquals( + array( + "The inverse join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity2', however 'key4' are missing.", + "The join columns of the many-to-many table 'Entity1Entity2' have to contain to ALL identifier columns of the source entity 'Doctrine\Tests\ORM\Tools\InvalidEntity1', however 'key2' are missing." + ), + $ce + ); + } + + /** + * @group DDC-1439 + */ + public function testInvalidToOneJoinColumnSchema() + { + $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity1'); + $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\InvalidEntity2'); + + $ce = $this->validator->validateClass($class2); + + $this->assertEquals( + array( + "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\InvalidEntity1'.", + "The join columns of the association 'assoc' have to match to ALL identifier columns of the target entity 'Doctrine\Tests\ORM\Tools\InvalidEntity2', however 'key1, key2' are missing." + ), + $ce + ); + } + + /** + * @group DDC-1587 + */ + public function testValidOneToOneAsIdentifierSchema() + { + $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\DDC1587ValidEntity2'); + $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\DDC1587ValidEntity1'); + + $ce = $this->validator->validateClass($class1); + + $this->assertEquals(array(), $ce); + } + + /** + * @group DDC-1649 + */ + public function testInvalidTripleAssociationAsKeyMapping() + { + $classThree = $this->em->getClassMetadata(__NAMESPACE__ . '\DDC1649Three'); + $ce = $this->validator->validateClass($classThree); + + $this->assertEquals(Array( + "Cannot map association 'Doctrine\Tests\ORM\Tools\DDC1649Three#two as identifier, because the target entity 'Doctrine\Tests\ORM\Tools\DDC1649Two' also maps an association as identifier.", + "The referenced column name 'id' has to be a primary key column on the target entity class 'Doctrine\Tests\ORM\Tools\DDC1649Two'." + ), $ce); + } +} + +/** + * @Entity + */ +class InvalidEntity1 +{ + /** + * @Id @Column + */ + protected $key1; + /** + * @Id @Column + */ + protected $key2; + /** + * @ManyToMany (targetEntity="InvalidEntity2") + * @JoinTable (name="Entity1Entity2", + * joinColumns={@JoinColumn(name="key1", referencedColumnName="key1")}, + * inverseJoinColumns={@JoinColumn(name="key3", referencedColumnName="key3")} + * ) + */ + protected $entity2; +} + +/** + * @Entity + */ +class InvalidEntity2 +{ + /** + * @Id @Column + */ + protected $key3; + + /** + * @Id @Column + */ + protected $key4; + + /** + * @ManyToOne(targetEntity="InvalidEntity1") + */ + protected $assoc; +} + +/** + * @Entity(repositoryClass="Entity\Repository\Agent") + * @Table(name="agent") + */ +class DDC1587ValidEntity1 +{ + /** + * @var int + * + * @Id @GeneratedValue + * @Column(name="pk", type="integer") + */ + private $pk; + + /** + * @var string + * + * @Column(name="name", type="string", length=32) + */ + private $name; + + /** + * @var Identifier + * + * @OneToOne(targetEntity="DDC1587ValidEntity2", cascade={"all"}, mappedBy="agent") + * @JoinColumn(name="pk", referencedColumnName="pk_agent") + */ + private $identifier; +} + +/** + * @Entity + * @Table + */ +class DDC1587ValidEntity2 +{ + /** + * @var DDC1587ValidEntity1 + * + * @Id + * @OneToOne(targetEntity="DDC1587ValidEntity1", inversedBy="identifier") + * @JoinColumn(name="pk_agent", referencedColumnName="pk", nullable=false) + */ + private $agent; + + /** + * @var string + * + * @Column(name="num", type="string", length=16, nullable=true) + */ + private $num; +} + +/** + * @Entity + */ +class DDC1649One +{ + /** + * @Id @Column @GeneratedValue + */ + public $id; +} + +/** + * @Entity + */ +class DDC1649Two +{ + /** @Id @ManyToOne(targetEntity="DDC1649One")@JoinColumn(name="id", referencedColumnName="id") */ + public $one; +} + +/** + * @Entity + */ +class DDC1649Three +{ + /** @Id @ManyToOne(targetEntity="DDC1649Two") @JoinColumn(name="id", + * referencedColumnName="id") */ + private $two; +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SetupTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SetupTest.php new file mode 100644 index 0000000..50db4b2 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/SetupTest.php @@ -0,0 +1,110 @@ +markTestSkipped("Test only runs in a dev-installation from Github"); + } + + $this->originalAutoloaderCount = count(spl_autoload_functions()); + $this->originalIncludePath = get_include_path(); + } + + public function tearDown() + { + if ( ! $this->originalIncludePath) { + return; + } + + set_include_path($this->originalIncludePath); + $loaders = spl_autoload_functions(); + for ($i = 0; $i < count($loaders); $i++) { + if ($i > $this->originalAutoloaderCount+1) { + spl_autoload_unregister($loaders[$i]); + } + } + } + + public function testGitAutoload() + { + Setup::registerAutoloadGit(__DIR__ . "/../../../../../"); + + $this->assertEquals($this->originalAutoloaderCount + 4, count(spl_autoload_functions())); + } + + public function testPEARAutoload() + { + set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . "/../../../../../lib/vendor/doctrine-common/lib"); + + Setup::registerAutoloadPEAR(); + + $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); + } + + public function testDirectoryAutoload() + { + Setup::registerAutoloadDirectory(__DIR__ . "/../../../../../lib/vendor/doctrine-common/lib"); + + $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions())); + } + + public function testAnnotationConfiguration() + { + $config = Setup::createAnnotationMetadataConfiguration(array(), true); + + $this->assertInstanceOf('Doctrine\ORM\Configuration', $config); + $this->assertEquals(sys_get_temp_dir(), $config->getProxyDir()); + $this->assertEquals('DoctrineProxies', $config->getProxyNamespace()); + $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $config->getMetadataDriverImpl()); + } + + public function testXMLConfiguration() + { + $config = Setup::createXMLMetadataConfiguration(array(), true); + + $this->assertInstanceOf('Doctrine\ORM\Configuration', $config); + $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\XmlDriver', $config->getMetadataDriverImpl()); + } + + public function testYAMLConfiguration() + { + $config = Setup::createYAMLMetadataConfiguration(array(), true); + + $this->assertInstanceOf('Doctrine\ORM\Configuration', $config); + $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $config->getMetadataDriverImpl()); + } + + /** + * @group DDC-1350 + */ + public function testConfigureProxyDir() + { + $config = Setup::createAnnotationMetadataConfiguration(array(), true, "/foo"); + $this->assertEquals('/foo', $config->getProxyDir()); + } + + /** + * @group DDC-1350 + */ + public function testConfigureCache() + { + $cache = new ArrayCache(); + $config = Setup::createAnnotationMetadataConfiguration(array(), true, null, $cache); + + $this->assertSame($cache, $config->getResultCacheImpl()); + $this->assertSame($cache, $config->getMetadataCacheImpl()); + $this->assertSame($cache, $config->getQueryCacheImpl()); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml new file mode 100644 index 0000000..efa24c7 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Tools/doctrine1schema/schema.yml @@ -0,0 +1,28 @@ +User: + tableName: users + columns: + username: + type: string(255) + length: 100 + notnull: true + unique: true + password: + type: string(255) + clob: clob + test_alias as theAlias: + type: string(255) + indexes: + username: + fields: [username] + type: unique + +Profile: + columns: + first_name: string(255) + last_name: string(255) + user_id: integer + relations: + User: + onDelete: CASCADE + foreignType: one + type: one \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php new file mode 100644 index 0000000..9cc20ad --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -0,0 +1,312 @@ +_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock()); + $this->_emMock = EntityManagerMock::create($this->_connectionMock); + // SUT + $this->_unitOfWork = new UnitOfWorkMock($this->_emMock); + $this->_emMock->setUnitOfWork($this->_unitOfWork); + } + + protected function tearDown() { + } + + public function testRegisterRemovedOnNewEntityIsIgnored() + { + $user = new ForumUser(); + $user->username = 'romanb'; + $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); + $this->_unitOfWork->scheduleForDelete($user); + $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user)); + } + + + /* Operational tests */ + + public function testSavingSingleEntityWithIdentityColumnForcesInsert() + { + // Setup fake persister and id generator for identity generation + $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser")); + $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister); + //$idGeneratorMock = new IdentityIdGeneratorMock($this->_emMock); + //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $idGeneratorMock); + $userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); + + // Test + $user = new ForumUser(); + $user->username = 'romanb'; + $this->_unitOfWork->persist($user); + + // Check + $this->assertEquals(0, count($userPersister->getInserts())); + $this->assertEquals(0, count($userPersister->getUpdates())); + $this->assertEquals(0, count($userPersister->getDeletes())); + $this->assertFalse($this->_unitOfWork->isInIdentityMap($user)); + // should no longer be scheduled for insert + $this->assertTrue($this->_unitOfWork->isScheduledForInsert($user)); + + // Now lets check whether a subsequent commit() does anything + $userPersister->reset(); + + // Test + $this->_unitOfWork->commit(); + + // Check. + $this->assertEquals(1, count($userPersister->getInserts())); + $this->assertEquals(0, count($userPersister->getUpdates())); + $this->assertEquals(0, count($userPersister->getDeletes())); + + // should have an id + $this->assertTrue(is_numeric($user->id)); + } + + /** + * Tests a scenario where a save() operation is cascaded from a ForumUser + * to its associated ForumAvatar, both entities using IDENTITY id generation. + */ + public function testCascadedIdentityColumnInsert() + { + // Setup fake persister and id generator for identity generation + //ForumUser + $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser")); + $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister); + //$userIdGeneratorMock = new IdentityIdGeneratorMock($this->_emMock); + //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $userIdGeneratorMock); + $userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); + // ForumAvatar + $avatarPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumAvatar")); + $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumAvatar', $avatarPersister); + //$avatarIdGeneratorMock = new IdentityIdGeneratorMock($this->_emMock); + //$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumAvatar', $avatarIdGeneratorMock); + $avatarPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); + + // Test + $user = new ForumUser(); + $user->username = 'romanb'; + $avatar = new ForumAvatar(); + $user->avatar = $avatar; + $this->_unitOfWork->persist($user); // save cascaded to avatar + + $this->_unitOfWork->commit(); + + $this->assertTrue(is_numeric($user->id)); + $this->assertTrue(is_numeric($avatar->id)); + + $this->assertEquals(1, count($userPersister->getInserts())); + $this->assertEquals(0, count($userPersister->getUpdates())); + $this->assertEquals(0, count($userPersister->getDeletes())); + + $this->assertEquals(1, count($avatarPersister->getInserts())); + $this->assertEquals(0, count($avatarPersister->getUpdates())); + $this->assertEquals(0, count($avatarPersister->getDeletes())); + } + + public function testChangeTrackingNotify() + { + $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\ORM\NotifyChangedEntity")); + $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\NotifyChangedEntity', $persister); + $itemPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\ORM\NotifyChangedRelatedItem")); + $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\NotifyChangedRelatedItem', $itemPersister); + + $entity = new NotifyChangedEntity; + $entity->setData('thedata'); + $this->_unitOfWork->persist($entity); + + $this->_unitOfWork->commit(); + $this->assertEquals(1, count($persister->getInserts())); + $persister->reset(); + + $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); + + $entity->setData('newdata'); + $entity->setTransient('newtransientvalue'); + + $this->assertTrue($this->_unitOfWork->isScheduledForDirtyCheck($entity)); + + $this->assertEquals(array('data' => array('thedata', 'newdata')), $this->_unitOfWork->getEntityChangeSet($entity)); + + $item = new NotifyChangedRelatedItem(); + $entity->getItems()->add($item); + $item->setOwner($entity); + $this->_unitOfWork->persist($item); + + $this->_unitOfWork->commit(); + $this->assertEquals(1, count($itemPersister->getInserts())); + $persister->reset(); + $itemPersister->reset(); + + + $entity->getItems()->removeElement($item); + $item->setOwner(null); + $this->assertTrue($entity->getItems()->isDirty()); + $this->_unitOfWork->commit(); + $updates = $itemPersister->getUpdates(); + $this->assertEquals(1, count($updates)); + $this->assertTrue($updates[0] === $item); + } + + public function testGetEntityStateOnVersionedEntityWithAssignedIdentifier() + { + $persister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\ORM\VersionedAssignedIdentifierEntity")); + $this->_unitOfWork->setEntityPersister('Doctrine\Tests\ORM\VersionedAssignedIdentifierEntity', $persister); + + $e = new VersionedAssignedIdentifierEntity(); + $e->id = 42; + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($e)); + $this->assertFalse($persister->isExistsCalled()); + } + + public function testGetEntityStateWithAssignedIdentity() + { + $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->phonenumber = '12345'; + + $this->assertEquals(UnitOfWork::STATE_NEW, $this->_unitOfWork->getEntityState($ph)); + $this->assertTrue($persister->isExistsCalled()); + + $persister->reset(); + + // if the entity is already managed the exists() check should be skipped + $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->phonenumber = '12345'; + $this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); + $this->assertFalse($persister->isExistsCalled()); + } +} + +/** + * @Entity + */ +class NotifyChangedEntity implements \Doctrine\Common\NotifyPropertyChanged +{ + private $_listeners = array(); + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + private $id; + /** + * @Column(type="string") + */ + private $data; + + private $transient; // not persisted + + /** @OneToMany(targetEntity="NotifyChangedRelatedItem", mappedBy="owner") */ + private $items; + + public function __construct() { + $this->items = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function getId() { + return $this->id; + } + + public function getItems() { + return $this->items; + } + + public function setTransient($value) { + if ($value != $this->transient) { + $this->_onPropertyChanged('transient', $this->transient, $value); + $this->transient = $value; + } + } + + public function getData() { + return $this->data; + } + + public function setData($data) { + if ($data != $this->data) { + $this->_onPropertyChanged('data', $this->data, $data); + $this->data = $data; + } + } + + public function addPropertyChangedListener(\Doctrine\Common\PropertyChangedListener $listener) + { + $this->_listeners[] = $listener; + } + + protected function _onPropertyChanged($propName, $oldValue, $newValue) { + if ($this->_listeners) { + foreach ($this->_listeners as $listener) { + $listener->propertyChanged($this, $propName, $oldValue, $newValue); + } + } + } +} + +/** @Entity */ +class NotifyChangedRelatedItem +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue + */ + private $id; + + /** @ManyToOne(targetEntity="NotifyChangedEntity", inversedBy="items") */ + private $owner; + + public function getId() { + return $this->id; + } + + public function getOwner() { + return $this->owner; + } + + public function setOwner($owner) { + $this->owner = $owner; + } +} + +/** @Entity */ +class VersionedAssignedIdentifierEntity +{ + /** + * @Id @Column(type="integer") + */ + public $id; + /** + * @Version @Column(type="integer") + */ + public $version; +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php new file mode 100644 index 0000000..4b92ed5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -0,0 +1,415 @@ + array( + 'Doctrine\Tests\Models\CMS\CmsUser', + 'Doctrine\Tests\Models\CMS\CmsPhonenumber', + 'Doctrine\Tests\Models\CMS\CmsAddress', + 'Doctrine\Tests\Models\CMS\CmsEmail', + 'Doctrine\Tests\Models\CMS\CmsGroup', + 'Doctrine\Tests\Models\CMS\CmsArticle', + 'Doctrine\Tests\Models\CMS\CmsComment', + ), + 'forum' => array(), + 'company' => array( + '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\CompanyContract', + ), + 'ecommerce' => array( + 'Doctrine\Tests\Models\ECommerce\ECommerceCart', + 'Doctrine\Tests\Models\ECommerce\ECommerceCustomer', + 'Doctrine\Tests\Models\ECommerce\ECommerceProduct', + 'Doctrine\Tests\Models\ECommerce\ECommerceShipping', + 'Doctrine\Tests\Models\ECommerce\ECommerceFeature', + 'Doctrine\Tests\Models\ECommerce\ECommerceCategory' + ), + 'generic' => array( + 'Doctrine\Tests\Models\Generic\BooleanModel', + 'Doctrine\Tests\Models\Generic\DateTimeModel', + 'Doctrine\Tests\Models\Generic\DecimalModel', + 'Doctrine\Tests\Models\Generic\SerializationModel', + ), + 'routing' => array( + 'Doctrine\Tests\Models\Routing\RoutingLeg', + 'Doctrine\Tests\Models\Routing\RoutingLocation', + 'Doctrine\Tests\Models\Routing\RoutingRoute', + 'Doctrine\Tests\Models\Routing\RoutingRouteBooking', + ), + 'navigation' => array( + 'Doctrine\Tests\Models\Navigation\NavCountry', + 'Doctrine\Tests\Models\Navigation\NavPhotos', + 'Doctrine\Tests\Models\Navigation\NavTour', + 'Doctrine\Tests\Models\Navigation\NavPointOfInterest', + ), + 'directorytree' => array( + 'Doctrine\Tests\Models\DirectoryTree\AbstractContentItem', + 'Doctrine\Tests\Models\DirectoryTree\File', + 'Doctrine\Tests\Models\DirectoryTree\Directory', + ), + 'ddc117' => array( + 'Doctrine\Tests\Models\DDC117\DDC117Article', + 'Doctrine\Tests\Models\DDC117\DDC117Reference', + 'Doctrine\Tests\Models\DDC117\DDC117Translation', + 'Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', + 'Doctrine\Tests\Models\DDC117\DDC117ApproveChanges', + 'Doctrine\Tests\Models\DDC117\DDC117Editor', + 'Doctrine\Tests\Models\DDC117\DDC117Link', + ), + 'stockexchange' => array( + 'Doctrine\Tests\Models\StockExchange\Bond', + 'Doctrine\Tests\Models\StockExchange\Stock', + 'Doctrine\Tests\Models\StockExchange\Market', + ), + 'legacy' => array( + 'Doctrine\Tests\Models\Legacy\LegacyUser', + 'Doctrine\Tests\Models\Legacy\LegacyUserReference', + 'Doctrine\Tests\Models\Legacy\LegacyArticle', + 'Doctrine\Tests\Models\Legacy\LegacyCar', + ), + 'customtype' => array( + 'Doctrine\Tests\Models\CustomType\CustomTypeChild', + 'Doctrine\Tests\Models\CustomType\CustomTypeParent', + 'Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', + ), + ); + + protected function useModelSet($setName) + { + $this->_usedModelSets[$setName] = true; + } + + /** + * Sweeps the database tables and clears the EntityManager. + */ + protected function tearDown() + { + $conn = static::$_sharedConn; + + $this->_sqlLoggerStack->enabled = false; + + if (isset($this->_usedModelSets['cms'])) { + $conn->executeUpdate('DELETE FROM cms_users_groups'); + $conn->executeUpdate('DELETE FROM cms_groups'); + $conn->executeUpdate('DELETE FROM cms_addresses'); + $conn->executeUpdate('DELETE FROM cms_phonenumbers'); + $conn->executeUpdate('DELETE FROM cms_comments'); + $conn->executeUpdate('DELETE FROM cms_articles'); + $conn->executeUpdate('DELETE FROM cms_users'); + } + + if (isset($this->_usedModelSets['ecommerce'])) { + $conn->executeUpdate('DELETE FROM ecommerce_carts_products'); + $conn->executeUpdate('DELETE FROM ecommerce_products_categories'); + $conn->executeUpdate('DELETE FROM ecommerce_products_related'); + $conn->executeUpdate('DELETE FROM ecommerce_carts'); + $conn->executeUpdate('DELETE FROM ecommerce_customers'); + $conn->executeUpdate('DELETE FROM ecommerce_features'); + $conn->executeUpdate('DELETE FROM ecommerce_products'); + $conn->executeUpdate('DELETE FROM ecommerce_shippings'); + $conn->executeUpdate('UPDATE ecommerce_categories SET parent_id = NULL'); + $conn->executeUpdate('DELETE FROM ecommerce_categories'); + } + + if (isset($this->_usedModelSets['company'])) { + $conn->executeUpdate('DELETE FROM company_contract_employees'); + $conn->executeUpdate('DELETE FROM company_contract_managers'); + $conn->executeUpdate('DELETE FROM company_contracts'); + $conn->executeUpdate('DELETE FROM company_persons_friends'); + $conn->executeUpdate('DELETE FROM company_managers'); + $conn->executeUpdate('DELETE FROM company_employees'); + $conn->executeUpdate('UPDATE company_persons SET spouse_id = NULL'); + $conn->executeUpdate('DELETE FROM company_persons'); + $conn->executeUpdate('DELETE FROM company_raffles'); + $conn->executeUpdate('DELETE FROM company_auctions'); + $conn->executeUpdate('UPDATE company_organizations SET main_event_id = NULL'); + $conn->executeUpdate('DELETE FROM company_events'); + $conn->executeUpdate('DELETE FROM company_organizations'); + } + + if (isset($this->_usedModelSets['generic'])) { + $conn->executeUpdate('DELETE FROM boolean_model'); + $conn->executeUpdate('DELETE FROM date_time_model'); + $conn->executeUpdate('DELETE FROM decimal_model'); + $conn->executeUpdate('DELETE FROM serialize_model'); + } + + if (isset($this->_usedModelSets['routing'])) { + $conn->executeUpdate('DELETE FROM RoutingRouteLegs'); + $conn->executeUpdate('DELETE FROM RoutingRouteBooking'); + $conn->executeUpdate('DELETE FROM RoutingRoute'); + $conn->executeUpdate('DELETE FROM RoutingLeg'); + $conn->executeUpdate('DELETE FROM RoutingLocation'); + } + + if(isset($this->_usedModelSets['navigation'])) { + $conn->executeUpdate('DELETE FROM navigation_tour_pois'); + $conn->executeUpdate('DELETE FROM navigation_photos'); + $conn->executeUpdate('DELETE FROM navigation_pois'); + $conn->executeUpdate('DELETE FROM navigation_tours'); + $conn->executeUpdate('DELETE FROM navigation_countries'); + } + if (isset($this->_usedModelSets['directorytree'])) { + $conn->executeUpdate('DELETE FROM ' . $this->_em->getConnection()->getDatabasePlatform()->quoteIdentifier("file")); + // MySQL doesnt know deferred deletions therefore only executing the second query gives errors. + $conn->executeUpdate('DELETE FROM Directory WHERE parentDirectory_id IS NOT NULL'); + $conn->executeUpdate('DELETE FROM Directory'); + } + if (isset($this->_usedModelSets['ddc117'])) { + return; + $conn->executeUpdate('DELETE FROM ddc117editor_ddc117translation'); + $conn->executeUpdate('DELETE FROM DDC117Editor'); + $conn->executeUpdate('DELETE FROM DDC117ApproveChanges'); + $conn->executeUpdate('DELETE FROM DDC117Link'); + $conn->executeUpdate('DELETE FROM DDC117Reference'); + $conn->executeUpdate('DELETE FROM DDC117ArticleDetails'); + $conn->executeUpdate('DELETE FROM DDC117Translation'); + $conn->executeUpdate('DELETE FROM DDC117Article'); + } + if (isset($this->_usedModelSets['stockexchange'])) { + $conn->executeUpdate('DELETE FROM exchange_bonds_stocks'); + $conn->executeUpdate('DELETE FROM exchange_bonds'); + $conn->executeUpdate('DELETE FROM exchange_stocks'); + $conn->executeUpdate('DELETE FROM exchange_markets'); + } + if (isset($this->_usedModelSets['legacy'])) { + $conn->executeUpdate('DELETE FROM legacy_users_cars'); + $conn->executeUpdate('DELETE FROM legacy_users_reference'); + $conn->executeUpdate('DELETE FROM legacy_articles'); + $conn->executeUpdate('DELETE FROM legacy_cars'); + $conn->executeUpdate('DELETE FROM legacy_users'); + } + + if (isset($this->_usedModelSets['customtype'])) { + $conn->executeUpdate('DELETE FROM customtype_parent_friends'); + $conn->executeUpdate('DELETE FROM customtype_parents'); + $conn->executeUpdate('DELETE FROM customtype_children'); + $conn->executeUpdate('DELETE FROM customtype_uppercases'); + } + + $this->_em->clear(); + } + + protected function setUpEntitySchema(array $classNames) + { + if ($this->_em === null) { + throw new \RuntimeException("EntityManager not set, you have to call parent::setUp() before invoking this method."); + } + + $classes = array(); + foreach ($classNames as $className) { + if ( ! isset(static::$_entityTablesCreated[$className])) { + static::$_entityTablesCreated[$className] = true; + $classes[] = $this->_em->getClassMetadata($className); + } + } + + if ($classes) { + $this->_schemaTool->createSchema($classes); + } + } + + /** + * Creates a connection to the test database, if there is none yet, and + * creates the necessary tables. + */ + protected function setUp() + { + $forceCreateTables = false; + + if ( ! isset(static::$_sharedConn)) { + static::$_sharedConn = TestUtil::getConnection(); + + if (static::$_sharedConn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) { + $forceCreateTables = true; + } + } + + if (isset($GLOBALS['DOCTRINE_MARK_SQL_LOGS'])) { + if (in_array(static::$_sharedConn->getDatabasePlatform()->getName(), array("mysql", "postgresql"))) { + static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/'); + } else if (static::$_sharedConn->getDatabasePlatform()->getName() == "oracle") { + static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/ FROM dual'); + } + } + + if ( ! $this->_em) { + $this->_em = $this->_getEntityManager(); + $this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em); + } + + $classes = array(); + + foreach ($this->_usedModelSets as $setName => $bool) { + if ( ! isset(static::$_tablesCreated[$setName])/* || $forceCreateTables*/) { + foreach (static::$_modelSets[$setName] as $className) { + $classes[] = $this->_em->getClassMetadata($className); + } + + static::$_tablesCreated[$setName] = true; + } + } + + if ($classes) { + $this->_schemaTool->createSchema($classes); + } + + $this->_sqlLoggerStack->enabled = true; + } + + /** + * Gets an EntityManager for testing purposes. + * + * @param Configuration $config The Configuration to pass to the EntityManager. + * @param EventManager $eventManager The EventManager to pass to the EntityManager. + * @return EntityManager + */ + protected function _getEntityManager($config = null, $eventManager = null) { + // NOTE: Functional tests use their own shared metadata cache, because + // the actual database platform used during execution has effect on some + // metadata mapping behaviors (like the choice of the ID generation). + if (is_null(self::$_metadataCacheImpl)) { + if (isset($GLOBALS['DOCTRINE_CACHE_IMPL'])) { + self::$_metadataCacheImpl = new $GLOBALS['DOCTRINE_CACHE_IMPL']; + } else { + self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + } + } + + if (is_null(self::$_queryCacheImpl)) { + self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + } + + $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); + $this->_sqlLoggerStack->enabled = false; + + //FIXME: two different configs! $conn and the created entity manager have + // different configs. + $config = new \Doctrine\ORM\Configuration(); + $config->setMetadataCacheImpl(self::$_metadataCacheImpl); + $config->setQueryCacheImpl(self::$_queryCacheImpl); + $config->setProxyDir(__DIR__ . '/Proxies'); + $config->setProxyNamespace('Doctrine\Tests\Proxies'); + + $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver()); + + $conn = static::$_sharedConn; + $conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); + + // get rid of more global state + $evm = $conn->getEventManager(); + foreach ($evm->getListeners() AS $event => $listeners) { + foreach ($listeners AS $listener) { + $evm->removeEventListener(array($event), $listener); + } + } + + if (isset($GLOBALS['db_event_subscribers'])) { + foreach (explode(",", $GLOBALS['db_event_subscribers']) AS $subscriberClass) { + $subscriberInstance = new $subscriberClass(); + $evm->addEventSubscriber($subscriberInstance); + } + } + + if (isset($GLOBALS['debug_uow_listener'])) { + $evm->addEventListener(array('onFlush'), new \Doctrine\ORM\Tools\DebugUnitOfWorkListener()); + } + + return \Doctrine\ORM\EntityManager::create($conn, $config); + } + + protected function onNotSuccessfulTest(\Exception $e) + { + if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { + throw $e; + } + + 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; + } + + $trace = $e->getTrace(); + $traceMsg = ""; + foreach($trace AS $part) { + if(isset($part['file'])) { + if(strpos($part['file'], "PHPUnit/") !== false) { + // Beginning with PHPUnit files we don't print the trace anymore. + break; + } + + $traceMsg .= $part['file'].":".$part['line'].PHP_EOL; + } + } + + $message = "[".get_class($e)."] ".$e->getMessage().PHP_EOL.PHP_EOL."With queries:".PHP_EOL.$queries.PHP_EOL."Trace:".PHP_EOL.$traceMsg; + + throw new \Exception($message, (int)$e->getCode(), $e); + } + throw $e; + } + + /** + * Using the SQL Logger Stack this method retrieves the current query count executed in this test. + * + * @return int + */ + protected function getCurrentQueryCount() + { + return count($this->_sqlLoggerStack->queries); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmPerformanceTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmPerformanceTestCase.php new file mode 100644 index 0000000..ab8fcf5 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmPerformanceTestCase.php @@ -0,0 +1,60 @@ +maxRunningTime != 0 && $time > $this->maxRunningTime) { + $this->fail( + sprintf( + 'expected running time: <= %s but was: %s', + + $this->maxRunningTime, + $time + ) + ); + } + } + + /** + * @param integer $maxRunningTime + * @throws InvalidArgumentException + * @since Method available since Release 2.3.0 + */ + public function setMaxRunningTime($maxRunningTime) + { + if (is_integer($maxRunningTime) && $maxRunningTime >= 0) { + $this->maxRunningTime = $maxRunningTime; + } else { + throw new \InvalidArgumentException; + } + } + + /** + * @return integer + * @since Method available since Release 2.3.0 + */ + public function getMaxRunningTime() + { + return $this->maxRunningTime; + } +} + diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php new file mode 100644 index 0000000..f9260d6 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/OrmTestCase.php @@ -0,0 +1,122 @@ +=')) { + $reader = new \Doctrine\Common\Annotations\CachedReader( + new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache() + ); + } + else if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { + // Register the ORM Annotations in the AnnotationRegistry + $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); + $reader->addNamespace('Doctrine\ORM\Mapping'); + $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); + } + else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) { + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + $reader->setIgnoreNotImportedAnnotations(true); + $reader->setEnableParsePhpImports(false); + if ($alias) { + $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); + } else { + $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); + } + $reader = new \Doctrine\Common\Annotations\CachedReader( + new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() + ); + } else { + $reader = new \Doctrine\Common\Annotations\AnnotationReader(); + if ($alias) { + $reader->setAnnotationNamespaceAlias('Doctrine\ORM\Mapping\\', $alias); + } else { + $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); + } + } + \Doctrine\Common\Annotations\AnnotationRegistry::registerFile( + __DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); + return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array)$paths); + } + + /** + * Creates an EntityManager for testing purposes. + * + * NOTE: The created EntityManager will have its dependant DBAL parts completely + * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then + * be configured in the tests to simulate the DBAL behavior that is desired + * for a particular test, + * + * @return Doctrine\ORM\EntityManager + */ + protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true) + { + $metadataCache = $withSharedMetadata + ? self::getSharedMetadataCacheImpl() + : new \Doctrine\Common\Cache\ArrayCache; + + $config = new \Doctrine\ORM\Configuration(); + + $config->setMetadataCacheImpl($metadataCache); + $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver()); + $config->setQueryCacheImpl(self::getSharedQueryCacheImpl()); + $config->setProxyDir(__DIR__ . '/Proxies'); + $config->setProxyNamespace('Doctrine\Tests\Proxies'); + + if ($conn === null) { + $conn = array( + 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock', + 'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock', + 'user' => 'john', + 'password' => 'wayne' + ); + } + + if (is_array($conn)) { + $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager); + } + + return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager); + } + + private static function getSharedMetadataCacheImpl() + { + if (self::$_metadataCacheImpl === null) { + self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + } + + return self::$_metadataCacheImpl; + } + + private static function getSharedQueryCacheImpl() + { + if (self::$_queryCacheImpl === null) { + self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; + } + + return self::$_queryCacheImpl; + } + + public function assertSQLEquals($expectedSQL, $actualSQL, $failureMessage = null) + { + return $this->assertEquals(strtolower($expectedSQL), strtolower($actualSQL), $failureMessage); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/TestInit.php b/vendor/doctrine/orm/tests/Doctrine/Tests/TestInit.php new file mode 100644 index 0000000..3a35c21 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/TestInit.php @@ -0,0 +1,43 @@ +register(); + +if (isset($GLOBALS['DOCTRINE_DBAL_PATH'])) { + $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', $GLOBALS['DOCTRINE_DBAL_PATH']); +} else { + $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', __DIR__ . '/../../../lib/vendor/doctrine-dbal/lib'); +} +$classLoader->register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', __DIR__ . '/../../../lib'); +$classLoader->register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Tests', __DIR__ . '/../../'); +$classLoader->register(); + +$classLoader = new \Doctrine\Common\ClassLoader('Symfony', __DIR__ . "/../../../lib/vendor"); +$classLoader->register(); + +if (!file_exists(__DIR__."/Proxies")) { + if (!mkdir(__DIR__."/Proxies")) { + throw new Exception("Could not create " . __DIR__."/Proxies Folder."); + } +} +if (!file_exists(__DIR__."/ORM/Proxy/generated")) { + if (!mkdir(__DIR__."/ORM/Proxy/generated")) { + throw new Exception("Could not create " . __DIR__."/ORM/Proxy/generated Folder."); + } +} diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/TestUtil.php b/vendor/doctrine/orm/tests/Doctrine/Tests/TestUtil.php new file mode 100644 index 0000000..b78d06e --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/TestUtil.php @@ -0,0 +1,119 @@ +real database connection using the following parameters + * of the $GLOBALS array: + * + * 'db_type' : The name of the Doctrine DBAL database driver to use. + * 'db_username' : The username to use for connecting. + * 'db_password' : The password to use for connecting. + * 'db_host' : The hostname of the database to connect to. + * 'db_name' : The name of the database to connect to. + * 'db_port' : The port of the database to connect to. + * + * Usually these variables of the $GLOBALS array are filled by PHPUnit based + * on an XML configuration file. If no such parameters exist, an SQLite + * in-memory database is used. + * + * IMPORTANT: + * 1) Each invocation of this method returns a NEW database connection. + * 2) The database is dropped and recreated to ensure it's clean. + * + * @return Doctrine\DBAL\Connection The database connection instance. + */ + public static function getConnection() + { + if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'], + $GLOBALS['db_host'], $GLOBALS['db_name'], $GLOBALS['db_port']) && + isset($GLOBALS['tmpdb_type'], $GLOBALS['tmpdb_username'], $GLOBALS['tmpdb_password'], + $GLOBALS['tmpdb_host'], $GLOBALS['tmpdb_name'], $GLOBALS['tmpdb_port'])) { + $realDbParams = array( + 'driver' => $GLOBALS['db_type'], + 'user' => $GLOBALS['db_username'], + 'password' => $GLOBALS['db_password'], + 'host' => $GLOBALS['db_host'], + 'dbname' => $GLOBALS['db_name'], + 'port' => $GLOBALS['db_port'] + ); + $tmpDbParams = array( + 'driver' => $GLOBALS['tmpdb_type'], + 'user' => $GLOBALS['tmpdb_username'], + 'password' => $GLOBALS['tmpdb_password'], + 'host' => $GLOBALS['tmpdb_host'], + 'dbname' => $GLOBALS['tmpdb_name'], + 'port' => $GLOBALS['tmpdb_port'] + ); + + $realConn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams); + + $platform = $realConn->getDatabasePlatform(); + + if ($platform->supportsCreateDropDatabase()) { + $dbname = $realConn->getDatabase(); + // Connect to tmpdb in order to drop and create the real test db. + $tmpConn = \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); + $realConn->close(); + + $tmpConn->getSchemaManager()->dropDatabase($dbname); + $tmpConn->getSchemaManager()->createDatabase($dbname); + + $tmpConn->close(); + } else { + $sm = $realConn->getSchemaManager(); + + /* @var $schema Schema */ + $schema = $sm->createSchema(); + $stmts = $schema->toDropSql($realConn->getDatabasePlatform()); + + foreach ($stmts AS $stmt) { + try { + $realConn->exec($stmt); + } catch(\Exception $e) { + // TODO: Now is this a real good idea? + } + } + } + + $conn = \Doctrine\DBAL\DriverManager::getConnection($realDbParams, null, null); + } else { + $params = array( + 'driver' => 'pdo_sqlite', + 'memory' => true + ); + if (isset($GLOBALS['db_path'])) { + $params['path'] = $GLOBALS['db_path']; + unlink($GLOBALS['db_path']); + } + $conn = \Doctrine\DBAL\DriverManager::getConnection($params); + } + + return $conn; + } + + /** + * @return \Doctrine\DBAL\Connection + */ + public static function getTempConnection() + { + $tmpDbParams = array( + 'driver' => $GLOBALS['tmpdb_type'], + 'user' => $GLOBALS['tmpdb_username'], + 'password' => $GLOBALS['tmpdb_password'], + 'host' => $GLOBALS['tmpdb_host'], + 'dbname' => $GLOBALS['tmpdb_name'], + 'port' => $GLOBALS['tmpdb_port'] + ); + + // Connect to tmpdb in order to drop and create the real test db. + return \Doctrine\DBAL\DriverManager::getConnection($tmpDbParams); + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/NativePhpunitTask.php b/vendor/doctrine/orm/tests/NativePhpunitTask.php new file mode 100644 index 0000000..8a3b190 --- /dev/null +++ b/vendor/doctrine/orm/tests/NativePhpunitTask.php @@ -0,0 +1,249 @@ + + */ +class NativePhpunitTask extends Task +{ + private $test; + private $testfile; + private $testdirectory; + private $configuration = null; + private $coverageClover = null; + private $junitlogfile = null; + private $haltonfailure = true; + private $haltonerror = true; + + public function setTestdirectory($directory) { + $this->testdirectory = $directory; + } + + public function setTest($test) { + $this->test = $test; + } + + public function setTestfile($testfile) { + $this->testfile = $testfile; + } + + public function setJunitlogfile($junitlogfile) { + if (strlen($junitlogfile) == 0) { + $junitlogfile = NULL; + } + + $this->junitlogfile = $junitlogfile; + } + + public function setConfiguration($configuration) { + if (strlen($configuration) == 0) { + $configuration = NULL; + } + + $this->configuration = $configuration; + } + + public function setCoverageClover($coverageClover) { + if (strlen($coverageClover) == 0) { + $coverageClover = NULL; + } + + $this->coverageClover = $coverageClover; + } + + public function setHaltonfailure($haltonfailures) { + $this->haltonfailure = $haltonfailures; + } + + public function setHaltonerror($haltonerrors) { + $this->haltonerror = $haltonerrors; + } + + public function init() + { + require_once "PHPUnit/Runner/Version.php"; + $version = PHPUnit_Runner_Version::id(); + + if (version_compare($version, '3.4.0') < 0) + { + throw new BuildException("NativePHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation()); + } + + require_once 'PHPUnit/Util/Filter.php'; + + // point PHPUnit_MAIN_METHOD define to non-existing method + if (!defined('PHPUnit_MAIN_METHOD')) + { + define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined'); + } + } + + public function main() + { + if (!is_dir(realpath($this->testdirectory))) { + throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '".$this->testdirectory."' given."); + } + set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path()); + + $printer = new NativePhpunitPrinter(); + + $arguments = array( + 'configuration' => $this->configuration, + 'coverageClover' => $this->coverageClover, + 'junitLogfile' => $this->junitlogfile, + 'printer' => $printer, + ); + + require_once "PHPUnit/TextUI/TestRunner.php"; + $runner = new PHPUnit_TextUI_TestRunner(); + $suite = $runner->getTest($this->test, $this->testfile, true); + + try { + $result = $runner->doRun($suite, $arguments); + /* @var $result PHPUnit_Framework_TestResult */ + + if ( ($this->haltonfailure && $result->failureCount() > 0) || ($this->haltonerror && $result->errorCount() > 0) ) { + throw new BuildException("PHPUnit: ".$result->failureCount()." Failures and ".$result->errorCount()." Errors, ". + "last failure message: ".$printer->getMessages()); + } + + $this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ". + "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); + + // Hudson for example doesn't like the backslash in class names + if (file_exists($this->coverageClover)) { + $this->log("Generated Clover Coverage XML to: ".$this->coverageClover); + $content = file_get_contents($this->coverageClover); + $content = str_replace("\\", ".", $content); + file_put_contents($this->coverageClover, $content); + unset($content); + } + + } catch(\Exception $e) { + throw new BuildException("NativePhpunitTask failed: ".$e->getMessage()); + } + } +} + +class NativePhpunitPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener +{ + private $_messages = array(); + + public function write($buffer) + { + // do nothing + } + + public function getMessages() + { + return $this->_messages; + } + + /** + * An error occurred. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) + { + $this->_messages[] = "Test ERROR: ".$test->getName().": ".$e->getMessage(); + } + + /** + * A failure occurred. + * + * @param PHPUnit_Framework_Test $test + * @param PHPUnit_Framework_AssertionFailedError $e + * @param float $time + */ + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + { + $this->_messages[] = "Test FAILED: ".$test->getName().": ".$e->getMessage(); + } + + /** + * Incomplete test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + */ + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + + } + + /** + * Skipped test. + * + * @param PHPUnit_Framework_Test $test + * @param Exception $e + * @param float $time + * @since Method available since Release 3.0.0 + */ + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + { + + } + + /** + * A test suite started. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) + { + + } + + /** + * A test suite ended. + * + * @param PHPUnit_Framework_TestSuite $suite + * @since Method available since Release 2.2.0 + */ + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) + { + + } + + /** + * A test started. + * + * @param PHPUnit_Framework_Test $test + */ + public function startTest(PHPUnit_Framework_Test $test) + { + + } + + /** + * A test ended. + * + * @param PHPUnit_Framework_Test $test + * @param float $time + */ + public function endTest(PHPUnit_Framework_Test $test, $time) + { + + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/README.markdown b/vendor/doctrine/orm/tests/README.markdown new file mode 100644 index 0000000..c1027ac --- /dev/null +++ b/vendor/doctrine/orm/tests/README.markdown @@ -0,0 +1,25 @@ +# Running the Doctrine 2 Testsuite + +## Setting up a PHPUnit Configuration XML + +.. + +## Testing Lock-Support + +The Lock support in Doctrine 2 is tested using Gearman, which allows to run concurrent tasks in parallel. +Install Gearman with PHP as follows: + +1. Go to http://www.gearman.org and download the latest Gearman Server +2. Compile it and then call ldconfig +3. Start it up "gearmand -vvvv" +4. Install pecl/gearman by calling "gearman-beta" + +You can then go into tests/ and start up two workers: + + php Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php + +Then run the locking test-suite: + + phpunit --configuration Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php + +This can run considerable time, because it is using sleep() to test for the timing ranges of locks. \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/dbproperties.xml.dev b/vendor/doctrine/orm/tests/dbproperties.xml.dev new file mode 100644 index 0000000..503cb85 --- /dev/null +++ b/vendor/doctrine/orm/tests/dbproperties.xml.dev @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/travis/mysql.travis.xml b/vendor/doctrine/orm/tests/travis/mysql.travis.xml new file mode 100644 index 0000000..f17a4b8 --- /dev/null +++ b/vendor/doctrine/orm/tests/travis/mysql.travis.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + ./../Doctrine/Tests/ORM + + + + + performance + locking_functional + + + + + diff --git a/vendor/doctrine/orm/tests/travis/pgsql.travis.xml b/vendor/doctrine/orm/tests/travis/pgsql.travis.xml new file mode 100644 index 0000000..fa0581a --- /dev/null +++ b/vendor/doctrine/orm/tests/travis/pgsql.travis.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + ./../Doctrine/Tests/ORM + + + + + + performance + locking_functional + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tests/travis/sqlite.travis.xml b/vendor/doctrine/orm/tests/travis/sqlite.travis.xml new file mode 100644 index 0000000..5d310c3 --- /dev/null +++ b/vendor/doctrine/orm/tests/travis/sqlite.travis.xml @@ -0,0 +1,15 @@ + + + + + ./../Doctrine/Tests/ORM + + + + + performance + locking_functional + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/Entities/Address.php b/vendor/doctrine/orm/tools/sandbox/Entities/Address.php new file mode 100644 index 0000000..717ea63 --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/Entities/Address.php @@ -0,0 +1,45 @@ +id; + } + + public function getStreet() + { + return $this->street; + } + + public function setStreet($street) + { + $this->street = $street; + } + + public function getUser() + { + return $this->user; + } + + public function setUser(User $user) + { + if ($this->user !== $user) { + $this->user = $user; + $user->setAddress($this); + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/Entities/User.php b/vendor/doctrine/orm/tools/sandbox/Entities/User.php new file mode 100644 index 0000000..cd18421 --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/Entities/User.php @@ -0,0 +1,48 @@ +id; + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + public function getAddress() + { + return $this->address; + } + + public function setAddress(Address $address) + { + if ($this->address !== $address) { + $this->address = $address; + $address->setUser($this); + } + } +} \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/cli-config.php b/vendor/doctrine/orm/tools/sandbox/cli-config.php new file mode 100644 index 0000000..c949668 --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/cli-config.php @@ -0,0 +1,36 @@ +register(); +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); +$classLoader->register(); + +$config = new \Doctrine\ORM\Configuration(); +$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); +$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); +$config->setMetadataDriverImpl($driverImpl); + +$config->setProxyDir(__DIR__ . '/Proxies'); +$config->setProxyNamespace('Proxies'); + +$connectionOptions = array( + 'driver' => 'pdo_sqlite', + 'path' => 'database.sqlite' +); + +$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); + +$helpers = array( + 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), + 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) +); \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/doctrine b/vendor/doctrine/orm/tools/sandbox/doctrine new file mode 100755 index 0000000..92f323f --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/doctrine @@ -0,0 +1,4 @@ +#!/usr/bin/env php +register(); +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); +$classLoader->register(); +$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); +$classLoader->register(); + +// Variable $helperSet is defined inside cli-config.php +require __DIR__ . '/cli-config.php'; + +$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION); +$cli->setCatchExceptions(true); +$helperSet = $cli->getHelperSet(); +foreach ($helpers as $name => $helper) { + $helperSet->set($helper, $name); +} +$cli->addCommands(array( + // DBAL Commands + new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), + new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), + + // ORM Commands + new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), + new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), + new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), + new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), + new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), + new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), + new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), + new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), + new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), + new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), + new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), + new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), + new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), + new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(), + +)); +$cli->run(); diff --git a/vendor/doctrine/orm/tools/sandbox/index.php b/vendor/doctrine/orm/tools/sandbox/index.php new file mode 100644 index 0000000..ad1cb9d --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/index.php @@ -0,0 +1,62 @@ +register(); +$classLoader = new ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); +$classLoader->register(); +$classLoader = new ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); +$classLoader->register(); +$classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); +$classLoader->register(); +$classLoader = new ClassLoader('Entities', __DIR__); +$classLoader->register(); +$classLoader = new ClassLoader('Proxies', __DIR__); +$classLoader->register(); + +// Set up caches +$config = new Configuration; +$cache = new ApcCache; +$config->setMetadataCacheImpl($cache); +$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); +$config->setMetadataDriverImpl($driverImpl); +$config->setQueryCacheImpl($cache); + +// Proxy configuration +$config->setProxyDir(__DIR__ . '/Proxies'); +$config->setProxyNamespace('Proxies'); +$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); + +// Database connection information +$connectionOptions = array( + 'driver' => 'pdo_sqlite', + 'path' => 'database.sqlite' +); + +// Create EntityManager +$em = EntityManager::create($connectionOptions, $config); + +## PUT YOUR TEST CODE BELOW + +$user = new User; +$address = new Address; + +echo 'Hello World!' . PHP_EOL; diff --git a/vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml b/vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml new file mode 100644 index 0000000..7e8dd01 --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml b/vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml new file mode 100644 index 0000000..e548fd1 --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml b/vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml new file mode 100644 index 0000000..140e902 --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml @@ -0,0 +1,16 @@ +Entities\Address: + type: entity + table: addresses + id: + id: + type: integer + generator: + strategy: AUTO + fields: + street: + type: string + length: 255 + oneToOne: + user: + targetEntity: User + mappedBy: address \ No newline at end of file diff --git a/vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml b/vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml new file mode 100644 index 0000000..a93d48f --- /dev/null +++ b/vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml @@ -0,0 +1,18 @@ +Entities\User: + type: entity + table: users + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type: string + length: 50 + oneToOne: + address: + targetEntity: Address + joinColumn: + name: address_id + referencedColumnName: id diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/InterceptorLoader.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/InterceptorLoader.php new file mode 100644 index 0000000..79ac040 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/InterceptorLoader.php @@ -0,0 +1,58 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Aop; + +use CG\Proxy\InterceptorLoaderInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Lazy-loading interceptor loader implementation. + * + * @author Johannes M. Schmitt + */ +class InterceptorLoader implements InterceptorLoaderInterface +{ + private $container; + private $interceptors; + private $loadedInterceptors = array(); + + public function __construct(ContainerInterface $container, array $interceptors) + { + $this->container = $container; + $this->interceptors = $interceptors; + } + + public function loadInterceptors(\ReflectionMethod $method) + { + if (!isset($this->interceptors[$method->class][$method->name])) { + return array(); + } + + if (isset($this->loadedInterceptors[$method->class][$method->name])) { + return $this->loadedInterceptors[$method->class][$method->name]; + } + + $interceptors = array(); + foreach ($this->interceptors[$method->class][$method->name] as $id) { + $interceptors[] = $this->container->get($id); + } + + return $this->loadedInterceptors[$method->class][$method->name] = $interceptors; + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutContainer.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutContainer.php new file mode 100644 index 0000000..5c73741 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutContainer.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Aop; + +final class PointcutContainer +{ + private $pointcuts; + + public function __construct(array $pointcuts) + { + $this->pointcuts = $pointcuts; + } + + public function getPointcuts() + { + return $this->pointcuts; + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutInterface.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutInterface.php new file mode 100644 index 0000000..a263d52 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/PointcutInterface.php @@ -0,0 +1,54 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Aop; + +/** + * Pointcut Interface. + * + * Implementations of this class are responsible for making a decision on whether + * a certain method call matches the advice which is associated with this pointcut. + * + * @author Johannes M. Schmitt + */ +interface PointcutInterface +{ + /** + * Determines whether the advice applies to instances of the given class. + * + * There are some limits as to what you can do in this method. Namely, you may + * only base your decision on resources that are part of the ContainerBuilder. + * Specifically, you may not use any data in the class itself, such as + * annotations. + * + * @param \ReflectionClass $class + * @return boolean + */ + function matchesClass(\ReflectionClass $class); + + /** + * Determines whether the advice applies to the given method. + * + * This method is not limited in the way the matchesClass method is. It may + * use information in the associated class to make its decision. + * + * @param \ReflectionMethod $method + * @return boolean + */ + function matchesMethod(\ReflectionMethod $method); +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/RegexPointcut.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/RegexPointcut.php new file mode 100644 index 0000000..cbb1404 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Aop/RegexPointcut.php @@ -0,0 +1,46 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Aop; + +/** + * A regex pointcut implementation. + * + * Uses a regular expression for determining whether the pointcut matches. + * + * @author Johannes M. Schmitt + */ +class RegexPointcut implements PointcutInterface +{ + private $pattern; + + public function __construct($pattern) + { + $this->pattern = $pattern; + } + + public function matchesClass(\ReflectionClass $class) + { + return true; + } + + public function matchesMethod(\ReflectionMethod $method) + { + return 0 < preg_match('#'.$this->pattern.'#', sprintf('%s::%s', $method->class, $method->name)); + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Compiler/PointcutMatchingPass.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Compiler/PointcutMatchingPass.php new file mode 100644 index 0000000..51967a6 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Compiler/PointcutMatchingPass.php @@ -0,0 +1,195 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\DependencyInjection\Compiler; + +use CG\Core\ClassUtils; + +use JMS\AopBundle\Exception\RuntimeException; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\Reference; +use CG\Proxy\Enhancer; +use CG\Proxy\InterceptionGenerator; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Matches pointcuts against service methods. + * + * This pass will collect the advices that match a certain method, and then + * generate proxy classes where necessary. + * + * @author Johannes M. Schmitt + */ +class PointcutMatchingPass implements CompilerPassInterface +{ + private $pointcuts; + private $cacheDir; + private $container; + + public function __construct(array $pointcuts = null) + { + $this->pointcuts = $pointcuts; + } + + public function process(ContainerBuilder $container) + { + $this->container = $container; + $this->cacheDir = $container->getParameter('jms_aop.cache_dir').'/proxies'; + $pointcuts = $this->getPointcuts(); + + $interceptors = array(); + foreach ($container->getDefinitions() as $id => $definition) { + $this->processDefinition($definition, $pointcuts, $interceptors); + + $this->processInlineDefinitions($pointcuts, $interceptors, $definition->getArguments()); + $this->processInlineDefinitions($pointcuts, $interceptors, $definition->getMethodCalls()); + $this->processInlineDefinitions($pointcuts, $interceptors, $definition->getProperties()); + } + + $container + ->getDefinition('jms_aop.interceptor_loader') + ->addArgument($interceptors) + ; + } + + private function processInlineDefinitions($pointcuts, &$interceptors, array $a) { + foreach ($a as $k => $v) { + if ($v instanceof Definition) { + $this->processDefinition($v, $pointcuts, $interceptors); + } else if (is_array($v)) { + $this->processInlineDefinitions($pointcuts, $interceptors, $v); + } + } + } + + private function processDefinition(Definition $definition, $pointcuts, &$interceptors) + { + if ($definition->isSynthetic()) { + return; + } + + if ($definition->getFactoryService() || $definition->getFactoryClass()) { + return; + } + + if ($file = $definition->getFile()) { + require_once $file; + } + + if (!class_exists($definition->getClass())) { + return; + } + + $class = new \ReflectionClass($definition->getClass()); + + // check if class is matched + $matchingPointcuts = array(); + foreach ($pointcuts as $interceptor => $pointcut) { + if ($pointcut->matchesClass($class)) { + $matchingPointcuts[$interceptor] = $pointcut; + } + } + + if (empty($matchingPointcuts)) { + return; + } + + $this->addResources($class, $this->container); + + if ($class->isFinal()) { + return; + } + + $classAdvices = array(); + foreach ($class->getMethods(\ReflectionMethod::IS_PROTECTED | \ReflectionMethod::IS_PUBLIC) as $method) { + if ($method->isFinal()) { + continue; + } + + $advices = array(); + foreach ($matchingPointcuts as $interceptor => $pointcut) { + if ($pointcut->matchesMethod($method)) { + $advices[] = $interceptor; + } + } + + if (empty($advices)) { + continue; + } + + $classAdvices[$method->name] = $advices; + } + + if (empty($classAdvices)) { + return; + } + + $interceptors[ClassUtils::getUserClass($class->name)] = $classAdvices; + + $generator = new InterceptionGenerator(); + $generator->setFilter(function(\ReflectionMethod $method) use ($classAdvices) { + return isset($classAdvices[$method->name]); + }); + if ($file) { + $generator->setRequiredFile($file); + } + $enhancer = new Enhancer($class, array(), array( + $generator + )); + $enhancer->writeClass($filename = $this->cacheDir.'/'.str_replace('\\', '-', $class->name).'.php'); + $definition->setFile($filename); + $definition->setClass($enhancer->getClassName($class)); + $definition->addMethodCall('__CGInterception__setLoader', array( + new Reference('jms_aop.interceptor_loader') + )); + } + + private function addResources(\ReflectionClass $class) + { + do { + $this->container->addResource(new FileResource($class->getFilename())); + } while (($class = $class->getParentClass()) && $class->getFilename()); + } + + private function getPointcuts() + { + if (null !== $this->pointcuts) { + return $this->pointcuts; + } + + $pointcuts = $pointcutReferences = array(); + + foreach ($this->container->findTaggedServiceIds('jms_aop.pointcut') as $id => $attr) { + if (!isset($attr[0]['interceptor'])) { + throw new RuntimeException('You need to set the "interceptor" attribute for the "jms_aop.pointcut" tag of service "'.$id.'".'); + } + + $pointcutReferences[$attr[0]['interceptor']] = new Reference($id); + $pointcuts[$attr[0]['interceptor']] = $this->container->get($id); + } + + $this->container + ->getDefinition('jms_aop.pointcut_container') + ->addArgument($pointcutReferences) + ; + + return $pointcuts; + } +} diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Configuration.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Configuration.php new file mode 100644 index 0000000..947cdf5 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/Configuration.php @@ -0,0 +1,45 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +/** + * This is the class that validates and merges configuration from your app/config files + * + * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} + */ +class Configuration implements ConfigurationInterface +{ + /** + * {@inheritDoc} + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $treeBuilder->root('jms_aop') + ->children() + ->scalarNode('cache_dir')->cannotBeEmpty()->defaultValue('%kernel.cache_dir%/jms_aop')->end() + ->end() + ; + + return $treeBuilder; + } +} diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/JMSAopExtension.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/JMSAopExtension.php new file mode 100644 index 0000000..6f9a1e3 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/DependencyInjection/JMSAopExtension.php @@ -0,0 +1,53 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\DependencyInjection; + +use JMS\AopBundle\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\Loader; + +/** + * JMSAopExtension. + * + * @author Johannes M. Schmitt + */ +class JMSAopExtension extends Extension +{ + /** + * {@inheritDoc} + */ + public function load(array $configs, ContainerBuilder $container) + { + $configuration = new Configuration(); + $config = $this->processConfiguration($configuration, $configs); + + $cacheDir = $container->getParameterBag()->resolveValue($config['cache_dir']); + if (!is_dir($cacheDir)) { + if (false === @mkdir($cacheDir, 0777, true)) { + throw new RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir)); + } + } + $container->setParameter('jms_aop.cache_dir', $cacheDir); + + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/Exception.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/Exception.php new file mode 100644 index 0000000..1cbc27e --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/Exception.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Exception; + +/** + * Base exception for the AopBundle. + * + * @author Johannes M. Schmitt + */ +interface Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/RuntimeException.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/RuntimeException.php new file mode 100644 index 0000000..02a0db4 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Exception/RuntimeException.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Exception; + +/** + * RuntimeException for the AopBundle. + * + * @author Johannes M. Schmitt + */ +class RuntimeException extends \RuntimeException implements Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/JMSAopBundle.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/JMSAopBundle.php new file mode 100644 index 0000000..dbd6b8b --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/JMSAopBundle.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle; + +use Symfony\Component\DependencyInjection\Compiler\PassConfig; +use JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class JMSAopBundle extends Bundle +{ + const VERSION = '1.0.0'; + + public function build(ContainerBuilder $container) + { + $container->addCompilerPass(new PointcutMatchingPass(), PassConfig::TYPE_AFTER_REMOVING); + } +} diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/README b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/README new file mode 100644 index 0000000..72bab21 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/README @@ -0,0 +1,8 @@ +For documentation, see: + + Resources/doc + + +For license, see: + + Resources/meta/LICENSE \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/config/services.xml b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/config/services.xml new file mode 100644 index 0000000..c1caed4 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/config/services.xml @@ -0,0 +1,18 @@ + + + + + + JMS\AopBundle\Aop\InterceptorLoader + + + + + + + + + + diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/doc/index.rst b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/doc/index.rst new file mode 100644 index 0000000..e637fb0 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/doc/index.rst @@ -0,0 +1,252 @@ +======== +Overview +======== + +This bundle adds AOP capabilities to Symfony2. + +If you haven't heard of AOP yet, it basically allows you to separate a +cross-cutting concern (for example, security checks) into a dedicated class, +and not having to repeat that code in all places where it is needed. + +In other words, this allows you to execute custom code before, and after the +invocation of certain methods in your service layer, or your controllers. You +can also choose to skip the invocation of the original method, or throw exceptions. + +Installation +------------ +Checkout a copy of the code:: + + git submodule add https://github.com/schmittjoh/JMSAopBundle.git src/JMS/AopBundle + +Then register the bundle with your kernel:: + + // in AppKernel::registerBundles() + $bundles = array( + // ... + new JMS\AopBundle\JMSAopBundle(), + // ... + ); + +This bundle also requires the CG library for code generation:: + + git submodule add https://github.com/schmittjoh/cg-library.git vendor/cg-library + +Make sure that you also register the namespaces with the autoloader:: + + // app/autoload.php + $loader->registerNamespaces(array( + // ... + 'JMS' => __DIR__.'/../vendor/bundles', + 'CG' => __DIR__.'/../vendor/cg-library/src', + // ... + )); + + +Configuration +------------- +:: + + jms_aop: + cache_dir: %kernel.cache_dir%/jms_aop + + +Usage +----- +In order to execute custom code, you need two classes. First, you need a so-called +pointcut. The purpose of this class is to make a decision whether a method call +should be intercepted by a certain interceptor. This decision has to be made +statically only on the basis of the method signature itself. + +The second class is the interceptor. This class is being called instead +of the original method. It contains the custom code that you would like to +execute. At this point, you have access to the object on which the method is +called, and all the arguments which were passed to that method. + +Examples +-------- + +1. Logging +~~~~~~~~~~ + +In this example, we will be implementing logging for all methods that contain +"delete". + +Pointcut +^^^^^^^^ + +:: + + name, 'delete'); + } + } + +:: + + # services.yml + services: + my_logging_pointcut: + class: LoggingPointcut + tags: + - { name: jms_aop.pointcut, interceptor: logging_interceptor } + + +LoggingInterceptor +^^^^^^^^^^^^^^^^^^ + +:: + + context = $context; + $this->logger = $logger; + } + + public function intercept(MethodInvocation $invocation) + { + $user = $this->context->getToken()->getUsername(); + $this->logger->info(sprintf('User "%s" invoked method "%s".', $user, $invocation->reflection->name)); + + // make sure to proceed with the invocation otherwise the original + // method will never be called + return $invocation->proceed(); + } + } + +:: + + # services.yml + services: + logging_interceptor: + class: LoggingInterceptor + arguments: [@security.context, @logger] + + +2. Transaction Management +~~~~~~~~~~~~~~~~~~~~~~~~~ + +In this example, we add a @Transactional annotation, and we automatically wrap all methods +where this annotation is declared in a transaction. + +Pointcut +^^^^^^^^ + +:: + + use Doctrine\Common\Annotations\Reader; + use JMS\AopBundle\Aop\PointcutInterface; + use JMS\DiExtraBundle\Annotation as DI; + + /** + * @DI\Service + * @DI\Tag("jms_aop.pointcut", attributes = {"interceptor" = "aop.transactional_interceptor"}) + * + * @author Johannes M. Schmitt + */ + class TransactionalPointcut implements PointcutInterface + { + private $reader; + + /** + * @DI\InjectParams({ + * "reader" = @DI\Inject("annotation_reader"), + * }) + * @param Reader $reader + */ + public function __construct(Reader $reader) + { + $this->reader = $reader; + } + + public function matchesClass(\ReflectionClass $class) + { + return true; + } + + public function matchesMethod(\ReflectionMethod $method) + { + return null !== $this->reader->getMethodAnnotation($method, 'Annotation\Transactional'); + } + } + +Interceptor +^^^^^^^^^^^ + +:: + + use Symfony\Component\HttpKernel\Log\LoggerInterface; + use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + use CG\Proxy\MethodInvocation; + use CG\Proxy\MethodInterceptorInterface; + use Doctrine\ORM\EntityManager; + use JMS\DiExtraBundle\Annotation as DI; + + /** + * @DI\Service("aop.transactional_interceptor") + * + * @author Johannes M. Schmitt + */ + class TransactionalInterceptor implements MethodInterceptorInterface + { + private $em; + private $logger; + + /** + * @DI\InjectParams + * @param EntityManager $em + */ + public function __construct(EntityManager $em, LoggerInterface $logger) + { + $this->em = $em; + $this->logger = $logger; + } + + public function intercept(MethodInvocation $invocation) + { + $this->logger->info('Beginning transaction for method "'.$invocation.'")'); + $this->em->getConnection()->beginTransaction(); + try { + $rs = $invocation->proceed(); + + $this->logger->info(sprintf('Comitting transaction for method "%s" (method invocation successful)', $invocation)); + $this->em->getConnection()->commit(); + + return $rs; + } catch (\Exception $ex) { + if ($ex instanceof NotFoundHttpException) { + $this->logger->info(sprintf('Committing transaction for method "%s" (exception thrown, but no rollback)', $invocation)); + $this->em->getConnection()->commit(); + } else { + $this->logger->info(sprintf('Rolling back transaction for method "%s" (exception thrown)', $invocation)); + $this->em->getConnection()->rollBack(); + } + + throw $ex; + } + } + } diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/meta/LICENSE b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/meta/LICENSE new file mode 100644 index 0000000..753842b --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Resources/meta/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/InterceptorLoaderTest.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/InterceptorLoaderTest.php new file mode 100644 index 0000000..1789973 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/InterceptorLoaderTest.php @@ -0,0 +1,64 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Tests\Aop; + +use JMS\AopBundle\Aop\PointcutContainer; + +use JMS\AopBundle\Aop\InterceptorLoader; + +class InterceptorLoaderTest extends \PHPUnit_Framework_TestCase +{ + public function testLoadInterceptors() + { + $interceptor = $this->getMock('CG\Proxy\MethodInterceptorInterface'); + + list($loader, $container) = $this->getLoader(array( + 'JMS\AopBundle\Tests\Aop\InterceptorLoaderTestClass' => array( + 'foo' => array('foo'), + ), + )); + + $container + ->expects($this->once()) + ->method('get') + ->with($this->equalTo('foo')) + ->will($this->returnValue($interceptor)) + ; + + $method = new \ReflectionMethod('JMS\AopBundle\Tests\Aop\InterceptorLoaderTestClass', 'foo'); + + $this->assertSame(array($interceptor), $loader->loadInterceptors($method)); + // yes, twice + $this->assertSame(array($interceptor), $loader->loadInterceptors($method)); + } + + private function getLoader(array $interceptors = array()) + { + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + + return array(new InterceptorLoader($container, $interceptors), $container); + } +} + +class InterceptorLoaderTestClass +{ + public function foo() + { + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/RegexPointcutTest.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/RegexPointcutTest.php new file mode 100644 index 0000000..72f5295 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/Aop/RegexPointcutTest.php @@ -0,0 +1,47 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Tests\Aop; + +use JMS\AopBundle\Aop\RegexPointcut; + +class RegexPointcutTest extends \PHPUnit_Framework_TestCase +{ + public function testMatchesClass() + { + $pointcut = new RegexPointcut(''); + $this->assertTrue($pointcut->matchesClass(new \ReflectionClass('stdClass'))); + } + + public function testMatchesMethod() + { + $pointcut = new RegexPointcut('foo$'); + + $method = new \ReflectionMethod('JMS\AopBundle\Tests\Aop\RegexPointcutTestClass', 'foo'); + $this->assertTrue($pointcut->matchesMethod($method)); + + $method = new \ReflectionMethod('JMS\AopBundle\Tests\Aop\RegexPointcutTestClass', 'bar'); + $this->assertFalse($pointcut->matchesMethod($method)); + } +} + +class RegexPointcutTestClass +{ + public function foo() {} + public function bar() {} +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingInterceptor.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingInterceptor.php new file mode 100644 index 0000000..0c0547c --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingInterceptor.php @@ -0,0 +1,39 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Tests\DependencyInjection\Compiler\Fixture; + +use CG\Proxy\MethodInvocation; +use CG\Proxy\MethodInterceptorInterface; + +class LoggingInterceptor implements MethodInterceptorInterface +{ + private $log = array(); + + public function getLog() + { + return $this->log; + } + + public function intercept(MethodInvocation $invocation) + { + $this->log[] = $invocation->reflection->name; + + return $invocation->proceed(); + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingPointcut.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingPointcut.php new file mode 100644 index 0000000..b7076cb --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/LoggingPointcut.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Tests\DependencyInjection\Compiler\Fixture; + +use JMS\AopBundle\Aop\PointcutInterface; + +class LoggingPointcut implements PointcutInterface +{ + public function matchesClass(\ReflectionClass $class) + { + return true; + } + + public function matchesMethod(\ReflectionMethod $method) + { + return false !== strpos($method->name, 'delete'); + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/TestService.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/TestService.php new file mode 100644 index 0000000..99f2861 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/Fixture/TestService.php @@ -0,0 +1,32 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Tests\DependencyInjection\Compiler\Fixture; + +class TestService +{ + public function add() + { + return true; + } + + public function delete() + { + return true; + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/PointcutMatchingPassTest.php b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/PointcutMatchingPassTest.php new file mode 100644 index 0000000..b75151c --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/Tests/DependencyInjection/Compiler/PointcutMatchingPassTest.php @@ -0,0 +1,96 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\AopBundle\Tests\DependencyInjection\Compiler; + +use JMS\AopBundle\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass; +use JMS\AopBundle\DependencyInjection\JMSAopExtension; +use JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass; +use Symfony\Component\HttpKernel\Util\Filesystem; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +class PointcutMatchingPassTest extends \PHPUnit_Framework_TestCase +{ + private $cacheDir; + private $fs; + + public function testProcess() + { + $container = $this->getContainer(); + + $container + ->register('pointcut', 'JMS\AopBundle\Tests\DependencyInjection\Compiler\Fixture\LoggingPointcut') + ->addTag('jms_aop.pointcut', array('interceptor' => 'interceptor')) + ; + $container + ->register('interceptor', 'JMS\AopBundle\Tests\DependencyInjection\Compiler\Fixture\LoggingInterceptor') + ; + $container + ->register('test', 'JMS\AopBundle\Tests\DependencyInjection\Compiler\Fixture\TestService') + ; + + $this->process($container); + + $service = $container->get('test'); + $this->assertInstanceOf('JMS\AopBundle\Tests\DependencyInjection\Compiler\Fixture\TestService', $service); + $this->assertTrue($service->add()); + $this->assertTrue($service->delete()); + $this->assertEquals(array('delete'), $container->get('interceptor')->getLog()); + } + + protected function setUp() + { + $this->cacheDir = sys_get_temp_dir().'/jms_aop_test'; + $this->fs = new Filesystem(); + + if (is_dir($this->cacheDir)) { + $this->fs->remove($this->cacheDir); + } + + if (false === @mkdir($this->cacheDir, 0777, true)) { + throw new RuntimeException(sprintf('Could not create cache dir "%s".', $this->cacheDir)); + } + } + + protected function tearDown() + { + $this->fs->remove($this->cacheDir); + } + + private function getContainer() + { + $container = new ContainerBuilder(); + + $extension = new JMSAopExtension(); + $extension->load(array(array( + 'cache_dir' => $this->cacheDir, + )), $container); + + return $container; + } + + private function process(ContainerBuilder $container) + { + $pass = new ResolveParameterPlaceHoldersPass(); + $pass->process($container); + + $pass = new PointcutMatchingPass(); + $pass->process($container); + } +} \ No newline at end of file diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/composer.json b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/composer.json new file mode 100644 index 0000000..1fe7e80 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/composer.json @@ -0,0 +1,21 @@ +{ + "name": "jms/aop-bundle", + "description": "Adds AOP capabilities to Symfony2", + "keywords": ["annotations","aop"], + "type": "symfony-bundle", + "license": "Apache", + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "require": { + "symfony/framework-bundle": "2.*", + "jms/cg": "1.0.0" + }, + "autoload": { + "psr-0": { "JMS\\AopBundle": "" } + }, + "target-dir": "JMS/AopBundle" +} diff --git a/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/phpunit.xml.dist b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/phpunit.xml.dist new file mode 100644 index 0000000..7484342 --- /dev/null +++ b/vendor/jms/aop-bundle/JMS/AopBundle/schmittjoh-JMSAopBundle-8ef7db0/phpunit.xml.dist @@ -0,0 +1,26 @@ + + + + + + + ./Tests + + + + + + performance + + + diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/LICENSE b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/LICENSE new file mode 100644 index 0000000..f49a4e1 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/README.rst b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/README.rst new file mode 100644 index 0000000..22b4d90 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/README.rst @@ -0,0 +1,9 @@ +CG library provides a toolset for generating PHP code +===================================================== + +Overview +-------- + +This library provides some tools that you commonly need for generating PHP code. +One of it's strength lies in the enhancement of existing classes with behaviors. + diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/composer.json b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/composer.json new file mode 100644 index 0000000..edb5eec --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/composer.json @@ -0,0 +1,19 @@ +{ + "name": "jms/cg", + "description": "Toolset for generating PHP code", + "keywords": ["code generation"], + "type": "library", + "license": "Apache", + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-0": { "CG\\": "src/" } + } +} diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/phpunit.xml.dist b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/phpunit.xml.dist new file mode 100644 index 0000000..4f6c5e4 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + + ./tests/CG/ + + + + + + performance + + + diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/AbstractClassGenerator.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/AbstractClassGenerator.php new file mode 100644 index 0000000..203d9ba --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/AbstractClassGenerator.php @@ -0,0 +1,60 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +use CG\Generator\PhpClass; + +/** + * Abstract base class for all class generators. + * + * @author Johannes M. Schmitt + */ +abstract class AbstractClassGenerator implements ClassGeneratorInterface +{ + private $namingStrategy; + private $generatorStrategy; + + public function setNamingStrategy(NamingStrategyInterface $namingStrategy = null) + { + $this->namingStrategy = $namingStrategy; + } + + public function setGeneratorStrategy(GeneratorStrategyInterface $generatorStrategy = null) + { + $this->generatorStrategy = $generatorStrategy; + } + + public function getClassName(\ReflectionClass $class) + { + if (null === $this->namingStrategy) { + $this->namingStrategy = new DefaultNamingStrategy(); + } + + return $this->namingStrategy->getClassName($class); + } + + protected function generateCode(PhpClass $class) + { + if (null === $this->generatorStrategy) { + $this->generatorStrategy = new DefaultGeneratorStrategy(); + } + + return $this->generatorStrategy->generate($class); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassGeneratorInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassGeneratorInterface.php new file mode 100644 index 0000000..93ca18f --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassGeneratorInterface.php @@ -0,0 +1,36 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +use CG\Generator\PhpClass; + +/** + * Interface for class generators. + * + * @author Johannes M. Schmitt + */ +interface ClassGeneratorInterface +{ + /** + * Generates the PHP class. + * + * @return string + */ + function generateClass(); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassUtils.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassUtils.php new file mode 100644 index 0000000..3e33bd5 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ClassUtils.php @@ -0,0 +1,35 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +use CG\Proxy\Enhancer; + +abstract class ClassUtils +{ + public static function getUserClass($className) + { + if (false === $pos = strrpos($className, '\\'.NamingStrategyInterface::SEPARATOR.'\\')) { + return $className; + } + + return substr($className, $pos + NamingStrategyInterface::SEPARATOR_LENGTH + 2); + } + + private final function __construct() {} +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultGeneratorStrategy.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultGeneratorStrategy.php new file mode 100644 index 0000000..28b60bf --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultGeneratorStrategy.php @@ -0,0 +1,67 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +use CG\Generator\DefaultVisitorInterface; +use CG\Generator\PhpClass; +use CG\Generator\DefaultVisitor; +use CG\Generator\DefaultNavigator; + +/** + * The default generator strategy. + * + * This strategy allows to change the order in which methods, properties and + * constants are sorted. + * + * @author Johannes M. Schmitt + */ +class DefaultGeneratorStrategy implements GeneratorStrategyInterface +{ + private $navigator; + private $visitor; + + public function __construct(DefaultVisitorInterface $visitor = null) + { + $this->navigator = new DefaultNavigator(); + $this->visitor = $visitor ?: new DefaultVisitor(); + } + + public function setConstantSortFunc(\Closure $func = null) + { + $this->navigator->setConstantSortFunc($func); + } + + public function setMethodSortFunc(\Closure $func = null) + { + $this->navigator->setMethodSortFunc($func); + } + + public function setPropertySortFunc(\Closure $func = null) + { + $this->navigator->setPropertySortFunc($func); + } + + public function generate(PhpClass $class) + { + $this->visitor->reset(); + $this->navigator->accept($this->visitor, $class); + + return $this->visitor->getContent(); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultNamingStrategy.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultNamingStrategy.php new file mode 100644 index 0000000..600c995 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/DefaultNamingStrategy.php @@ -0,0 +1,41 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +/** + * The default naming strategy. + * + * @author Johannes M. Schmitt + */ +class DefaultNamingStrategy implements NamingStrategyInterface +{ + private $prefix; + + public function __construct($prefix = 'EnhancedProxy') + { + $this->prefix = $prefix; + } + + public function getClassName(\ReflectionClass $class) + { + $userClass = ClassUtils::getUserClass($class->name); + + return $this->prefix.'_'.sha1($class->name).'\\'.self::SEPARATOR.'\\'.$userClass; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/GeneratorStrategyInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/GeneratorStrategyInterface.php new file mode 100644 index 0000000..2468bc1 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/GeneratorStrategyInterface.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +use CG\Generator\PhpClass; + +/** + * Generator Strategy Interface. + * + * Implementing classes are responsible for generating PHP code from the given + * PhpClass instance. + * + * @author Johannes M. Schmitt + */ +interface GeneratorStrategyInterface +{ + function generate(PhpClass $class); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/NamingStrategyInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/NamingStrategyInterface.php new file mode 100644 index 0000000..c7c03fa --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/NamingStrategyInterface.php @@ -0,0 +1,50 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +/** + * The naming strategy interface. + * + * @author Johannes M. Schmitt + */ +interface NamingStrategyInterface +{ + const SEPARATOR = '__CG__'; + const SEPARATOR_LENGTH = 6; + + /** + * Returns the class name for the proxy class. + * + * The generated class name MUST be the concatenation of a nonempty prefix, + * the namespace separator __CG__, and the original class name. + * + * Examples: + * + * +----------------------------+------------------------------+ + * | Original Name | Generated Name | + * +============================+==============================+ + * | Foo\Bar | dred332\__CG__\Foo\Bar | + * | Bar\Baz | Foo\Doo\__CG__\Bar\Baz | + * +----------------------------+------------------------------+ + * + * @param \ReflectionClass $class + * @return string the class name for the generated class + */ + function getClassName(\ReflectionClass $class); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ReflectionUtils.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ReflectionUtils.php new file mode 100644 index 0000000..e7e9ea7 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Core/ReflectionUtils.php @@ -0,0 +1,57 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Core; + +abstract class ReflectionUtils +{ + public static function getOverrideableMethods(\ReflectionClass $class, $publicOnly = false) + { + $filter = \ReflectionMethod::IS_PUBLIC; + + if (!$publicOnly) { + $filter |= \ReflectionMethod::IS_PROTECTED; + } + + return array_filter( + $class->getMethods($filter), + function($method) { return !$method->isFinal() && !$method->isStatic(); } + ); + } + + public static function getUnindentedDocComment($docComment) + { + $lines = explode("\n", $docComment); + for ($i=0,$c=count($lines); $i<$c; $i++) { + if (0 === $i) { + $docBlock = $lines[0]."\n"; + continue; + } + + $docBlock .= ' '.ltrim($lines[$i]); + + if ($i+1 < $c) { + $docBlock .= "\n"; + } + } + + return $docBlock; + } + + private final function __construct() { } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/AbstractPhpMember.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/AbstractPhpMember.php new file mode 100644 index 0000000..5ae8aa4 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/AbstractPhpMember.php @@ -0,0 +1,95 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * Abstract PHP member class. + * + * @author Johannes M. Schmitt + */ +abstract class AbstractPhpMember +{ + const VISIBILITY_PRIVATE = 'private'; + const VISIBILITY_PROTECTED = 'protected'; + const VISIBILITY_PUBLIC = 'public'; + + private $static = false; + private $visibility = self::VISIBILITY_PUBLIC; + private $name; + private $docblock; + + public function __construct($name = null) + { + $this->setName($name); + } + + public function setName($name) + { + $this->name = $name; + + return $this; + } + + public function setVisibility($visibility) + { + if ($visibility !== self::VISIBILITY_PRIVATE + && $visibility !== self::VISIBILITY_PROTECTED + && $visibility !== self::VISIBILITY_PUBLIC) { + throw new \InvalidArgumentException(sprintf('The visibility "%s" does not exist.', $visibility)); + } + + $this->visibility = $visibility; + + return $this; + } + + public function setStatic($bool) + { + $this->static = (Boolean) $bool; + + return $this; + } + + public function setDocblock($doc) + { + $this->docblock = $doc; + + return $this; + } + + public function isStatic() + { + return $this->static; + } + + public function getVisibility() + { + return $this->visibility; + } + + public function getName() + { + return $this->name; + } + + public function getDocblock() + { + return $this->docblock; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultNavigator.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultNavigator.php new file mode 100644 index 0000000..3d46bb3 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultNavigator.php @@ -0,0 +1,172 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * The default navigator. + * + * This class is responsible for the default traversal algorithm of the different + * code elements. + * + * Unlike other visitor pattern implementations, this allows to separate the + * traversal logic from the objects that are traversed. + * + * @author Johannes M. Schmitt + */ +class DefaultNavigator +{ + private $constantSortFunc; + private $propertySortFunc; + private $methodSortFunc; + + /** + * Sets a custom constant sorting function. + * + * @param \Closure $func + */ + public function setConstantSortFunc(\Closure $func = null) + { + $this->constantSortFunc = $func; + } + + /** + * Sets a custom property sorting function. + * + * @param \Closure $func + */ + public function setPropertySortFunc(\Closure $func = null) + { + $this->propertySortFunc = $func; + } + + /** + * Sets a custom method sorting function. + * + * @param \Closure $func + */ + public function setMethodSortFunc(\Closure $func = null) + { + $this->methodSortFunc = $func; + } + + public function accept(DefaultVisitorInterface $visitor, PhpClass $class) + { + $visitor->startVisitingClass($class); + + $constants = $class->getConstants(); + if (!empty($constants)) { + uksort($constants, $this->getConstantSortFunc()); + + $visitor->startVisitingConstants(); + foreach ($constants as $name => $value) { + $visitor->visitConstant($name, $value); + } + $visitor->endVisitingConstants(); + } + + $properties = $class->getProperties(); + if (!empty($properties)) { + usort($properties, $this->getPropertySortFunc()); + + $visitor->startVisitingProperties(); + foreach ($properties as $property) { + $visitor->visitProperty($property); + } + $visitor->endVisitingProperties(); + } + + $methods = $class->getMethods(); + if (!empty($methods)) { + usort($methods, $this->getMethodSortFunc()); + + $visitor->startVisitingMethods(); + foreach ($methods as $method) { + $visitor->visitMethod($method); + } + $visitor->endVisitingMethods(); + } + + $visitor->endVisitingClass($class); + } + + private function getConstantSortFunc() + { + return $this->constantSortFunc ?: 'strcasecmp'; + } + + private function getMethodSortFunc() + { + if (null !== $this->methodSortFunc) { + return $this->methodSortFunc; + } + + static $defaultSortFunc; + if (empty($defaultSortFunc)) { + $defaultSortFunc = function($a, $b) { + if ($a->isStatic() !== $isStatic = $b->isStatic()) { + return $isStatic ? 1 : -1; + } + + if (($aV = $a->getVisibility()) !== $bV = $b->getVisibility()) { + $aV = 'public' === $aV ? 3 : ('protected' === $aV ? 2 : 1); + $bV = 'public' === $bV ? 3 : ('protected' === $bV ? 2 : 1); + + return $aV > $bV ? -1 : 1; + } + + $rs = strcasecmp($a->getName(), $b->getName()); + if (0 === $rs) { + return 0; + } + + return $rs > 0 ? -1 : 1; + }; + } + + return $defaultSortFunc; + } + + private function getPropertySortFunc() + { + if (null !== $this->propertySortFunc) { + return $this->propertySortFunc; + } + + static $defaultSortFunc; + if (empty($defaultSortFunc)) { + $defaultSortFunc = function($a, $b) { + if (($aV = $a->getVisibility()) !== $bV = $b->getVisibility()) { + $aV = 'public' === $aV ? 3 : ('protected' === $aV ? 2 : 1); + $bV = 'public' === $bV ? 3 : ('protected' === $bV ? 2 : 1); + + return $aV > $bV ? -1 : 1; + } + + $rs = strcasecmp($a->getName(), $b->getName()); + if (0 === $rs) { + return 0; + } + + return $rs > 0 ? -1 : 1; + }; + } + + return $defaultSortFunc; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitor.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitor.php new file mode 100644 index 0000000..5dd4094 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitor.php @@ -0,0 +1,237 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * The default code generation visitor. + * + * @author Johannes M. Schmitt + */ +class DefaultVisitor implements DefaultVisitorInterface +{ + private $writer; + + public function __construct() + { + $this->writer = new Writer(); + } + + public function reset() + { + $this->writer->reset(); + } + + public function startVisitingClass(PhpClass $class) + { + if ($namespace = $class->getNamespace()) { + $this->writer->write('namespace '.$namespace.';'."\n\n"); + } + + if ($files = $class->getRequiredFiles()) { + foreach ($files as $file) { + $this->writer->writeln('require_once '.var_export($file, true).';'); + } + + $this->writer->write("\n"); + } + + if ($useStatements = $class->getUseStatements()) { + foreach ($useStatements as $alias => $namespace) { + $this->writer->write('use '.$namespace); + + if (substr($namespace, strrpos($namespace, '\\') + 1) !== $alias) { + $this->writer->write(' as '.$alias); + } + + $this->writer->write(";\n"); + } + + $this->writer->write("\n"); + } + + if ($docblock = $class->getDocblock()) { + $this->writer->write($docblock); + } + + $this->writer->write('class '.$class->getShortName()); + + if ($parentClassName = $class->getParentClassName()) { + $this->writer->write(' extends '.('\\' === $parentClassName[0] ? $parentClassName : '\\'.$parentClassName)); + } + + $interfaceNames = $class->getInterfaceNames(); + if (!empty($interfaceNames)) { + $interfaceNames = array_unique($interfaceNames); + + $interfaceNames = array_map(function($name) { + if ('\\' === $name[0]) { + return $name; + } + + return '\\'.$name; + }, $interfaceNames); + + $this->writer->write(' implements '.implode(', ', $interfaceNames)); + } + + $this->writer + ->write("\n{\n") + ->indent() + ; + } + + public function startVisitingConstants() + { + } + + public function visitConstant($name, $value) + { + $this->writer->writeln('const '.$name.' = '.var_export($value, true).';'); + } + + public function endVisitingConstants() + { + $this->writer->write("\n"); + } + + public function startVisitingProperties() + { + } + + public function visitProperty(PhpProperty $property) + { + $this->writer->write($property->getVisibility().' '.($property->isStatic()? 'static ' : '').'$'.$property->getName()); + + if ($property->hasDefaultValue()) { + $this->writer->write(' = '.var_export($property->getDefaultValue(), true)); + } + + $this->writer->writeln(';'); + } + + public function endVisitingProperties() + { + $this->writer->write("\n"); + } + + public function startVisitingMethods() + { + } + + public function visitMethod(PhpMethod $method) + { + if ($docblock = $method->getDocblock()) { + $this->writer->writeln($docblock)->rtrim(); + } + + if ($method->isAbstract()) { + $this->writer->write('abstract '); + } + + $this->writer->write($method->getVisibility().' '); + + if ($method->isStatic()) { + $this->writer->write('static '); + } + + $this->writer->write('function '.$method->getName().'('); + + $this->writeParameters($method->getParameters()); + + if ($method->isAbstract()) { + $this->writer->write(");\n\n"); + + return; + } + + $this->writer + ->writeln(")") + ->writeln('{') + ->indent() + ->writeln($method->getBody()) + ->outdent() + ->rtrim() + ->write("}\n\n") + ; + } + + public function endVisitingMethods() + { + } + + public function endVisitingClass(PhpClass $class) + { + $this->writer + ->outdent() + ->rtrim() + ->write('}') + ; + } + + public function visitFunction(PhpFunction $function) + { + if ($namespace = $function->getNamespace()) { + $this->writer->write("namespace $namespace;\n\n"); + } + + $this->writer->write("function {$function->getName()}("); + $this->writeParameters($function->getParameters()); + $this->writer + ->write(")\n{\n") + ->indent() + ->writeln($function->getBody()) + ->outdent() + ->rtrim() + ->write('}') + ; + } + + public function getContent() + { + return $this->writer->getContent(); + } + + private function writeParameters(array $parameters) + { + $first = true; + foreach ($parameters as $parameter) { + if (!$first) { + $this->writer->write(', '); + } + $first = false; + + if ($type = $parameter->getType()) { + $this->writer->write( + ('array' === $type ? 'array' : ('\\' === $type[0] ? $type : '\\'. $type)) + .' ' + ); + } + + if ($parameter->isPassedByReference()) { + $this->writer->write('&'); + } + + $this->writer->write('$'.$parameter->getName()); + + if ($parameter->hasDefaultValue()) { + $this->writer->write(' = '.var_export($parameter->getDefaultValue(), true)); + } + } + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitorInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitorInterface.php new file mode 100644 index 0000000..d9532bb --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/DefaultVisitorInterface.php @@ -0,0 +1,47 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * The visitor interface required by the DefaultNavigator. + * + * @author Johannes M. Schmitt + */ +interface DefaultVisitorInterface +{ + /** + * Resets the visitors internal state to allow re-using the same instance. + * + * @return void + */ + function reset(); + + function startVisitingClass(PhpClass $class); + function startVisitingConstants(); + function visitConstant($name, $value); + function endVisitingConstants(); + function startVisitingProperties(); + function visitProperty(PhpProperty $property); + function endVisitingProperties(); + function startVisitingMethods(); + function visitMethod(PhpMethod $method); + function endVisitingMethods(); + function endVisitingClass(PhpClass $class); + function visitFunction(PhpFunction $function); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/GeneratorUtils.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/GeneratorUtils.php new file mode 100644 index 0000000..8f7a44c --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/GeneratorUtils.php @@ -0,0 +1,38 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * Some Generator utils. + * + * @author Johannes M. Schmitt + */ +abstract class GeneratorUtils +{ + private final function __construct() {} + + public static function callMethod(\ReflectionMethod $method, array $params = null) + { + if (null === $params) { + $params = array_map(function($p) { return '$'.$p->name; }, $method->getParameters()); + } + + return '\\'.$method->getDeclaringClass()->name.'::'.$method->name.'('.implode(', ', $params).')'; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpClass.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpClass.php new file mode 100644 index 0000000..e8496f0 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpClass.php @@ -0,0 +1,360 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +use Doctrine\Common\Annotations\PhpParser; + +use CG\Core\ReflectionUtils; + +/** + * Represents a PHP class. + * + * @author Johannes M. Schmitt + */ +class PhpClass +{ + private static $phpParser; + + private $name; + private $parentClassName; + private $interfaceNames = array(); + private $useStatements = array(); + private $constants = array(); + private $properties = array(); + private $requiredFiles = array(); + private $methods = array(); + private $abstract = false; + private $final = false; + private $docblock; + + public static function create($name = null) + { + return new self($name); + } + + public static function fromReflection(\ReflectionClass $ref) + { + $class = new static(); + $class + ->setName($ref->name) + ->setAbstract($ref->isAbstract()) + ->setFinal($ref->isFinal()) + ->setConstants($ref->getConstants()) + ; + + if (null === self::$phpParser) { + if (!class_exists('Doctrine\Common\Annotations\PhpParser')) { + self::$phpParser = false; + } else { + self::$phpParser = new PhpParser(); + } + } + + if (false !== self::$phpParser) { + $class->setUseStatements(self::$phpParser->parseClass($ref)); + } + + if ($docComment = $ref->getDocComment()) { + $class->setDocblock(ReflectionUtils::getUnindentedDocComment($docComment)); + } + + foreach ($ref->getMethods() as $method) { + $class->setMethod(static::createMethod($method)); + } + + foreach ($ref->getProperties() as $property) { + $class->setProperty(static::createProperty($property)); + } + + return $class; + } + + protected static function createMethod(\ReflectionMethod $method) + { + return PhpMethod::fromReflection($method); + } + + protected static function createProperty(\ReflectionProperty $property) + { + return PhpProperty::fromReflection($property); + } + + public function __construct($name = null) + { + $this->name = $name; + } + + public function setName($name) + { + $this->name = $name; + + return $this; + } + + public function setParentClassName($name) + { + $this->parentClassName = $name; + + return $this; + } + + public function setInterfaceNames(array $names) + { + $this->interfaceNames = $names; + + return $this; + } + + public function addInterfaceName($name) + { + $this->interfaceNames[] = $name; + + return $this; + } + + public function setRequiredFiles(array $files) + { + $this->requiredFiles = $files; + + return $this; + } + + public function addRequiredFile($file) + { + $this->requiredFiles[] = $file; + + return $this; + } + + public function setUseStatements(array $useStatements) + { + $this->useStatements = $useStatements; + + return $this; + } + + public function addUseStatement($namespace, $alias = null) + { + if (null === $alias) { + $alias = substr($namespace, strrpos($namespace, '\\') + 1); + } + + $this->useStatements[$alias] = $namespace; + + return $this; + } + + public function setConstants(array $constants) + { + $this->constants = $constants; + + return $this; + } + + public function setConstant($name, $value) + { + $this->constants[$name] = $value; + + return $this; + } + + public function hasConstant($name) + { + return array_key_exists($this->constants, $name); + } + + public function removeConstant($name) + { + if (!array_key_exists($name, $this->constants)) { + throw new \InvalidArgumentException(sprintf('The constant "%s" does not exist.', $name)); + } + + unset($this->constants[$name]); + + return $this; + } + + public function setProperties(array $properties) + { + $this->properties = $properties; + + return $this; + } + + public function setProperty(PhpProperty $property) + { + $this->properties[$property->getName()] = $property; + + return $this; + } + + public function hasProperty($property) + { + if ($property instanceof PhpProperty) { + $property = $property->getName(); + } + + return isset($this->properties[$property]); + } + + public function removeProperty($property) + { + if ($property instanceof PhpProperty) { + $property = $property->getName(); + } + + if (!array_key_exists($property, $this->properties)) { + throw new \InvalidArgumentException(sprintf('The property "%s" does not exist.', $property)); + } + unset($this->properties[$property]); + + return $this; + } + + public function setMethods(array $methods) + { + $this->methods = $methods; + + return $this; + } + + public function setMethod(PhpMethod $method) + { + $this->methods[$method->getName()] = $method; + + return $this; + } + + public function hasMethod($method) + { + if ($method instanceof PhpMethod) { + $method = $method->getName(); + } + + return isset($this->methods[$method]); + } + + public function removeMethod($method) + { + if ($method instanceof PhpMethod) { + $method = $method->getName(); + } + + if (!array_key_exists($method, $this->methods)) { + throw new \InvalidArgumentException(sprintf('The method "%s" does not exist.', $method)); + } + unset($this->methods[$method]); + + return $this; + } + + public function setAbstract($bool) + { + $this->abstract = (Boolean) $bool; + + return $this; + } + + public function setFinal($bool) + { + $this->final = (Boolean) $bool; + + return $this; + } + + public function setDocblock($block) + { + $this->docblock = $block; + + return $this; + } + + public function getName() + { + return $this->name; + } + + public function getParentClassName() + { + return $this->parentClassName; + } + + public function getInterfaceNames() + { + return $this->interfaceNames; + } + + public function getRequiredFiles() + { + return $this->requiredFiles; + } + + public function getUseStatements() + { + return $this->useStatements; + } + + public function getNamespace() + { + if (false === $pos = strrpos($this->name, '\\')) { + return null; + } + + return substr($this->name, 0, $pos); + } + + public function getShortName() + { + if (false === $pos = strrpos($this->name, '\\')) { + return $this->name; + } + + return substr($this->name, $pos+1); + } + + public function getConstants() + { + return $this->constants; + } + + public function getProperties() + { + return $this->properties; + } + + public function getMethods() + { + return $this->methods; + } + + public function isAbstract() + { + return $this->abstract; + } + + public function isFinal() + { + return $this->final; + } + + public function getDocblock() + { + return $this->docblock; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpFunction.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpFunction.php new file mode 100644 index 0000000..2c14511 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpFunction.php @@ -0,0 +1,146 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * Represents a PHP function. + * + * @author Johannes M. Schmitt + */ +class PhpFunction +{ + private $name; + private $namespace; + private $parameters = array(); + private $body = ''; + private $referenceReturned = false; + private $docblock; + + public static function create($name = null) + { + return new static($name); + } + + public function __construct($name = null) + { + $this->name = $name; + } + + public function setName($name) + { + $this->name = $name; + + return $this; + } + + public function setNamespace($namespace) + { + $this->namespace = $namespace; + + return $this; + } + + public function setParameters(array $parameters) + { + $this->parameters = $parameters; + + return $this; + } + + public function setReferenceReturned($bool) + { + $this->referenceReturned = (Boolean) $bool; + + return $this; + } + + public function replaceParameter($position, PhpParameter $parameter) + { + if ($position < 0 || $position > count($this->parameters)) { + throw new \InvalidArgumentException(sprintf('$position must be in the range [0, %d].', count($this->parameters))); + } + + $this->parameters[$position] = $parameter; + + return $this; + } + + public function addParameter(PhpParameter $parameter) + { + $this->parameters[] = $parameter; + + return $this; + } + + public function removeParameter($position) + { + if (!isset($this->parameters[$position])) { + throw new \InvalidArgumentException(sprintf('There is not parameter at position %d.', $position)); + } + + unset($this->parameters[$position]); + $this->parameters = array_values($this->parameters); + + return $this; + } + + public function setBody($body) + { + $this->body = $body; + + return $this; + } + + public function setDocblock($docBlock) + { + $this->docblock = $docBlock; + + return $this; + } + + public function getName() + { + return $this->name; + } + + public function getNamespace() + { + return $this->namespace; + } + + public function getParameters() + { + return $this->parameters; + } + + public function getBody() + { + return $this->body; + } + + public function getDocblock() + { + return $this->docblock; + } + + public function isReferenceReturned() + { + return $this->referenceReturned; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpMethod.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpMethod.php new file mode 100644 index 0000000..f8b7314 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpMethod.php @@ -0,0 +1,158 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +use CG\Core\ReflectionUtils; + +/** + * Represents a PHP method. + * + * @author Johannes M. Schmitt + */ +class PhpMethod extends AbstractPhpMember +{ + private $final = false; + private $abstract = false; + private $parameters = array(); + private $referenceReturned = false; + private $body = ''; + + public static function create($name = null) + { + return new static($name); + } + + public static function fromReflection(\ReflectionMethod $ref) + { + $method = new static(); + $method + ->setFinal($ref->isFinal()) + ->setAbstract($ref->isAbstract()) + ->setStatic($ref->isStatic()) + ->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE)) + ->setReferenceReturned($ref->returnsReference()) + ->setName($ref->name) + ; + + if ($docComment = $ref->getDocComment()) { + $method->setDocblock(ReflectionUtils::getUnindentedDocComment($docComment)); + } + + foreach ($ref->getParameters() as $param) { + $method->addParameter(static::createParameter($param)); + } + + // FIXME: Extract body? + + return $method; + } + + protected static function createParameter(\ReflectionParameter $parameter) + { + return PhpParameter::fromReflection($parameter); + } + + public function setFinal($bool) + { + $this->final = (Boolean) $bool; + + return $this; + } + + public function setAbstract($bool) + { + $this->abstract = $bool; + + return $this; + } + + public function setReferenceReturned($bool) + { + $this->referenceReturned = (Boolean) $bool; + + return $this; + } + + public function setBody($body) + { + $this->body = $body; + + return $this; + } + + public function setParameters(array $parameters) + { + $this->parameters = array_values($parameters); + + return $this; + } + + public function addParameter(PhpParameter $parameter) + { + $this->parameters[] = $parameter; + + return $this; + } + + public function replaceParameter($position, PhpParameter $parameter) + { + if ($position < 0 || $position > strlen($this->parameters)) { + throw new \InvalidArgumentException(sprintf('The position must be in the range [0, %d].', strlen($this->parameters))); + } + $this->parameters[$position] = $parameter; + + return $this; + } + + public function removeParameter($position) + { + if (!isset($this->parameters[$position])) { + throw new \InvalidArgumentException(sprintf('There is no parameter at position "%d" does not exist.', $position)); + } + unset($this->parameters[$position]); + $this->parameters = array_values($this->parameters); + + return $this; + } + + public function isFinal() + { + return $this->final; + } + + public function isAbstract() + { + return $this->abstract; + } + + public function isReferenceReturned() + { + return $this->referenceReturned; + } + + public function getBody() + { + return $this->body; + } + + public function getParameters() + { + return $this->parameters; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpParameter.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpParameter.php new file mode 100644 index 0000000..0f8b2cb --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpParameter.php @@ -0,0 +1,126 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * Represents a PHP parameter. + * + * @author Johannes M. Schmitt + */ +class PhpParameter +{ + private $name; + private $defaultValue; + private $hasDefaultValue = false; + private $passedByReference = false; + private $type; + + public static function create($name = null) + { + return new static($name); + } + + public static function fromReflection(\ReflectionParameter $ref) + { + $parameter = new static(); + $parameter + ->setName($ref->name) + ->setPassedByReference($ref->isPassedByReference()) + ; + + if ($ref->isDefaultValueAvailable()) { + $parameter->setDefaultValue($ref->getDefaultValue()); + } + + if ($ref->isArray()) { + $parameter->setType('array'); + } else if ($class = $ref->getClass()) { + $parameter->setType($class->name); + } + + return $parameter; + } + + public function __construct($name = null) + { + $this->name = $name; + } + + public function setName($name) + { + $this->name = $name; + + return $this; + } + + public function setDefaultValue($value) + { + $this->defaultValue = $value; + $this->hasDefaultValue = true; + + return $this; + } + + public function unsetDefaultValue() + { + $this->defaultValue = null; + $this->hasDefaultValue = false; + + return $this; + } + + public function setPassedByReference($bool) + { + $this->passedByReference = (Boolean) $bool; + + return $this; + } + + public function setType($type) + { + $this->type = $type; + + return $this; + } + + public function getName() + { + return $this->name; + } + + public function getDefaultValue() + { + return $this->defaultValue; + } + + public function hasDefaultValue() + { + return $this->hasDefaultValue; + } + + public function isPassedByReference() + { + return $this->passedByReference; + } + + public function getType() + { + return $this->type; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpProperty.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpProperty.php new file mode 100644 index 0000000..a5b33d8 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/PhpProperty.php @@ -0,0 +1,84 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +use CG\Core\ReflectionUtils; + +/** + * Represents a PHP property. + * + * @author Johannes M. Schmitt + */ +class PhpProperty extends AbstractPhpMember +{ + private $hasDefaultValue = false; + private $defaultValue; + + public static function create($name = null) + { + return new static($name); + } + + public static function fromReflection(\ReflectionProperty $ref) + { + $property = new static(); + $property + ->setName($ref->name) + ->setStatic($ref->isStatic()) + ->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE)) + ; + + if ($docComment = $ref->getDocComment()) { + $property->setDocblock(ReflectionUtils::getUnindentedDocComment($docComment)); + } + + $defaultProperties = $ref->getDeclaringClass()->getDefaultProperties(); + if (isset($defaultProperties[$ref->name])) { + $property->setDefaultValue($defaultProperties[$ref->name]); + } + + return $property; + } + + public function setDefaultValue($value) + { + $this->defaultValue = $value; + $this->hasDefaultValue = true; + + return $this; + } + + public function unsetDefaultValue() + { + $this->hasDefaultValue = false; + $this->defaultValue = null; + + return $this; + } + + public function hasDefaultValue() + { + return $this->hasDefaultValue; + } + + public function getDefaultValue() + { + return $this->defaultValue; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/Writer.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/Writer.php new file mode 100644 index 0000000..29ca853 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Generator/Writer.php @@ -0,0 +1,103 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Generator; + +/** + * A writer implementation. + * + * This may be used to simplify writing well-formatted code. + * + * @author Johannes M. Schmitt + */ +class Writer +{ + private $content = ''; + private $indentationSpaces = 4; + private $indentationLevel = 0; + + public function indent() + { + $this->indentationLevel += 1; + + return $this; + } + + public function outdent() + { + $this->indentationLevel -= 1; + + if ($this->indentationLevel < 0) { + throw new \RuntimeException('The identation level cannot be less than zero.'); + } + + return $this; + } + + public function writeln($content) + { + $this->write($content."\n"); + + return $this; + } + + public function write($content) + { + $lines = explode("\n", $content); + for ($i=0,$c=count($lines); $i<$c; $i++) { + if ($this->indentationLevel > 0 + && !empty($lines[$i]) + && (empty($this->content) || "\n" === substr($this->content, -1))) { + $this->content .= str_repeat(' ', $this->indentationLevel * $this->indentationSpaces); + } + + $this->content .= $lines[$i]; + + if ($i+1 < $c) { + $this->content .= "\n"; + } + } + + return $this; + } + + public function rtrim() + { + $addNl = "\n" === substr($this->content, -1); + $this->content = rtrim($this->content); + + if ($addNl) { + $this->content .= "\n"; + } + + return $this; + } + + public function reset() + { + $this->content = ''; + $this->indentationLevel = 0; + + return $this; + } + + public function getContent() + { + return $this->content; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/Enhancer.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/Enhancer.php new file mode 100644 index 0000000..2ba73ed --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/Enhancer.php @@ -0,0 +1,158 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +use CG\Core\NamingStrategyInterface; + +use CG\Generator\Writer; +use CG\Generator\PhpMethod; +use CG\Generator\PhpDocblock; +use CG\Generator\PhpClass; +use CG\Core\AbstractClassGenerator; + +/** + * Class enhancing generator implementation. + * + * This class enhances existing classes by generating a proxy and leveraging + * different generator implementation. + * + * There are several built-in generator such as lazy-initializing objects, or + * a generator for creating AOP joinpoints. + * + * @author Johannes M. Schmitt + */ +class Enhancer extends AbstractClassGenerator +{ + private $generatedClass; + private $class; + private $interfaces; + private $generators; + + public function __construct(\ReflectionClass $class, array $interfaces = array(), array $generators = array()) + { + if (empty($generators) && empty($interfaces)) { + throw new \RuntimeException('Either generators, or interfaces must be given.'); + } + + $this->class = $class; + $this->interfaces = $interfaces; + $this->generators = $generators; + } + + /** + * Creates a new instance of the enhanced class. + * + * @param array $args + * @return object + */ + public function createInstance(array $args = array()) + { + $generatedClass = $this->getClassName($this->class); + + if (!class_exists($generatedClass, false)) { + eval($this->generateClass()); + } + + $ref = new \ReflectionClass($generatedClass); + + return $ref->newInstanceArgs($args); + } + + public function writeClass($filename) + { + if (!is_dir($dir = dirname($filename))) { + if (false === @mkdir($dir, 0777, true)) { + throw new \RuntimeException(sprintf('Could not create directory "%s".', $dir)); + } + } + + if (!is_writable($dir)) { + throw new \RuntimeException(sprintf('The directory "%s" is not writable.', $dir)); + } + + file_put_contents($filename, "generateClass()); + } + + /** + * Creates a new enhanced class + * + * @return string + */ + public final function generateClass() + { + static $docBlock; + if (empty($docBlock)) { + $writer = new Writer(); + $writer + ->writeln('/**') + ->writeln(' * CG library enhanced proxy class.') + ->writeln(' *') + ->writeln(' * This code was generated automatically by the CG library, manual changes to it') + ->writeln(' * will be lost upon next generation.') + ->writeln(' */') + ; + $docBlock = $writer->getContent(); + } + + $this->generatedClass = PhpClass::create() + ->setDocblock($docBlock) + ->setParentClassName($this->class->name) + ; + + $proxyClassName = $this->getClassName($this->class); + if (false === strpos($proxyClassName, NamingStrategyInterface::SEPARATOR)) { + throw new \RuntimeException(sprintf('The proxy class name must be suffixed with "%s" and an optional string, but got "%s".', NamingStrategyInterface::SEPARATOR, $proxyClassName)); + } + $this->generatedClass->setName($proxyClassName); + + if (!empty($this->interfaces)) { + $this->generatedClass->setInterfaceNames(array_map(function($v) { return '\\'.$v; }, $this->interfaces)); + + foreach ($this->getInterfaceMethods() as $method) { + $method = PhpMethod::fromReflection($method); + $method->setAbstract(false); + + $this->generatedClass->setMethod($method); + } + } + + if (!empty($this->generators)) { + foreach ($this->generators as $generator) { + $generator->generate($this->class, $this->generatedClass); + } + } + + return $this->generateCode($this->generatedClass); + } + + /** + * Adds stub methods for the interfaces that have been implemented. + */ + protected function getInterfaceMethods() + { + $methods = array(); + + foreach ($this->interfaces as $interface) { + $ref = new \ReflectionClass($interface); + $methods = array_merge($methods, $ref->getMethods()); + } + + return $methods; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/GeneratorInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/GeneratorInterface.php new file mode 100644 index 0000000..e641ec5 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/GeneratorInterface.php @@ -0,0 +1,38 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +use CG\Generator\PhpClass; + +/** + * Interface for enhancing generators. + * + * @author Johannes M. Schmitt + */ +interface GeneratorInterface +{ + /** + * Generates the necessary changes in the class. + * + * @param \ReflectionClass $originalClass + * @param PhpClass $generatedClass The generated class + * @return void + */ + function generate(\ReflectionClass $originalClass, PhpClass $generatedClass); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptionGenerator.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptionGenerator.php new file mode 100644 index 0000000..31a8ba6 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptionGenerator.php @@ -0,0 +1,117 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +use CG\Core\ClassUtils; + +use CG\Core\ReflectionUtils; + +use CG\Generator\PhpParameter; +use CG\Generator\PhpProperty; +use CG\Generator\PhpMethod; +use CG\Generator\PhpClass; + +/** + * Interception Generator. + * + * This generator creates joinpoints to allow for AOP advices. Right now, it only + * supports the most powerful around advice. + * + * @author Johannes M. Schmitt + */ +class InterceptionGenerator implements GeneratorInterface +{ + private $prefix = '__CGInterception__'; + private $filter; + private $requiredFile; + + public function setRequiredFile($file) + { + $this->requiredFile = $file; + } + + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + public function setFilter(\Closure $filter) + { + $this->filter = $filter; + } + + public function generate(\ReflectionClass $originalClass, PhpClass $genClass) + { + $methods = ReflectionUtils::getOverrideableMethods($originalClass); + + if (null !== $this->filter) { + $methods = array_filter($methods, $this->filter); + } + + if (empty($methods)) { + return; + } + + if (!empty($this->requiredFile)) { + $genClass->addRequiredFile($this->requiredFile); + } + + $interceptorLoader = new PhpProperty(); + $interceptorLoader + ->setName($this->prefix.'loader') + ->setVisibility(PhpProperty::VISIBILITY_PRIVATE) + ; + $genClass->setProperty($interceptorLoader); + + $loaderSetter = new PhpMethod(); + $loaderSetter + ->setName($this->prefix.'setLoader') + ->setVisibility(PhpMethod::VISIBILITY_PUBLIC) + ->setBody('$this->'.$this->prefix.'loader = $loader;') + ; + $genClass->setMethod($loaderSetter); + $loaderParam = new PhpParameter(); + $loaderParam + ->setName('loader') + ->setType('CG\Proxy\InterceptorLoaderInterface') + ; + $loaderSetter->addParameter($loaderParam); + + $interceptorCode = + '$ref = new \ReflectionMethod(%s, %s);'."\n" + .'$interceptors = $this->'.$this->prefix.'loader->loadInterceptors($ref, $this, array(%s));'."\n" + .'$invocation = new \CG\Proxy\MethodInvocation($ref, $this, array(%s), $interceptors);'."\n\n" + .'return $invocation->proceed();' + ; + + foreach ($methods as $method) { + $params = array(); + foreach ($method->getParameters() as $param) { + $params[] = '$'.$param->name; + } + $params = implode(', ', $params); + + $genMethod = PhpMethod::fromReflection($method) + ->setBody(sprintf($interceptorCode, var_export(ClassUtils::getUserClass($method->class), true), var_export($method->name, true), $params, $params)) + ->setDocblock(null) + ; + $genClass->setMethod($genMethod); + } + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptorLoaderInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptorLoaderInterface.php new file mode 100644 index 0000000..5deff19 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/InterceptorLoaderInterface.php @@ -0,0 +1,38 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +/** + * Interception Loader. + * + * Implementations of this interface are responsible for loading the interceptors + * for a certain method. + * + * @author Johannes M. Schmitt + */ +interface InterceptorLoaderInterface +{ + /** + * Loads interceptors. + * + * @param \ReflectionMethod $method + * @return array + */ + function loadInterceptors(\ReflectionMethod $method); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerGenerator.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerGenerator.php new file mode 100644 index 0000000..8591599 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerGenerator.php @@ -0,0 +1,153 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +use CG\Generator\Writer; +use CG\Core\ReflectionUtils; +use CG\Generator\GeneratorUtils; +use CG\Generator\PhpParameter; +use CG\Generator\PhpMethod; +use CG\Generator\PhpProperty; +use CG\Generator\PhpClass; + +/** + * Generator for creating lazy-initializing instances. + * + * This generator enhances concrete classes to allow for them to be lazily + * initialized upon first access. + * + * @author Johannes M. Schmitt + */ +class LazyInitializerGenerator implements GeneratorInterface +{ + private $writer; + private $prefix = '__CG__'; + private $markerInterface; + + public function __construct() + { + $this->writer = new Writer(); + } + + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * Sets the marker interface which should be implemented by the + * generated classes. + * + * @param string $interface The FQCN of the interface + */ + public function setMarkerInterface($interface) + { + $this->markerInterface = $interface; + } + + /** + * Generates the necessary methods in the class. + * + * @param \ReflectionClass $originalClass + * @param PhpClass $class + * @return void + */ + public function generate(\ReflectionClass $originalClass, PhpClass $class) + { + $methods = ReflectionUtils::getOverrideableMethods($originalClass, true); + + // no public, non final methods + if (empty($methods)) { + return; + } + + if (null !== $this->markerInterface) { + $class->setImplementedInterfaces(array_merge( + $class->getImplementedInterfaces(), + array($this->markerInterface) + )); + } + + $initializer = new PhpProperty(); + $initializer->setName($this->prefix.'lazyInitializer'); + $initializer->setVisibility(PhpProperty::VISIBILITY_PRIVATE); + $class->setProperty($initializer); + + $initialized = new PhpProperty(); + $initialized->setName($this->prefix.'initialized'); + $initialized->setDefaultValue(false); + $initialized->setVisibility(PhpProperty::VISIBILITY_PRIVATE); + $class->setProperty($initialized); + + $initializerSetter = new PhpMethod(); + $initializerSetter->setName($this->prefix.'setLazyInitializer'); + $initializerSetter->setBody('$this->'.$this->prefix.'lazyInitializer = $initializer;'); + + $parameter = new PhpParameter(); + $parameter->setName('initializer'); + $parameter->setType('\CG\Proxy\LazyInitializerInterface'); + $initializerSetter->addParameter($parameter); + $class->setMethod($initializerSetter); + + $this->addMethods($class, $methods); + + $initializingMethod = new PhpMethod(); + $initializingMethod->setName($this->prefix.'initialize'); + $initializingMethod->setVisibility(PhpMethod::VISIBILITY_PRIVATE); + $initializingMethod->setBody( + $this->writer + ->reset() + ->writeln('if (null === $this->'.$this->prefix.'lazyInitializer) {') + ->indent() + ->writeln('throw new \RuntimeException("'.$this->prefix.'setLazyInitializer() must be called prior to any other public method on this object.");') + ->outdent() + ->write("}\n\n") + ->writeln('$this->'.$this->prefix.'lazyInitializer->initializeObject($this);') + ->writeln('$this->'.$this->prefix.'initialized = true;') + ->getContent() + ); + $class->setMethod($initializingMethod); + } + + private function addMethods(PhpClass $class, array $methods) + { + foreach ($methods as $method) { + $initializingCode = 'if (false === $this->'.$this->prefix.'initialized) {'."\n" + .' $this->'.$this->prefix.'initialize();'."\n" + .'}'; + + if ($class->hasMethod($method->name)) { + $genMethod = $class->getMethod($method->name); + $genMethod->setBody( + $initializingCode."\n" + .$genMethod->getBody() + ); + + continue; + } + + $genMethod = PhpMethod::fromReflection($method); + $genMethod->setBody( + $initializingCode."\n\n" + .'return '.GeneratorUtils::callMethod($method).';' + ); + $class->setMethod($genMethod); + } + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerInterface.php new file mode 100644 index 0000000..7cfca5b --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/LazyInitializerInterface.php @@ -0,0 +1,38 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +/** + * Lazy Initializer. + * + * Implementations of this interface are responsible for lazily initializing + * object instances. + * + * @author Johannes M. Schmitt + */ +interface LazyInitializerInterface +{ + /** + * Initializes the passed object. + * + * @param object $object + * @return void + */ + function initializeObject($object); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInterceptorInterface.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInterceptorInterface.php new file mode 100644 index 0000000..f1a7997 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInterceptorInterface.php @@ -0,0 +1,42 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +/** + * Interface for Method Interceptors. + * + * Implementations of this interface can execute custom code before, and after the + * invocation of the actual method. In addition, they can also catch, or throw + * exceptions, modify the return value, or modify the arguments. + * + * This is also known as around advice in AOP terminology. + * + * @author Johannes M. Schmitt + */ +interface MethodInterceptorInterface +{ + /** + * Called when intercepting a method call. + * + * @param MethodInvocation $invocation + * @return mixed the return value for the method invocation + * @throws \Exception may throw any exception + */ + function intercept(MethodInvocation $invocation); +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInvocation.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInvocation.php new file mode 100644 index 0000000..11393f4 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/MethodInvocation.php @@ -0,0 +1,77 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +/** + * Represents a method invocation. + * + * This object contains information for the method invocation, such as the object + * on which the method is invoked, and the arguments that are passed to the method. + * + * Before the actual method is called, first all the interceptors must call the + * proceed() method on this class. + * + * @author Johannes M. Schmitt + */ +class MethodInvocation +{ + public $reflection; + public $object; + public $arguments; + + private $interceptors; + private $pointer; + + public function __construct(\ReflectionMethod $reflection, $object, array $arguments, array $interceptors) + { + $this->reflection = $reflection; + $this->object = $object; + $this->arguments = $arguments; + $this->interceptors = $interceptors; + $this->pointer = 0; + } + + /** + * Proceeds down the call-chain and eventually calls the original method. + * + * @return mixed + */ + public function proceed() + { + if (isset($this->interceptors[$this->pointer])) { + return $this->interceptors[$this->pointer++]->intercept($this); + } + + $this->reflection->setAccessible(true); + + return $this->reflection->invokeArgs($this->object, $this->arguments); + } + + /** + * Returns a string representation of the method. + * + * This is intended for debugging purposes only. + * + * @return string + */ + public function __toString() + { + return sprintf('%s::%s', $this->reflection->class, $this->reflection->name); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/RegexInterceptionLoader.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/RegexInterceptionLoader.php new file mode 100644 index 0000000..74a7c37 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Proxy/RegexInterceptionLoader.php @@ -0,0 +1,48 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace CG\Proxy; + +class RegexInterceptionLoader implements InterceptorLoaderInterface +{ + private $interceptors; + + public function __construct(array $interceptors = array()) + { + $this->interceptors = $interceptors; + } + + public function loadInterceptors(\ReflectionMethod $method) + { + $signature = $method->class.'::'.$method->name; + + $matchingInterceptors = array(); + foreach ($this->interceptors as $pattern => $interceptor) { + if (preg_match('#'.$pattern.'#', $signature)) { + $matchingInterceptors[] = $this->initializeInterceptor($interceptor); + } + } + + return $matchingInterceptors; + } + + protected function initializeInterceptor($interceptor) + { + return $interceptor; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Version.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Version.php new file mode 100644 index 0000000..0ca6842 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/src/CG/Version.php @@ -0,0 +1,8 @@ +assertEquals('Foo', ClassUtils::getUserClass('Foo')); + $this->assertEquals('Bar', ClassUtils::getUserClass('FOO\__CG__\Bar')); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/DefaultGeneratorStrategyTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/DefaultGeneratorStrategyTest.php new file mode 100644 index 0000000..2ab4638 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/DefaultGeneratorStrategyTest.php @@ -0,0 +1,66 @@ +setConstantSortFunc(function($a, $b) { + return strcasecmp($a, $b); + }); + $strategy->setMethodSortFunc($func = function($a, $b) { + return strcasecmp($a->getName(), $b->getName()); + }); + $strategy->setPropertySortFunc($func); + + $this->assertEquals( + $this->getContent('GenerationTestClass_A.php'), + $strategy->generate($this->getClass()) + ); + } + + public function testGenerateChangedConstantOrder() + { + $strategy = new DefaultGeneratorStrategy(); + $strategy->setConstantSortFunc(function($a, $b) { + return -1 * strcasecmp($a, $b); + }); + $strategy->setMethodSortFunc($func = function($a, $b) { + return strcasecmp($a->getName(), $b->getName()); + }); + $strategy->setPropertySortFunc($func); + + $this->assertEquals( + $this->getContent('GenerationTestClass_B.php'), + $strategy->generate($this->getClass()) + ); + } + + private function getContent($file) + { + return file_get_contents(__DIR__.'/generated/'.$file); + } + + private function getClass() + { + $class = PhpClass::create() + ->setName('GenerationTestClass') + ->setMethod(PhpMethod::create('a')) + ->setMethod(PhpMethod::create('b')) + ->setProperty(PhpProperty::create('a')) + ->setProperty(PhpProperty::create('b')) + ->setConstant('a', 'foo') + ->setConstant('b', 'bar') + ; + + return $class; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/ReflectionUtilsTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/ReflectionUtilsTest.php new file mode 100644 index 0000000..d46f675 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/ReflectionUtilsTest.php @@ -0,0 +1,48 @@ +assertEquals(4, count($methods)); + + $methods = array_map(function($v) { return $v->name; }, $methods); + sort($methods); + $this->assertEquals(array('a', 'd', 'e', 'h'), $methods); + } + + public function testGetUnindentedDocComment() + { + $writer = new Writer(); + $comment = $writer + ->writeln('/**') + ->indent() + ->writeln(' * Foo.') + ->write(' */') + ->getContent() + ; + + $this->assertEquals("/**\n * Foo.\n */", ReflectionUtils::getUnindentedDocComment($comment)); + } +} + +abstract class OverridableReflectionTest +{ + public function a() { } + public final function b() { } + public static function c() { } + abstract public function d(); + protected function e() { } + protected final function f() {} + protected static function g() { } + abstract protected function h(); + private function i() { } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_A.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_A.php new file mode 100644 index 0000000..4f17cc8 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_A.php @@ -0,0 +1,16 @@ +class GenerationTestClass +{ + const a = 'foo'; + const b = 'bar'; + + public $a; + public $b; + + public function a() + { + } + + public function b() + { + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_B.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_B.php new file mode 100644 index 0000000..6a0c80c --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Core/generated/GenerationTestClass_B.php @@ -0,0 +1,16 @@ +class GenerationTestClass +{ + const b = 'bar'; + const a = 'foo'; + + public $a; + public $b; + + public function a() + { + } + + public function b() + { + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/AbstractPhpMemberTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/AbstractPhpMemberTest.php new file mode 100644 index 0000000..16f65c9 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/AbstractPhpMemberTest.php @@ -0,0 +1,58 @@ +getMember(); + + $this->assertFalse($member->isStatic()); + $this->assertSame($member, $member->setStatic(true)); + $this->assertTrue($member->isStatic()); + $this->assertSame($member, $member->setStatic(false)); + $this->assertFalse($member->isStatic()); + } + + public function testSetGetVisibility() + { + $member = $this->getMember(); + + $this->assertEquals('public', $member->getVisibility()); + $this->assertSame($member, $member->setVisibility('private')); + $this->assertEquals('private', $member->getVisibility()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testSetVisibilityThrowsExOnInvalidValue() + { + $member = $this->getMember(); + $member->setVisibility('foo'); + } + + public function testSetGetName() + { + $member = $this->getMember(); + + $this->assertNull($member->getName()); + $this->assertSame($member, $member->setName('foo')); + $this->assertEquals('foo', $member->getName()); + } + + public function testSetGetDocblock() + { + $member = $this->getMember(); + + $this->assertNull($member->getDocblock()); + $this->assertSame($member, $member->setDocblock('foo')); + $this->assertEquals('foo', $member->getDocblock()); + } + + private function getMember() + { + return $this->getMockForAbstractClass('CG\Generator\AbstractPhpMember'); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/DefaultVisitorTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/DefaultVisitorTest.php new file mode 100644 index 0000000..a159a1a --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/DefaultVisitorTest.php @@ -0,0 +1,47 @@ +setName('foo') + ->addParameter(PhpParameter::create('a')) + ->addParameter(PhpParameter::create('b')) + ->setBody( + $writer + ->writeln('if ($a === $b) {') + ->indent() + ->writeln('throw new \InvalidArgumentException(\'$a is not allowed to be the same as $b.\');') + ->outdent() + ->write("}\n\n") + ->write('return $b;') + ->getContent() + ) + ; + + $visitor = new DefaultVisitor(); + $visitor->visitFunction($function); + + $this->assertEquals($this->getContent('a_b_function.php'), $visitor->getContent()); + } + + private function getContent($filename) + { + if (!is_file($path = __DIR__.'/Fixture/generated/'.$filename)) { + throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $path)); + } + + return file_get_contents($path); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/Entity.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/Entity.php new file mode 100644 index 0000000..525a616 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/Entity.php @@ -0,0 +1,35 @@ + + */ +abstract class Entity +{ + /** + * @var integer + */ + private $id; + private $enabled = false; + + /** + * Another doc comment. + * + * @param unknown_type $a + * @param array $b + * @param \stdClass $c + * @param unknown_type $d + */ + public final function __construct($a, array &$b, \stdClass $c, $d = 'foo') + { + } + + abstract protected function foo(); + + private static function bar() + { + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/generated/a_b_function.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/generated/a_b_function.php new file mode 100644 index 0000000..8a79355 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/Fixture/generated/a_b_function.php @@ -0,0 +1,8 @@ +function foo($a, $b) +{ + if ($a === $b) { + throw new \InvalidArgumentException('$a is not allowed to be the same as $b.'); + } + + return $b; +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpClassTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpClassTest.php new file mode 100644 index 0000000..ab35d16 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpClassTest.php @@ -0,0 +1,215 @@ +setName('CG\Tests\Generator\Fixture\Entity') + ->setAbstract(true) + ->setDocblock('/** + * Doc Comment. + * + * @author Johannes M. Schmitt + */') + ->setProperty(PhpProperty::create('id') + ->setVisibility('private') + ->setDocblock('/** + * @var integer + */') + ) + ->setProperty(PhpProperty::create('enabled') + ->setVisibility('private') + ->setDefaultValue(false) + ) + ; + + $method = PhpMethod::create() + ->setName('__construct') + ->setFinal(true) + ->addParameter(new PhpParameter('a')) + ->addParameter(PhpParameter::create() + ->setName('b') + ->setType('array') + ->setPassedByReference(true) + ) + ->addParameter(PhpParameter::create() + ->setName('c') + ->setType('stdClass') + ) + ->addParameter(PhpParameter::create() + ->setName('d') + ->setDefaultValue('foo') + )->setDocblock('/** + * Another doc comment. + * + * @param unknown_type $a + * @param array $b + * @param \stdClass $c + * @param unknown_type $d + */') + ; + $class->setMethod($method); + + $class->setMethod(PhpMethod::create() + ->setName('foo') + ->setAbstract(true) + ->setVisibility('protected') + ); + + $class->setMethod(PhpMethod::create() + ->setName('bar') + ->setStatic(true) + ->setVisibility('private') + ); + + $this->assertEquals($class, PhpClass::fromReflection(new \ReflectionClass('CG\Tests\Generator\Fixture\Entity'))); + } + + public function testGetSetName() + { + $class = new PhpClass(); + $this->assertNull($class->getName()); + + $class = new PhpClass('foo'); + $this->assertEquals('foo', $class->getName()); + $this->assertSame($class, $class->setName('bar')); + $this->assertEquals('bar', $class->getName()); + } + + public function testSetGetConstants() + { + $class = new PhpClass(); + + $this->assertEquals(array(), $class->getConstants()); + $this->assertSame($class, $class->setConstants(array('foo' => 'bar'))); + $this->assertEquals(array('foo' => 'bar'), $class->getConstants()); + $this->assertSame($class, $class->setConstant('bar', 'baz')); + $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), $class->getConstants()); + $this->assertSame($class, $class->removeConstant('foo')); + $this->assertEquals(array('bar' => 'baz'), $class->getConstants()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testRemoveConstantThrowsExceptionWhenConstantDoesNotExist() + { + $class = new PhpClass(); + $class->removeConstant('foo'); + } + + public function testSetIsAbstract() + { + $class = new PhpClass(); + + $this->assertFalse($class->isAbstract()); + $this->assertSame($class, $class->setAbstract(true)); + $this->assertTrue($class->isAbstract()); + $this->assertSame($class, $class->setAbstract(false)); + $this->assertFalse($class->isAbstract()); + } + + public function testSetIsFinal() + { + $class = new PhpClass(); + + $this->assertFalse($class->isFinal()); + $this->assertSame($class, $class->setFinal(true)); + $this->assertTrue($class->isFinal()); + $this->assertSame($class, $class->setFinal(false)); + $this->assertFalse($class->isFinal()); + } + + public function testSetGetParentClassName() + { + $class = new PhpClass(); + + $this->assertNull($class->getParentClassName()); + $this->assertSame($class, $class->setParentClassName('stdClass')); + $this->assertEquals('stdClass', $class->getParentClassName()); + $this->assertSame($class, $class->setParentClassName(null)); + $this->assertNull($class->getParentClassName()); + } + + public function testSetGetInterfaceNames() + { + $class = new PhpClass(); + + $this->assertEquals(array(), $class->getInterfaceNames()); + $this->assertSame($class, $class->setInterfaceNames(array('foo', 'bar'))); + $this->assertEquals(array('foo', 'bar'), $class->getInterfaceNames()); + $this->assertSame($class, $class->addInterfaceName('stdClass')); + $this->assertEquals(array('foo', 'bar', 'stdClass'), $class->getInterfaceNames()); + } + + public function testSetGetUseStatements() + { + $class = new PhpClass(); + + $this->assertEquals(array(), $class->getUseStatements()); + $this->assertSame($class, $class->setUseStatements(array('foo' => 'bar'))); + $this->assertEquals(array('foo' => 'bar'), $class->getUseStatements()); + $this->assertSame($class, $class->addUseStatement('Foo\Bar')); + $this->assertEquals(array('foo' => 'bar', 'Bar' => 'Foo\Bar'), $class->getUseStatements()); + $this->assertSame($class, $class->addUseStatement('Foo\Bar', 'Baz')); + $this->assertEquals(array('foo' => 'bar', 'Bar' => 'Foo\Bar', 'Baz' => 'Foo\Bar'), $class->getUseStatements()); + } + + public function testSetGetProperties() + { + $class = new PhpClass(); + + $this->assertEquals(array(), $class->getProperties()); + $this->assertSame($class, $class->setProperties($props = array('foo' => new PhpProperty()))); + $this->assertSame($props, $class->getProperties()); + $this->assertSame($class, $class->setProperty($prop = new PhpProperty('foo'))); + $this->assertSame(array('foo' => $prop), $class->getProperties()); + $this->assertTrue($class->hasProperty('foo')); + $this->assertSame($class, $class->removeProperty('foo')); + $this->assertEquals(array(), $class->getProperties()); + } + + public function testSetGetMethods() + { + $class = new PhpClass(); + + $this->assertEquals(array(), $class->getMethods()); + $this->assertSame($class, $class->setMethods($methods = array('foo' => new PhpMethod()))); + $this->assertSame($methods, $class->getMethods()); + $this->assertSame($class, $class->setMethod($method = new PhpMethod('foo'))); + $this->assertSame(array('foo' => $method), $class->getMethods()); + $this->assertTrue($class->hasMethod('foo')); + $this->assertSame($class, $class->removeMethod('foo')); + $this->assertEquals(array(), $class->getMethods()); + } + + public function testSetGetDocblock() + { + $class = new PhpClass(); + + $this->assertNull($class->getDocblock()); + $this->assertSame($class, $class->setDocblock('foo')); + $this->assertEquals('foo', $class->getDocblock()); + } + + public function testSetGetRequiredFiles() + { + $class = new PhpClass(); + + $this->assertEquals(array(), $class->getRequiredFiles()); + $this->assertSame($class, $class->setRequiredFiles(array('foo'))); + $this->assertEquals(array('foo'), $class->getRequiredFiles()); + $this->assertSame($class, $class->addRequiredFile('bar')); + $this->assertEquals(array('foo', 'bar'), $class->getRequiredFiles()); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpFunctionTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpFunctionTest.php new file mode 100644 index 0000000..376b58a --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpFunctionTest.php @@ -0,0 +1,75 @@ +assertNull($func->getName()); + $this->assertSame($func, $func->setName('foo')); + $this->assertEquals('foo', $func->getName()); + + $func = new PhpFunction('foo'); + $this->assertEquals('foo', $func->getName()); + } + + public function testSetGetNamespace() + { + $func = new PhpFunction(); + + $this->assertNull($func->getNamespace()); + $this->assertSame($func, $func->setNamespace('foo')); + $this->assertEquals('foo', $func->getNamespace()); + } + + public function testSetGetBody() + { + $func = new PhpFunction(); + + $this->assertSame('', $func->getBody()); + $this->assertSame($func, $func->setBody('foo')); + $this->assertEquals('foo', $func->getBody()); + } + + public function testSetGetParameters() + { + $func = new PhpFunction(); + + $this->assertEquals(array(), $func->getParameters()); + $this->assertSame($func, $func->setParameters(array($param = new PhpParameter()))); + $this->assertSame(array($param), $func->getParameters()); + $this->assertSame($func, $func->addParameter($param2 = new PhpParameter())); + $this->assertSame(array($param, $param2), $func->getParameters()); + $this->assertSame($func, $func->replaceParameter(1, $param3 = new PhpParameter())); + $this->assertSame(array($param, $param3), $func->getParameters()); + $this->assertSame($func, $func->removeParameter(0)); + $this->assertSame(array($param3), $func->getParameters()); + } + + public function testSetGetDocblock() + { + $func = new PhpFunction(); + + $this->assertNull($func->getDocblock()); + $this->assertSame($func, $func->setDocblock('foo')); + $this->assertEquals('foo', $func->getDocblock()); + } + + public function testSetIsReferenceReturned() + { + $func = new PhpFunction(); + + $this->assertFalse($func->isReferenceReturned()); + $this->assertSame($func, $func->setReferenceReturned(true)); + $this->assertTrue($func->isReferenceReturned()); + $this->assertSame($func, $func->setReferenceReturned(false)); + $this->assertFalse($func->isReferenceReturned()); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpMethodTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpMethodTest.php new file mode 100644 index 0000000..cd84bc5 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpMethodTest.php @@ -0,0 +1,74 @@ +assertFalse($method->isFinal()); + $this->assertSame($method, $method->setFinal(true)); + $this->assertTrue($method->isFinal()); + $this->assertSame($method, $method->setFinal(false)); + $this->assertFalse($method->isFinal()); + } + + public function testSetIsAbstract() + { + $method = new PhpMethod(); + + $this->assertFalse($method->isAbstract()); + $this->assertSame($method, $method->setAbstract(true)); + $this->assertTrue($method->isAbstract()); + $this->assertSame($method, $method->setAbstract(false)); + $this->assertFalse($method->isAbstract()); + } + + public function testSetGetParameters() + { + $method = new PhpMethod(); + + $this->assertEquals(array(), $method->getParameters()); + $this->assertSame($method, $method->setParameters($params = array(new PhpParameter()))); + $this->assertSame($params, $method->getParameters()); + + $this->assertSame($method, $method->addParameter($param = new PhpParameter())); + $params[] = $param; + $this->assertSame($params, $method->getParameters()); + + $this->assertSame($method, $method->removeParameter(0)); + unset($params[0]); + $this->assertSame(array($param), $method->getParameters()); + + $this->assertSame($method, $method->addParameter($param = new PhpParameter())); + $params[] = $param; + $params = array_values($params); + $this->assertSame($params, $method->getParameters()); + } + + public function testSetGetBody() + { + $method = new PhpMethod(); + + $this->assertSame('', $method->getBody()); + $this->assertSame($method, $method->setBody('foo')); + $this->assertEquals('foo', $method->getBody()); + } + + public function testSetIsReferenceReturned() + { + $method = new PhpMethod(); + + $this->assertFalse($method->isReferenceReturned()); + $this->assertSame($method, $method->setReferenceReturned(true)); + $this->assertTrue($method->isReferenceReturned()); + $this->assertSame($method, $method->setReferenceReturned(false)); + $this->assertFalse($method->isReferenceReturned()); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpParameterTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpParameterTest.php new file mode 100644 index 0000000..7586a97 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpParameterTest.php @@ -0,0 +1,51 @@ +assertNull($param->getName()); + $this->assertSame($param, $param->setName('foo')); + $this->assertEquals('foo', $param->getName()); + } + + public function testSetGetDefaultValue() + { + $param = new PhpParameter(); + + $this->assertNull($param->getDefaultValue()); + $this->assertFalse($param->hasDefaultValue()); + $this->assertSame($param, $param->setDefaultValue('foo')); + $this->assertEquals('foo', $param->getDefaultValue()); + $this->assertTrue($param->hasDefaultValue()); + $this->assertSame($param, $param->unsetDefaultValue()); + $this->assertNull($param->getDefaultValue()); + $this->assertFalse($param->hasDefaultValue()); + } + + public function testSetIsPassedByReference() + { + $param = new PhpParameter(); + + $this->assertFalse($param->isPassedByReference()); + $this->assertSame($param, $param->setPassedByReference(true)); + $this->assertTrue($param->isPassedByReference()); + $this->assertSame($param, $param->setPassedByReference(false)); + $this->assertFalse($param->isPassedByReference()); + } + + public function testSetGetType() + { + $param = new PhpParameter(); + + $this->assertNull($param->getType()); + $this->assertSame($param, $param->setType('array')); + $this->assertEquals('array', $param->getType()); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpPropertyTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpPropertyTest.php new file mode 100644 index 0000000..df28f8f --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Generator/PhpPropertyTest.php @@ -0,0 +1,22 @@ +assertNull($prop->getDefaultValue()); + $this->assertFalse($prop->hasDefaultValue()); + $this->assertSame($prop, $prop->setDefaultValue('foo')); + $this->assertEquals('foo', $prop->getDefaultValue()); + $this->assertTrue($prop->hasDefaultValue()); + $this->assertSame($prop, $prop->unsetDefaultValue()); + $this->assertNull($prop->getDefaultValue()); + $this->assertFalse($prop->hasDefaultValue()); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/EnhancerTest.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/EnhancerTest.php new file mode 100644 index 0000000..30770e2 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/EnhancerTest.php @@ -0,0 +1,111 @@ +setNamingStrategy($this->getNamingStrategy($generatedClass)); + + $this->assertEquals($this->getContent(substr($generatedClass, strrpos($generatedClass, '\\') + 1)), $enhancer->generateClass()); + } + + public function getGenerationTests() + { + return array( + array('CG\Tests\Proxy\Fixture\SimpleClass', 'CG\Tests\Proxy\Fixture\SimpleClass__CG__Enhanced', array('CG\Tests\Proxy\Fixture\MarkerInterface'), array()), + array('CG\Tests\Proxy\Fixture\SimpleClass', 'CG\Tests\Proxy\Fixture\SimpleClass__CG__Sluggable', array('CG\Tests\Proxy\Fixture\SluggableInterface'), array()), + array('CG\Tests\Proxy\Fixture\Entity', 'CG\Tests\Proxy\Fixture\Entity__CG__LazyInitializing', array(), array( + new LazyInitializerGenerator(), + )) + ); + } + + public function testInterceptionGenerator() + { + $enhancer = new Enhancer(new \ReflectionClass('CG\Tests\Proxy\Fixture\Entity'), array(), array( + $generator = new InterceptionGenerator() + )); + $enhancer->setNamingStrategy($this->getNamingStrategy('CG\Tests\Proxy\Fixture\Entity__CG__Traceable_'.sha1(microtime(true)))); + $generator->setPrefix(''); + + $traceable = $enhancer->createInstance(); + $traceable->setLoader($this->getLoader(array( + $interceptor1 = new TraceInterceptor(), + $interceptor2 = new TraceInterceptor(), + ))); + + $this->assertEquals('foo', $traceable->getName()); + $this->assertEquals('foo', $traceable->getName()); + $this->assertEquals(2, count($interceptor1->getLog())); + $this->assertEquals(2, count($interceptor2->getLog())); + } + + public function testLazyInitializerGenerator() + { + $enhancer = new Enhancer(new \ReflectionClass('CG\Tests\Proxy\Fixture\Entity'), array(), array( + $generator = new LazyInitializerGenerator(), + )); + $generator->setPrefix(''); + + $entity = $enhancer->createInstance(); + $entity->setLazyInitializer($initializer = new Initializer()); + $this->assertEquals('foo', $entity->getName()); + $this->assertSame($entity, $initializer->getLastObject()); + } + + private function getLoader(array $interceptors) + { + $loader = $this->getMock('CG\Proxy\InterceptorLoaderInterface'); + $loader + ->expects($this->any()) + ->method('loadInterceptors') + ->will($this->returnValue($interceptors)) + ; + + return $loader; + } + + private function getContent($file) + { + return file_get_contents(__DIR__.'/Fixture/generated/'.$file.'.php.gen'); + } + + private function getNamingStrategy($name) + { + $namingStrategy = $this->getMock('CG\Core\NamingStrategyInterface'); + $namingStrategy + ->expects($this->any()) + ->method('getClassName') + ->will($this->returnValue($name)) + ; + + return $namingStrategy; + } +} + +class Initializer implements LazyInitializerInterface +{ + private $lastObject; + + public function initializeObject($object) + { + $this->lastObject = $object; + } + + public function getLastObject() + { + return $this->lastObject; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/Entity.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/Entity.php new file mode 100644 index 0000000..c7564a2 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/Entity.php @@ -0,0 +1,23 @@ +log; + } + + public function intercept(MethodInvocation $method) + { + $message = sprintf('%s::%s(', $method->reflection->class, $method->reflection->name); + + $logArgs = array(); + foreach ($method->arguments as $arg) { + $logArgs[] = var_export($arg, true); + } + $this->log[] = $message.implode(', ', $logArgs).')'; + + return $method->proceed(); + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/Entity__CG__LazyInitializing.php.gen b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/Entity__CG__LazyInitializing.php.gen new file mode 100644 index 0000000..e7e4965 --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/Entity__CG__LazyInitializing.php.gen @@ -0,0 +1,37 @@ +namespace CG\Tests\Proxy\Fixture; + +/** + * CG library enhanced proxy class. + * + * This code was generated automatically by the CG library, manual changes to it + * will be lost upon next generation. + */ +class Entity__CG__LazyInitializing extends \CG\Tests\Proxy\Fixture\Entity +{ + private $__CG__lazyInitializer; + private $__CG__initialized = false; + + public function getName() + { + if (false === $this->__CG__initialized) { + $this->__CG__initialize(); + } + + return \CG\Tests\Proxy\Fixture\Entity::getName(); + } + + public function __CG__setLazyInitializer(\CG\Proxy\LazyInitializerInterface $initializer) + { + $this->__CG__lazyInitializer = $initializer; + } + + private function __CG__initialize() + { + if (null === $this->__CG__lazyInitializer) { + throw new \RuntimeException("__CG__setLazyInitializer() must be called prior to any other public method on this object."); + } + + $this->__CG__lazyInitializer->initializeObject($this); + $this->__CG__initialized = true; + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Enhanced.php.gen b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Enhanced.php.gen new file mode 100644 index 0000000..3b367fc --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Enhanced.php.gen @@ -0,0 +1,11 @@ +namespace CG\Tests\Proxy\Fixture; + +/** + * CG library enhanced proxy class. + * + * This code was generated automatically by the CG library, manual changes to it + * will be lost upon next generation. + */ +class SimpleClass__CG__Enhanced extends \CG\Tests\Proxy\Fixture\SimpleClass implements \CG\Tests\Proxy\Fixture\MarkerInterface +{ +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Sluggable.php.gen b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Sluggable.php.gen new file mode 100644 index 0000000..1b6be0c --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/CG/Tests/Proxy/Fixture/generated/SimpleClass__CG__Sluggable.php.gen @@ -0,0 +1,14 @@ +namespace CG\Tests\Proxy\Fixture; + +/** + * CG library enhanced proxy class. + * + * This code was generated automatically by the CG library, manual changes to it + * will be lost upon next generation. + */ +class SimpleClass__CG__Sluggable extends \CG\Tests\Proxy\Fixture\SimpleClass implements \CG\Tests\Proxy\Fixture\SluggableInterface +{ + public function getSlug() + { + } +} \ No newline at end of file diff --git a/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/bootstrap.php b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/bootstrap.php new file mode 100644 index 0000000..76bcd6c --- /dev/null +++ b/vendor/jms/cg/schmittjoh-cg-library-ce8ef43/tests/bootstrap.php @@ -0,0 +1,35 @@ + + * + */ + +spl_autoload_register(function($class) +{ + if (0 === strpos($class, 'CG\Tests\\')) { + $path = __DIR__.'/../tests/'.strtr($class, '\\', '/').'.php'; + if (file_exists($path) && is_readable($path)) { + require_once $path; + + return true; + } + } else if (0 === strpos($class, 'CG\\')) { + $path = __DIR__.'/../src/'.($class = strtr($class, '\\', '/')).'.php'; + if (file_exists($path) && is_readable($path)) { + require_once $path; + + return true; + } + } else if (0 === strpos($class, 'Zend\\')) { + $path = __DIR__.'/../../zend-framework2/library/'.($class = strtr($class, '\\', '/')).'.php'; + if (file_exists($path) && is_readable($path)) { + require_once $path; + + return true; + } + } +}); + diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/AfterSetup.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/AfterSetup.php new file mode 100644 index 0000000..1fb2e2c --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/AfterSetup.php @@ -0,0 +1,13 @@ + + */ +final class AfterSetup +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/DoctrineListener.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/DoctrineListener.php new file mode 100644 index 0000000..3a834f0 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/DoctrineListener.php @@ -0,0 +1,74 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +use JMS\DiExtraBundle\Exception\InvalidTypeException; + +/** + * @Annotation + * @Target("CLASS") + */ +class DoctrineListener +{ + /** @var array @Required */ + public $events; + + /** @var string */ + public $connection; + + /** @var boolean */ + public $lazy = true; + + /** @var integer */ + public $priority = 0; + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (!isset($values['value'])) { + throw new InvalidTypeException('DoctrineListener', 'value', 'array or string', null); + } + $this->events = (array) $values['value']; + + if (isset($values['connection'])) { + if (!is_string($values['connection'])) { + throw new InvalidTypeException('DoctrineListener', 'connection', 'string', $values['connection']); + } + $this->connection = $values['connection']; + } + + if (isset($values['lazy'])) { + if (!is_boolean($values['lazy'])) { + throw new InvalidTypeException('DoctrineListener', 'lazy', 'boolean', $values['lazy']); + } + $this->lazy = $values['lazy']; + } + + if (isset($values['priority'])) { + if (!is_integer($values['priority'])) { + throw new InvalidTypeException('DoctrineListener', 'priority', 'integer', $values['priority']); + } + $this->priority = $values['priority']; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/FormType.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/FormType.php new file mode 100644 index 0000000..073b971 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/FormType.php @@ -0,0 +1,37 @@ + + */ +final class FormType +{ + /** @var string */ + public $alias; + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (isset($values['value'])) { + $values['alias'] = $values['value']; + } + + if (isset($values['alias'])) { + if (!is_string($values['alias'])) { + throw new InvalidTypeException('FormType', 'alias', 'string', $values['alias']); + } + + $this->alias = $values['alias']; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Inject.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Inject.php new file mode 100644 index 0000000..f723003 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Inject.php @@ -0,0 +1,27 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +/** + * @Annotation + * @Target({"PROPERTY", "ANNOTATION"}) + */ +final class Inject extends Reference +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/InjectParams.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/InjectParams.php new file mode 100644 index 0000000..44a4d82 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/InjectParams.php @@ -0,0 +1,57 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +use JMS\DiExtraBundle\Exception\InvalidTypeException; + +/** + * @Annotation + * @Target("METHOD") + */ +final class InjectParams +{ + /** @var array */ + public $params = array(); + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (isset($values['params'])) { + $values['value'] = $values['params']; + } + + if (isset($values['value'])) { + if (!is_array($values['value'])) { + throw new InvalidTypeException('InjectParams', 'value', 'array', $values['value']); + } + + foreach ($values['value'] as $k => $v) { + if (!$v instanceof Inject) { + throw new InvalidTypeException('InjectParams', sprintf('value[%s]', $k), '@Inject', $v); + } + + $this->params[$k] = $v; + } + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/LookupMethod.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/LookupMethod.php new file mode 100644 index 0000000..30fef73 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/LookupMethod.php @@ -0,0 +1,27 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +/** + * @Annotation + * @Target("METHOD") + */ +final class LookupMethod extends Reference +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Observe.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Observe.php new file mode 100644 index 0000000..000f827 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Observe.php @@ -0,0 +1,62 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +use JMS\DiExtraBundle\Exception\InvalidTypeException; + +/** + * @Annotation + * @Target("METHOD") + */ +final class Observe +{ + /** @var string @Required */ + public $event; + + /** @var integer */ + public $priority = 0; + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (isset($values['event'])) { + $values['value'] = $values['event']; + } + + if (isset($values['value'])) { + if (!is_string($values['value'])) { + throw new InvalidTypeException('Observe', 'value', 'string', $values['value']); + } + + $this->event = $values['value']; + } + + if (isset($values['priority'])) { + if (!is_numeric($values['priority'])) { + throw new InvalidTypeException('Observe', 'priority', 'integer', $values['priority']); + } + + $this->priority = $values['priority']; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Reference.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Reference.php new file mode 100644 index 0000000..853f514 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Reference.php @@ -0,0 +1,54 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +use JMS\DiExtraBundle\Exception\InvalidTypeException; + +abstract class Reference +{ + /** @var string */ + public $value; + + /** @var boolean */ + public $required; + + public final function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (isset($values['value'])) { + if (!is_string($values['value'])) { + throw new InvalidTypeException('Inject', 'value', 'string', $values['value']); + } + + $this->value = $values['value']; + } + + if (isset($values['required'])) { + if (!is_bool($values['required'])) { + throw new InvalidTypeException('Inject', 'required', 'boolean', $values['required']); + } + + $this->required = $values['required']; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Service.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Service.php new file mode 100644 index 0000000..caa0557 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Service.php @@ -0,0 +1,87 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +use JMS\DiExtraBundle\Exception\InvalidTypeException; + +/** + * @Annotation + * @Target("CLASS") + */ +final class Service +{ + /** @var string */ + public $id; + + /** @var string */ + public $parent; + + /** @var boolean */ + public $public; + + /** @var string */ + public $scope; + + /** @var boolean */ + public $abstract; + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (isset($values['value'])) { + if (!is_string($values['value'])) { + throw new InvalidTypeException('Service', 'value', 'string', $values['value']); + } + + $this->id = $values['value']; + } + if (isset($values['parent'])) { + if (!is_string($values['parent'])) { + throw new InvalidTypeException('Service', 'parent', 'string', $values['parent']); + } + + $this->parent = $values['parent']; + } + if (isset($values['public'])) { + if (!is_bool($values['public'])) { + throw new InvalidTypeException('Service', 'public', 'boolean', $values['public']); + } + + $this->public = $values['public']; + } + if (isset($values['scope'])) { + if (!is_string($values['scope'])) { + throw new InvalidTypeException('Service', 'scope', 'string', $values['scope']); + } + + $this->scope = $values['scope']; + } + if (isset($values['abstract'])) { + if (!is_bool($values['abstract'])) { + throw new InvalidTypeException('Service', 'abstract', 'boolean', $values['abstract']); + } + + $this->abstract = $values['abstract']; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Tag.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Tag.php new file mode 100644 index 0000000..55942be --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Tag.php @@ -0,0 +1,60 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +use JMS\DiExtraBundle\Exception\InvalidArgumentException; +use JMS\DiExtraBundle\Exception\InvalidTypeException; + +/** + * @Annotation + * @Target("CLASS") + */ +final class Tag +{ + /** @var string @Required */ + public $name; + + /** @var array */ + public $attributes = array(); + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (!isset($values['value'])) { + throw new InvalidArgumentException('A value must be given for annotation "@Tag".'); + } + if (!is_string($values['value'])) { + throw new InvalidTypeException('Tag', 'value', 'string', $values['value']); + } + + $this->name = $values['value']; + + if (isset($values['attributes'])) { + if (!is_array($values['attributes'])) { + throw new InvalidTypeException('Tag', 'attributes', 'array', $values['attributes']); + } + + $this->attributes = $values['attributes']; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Validator.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Validator.php new file mode 100644 index 0000000..cc8e38a --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Annotation/Validator.php @@ -0,0 +1,51 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Annotation; + +use JMS\DiExtraBundle\Exception\InvalidTypeException; + +/** + * @Annotation + * @Target("CLASS") + */ +final class Validator +{ + /** @var string @Required */ + public $alias; + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (isset($values['alias'])) { + $values['value'] = $values['alias']; + } + + if (!isset($values['value'])) { + throw new \InvalidArgumentException('A value must be given for @Validator annotations.'); + } + if (!is_string($values['value'])) { + throw new InvalidTypeException('Validator', 'value', 'string', $values['value']); + } + $this->alias = $values['value']; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/FastDirectoriesResource.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/FastDirectoriesResource.php new file mode 100644 index 0000000..719ac41 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/FastDirectoriesResource.php @@ -0,0 +1,78 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Config; + +use JMS\DiExtraBundle\Finder\PatternFinder; + +use Symfony\Component\Config\Resource\ResourceInterface; + +class FastDirectoriesResource implements ResourceInterface +{ + private $finder; + + private $directories; + private $filePattern; + private $files = array(); + + public function __construct(array $directories, $filePattern = null) + { + $this->finder = new PatternFinder('.*', '*.php'); + $this->finder->setRegexPattern(true); + + $this->directories = $directories; + $this->filePattern = $filePattern ?: '*'; + } + + public function __toString() + { + return implode(', ', $this->directories); + } + + public function getResource() + { + return $this->directories; + } + + public function update() + { + $this->files = $this->getFiles(); + } + + public function isFresh($timestamp) + { + $files = $this->getFiles(); + + if (array_diff($this->files, $files) || array_diff($files, $this->files)) { + return false; + } + + foreach ($files as $file) { + if (filemtime($file) > $timestamp) { + return false; + } + } + + return true; + } + + private function getFiles() + { + return $this->finder->findFiles($this->directories); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/ServiceFilesResource.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/ServiceFilesResource.php new file mode 100644 index 0000000..40508b2 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Config/ServiceFilesResource.php @@ -0,0 +1,52 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Config; + +use JMS\DiExtraBundle\Finder\PatternFinder; +use Symfony\Component\Config\Resource\ResourceInterface; + +class ServiceFilesResource implements ResourceInterface +{ + private $files; + private $dirs; + + public function __construct(array $files, array $dirs) + { + $this->files = $files; + $this->dirs = $dirs; + } + + public function isFresh($timestamp) + { + $finder = new PatternFinder('JMS\DiExtraBundle\Annotation'); + $files = $finder->findFiles($this->dirs); + + return !array_diff($files, $this->files) && !array_diff($this->files, $files); + } + + public function __toString() + { + return implode(', ', $this->files); + } + + public function getResource() + { + return array($this->files, $this->dirs); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/AnnotationConfigurationPass.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/AnnotationConfigurationPass.php new file mode 100644 index 0000000..cb8d77b --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/AnnotationConfigurationPass.php @@ -0,0 +1,120 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Alias; +use JMS\DiExtraBundle\Exception\RuntimeException; +use JMS\DiExtraBundle\Config\ServiceFilesResource; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\DefinitionDecorator; +use Symfony\Component\DependencyInjection\Definition; +use JMS\DiExtraBundle\Finder\PatternFinder; +use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +class AnnotationConfigurationPass implements CompilerPassInterface +{ + private $kernel; + private $finder; + + public function __construct(KernelInterface $kernel) + { + $this->kernel = $kernel; + $this->finder = new PatternFinder('JMS\DiExtraBundle\Annotation'); + } + + public function process(ContainerBuilder $container) + { + $reader = $container->get('annotation_reader'); + $factory = $container->get('jms_di_extra.metadata.metadata_factory'); + $converter = $container->get('jms_di_extra.metadata.converter'); + + $directories = $this->getScanDirectories($container); + if (!$directories) { + $container->getCompiler()->addLogMessage('No directories configured for AnnotationConfigurationPass.'); + return; + } + + $files = $this->finder->findFiles($directories); + $container->addResource(new ServiceFilesResource($files, $directories)); + foreach ($files as $file) { + $container->addResource(new FileResource($file)); + require_once $file; + + $className = $this->getClassName($file); + + if (null === $metadata = $factory->getMetadataForClass($className)) { + continue; + } + if (null === $metadata->getOutsideClassMetadata()->id) { + continue; + } + + foreach ($converter->convert($metadata) as $id => $definition) { + $container->setDefinition($id, $definition); + } + } + } + + private function getScanDirectories(ContainerBuilder $c) + { + $bundles = $this->kernel->getBundles(); + $scanBundles = $c->getParameter('jms_di_extra.bundles'); + $scanAllBundles = $c->getParameter('jms_di_extra.all_bundles'); + + $directories = $c->getParameter('jms_di_extra.directories'); + foreach ($bundles as $name => $bundle) { + if (!$scanAllBundles && !in_array($name, $scanBundles, true)) { + continue; + } + + if ('JMSDiExtraBundle' === $name) { + continue; + } + + $directories[] = $bundle->getPath(); + } + + return $directories; + } + + /** + * Only supports one namespaced class per file + * + * @throws \RuntimeException if the class name cannot be extracted + * @param string $filename + * @return string the fully qualified class name + */ + private function getClassName($filename) + { + $src = file_get_contents($filename); + + if (!preg_match('/\bnamespace\s+([^;]+);/s', $src, $match)) { + throw new RuntimeException(sprintf('Namespace could not be determined for file "%s".', $filename)); + } + $namespace = $match[1]; + + if (!preg_match('/\bclass\s+([^\s]+)\s+(?:extends|implements|{)/s', $src, $match)) { + throw new RuntimeException(sprintf('Could not extract class name from file "%s".', $filename)); + } + + return $namespace.'\\'.$match[1]; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/IntegrationPass.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/IntegrationPass.php new file mode 100644 index 0000000..db3e488 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/IntegrationPass.php @@ -0,0 +1,55 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Integrates the bundle with external code. + * + * @author Johannes M. Schmitt + */ +class IntegrationPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + // replace Symfony2's default controller resolver + $container->setAlias('controller_resolver', new Alias('jms_di_extra.controller_resolver', false)); + + // replace SensioFrameworkExtraBundle's default template listener + if ($container->hasDefinition('sensio_framework_extra.view.listener')) { + $def = $container->getDefinition('sensio_framework_extra.view.listener'); + + // only overwrite if it has the default class otherwise the user has to do the integration manually + if ('%sensio_framework_extra.view.listener.class%' === $def->getClass()) { + $def->setClass('%jms_di_extra.template_listener.class%'); + } + } + + if ($container->hasDefinition('sensio_framework_extra.controller.listener')) { + $def = $container->getDefinition('sensio_framework_extra.controller.listener'); + + if ('%sensio_framework_extra.controller.listener.class%' === $def->getClass()) { + $def->setClass('%jms_di_extra.controller_listener.class%'); + } + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/ResourceOptimizationPass.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/ResourceOptimizationPass.php new file mode 100644 index 0000000..ee73a0e --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Compiler/ResourceOptimizationPass.php @@ -0,0 +1,81 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\DependencyInjection\Compiler; + +use JMS\DiExtraBundle\Config\FastDirectoriesResource; + +use Symfony\Component\Config\Resource\DirectoryResource; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +class ResourceOptimizationPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + $resources = $directories = array(); + + $ref = new \ReflectionProperty('Symfony\Component\Config\Resource\DirectoryResource', 'pattern'); + $ref->setAccessible(true); + + foreach ($container->getResources() as $resource) { + if ($resource instanceof DirectoryResource) { + if (null === $pattern = $ref->getValue($resource)) { + $pattern = '*'; + } + + $directories[$pattern][] = $resource->getResource(); + + continue; + } + + $resources[] = $resource; + } + + $sortFunc = function($a, $b) { + return strlen($a) - strlen($b); + }; + + foreach ($directories as $pattern => $pDirectories) { + $newResources = array(); + + usort($pDirectories, $sortFunc); + foreach ($pDirectories as $a) { + foreach ($newResources as $b) { + if (0 === strpos($a, $b)) { + continue 2; + } + } + + $newResources[] = $a; + } + + $directories[$pattern] = $newResources; + } + + foreach ($directories as $pattern => $pDirectories) { + $newResource = new FastDirectoriesResource($pDirectories, $pattern); + $newResource->update(); + $resources[] = $newResource; + } + + $ref = new \ReflectionProperty('Symfony\Component\DependencyInjection\ContainerBuilder', 'resources'); + $ref->setAccessible(true); + $ref->setValue($container, $resources); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Configuration.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Configuration.php new file mode 100644 index 0000000..52129b8 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/Configuration.php @@ -0,0 +1,69 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class Configuration implements ConfigurationInterface +{ + public function getConfigTreeBuilder() + { + $tb = new TreeBuilder(); + + $tb + ->root('jms_di_extra', 'array') + ->children() + ->arrayNode('locations') + ->addDefaultsIfNotSet() + ->children() + ->booleanNode('all_bundles')->defaultFalse()->end() + ->arrayNode('bundles') + ->beforeNormalization() + ->ifString() + ->then(function($v) { + return preg_split('/\s*,\s*/', $v); + }) + ->end() + ->prototype('scalar')->end() + ->end() + ->arrayNode('directories') + ->beforeNormalization() + ->ifString() + ->then(function($v) { + return preg_split('/\s*,\s*/', $v); + }) + ->end() + ->prototype('scalar')->end() + ->end() + ->end() + ->end() + ->scalarNode('cache_dir')->defaultValue('%kernel.cache_dir%/diextra')->end() + ->arrayNode('metadata') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('cache')->defaultValue('file')->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end(); + + return $tb; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/JMSDiExtraExtension.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/JMSDiExtraExtension.php new file mode 100644 index 0000000..9c0266c --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/JMSDiExtraExtension.php @@ -0,0 +1,84 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\DependencyInjection; + +use JMS\DiExtraBundle\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; + +class JMSDiExtraExtension extends Extension +{ + public function load(array $configs, ContainerBuilder $container) + { + $config = $this->mergeConfigs($configs); + + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + + $container->setParameter('jms_di_extra.all_bundles', $config['locations']['all_bundles']); + $container->setParameter('jms_di_extra.bundles', $config['locations']['bundles']); + $container->setParameter('jms_di_extra.directories', $config['locations']['directories']); + $container->setParameter('jms_di_extra.cache_dir', $config['cache_dir']); + + $this->configureMetadata($config['metadata'], $container, $config['cache_dir'].'/metadata'); + + $this->addClassesToCompile(array( + 'JMS\\DiExtraBundle\\HttpKernel\ControllerResolver', + )); + } + + private function configureMetadata(array $config, $container, $cacheDir) + { + if ('none' === $config['cache']) { + $container->removeAlias('jms_di_extra.metadata.cache'); + return; + } + + if ('file' === $config['cache']) { + $cacheDir = $container->getParameterBag()->resolveValue($cacheDir); + if (!file_exists($cacheDir)) { + if (false === @mkdir($cacheDir, 0777, true)) { + throw new RuntimeException(sprintf('The cache dir "%s" could not be created.', $cacheDir)); + } + } + if (!is_writable($cacheDir)) { + throw new RuntimeException(sprintf('The cache dir "%s" is not writable.', $cacheDir)); + } + + $container + ->getDefinition('jms_di_extra.metadata.cache.file_cache') + ->replaceArgument(0, $cacheDir) + ; + } else { + $container->setAlias('jms_di_extra.metadata.cache', new Alias($config['cache'], false)); + } + } + + private function mergeConfigs(array $configs) + { + $processor = new Processor(); + $configuration = new Configuration(); + + return $processor->process($configuration->getConfigTreeBuilder()->buildTree(), $configs); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/LookupMethodClassInterface.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/LookupMethodClassInterface.php new file mode 100644 index 0000000..40a506f --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/DependencyInjection/LookupMethodClassInterface.php @@ -0,0 +1,24 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\DependencyInjection; + +interface LookupMethodClassInterface +{ + function __jmsDiExtra_getOriginalClassName(); +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/ControllerListener.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/ControllerListener.php new file mode 100644 index 0000000..cab730f --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/ControllerListener.php @@ -0,0 +1,58 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\EventListener; + +use Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener as BaseControllerListener; +use CG\Core\ClassUtils; +use Doctrine\Common\Annotations\Reader; +use Symfony\Component\HttpKernel\Event\FilterControllerEvent; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface; + +/** + * The ControllerListener class parses annotation blocks located in + * controller classes. + * + * @author Fabien Potencier + */ +class ControllerListener extends BaseControllerListener +{ + /** + * Modifies the Request object to apply configuration information found in + * controllers annotations like the template to render or HTTP caching + * configuration. + * + * @param FilterControllerEvent $event A FilterControllerEvent instance + */ + public function onKernelController(FilterControllerEvent $event) + { + if (!is_array($controller = $event->getController())) { + return; + } + + $object = new \ReflectionClass(ClassUtils::getUserClass(get_class($controller[0]))); + $method = $object->getMethod($controller[1]); + + $request = $event->getRequest(); + foreach ($this->reader->getMethodAnnotations($method) as $configuration) { + if ($configuration instanceof ConfigurationInterface) { + $request->attributes->set('_'.$configuration->getAliasName(), $configuration); + } + } + } +} diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/TemplateListener.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/TemplateListener.php new file mode 100644 index 0000000..feacc35 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/EventListener/TemplateListener.php @@ -0,0 +1,50 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\EventListener; + +use CG\Core\ClassUtils; +use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; +use Symfony\Component\HttpFoundation\Request; +use JMS\DiExtraBundle\DependencyInjection\LookupMethodClassInterface; +use Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener as FrameworkExtraTemplateListener; + +class TemplateListener extends FrameworkExtraTemplateListener +{ + protected function guessTemplateName($controller, Request $request, $engine = 'twig') + { + $controllerClass = get_class($controller[0]); + $userClass = ClassUtils::getUserClass($controllerClass); + + if ($controllerClass === $userClass) { + return parent::guessTemplateName($controller, $request, $engine); + } + + if (!preg_match('/Controller\\\(.+)Controller$/', $userClass, $matchController)) { + throw new \InvalidArgumentException(sprintf('The "%s" class does not look like a controller class (it must be in a "Controller" sub-namespace and the class name must end with "Controller")', $userClass)); + } + + if (!preg_match('/^(.+)Action$/', $controller[1], $matchAction)) { + throw new \InvalidArgumentException(sprintf('The "%s" method does not look like an action method (it does not end with Action)', $controller[1])); + } + + $bundle = $this->getBundleForClass($userClass); + + return new TemplateReference($bundle->getName(), $matchController[1], $matchAction[1], $request->getRequestFormat(), $engine); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/Exception.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/Exception.php new file mode 100644 index 0000000..293e70b --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/Exception.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Exception; + +/** + * Base exception for the DiExtraBundle. + * + * @author Johannes M. Schmitt + */ +interface Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidArgumentException.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..990c60f --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidArgumentException.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Exception; + +/** + * InvalidArgumentException for the DiExtraBundle. + * + * @author Johannes M. Schmitt + */ +class InvalidArgumentException extends \InvalidArgumentException implements Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidTypeException.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidTypeException.php new file mode 100644 index 0000000..7437778 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/InvalidTypeException.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Exception; + +class InvalidTypeException extends InvalidArgumentException +{ + public function __construct($annotName, $attrName, $expected, $actual) + { + $msg = sprintf('The attribute "%s" on annotation "@%s" is expected to be of type %s, but got %s.', $attrName, $annotName, $expected, gettype($actual)); + + parent::__construct($msg); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/RuntimeException.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/RuntimeException.php new file mode 100644 index 0000000..a47a6e4 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Exception/RuntimeException.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Exception; + +/** + * RuntimeException for the DiExtraBundle. + * + * @author Johannes M. Schmitt + */ +class RuntimeException extends \RuntimeException implements Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Finder/PatternFinder.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Finder/PatternFinder.php new file mode 100644 index 0000000..f4bea5f --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Finder/PatternFinder.php @@ -0,0 +1,201 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Finder; + +use JMS\DiExtraBundle\Exception\RuntimeException; +use Symfony\Component\Finder\Finder; +use Symfony\Component\Process\ExecutableFinder; + +class PatternFinder +{ + const METHOD_GREP = 1; + const METHOD_FINDSTR = 2; + const METHOD_FINDER = 3; + + private static $method; + private static $grepPath; + + private $pattern; + private $filePattern; + private $recursive = true; + private $regexPattern = false; + + public function __construct($pattern, $filePattern = '*.php') + { + if (null === self::$method) { + self::determineMethod(); + } + + $this->pattern = $pattern; + $this->filePattern = $filePattern; + } + + public function setRecursive($bool) + { + $this->recursive = (Boolean) $bool; + } + + public function setRegexPattern($bool) + { + $this->regexPattern = (Boolean) $bool; + } + + public function findFiles(array $dirs) + { + // check for grep availability + if (self::METHOD_GREP === self::$method) { + return $this->findUsingGrep($dirs); + } + + // use FINDSTR on Windows + if (self::METHOD_FINDSTR === self::$method) { + return $this->findUsingFindstr($dirs); + } + + // this should really be avoided at all costs since it is damn slow + return $this->findUsingFinder($dirs); + } + + private function findUsingFindstr(array $dirs) + { + $cmd = 'FINDSTR /M /S /P'; + + if (!$this->recursive) { + $cmd .= ' /L'; + } + + $cmd .= ' /D:'.escapeshellarg(implode(';', $dirs)); + $cmd .= ' '.escapeshellarg($this->pattern); + $cmd .= ' '.$this->filePattern; + + exec($cmd, $lines, $exitCode); + + if (1 === $exitCode) { + return array(); + } + + if (0 !== $exitCode) { + throw new RuntimeException(sprintf('Command "%s" exited with non-successful status code. "%d".', $cmd, $exitCode)); + } + + // Looks like FINDSTR has different versions with different output formats. + // + // Supported format #1: + // C:\matched\dir1: + // Relative\Path\To\File1.php + // Relative\Path\To\File2.php + // C:\matched\dir2: + // Relative\Path\To\File3.php + // Relative\Path\To\File4.php + // + // Supported format #2: + // C:\matched\dir1\Relative\Path\To\File1.php + // C:\matched\dir1\Relative\Path\To\File2.php + // C:\matched\dir2\Relative\Path\To\File3.php + // C:\matched\dir2\Relative\Path\To\File4.php + + $files = array(); + $currentDir = ''; + foreach ($lines as $line) { + if (':' === substr($line, -1)) { + $currentDir = trim($line, ' :/').'/'; + continue; + } + + $files[] = $currentDir.$line; + } + + return $files; + } + + private function findUsingGrep(array $dirs) + { + $cmd = self::$grepPath; + + if (!$this->regexPattern) { + $cmd .= ' --fixed-strings'; + } else { + $cmd .= ' --extended-regexp'; + } + + if ($this->recursive) { + $cmd .= ' --directories=recurse'; + } else { + $cmd .= ' --directories=skip'; + } + + $cmd .= ' --devices=skip --files-with-matches --with-filename --max-count=1 --color=never --include='.$this->filePattern; + $cmd .= ' '.escapeshellarg($this->pattern); + + foreach ($dirs as $dir) { + $cmd .= ' '.escapeshellarg($dir); + } + exec($cmd, $files, $exitCode); + + if (1 === $exitCode) { + return array(); + } + + if (0 !== $exitCode) { + throw new RuntimeException(sprintf('Command "%s" exited with non-successful status code "%d".', $cmd, $exitCode)); + } + + return $files; + } + + private function findUsingFinder(array $dirs) + { + $finder = new Finder(); + $pattern = $this->pattern; + $regex = $this->regexPattern; + $finder + ->files() + ->name($this->filePattern) + ->in($dirs) + ->ignoreVCS(true) + ->filter(function($file) use ($pattern, $regex) { + if (!$regex) { + return false !== strpos(file_get_contents($file->getPathName()), $pattern); + } + + return 0 < preg_match('#'.$pattern.'#', file_get_contents($file->getPathName())); + }) + ; + + if (!$this->recursive) { + $finder->depth('<= 0'); + } + + return array_keys(iterator_to_array($finder)); + } + + private static function determineMethod() + { + $finder = new ExecutableFinder(); + $isWindows = 0 === stripos(PHP_OS, 'win'); + + if (!$isWindows && self::$grepPath = $finder->find('grep')) { + self::$method = self::METHOD_GREP; + } else if ($isWindows) { + self::$method = self::METHOD_FINDSTR; + } else { + self::$method = self::METHOD_FINDER; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/DefinitionInjectorGenerator.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/DefinitionInjectorGenerator.php new file mode 100644 index 0000000..3bfea60 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/DefinitionInjectorGenerator.php @@ -0,0 +1,192 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Generator; + +use CG\Generator\Writer; +use Symfony\Component\DependencyInjection\Parameter; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\Definition; + +/** + * Generates lightweight code for injecting a single definition. + * + * @author Johannes M. Schmitt + */ +class DefinitionInjectorGenerator +{ + private $nameGenerator; + private $inlinedDefinitions; + + public function __construct() + { + $this->nameGenerator = new NameGenerator(); + $this->inlinedDefinitions = new \SplObjectStorage(); + } + + public function generate(Definition $def) + { + $writer = new Writer(); + + $writer + ->writeln('writeln('/**') + ->writeln(' * This code has been auto-generated by the JMSDiExtraBundle.') + ->writeln(' *') + ->writeln(' * Manual changes to it will be lost.') + ->writeln(' */') + ->writeln('return function($container) {') + ->indent() + ; + + if ($file = $def->getFile()) { + $writer->writeln('require_once '.var_export($file, true).';'); + + require_once $file; + } + + foreach ($this->getInlineDefinitions($def) as $inlineDef) { + $name = $this->nameGenerator->nextName(); + $this->inlinedDefinitions[$inlineDef] = $name; + + $writer->writeln('$'.$name.' = new \\'.$inlineDef->getClass().$this->dumpArguments($inlineDef->getArguments()).';'); + } + + $writer->writeln('$instance = new \\'.$def->getClass().$this->dumpArguments($def->getArguments()).';'); + + foreach ($def->getMethodCalls() as $call) { + list($method, $arguments) = $call; + $writer->writeln('$instance->'.$method.$this->dumpArguments($arguments).';'); + } + + $ref = new \ReflectionClass($def->getClass()); + foreach ($def->getProperties() as $property => $value) { + $refProperty = $this->getReflectionProperty($ref, $property); + + if ($refProperty->isPublic()) { + $writer->writeln('$instance->'.$property.' = '.$this->dumpValue($value).';'); + } else { + $writer + ->writeln(sprintf("\$refProperty = new \ReflectionProperty(%s, %s);", var_export($refProperty->getDeclaringClass()->getName(), true), var_export($property, true))) + ->writeln('$refProperty->setAccessible(true);') + ->writeln('$refProperty->setValue($instance, '.$this->dumpValue($value).');') + ; + } + } + + if (method_exists($def, 'getInitMethod') && $def->getInitMethod()) { + $writer->writeln('$instance->'.$def->getInitMethod().'();'); + } + + $writer + ->writeln('return $instance;') + ->outdent() + ->writeln('};') + ; + + return $writer->getContent(); + } + + private function getReflectionProperty($ref, $property) + { + $origClass = $ref->getName(); + while (!$ref->hasProperty($property) && false !== $ref = $ref->getParentClass()); + + if (!$ref->hasProperty($property)) { + throw new \RuntimeException(sprintf('Could not find property "%s" anywhere in class "%s" or one of its parents.', $property, $origName)); + } + + return $ref->getProperty($property); + } + + private function getInlineDefinitions(Definition $def) + { + $defs = new \SplObjectStorage(); + $this->getDefinitionsFromArray($def->getArguments(), $defs); + $this->getDefinitionsFromArray($def->getMethodCalls(), $defs); + $this->getDefinitionsFromArray($def->getProperties(), $defs); + + return $defs; + } + + private function getDefinitionsFromArray(array $a, \SplObjectStorage $defs) + { + foreach ($a as $k => $v) { + if ($v instanceof Definition) { + $defs->attach($v); + } else if (is_array($v)) { + $this->getDefinitionsFromArray($v, $defs); + } + } + } + + private function dumpArguments(array $arguments) + { + $code = '('; + + $first = true; + foreach ($arguments as $argument) { + if (!$first) { + $code .= ', '; + } + $first = false; + + $code .= $this->dumpValue($argument); + } + + return $code.')'; + } + + private function dumpValue($value) + { + if (is_array($value)) { + $code = 'array('; + + $first = true; + foreach ($value as $k => $v) { + if (!$first) { + $code .= ', '; + } + $first = false; + + $code .= sprintf('%s => %s', var_export($k, true), $this->dumpValue($v)); + } + + return $code.')'; + } else if ($value instanceof Reference) { + if ('service_container' === (string) $value) { + return '$container'; + } + + return sprintf('$container->get(%s, %d)', var_export((string) $value, true), $value->getInvalidBehavior()); + } else if ($value instanceof Parameter) { + return sprintf('$container->getParameter(%s)', var_export((string) $value, true)); + } else if (is_scalar($value) || null === $value) { + // we do not support embedded parameters + if (is_string($value) && '%' === $value[0] && '%' !== $value[1]) { + return sprintf('$container->getParameter(%s)', var_export(substr($value, 1, -1), true)); + } + + return var_export($value, true); + } else if ($value instanceof Definition) { + return sprintf('$%s', $this->inlinedDefinitions[$value]); + } + + throw new \RuntimeException(sprintf('Found unsupported value of type %s during definition injector generation: "%s"', gettype($value), json_encode($value))); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/LookupMethodClassGenerator.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/LookupMethodClassGenerator.php new file mode 100644 index 0000000..54b02cf --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/LookupMethodClassGenerator.php @@ -0,0 +1,119 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Generator; + +use Metadata\ClassHierarchyMetadata; +use CG\Generator\PhpParameter; +use CG\Generator\PhpMethod; +use CG\Generator\PhpProperty; +use CG\Generator\PhpClass; +use CG\Proxy\GeneratorInterface; +use Symfony\Component\DependencyInjection\Parameter; +use Symfony\Component\DependencyInjection\Reference; + +class LookupMethodClassGenerator implements GeneratorInterface +{ + const PREFIX = '__jmsDiExtra_'; + + private $metadata; + private $requiredFile; + + public function __construct(ClassHierarchyMetadata $metadata) + { + $this->metadata = $metadata; + } + + public function setRequiredFile($file) + { + $this->requiredFile = $file; + } + + public function generate(\ReflectionClass $class, PhpClass $genClass) + { + if (!empty($this->requiredFile)) { + $genClass->addRequiredFile($this->requiredFile); + } + + $genClass->setProperty(PhpProperty::create() + ->setName(self::PREFIX.'container') + ->setVisibility('private') + ); + + $genClass->setMethod(PhpMethod::create() + ->setName(self::PREFIX.'setContainer') + ->addParameter(PhpParameter::create() + ->setName('container') + ->setType('Symfony\Component\DependencyInjection\ContainerInterface') + ) + ->setBody('$this->'.self::PREFIX.'container = $container;') + ); + + $genClass->addInterfaceName('JMS\DiExtraBundle\DependencyInjection\LookupMethodClassInterface'); + $genClass->setMethod(PhpMethod::create() + ->setName(self::PREFIX.'getOriginalClassName') + ->setFinal(true) + ->setBody('return '.var_export($class->name, true).';') + ); + + foreach ($this->getLookupMethods() as $name => $value) { + $genClass->setMethod(PhpMethod::fromReflection($class->getMethod($name)) + ->setAbstract(false) + ->setBody('return '.$this->dumpValue($value).';') + ->setDocblock(null) + ); + } + } + + private function getLookupMethods() + { + $outerClass = $this->metadata->getOutsideClassMetadata()->reflection; + $lookupMethods = array(); + foreach ($this->metadata->classMetadata as $classMetadata) { + if (!$classMetadata->lookupMethods) { + continue; + } + + foreach ($classMetadata->lookupMethods as $name => $value) { + // check if method has been overridden + if ($outerClass->getMethod($name)->class !== $classMetadata->reflection->name) { + continue; + } + + $lookupMethods[$name] = $value; + } + } + + return $lookupMethods; + } + + private function dumpValue($value) + { + if ($value instanceof Parameter) { + return '$this->'.self::PREFIX.'container->getParameter('.var_export((string) $value, true).')'; + } else if ($value instanceof Reference) { + return '$this->'.self::PREFIX.'container->get('.var_export((string) $value, true).', '.var_export($value->getInvalidBehavior(), true).')'; + } else if (is_string($value) && '%' === $value[0]) { + return '$this->'.self::PREFIX.'container->getParameter('.var_export(substr($value, 1, -1), true).')'; + } else if (is_array($value) || is_scalar($value) || null === $value) { + return var_export($value, true); + } + + throw new \RuntimeException(sprintf('Invalid value for lookup method: %s', json_encode($value))); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/NameGenerator.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/NameGenerator.php new file mode 100644 index 0000000..df3c1c8 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Generator/NameGenerator.php @@ -0,0 +1,79 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Generator; + +class NameGenerator +{ + private $count = 0; + private $firstChars = 'abcdefghijklmnopqrstuvwxyz'; + private $firstCharsLength = 26; + private $nonFirstChars = 'abcdefghijklmnopqrstuvwxyz0123456789_'; + private $nonFirstCharsLength = 37; + private $reservedNames = array(); + + public function addReservedName($name) + { + $this->reservedNames[$name] = true; + } + + public function setFirstChars($chars) + { + $this->firstChars = $chars; + $this->firstCharsLength = strlen($chars); + } + + public function setNonFirstChars($chars) + { + $this->nonFirstChars = $chars; + $this->nonFirstCharsLength = strlen($chars); + } + + public function reset() + { + $this->count = 0; + } + + public function nextName() + { + while (true) { + $name = ''; + $i = $this->count; + + if ('' === $name) { + $name .= $this->firstChars[$i%$this->firstCharsLength]; + $i = intval($i/$this->firstCharsLength); + } + + while ($i > 0) { + $i -= 1; + $name .= $this->nonFirstChars[$i%$this->nonFirstCharsLength]; + $i = intval($i/$this->nonFirstCharsLength); + } + + $this->count += 1; + + // check that the name is not reserved + if (isset($this->reservedNames[$name])) { + continue; + } + + return $name; + } + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/HttpKernel/ControllerResolver.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/HttpKernel/ControllerResolver.php new file mode 100644 index 0000000..f1a48ce --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/HttpKernel/ControllerResolver.php @@ -0,0 +1,179 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\HttpKernel; + +use Metadata\ClassHierarchyMetadata; +use JMS\DiExtraBundle\Metadata\ClassMetadata; +use CG\Core\DefaultNamingStrategy; +use CG\Proxy\Enhancer; +use JMS\AopBundle\DependencyInjection\Compiler\PointcutMatchingPass; +use JMS\DiExtraBundle\Generator\DefinitionInjectorGenerator; +use JMS\DiExtraBundle\Generator\LookupMethodClassGenerator; +use JMS\DiExtraBundle\DependencyInjection\Dumper\PhpDumper; +use Metadata\MetadataFactory; +use Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\Compiler\ResolveDefinitionTemplatesPass; +use Symfony\Component\DependencyInjection\Parameter; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\Config\ConfigCache; +use Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver as BaseControllerResolver; + +class ControllerResolver extends BaseControllerResolver +{ + protected function createController($controller) + { + if (false === $pos = strpos($controller, '::')) { + $count = substr_count($controller, ':'); + if (2 == $count) { + // controller in the a:b:c notation then + $controller = $this->parser->parse($controller); + $pos = strpos($controller, '::'); + } elseif (1 == $count) { + // controller in the service:method notation + list($service, $method) = explode(':', $controller); + + return array($this->container->get($service), $method); + } else { + throw new \LogicException(sprintf('Unable to parse the controller name "%s".', $controller)); + } + } + + $class = substr($controller, 0, $pos); + $method = substr($controller, $pos+2); + + if (!class_exists($class)) { + throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); + } + + $filename = $this->container->getParameter('jms_di_extra.cache_dir').'/controller_injectors/'.str_replace('\\', '', $class).'.php'; + $cache = new ConfigCache($filename, $this->container->getParameter('kernel.debug')); + + if (!$cache->isFresh()) { + $metadata = $this->container->get('jms_di_extra.metadata.metadata_factory')->getMetadataForClass($class); + if (null === $metadata) { + $metadata = new ClassHierarchyMetadata(); + $metadata->addClassMetadata(new ClassMetadata($class)); + } + + $this->prepareContainer($cache, $filename, $metadata); + } + + $inject = require $filename; + $controller = $inject($this->container); + + if ($controller instanceof ContainerAwareInterface) { + $controller->setContainer($this->container); + } + + return array($controller, $method); + } + + private function prepareContainer($cache, $containerFilename, $metadata) + { + $container = new ContainerBuilder(); + $container->setParameter('jms_aop.cache_dir', $this->container->getParameter('jms_di_extra.cache_dir')); + $def = $container + ->register('jms_aop.interceptor_loader', 'JMS\AopBundle\Aop\InterceptorLoader') + ->addArgument(new Reference('service_container')) + ->setPublic(false) + ; + + // add resources + $ref = $metadata->getOutsideClassMetadata()->reflection; + while ($ref && false !== $filename = $ref->getFilename()) { + $container->addResource(new FileResource($filename)); + $ref = $ref->getParentClass(); + } + + // add definitions + $definitions = $this->container->get('jms_di_extra.metadata.converter')->convert($metadata); + $serviceIds = $parameters = array(); + + $controllerDef = array_pop($definitions); + $container->setDefinition('controller', $controllerDef); + + foreach ($definitions as $id => $def) { + $container->setDefinition($id, $def); + } + + $this->generateLookupMethods($controllerDef, $metadata); + + $config = $container->getCompilerPassConfig(); + $config->setOptimizationPasses(array()); + $config->setRemovingPasses(array()); + $config->addPass(new ResolveDefinitionTemplatesPass()); + $config->addPass(new PointcutMatchingPass($this->container->get('jms_aop.pointcut_container')->getPointcuts())); + $config->addPass(new InlineServiceDefinitionsPass()); + $container->compile(); + + if (!file_exists($dir = dirname($containerFilename))) { + if (false === @mkdir($dir, 0777, true)) { + throw new \RuntimeException(sprintf('Could not create directory "%s".', $dir)); + } + } + + static $generator; + if (null === $generator) { + $generator = new DefinitionInjectorGenerator(); + } + + $cache->write($generator->generate($container->getDefinition('controller')), $container->getResources()); + } + + private function generateLookupMethods($def, $metadata) + { + $found = false; + foreach ($metadata->classMetadata as $cMetadata) { + if (!empty($cMetadata->lookupMethods)) { + $found = true; + break; + } + } + + if (!$found) { + return; + } + + $generator = new LookupMethodClassGenerator($metadata); + $outerClass = $metadata->getOutsideClassMetadata()->reflection; + + if ($file = $def->getFile()) { + $generator->setRequiredFile($file); + } + + $enhancer = new Enhancer( + $outerClass, + array(), + array( + $generator, + ) + ); + + $filename = $this->container->getParameter('jms_di_extra.cache_dir').'/lookup_method_classes/'.str_replace('\\', '-', $outerClass->name).'.php'; + $enhancer->writeClass($filename); + + $def->setFile($filename); + $def->setClass($enhancer->getClassName($outerClass)); + $def->addMethodCall('__jmsDiExtra_setContainer', array(new Reference('service_container'))); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/JMSDiExtraBundle.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/JMSDiExtraBundle.php new file mode 100644 index 0000000..6a88dbe --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/JMSDiExtraBundle.php @@ -0,0 +1,50 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle; + +use JMS\DiExtraBundle\DependencyInjection\Compiler\ResourceOptimizationPass; +use JMS\DiExtraBundle\DependencyInjection\Compiler\IntegrationPass; +use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; +use JMS\DiExtraBundle\DependencyInjection\Compiler\AnnotationConfigurationPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class JMSDiExtraBundle extends Bundle +{ + const VERSION = '1.0.1'; + + private $kernel; + + public function __construct(KernelInterface $kernel) + { + $this->kernel = $kernel; + } + + public function build(ContainerBuilder $container) + { + $config = $container->getCompiler()->getPassConfig(); + $passes = $config->getBeforeOptimizationPasses(); + array_unshift($passes, new AnnotationConfigurationPass($this->kernel)); + $config->setBeforeOptimizationPasses($passes); + + $container->addCompilerPass(new IntegrationPass()); + $container->addCompilerPass(new ResourceOptimizationPass(), PassConfig::TYPE_AFTER_REMOVING); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/ClassMetadata.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/ClassMetadata.php new file mode 100644 index 0000000..7b992d9 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/ClassMetadata.php @@ -0,0 +1,74 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Metadata; + +use Metadata\ClassMetadata as BaseClassMetadata; + +class ClassMetadata extends BaseClassMetadata +{ + public $id; + public $parent; + public $scope; + public $public; + public $abstract; + public $tags = array(); + public $arguments; + public $methodCalls = array(); + public $lookupMethods = array(); + public $properties = array(); + public $initMethod; + + public function serialize() + { + return serialize(array( + $this->id, + $this->parent, + $this->scope, + $this->public, + $this->abstract, + $this->tags, + $this->arguments, + $this->methodCalls, + $this->lookupMethods, + $this->properties, + $this->initMethod, + parent::serialize(), + )); + } + + public function unserialize($str) + { + list( + $this->id, + $this->parent, + $this->scope, + $this->public, + $this->abstract, + $this->tags, + $this->arguments, + $this->methodCalls, + $this->lookupMethods, + $this->properties, + $this->initMethod, + $parentStr + ) = unserialize($str); + + parent::unserialize($parentStr); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/Driver/AnnotationDriver.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/Driver/AnnotationDriver.php new file mode 100644 index 0000000..cbd2051 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/Driver/AnnotationDriver.php @@ -0,0 +1,220 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Metadata\Driver; + +use JMS\DiExtraBundle\Annotation\AfterSetup; + +use JMS\DiExtraBundle\Annotation\FormType; + +use JMS\DiExtraBundle\Annotation\DoctrineListener; +use JMS\DiExtraBundle\Annotation\Reference as AnnotReference; +use JMS\DiExtraBundle\Annotation\LookupMethod; +use JMS\DiExtraBundle\Annotation\Validator; +use JMS\DiExtraBundle\Annotation\InjectParams; +use JMS\DiExtraBundle\Exception\InvalidTypeException; +use JMS\DiExtraBundle\Annotation\Observe; +use Doctrine\Common\Annotations\Reader; +use JMS\DiExtraBundle\Annotation\Inject; +use JMS\DiExtraBundle\Annotation\Service; +use JMS\DiExtraBundle\Annotation\Tag; +use JMS\DiExtraBundle\Metadata\ClassMetadata; +use Metadata\Driver\DriverInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Reference; + +class AnnotationDriver implements DriverInterface +{ + private $reader; + + public function __construct(Reader $reader) + { + $this->reader = $reader; + } + + public function loadMetadataForClass(\ReflectionClass $class) + { + $metadata = new ClassMetadata($className = $class->getName()); + if (false !== $filename = $class->getFilename()) { + $metadata->fileResources[] = $filename; + } + + // this is a bit of a hack, but avoids any timeout issues when a class + // is moved into one of the compiled classes files, and Doctrine + // Common 2.1 is used. + if (false !== strpos($filename, '/classes.php') + || false !== strpos($filename, '/bootstrap.php')) { + return null; + } + + foreach ($this->reader->getClassAnnotations($class) as $annot) { + if ($annot instanceof Service) { + if (null === $annot->id) { + $metadata->id = $this->generateId($className); + } else { + $metadata->id = $annot->id; + } + + $metadata->parent = $annot->parent; + $metadata->public = $annot->public; + $metadata->scope = $annot->scope; + $metadata->abstract = $annot->abstract; + } else if ($annot instanceof Tag) { + $metadata->tags[$annot->name][] = $annot->attributes; + } else if ($annot instanceof Validator) { + // automatically register as service if not done explicitly + if (null === $metadata->id) { + $metadata->id = $this->generateId($className); + } + + $metadata->tags['validator.constraint_validator'][] = array( + 'alias' => $annot->alias, + ); + } else if ($annot instanceof DoctrineListener) { + if (null === $metadata->id) { + $metadata->id = $this->generateId($className); + } + + foreach ($annot->events as $event) { + $metadata->tags['doctrine.event_listener'][] = array( + 'event' => $event, + 'connection' => $annot->connection ?: 'default', + 'lazy' => $annot->lazy, + 'priority' => $annot->priority, + ); + } + } else if ($annot instanceof FormType) { + if (null === $metadata->id) { + $metadata->id = $this->generateId($className); + } + + $alias = $annot->alias; + + // try to extract it from the class itself + if (null === $alias) { + $instance = unserialize(sprintf('O:%d:"%s":0:{}', strlen($className), $className)); + $alias = $instance->getName(); + } + + $metadata->tags['form.type'][] = array( + 'alias' => $alias, + ); + } + } + + $hasInjection = false; + foreach ($class->getProperties() as $property) { + if ($property->getDeclaringClass()->getName() !== $className) { + continue; + } + $name = $property->getName(); + + foreach ($this->reader->getPropertyAnnotations($property) as $annot) { + if ($annot instanceof Inject) { + $hasInjection = true; + $metadata->properties[$name] = $this->convertReferenceValue($name, $annot); + } + } + } + + foreach ($class->getMethods() as $method) { + if ($method->getDeclaringClass()->getName() !== $className) { + continue; + } + $name = $method->getName(); + + foreach ($this->reader->getMethodAnnotations($method) as $annot) { + if ($annot instanceof Observe) { + $metadata->tags['kernel.event_listener'][] = array( + 'event' => $annot->event, + 'method' => $name, + 'priority' => $annot->priority, + ); + } else if ($annot instanceof InjectParams) { + $params = array(); + foreach ($method->getParameters() as $param) { + if (!isset($annot->params[$paramName = $param->getName()])) { + $params[] = $this->convertReferenceValue($paramName, new Inject(array('value' => null))); + continue; + } + + $params[] = $this->convertReferenceValue($paramName, $annot->params[$paramName]); + } + + if (!$params) { + continue; + } + + $hasInjection = true; + + if ('__construct' === $name) { + $metadata->arguments = $params; + } else { + $metadata->methodCalls[] = array($name, $params); + } + } else if ($annot instanceof LookupMethod) { + $hasInjection = true; + + if ($method->isFinal()) { + throw new \RuntimeException(sprintf('The method "%s::%s" is marked as final and cannot be declared as lookup-method.', $className, $name)); + } + if ($method->isPrivate()) { + throw new \RuntimeException(sprintf('The method "%s::%s" is marked as private and cannot be declared as lookup-method.', $className, $name)); + } + if ($method->getParameters()) { + throw new \RuntimeException(sprintf('The method "%s::%s" must have a no-arguments signature if you want to use it as lookup-method.', $className, $name)); + } + + $metadata->lookupMethods[$name] = $this->convertReferenceValue('get' === substr($name, 0, 3) ? substr($name, 3) : $name, $annot); + } else if ($annot instanceof AfterSetup) { + if (!$method->isPublic()) { + throw new \RuntimeException(sprintf('The init method "%s::%s" must be public.', $method->class, $method->name)); + } + + $metadata->initMethod = $method->name; + } + } + } + + if (null == $metadata->id && !$hasInjection) { + return null; + } + + return $metadata; + } + + private function convertReferenceValue($name, AnnotReference $annot) + { + if (null === $annot->value) { + return new Reference($this->generateId($name), false !== $annot->required ? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE : ContainerInterface::NULL_ON_INVALID_REFERENCE); + } + + if (false === strpos($annot->value, '%')) { + return new Reference($annot->value, false !== $annot->required ? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE : ContainerInterface::NULL_ON_INVALID_REFERENCE); + } + + return $annot->value; + } + + private function generateId($name) + { + $name = preg_replace('/(?<=[a-zA-Z0-9])[A-Z]/', '_\\0', $name); + + return strtolower(strtr($name, '\\', '.')); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/MetadataConverter.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/MetadataConverter.php new file mode 100644 index 0000000..a4f8ea5 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Metadata/MetadataConverter.php @@ -0,0 +1,85 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Metadata; + +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\DefinitionDecorator; +use Symfony\Component\DependencyInjection\Definition; +use Metadata\ClassHierarchyMetadata; + +class MetadataConverter +{ + /** + * Converts class hierarchy metadata to definition instances. + * + * @param ClassHierarchyMetadata $metadata + * @return array an array of Definition instances + */ + public function convert(ClassHierarchyMetadata $metadata) + { + static $count = 0; + $definitions = array(); + + $previous = null; + foreach ($metadata->classMetadata as $classMetadata) { + if (null === $previous && null === $classMetadata->parent) { + $definition = new Definition(); + } else { + $definition = new DefinitionDecorator( + $classMetadata->parent ?: $previous->id + ); + } + + $definition->setClass($classMetadata->name); + if (null !== $classMetadata->scope) { + $definition->setScope($classMetadata->scope); + } + if (null !== $classMetadata->public) { + $definition->setPublic($classMetadata->public); + } + if (null !== $classMetadata->abstract) { + $definition->setAbstract($classMetadata->abstract); + } + if (null !== $classMetadata->arguments) { + $definition->setArguments($classMetadata->arguments); + } + + $definition->setMethodCalls($classMetadata->methodCalls); + $definition->setTags($classMetadata->tags); + $definition->setProperties($classMetadata->properties); + + if (null === $classMetadata->id) { + $classMetadata->id = '_jms_di_extra.unnamed.service_'.$count++; + } + + if ($classMetadata->initMethod) { + if (!method_exists($definition, 'setInitMethod')) { + throw new \RuntimeException(sprintf('@AfterSetup is not available on your Symfony version.')); + } + + $definition->setInitMethod($classMetadata->initMethod); + } + + $definitions[$classMetadata->id] = $definition; + $previous = $classMetadata; + } + + return $definitions; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/README b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/README new file mode 100644 index 0000000..72bab21 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/README @@ -0,0 +1,8 @@ +For documentation, see: + + Resources/doc + + +For license, see: + + Resources/meta/LICENSE \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/config/services.xml b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/config/services.xml new file mode 100644 index 0000000..c1ac0d4 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/config/services.xml @@ -0,0 +1,50 @@ + + + + + + JMS\DiExtraBundle\Metadata\Driver\AnnotationDriver + + Metadata\MetadataFactory + Metadata\Cache\FileCache + + JMS\DiExtraBundle\Metadata\MetadataConverter + JMS\DiExtraBundle\HttpKernel\ControllerResolver + + JMS\DiExtraBundle\EventListener\TemplateListener + JMS\DiExtraBundle\EventListener\ControllerListener + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/doc/index.rst b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/doc/index.rst new file mode 100644 index 0000000..9b7ece5 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/doc/index.rst @@ -0,0 +1,290 @@ +======== +Overview +======== + +This bundle allows you to configure dependency injection using annotations. + +Installation +------------ +Add the following to your ``deps`` file:: + + [JMSDiExtraBundle] + git=https://github.com/schmittjoh/JMSDiExtraBundle.git + target=/bundles/JMS/DiExtraBundle + + ; Dependencies: + ;-------------- + [metadata] + git=https://github.com/schmittjoh/metadata.git + version=1.1.0 ; <- make sure to get 1.1, not 1.0 + +Then register the bundle with your kernel:: + + // in AppKernel::registerBundles() + $bundles = array( + // ... + new JMS\DiExtraBundle\JMSDiExtraBundle($this), + // ... + ); + +In addition, this bundle also requires the JMSAopBundle. See its documentation for +installation instructions:: + + https://github.com/schmittjoh/JMSAopBundle/blob/master/Resources/doc/index.rst + + +Make sure that you also register the namespaces with the autoloader:: + + // app/autoload.php + $loader->registerNamespaces(array( + // ... + 'JMS' => __DIR__.'/../vendor/bundles', + 'Metadata' => __DIR__.'/../vendor/metadata/src', + // ... + )); + + +Configuration +------------- +For optimal development performance (in production there is no difference either way), +it is recommended to explicitly configure the directories which should be scanned for +service classes (by default no directory is scanned):: + + jms_di_extra: + locations: + all_bundles: false + bundles: [FooBundle, AcmeBlogBundle, etc.] + directories: [%kernel.root_dir%/../src, some/other/dir] + +Usage +----- + +Non-Controller Classes +~~~~~~~~~~~~~~~~~~~~~~ + +Non-controller classes are configured, and managed by Symfony's DIC just like any +other service that you configure using YML, XML, or PHP. The only difference is +that you can do it via annotations which is a lot more convenient. + +You can use these annotations on services (for examples, see below): +@Service, @Inject, @InjectParams, @Observe, @Tag + +Note that you cannot use the @Inject annotation on private, or protected properties. +Likewise, the @InjectParams annotation does not work on protected, or private methods. + + +Controllers +~~~~~~~~~~~ + +Controllers are a special type of class which is also treated specially by this +bundle. The most notable difference is that you do not need to define these +classes as services. Yes, no services, but don't worry you can still use all of +the DIC's features, and even some more. + +- Constructor/Setter Injection:: + + em = $em; + $this->session = $session; + } + // ... some actions + } + + **Note:** Constructor Injection is not possible when a parent definition + also defines a constructor which is configured for injection. + +- Property Injection:: + + getMailer(); + } + } + + /** @DI\LookupMethod("mailer") */ + protected function getMailer() { /* empty body here */ } + } + +You can use this type of injection if you have a dependency that you do not +always need in the controller, and which is costly to initialize, like the +mailer in the example above. + + +Annotations +----------- + +@Inject +~~~~~~~~~ +This marks a property, or parameter for injection:: + + use JMS\DiExtraBundle\Annotation\Inject; + + class Controller + { + /** + * @Inject("security.context", required = false) + */ + private $securityContext; + + /** + * @Inject("%kernel.cache_dir%") + */ + private $cacheDir; + + /** + * @Inject + */ + private $session; + } + +If you do not specify the service explicitly, we will try to guess it based on the name +of the property or the parameter. + +@InjectParams +~~~~~~~~~~~~~~~ +This marks the parameters of a method for injection:: + + use JMS\DiExtraBundle\Annotation\Inject; + use JMS\DiExtraBundle\Annotation\InjectParams; + use JMS\DiExtraBundle\Annotation\Service; + + /** + * @Service + */ + class Listener + { + /** + * @InjectParams({ + * "em" = @Inject("doctrine.entity_manager") + * }) + */ + public function __construct(EntityManager $em, Session $session) + { + // ... + } + } + +If you don't define all parameters in the param map, we will try to guess which services +should be injected into the remaining parameters based on their name. + +@Service +~~~~~~~~ +Marks a class as service:: + + use JMS\DiExtraBundle\Annotation\Service; + + /** + * @Service("some.service.id", parent="another.service.id", public=false) + */ + class Listener + { + } + +If you do not explicitly define a service id, then we will generated a sensible default +based on the fully qualified class name for you. + +@Tag +~~~~ +Adds a tag to the service:: + + use JMS\DiExtraBundle\Annotation\Service; + use JMS\DiExtraBundle\Annotation\Tag; + + /** + * @Service + * @Tag("doctrine.event_listener", attributes = {"event" = "postGenerateSchema", lazy=true}) + */ + class Listener + { + // ... + } + +@Observe +~~~~~~~~ +Automatically registers a method as listener to a certain event:: + + use JMS\DiExtraBundle\Annotation\Observe; + use JMS\DiExtraBundle\Annotation\Service; + + /** + * @Service + */ + class RequestListener + { + /** + * @Observe("kernel.request", priority = 255) + */ + public function onKernelRequest() + { + // ... + } + } + +@Validator +~~~~~~~~~~ +Automatically registers the given class as constraint validator for the Validator component:: + + use JMS\DiExtraBundle\Annotation\Validator; + use Symfony\Component\Validator\Constraint; + use Symfony\Component\Validator\ConstraintValidator; + + /** + * @Validator("my_alias") + */ + class MyValidator extends ConstraintValidator + { + // ... + } + + class MyConstraint extends Constraint + { + // ... + public function validatedBy() + { + return 'my_alias'; + } + } + +The @Validator annotation also implies the @Service annotation if you do not specify it explicitly. +The alias which is passed to the @Validator annotation must match the string that is returned from +the ``validatedBy`` method of your constraint. + diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/meta/LICENSE b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/meta/LICENSE new file mode 100644 index 0000000..753842b --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Resources/meta/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php new file mode 100644 index 0000000..37c518a --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/AnnotationConfigurationPassTest.php @@ -0,0 +1,127 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Reference; + +use Symfony\Component\DependencyInjection\DefinitionDecorator; + +use Doctrine\Common\Annotations\AnnotationReader; +use JMS\DiExtraBundle\DependencyInjection\JMSDiExtraExtension; +use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use JMS\DiExtraBundle\DependencyInjection\Compiler\AnnotationConfigurationPass; + +class AnnotationConfigurationPassTest extends \PHPUnit_Framework_TestCase +{ + public function testProcess() + { + $container = $this->getContainer(array(), array( + __DIR__.'/../../Fixture/', + )); + $container->set('doctrine.entity_manager', $em = new \stdClass); + $container->set('session', $session = new \stdClass); + $container->set('database_connection', $dbCon = new \stdClass); + $container->set('router', $router = new \stdClass); + $container->setParameter('table_name', 'foo'); + $this->process($container); + + $this->assertTrue($container->hasDefinition('j_m_s.di_extra_bundle.tests.fixture.request_listener')); + $service = $container->get('j_m_s.di_extra_bundle.tests.fixture.request_listener'); + $this->assertAttributeEquals($em, 'em', $service); + $this->assertAttributeEquals($session, 'session', $service); + $this->assertAttributeEquals($dbCon, 'con', $service); + $this->assertAttributeEquals($router, 'router', $service); + $this->assertAttributeEquals('foo', 'table', $service); + } + + public function testProcessValidator() + { + $container = $this->getContainer(array(), array( + __DIR__.'/../../Fixture/Validator', + )); + $container->set('foo', $foo = new \stdClass); + $this->process($container); + + $this->assertTrue($container->hasDefinition('j_m_s.di_extra_bundle.tests.fixture.validator.validator')); + + $def = $container->getDefinition('j_m_s.di_extra_bundle.tests.fixture.validator.validator'); + $this->assertEquals(array( + 'validator.constraint_validator' => array( + array('alias' => 'foobar'), + ) + ), $def->getTags()); + + $v = $container->get('j_m_s.di_extra_bundle.tests.fixture.validator.validator'); + $this->assertAttributeEquals($foo, 'foo', $v); + } + + public function testConstructorWithInheritance() + { + $container = $this->getContainer(array(), array( + __DIR__.'/../../Functional/Bundle/TestBundle/Inheritance', + )); + $container->set('foo', $foo = new \stdClass); + $container->set('bar', $bar = new \stdClass); + $this->process($container); + + $this->assertTrue($container->hasDefinition('concrete_class')); + $this->assertTrue($container->hasDefinition('abstract_class')); + + $def = new DefinitionDecorator('abstract_class'); + $def->setClass('JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\ConcreteClass'); + $def->addArgument(new Reference('foo')); + $def->addArgument(new Reference('bar')); + + $this->assertEquals($def, $container->getDefinition('concrete_class')); + } + + private function getContainer(array $bundles = array(), array $directories = array()) + { + $container = new ContainerBuilder(); + $container->set('annotation_reader', new AnnotationReader()); + $container->setParameter('kernel.debug', false); + + $extension = new JMSDiExtraExtension(); + $extension->load(array(array( + 'locations' => array( + 'bundles' => $bundles, + 'directories' => $directories, + ), + 'metadata' => array( + 'cache' => 'none', + ) + )), $container); + + return $container; + } + + private function process(ContainerBuilder $container, array $bundles = array()) + { + $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel + ->expects($this->once()) + ->method('getBundles') + ->will($this->returnValue($bundles)) + ; + + $pass = new AnnotationConfigurationPass($kernel); + $pass->process($container); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/Fixtures/a/b/.gitkeep b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/Fixtures/a/b/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/Fixtures/c/.gitkeep b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/Fixtures/c/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php new file mode 100644 index 0000000..af86269 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/DependencyInjection/Compiler/ResourceOptimizationPassTest.php @@ -0,0 +1,50 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use JMS\DiExtraBundle\DependencyInjection\Compiler\ResourceOptimizationPass; +use Symfony\Component\Config\Resource\DirectoryResource; + +class ResourceOptimizationPassTest extends \PHPUnit_Framework_TestCase +{ + public function testProcess() + { + $container = new ContainerBuilder(); + $container->addResource(new DirectoryResource(__DIR__.'/Fixtures/a')); + $container->addResource(new DirectoryResource(__DIR__.'/Fixtures/a/b')); + $container->addResource(new DirectoryResource(__DIR__.'/Fixtures/c')); + $this->process($container); + + $resources = $container->getResources(); + $this->assertEquals(1, count($resources)); + $this->assertInstanceOf('JMS\DiExtraBundle\Config\FastDirectoriesResource', $resources[0]); + $this->assertEquals(array( + __DIR__.'/Fixtures/a', + __DIR__.'/Fixtures/c' + ), $resources[0]->getResource()); + $this->assertAttributeEquals('*', 'filePattern', $resources[0]); + } + + private function process(ContainerBuilder $container) + { + $pass = new ResourceOptimizationPass(); + $pass->process($container); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/AbstractPatternFinderTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/AbstractPatternFinderTest.php new file mode 100644 index 0000000..bbcdb03 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/AbstractPatternFinderTest.php @@ -0,0 +1,50 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Finder; + +use JMS\DiExtraBundle\Finder\PatternFinder; +use Symfony\Component\Process\ExecutableFinder; + +abstract class AbstractPatternFinderTest extends \PHPUnit_Framework_TestCase +{ + public function testFindFiles() + { + $finder = $this->getFinder(); + + $expectedFiles = array( + realpath(__DIR__.'/../Fixture/NonEmptyDirectory/Service1.php'), + realpath(__DIR__.'/../Fixture/NonEmptyDirectory/SubDir1/Service2.php'), + realpath(__DIR__.'/../Fixture/NonEmptyDirectory/SubDir2/Service3.php'), + ); + + $foundFiles = $finder->findFiles(array(__DIR__.'/../Fixture/NonEmptyDirectory')); + $foundFiles = array_map('realpath', $foundFiles); + + $this->assertEquals(array(), array_diff($expectedFiles, $foundFiles)); + $this->assertEquals(array(), array_diff($foundFiles, $expectedFiles)); + } + + public function testFindFilesUsingGrepReturnsEmptyArrayWhenNoMatchesAreFound() + { + $finder = $this->getFinder(); + $this->assertEquals(array(), $finder->findFiles(array(__DIR__.'/../Fixture/EmptyDirectory'))); + } + + abstract protected function getFinder(); +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/FindstrPatternFinderTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/FindstrPatternFinderTest.php new file mode 100644 index 0000000..e874edf --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/FindstrPatternFinderTest.php @@ -0,0 +1,38 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Finder; + +use JMS\DiExtraBundle\Finder\PatternFinder; + +class FindstrPatternFinderTest extends AbstractPatternFinderTest +{ + protected function getFinder() + { + if (0 !== stripos(PHP_OS, 'win')) { + $this->markTestSkipped('FINDSTR is only available on Windows.'); + } + + $finder = new PatternFinder('JMS\DiExtraBundle\Annotation'); + $ref = new \ReflectionProperty($finder, 'method'); + $ref->setAccessible(true); + $ref->setValue($finder, PatternFinder::METHOD_FINDSTR); + + return $finder; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/GrepPatternFinderTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/GrepPatternFinderTest.php new file mode 100644 index 0000000..fa94199 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/GrepPatternFinderTest.php @@ -0,0 +1,37 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Finder; + +use JMS\DiExtraBundle\Finder\PatternFinder; + +class GrepPatternFinderTest extends AbstractPatternFinderTest +{ + protected function getFinder() + { + $finder = new PatternFinder('JMS\DiExtraBundle\Annotation'); + + $ref = new \ReflectionProperty($finder, 'grepPath'); + $ref->setAccessible(true); + if (null === $v = $ref->getValue($finder)) { + $this->markTestSkipped('grep is not available on your system.'); + } + + return $finder; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/PhpPatternFinderTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/PhpPatternFinderTest.php new file mode 100644 index 0000000..c3800cc --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Finder/PhpPatternFinderTest.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Finder; + +use JMS\DiExtraBundle\Finder\PatternFinder; + +class PhpPatternFinderTest extends AbstractPatternFinderTest +{ + protected function getFinder() + { + $finder = new PatternFinder('JMS\DiExtraBundle\Annotation'); + $ref = new \ReflectionProperty($finder, 'method'); + $ref->setAccessible(true); + $ref->setValue($finder, PatternFinder::METHOD_FINDER); + + return $finder; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/EmptyDirectory/.gitkeep b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/EmptyDirectory/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/LoginController.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/LoginController.php new file mode 100644 index 0000000..6e8b1bb --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/LoginController.php @@ -0,0 +1,73 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Fixture; + +use JMS\DiExtraBundle\Annotation\Inject; + +/** + * Login Controller. + * + * @author Johannes M. Schmitt + */ +class LoginController +{ + /** + * @Inject("form.csrf_provider") + */ + private $csrfProvider; + + /** + * @Inject + */ + private $rememberMeServices; + + /** + * @Inject("security.context") + */ + private $securityContext; + + /** + * @Inject("security.authentication.trust_resolver") + */ + private $trustResolver; + + public function loginAction() + { + } + + public function getCsrfProvider() + { + return $this->csrfProvider; + } + + public function getRememberMeServices() + { + return $this->rememberMeServices; + } + + public function getSecurityContext() + { + return $this->securityContext; + } + + public function getTrustResolver() + { + return $this->trustResolver; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/DummyFile.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/DummyFile.php new file mode 100644 index 0000000..fe8dd78 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/DummyFile.php @@ -0,0 +1,3 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Fixture\NonEmptyDirectory; + +use JMS\DiExtraBundle\Annotation as DI; + +/** @DI\Service */ +class Service1 +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir1/NonPhpFile.txt b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir1/NonPhpFile.txt new file mode 100644 index 0000000..88e0de9 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir1/NonPhpFile.txt @@ -0,0 +1,10 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Fixture\NonEmptyDirectory\SubDir1; + +use JMS\DiExtraBundle\Annotation\Service; + +/** @Service */ +class Service2 +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir2/Service3.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir2/Service3.php new file mode 100644 index 0000000..f751265 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/NonEmptyDirectory/SubDir2/Service3.php @@ -0,0 +1,26 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Fixture\NonEmptyDirectory\SubDir2; + +use JMS\DiExtraBundle\Annotation as DI; + +/** @DI\Service */ +class Service1 +{ +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/RequestListener.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/RequestListener.php new file mode 100644 index 0000000..e69ffcc --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/RequestListener.php @@ -0,0 +1,58 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Fixture; + +use JMS\DiExtraBundle\Annotation as DI; + +/** + * @DI\Service + * + * @author Johannes M. Schmitt + */ +class RequestListener +{ + private $router; + private $session; + private $em; + private $con; + private $table; + + /** + * @DI\InjectParams({ + * "em" = @DI\Inject("doctrine.entity_manager") + * }) + */ + public function __construct($router, $session, $em) + { + $this->router = $router; + $this->session = $session; + $this->em = $em; + } + + /** + * @DI\InjectParams({ + * "table" = @DI\Inject("%table_name%") + * }) + */ + public function setConnection($databaseConnection, $table) + { + $this->con = $databaseConnection; + $this->table = $table; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/Validator/Validator.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/Validator/Validator.php new file mode 100644 index 0000000..1ae4c0e --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Fixture/Validator/Validator.php @@ -0,0 +1,45 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Fixture\Validator; + +use JMS\DiExtraBundle\Annotation\InjectParams; +use JMS\DiExtraBundle\Annotation\Validator as ValidatorAnnot; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\ConstraintValidator; + +/** + * @ValidatorAnnot("foobar") + */ +class Validator extends ConstraintValidator +{ + private $foo; + + /** + * @InjectParams + */ + public function __construct($foo) + { + $this->foo = $foo; + } + + public function isValid($value, Constraint $constraint) + { + return true; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/AppKernel.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/AppKernel.php new file mode 100644 index 0000000..6a8c682 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/AppKernel.php @@ -0,0 +1,80 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional; + +require_once __DIR__.'/../bootstrap.php'; + +use Symfony\Component\HttpKernel\Util\Filesystem; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Kernel; + +class AppKernel extends Kernel +{ + private $config; + + public function __construct($config) + { + parent::__construct('test', true); + + $fs = new Filesystem(); + if (!$fs->isAbsolutePath($config)) { + $config = __DIR__.'/config/'.$config; + } + + if (!file_exists($config)) { + throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config)); + } + + $this->config = $config; + } + + public function registerBundles() + { + return array( + new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), + new \Symfony\Bundle\SecurityBundle\SecurityBundle(), + new \Symfony\Bundle\TwigBundle\TwigBundle(), + new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), + new \JMS\AopBundle\JMSAopBundle(), + new \JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\JMSDiExtraTestBundle(), + new \JMS\DiExtraBundle\JMSDiExtraBundle($this), + new \JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), + ); + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load($this->config); + } + + public function getCacheDir() + { + return sys_get_temp_dir().'/JMSDiExtraBundle'; + } + + public function serialize() + { + return $this->config; + } + + public function unserialize($config) + { + $this->__construct($config); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/BaseTestCase.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/BaseTestCase.php new file mode 100644 index 0000000..8cc2a30 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/BaseTestCase.php @@ -0,0 +1,49 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional; + +use Symfony\Component\HttpKernel\Util\Filesystem; + +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +class BaseTestCase extends WebTestCase +{ + static protected function createKernel(array $options = array()) + { + return new AppKernel( + isset($options['config']) ? $options['config'] : 'default.yml' + ); + } + + protected function tearDown() + { + $this->cleanTmpDir(); + } + + protected function setUp() + { + $this->cleanTmpDir(); + } + + private function cleanTmpDir() + { + $fs = new Filesystem(); + $fs->remove(sys_get_temp_dir().'/JMSDiExtraBundle'); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php new file mode 100644 index 0000000..d517058 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/AnotherSecuredController.php @@ -0,0 +1,40 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller; + +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use JMS\SecurityExtraBundle\Annotation\Secure; +use JMS\DiExtraBundle\Annotation as DI; + +/** + * Secured Controller. + * + * @author Johannes M. Schmitt + */ +class AnotherSecuredController +{ + /** + * @Route("/secure-action") + * @Secure("ROLE_FOO") + */ + public function secureAction() + { + throw new \Exception('Should never be called'); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/RegisterController.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/RegisterController.php new file mode 100644 index 0000000..8ec8c31 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/RegisterController.php @@ -0,0 +1,42 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller; + +use Symfony\Component\HttpFoundation\Response; +use JMS\DiExtraBundle\Annotation as DI; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; + +/** + * @author Johannes M. Schmitt + */ +abstract class RegisterController +{ + /** + * @Route("/register") + */ + public function registerAction() + { + $mailer = $this->getMailer(); + + return new Response($mailer->getFromMail(), 200, array('Content-Type' => 'text/plain')); + } + + /** @DI\LookupMethod("test_mailer") */ + abstract protected function getMailer(); +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php new file mode 100644 index 0000000..0bf831c --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Controller/SecuredController.php @@ -0,0 +1,41 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Controller; + +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use JMS\SecurityExtraBundle\Annotation\Secure; +use JMS\DiExtraBundle\Annotation as DI; + +/** + * @author Johannes M. Schmitt + */ +abstract class SecuredController +{ + /** + * @Route("/lookup-method-and-aop") + * @Secure("ROLE_FOO") + */ + public function secureAction() + { + throw new \Exception('Should never be called'); + } + + /** @DI\LookupMethod */ + abstract protected function getTestMailer(); +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/AbstractClass.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/AbstractClass.php new file mode 100644 index 0000000..b3124c1 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/AbstractClass.php @@ -0,0 +1,31 @@ +templating = $templating; + } + + public function getTemplating() + { + return $this->templating; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/ConcreteClass.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/ConcreteClass.php new file mode 100644 index 0000000..2afb936 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Inheritance/ConcreteClass.php @@ -0,0 +1,38 @@ + + */ +class ConcreteClass extends AbstractClass +{ + private $foo; + private $bar; + + /** + * @DI\InjectParams + * + * @param stdClass $foo + * @param stdClass $bar + */ + public function __construct($foo, $bar) + { + $this->foo = $foo; + $this->bar = $bar; + } + + public function getFoo() + { + return $this->foo; + } + + public function getBar() + { + return $this->bar; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/JMSDiExtraTestBundle.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/JMSDiExtraTestBundle.php new file mode 100644 index 0000000..acf74ca --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/JMSDiExtraTestBundle.php @@ -0,0 +1,25 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class JMSDiExtraTestBundle extends Bundle +{ +} diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Mailer/TestMailer.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Mailer/TestMailer.php new file mode 100644 index 0000000..89cc63d --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Bundle/TestBundle/Mailer/TestMailer.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Mailer; + +use JMS\DiExtraBundle\Annotation as DI; + +/** + * @DI\Service("test_mailer") + * + * @author Johannes M. Schmitt + */ +class TestMailer +{ + public function getFromMail() + { + return 'foo@bar.de'; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/ControllerResolverTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/ControllerResolverTest.php new file mode 100644 index 0000000..76a7aab --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/ControllerResolverTest.php @@ -0,0 +1,50 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Functional; + +class ControllerResolverTest extends BaseTestCase +{ + public function testLookupMethodIsCorrectlyImplemented() + { + $client = $this->createClient(); + $client->request('GET', '/register'); + + $this->assertEquals('foo@bar.de', $client->getResponse()->getContent()); + } + + public function testLookupMethodAndAopProxy() + { + $client = $this->createClient(); + $client->request('GET', '/lookup-method-and-aop'); + + $this->assertTrue($client->getResponse()->isRedirect('http://localhost/login'), substr((string) $client->getResponse(), 0, 512)); + + $client->insulate(); + $client->request('GET', '/lookup-method-and-aop'); + $this->assertTrue($client->getResponse()->isRedirect('http://localhost/login'), substr((string) $client->getResponse(), 0, 512)); + } + + public function testAopProxyWhenNoDiMetadata() + { + $client = $this->createClient(); + $client->request('GET', '/secure-action'); + + $this->assertTrue($client->getResponse()->isRedirect('http://localhost/login')); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Issue11Test.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Issue11Test.php new file mode 100644 index 0000000..c2bc483 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/Issue11Test.php @@ -0,0 +1,21 @@ +createClient(); + + $container = self::$kernel->getContainer(); + $foo = $container->get('foo'); + $bar = $container->get('bar'); + $templating = $container->get('templating'); + + $concreteService = $container->get('concrete_class'); + $this->assertSame($templating, $concreteService->getTemplating()); + $this->assertSame($foo, $concreteService->getFoo()); + $this->assertSame($bar, $concreteService->getBar()); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/default.yml b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/default.yml new file mode 100644 index 0000000..31bf587 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/default.yml @@ -0,0 +1,12 @@ +imports: + - { resource: framework.yml } + - { resource: twig.yml } + - { resource: security.yml } + +jms_di_extra: + locations: + bundles: [JMSDiExtraTestBundle] + +services: + foo: { class: stdClass } + bar: { class: stdClass } \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/framework.yml b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/framework.yml new file mode 100644 index 0000000..0057272 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/framework.yml @@ -0,0 +1,16 @@ +framework: + secret: test + test: ~ + session: + storage_id: session.storage.filesystem + form: true + csrf_protection: true + validation: + enabled: true + enable_annotations: true + router: + resource: %kernel.root_dir%/config/routing.yml + +services: + logger: + class: Symfony\Component\HttpKernel\Log\NullLogger \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/routing.yml b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/routing.yml new file mode 100644 index 0000000..9c0c861 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/routing.yml @@ -0,0 +1,3 @@ +TestBundle: + type: annotation + resource: @JMSDiExtraTestBundle/Controller/ \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/security.yml b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/security.yml new file mode 100644 index 0000000..eeb621e --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/security.yml @@ -0,0 +1,13 @@ +security: + providers: + in_memory: + users: + johannes: { password: login } + + encoders: + Symfony\Component\Security\Core\User\UserInterface: plaintext + + firewalls: + default: + form_login: ~ + anonymous: ~ diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/twig.yml b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/twig.yml new file mode 100644 index 0000000..2c8539a --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Functional/config/twig.yml @@ -0,0 +1,7 @@ +framework: + templating: + engines: [twig, php] + +twig: + debug: %kernel.debug% + strict_variables: %kernel.debug% \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/ClassMetadataTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/ClassMetadataTest.php new file mode 100644 index 0000000..18e8454 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/ClassMetadataTest.php @@ -0,0 +1,35 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests\Metadata; + +use JMS\DiExtraBundle\Metadata\ClassMetadata; + +class ClassMetadataTest extends \PHPUnit_Framework_TestCase +{ + public function testSerializeUnserialize() + { + $classMetadata = new ClassMetadata('JMS\DiExtraBundle\Tests\Fixture\LoginController'); + $classMetadata->arguments = array('foo', 'bar'); + $classMetadata->abstract = true; + $classMetadata->public = false; + $classMetadata->id = 'foo'; + + $this->assertEquals($classMetadata, unserialize(serialize($classMetadata))); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/AnnotationDriverTest.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/AnnotationDriverTest.php new file mode 100644 index 0000000..b7a8056 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/AnnotationDriverTest.php @@ -0,0 +1,37 @@ +getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\DiExtraBundle\Tests\Metadata\Driver\Fixture\LoginType')); + + $this->assertEquals('j_m_s.di_extra_bundle.tests.metadata.driver.fixture.login_type', $metadata->id); + $this->assertEquals(array( + 'form.type' => array( + array('alias' => 'login'), + ) + ), $metadata->tags); + } + + public function testFormTypeWithExplicitAlias() + { + $metadata = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\DiExtraBundle\Tests\Metadata\Driver\Fixture\SignUpType')); + + $this->assertEquals(array( + 'form.type' => array( + array('alias' => 'foo'), + ) + ), $metadata->tags); + } + + private function getDriver() + { + return new AnnotationDriver(new AnnotationReader()); + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/LoginType.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/LoginType.php new file mode 100644 index 0000000..8bee517 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/LoginType.php @@ -0,0 +1,27 @@ + + */ +class LoginType extends AbstractType +{ + private $securityContext; + + public function __construct(SecurityContext $context) + { + $this->securityContext = $context; + } + + public function getName() + { + return 'login'; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/SignUpType.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/SignUpType.php new file mode 100644 index 0000000..476a505 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/Metadata/Driver/Fixture/SignUpType.php @@ -0,0 +1,19 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\DiExtraBundle\Tests; + +use Symfony\Bundle\TwigBundle\TwigBundle; +use Symfony\Bundle\DoctrineBundle\DoctrineBundle; +use JMS\DiExtraBundle\JMSDiExtraBundle; +use JMS\SecurityExtraBundle\JMSSecurityExtraBundle; +use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle; +use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension; +use Symfony\Bundle\AsseticBundle\AsseticBundle; +use Symfony\Bundle\MonologBundle\MonologBundle; +use Symfony\Bundle\SecurityBundle\SecurityBundle; +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use JMS\DiExtraBundle\Finder\ServiceFinder; + +/** + * @group performance + */ +class PerformanceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getFinderMethods + */ + public function testServiceFinder($method) + { + $finder = new ServiceFinder(); + $ref = new \ReflectionMethod($finder, $method); + $ref->setAccessible(true); + + $bundles = array( + new FrameworkBundle(), + new SecurityBundle(), + new MonologBundle(), + new AsseticBundle(), + new DoctrineBundle(), + new TwigBundle(), + new SensioFrameworkExtraBundle(), + new JMSSecurityExtraBundle(), + ); + $bundles = array_map(function($v) { + return $v->getPath(); + }, $bundles); + + $bundles[] = __DIR__.'/../'; + + $time = microtime(true); + for ($i=0,$c=5; $i<$c; $i++) { + $ref->invoke($finder, $bundles); + } + $time = microtime(true) - $time; + $this->printResults('service finder ('.$method.')', $time, $c); + } + + public function getFinderMethods() + { + return array( + array('findUsingGrep'), + array('findUsingFinder'), + ); + } + + private function printResults($test, $time, $iterations) + { + if (0 == $iterations) { + throw new InvalidArgumentException('$iterations cannot be zero.'); + } + + $title = $test." results:\n"; + $iterationsText = sprintf("Iterations: %d\n", $iterations); + $totalTime = sprintf("Total Time: %.3f s\n", $time); + $iterationTime = sprintf("Time per iteration: %.3f ms\n", $time/$iterations * 1000); + + $max = max(strlen($title), strlen($iterationTime)) - 1; + + echo "\n".str_repeat('-', $max)."\n"; + echo $title; + echo str_repeat('=', $max)."\n"; + echo $iterationsText; + echo $totalTime; + echo $iterationTime; + echo str_repeat('-', $max)."\n"; + } +} \ No newline at end of file diff --git a/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/bootstrap.php b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/bootstrap.php new file mode 100644 index 0000000..91518c7 --- /dev/null +++ b/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/schmittjoh-JMSDiExtraBundle-03a343a/Tests/bootstrap.php @@ -0,0 +1,15 @@ + + + + + + + ./Tests + + + + + + performance + + + diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/CHANGELOG.md b/vendor/jms/metadata/schmittjoh-metadata-84088bc/CHANGELOG.md new file mode 100644 index 0000000..74da57e --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/CHANGELOG.md @@ -0,0 +1,18 @@ +CHANGELOG +========= + +This changelog references all relevant changes: + +To get the diff between the two last versions, go to +https://github.com/schmittjoh/metadata/compare/1.0.0...1.1.0 + +* 1.1.0 (2011-10-04) + + * added support for metadata on interfaces + * added support for non annotation-based drivers + * added support for merging metadata + +This release is fully backwards compatible with the 1.0.0 release. Therefore, +the 1.0.x branch has been discontinued. + +* 1.0.0 (2011-07-09) diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/LICENSE b/vendor/jms/metadata/schmittjoh-metadata-84088bc/LICENSE new file mode 100644 index 0000000..f49a4e1 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/README.rst b/vendor/jms/metadata/schmittjoh-metadata-84088bc/README.rst new file mode 100644 index 0000000..51517ff --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/README.rst @@ -0,0 +1,37 @@ +Metadata is a library for class/method/property metadata management in PHP +========================================================================== + +Overview +-------- + +This library provides some commonly needed base classes for managing metadata +for classes, methods and properties. The metadata can come from many different +sources (annotations, YAML/XML/PHP configuration files). + +The metadata classes are used to abstract away that source and provide a common +interface for all of them. + +Usage +----- + +The library provides three classes that you can extend to add your application +specific properties, and flags: ``ClassMetadata``, ``MethodMetadata``, and +``PropertyMetadata`` + +After you have added, your properties in sub-classes, you also need to add +``DriverInterface`` implementations which know how to populate these classes +from the different metadata sources. + +Finally, you can use the ``MetadataFactory`` to retrieve the metadata:: + + getMetadataForClass('MyNamespace\MyObject'); + diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/composer.json b/vendor/jms/metadata/schmittjoh-metadata-84088bc/composer.json new file mode 100644 index 0000000..e598e25 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/composer.json @@ -0,0 +1,19 @@ +{ + "name": "jms/metadata", + "description": "Class/method/property metadata management in PHP", + "keywords": ["annotations","metadata","yaml","xml"], + "type": "library", + "license": "Apache", + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-0": { "Metadata\\": "src/" } + } +} diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/phpunit.xml.dist b/vendor/jms/metadata/schmittjoh-metadata-84088bc/phpunit.xml.dist new file mode 100644 index 0000000..38db7c3 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + + ./tests/Metadata/ + + + + + + performance + + + diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Cache/CacheInterface.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Cache/CacheInterface.php new file mode 100644 index 0000000..dbf3ccb --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Cache/CacheInterface.php @@ -0,0 +1,35 @@ +dir = rtrim($dir, '\\/'); + } + + public function loadClassMetadataFromCache(\ReflectionClass $class) + { + $path = $this->dir.'/'.strtr($class->getName(), '\\', '-').'.cache.php'; + if (!file_exists($path)) { + return null; + } + + return include $path; + } + + public function putClassMetadataInCache(ClassMetadata $metadata) + { + $path = $this->dir.'/'.strtr($metadata->name, '\\', '-').'.cache.php'; + file_put_contents($path, 'dir.'/'.strtr($class->getName(), '\\', '-').'.cache.php'; + if (file_exists($path)) { + unlink($path); + } + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassHierarchyMetadata.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassHierarchyMetadata.php new file mode 100644 index 0000000..c90a5e4 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassHierarchyMetadata.php @@ -0,0 +1,55 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata; + +/** + * Represents the metadata for the entire class hierarchy. + * + * @author Johannes M. Schmitt + */ +class ClassHierarchyMetadata +{ + public $classMetadata = array(); + + public function addClassMetadata(ClassMetadata $metadata) + { + $this->classMetadata[$metadata->name] = $metadata; + } + + public function getRootClassMetadata() + { + return reset($this->classMetadata); + } + + public function getOutsideClassMetadata() + { + return end($this->classMetadata); + } + + public function isFresh($timestamp) + { + foreach ($this->classMetadata as $metadata) { + if (!$metadata->isFresh($timestamp)) { + return false; + } + } + + return true; + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassMetadata.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassMetadata.php new file mode 100644 index 0000000..2479a4f --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/ClassMetadata.php @@ -0,0 +1,98 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata; + +/** + * Base class for class metadata. + * + * This class is intended to be extended to add your own application specific + * properties, and flags. + * + * @author Johannes M. Schmitt + */ +class ClassMetadata implements \Serializable +{ + public $name; + public $reflection; + public $methodMetadata = array(); + public $propertyMetadata = array(); + public $fileResources = array(); + public $createdAt; + + public function __construct($name) + { + $this->name = $name; + + $this->reflection = new \ReflectionClass($name); + $this->createdAt = time(); + } + + public function addMethodMetadata(MethodMetadata $metadata) + { + $this->methodMetadata[$metadata->name] = $metadata; + } + + public function addPropertyMetadata(PropertyMetadata $metadata) + { + $this->propertyMetadata[$metadata->name] = $metadata; + } + + public function isFresh($timestamp = null) + { + if (null === $timestamp) { + $timestamp = $this->createdAt; + } + + foreach ($this->fileResources as $filepath) { + if (!file_exists($filepath)) { + return false; + } + + if ($timestamp < filemtime($filepath)) { + return false; + } + } + + return true; + } + + public function serialize() + { + return serialize(array( + $this->name, + $this->methodMetadata, + $this->propertyMetadata, + $this->fileResources, + $this->createdAt, + )); + } + + public function unserialize($str) + { + list( + $this->name, + $this->methodMetadata, + $this->propertyMetadata, + $this->fileResources, + $this->createdAt + ) = unserialize($str); + + $this->reflection = new \ReflectionClass($this->name); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/AbstractFileDriver.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/AbstractFileDriver.php new file mode 100644 index 0000000..b02f387 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/AbstractFileDriver.php @@ -0,0 +1,42 @@ + + */ +abstract class AbstractFileDriver implements DriverInterface +{ + private $locator; + + public function __construct(FileLocatorInterface $locator) + { + $this->locator = $locator; + } + + public function loadMetadataForClass(\ReflectionClass $class) + { + if (null === $path = $this->locator->findFileForClass($class, $this->getExtension())) { + return null; + } + + return $this->loadMetadataFromFile($class, $path); + } + + /** + * Parses the content of the file, and converts it to the desired metadata. + * + * @param string $file + * @return ClassMetadata|null + */ + abstract protected function loadMetadataFromFile(\ReflectionClass $class, $file); + + /** + * Returns the extension of the file. + * + * @return string + */ + abstract protected function getExtension(); +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverChain.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverChain.php new file mode 100644 index 0000000..809ccf1 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverChain.php @@ -0,0 +1,40 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata\Driver; + +final class DriverChain implements DriverInterface +{ + private $drivers; + + public function __construct(array $drivers) + { + $this->drivers = $drivers; + } + + public function loadMetadataForClass(\ReflectionClass $class) + { + foreach ($this->drivers as $driver) { + if (null !== $metadata = $driver->loadMetadataForClass($class)) { + return $metadata; + } + } + + return null; + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverInterface.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverInterface.php new file mode 100644 index 0000000..57ed66d --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/DriverInterface.php @@ -0,0 +1,24 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata\Driver; + +interface DriverInterface +{ + function loadMetadataForClass(\ReflectionClass $class); +} diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocator.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocator.php new file mode 100644 index 0000000..41f7b99 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocator.php @@ -0,0 +1,29 @@ +dirs = $dirs; + } + + public function findFileForClass(\ReflectionClass $class, $extension) + { + foreach ($this->dirs as $prefix => $dir) { + if (0 !== strpos($class->getNamespaceName(), $prefix)) { + continue; + } + + $path = $dir.'/'.str_replace('\\', '.', substr($class->getName(), strlen($prefix)+1)).'.'.$extension; + if (file_exists($path)) { + return $path; + } + } + + return null; + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocatorInterface.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocatorInterface.php new file mode 100644 index 0000000..5092f3d --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Driver/FileLocatorInterface.php @@ -0,0 +1,8 @@ +container = $container; + $this->realDriverId = $realDriverId; + } + + public function loadMetadataForClass(\ReflectionClass $class) + { + return $this->container->get($this->realDriverId)->loadMetadataForClass($class); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableClassMetadata.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableClassMetadata.php new file mode 100644 index 0000000..13ec158 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableClassMetadata.php @@ -0,0 +1,23 @@ +name = $object->name; + $this->reflection = $object->reflection; + $this->methodMetadata = array_merge($this->methodMetadata, $object->methodMetadata); + $this->propertyMetadata = array_merge($this->propertyMetadata, $object->propertyMetadata); + $this->fileResources = array_merge($this->fileResources, $object->fileResources); + + if ($object->createdAt < $this->createdAt) { + $this->createdAt = $object->createdAt; + } + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableInterface.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableInterface.php new file mode 100644 index 0000000..1da234f --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MergeableInterface.php @@ -0,0 +1,8 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata; + +use Metadata\Driver\DriverInterface; +use Metadata\Cache\CacheInterface; + +final class MetadataFactory implements MetadataFactoryInterface +{ + private $driver; + private $cache; + private $loadedMetadata = array(); + private $loadedClassMetadata = array(); + private $hierarchyMetadataClass; + private $includeInterfaces = false; + private $debug; + + public function __construct(DriverInterface $driver, $hierarchyMetadataClass = 'Metadata\ClassHierarchyMetadata', $debug = false) + { + $this->driver = $driver; + $this->hierarchyMetadataClass = $hierarchyMetadataClass; + $this->debug = $debug; + } + + public function setIncludeInterfaces($bool) + { + $this->includeInterfaces = (Boolean) $bool; + } + + public function setCache(CacheInterface $cache) + { + $this->cache = $cache; + } + + public function getMetadataForClass($className) + { + if (isset($this->loadedMetadata[$className])) { + return $this->loadedMetadata[$className]; + } + + $metadata = null; + foreach ($this->getClassHierarchy($className) as $class) { + if (isset($this->loadedClassMetadata[$name = $class->getName()])) { + $this->addClassMetadata($metadata, $this->loadedClassMetadata[$name]); + continue; + } + + // check the cache + if (null !== $this->cache + && (null !== $classMetadata = $this->cache->loadClassMetadataFromCache($class))) { + if ($this->debug && !$classMetadata->isFresh()) { + $this->cache->evictClassMetadataFromCache($classMetadata->reflection); + } else { + $this->loadedClassMetadata[$name] = $classMetadata; + $this->addClassMetadata($metadata, $classMetadata); + continue; + } + } + + // load from source + if (null !== $classMetadata = $this->driver->loadMetadataForClass($class)) { + $this->loadedClassMetadata[$name] = $classMetadata; + $this->addClassMetadata($metadata, $classMetadata); + + if (null !== $this->cache) { + $this->cache->putClassMetadataInCache($classMetadata); + } + + continue; + } + } + + return $this->loadedMetadata[$className] = $metadata; + } + + private function addClassMetadata(&$metadata, $toAdd) + { + if ($toAdd instanceof MergeableInterface) { + if (null === $metadata) { + $metadata = clone $toAdd; + } else { + $metadata->merge($toAdd); + } + } else { + if (null === $metadata) { + $metadata = new $this->hierarchyMetadataClass; + } + + $metadata->addClassMetadata($toAdd); + } + } + + private function getClassHierarchy($class) + { + $classes = array(); + $refl = new \ReflectionClass($class); + + do { + $classes[] = $refl; + } while (false !== $refl = $refl->getParentClass()); + + $classes = array_reverse($classes, false); + + if (!$this->includeInterfaces) { + return $classes; + } + + $addedInterfaces = array(); + $newHierarchy = array(); + + foreach ($classes as $class) { + foreach ($class->getInterfaces() as $interface) { + if (isset($addedInterfaces[$interface->getName()])) { + continue; + } + $addedInterfaces[$interface->getName()] = true; + + $newHierarchy[] = $interface; + } + + $newHierarchy[] = $class; + } + + return $newHierarchy; + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MetadataFactoryInterface.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MetadataFactoryInterface.php new file mode 100644 index 0000000..d7fa68a --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MetadataFactoryInterface.php @@ -0,0 +1,24 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata; + +interface MetadataFactoryInterface +{ + function getMetadataForClass($className); +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MethodMetadata.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MethodMetadata.php new file mode 100644 index 0000000..db2d501 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/MethodMetadata.php @@ -0,0 +1,61 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata; + +/** + * Base class for method metadata. + * + * This class is intended to be extended to add your application specific + * properties, and flags. + * + * @author Johannes M. Schmitt + */ +class MethodMetadata implements \Serializable +{ + public $class; + public $name; + public $reflection; + + public function __construct($class, $name) + { + $this->class = $class; + $this->name = $name; + + $this->reflection = new \ReflectionMethod($class, $name); + $this->reflection->setAccessible(true); + } + + public function invoke($obj, array $args = array()) + { + return $this->reflection->invokeArgs($obj, $args); + } + + public function serialize() + { + return serialize(array($this->class, $this->name)); + } + + public function unserialize($str) + { + list($this->class, $this->name) = unserialize($str); + + $this->reflection = new \ReflectionMethod($this->class, $this->name); + $this->reflection->setAccessible(true); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/PropertyMetadata.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/PropertyMetadata.php new file mode 100644 index 0000000..a581ce0 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/PropertyMetadata.php @@ -0,0 +1,69 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata; + +/** + * Base class for property metadata. + * + * This class is intended to be extended to add your application specific + * properties, and flags. + * + * @author Johannes M. Schmitt + */ +class PropertyMetadata implements \Serializable +{ + public $class; + public $name; + public $reflection; + + public function __construct($class, $name) + { + $this->class = $class; + $this->name = $name; + + $this->reflection = new \ReflectionProperty($class, $name); + $this->reflection->setAccessible(true); + } + + public function getValue($obj) + { + return $this->reflection->getValue($obj); + } + + public function setValue($obj, $value) + { + $this->reflection->setValue($obj, $value); + } + + public function serialize() + { + return serialize(array( + $this->class, + $this->name, + )); + } + + public function unserialize($str) + { + list($this->class, $this->name) = unserialize($str); + + $this->reflection = new \ReflectionProperty($this->class, $this->name); + $this->reflection->setAccessible(true); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Version.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Version.php new file mode 100644 index 0000000..0ea37d6 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/src/Metadata/Version.php @@ -0,0 +1,24 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Metadata; + +final class Version +{ + const VERSION = '1.1.1'; +} diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Cache/FileCacheTest.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Cache/FileCacheTest.php new file mode 100644 index 0000000..5c308b5 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Cache/FileCacheTest.php @@ -0,0 +1,23 @@ +assertNull($cache->loadClassMetadataFromCache($refl = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject'))); + $cache->putClassMetadataInCache($metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject')); + + $this->assertEquals($metadata, $cache->loadClassMetadataFromCache($refl)); + + $cache->evictClassMetadataFromCache($refl); + $this->assertNull($cache->loadClassMetadataFromCache($refl)); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/ClassMetadataTest.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/ClassMetadataTest.php new file mode 100644 index 0000000..cc5a1ce --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/ClassMetadataTest.php @@ -0,0 +1,39 @@ +assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->name); + $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->reflection->getName()); + } + + public function testSerializeUnserialize() + { + $metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'); + + $this->assertEquals($metadata, unserialize(serialize($metadata))); + } + + public function testIsFresh() + { + $ref = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject'); + touch($ref->getFilename()); + sleep(2); + + $metadata = new ClassMetadata($ref->getName()); + $metadata->fileResources[] = $ref->getFilename(); + $this->assertTrue($metadata->isFresh()); + + sleep(2); + clearstatcache($ref->getFilename()); + touch($ref->getFilename()); + $this->assertFalse($metadata->isFresh()); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/DriverChainTest.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/DriverChainTest.php new file mode 100644 index 0000000..a175587 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/DriverChainTest.php @@ -0,0 +1,37 @@ +getMock('Metadata\\Driver\\DriverInterface'); + $driver + ->expects($this->once()) + ->method('loadMetadataForClass') + ->will($this->returnValue($metadata = new ClassMetadata('\stdClass'))) + ; + $chain = new DriverChain(array($driver)); + + $this->assertSame($metadata, $chain->loadMetadataForClass(new \ReflectionClass('\stdClass'))); + } + + public function testLoadMetadataForClassReturnsNullWhenNoMetadataIsFound() + { + $driver = new DriverChain(array()); + $this->assertNull($driver->loadMetadataForClass(new \ReflectionClass('\stdClass'))); + + $driver = $this->getMock('Metadata\\Driver\\DriverInterface'); + $driver + ->expects($this->once()) + ->method('loadMetadataForClass') + ->will($this->returnValue(null)) + ; + $driverChain = new DriverChain(array($driver)); + $this->assertNull($driver->loadMetadataForClass(new \ReflectionClass('\stdClass'))); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/FileLocatorTest.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/FileLocatorTest.php new file mode 100644 index 0000000..e121eba --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/FileLocatorTest.php @@ -0,0 +1,26 @@ + __DIR__.'/Fixture/A', + 'Metadata\Tests\Driver\Fixture\B' => __DIR__.'/Fixture/B', + 'Metadata\Tests\Driver\Fixture\C' => __DIR__.'/Fixture/C', + )); + + $ref = new \ReflectionClass('Metadata\Tests\Driver\Fixture\A\A'); + $this->assertEquals(realpath(__DIR__.'/Fixture/A/A.xml'), realpath($locator->findFileForClass($ref, 'xml'))); + + $ref = new \ReflectionClass('Metadata\Tests\Driver\Fixture\B\B'); + $this->assertNull($locator->findFileForClass($ref, 'xml')); + + $ref = new \ReflectionClass('Metadata\Tests\Driver\Fixture\C\SubDir\C'); + $this->assertEquals(realpath(__DIR__.'/Fixture/C/SubDir.C.yml'), realpath($locator->findFileForClass($ref, 'yml'))); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/A/A.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/A/A.php new file mode 100644 index 0000000..3ea6df1 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Driver/Fixture/A/A.php @@ -0,0 +1,5 @@ +foo; + } + + private function setFoo($foo) + { + $this->foo = $foo; + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/TestParent.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/TestParent.php new file mode 100644 index 0000000..940cb5b --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/Fixtures/TestParent.php @@ -0,0 +1,7 @@ +propertyMetadata['foo'] = 'bar'; + $parentMetadata->propertyMetadata['baz'] = 'baz'; + $parentMetadata->methodMetadata['foo'] = 'bar'; + $parentMetadata->createdAt = 2; + $parentMetadata->fileResources[] = 'foo'; + + $childMetadata = new MergeableClassMetadata('Metadata\Tests\Fixtures\TestObject'); + $childMetadata->propertyMetadata['foo'] = 'baz'; + $childMetadata->methodMetadata['foo'] = 'baz'; + $childMetadata->createdAt = 1; + $childMetadata->fileResources[] = 'bar'; + + $parentMetadata->merge($childMetadata); + $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $parentMetadata->name); + $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $parentMetadata->reflection->getName()); + $this->assertEquals(array('foo' => 'baz', 'baz' => 'baz',), $parentMetadata->propertyMetadata); + $this->assertEquals(array('foo' => 'baz',), $parentMetadata->methodMetadata); + $this->assertEquals(1, $parentMetadata->createdAt); + $this->assertEquals(array('foo', 'bar'), $parentMetadata->fileResources); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MetadataFactoryTest.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MetadataFactoryTest.php new file mode 100644 index 0000000..193250c --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MetadataFactoryTest.php @@ -0,0 +1,184 @@ +getMock('Metadata\Driver\DriverInterface'); + + $driver + ->expects($this->at(0)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject'))) + ->will($this->returnCallback(function($class) { + return new ClassMetadata($class->getName()); + })) + ; + $driver + ->expects($this->at(1)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestParent'))) + ->will($this->returnCallback(function($class) { + return new ClassMetadata($class->getName()); + })) + ; + + $factory = new MetadataFactory($driver); + $metadata = $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestParent'); + + $this->assertInstanceOf('Metadata\ClassHierarchyMetadata', $metadata); + $this->assertEquals(2, count($metadata->classMetadata)); + } + + public function testGetMetadataForClassWhenMergeable() + { + $driver = $this->getMock('Metadata\Driver\DriverInterface'); + + $driver + ->expects($this->at(0)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject'))) + ->will($this->returnCallback(function($class) { + return new MergeableClassMetadata($class->getName()); + })) + ; + $driver + ->expects($this->at(1)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestParent'))) + ->will($this->returnCallback(function($class) { + return new MergeableClassMetadata($class->getName()); + })) + ; + + $factory = new MetadataFactory($driver); + $metadata = $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestParent'); + + $this->assertInstanceOf('Metadata\MergeableClassMetadata', $metadata); + $this->assertEquals('Metadata\Tests\Fixtures\TestParent', $metadata->name); + } + + public function testGetMetadataWithComplexHierarchy() + { + $driver = $this->getMock('Metadata\Driver\DriverInterface'); + + $driver + ->expects($this->any()) + ->method('loadMetadataForClass') + ->will($this->returnCallback(function($class) { + $metadata = new MergeableClassMetadata($class->name); + + switch ($class->name) { + case 'Metadata\Tests\Fixtures\ComplexHierarchy\BaseClass': + $metadata->propertyMetadata['foo'] = new PropertyMetadata($class->name, 'foo'); + break; + + case 'Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA': + $metadata->propertyMetadata['bar'] = new PropertyMetadata($class->name, 'bar'); + break; + + case 'Metadata\Tests\Fixtures\ComplexHierarchy\SubClassB': + $metadata->propertyMetadata['baz'] = new PropertyMetadata($class->name, 'baz'); + break; + + default: + throw new \RuntimeException(sprintf('Unsupported class "%s".', $class->name)); + } + + return $metadata; + })) + ; + + $factory = new MetadataFactory($driver); + + $subClassA = $factory->getMetadataForClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA'); + $this->assertInstanceOf('Metadata\MergeableClassMetadata', $subClassA); + $this->assertEquals(array('foo', 'bar'), array_keys($subClassA->propertyMetadata)); + + $subClassB = $factory->getMetadataForClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassB'); + $this->assertInstanceOf('Metadata\MergeableClassMetadata', $subClassB); + $this->assertEquals(array('foo', 'baz'), array_keys($subClassB->propertyMetadata)); + } + + public function testGetMetadataWithCache() + { + $driver = $this->getMock('Metadata\Driver\DriverInterface'); + $driver + ->expects($this->once()) + ->method('loadMetadataForClass') + ->will($this->returnValue($metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'))) + ; + + $factory = new MetadataFactory($driver); + + $cache = $this->getMock('Metadata\Cache\CacheInterface'); + $cache + ->expects($this->once()) + ->method('loadClassMetadataFromCache') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject'))) + ->will($this->returnValue(null)) + ; + $cache + ->expects($this->once()) + ->method('putClassMetadataInCache') + ->with($this->equalTo($metadata)) + ; + $factory->setCache($cache); + + $this->assertSame($metadata, reset($factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject')->classMetadata)); + } + + public function testGetMetadataReturnsNullIfNoMetadataIsFound() + { + $driver = $this->getMock('Metadata\Driver\DriverInterface'); + $driver + ->expects($this->once()) + ->method('loadMetadataForClass') + ->will($this->returnValue(null)) + ; + + $factory = new MetadataFactory($driver); + + $this->assertNull($factory->getMetadataForClass('stdClass')); + } + + public function testGetMetadataWithInterfaces() + { + $driver = $this->getMock('Metadata\Driver\DriverInterface'); + + $driver + ->expects($this->at(3)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA'))) + ; + $driver + ->expects($this->at(2)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\InterfaceB'))) + ; + $driver + ->expects($this->at(1)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\BaseClass'))) + ; + $driver + ->expects($this->at(0)) + ->method('loadMetadataForClass') + ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\InterfaceA'))) + ; + + $factory = new MetadataFactory($driver); + $factory->setIncludeInterfaces(true); + + $factory->getMetadataForClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA'); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MethodMetadataTest.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MethodMetadataTest.php new file mode 100644 index 0000000..7ab9af6 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/MethodMetadataTest.php @@ -0,0 +1,36 @@ +assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class); + $this->assertEquals('setFoo', $metadata->name); + $this->assertEquals(new \ReflectionMethod('Metadata\Tests\Fixtures\TestObject', 'setFoo'), $metadata->reflection); + } + + public function testSerializeUnserialize() + { + $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo'); + + $this->assertEquals($metadata, unserialize(serialize($metadata))); + } + + public function testInvoke() + { + $obj = new TestObject(); + $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo'); + + $this->assertNull($obj->getFoo()); + $metadata->invoke($obj, array('foo')); + $this->assertEquals('foo', $obj->getFoo()); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/PropertyMetadataTest.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/PropertyMetadataTest.php new file mode 100644 index 0000000..46f1a27 --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/Metadata/Tests/PropertyMetadataTest.php @@ -0,0 +1,36 @@ +assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class); + $this->assertEquals('foo', $metadata->name); + $this->assertEquals(new \ReflectionProperty('Metadata\Tests\Fixtures\TestObject', 'foo'), $metadata->reflection); + } + + public function testSerializeUnserialize() + { + $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo'); + + $this->assertEquals($metadata, unserialize(serialize($metadata))); + } + + public function testSetGetValue() + { + $obj = new TestObject(); + $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo'); + + $this->assertNull($metadata->getValue($obj)); + $metadata->setValue($obj, 'foo'); + $this->assertEquals('foo', $metadata->getValue($obj)); + } +} \ No newline at end of file diff --git a/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/bootstrap.php b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/bootstrap.php new file mode 100644 index 0000000..7a9f78f --- /dev/null +++ b/vendor/jms/metadata/schmittjoh-metadata-84088bc/tests/bootstrap.php @@ -0,0 +1,36 @@ + + * + */ + +spl_autoload_register(function($class) +{ + if (0 === strpos($class, 'Metadata\Tests\\')) { + $path = __DIR__.'/../tests/'.strtr($class, '\\', '/').'.php'; + if (file_exists($path) && is_readable($path)) { + require_once $path; + + return true; + } + } else if (0 === strpos($class, 'Metadata\\')) { + $path = __DIR__.'/../src/'.($class = strtr($class, '\\', '/')).'.php'; + if (file_exists($path) && is_readable($path)) { + require_once $path; + + return true; + } + } else if (0 === strpos($class, 'Symfony\\')) { + $path = __DIR__.'/../../symfony/src/'.strtr($class, '\\', '/').'.php'; + + if (file_exists($path) && is_readable($path)) { + require_once $path; + + return true; + } + } +}); + diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/PreAuthorize.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/PreAuthorize.php new file mode 100644 index 0000000..0128138 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/PreAuthorize.php @@ -0,0 +1,59 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Annotation; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; + +/** + * Annotation for expression-based access control. + * + * @Annotation + * @Target("METHOD") + * + * @author Johannes M. Schmitt + */ +final class PreAuthorize +{ + /** + * @Required + * @var string + */ + public $expr; + + public function __construct() + { + if (0 === func_num_args()) { + return; + } + $values = func_get_arg(0); + + if (isset($values['value'])) { + $values['expr'] = $values['value']; + } + if (!isset($values['expr'])) { + throw new InvalidArgumentException('The "expr" attribute must be set for annotation @PreAuthorize.'); + } + + if (!is_string($values['expr'])) { + throw new InvalidArgumentException(sprintf('The "expr" attribute of annotation @PreAuthorize must be a string, but got "%s".', gettype($values['expr']))); + } + + $this->expr = $values['expr']; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/RunAs.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/RunAs.php new file mode 100644 index 0000000..94de7a3 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/RunAs.php @@ -0,0 +1,42 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Annotation; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; + +/** + * @Annotation + * @Target("METHOD") + */ +final class RunAs +{ + public $roles; + + public function __construct(array $values) + { + if (isset($values['value'])) { + $values['roles'] = $values['value']; + } + if (!isset($values['roles'])) { + throw new InvalidArgumentException('"roles" must be defined for RunAs annotation.'); + } + + $this->roles = array_map('trim', explode(',', $values['roles'])); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SatisfiesParentSecurityPolicy.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SatisfiesParentSecurityPolicy.php new file mode 100644 index 0000000..e087f2f --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SatisfiesParentSecurityPolicy.php @@ -0,0 +1,81 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Annotation; + +/** + * This must be declared on classes which inherit from classes that have + * requested method invocation securing capabilities. + * + * It indicates to the analyzer that the developer is aware of these security + * restrictions, and has applied them to the root class in an appropriate + * fashion. + * + * We cannot do this automatically without properly analyzing the control flow, + * and in some cases it is not possible at all. See the following example: + * + * + * // child class + * public function editComment($commentId) + * { + * // retrieve comment from database + * $comment = $this->entityManager->find($commentId); + * + * return parent::editComment($comment); + * } + * + * // base class which is inherited from + * /** + * * @SecureParam(name="comment", permissions="EDIT") + * *\/ + * public function editComment(Comment $comment) + * { + * // do some supposedly secure action + * } + * + * + * The above example can be rewritten so that we can apply security checks + * automatically: + * + * + * // child class + * public function editComment($commentId) + * { + * // retrieve comment from database + * $comment = $this->entityManager->find($commentId); + * + * return $this->doEditComment($comment); + * } + * + * // base class which is inherited from + * /** + * * @SecureParam(name="comment", permissions="EDIT") + * *\/ + * protected function doEditComment(Comment $comment) + * { + * // do some secure action + * } + * + * + * @Annotation + * @Target("METHOD") + * @author Johannes M. Schmitt + */ +final class SatisfiesParentSecurityPolicy +{ +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/Secure.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/Secure.php new file mode 100644 index 0000000..bffd8fd --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/Secure.php @@ -0,0 +1,45 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Annotation; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; + +/** + * Represents a @Secure annotation. + * + * @Annotation + * @Target("METHOD") + * @author Johannes M. Schmitt + */ +final class Secure +{ + public $roles; + + public function __construct(array $values) + { + if (isset($values['value'])) { + $values['roles'] = $values['value']; + } + if (!isset($values['roles'])) { + throw new InvalidArgumentException('You must define a "roles" attribute for each Secure annotation.'); + } + + $this->roles = array_map('trim', explode(',', $values['roles'])); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureParam.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureParam.php new file mode 100644 index 0000000..ec098b7 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureParam.php @@ -0,0 +1,48 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Annotation; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; + +/** + * Represents a @SecureParam annotation. + * + * @Annotation + * @Target("METHOD") + * @author Johannes M. Schmitt + */ +final class SecureParam +{ + public $name; + public $permissions; + + public function __construct(array $values) + { + if (!isset($values['name'])) { + throw new InvalidArgumentException('You must define a "name" attribute for each SecureParam annotation.'); + } + if (!isset($values['permissions'])) { + throw new InvalidArgumentException('You must define a "permissions" attribute for each SecureParam annotation.'); + } + + $this->name = $values['name']; + + $this->permissions = array_map('trim', explode(',', $values['permissions'])); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureReturn.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureReturn.php new file mode 100644 index 0000000..35e071e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Annotation/SecureReturn.php @@ -0,0 +1,45 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Annotation; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; + +/** + * Represents a @SecureReturn annotation. + * + * @Annotation + * @Target("METHOD") + * @author Johannes M. Schmitt + */ +final class SecureReturn +{ + public $permissions; + + public function __construct(array $values) + { + if (isset($values['value'])) { + $values['permissions'] = $values['value']; + } + if (!isset($values['permissions'])) { + throw new InvalidArgumentException('You must define a "permissions" attribute for each SecureReturn annotation.'); + } + + $this->permissions = array_map('trim', explode(',', $values['permissions'])); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/CHANGELOG-1.1.md b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/CHANGELOG-1.1.md new file mode 100644 index 0000000..a76156b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/CHANGELOG-1.1.md @@ -0,0 +1,38 @@ +This document details all changes from JMSSecurityExtraBundle 1.0.x to 1.1: + +- The configuration option "secure_controllers" has been removed. This setting is + now automatically enabled, but it requires the JMSDiExtraBundle. + +- The dependencies of this bundle have changed: + + * The metadata library 1.1 version is now required instead of the 1.0 version + (if you are using the Standard Edition, just change the "version=origin/1.0.x" + line from your deps file to "version=1.1.0"). + * The JMSAopBundle is now required. For installation instructions, please see + https://github.com/schmittjoh/JMSAopBundle + * The JMSDiExtraBundle is now required if you want to secure your non-service + controllers (if you only have service controllers, you don't need it). For + installation instructions, see https://github.com/schmittjoh/JMSDiExtraBundle + +- The attribute "IS_IDDQD" has been renamed to "ROLE_IDDQD" + +- A powerful expression-based authorization language has been added which works + in combination with the existing voting system. Since it is much more powerful + than the built-in voters, and also much faster, you are highly encouraged to + migrate your existing authorization rules to expressions, and eventually disable + the built-in voters entirely. Some examples for how to convert simple attributes + to their equivalent expressions are listed below: + + * IS_AUTHENTICATED_ANONYMOUSLY -> "permitAll" + * IS_AUTHENTICATED_REMEMBERED -> "isAuthenticated()" + * IS_AUTHENTICATED_FULLY -> "isFullyAuthenticated()" + * ROLE_FOO -> "hasRole('ROLE_FOO')" + +- The ability to configure method access control (e.g. for controller actions) + in the DI configuration has been added. Note that for non-service controllers + the JMSDiExtraBundle is required. + +- The "is_expr_granted" Twig function has been added if you want to check an + expression from a Twig template. + + diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/AccessControlConfiguration.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/AccessControlConfiguration.php new file mode 100644 index 0000000..dc547a1 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/AccessControlConfiguration.php @@ -0,0 +1,90 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\ConfigurationInterface; + +use Symfony\Component\HttpKernel\Kernel; + +use Symfony\Bundle\SecurityBundle\DependencyInjection\MainConfiguration as BaseConfiguration; +use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; + +/** + * Enhances the access_control section configuration. + * + * @author Johannes M. Schmitt + */ +class AccessControlConfiguration implements ConfigurationInterface +{ + /** + * Generates the configuration tree builder. + * + * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder + */ + public function getConfigTreeBuilder() + { + $tb = new TreeBuilder(); + $rootNode = $tb->root('security'); + + $rootNode + ->ignoreExtraKeys() + ->fixXmlConfig('rule', 'access_control') + ->children() + ->arrayNode('access_control') + ->cannotBeOverwritten() + ->prototype('array') + ->fixXmlConfig('role') + ->validate() + ->always(function($v) { + if (!empty($v['roles']) && isset($v['access'])) { + throw new \Exception('"roles", and "access" cannot be set at the same time.'); + } + + if (empty($v['roles'])) { + unset($v['roles']); + } + + return $v; + }) + ->end() + ->children() + ->scalarNode('requires_channel')->defaultNull()->end() + ->scalarNode('path')->defaultNull()->end() + ->scalarNode('host')->defaultNull()->end() + ->scalarNode('ip')->defaultNull()->end() + ->arrayNode('methods') + ->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end() + ->prototype('scalar')->end() + ->end() + ->arrayNode('roles') + ->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end() + ->prototype('scalar')->end() + ->end() + ->scalarNode('access')->end() + ->end() + ->end() + ->end() + ->end() + ; + + return $tb; + } +} diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddAfterInvocationProvidersPass.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddAfterInvocationProvidersPass.php new file mode 100644 index 0000000..64547b1 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddAfterInvocationProvidersPass.php @@ -0,0 +1,52 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * Collects after invocation providers. + * + * @author Johannes M. Schmitt + */ +class AddAfterInvocationProvidersPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('security.access.after_invocation_manager')) { + return; + } + + $providers = array(); + foreach (array_keys($container->findTaggedServiceIds('security.after_invocation.provider')) as $id) { + if ('security.access.after_invocation.acl_provider' === $id && !$container->has('security.acl.provider')) { + continue; + } + + $providers[] = new Reference($id); + } + + $container + ->getDefinition('security.access.after_invocation_manager') + ->setArguments(array($providers)) + ; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddExpressionCompilersPass.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddExpressionCompilersPass.php new file mode 100644 index 0000000..6b63a42 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/AddExpressionCompilersPass.php @@ -0,0 +1,66 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection\Compiler; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +class AddExpressionCompilersPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + if (!$container->hasDefinition('security.expressions.compiler')) { + return; + } + + $compilerDef = $container->getDefinition('security.expressions.compiler'); + foreach ($container->findTaggedServiceIds('security.expressions.function_compiler') + as $id => $attr) { + $compilerDef->addMethodCall('addFunctionCompiler', array(new Reference($id))); + } + + foreach ($container->findTaggedServiceIds('security.expressions.type_compiler') + as $id => $attr) { + $compilerDef->addMethodCall('addTypeCompiler', array(new Reference($id))); + } + + $serviceMap = $parameterMap = array(); + foreach ($container->findTaggedServiceIds('security.expressions.variable') as $id => $attributes) { + foreach ($attributes as $attr) { + if (!isset($attr['variable']) || (!isset($attr['service']) && !isset($attr['parameter']))) { + throw new RuntimeException(sprintf('"variable", and either "service" or "parameter" must be given for tag "security.expressions.variable" for service id "%s".', $id)); + } + + if (isset($attr['service'])) { + $serviceMap[$attr['variable']] = $attr['service']; + $container + ->findDefinition($attr['service']) + ->setPublic(true) + ; + } else { + $parameterMap[$attr['variable']] = $attr['parameter']; + } + } + } + $container->getDefinition('security.expressions.variable_compiler') + ->addMethodCall('setMaps', array($serviceMap, $parameterMap)); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/CollectSecuredServicesPass.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/CollectSecuredServicesPass.php new file mode 100644 index 0000000..b813b89 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/CollectSecuredServicesPass.php @@ -0,0 +1,43 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Collects secured services. + * + * @author Johannes M. Schmitt + */ +class CollectSecuredServicesPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + $securedClasses = array(); + foreach ($container->findTaggedServiceIds('security.secure_service') as $id => $attr) { + $securedClasses[] = $container->getDefinition($id)->getClass(); + } + + $container + ->getDefinition('security.access.pointcut') + ->addMethodCall('setSecuredClasses', array($securedClasses)) + ; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/DisableVotersPass.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/DisableVotersPass.php new file mode 100644 index 0000000..fb35bb9 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/DisableVotersPass.php @@ -0,0 +1,46 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +class DisableVotersPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container) + { + if ($container->getParameter('security.role_voter.disabled')) { + $container->removeDefinition('security.access.role_hierarchy_voter'); + $container->removeDefinition('security.access.simple_role_voter'); + } + + if ($container->getParameter('security.authenticated_voter.disabled')) { + $container->removeDefinition('security.access.authenticated_voter'); + } + + if ($container->hasDefinition('security.acl.voter.basic_permissions')) { + if ($container->getParameter('security.acl_voter.disabled')) { + $container->removeDefinition('security.acl.voter.basic_permissions'); + } else { + $container->getDefinition('security.acl.voter.basic_permissions') + ->setClass('JMS\SecurityExtraBundle\Security\Acl\Voter\AclVoter'); + } + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/IntegrationPass.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/IntegrationPass.php new file mode 100644 index 0000000..abfcdb2 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Compiler/IntegrationPass.php @@ -0,0 +1,22 @@ +hasAlias('security.acl.provider') + && !$container->hasDefinition('security.acl.provider')) { + $container->removeDefinition('security.acl.permission_evaluator'); + } + + if ($container->hasDefinition('security.role_hierarchy')) { + $container->getDefinition('security.role_hierarchy') + ->setPublic(true); + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Configuration.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Configuration.php new file mode 100644 index 0000000..70cf1d5 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/Configuration.php @@ -0,0 +1,64 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class Configuration implements ConfigurationInterface +{ + public function getConfigTreeBuilder() + { + $tb = new TreeBuilder(); + $tb + ->root('jms_security_extra') + ->validate() + ->always(function($v) { + if ($v['method_access_control'] && !$v['expressions']) { + throw new \Exception('You need to enable expressions if you want to configure method access via the DI config.'); + } + + return $v; + }) + ->end() + ->children() + ->booleanNode('secure_all_services')->defaultFalse()->end() + ->booleanNode('enable_iddqd_attribute')->defaultFalse()->end() + ->scalarNode('cache_dir')->cannotBeEmpty()->defaultValue('%kernel.cache_dir%/jms_security')->end() + ->booleanNode('expressions')->defaultFalse()->end() + ->arrayNode('voters') + ->addDefaultsIfNotSet() + ->canBeUnset() + ->children() + ->booleanNode('disable_authenticated')->defaultFalse()->end() + ->booleanNode('disable_role')->defaultFalse()->end() + ->booleanNode('disable_acl')->defaultFalse()->end() + ->end() + ->end() + ->arrayNode('method_access_control') + ->useAttributeAsKey('pattern') + ->prototype('scalar')->isRequired()->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ; + + return $tb; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/JMSSecurityExtraExtension.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/JMSSecurityExtraExtension.php new file mode 100644 index 0000000..cd2e1c2 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/JMSSecurityExtraExtension.php @@ -0,0 +1,100 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection; + +use Symfony\Component\DependencyInjection\Reference; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** + * JMSSecurityExtraExtension. + * + * @author Johannes M. Schmitt + */ +class JMSSecurityExtraExtension extends Extension +{ + public function load(array $configs, ContainerBuilder $container) + { + $bundles = $container->getParameter('kernel.bundles'); + if (!isset($bundles['JMSAopBundle'])) { + throw new RuntimeException('The JMSSecurityExtraBundle requires the JMSAopBundle, please make sure to enable it in your AppKernel.'); + } + + $config = $this->processConfiguration(new Configuration(), $configs); + + $loader = new XmlFileLoader($container, new FileLocator(array(__DIR__.'/../Resources/config/'))); + $loader->load('services.xml'); + + $container->setParameter('security.access.secure_all_services', $config['secure_all_services']); + + $cacheDir = $container->getParameterBag()->resolveValue($config['cache_dir']); + if (!is_dir($cacheDir)) { + if (false === @mkdir($cacheDir, 0777, true)) { + throw new RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir)); + } + } + $container->setParameter('security.extra.cache_dir', $cacheDir); + + if ($config['expressions']) { + $loader->load('security_expressions.xml'); + + if (!is_dir($cacheDir.'/expressions')) { + if (false === @mkdir($cacheDir.'/expressions', 0777, true)) { + throw new RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir.'/expressions')); + } + } + + $container->getDefinition('security.expressions.voter') + ->addMethodCall('setCacheDir', array($cacheDir.'/expressions')); + } + + $disableAllVoters = !isset($config['voters']); + $container->setParameter('security.authenticated_voter.disabled', + $disableAllVoters || $config['voters']['disable_authenticated']); + $container->setParameter('security.role_voter.disabled', + $disableAllVoters || $config['voters']['disable_role']); + $container->setParameter('security.acl_voter.disabled', + $disableAllVoters || $config['voters']['disable_acl']); + + if ($config['enable_iddqd_attribute']) { + $container + ->getDefinition('security.extra.iddqd_voter') + ->addTag('security.voter') + ; + + // FIXME: Also add an iddqd after invocation provider + } + + if ($config['method_access_control']) { + $driverDef = $container->getDefinition('security.extra.driver_chain'); + $args = $driverDef->getArguments(); + array_unshift($args[0], new Reference('security.extra.config_driver')); + $driverDef->setArguments($args); + + $container->setParameter('security.access.method_access_control', + $config['method_access_control']); + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/SecurityExtension.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/SecurityExtension.php new file mode 100644 index 0000000..96ddf99 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/DependencyInjection/SecurityExtension.php @@ -0,0 +1,130 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\DependencyInjection; + +use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension as BaseSecurityExtension; +use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\DependencyInjection\DefinitionDecorator; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\Config\FileLocator; + +/** + * Enhances the access_control section of the SecurityBundle. + * + * @author Johannes M. Schmitt + */ +class SecurityExtension extends Extension +{ + private $extension; + + public function __construct(BaseSecurityExtension $extension) + { + $this->extension = $extension; + } + + public function getAlias() + { + return $this->extension->getAlias(); + } + + public function getNamespace() + { + return $this->extension->getNamespace(); + } + + public function getXsdValidationBasePath() + { + return $this->extension->getXsdValidationBasePath(); + } + + public function getClassesToCompile() + { + return array_merge(parent::getClassesToCompile(), $this->extension->getClassesToCompile()); + } + + public function load(array $configs, ContainerBuilder $container) + { + $parentConfigs = array(); + + foreach ($configs as $config) { + if (isset($config['rule'])) { + unset($config['rule']); + } + if (isset($config['access_control'])) { + unset($config['access_control']); + } + + $parentConfigs[] = $config; + } + $this->extension->load($parentConfigs, $container); + + $config = $this->processConfiguration(new AccessControlConfiguration(), $configs); + $this->createAuthorization($config, $container); + } + + public function __call($method, array $args) + { + return call_user_func_array(array($this->extension, $method), $args); + } + + private function createAuthorization($config, ContainerBuilder $container) + { + if (!$config['access_control']) { + return; + } + + $this->addClassesToCompile(array( + 'Symfony\\Component\\Security\\Http\\AccessMap', + )); + + foreach ($config['access_control'] as $access) { + $matcher = $this->invokeParent('createRequestMatcher', array( + $container, + $access['path'], + $access['host'], + count($access['methods']) === 0 ? null : $access['methods'], + $access['ip'] + )); + + if (isset($access['roles'])) { + $attributes = $access['roles']; + } else { + $def = new DefinitionDecorator('security.expressions.expression'); + $def->addArgument($access['access']); + $container->setDefinition($exprId = 'security.expressions.expression.'.sha1($access['access']), $def); + + $attributes = array(new Reference($exprId)); + } + + $container->getDefinition('security.access_map') + ->addMethodCall('add', array($matcher, $attributes, $access['requires_channel'])); + } + } + + private function invokeParent($method, array $args = array()) + { + $ref = new \ReflectionMethod($this->extension, $method); + $ref->setAccessible(true); + + return $ref->invokeArgs($this->extension, $args); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/Exception.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/Exception.php new file mode 100644 index 0000000..b6606f9 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/Exception.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Exception; + +/** + * Base exception for the SecurityExtraBundle. + * + * @author Johannes M. Schmitt + */ +interface Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/InvalidArgumentException.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..6a9f2ae --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/InvalidArgumentException.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Exception; + +/** + * InvalidArgumentException for the SecurityExtraBundle. + * + * @author Johannes M. Schmitt + */ +class InvalidArgumentException extends \InvalidArgumentException implements Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/RuntimeException.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/RuntimeException.php new file mode 100644 index 0000000..b7bb573 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Exception/RuntimeException.php @@ -0,0 +1,28 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Exception; + +/** + * RuntimeException for the SecurityExtraBundle. + * + * @author Johannes M. Schmitt + */ +class RuntimeException extends \RuntimeException implements Exception +{ +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/JMSSecurityExtraBundle.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/JMSSecurityExtraBundle.php new file mode 100644 index 0000000..6f5c0e3 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/JMSSecurityExtraBundle.php @@ -0,0 +1,59 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle; + +use JMS\SecurityExtraBundle\DependencyInjection\SecurityExtension; +use JMS\SecurityExtraBundle\DependencyInjection\Compiler\IntegrationPass; +use JMS\SecurityExtraBundle\DependencyInjection\Compiler\DisableVotersPass; +use JMS\SecurityExtraBundle\DependencyInjection\Compiler\AddExpressionCompilersPass; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; +use JMS\SecurityExtraBundle\DependencyInjection\Compiler\AddAfterInvocationProvidersPass; +use JMS\SecurityExtraBundle\DependencyInjection\Compiler\CollectSecuredServicesPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\Bundle; + +/** + * Registers our custom compiler pass. + * + * @author Johannes M. Schmitt + */ +class JMSSecurityExtraBundle extends Bundle +{ + const VERSION = '1.1.0'; + + public function build(ContainerBuilder $container) + { + if (!$container->hasExtension('security')) { + throw new \LogicException('The JMSSecurityExtraBundle must be registered after the SecurityBundle in your AppKernel.php.'); + } + $container->registerExtension(new SecurityExtension($container->getExtension('security'))); + + $passConfig = $container->getCompilerPassConfig(); + + // needs to run before voter collection + $passes = $passConfig->getBeforeOptimizationPasses(); + array_unshift($passes, new DisableVotersPass()); + $passConfig->setBeforeOptimizationPasses($passes); + + $passConfig->addPass(new AddAfterInvocationProvidersPass()); + $passConfig->addPass(new CollectSecuredServicesPass()); + $passConfig->addPass(new AddExpressionCompilersPass()); + $passConfig->addPass(new IntegrationPass()); + } +} diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/ClassMetadata.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/ClassMetadata.php new file mode 100644 index 0000000..5f692cb --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/ClassMetadata.php @@ -0,0 +1,93 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Metadata; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; +use Metadata\MethodMetadata; +use Metadata\MergeableInterface; +use Metadata\MergeableClassMetadata; + +/** + * Contains class metadata information + * + * @author Johannes M. Schmitt + */ +class ClassMetadata extends MergeableClassMetadata +{ + public function addMethodMetadata(MethodMetadata $metadata) + { + if ($this->reflection->isFinal()) { + throw new RuntimeException(sprintf('Class "%s" is declared final, and cannot be secured.', $reflection->name)); + } + + if ($metadata->reflection->isStatic()) { + throw new RuntimeException(sprintf('Method "%s::%s" is declared static and cannot be secured.', $metadata->reflection->class, $metadata->reflection->name)); + } + + if ($metadata->reflection->isFinal()) { + throw new RuntimeException(sprintf('Method "%s::%s" is declared final and cannot be secured.', $metadata->reflection->class, $metadata->reflection->name)); + } + + parent::addMethodMetadata($metadata); + } + + public function merge(MergeableInterface $metadata) + { + if (!$metadata instanceof ClassMetadata) { + throw new InvalidArgumentException('$metadata must be an instance of ClassMetadata.'); + } + + foreach ($this->methodMetadata as $name => $methodMetadata) { + // check if metadata was declared on an interface + if (!$metadata->reflection->hasMethod($name)) { + continue; + } + + if ($metadata->reflection->getMethod($name)->getDeclaringClass()->name + !== $methodMetadata->class) { + if (!isset($metadata->methodMetadata[$name])) { + if ($methodMetadata->reflection->isAbstract()) { + continue; + } + + throw new RuntimeException(sprintf( + 'You have overridden a secured method "%s::%s" in "%s". ' + .'Please copy over the applicable security metadata, and ' + .'also add @SatisfiesParentSecurityPolicy.', + $methodMetadata->reflection->class, + $name, + $metadata->reflection->name + )); + } + + if (!$metadata->methodMetadata[$name]->satisfiesParentSecurityPolicy) { + throw new RuntimeException(sprintf('Unresolved security metadata conflict for method "%s::%s" in "%s". Please copy the respective annotations, and add @SatisfiesParentSecurityPolicy to the child method.', $metadata->reflection->name, $name, $methodMetadata->reflection->getDeclaringClass()->getFilename())); + } + } + } + + parent::merge($metadata); + } + + public function isProxyRequired() + { + return !empty($this->methodMetadata); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/AnnotationDriver.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/AnnotationDriver.php new file mode 100644 index 0000000..7617c60 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/AnnotationDriver.php @@ -0,0 +1,107 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Metadata\Driver; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; +use Doctrine\Common\Annotations\Reader; +use JMS\SecurityExtraBundle\Annotation\PreAuthorize; +use JMS\SecurityExtraBundle\Annotation\RunAs; +use JMS\SecurityExtraBundle\Annotation\SatisfiesParentSecurityPolicy; +use JMS\SecurityExtraBundle\Annotation\Secure; +use JMS\SecurityExtraBundle\Annotation\SecureParam; +use JMS\SecurityExtraBundle\Annotation\SecureReturn; +use JMS\SecurityExtraBundle\Metadata\ClassMetadata; +use JMS\SecurityExtraBundle\Metadata\MethodMetadata; +use Metadata\Driver\DriverInterface; +use \ReflectionClass; +use \ReflectionMethod; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression; + +/** + * Loads security annotations and converts them to metadata + * + * @author Johannes M. Schmitt + */ +class AnnotationDriver implements DriverInterface +{ + private $reader; + + public function __construct(Reader $reader) + { + $this->reader = $reader; + } + + public function loadMetadataForClass(ReflectionClass $reflection) + { + $metadata = new ClassMetadata($reflection->getName()); + + foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED) as $method) { + // check if the method was defined on this class + if ($method->getDeclaringClass()->getName() !== $reflection->getName()) { + continue; + } + + $annotations = $this->reader->getMethodAnnotations($method); + + if ($annotations && null !== $methodMetadata = $this->convertMethodAnnotations($method, $annotations)) { + $metadata->addMethodMetadata($methodMetadata); + } + } + + return $metadata; + } + + private function convertMethodAnnotations(\ReflectionMethod $method, array $annotations) + { + $parameters = array(); + foreach ($method->getParameters() as $index => $parameter) { + $parameters[$parameter->getName()] = $index; + } + + $methodMetadata = new MethodMetadata($method->getDeclaringClass()->getName(), $method->getName()); + $hasSecurityMetadata = false; + foreach ($annotations as $annotation) { + if ($annotation instanceof Secure) { + $methodMetadata->roles = $annotation->roles; + $hasSecurityMetadata = true; + } else if ($annotation instanceof PreAuthorize) { + $methodMetadata->roles = array(new Expression($annotation->expr)); + $hasSecurityMetadata = true; + } else if ($annotation instanceof SecureParam) { + if (!isset($parameters[$annotation->name])) { + throw new InvalidArgumentException(sprintf('The parameter "%s" does not exist for method "%s".', $annotation->name, $method->getName())); + } + + $methodMetadata->addParamPermissions($parameters[$annotation->name], $annotation->permissions); + $hasSecurityMetadata = true; + } else if ($annotation instanceof SecureReturn) { + $methodMetadata->returnPermissions = $annotation->permissions; + $hasSecurityMetadata = true; + } else if ($annotation instanceof SatisfiesParentSecurityPolicy) { + $methodMetadata->satisfiesParentSecurityPolicy = true; + $hasSecurityMetadata = true; + } else if ($annotation instanceof RunAs) { + $methodMetadata->runAsRoles = $annotation->roles; + $hasSecurityMetadata = true; + } + } + + return $hasSecurityMetadata ? $methodMetadata : null; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/ConfigDriver.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/ConfigDriver.php new file mode 100644 index 0000000..00dd89e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/Driver/ConfigDriver.php @@ -0,0 +1,100 @@ + + */ +class ConfigDriver implements DriverInterface +{ + private $bundles; + private $config; + + public function __construct(array $bundles, array $config) + { + uasort($bundles, function($a, $b) { + return strlen($b) - strlen($a); + }); + + foreach ($bundles as $name => $namespace) { + $bundles[$name] = substr($namespace, 0, strrpos($namespace, '\\')); + } + + $this->bundles = $bundles; + $this->config = $config; + } + + public function loadMetadataForClass(\ReflectionClass $class) + { + $metadata = new ClassMetadata($class->name); + + foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) { + if ($method->getDeclaringClass()->name !== $class->name) { + continue; + } + + $expression = null; + if (null !== $notation = $this->getControllerNotation($method)) { + $expression = $this->getExpressionForSignature($notation); + } + + if (null === $expression && null === $expression = + $this->getExpressionForSignature($method->class.'::'.$method->name)) { + continue; + } + + $methodMetadata = new MethodMetadata($method->class, $method->name); + $methodMetadata->roles = array(new Expression($expression)); + $metadata->addMethodMetadata($methodMetadata); + } + + if (!$metadata->methodMetadata) { + return null; + } + + return $metadata; + } + + private function getExpressionForSignature($signature) + { + foreach ($this->config as $pattern => $expr) { + if (!preg_match('#'.$pattern.'#i', $signature)) { + continue; + } + + return $expr; + } + + return null; + } + + // TODO: Is it feasible to reverse-engineer the notation for service controllers? + private function getControllerNotation(\ReflectionMethod $method) + { + $signature = $method->class.'::'.$method->name; + + // check if class is a controller + if (0 === preg_match('#\\\\Controller\\\\([^\\\\]+)Controller::(.+)Action$#', $signature, $match)) { + return null; + } + + foreach ($this->bundles as $name => $namespace) { + if (0 !== strpos($method->class, $namespace)) { + continue; + } + + // controller notation (AcmeBundle:Foo:foo) + return $name.':'.$match[1].':'.$match[2]; + } + + return null; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/MethodMetadata.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/MethodMetadata.php new file mode 100644 index 0000000..6bec7ce --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Metadata/MethodMetadata.php @@ -0,0 +1,84 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Metadata; + +use Metadata\MethodMetadata as BaseMethodMetadata; + +/** + * Contains method metadata information + * + * @author Johannes M. Schmitt + */ +class MethodMetadata extends BaseMethodMetadata +{ + public $roles = array(); + public $paramPermissions = array(); + public $returnPermissions = array(); + public $runAsRoles = array(); + public $satisfiesParentSecurityPolicy = false; + + /** + * Adds a parameter restriction + * + * @param integer $index 0-based + * @param array $permissions + */ + public function addParamPermissions($index, array $permissions) + { + $this->paramPermissions[$index] = $permissions; + } + + public function isDeclaredOnInterface() + { + foreach ($this->reflection->getDeclaringClass()->getInterfaces() as $interface) { + if ($interface->hasMethod($this->name)) { + return true; + } + } + + return false; + } + + /** + * This allows to merge in metadata from an interface + * + * @param MethodMetadata $method + * @return void + */ + public function merge(MethodMetadata $method) + { + if (!$this->roles) { + $this->roles = $method->roles; + } + + if (!$this->returnPermissions) { + $this->returnPermissions = $method->returnPermissions; + } + + if (!$this->runAsRoles) { + $this->runAsRoles = $method->runAsRoles; + } + + foreach ($method->paramPermissions as $index => $permissions) { + if (!isset($this->paramPermissions[$index])) { + $this->paramPermissions[$index] = $permissions; + } + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/README b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/README new file mode 100644 index 0000000..72bab21 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/README @@ -0,0 +1,8 @@ +For documentation, see: + + Resources/doc + + +For license, see: + + Resources/meta/LICENSE \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/security_expressions.xml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/security_expressions.xml new file mode 100644 index 0000000..493e2ea --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/security_expressions.xml @@ -0,0 +1,84 @@ + + + + + + JMS\SecurityExtraBundle\Security\Acl\Expression\PermissionEvaluator + JMS\SecurityExtraBundle\Security\Acl\Expression\HasPermissionFunctionCompiler + + JMS\SecurityExtraBundle\Security\Authorization\Expression\LazyLoadingExpressionVoter + JMS\SecurityExtraBundle\Security\Authorization\Expression\ContainerAwareExpressionHandler + + JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler + JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression + + JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\ContainerAwareVariableCompiler + JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\ParameterExpressionCompiler + + JMS\SecurityExtraBundle\Metadata\Driver\ConfigDriver + + JMS\SecurityExtraBundle\Twig\SecurityExtension + + + + + + + + + + %kernel.bundles% + %security.access.method_access_control% + + + + + + + + + + + + + + + + + + + + security.expressions.compiler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/services.xml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/services.xml new file mode 100644 index 0000000..0ad446c --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/config/services.xml @@ -0,0 +1,99 @@ + + + + + + + + JMS\SecurityExtraBundle\Security\Authorization\Interception\MethodSecurityInterceptor + + + JMS\SecurityExtraBundle\Security\Authorization\RunAsManager + JMS\SecurityExtraBundle\Security\Authentication\Provider\RunAsAuthenticationProvider + RunAsToken + ROLE_ + + JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation\AfterInvocationManager + JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation\AclAfterInvocationProvider + + JMS\SecurityExtraBundle\Security\Authorization\Voter\IddqdVoter + + Metadata\MetadataFactory + Metadata\Driver\LazyLoadingDriver + Metadata\Driver\DriverChain + JMS\SecurityExtraBundle\Metadata\Driver\AnnotationDriver + Metadata\Cache\FileCache + + + + + %security.run_as.key% + %security.run_as.role_prefix% + + + + + + + + + + + + + + + %security.access.secure_all_services% + %security.access.method_access_control% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + security.extra.metadata_driver + + + + + + + + %security.extra.cache_dir% + %kernel.debug% + + + + + + \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/doc/index.rst b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/doc/index.rst new file mode 100644 index 0000000..8b41a2f --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/doc/index.rst @@ -0,0 +1,352 @@ +======== +Overview +======== + +This bundle enhances the Symfony2 Security Component by adding several new features. + +Features: + +- powerful expression-based authorization language +- method security authorization +- authorization configuration via annotations + +Installation +------------ +Add the following to your ``deps`` file:: + + [JMSSecurityExtraBundle] + git=https://github.com/schmittjoh/JMSSecurityExtraBundle.git + target=/bundles/JMS/SecurityExtraBundle + + ; Dependencies: + ;-------------- + [metadata] + git=https://github.com/schmittjoh/metadata.git + version=1.1.0 ; <- make sure to get 1.1, not 1.0 + + ; see https://github.com/schmittjoh/JMSAopBundle/blob/master/Resources/doc/index.rst + [JMSAopBundle] + git=https://github.com/schmittjoh/JMSAopBundle.git + target=/bundles/JMS/AopBundle + + [cg-library] + git=https://github.com/schmittjoh/cg-library.git + + ; This dependency is optional (you need it if you are using non-service controllers): + ; see https://github.com/schmittjoh/JMSDiExtraBundle/blob/master/Resources/doc/index.rst + [JMSDiExtraBundle] + git=https://github.com/schmittjoh/JMSDiExtraBundle.git + target=/bundles/JMS/DiExtraBundle + +Then register the bundle with your kernel:: + + // in AppKernel::registerBundles() + $bundles = array( + // ... + new JMS\AopBundle\JMSAopBundle(), + new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), + new JMS\DiExtraBundle\JMSDiExtraBundle($this), + // ... + ); + +Make sure that you also register the namespaces with the autoloader:: + + // app/autoload.php + $loader->registerNamespaces(array( + // ... + 'JMS' => __DIR__.'/../vendor/bundles', + 'Metadata' => __DIR__.'/../vendor/metadata/src', + 'CG' => __DIR__.'/../vendor/cg-library/src', + // ... + )); + +Configuration +------------- + +Below, you find the default configuration:: + + # app/config/config.yml + jms_security_extra: + # Whether you want to secure all services (true), or only secure specific + # services (false); see also below + secure_all_services: false + + # Enabling this setting will add an additional special attribute "IS_IDDQD". + # Anybody with this attribute will effectively bypass all security checks. + enable_iddqd_attribute: false + + # Enables expression language + expressions: false + + # Allows you to disable some, or all built-in voters + voters: + disable_authenticated: false + disable_role: false + disable_acl: false + + # Allows you to specify access control rules for specific methods, such + # as controller actions + method_access_control: { } + + +Expression-based Authorization Language +--------------------------------------- +The expression language is a very powerful alternative to the simple attributes +of the security voting system. They allow to perform complex access decision +checks, and because they are compiled down to raw PHP, they are much faster than +the built-in voters. Also they are lazy-loading by nature, so you will also +save some resources for example by not having to initialize the entire ACL system +on each request. + +Programmatic Usage +~~~~~~~~~~~~~~~~~~ +You can execute expressions programmatically by using the ``isGranted`` method +of the SecurityContext. Some examples:: + + use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression; + + $securityContext->isGranted(array(new Expression('hasRole("A")'))); + $securityContext->isGranted(array(new Expression('hasRole("A") or (hasRole("B") and hasRole("C"))'))); + $securityContext->isGranted(array(new Expression('hasPermission(object, "VIEW")'), $object)); + $securityContext->isGranted(array(new Expression('token.getUsername() == "Johannes"'))); + +Twig Usage +~~~~~~~~~~ +You can check expressions from Twig templates using the ``is_expr_granted`` +function. Some examples:: + + is_expr_granted("hasRole('FOO')") + is_expr_granted("hasPermission(object, 'VIEW')", object) + +Usage in Access Control +~~~~~~~~~~~~~~~~~~~~~~~ +You can also use expressions in the ``access_control``:: + + security: + access_control: + - { path: ^/foo, access: "hasRole('FOO') and hasRole('BAR')" } + +Annotation-based Usage +~~~~~~~~~~~~~~~~~~~~~~ +see @PreAuthorize in the annotation reference + +Reference +~~~~~~~~~ ++-----------------------------------+--------------------------------------------+ +| Expression | Description | ++===================================+============================================+ +| hasRole('ROLE') | Checks whether the token has a certain | +| | role. | ++-----------------------------------+--------------------------------------------+ +| hasAnyRole('ROLE1', 'ROLE2', ...) | Checks whether the token has any of the | +| | given roles. | ++-----------------------------------+--------------------------------------------+ +| isAnonymous() | Checks whether the token is anonymous. | ++-----------------------------------+--------------------------------------------+ +| isRememberMe() | Checks whether the token is remember me. | ++-----------------------------------+--------------------------------------------+ +| isFullyAuthenticated() | Checks whether the token is fully | +| | authenticated. | ++-----------------------------------+--------------------------------------------+ +| isAuthenticated() | Checks whether the token is not anonymous. | ++-----------------------------------+--------------------------------------------+ +| hasPermission(*var*, 'PERMISSION')| Checks whether the token has the given | +| | permission for the given object (requires | +| | the ACL system). | ++-----------------------------------+--------------------------------------------+ +| token | Variable that refers to the token | +| | which is currently in the security context.| ++-----------------------------------+--------------------------------------------+ +| user | Variable that refers to the user | +| | which is currently in the security context.| ++-----------------------------------+--------------------------------------------+ +| object | Variable that refers to the object for | +| | which access is being requested. | ++-----------------------------------+--------------------------------------------+ +| #*paramName* | Any identifier prefixed with # refers to | +| | a parameter of the same name that is passed| +| | to the method where the expression is used.| ++-----------------------------------+--------------------------------------------+ +| and / && | Binary "and" operator | ++-----------------------------------+--------------------------------------------+ +| or / || | Binary "or" operator | ++-----------------------------------+--------------------------------------------+ +| == | Binary "is equal" operator | ++-----------------------------------+--------------------------------------------+ +| not / ! | Negation operator | ++-----------------------------------+--------------------------------------------+ + +Method Security Authorization +----------------------------- +Generally, you can secure all public, or protected methods which are non-static, +and non-final. Private methods cannot be secured. You can also add metadata for +abstract methods, or interfaces which will then be applied to their concrete +implementations automatically. + +Access Control via DI configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +You can specify access control **expressions** in the DI configuration:: + + # config.yml + jms_security_extra: + method_access_control: + ':loginAction$': 'isAnonymous()' + 'AcmeFooBundle:.*:deleteAction': 'hasRole("ROLE_ADMIN")' + '^MyNamespace\MyService::foo$': 'hasPermission(#user, "VIEW")' + +The pattern is a case-sensitive regular expression which is matched against two notations. +The first match is being used. + +First, your pattern is matched against the notation for non-service controllers. +This obviously is only done if your class is actually a controller, e.g. +``AcmeFooBundle:Add:new`` for a controller named ``AddController`` and a method +named ``newAction`` in a sub-namespace ``Controller`` in a bundle named ``AcmeFooBundle``. + +Last, your pattern is matched against the concatenation of the class name, and +the method name that is being called, e.g. ``My\Fully\Qualified\ClassName::myMethodName``. + +**Note:** If you would like to secure non-service controllers, the +``JMSDiExtraBundle`` must be installed. + +Access Control via Annotations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If you like to secure a service with annotations, you need to enable annotation +configuration for this service:: + + + + + +In case, you like to configure all services via annotations, you can also set +``secure_all_services`` to true. Then, you do not need to add a tag for each +service. + + +Annotations +----------- +@PreAuthorize +~~~~~~~~~~~~~ +This annotation lets you define an expression (see the expression language +paragraph) which is executed prior to invoking a method:: + + myPrivateService->aMethodOnlyToBeInvokedThroughASpecificChannel(); + } + } + +@SatisfiesParentSecurityPolicy +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This must be defined on a method that overrides a method which has security metadata. +It is there to ensure that you are aware the security of the overridden method cannot +be enforced anymore, and that you must copy over all annotations if you want to keep +them. diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/meta/LICENSE b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/meta/LICENSE new file mode 100644 index 0000000..753842b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Resources/meta/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/HasPermissionFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/HasPermissionFunctionCompiler.php new file mode 100644 index 0000000..340617b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/HasPermissionFunctionCompiler.php @@ -0,0 +1,63 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Acl\Expression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ConstantExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func\FunctionCompilerInterface; + +class HasPermissionFunctionCompiler implements FunctionCompilerInterface +{ + public function getName() + { + return 'hasPermission'; + } + + public function compilePreconditions(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler->verifyItem('token', 'Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + } + + public function compile(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler + ->compileInternal(new VariableExpression('permission_evaluator')) + ->write('->hasPermission(') + ->compileInternal(new VariableExpression('token')) + ->write(', ') + ->compileInternal($function->args[0]) + ->write(', ') + ; + + if ($function->args[1] instanceof ConstantExpression) { + $compiler->write(var_export(strtoupper($function->args[1]->value), true).')'); + + return; + } + + $compiler + ->write('strtoupper(') + ->compileInternal($function->args[1]) + ->write('))') + ; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/PermissionEvaluator.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/PermissionEvaluator.php new file mode 100644 index 0000000..96111fc --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Expression/PermissionEvaluator.php @@ -0,0 +1,122 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Acl\Expression; + +use Symfony\Component\Security\Acl\Exception\NoAceFoundException; +use Symfony\Component\Security\Acl\Exception\AclNotFoundException; +use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; +use Symfony\Component\Security\Acl\Permission\PermissionMapInterface; +use Symfony\Component\Security\Acl\Model\AclProviderInterface; +use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface; +use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; +use Symfony\Component\HttpKernel\Log\LoggerInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +class PermissionEvaluator +{ + private $aclProvider; + private $oidRetrievalStrategy; + private $sidRetrievalStrategy; + private $permissionMap; + private $allowIfObjectIdentityUnavailable; + private $logger; + + public function __construct(AclProviderInterface $aclProvider, + ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, + SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy, + PermissionMapInterface $permissionMap, + $allowIfObjectIdentityUnavailable = true, + LoggerInterface $logger = null) + { + $this->aclProvider = $aclProvider; + $this->oidRetrievalStrategy = $oidRetrievalStrategy; + $this->sidRetrievalStrategy = $sidRetrievalStrategy; + $this->permissionMap = $permissionMap; + $this->allowIfObjectIdentityUnavailable = $allowIfObjectIdentityUnavailable; + $this->logger = $logger; + } + + public function hasPermission(TokenInterface $token, $object, $permission) + { + if (null === $masks = $this->permissionMap->getMasks($permission, $object)) { + return false; + } + + if (null === $object) { + if (null !== $this->logger) { + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + } + + return $this->allowIfObjectIdentityUnavailable ? true : false; + } else if ($object instanceof FieldVote) { + $field = $object->getField(); + $object = $object->getDomainObject(); + } else { + $field = null; + } + + if ($object instanceof ObjectIdentityInterface) { + $oid = $object; + } else if (null === $oid = $this->oidRetrievalStrategy->getObjectIdentity($object)) { + if (null !== $this->logger) { + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + } + + return $this->allowIfObjectIdentityUnavailable ? true : false; + } + + $sids = $this->sidRetrievalStrategy->getSecurityIdentities($token); + + try { + $acl = $this->aclProvider->findAcl($oid, $sids); + + if (null === $field && $acl->isGranted($masks, $sids, false)) { + if (null !== $this->logger) { + $this->logger->debug('ACL found, permission granted. Voting to grant access'); + } + + return true; + } else if (null !== $field && $acl->isFieldGranted($field, $masks, $sids, false)) { + if (null !== $this->logger) { + $this->logger->debug('ACL found, permission granted. Voting to grant access'); + } + + return true; + } + + if (null !== $this->logger) { + $this->logger->debug('ACL found, insufficient permissions. Voting to deny access.'); + } + + return false; + } catch (AclNotFoundException $noAcl) { + if (null !== $this->logger) { + $this->logger->debug('No ACL found for the object identity. Voting to deny access.'); + } + + return false; + } catch (NoAceFoundException $noAce) { + if (null !== $this->logger) { + $this->logger->debug('ACL found, no ACE applicable. Voting to deny access.'); + } + + return false; + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Voter/AclVoter.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Voter/AclVoter.php new file mode 100644 index 0000000..bad27d8 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Acl/Voter/AclVoter.php @@ -0,0 +1,136 @@ + + */ +class AclVoter implements VoterInterface +{ + private $aclProvider; + private $permissionMap; + private $objectIdentityRetrievalStrategy; + private $securityIdentityRetrievalStrategy; + private $allowIfObjectIdentityUnavailable; + private $logger; + + public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy, PermissionMapInterface $permissionMap, LoggerInterface $logger = null, $allowIfObjectIdentityUnavailable = true) + { + $this->aclProvider = $aclProvider; + $this->permissionMap = $permissionMap; + $this->objectIdentityRetrievalStrategy = $oidRetrievalStrategy; + $this->securityIdentityRetrievalStrategy = $sidRetrievalStrategy; + $this->logger = $logger; + $this->allowIfObjectIdentityUnavailable = $allowIfObjectIdentityUnavailable; + } + + public function supportsAttribute($attribute) + { + return $this->permissionMap->contains($attribute); + } + + public function vote(TokenInterface $token, $object, array $attributes) + { + foreach ($attributes as $attribute) { + if (null === $masks = $this->permissionMap->getMasks((string) $attribute, $object)) { + continue; + } + + if (null === $object) { + if (null !== $this->logger) { + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + } + + return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; + } else if ($object instanceof FieldVote) { + $field = $object->getField(); + $object = $object->getDomainObject(); + } else { + $field = null; + } + + if ($object instanceof ObjectIdentityInterface) { + $oid = $object; + } else if (null === $oid = $this->objectIdentityRetrievalStrategy->getObjectIdentity($object)) { + if (null !== $this->logger) { + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + } + + return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; + } + + if (!$this->supportsClass($oid->getType())) { + return self::ACCESS_ABSTAIN; + } + + $sids = $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token); + + try { + $acl = $this->aclProvider->findAcl($oid, $sids); + + if (null === $field && $acl->isGranted($masks, $sids, false)) { + if (null !== $this->logger) { + $this->logger->debug('ACL found, permission granted. Voting to grant access'); + } + + return self::ACCESS_GRANTED; + } else if (null !== $field && $acl->isFieldGranted($field, $masks, $sids, false)) { + if (null !== $this->logger) { + $this->logger->debug('ACL found, permission granted. Voting to grant access'); + } + + return self::ACCESS_GRANTED; + } + + if (null !== $this->logger) { + $this->logger->debug('ACL found, insufficient permissions. Voting to deny access.'); + } + + return self::ACCESS_DENIED; + } catch (AclNotFoundException $noAcl) { + if (null !== $this->logger) { + $this->logger->debug('No ACL found for the object identity. Voting to deny access.'); + } + + return self::ACCESS_DENIED; + } catch (NoAceFoundException $noAce) { + if (null !== $this->logger) { + $this->logger->debug('ACL found, no ACE applicable. Voting to deny access.'); + } + + return self::ACCESS_DENIED; + } + } + + // no attribute was supported + return self::ACCESS_ABSTAIN; + } + + /** + * You can override this method when writing a voter for a specific domain + * class. + * + * @param string $class The class name + * + * @return Boolean + */ + public function supportsClass($class) + { + return true; + } +} diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Provider/RunAsAuthenticationProvider.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Provider/RunAsAuthenticationProvider.php new file mode 100644 index 0000000..6958805 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Provider/RunAsAuthenticationProvider.php @@ -0,0 +1,57 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authentication\Provider; + +use Symfony\Component\Security\Core\Exception\BadCredentialsException; +use JMS\SecurityExtraBundle\Security\Authentication\Token\RunAsUserToken; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface; + +/** + * Class which authenticates RunAsTokens. + * + * @author Johannes M. Schmitt + */ +class RunAsAuthenticationProvider implements AuthenticationProviderInterface +{ + private $key; + + public function __construct($key) + { + $this->key = $key; + } + + public function authenticate(TokenInterface $token) + { + if (!$this->supports($token)) { + return null; + } + + if ($token->getKey() === $this->key) { + return $token; + } else { + throw new BadCredentialsException('The keys do not match.'); + } + } + + public function supports(TokenInterface $token) + { + return $token instanceof RunAsUserToken; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Token/RunAsUserToken.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Token/RunAsUserToken.php new file mode 100644 index 0000000..0672f2a --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authentication/Token/RunAsUserToken.php @@ -0,0 +1,85 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authentication\Token; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; + +/** + * This token is automatically generated by the RunAsManager when an invocation + * is supposed to be run with a different Token. + * + * @author Johannes M. Schmitt + */ +class RunAsUserToken extends AbstractToken +{ + private $originalToken; + private $key; + private $credentials; + + public function __construct($key, $user, $credentials, array $roles, TokenInterface $originalToken) + { + parent::__construct($roles); + + $this->originalToken = $originalToken; + $this->credentials = $credentials; + $this->key = $key; + + $this->setUser($user); + $this->setAuthenticated(true); + } + + public function getKey() + { + return $this->key; + } + + public function getOriginalToken() + { + return $this->originalToken; + } + + public function getCredentials() + { + return $this->credentials; + } + + public function eraseCredentials() + { + parent::eraseCredentials(); + + $this->credentials = null; + } + + public function serialize() + { + return serialize(array( + $this->originalToken, + $this->key, + $this->credentials, + parent::serialize(), + )); + } + + public function unserialize($str) + { + list($this->originalToken, $this->key, $this->credentials, $parentStr) = unserialize($str); + parent::unserialize($parentStr); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AclAfterInvocationProvider.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AclAfterInvocationProvider.php new file mode 100644 index 0000000..a004e92 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AclAfterInvocationProvider.php @@ -0,0 +1,111 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation; + +use Symfony\Component\HttpKernel\Log\LoggerInterface; +use Symfony\Component\Security\Acl\Exception\AclNotFoundException; +use Symfony\Component\Security\Acl\Exception\NoAceFoundException; +use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface; +use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; +use Symfony\Component\Security\Acl\Model\AclProviderInterface; +use Symfony\Component\Security\Acl\Permission\PermissionMapInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; + +/** + * This after invocation provider filters returned objects based on ACLs. + * + * @author Johannes M. Schmitt + */ +class AclAfterInvocationProvider implements AfterInvocationProviderInterface +{ + private $aclProvider; + private $oidRetrievalStrategy; + private $sidRetrievalStrategy; + private $permissionMap; + private $logger; + + public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy, PermissionMapInterface $permissionMap, LoggerInterface $logger = null) + { + $this->aclProvider = $aclProvider; + $this->oidRetrievalStrategy = $oidRetrievalStrategy; + $this->sidRetrievalStrategy = $sidRetrievalStrategy; + $this->permissionMap = $permissionMap; + $this->logger = $logger; + } + + public function decide(TokenInterface $token, $secureObject, array $attributes, $returnedObject) + { + if (null === $returnedObject) { + if (null !== $this->logger) { + $this->logger->debug('Returned object was null, skipping security check.'); + } + + return null; + } + + foreach ($attributes as $attribute) { + if (!$this->supportsAttribute($attribute)) { + continue; + } + + if (null === $oid = $this->oidRetrievalStrategy->getObjectIdentity($returnedObject)) { + if (null !== $this->logger) { + $this->logger->debug('Returned object was no domain object, skipping security check.'); + } + + return $returnedObject; + } + + $sids = $this->sidRetrievalStrategy->getSecurityIdentities($token); + + try { + $acl = $this->aclProvider->findAcl($oid, $sids); + if ($acl->isGranted($this->permissionMap->getMasks($attribute, $returnedObject), $sids, false)) { + return $returnedObject; + } + + if (null !== $this->logger) { + $this->logger->debug('Token has been denied access for returned object.'); + } + } catch (AclNotFoundException $noAcl) { + throw new AccessDeniedException('No applicable ACL found for domain object.'); + } catch (NoAceFoundException $noAce) { + if (null !== $this->logger) { + $this->logger->debug('No applicable ACE found for the given Token, denying access.'); + } + } + + throw new AccessDeniedException('ACL has denied access for attribute: '.$attribute); + } + + // no attribute was supported + return $returnedObject; + } + + public function supportsAttribute($attribute) + { + return $this->permissionMap->contains($attribute); + } + + public function supportsClass($className) + { + return true; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManager.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManager.php new file mode 100644 index 0000000..88beeae --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManager.php @@ -0,0 +1,77 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +/** + * This is the pendant to the AccessDecisionManager which is used to make + * access decisions after a method has been executed. + * + * @author Johannes M. Schmitt + */ +class AfterInvocationManager implements AfterInvocationManagerInterface +{ + private $providers; + + public function __construct(array $providers) + { + $this->providers = $providers; + } + + /** + * {@inheritDoc} + */ + public function decide(TokenInterface $token, $secureInvocation, array $attributes, $returnedObject) + { + foreach ($this->providers as $provider) { + $returnedObject = $provider->decide($token, $secureInvocation, $attributes, $returnedObject); + } + + return $returnedObject; + } + + /** + * {@inheritDoc} + */ + public function supportsAttribute($attribute) + { + foreach ($this->providers as $provider) { + if (true === $provider->supportsAttribute($attribute)) { + return true; + } + } + + return false; + } + + /** + * {@inheritDoc} + */ + public function supportsClass($className) + { + foreach ($this->providers as $provider) { + if (true === $provider->supportsClass($className)) { + return true; + } + } + + return false; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManagerInterface.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManagerInterface.php new file mode 100644 index 0000000..c02ec50 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationManagerInterface.php @@ -0,0 +1,56 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +/** + * AfterInvocationManagerInterface + * + * @author Johannes M. Schmitt + */ +interface AfterInvocationManagerInterface +{ + /** + * Makes an access decision after the invocation of a method + * + * @param TokenInterface $token + * @param object $secureObject + * @param array $attributes + * @param mixed $returnedValue the value that was returned by the method invocation + * @return mixed the filter return value + */ + function decide(TokenInterface $token, $secureObject, array $attributes, $returnedValue); + + /** + * Determines whether the given attribute is supported + * + * @param string $attribute + * @return Boolean + */ + function supportsAttribute($attribute); + + /** + * Determines whether the given class is supported + * + * @param string $className the class of the secure object + * @return Boolean + */ + function supportsClass($className); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationProviderInterface.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationProviderInterface.php new file mode 100644 index 0000000..e75466b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/AfterInvocation/AfterInvocationProviderInterface.php @@ -0,0 +1,33 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +/** + * AfterInvocationProviderInterface + * + * @author Johannes M. Schmitt + */ +interface AfterInvocationProviderInterface +{ + function decide(TokenInterface $token, $secureObject, array $attributes, $returnedObject); + function supportsAttribute($attribute); + function supportsClass($className); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/AndExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/AndExpression.php new file mode 100644 index 0000000..e01d396 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/AndExpression.php @@ -0,0 +1,31 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class AndExpression implements ExpressionInterface +{ + public $left; + public $right; + + public function __construct(ExpressionInterface $left, ExpressionInterface $right) + { + $this->left = $left; + $this->right = $right; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ArrayExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ArrayExpression.php new file mode 100644 index 0000000..cb039bf --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ArrayExpression.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class ArrayExpression implements ExpressionInterface +{ + public $elements; + + public function __construct(array $elements) + { + $this->elements = $elements; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ConstantExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ConstantExpression.php new file mode 100644 index 0000000..963f1ed --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ConstantExpression.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class ConstantExpression implements ExpressionInterface +{ + public $value; + + public function __construct($value) + { + $this->value = $value; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ExpressionInterface.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ExpressionInterface.php new file mode 100644 index 0000000..91af129 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ExpressionInterface.php @@ -0,0 +1,23 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +interface ExpressionInterface +{ +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/FunctionExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/FunctionExpression.php new file mode 100644 index 0000000..5e52e98 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/FunctionExpression.php @@ -0,0 +1,32 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class FunctionExpression implements ExpressionInterface +{ + /** READ-ONLY */ + public $name; + public $args; + + public function __construct($name, array $args) + { + $this->name = $name; + $this->args = $args; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetItemExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetItemExpression.php new file mode 100644 index 0000000..2df5eb0 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetItemExpression.php @@ -0,0 +1,31 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class GetItemExpression +{ + public $array; + public $key; + + public function __construct(ExpressionInterface $array, ExpressionInterface $key) + { + $this->array = $array; + $this->key = $key; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetPropertyExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetPropertyExpression.php new file mode 100644 index 0000000..fe070ab --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/GetPropertyExpression.php @@ -0,0 +1,31 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class GetPropertyExpression implements ExpressionInterface +{ + public $object; + public $name; + + public function __construct(ExpressionInterface $obj, $name) + { + $this->object = $obj; + $this->name = $name; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/IsEqualExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/IsEqualExpression.php new file mode 100644 index 0000000..89f83f7 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/IsEqualExpression.php @@ -0,0 +1,31 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class IsEqualExpression implements ExpressionInterface +{ + public $left; + public $right; + + public function __construct(ExpressionInterface $left, ExpressionInterface $right) + { + $this->left = $left; + $this->right = $right; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/MethodCallExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/MethodCallExpression.php new file mode 100644 index 0000000..22f3274 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/MethodCallExpression.php @@ -0,0 +1,33 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class MethodCallExpression implements ExpressionInterface +{ + public $object; + public $method; + public $args; + + public function __construct(ExpressionInterface $obj, $method, array $args) + { + $this->object = $obj; + $this->method = $method; + $this->args = $args; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/NotExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/NotExpression.php new file mode 100644 index 0000000..aa730c0 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/NotExpression.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class NotExpression implements ExpressionInterface +{ + public $expr; + + public function __construct(ExpressionInterface $expr) + { + $this->expr = $expr; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/OrExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/OrExpression.php new file mode 100644 index 0000000..a3d1f03 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/OrExpression.php @@ -0,0 +1,31 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class OrExpression implements ExpressionInterface +{ + public $left; + public $right; + + public function __construct(ExpressionInterface $left, ExpressionInterface $right) + { + $this->left = $left; + $this->right = $right; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ParameterExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ParameterExpression.php new file mode 100644 index 0000000..f382e5c --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/ParameterExpression.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class ParameterExpression implements ExpressionInterface +{ + public $name; + + public function __construct($name) + { + $this->name = $name; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/VariableExpression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/VariableExpression.php new file mode 100644 index 0000000..c48c02e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Ast/VariableExpression.php @@ -0,0 +1,31 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast; + +class VariableExpression implements ExpressionInterface +{ + public $name; + public $allowNull; + + public function __construct($name, $allowNull = false) + { + $this->name = $name; + $this->allowNull = $allowNull; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/AndExpressionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/AndExpressionCompiler.php new file mode 100644 index 0000000..e488a32 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/AndExpressionCompiler.php @@ -0,0 +1,32 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +class AndExpressionCompiler extends BinaryExprCompiler +{ + public function getType() + { + return 'JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\AndExpression'; + } + + protected function getOperator() + { + return '&&'; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/BinaryExprCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/BinaryExprCompiler.php new file mode 100644 index 0000000..0dcd154 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/BinaryExprCompiler.php @@ -0,0 +1,51 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +/** + * Base Compiler for Binary Operators. + * + * @author Johannes M. Schmitt + */ +abstract class BinaryExprCompiler implements TypeCompilerInterface +{ + public function compilePreconditions(ExpressionCompiler $compiler, ExpressionInterface $expr) + { + $compiler + ->compilePreconditions($expr->left) + ->compilePreconditions($expr->right) + ; + } + + public function compile(ExpressionCompiler $compiler, ExpressionInterface $expr) + { + $compiler + ->write("(") + ->compileInternal($expr->left) + ->write(") ".$this->getOperator()." (") + ->compileInternal($expr->right) + ->write(")") + ; + } + + abstract protected function getOperator(); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ContainerAwareVariableCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ContainerAwareVariableCompiler.php new file mode 100644 index 0000000..809ffc2 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ContainerAwareVariableCompiler.php @@ -0,0 +1,60 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\VariableExpressionCompiler; + +class ContainerAwareVariableCompiler extends VariableExpressionCompiler +{ + private $serviceMap = array(); + private $parameterMap = array(); + + public function setMaps(array $serviceMap, array $parameterMap) + { + $this->serviceMap = $serviceMap; + $this->parameterMap = $parameterMap; + } + + public function compile(ExpressionCompiler $compiler, ExpressionInterface $expr) + { + if (isset($this->serviceMap[$expr->name])) { + $compiler->write("\$context['container']->get('{$this->serviceMap[$expr->name]}'"); + + if ($expr->allowNull) { + $compiler->write(", ".ContainerInterface::NULL_ON_INVALID_REFERENCE); + } + + $compiler->write(")"); + + return; + } + + if (isset($this->parameterMap[$expr->name])) { + $compiler->write("\$context['container']->getParameter('{$this->parameterMap[$expr->name]}')"); + + return; + } + + parent::compile($compiler, $expr); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/AuthenticationTrustFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/AuthenticationTrustFunctionCompiler.php new file mode 100644 index 0000000..aa98f6c --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/AuthenticationTrustFunctionCompiler.php @@ -0,0 +1,35 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +abstract class AuthenticationTrustFunctionCompiler implements FunctionCompilerInterface +{ + public function compilePreconditions(ExpressionCompiler $compiler, FunctionExpression $function) + { + if (!empty($function->args)) { + throw new InvalidArgumentException(sprintf('The '.$this->getName().'() function does not accept any arguments, but got "%s".', var_export($function->args, true))); + } + + $compiler->verifyItem('token', 'Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/FunctionCompilerInterface.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/FunctionCompilerInterface.php new file mode 100644 index 0000000..b364f0b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/FunctionCompilerInterface.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +interface FunctionCompilerInterface +{ + function getName(); + function compilePreconditions(ExpressionCompiler $compiler, FunctionExpression $function); + function compile(ExpressionCompiler $compiler, FunctionExpression $function); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasAnyRoleFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasAnyRoleFunctionCompiler.php new file mode 100644 index 0000000..02e71fa --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasAnyRoleFunctionCompiler.php @@ -0,0 +1,63 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class HasAnyRoleFunctionCompiler implements FunctionCompilerInterface +{ + private $rolesExpr; + + public function getName() + { + return 'hasAnyRole'; + } + + public function compilePreconditions(ExpressionCompiler $compiler, FunctionExpression $function) + { + if (0 === count($function->args)) { + throw new RuntimeException('The function hasAnyRole() expects at least one argument, but got none.'); + } + + $this->rolesExpr = $compiler->getRolesExpr(); + } + + public function compile(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler->write("("); + + $first = true; + foreach ($function->args as $arg) { + if (!$first) { + $compiler->write(" || "); + } + $first = false; + + $compiler + ->write("isset({$this->rolesExpr}[") + ->compileInternal($arg) + ->write("])") + ; + } + + $compiler->write(")"); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasRoleFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasRoleFunctionCompiler.php new file mode 100644 index 0000000..77a9834 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/HasRoleFunctionCompiler.php @@ -0,0 +1,51 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class HasRoleFunctionCompiler implements FunctionCompilerInterface +{ + private $rolesExpr; + + public function getName() + { + return 'hasRole'; + } + + public function compilePreconditions(ExpressionCompiler $compiler, FunctionExpression $function) + { + if (1 !== count($function->args)) { + throw new RuntimeException(sprintf('The hasRole() function expects exactly one argument, but got "%s".', var_export($function->args, true))); + } + + $this->rolesExpr = $compiler->getRolesExpr(); + } + + public function compile(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler + ->write("isset({$this->rolesExpr}[") + ->compileInternal($function->args[0]) + ->write("])") + ; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAnonymousFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAnonymousFunctionCompiler.php new file mode 100644 index 0000000..412825d --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAnonymousFunctionCompiler.php @@ -0,0 +1,39 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class IsAnonymousFunctionCompiler extends AuthenticationTrustFunctionCompiler +{ + public function getName() + { + return 'isAnonymous'; + } + + public function compile(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler + ->compileInternal(new VariableExpression('trust_resolver')) + ->write("->isAnonymous(\$context['token'])"); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAuthenticatedFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAuthenticatedFunctionCompiler.php new file mode 100644 index 0000000..ead97d8 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsAuthenticatedFunctionCompiler.php @@ -0,0 +1,41 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class IsAuthenticatedFunctionCompiler extends AuthenticationTrustFunctionCompiler +{ + public function getName() + { + return 'isAuthenticated'; + } + + public function compile(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler + ->write("!") + ->compileInternal(new VariableExpression('trust_resolver')) + ->write("->isAnonymous(\$context['token'])") + ; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsFullyAuthenticatedFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsFullyAuthenticatedFunctionCompiler.php new file mode 100644 index 0000000..366ef07 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsFullyAuthenticatedFunctionCompiler.php @@ -0,0 +1,39 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class IsFullyAuthenticatedFunctionCompiler extends AuthenticationTrustFunctionCompiler +{ + public function getName() + { + return 'isFullyAuthenticated'; + } + + public function compile(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler + ->compileInternal(new VariableExpression('trust_resolver')) + ->write("->isFullFledged(\$context['token'])"); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsRememberMeFunctionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsRememberMeFunctionCompiler.php new file mode 100644 index 0000000..cbba7c8 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/Func/IsRememberMeFunctionCompiler.php @@ -0,0 +1,39 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class IsRememberMeFunctionCompiler extends AuthenticationTrustFunctionCompiler +{ + public function getName() + { + return 'isRememberMe'; + } + + public function compile(ExpressionCompiler $compiler, FunctionExpression $function) + { + $compiler + ->compileInternal(new VariableExpression('trust_resolver')) + ->write("->isRememberMe(\$context['token'])"); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/IsEqualExpressionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/IsEqualExpressionCompiler.php new file mode 100644 index 0000000..93a8b23 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/IsEqualExpressionCompiler.php @@ -0,0 +1,32 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +class IsEqualExpressionCompiler extends BinaryExprCompiler +{ + public function getType() + { + return 'JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\IsEqualExpression'; + } + + protected function getOperator() + { + return '==='; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/NotExpressionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/NotExpressionCompiler.php new file mode 100644 index 0000000..1fccae8 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/NotExpressionCompiler.php @@ -0,0 +1,44 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; + +class NotExpressionCompiler implements TypeCompilerInterface +{ + public function getType() + { + return 'JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\NotExpression'; + } + + public function compilePreconditions(ExpressionCompiler $compiler, ExpressionInterface $expr) + { + $compiler->compilePreconditions($expr->expr); + } + + public function compile(ExpressionCompiler $compiler, ExpressionInterface $expr) + { + $compiler + ->write('!(') + ->compileInternal($expr->expr) + ->write(')') + ; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/OrExpressionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/OrExpressionCompiler.php new file mode 100644 index 0000000..4a4554e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/OrExpressionCompiler.php @@ -0,0 +1,32 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +class OrExpressionCompiler extends BinaryExprCompiler +{ + public function getType() + { + return 'JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\OrExpression'; + } + + protected function getOperator() + { + return '||'; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ParameterExpressionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ParameterExpressionCompiler.php new file mode 100644 index 0000000..678a119 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/ParameterExpressionCompiler.php @@ -0,0 +1,80 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\TypeCompilerInterface; + +class ParameterExpressionCompiler implements TypeCompilerInterface +{ + public function getType() + { + return 'JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ParameterExpression'; + } + + public function compilePreconditions(ExpressionCompiler $compiler, ExpressionInterface $parameter) + { + $compiler->verifyItem('object', 'CG\Proxy\MethodInvocation'); + + if (!isset($compiler->attributes['parameter_mapping_name'])) { + $this->addParameterMapping($compiler); + } + + $compiler + ->writeln("if (!isset(\${$compiler->attributes['parameter_mapping_name']}['{$parameter->name}'])) {") + ->indent() + ->write("throw new RuntimeException(sprintf('There is no parameter with name \"{$parameter->name}\" for method \"%s\".', ") + ->compileInternal(new VariableExpression('object')) + ->writeln("));") + ->outdent() + ->write("}\n\n") + ; + } + + public function compile(ExpressionCompiler $compiler, ExpressionInterface $parameter) + { + $compiler + ->compileInternal(new VariableExpression('object')) + ->write("->arguments[") + ->write("\${$compiler->attributes['parameter_mapping_name']}") + ->write("['{$parameter->name}']]") + ; + } + + private function addParameterMapping(ExpressionCompiler $compiler) + { + $name = $compiler->nextName(); + $indexName = $compiler->nextName(); + $paramName = $compiler->nextName(); + + $compiler + ->setAttribute('parameter_mapping_name', $name) + ->writeln("\$$name = array();") + ->write("foreach (") + ->compileInternal(new VariableExpression('object')) + ->writeln("->reflection->getParameters() as \$$indexName => \$$paramName) {") + ->indent() + ->writeln("\${$name}[\${$paramName}->name] = \$$indexName;") + ->outdent() + ->writeln("}\n") + ; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/TypeCompilerInterface.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/TypeCompilerInterface.php new file mode 100644 index 0000000..949a631 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/TypeCompilerInterface.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +interface TypeCompilerInterface +{ + function getType(); + function compilePreconditions(ExpressionCompiler $compiler, ExpressionInterface $expr); + function compile(ExpressionCompiler $compiler, ExpressionInterface $expr); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/VariableExpressionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/VariableExpressionCompiler.php new file mode 100644 index 0000000..ad1841c --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Compiler/VariableExpressionCompiler.php @@ -0,0 +1,74 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class VariableExpressionCompiler implements TypeCompilerInterface +{ + public function getType() + { + return 'JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression'; + } + + public function compilePreconditions(ExpressionCompiler $compiler, ExpressionInterface $expr) + { + if ('user' === $expr->name) { + $compiler + ->setAttribute('user_var_name', $name = $compiler->nextName()) + ->write("\$$name = ") + ->compileInternal(new VariableExpression('token')) + ->write("->getUser();\n\n") + ; + } + } + + public function compile(ExpressionCompiler $compiler, ExpressionInterface $expr) + { + if ('permitAll' === $expr->name) { + $compiler->write('true'); + + return; + } + + if ('denyAll' === $expr->name) { + $compiler->write('false'); + + return; + } + + if ('user' === $expr->name) { + $compiler->write("\${$compiler->attributes['user_var_name']}"); + + return; + } + + if ($expr->allowNull) { + $compiler->write("(isset(\$context['{$expr->name}']) ? "); + } + + $compiler->write("\$context['{$expr->name}']"); + + if ($expr->allowNull) { + $compiler->write(" : null)"); + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ContainerAwareExpressionHandler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ContainerAwareExpressionHandler.php new file mode 100644 index 0000000..f2d29af --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ContainerAwareExpressionHandler.php @@ -0,0 +1,47 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionHandlerInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Lazy-loading container aware expression handler. + * + * @author Johannes M. Schmitt + */ +class ContainerAwareExpressionHandler implements ExpressionHandlerInterface +{ + private $container; + + public function __construct(ContainerInterface $container) + { + $this->container = $container; + } + + public function createContext(TokenInterface $token, $object) + { + return array( + 'container' => $this->container, + 'token' => $token, + 'object' => $object, + ); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/DefaultExpressionHandler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/DefaultExpressionHandler.php new file mode 100644 index 0000000..70e4e13 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/DefaultExpressionHandler.php @@ -0,0 +1,51 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; +use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +class DefaultExpressionHandler implements ExpressionHandlerInterface +{ + private $trustResolver; + private $roleHierarchy; + + public function __construct(AuthenticationTrustResolverInterface $trustResolver, + RoleHierarchyInterface $roleHierarchy = null) + { + $this->trustResolver = $trustResolver; + $this->roleHierarchy = $roleHierarchy; + } + + public function createContext(TokenInterface $token, $object) + { + $context = array( + 'token' => $token, + 'object' => $object, + 'trust_resolver' => $this->trustResolver, + ); + + if (null !== $this->roleHierarchy) { + $context['role_hierarchy'] = $this->roleHierarchy; + } + + return $context; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Expression.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Expression.php new file mode 100644 index 0000000..219218d --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/Expression.php @@ -0,0 +1,40 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +final class Expression +{ + /** READ-ONLY */ + public $expression; + + public function __construct($expression) + { + $this->expression = $expression; + } + + public function getHashCode() + { + return sha1($this->expression); + } + + public function __toString() + { + return 'EXPRESSION('.$this->expression.')'; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionCompiler.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionCompiler.php new file mode 100644 index 0000000..fbfc69a --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionCompiler.php @@ -0,0 +1,395 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\TypeCompilerInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\IsEqualExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\Func\FunctionCompilerInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\OrExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\MethodCallExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\GetPropertyExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\GetItemExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ConstantExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ArrayExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\AndExpression; + +class ExpressionCompiler +{ + public $attributes = array(); + + private $indentationLevel = 0; + private $indentationSpaces = 4; + + private $nameCount = 0; + private $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + private $charCount = 52; + private $reservedNames = array('context' => true); + + private $itemExists = array(); + private $itemType = array(); + private $rolesName; + + private $code; + private $parser; + private $typeCompilers; + private $functionCompilers; + + public function __construct() + { + $this->addTypeCompiler(new Compiler\AndExpressionCompiler()); + $this->addTypeCompiler(new Compiler\IsEqualExpressionCompiler()); + $this->addTypeCompiler(new Compiler\OrExpressionCompiler()); + $this->addTypeCompiler(new Compiler\VariableExpressionCompiler()); + $this->addTypeCompiler(new Compiler\NotExpressionCompiler()); + + $this->functionCompilers = array( + 'isAnonymous' => new Compiler\Func\IsAnonymousFunctionCompiler(), + 'isAuthenticated' => new Compiler\Func\IsAuthenticatedFunctionCompiler(), + 'isRememberMe' => new Compiler\Func\IsRememberMeFunctionCompiler(), + 'isFullyAuthenticated' => new Compiler\Func\IsFullyAuthenticatedFunctionCompiler(), + 'hasRole' => new Compiler\Func\HasRoleFunctionCompiler(), + 'hasAnyRole' => new Compiler\Func\HasAnyRoleFunctionCompiler(), + ); + } + + public function setAttribute($name, $value) + { + $this->attributes[$name] = $value; + + return $this; + } + + public function addTypeCompiler(TypeCompilerInterface $compiler) + { + $this->typeCompilers[$compiler->getType()] = $compiler; + } + + public function addFunctionCompiler(FunctionCompilerInterface $compiler) + { + $this->functionCompilers[$compiler->getName()] = $compiler; + } + + public function compileExpression(Expression $expr) + { + return $this->compile($this->getParser()->parse($expr->expression), + $expr->expression); + } + + public function compile(ExpressionInterface $expr, $raw = null) + { + $this->nameCount = 0; + $this->code = ''; + $this->itemExists = $this->itemType = $this->attributes = array(); + $this->rolesName = null; + + if ($raw) { + $this->writeln('// Expression: '.$raw); + } + + $this + ->writeln('return function(array $context) {') + ->indent() + ->compilePreconditions($expr) + ->write('return ') + ->compileInternal($expr) + ->writeln(';') + ->outdent() + ->writeln('};') + ; + + return $this->code; + } + + public function indent() + { + $this->indentationLevel += 1; + + return $this; + } + + public function outdent() + { + $this->indentationLevel -= 1; + + if ($this->indentationLevel < 0) { + throw new RuntimeException('The identation level cannot be less than zero.'); + } + + return $this; + } + + public function writeln($content) + { + $this->write($content."\n"); + + return $this; + } + + public function getRolesExpr() + { + if (null !== $this->rolesName) { + return '$'.$this->rolesName; + } + + $this->verifyItem('token', 'Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + $this->rolesName = $rolesName = $this->nextName(); + $hierarchyName = $this->nextName(); + $tmpName = $this->nextName(); + $this + ->writeln("\$$rolesName = \$context['token']->getRoles();") + ->write("if (null !== \$$hierarchyName = ") + ->compileInternal(new VariableExpression('role_hierarchy', true)) + ->writeln(") {") + ->indent() + ->writeln("\$$rolesName = \${$hierarchyName}->getReachableRoles(\$$rolesName);") + ->outdent() + ->write("}\n\n") + ->writeln("\$$tmpName = array();") + ->writeln("foreach (\$$rolesName as \$role) {") + ->indent() + ->writeln("\${$tmpName}[\$role->getRole()] = true;") + ->outdent() + ->writeln("}") + ->write("\$$rolesName = \$$tmpName;\n\n") + ; + + return '$'.$rolesName; + } + + public function verifyItem($key, $expectedType = null) + { + if (!isset($this->itemExists[$key])) { + $this->itemExists[$key] = true; + + $this + ->writeln("if (!isset(\$context['$key'])) {") + ->indent() + ->writeln("throw new RuntimeException('The context contains no item with key \"$key\".');") + ->outdent() + ->write("}\n\n") + ; + } + + if (null !== $expectedType) { + if (isset($this->itemType[$key])) { + if ($this->itemType[$key] !== $expectedType) { + throw new RuntimeException(sprintf('Cannot verify that item "%s" is of type "%s" because it is already expected to be of type "%s".', + $key, $expectedType, $this->itemType[$key] + )); + } + + return $this; + } + + $this + ->writeln("if (!\$context['$key'] instanceof $expectedType) {") + ->indent() + ->writeln("throw new RuntimeException(sprintf('The item \"$key\" is expected to be of type \"$expectedType\", but got \"%s\".', get_class(\$context['$key'])));") + ->outdent() + ->write("}\n\n") + ; + } + + return $this; + } + + public function write($content) + { + $lines = explode("\n", $content); + for ($i=0,$c=count($lines); $i<$c; $i++) { + if ($this->indentationLevel > 0 + && !empty($lines[$i]) + && (empty($this->code) || "\n" === substr($this->code, -1))) { + $this->code .= str_repeat(' ', $this->indentationLevel * $this->indentationSpaces); + } + + $this->code .= $lines[$i]; + + if ($i+1 < $c) { + $this->code .= "\n"; + } + } + + return $this; + } + + public function nextName() + { + while (true) { + $name = ''; + $i = $this->nameCount; + + $name .= $this->chars[$i % $this->charCount]; + $i = intval($i / $this->charCount); + + while ($i > 0) { + $i -= 1; + $name .= $this->chars[$i % $this->charCount]; + $i = intval($i / $this->charCount); + } + + $this->nameCount += 1; + + // check that the name is not reserved + if (isset($this->reservedNames[$name])) { + continue; + } + + return $name; + } + } + + public function compilePreconditions(ExpressionInterface $expr) + { + if ($typeCompiler = $this->findTypeCompiler(get_class($expr))) { + $typeCompiler->compilePreconditions($this, $expr); + + return $this; + } + + if ($expr instanceof FunctionExpression) { + $this->getFunctionCompiler($expr->name)->compilePreconditions($this, $expr); + + foreach ($expr->args as $arg) { + $this->compilePreconditions($arg); + } + + return $this; + } + + if ($expr instanceof VariableExpression) { + $this->getVariableCompiler($expr->name)->compilePreconditions($this, $expr); + + return $this; + } + + if ($expr instanceof MethodCallExpression) { + $this->compilePreconditions($expr->object); + + foreach ($expr->args as $arg) { + $this->compilePreconditions($arg); + } + + return $this; + } + + if ($expr instanceof GetPropertyExpression) { + $this->compilePreconditions($expr->object); + + return $this; + } + + return $this; + } + + public function compileInternal(ExpressionInterface $expr) + { + if ($typeCompiler = $this->findTypeCompiler(get_class($expr))) { + $typeCompiler->compile($this, $expr); + + return $this; + } + + if ($expr instanceof ArrayExpression) { + $this->code .= 'array('; + foreach ($expr->elements as $key => $value) { + $this->code .= var_export($key, true).' => '; + $this->compileInternal($value); + $this->code .= ','; + } + $this->code .= ')'; + + return $this; + } + + if ($expr instanceof ConstantExpression) { + $this->code .= var_export($expr->value, true); + + return $this; + } + + if ($expr instanceof FunctionExpression) { + $this->getFunctionCompiler($expr->name)->compile($this, $expr); + + return $this; + } + + if ($expr instanceof GetItemExpression) { + $this->compileInternal($expr->array); + $this->code .= '['.$expr->key.']'; + + return $this; + } + + if ($expr instanceof GetPropertyExpression) { + $this->compileInternal($expr->object); + $this->code .= '->'.$expr->name; + + return $this; + } + + if ($expr instanceof MethodCallExpression) { + $this->compileInternal($expr->object); + $this->code .= '->'.$expr->method.'('; + + $first = true; + foreach ($expr->args as $arg) { + if (!$first) { + $this->code .= ', '; + } + $first = false; + + $this->compileInternal($arg); + } + $this->code .= ')'; + + return $this; + } + + throw new RuntimeException(sprintf('Unknown expression "%s".', get_class($expr))); + } + + public function getFunctionCompiler($name) + { + if (!isset($this->functionCompilers[$name])) { + throw new RuntimeException(sprintf('There is no compiler for function "%s".', $name)); + } + + return $this->functionCompilers[$name]; + } + + private function findTypeCompiler($type) + { + return isset($this->typeCompilers[$type]) ? $this->typeCompilers[$type] : null; + } + + private function getParser() + { + if (null !== $this->parser) { + return $this->parser; + } + + return $this->parser = new ExpressionParser(); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionHandlerInterface.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionHandlerInterface.php new file mode 100644 index 0000000..24e6024 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionHandlerInterface.php @@ -0,0 +1,26 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +interface ExpressionHandlerInterface +{ + function createContext(TokenInterface $token, $object); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionLexer.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionLexer.php new file mode 100644 index 0000000..e1f4445 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionLexer.php @@ -0,0 +1,134 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use JMS\SecurityExtraBundle\Exception\InvalidArgumentException; + +final class ExpressionLexer +{ + public $token; + public $lookahead; + + private $tokens; + private $pointer; + + const T_STRING = 1; + const T_IDENTIFIER = 2; + const T_NONE = 3; + const T_COMMA = 4; + const T_OPEN_PARENTHESIS = 5; + const T_CLOSE_PARENTHESIS = 6; + const T_AND = 7; + const T_OR = 8; + const T_PARAMETER = 9; + const T_OBJECT_OPERATOR = 10; + const T_OPEN_BRACKET = 11; + const T_CLOSE_BRACKET = 12; + const T_OPEN_BRACE = 13; + const T_CLOSE_BRACE = 14; + const T_COLON = 15; + const T_IS_EQUAL = 16; + const T_NOT = 17; + + public static function getLiteral($type) + { + static $constants; + + if (null === $constants) { + $ref = new \ReflectionClass(get_called_class()); + $constants = $ref->getConstants(); + } + + if (false === $literal = array_search($type, $constants, true)) { + throw new InvalidArgumentException(sprintf('There is no token of value "%s".', $type)); + } + + return $literal; + } + + public function initialize($input) + { + static $pattern = '/(#?[a-z][a-z0-9]*|\'(?:[^\']|(?<=\\\\)\')*\'|"(?:[^"]|(?<=\\\\)")*"|&&|\|\||==)|\s+|(.)/i'; + + $parts = preg_split($pattern, $input, -1, PREG_SPLIT_OFFSET_CAPTURE + | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + $tokens = array(); + foreach ($parts as $part) { + list($value, $position) = $part; + $type = self::T_NONE; + + if ("'" === $value[0] || '"' === $value[0]) { + $type = self::T_STRING; + $value = substr($value, 1, -1); + } else if (',' === $value) { + $type = self::T_COMMA; + } else if ('(' === $value) { + $type = self::T_OPEN_PARENTHESIS; + } else if (')' === $value) { + $type = self::T_CLOSE_PARENTHESIS; + } else if ('[' === $value) { + $type = self::T_OPEN_BRACKET; + } else if (']' === $value) { + $type = self::T_CLOSE_BRACKET; + } else if ('{' === $value) { + $type = self::T_OPEN_BRACE; + } else if ('}' === $value) { + $type = self::T_CLOSE_BRACE; + } else if ('&&' === $value || 'and' === strtolower($value)) { + $type = self::T_AND; + } else if ('||' === $value || 'or' === strtolower($value)) { + $type = self::T_OR; + } else if ('!' === $value || 'not' === strtolower($value)) { + $type = self::T_NOT; + } else if (':' === $value) { + $type = self::T_COLON; + } else if ('.' === $value) { + $type = self::T_OBJECT_OPERATOR; + } else if ('==' === $value) { + $type = self::T_IS_EQUAL; + } else if ('#' === $value[0]) { + $type = self::T_PARAMETER; + $value = substr($value, 1); + } else if (ctype_alpha($value)) { + $type = self::T_IDENTIFIER; + } + + $tokens[] = array( + 'type' => $type, + 'value' => $value, + 'position' => $position, + ); + } + + $this->tokens = $tokens; + $this->pointer = -1; + $this->next(); + } + + public function next() + { + $this->pointer += 1; + $this->token = $this->lookahead; + $this->lookahead = isset($this->tokens[$this->pointer]) ? + $this->tokens[$this->pointer] : null; + + return $this->lookahead !== null; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionParser.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionParser.php new file mode 100644 index 0000000..98fd32e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionParser.php @@ -0,0 +1,290 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\NotExpression; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\IsEqualExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ParameterExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\VariableExpression; + +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ConstantExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\OrExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\AndExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ArrayExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\GetItemExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\GetPropertyExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\MethodCallExpression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ExpressionInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\FunctionExpression; + +final class ExpressionParser +{ + const PRECEDENCE_OR = 10; + const PRECEDENCE_AND = 15; + const PRECEDENCE_IS_EQUAL = 20; + const PRECEDENCE_NOT = 30; + + private $lexer; + + public function __construct() + { + $this->lexer = new ExpressionLexer(); + } + + public function parse($str) + { + $this->lexer->initialize($str); + + return $this->Expression(); + } + + private function Expression($precedence = 0) + { + $expr = $this->Primary(); + + while (true) { + if (ExpressionLexer::T_AND === $this->lexer->lookahead['type'] + && $precedence <= self::PRECEDENCE_AND) { + $this->lexer->next(); + + $expr = new AndExpression($expr, $this->Expression( + self::PRECEDENCE_AND + 1)); + continue; + } + + if (ExpressionLexer::T_OR === $this->lexer->lookahead['type'] + && $precedence <= self::PRECEDENCE_OR) { + $this->lexer->next(); + + $expr = new OrExpression($expr, $this->Expression( + self::PRECEDENCE_OR + 1)); + continue; + } + + if (ExpressionLexer::T_IS_EQUAL === $this->lexer->lookahead['type'] + && $precedence <= self::PRECEDENCE_IS_EQUAL) { + $this->lexer->next(); + + $expr = new IsEqualExpression($expr, $this->Expression( + self::PRECEDENCE_IS_EQUAL + 1)); + continue; + } + + break; + } + + return $expr; + } + + private function Primary() + { + if (ExpressionLexer::T_NOT === $this->lexer->lookahead['type']) { + $this->lexer->next(); + $expr = new NotExpression($this->Expression(self::PRECEDENCE_NOT)); + + return $this->Suffix($expr); + } + + if (ExpressionLexer::T_OPEN_PARENTHESIS === $this->lexer->lookahead['type']) { + $this->lexer->next(); + $expr = $this->Expression(); + $this->match(ExpressionLexer::T_CLOSE_PARENTHESIS); + + return $this->Suffix($expr); + } + + if (ExpressionLexer::T_STRING === $this->lexer->lookahead['type']) { + return new ConstantExpression($this->match(ExpressionLexer::T_STRING)); + } + + if (ExpressionLexer::T_OPEN_BRACE === $this->lexer->lookahead['type']) { + return $this->Suffix($this->MapExpr()); + } + + if (ExpressionLexer::T_OPEN_BRACKET === $this->lexer->lookahead['type']) { + return $this->Suffix($this->ListExpr()); + } + + if (ExpressionLexer::T_IDENTIFIER === $this->lexer->lookahead['type']) { + $name = $this->match(ExpressionLexer::T_IDENTIFIER); + + if (ExpressionLexer::T_OPEN_PARENTHESIS === $this->lexer->lookahead['type']) { + $args = $this->Arguments(); + + return $this->Suffix(new FunctionExpression($name, $args)); + } + + return $this->Suffix(new VariableExpression($name)); + } + + if (ExpressionLexer::T_PARAMETER === $this->lexer->lookahead['type']) { + return $this->Suffix(new ParameterExpression($this->match(ExpressionLexer::T_PARAMETER))); + } + + $this->error('primary expression'); + } + + private function ListExpr() + { + $this->match(ExpressionLexer::T_OPEN_BRACKET); + + $elements = array(); + while (ExpressionLexer::T_CLOSE_BRACKET !== $this->lexer->lookahead['type']) { + $elements[] = $this->Expression(); + + if (ExpressionLexer::T_COMMA !== $this->lexer->lookahead['type']) { + break; + } + $this->lexer->next(); + } + + $this->match(ExpressionLexer::T_CLOSE_BRACKET); + + return new ArrayExpression($elements); + } + + private function MapExpr() + { + $this->match(ExpressionLexer::T_OPEN_BRACE); + + $entries = array(); + while (ExpressionLexer::T_CLOSE_BRACE !== $this->lexer->lookahead['type']) { + $key = $this->match(ExpressionLexer::T_STRING); + $this->match(ExpressionLexer::T_COLON); + $entries[$key] = $this->Expression(); + + if (ExpressionLexer::T_COMMA !== $this->lexer->lookahead['type']) { + break; + } + + $this->lexer->next(); + } + + $this->match(ExpressionLexer::T_CLOSE_BRACE); + + return new ArrayExpression($entries); + } + + private function Suffix(ExpressionInterface $expr) + { + while (true) { + if (ExpressionLexer::T_OBJECT_OPERATOR === $this->lexer->lookahead['type']) { + $this->lexer->next(); + $name = $this->match(ExpressionLexer::T_IDENTIFIER); + + if (ExpressionLexer::T_OPEN_PARENTHESIS === $this->lexer->lookahead['type']) { + $args = $this->Arguments(); + $expr = new MethodCallExpression($expr, $name, $args); + continue; + } + + $expr = new GetPropertyExpression($expr, $name); + continue; + } + + if (ExpressionLexer::T_OPEN_BRACKET === $this->lexer->lookahead['type']) { + $this->lexer->next(); + $key = $this->Expression(); + $this->match(ExpressionLexer::T_CLOSE_BRACKET); + $expr = new GetItemExpression($expr, $key); + continue; + } + + break; + } + + return $expr; + } + + private function FunctionCall() + { + $name = $this->match(ExpressionLexer::T_IDENTIFIER); + $args = $this->Arguments(); + + return new FunctionExpression($name, $args); + } + + private function Arguments() + { + $this->match(ExpressionLexer::T_OPEN_PARENTHESIS); + $args = array(); + + while (ExpressionLexer::T_CLOSE_PARENTHESIS !== $this->lexer->lookahead['type']) { + $args[] = $this->Expression(); + + if (ExpressionLexer::T_COMMA !== $this->lexer->lookahead['type']) { + break; + } + + $this->match(ExpressionLexer::T_COMMA); + } + $this->match(ExpressionLexer::T_CLOSE_PARENTHESIS); + + return $args; + } + + private function Value() + { + return $this->matchAny(array(ExpressionLexer::T_STRING)); + } + + private function matchAny(array $types) + { + if (null !== $this->lexer->lookahead) { + foreach ($types as $type) { + if ($type === $this->lexer->lookahead['type']) { + $this->lexer->next(); + + return $this->lexer->token['value']; + } + } + } + + $this->error(sprintf('one of these tokens "%s"', + implode('", "', array_map(array('JMS\SecurityExtraBundle\Security\Authorization\Expression\Lexer', 'getLiteral'), $types)) + )); + } + + private function match($type) + { + if (null === $this->lexer->lookahead + || $type !== $this->lexer->lookahead['type']) { + $this->error(sprintf('token "%s"', ExpressionLexer::getLiteral($type))); + } + + $this->lexer->next(); + + return $this->lexer->token['value']; + } + + private function error($expected) + { + $actual = null === $this->lexer->lookahead ? 'end of file' + : sprintf('token "%s" with value "%s" at position %d', + ExpressionLexer::getLiteral($this->lexer->lookahead['type']), + $this->lexer->lookahead['value'], + $this->lexer->lookahead['position']); + + throw new RuntimeException(sprintf('Expected %s, but got %s.', $expected, $actual)); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionVoter.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionVoter.php new file mode 100644 index 0000000..cf04742 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/ExpressionVoter.php @@ -0,0 +1,114 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; +use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; + +/** + * Expression-based voter. + * + * This voter allows to use complex access expression in a high-performance + * way. This is the preferred voter for any non-simple access checks. + * + * @author Johannes M. Schmitt + */ +class ExpressionVoter implements VoterInterface +{ + private $evaluators = array(); + private $compiler; + private $cacheDir; + private $expressionHandler; + + public function __construct(ExpressionHandlerInterface $expressionHandler) { + $this->expressionHandler = $expressionHandler; + } + + public function setCacheDir($cacheDir) + { + $this->cacheDir = $cacheDir; + } + + public function setCompiler(ExpressionCompiler $compiler) + { + $this->compiler = $compiler; + } + + public function vote(TokenInterface $token, $object, array $attributes) + { + $result = VoterInterface::ACCESS_ABSTAIN; + + foreach ($attributes as $attribute) { + if (!$attribute instanceof Expression) { + continue; + } + + $result = VoterInterface::ACCESS_DENIED; + if (!isset($this->evaluators[$attribute->expression])) { + $this->evaluators[$attribute->expression] = + $this->createEvaluator($attribute); + } + + if (call_user_func($this->evaluators[$attribute->expression], + $this->expressionHandler->createContext($token, $object))) { + return VoterInterface::ACCESS_GRANTED; + } + } + + return $result; + } + + public function supportsAttribute($attribute) + { + return $attribute instanceof Expression; + } + + public function supportsClass($class) + { + return true; + } + + protected function getCompiler() + { + if (null === $this->compiler) { + throw new RuntimeException('A compiler must be set.'); + } + + return $this->compiler; + } + + private function createEvaluator(Expression $expr) + { + if ($this->cacheDir) { + if (is_file($file = $this->cacheDir.'/'.sha1($expr->expression).'.php')) { + return require $file; + } + + $source = $this->getCompiler()->compileExpression($expr); + file_put_contents($file, "getCompiler()->compileExpression($expr)); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/LazyLoadingExpressionVoter.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/LazyLoadingExpressionVoter.php new file mode 100644 index 0000000..b9d577e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Expression/LazyLoadingExpressionVoter.php @@ -0,0 +1,39 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Expression; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionVoter; + +class LazyLoadingExpressionVoter extends ExpressionVoter +{ + private $container; + private $compilerId; + + public function setLazyCompiler(ContainerInterface $container, $id) + { + $this->container = $container; + $this->compilerId = $id; + } + + protected function getCompiler() + { + return $this->container->get($this->compilerId); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/MethodSecurityInterceptor.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/MethodSecurityInterceptor.php new file mode 100644 index 0000000..8d4c63a --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/MethodSecurityInterceptor.php @@ -0,0 +1,150 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Interception; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use CG\Core\ClassUtils; + +use CG\Proxy\MethodInterceptorInterface; +use CG\Proxy\MethodInvocation; +use JMS\SecurityExtraBundle\Metadata\MethodMetadata; +use JMS\SecurityExtraBundle\Security\Authentication\Token\RunAsUserToken; +use JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation\AfterInvocationManagerInterface; +use JMS\SecurityExtraBundle\Security\Authorization\RunAsManagerInterface; +use Metadata\MetadataFactoryInterface; +use Symfony\Component\HttpKernel\Log\LoggerInterface; +use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; +use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; +use Symfony\Component\Security\Core\SecurityContext; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException; + +/** + * All invocations of secure methods will go through this class. + * + * @author Johannes M. Schmitt + */ +class MethodSecurityInterceptor implements MethodInterceptorInterface +{ + private $alwaysAuthenticate; + private $securityContext; + private $metadataFactory; + private $authenticationManager; + private $accessDecisionManager; + private $afterInvocationManager; + private $runAsManager; + private $logger; + + public function __construct(SecurityContext $securityContext, AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, + AfterInvocationManagerInterface $afterInvocationManager, RunAsManagerInterface $runAsManager, MetadataFactoryInterface $metadataFactory, LoggerInterface $logger = null) + { + $this->alwaysAuthenticate = false; + $this->securityContext = $securityContext; + $this->metadataFactory = $metadataFactory; + $this->authenticationManager = $authenticationManager; + $this->accessDecisionManager = $accessDecisionManager; + $this->afterInvocationManager = $afterInvocationManager; + $this->runAsManager = $runAsManager; + $this->logger = $logger; + } + + public function setAlwaysAuthenticate($boolean) + { + $this->alwaysAuthenticate = !!$boolean; + } + + public function intercept(MethodInvocation $method) + { + $metadata = $this->metadataFactory->getMetadataForClass($method->reflection->class); + + // no security metadata, proceed + if (empty($metadata) || !isset($metadata->methodMetadata[$method->reflection->name])) { + return $method->proceed(); + } + $metadata = $metadata->methodMetadata[$method->reflection->name]; + + if (null === $token = $this->securityContext->getToken()) { + throw new AuthenticationCredentialsNotFoundException( + 'The security context was not populated with a Token.' + ); + } + + if ($this->alwaysAuthenticate || !$token->isAuthenticated()) { + $token = $this->authenticationManager->authenticate($token); + $this->securityContext->setToken($token); + } + + if (!empty($metadata->roles) && false === $this->accessDecisionManager->decide($token, $metadata->roles, $method)) { + throw new AccessDeniedException('Token does not have the required roles.'); + } + + if (!empty($metadata->paramPermissions)) { + foreach ($method->arguments as $index => $argument) { + if (null !== $argument && isset($metadata->paramPermissions[$index]) && false === $this->accessDecisionManager->decide($token, $metadata->paramPermissions[$index], $argument)) { + throw new AccessDeniedException(sprintf('Token does not have the required permissions for method "%s::%s".', $method->reflection->class, $method->reflection->name)); + } + } + } + + $runAsToken = null; + if (!empty($metadata->runAsRoles)) { + $runAsToken = $this->runAsManager->buildRunAs($token, $method, $metadata->runAsRoles); + + if (null !== $this->logger) { + $this->logger->debug('Populating security context with RunAsToken'); + } + + if (null === $runAsToken) { + throw new RuntimeException('RunAsManager must not return null from buildRunAs().'); + } + + $this->securityContext->setToken($runAsToken); + } + + try { + $returnValue = $method->proceed(); + + if (null !== $runAsToken) { + $this->restoreOriginalToken($runAsToken); + } + + if (empty($metadata->returnPermissions)) { + return $returnValue; + } + + return $this->afterInvocationManager->decide($this->securityContext->getToken(), $method, $metadata->returnPermissions, $returnValue); + } catch (\Exception $failed) { + if (null !== $runAsToken) { + $this->restoreOriginalToken($runAsToken); + } + + throw $failed; + } + } + + private function restoreOriginalToken(RunAsUserToken $runAsToken) + { + if (null !== $this->logger) { + $this->logger->debug('Populating security context with original Token.'); + } + + $this->securityContext->setToken($runAsToken->getOriginalToken()); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/SecurityPointcut.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/SecurityPointcut.php new file mode 100644 index 0000000..9cba96c --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Interception/SecurityPointcut.php @@ -0,0 +1,92 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Interception; + +use CG\Core\ClassUtils; +use Metadata\MetadataFactoryInterface; +use JMS\AopBundle\Aop\PointcutInterface; + +class SecurityPointcut implements PointcutInterface +{ + private $metadataFactory; + private $secureAllServices; + private $securedClasses = array(); + private $patterns; + + public function __construct(MetadataFactoryInterface $metadataFactory, $secureAllServices = false, array $patterns = array()) + { + $this->metadataFactory = $metadataFactory; + $this->secureAllServices = $secureAllServices; + $this->patterns = $patterns; + } + + public function setSecuredClasses(array $classes) + { + $this->securedClasses = $classes; + } + + public function matchesClass(\ReflectionClass $class) + { + if ($this->secureAllServices) { + return true; + } + + if ('Controller' === substr(ClassUtils::getUserClass($class->name), -10)) { + return true; + } + + foreach ($this->patterns as $pattern => $expr) { + // if not for all patterns the class is specified, then we need to scan all + // classes to catch all methods + if (false === $pos = strpos($pattern, '::')) { + // controller notation is already checked by JMSDiExtraBundle, + // we can safely ignore these patterns here + if (2 === substr_count($pattern, ':')) { + continue; + } + + return true; + } + + if (0 < preg_match('#'.substr($pattern, 0, $pos).'$#', $class->name)) { + return true; + } + } + + foreach ($this->securedClasses as $securedClass) { + if ($class->name === $securedClass || $class->isSubclassOf($securedClass)) { + return true; + } + } + + return false; + } + + public function matchesMethod(\ReflectionMethod $method) + { + $userClass = ClassUtils::getUserClass($method->class); + $metadata = $this->metadataFactory->getMetadataForClass($userClass); + + if (null === $metadata) { + return false; + } + + return isset($metadata->methodMetadata[$method->name]); + } +} diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManager.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManager.php new file mode 100644 index 0000000..f1884df --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManager.php @@ -0,0 +1,79 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization; + +use JMS\SecurityExtraBundle\Security\Authentication\Token\RunAsUserToken; +use Symfony\Component\Security\Core\Role\Role; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +/** + * The RunAsManager creates throw-away Tokens which are temporarily injected into + * the security context for the duration of the invocation of a specific method. + * + * @author Johannes M. Schmitt + */ +class RunAsManager implements RunAsManagerInterface +{ + private $key; + private $rolePrefix; + + public function __construct($key, $rolePrefix = 'ROLE_') + { + $this->key = $key; + $this->rolePrefix = $rolePrefix; + } + + /** + * {@inheritDoc} + */ + public function buildRunAs(TokenInterface $token, $secureObject, array $attributes) + { + $roles = array(); + foreach ($attributes as $attribute) + { + if ($this->supportsAttribute($attribute)) { + $roles[] = new Role($attribute); + } + } + + if (0 === count($roles)) { + return null; + } + + $roles = array_merge($roles, $token->getRoles()); + + return new RunAsUserToken($this->key, $token->getUser(), $token->getCredentials(), $roles, $token); + } + + /** + * {@inheritDoc} + */ + public function supportsAttribute($attribute) + { + return !empty($attribute) && 0 === strpos($attribute, $this->rolePrefix); + } + + /** + * {@inheritDoc} + */ + public function supportsClass($className) + { + return true; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManagerInterface.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManagerInterface.php new file mode 100644 index 0000000..a2b4909 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/RunAsManagerInterface.php @@ -0,0 +1,57 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +/** + * RunAsManagerInterface + * + * @author Johannes M. Schmitt + */ +interface RunAsManagerInterface +{ + /** + * Creates a temporary RunAsToken. + * + * The returned Token must have a complementing AuthenticationProvider implementation. + * + * @param TokenInterface $token the original Token + * @param object $secureObject the secure object which caused this call + * @param array $attributes an array of attributes to apply to the built token + * @return TokenInterface + */ + function buildRunAs(TokenInterface $token, $secureObject, array $attributes); + + /** + * Whether this RunAsManager supports the given attribute + * + * @param string $attribute + * @return Boolean + */ + function supportsAttribute($attribute); + + /** + * Whether this RunAsManager supports the given class. + * + * @param string $className The class of the secure object which requests RunAs capabilities + * @return Boolean + */ + function supportsClass($className); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Voter/IddqdVoter.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Voter/IddqdVoter.php new file mode 100644 index 0000000..663cd4e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Security/Authorization/Voter/IddqdVoter.php @@ -0,0 +1,61 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Security\Authorization\Voter; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; + +/** + * This voter adds a special role "ROLE_IDDQD" which effectively bypasses any, + * and all security checks. + * + * Most of the time, you will want to use this rule in combination with a + * @RunAs annotation to disable security checks for the invocation of a + * specific method. + * + * @author Johannes M. Schmitt + */ +class IddqdVoter implements VoterInterface +{ + public function vote(TokenInterface $token, $object, array $attributes) + { + return $this->isIddqd($token) ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_ABSTAIN; + } + + protected function isIddqd(TokenInterface $token) + { + foreach ($token->getRoles() as $role) { + if ('ROLE_IDDQD' === $role->getRole()) { + return true; + } + } + + return false; + } + + public function supportsAttribute($attribute) + { + return true; + } + + public function supportsClass($class) + { + return true; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/AddAfterInvocationProvidersPassTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/AddAfterInvocationProvidersPassTest.php new file mode 100644 index 0000000..277f374 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/AddAfterInvocationProvidersPassTest.php @@ -0,0 +1,91 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Definition; +use JMS\SecurityExtraBundle\DependencyInjection\Compiler\AddAfterInvocationProvidersPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +class AddAfterInvocationProvidersPassTest extends \PHPUnit_Framework_TestCase +{ + public function testProcessStopsWhenNoAfterInvocationManager() + { + $container = $this->getContainer(); + $container + ->expects($this->once()) + ->method('hasDefinition') + ->with($this->equalTo('security.access.after_invocation_manager')) + ->will($this->returnValue(false)) + ; + $container + ->expects($this->never()) + ->method('findTaggedServiceIds') + ; + + $this->process($container); + } + + public function testProcessRemovesAclProviderIfAclIsNotActive() + { + $container = new ContainerBuilder(); + $container->setDefinition('security.access.after_invocation_manager', $manager = new Definition()); + + $container + ->register('security.access.after_invocation.acl_provider') + ->addTag('security.after_invocation.provider') + ; + + $this->assertEquals(array(), $manager->getArguments()); + $this->process($container); + $this->assertEquals(array(array()), $manager->getArguments()); + } + + public function testProcess() + { + $container = new ContainerBuilder(); + + $container->setDefinition('security.access.after_invocation_manager', $manager = new Definition()); + + $provider1 = new Definition(); + $provider1->addTag('security.after_invocation.provider'); + $container->setDefinition('provider1', $provider1); + + $provider2 = new Definition(); + $provider2->addTag('security.after_invocation.provider'); + $container->setDefinition('provider2', $provider2); + + $this->process($container); + + $arguments = $manager->getArguments(); + $this->assertEquals(2, count($providers = $arguments[0])); + $this->assertEquals('provider1', (string) $providers[0]); + $this->assertEquals('provider2', (string) $providers[1]); + } + + protected function process(ContainerBuilder $container) + { + $pass = new AddAfterInvocationProvidersPass(); + $pass->process($container); + } + + protected function getContainer() + { + return $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/CollectSecuredServicesPassTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/CollectSecuredServicesPassTest.php new file mode 100644 index 0000000..bef1ffb --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/Compiler/CollectSecuredServicesPassTest.php @@ -0,0 +1,50 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; + +use JMS\SecurityExtraBundle\DependencyInjection\Compiler\CollectSecuredServicesPass; + +class CollectSecuredServicesPassTest extends \PHPUnit_Framework_TestCase +{ + public function testProcess() + { + $container = new ContainerBuilder(); + $container + ->register('security.access.pointcut', 'JMS\SecurityExtraBundle\Security\Authorization\Interception\SecurityPointcut') + ; + + $container + ->register('a', 'stdClass') + ->addTag('security.secure_service') + ; + $container + ->register('b', 'stdClass') + ->addTag('security.secure_service') + ; + + $pass = new CollectSecuredServicesPass(); + $pass->process($container); + + $this->assertEquals(array( + array('setSecuredClasses', array(array('stdClass', 'stdClass'))), + ), $container->getDefinition('security.access.pointcut')->getMethodCalls()); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/JMSSecurityExtraExtensionTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/JMSSecurityExtraExtensionTest.php new file mode 100644 index 0000000..37019fd --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/DependencyInjection/JMSSecurityExtraExtensionTest.php @@ -0,0 +1,91 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\DependencyInjection; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use JMS\SecurityExtraBundle\DependencyInjection\JMSSecurityExtraExtension; + +class JMSSecurityExtraExtensionTest extends \PHPUnit_Framework_TestCase +{ + private $extension; + + public function testConfigLoad() + { + $config = array(); + $this->extension->load(array($config), $container = $this->getContainer()); + + $this->assertTrue($container->hasDefinition('security.access.method_interceptor')); + $this->assertFalse($container->getParameter('security.access.secure_all_services')); + $this->assertFalse($container->getDefinition('security.extra.iddqd_voter')->hasTag('security.voter')); + } + + public function testConfigLoadSecureAll() + { + $this->extension->load(array(array('secure_all_services' => true)), + $container = $this->getContainer()); + + $this->assertTrue($container->getParameter('security.access.secure_all_services')); + } + + public function testConfigLoadEnableIddqdAttribute() + { + $this->extension->load(array(array('enable_iddqd_attribute' => true)), + $container = $this->getContainer()); + + $this->assertTrue($container->getDefinition('security.extra.iddqd_voter')->hasTag('security.voter')); + } + + public function testConfigLoadWithMethodAccessControl() + { + $this->extension->load(array(array( + 'expressions' => true, + 'method_access_control' => array( + ':login$' => 'hasRole("FOO")', + ) + )), $container = $this->getContainer()); + + $this->assertEquals(array(':login$' => 'hasRole("FOO")'), + $container->getParameter('security.access.method_access_control')); + } + + /** + * @expectedException \RuntimeException + */ + public function testConfigLoadThrowsExceptionWhenMethodAccessControlWithoutExpressions() + { + $this->extension->load(array(array( + 'expressions' => false, + 'method_access_control' => array('foo' => 'bar'), + )), $this->getContainer()); + } + + protected function setUp() + { + $this->extension = new JMSSecurityExtraExtension(); + } + + private function getContainer() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.cache_dir', sys_get_temp_dir()); + $container->setParameter('kernel.bundles', array('JMSAopBundle' => 'JMS\AopBundle\JMSAopBundle')); + + return $container; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/AbstractMethodNotDirectlyOverwrittenInDirectChildService.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/AbstractMethodNotDirectlyOverwrittenInDirectChildService.php new file mode 100644 index 0000000..5bd3647 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/AbstractMethodNotDirectlyOverwrittenInDirectChildService.php @@ -0,0 +1,45 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Fixtures; + +use JMS\SecurityExtraBundle\Annotation\SecureReturn; +use JMS\SecurityExtraBundle\Annotation\SecureParam; +use JMS\SecurityExtraBundle\Annotation\Secure; + +interface AMNDOIDCS_Interface +{ + /** + * @SecureReturn(permissions="VIEW") + */ + function abstractMethod(); +} + +abstract class AMNDOIDCS_DirectChild implements AMNDOIDCS_Interface +{ +} + +class AbstractMethodNotDirectlyOverwrittenInDirectChildService extends AMNDOIDCS_DirectChild +{ + /** + * Some comment + */ + public function abstractMethod() + { + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/Annotation/NonSecurityAnnotation.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/Annotation/NonSecurityAnnotation.php new file mode 100644 index 0000000..a1e9e81 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/Annotation/NonSecurityAnnotation.php @@ -0,0 +1,24 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Fixtures\Annotation; + +/** @Annotation */ +final class NonSecurityAnnotation +{ +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/ComplexService.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/ComplexService.php new file mode 100644 index 0000000..f3f9b8a --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/ComplexService.php @@ -0,0 +1,54 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Fixtures; + +use JMS\SecurityExtraBundle\Annotation\SecureReturn; +use JMS\SecurityExtraBundle\Annotation\SecureParam; +use JMS\SecurityExtraBundle\Annotation\Secure; + +interface E { + /** + * @SecureReturn(permissions="VIEW,UNDELETE") + */ + function retrieve(); +} +interface F { + /** + * @SecureParam(name="secure", permissions="OWNER") + * @SecureParam(name="foo", permissions="MASTER, EDIT") + */ + function delete($foo, $asdf, $secure); +} +interface C { } +interface D extends F {} +interface B extends C, E { } +abstract class G implements F, E { + /** + * @Secure(roles="ROLE_FOO, IS_AUTHENTICATED_FULLY") + * @SecureParam(name="secure", permissions="FOO") + * @SecureReturn(permissions="WOW") + */ + abstract function abstractMethod($foo, $secure); +} +class A extends G implements C, B, D { + public function retrieve() { } + public function delete($one, $two, $three) { } + public function abstractMethod($asdf, $wohoo) { } +} +class ComplexService extends A implements C { } diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/CorrectSubService.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/CorrectSubService.php new file mode 100644 index 0000000..e8eed1f --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/CorrectSubService.php @@ -0,0 +1,34 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Fixtures; + +use JMS\SecurityExtraBundle\Annotation\SatisfiesParentSecurityPolicy; +use JMS\SecurityExtraBundle\Annotation\SecureReturn; + +class CorrectSubService extends MainService +{ + /** + * @SatisfiesParentSecurityPolicy + * @SecureReturn(permissions="VIEW") + */ + public function differentMethodSignature($comment) + { + return parent::differentMethodSignature($comment); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/MainService.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/MainService.php new file mode 100644 index 0000000..eadd4ef --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/MainService.php @@ -0,0 +1,42 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Fixtures; + +use JMS\SecurityExtraBundle\Annotation\Secure; +use JMS\SecurityExtraBundle\Tests\Fixtures\Annotation\NonSecurityAnnotation; +use JMS\SecurityExtraBundle\Annotation\SecureParam; + +class MainService +{ + /** + * This Method has no relevant security annotations + * @NonSecurityAnnotation + */ + public function foo() + { + } + + /** + * @SecureParam(name="comment", permissions="EDIT") + */ + public function differentMethodSignature($comment) + { + // some secure action + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/SubService.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/SubService.php new file mode 100644 index 0000000..5933365 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Fixtures/SubService.php @@ -0,0 +1,29 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Fixtures; + +class SubService extends MainService +{ + public function differentMethodSignature($commentId) + { + $comment = 'asdgasdf'.$commentId; + + return MainService::differentMethodSignature($comment); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/AppKernel.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/AppKernel.php new file mode 100644 index 0000000..eaab813 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/AppKernel.php @@ -0,0 +1,97 @@ +isAbsolutePath($config)) { + $config = __DIR__.'/config/'.$config; + } + + if (!file_exists($config)) { + throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config)); + } + + $this->config = $config; + } + + public function registerBundles() + { + return array( + new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), + new \Symfony\Bundle\SecurityBundle\SecurityBundle(), + new \Symfony\Bundle\DoctrineBundle\DoctrineBundle(), + new \Symfony\Bundle\TwigBundle\TwigBundle(), + new TestBundle(), + new FormLoginBundle(), + new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), + new \JMS\AopBundle\JMSAopBundle(), + new \JMS\DiExtraBundle\JMSDiExtraBundle($this), + new \JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), + ); + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load($this->config); + } + + public function getCacheDir() + { + return sys_get_temp_dir().'/JMSSecurityExtraBundle/'.sha1($this->config); + } + + protected function getContainerClass() + { + return parent::getContainerClass().sha1($this->config); + } + + public function serialize() + { + return $this->config; + } + + public function unserialize($str) + { + $this->__construct($str); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/BaseTestCase.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/BaseTestCase.php new file mode 100644 index 0000000..ea0ff91 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/BaseTestCase.php @@ -0,0 +1,64 @@ +remove(sys_get_temp_dir().'/JMSSecurityExtraBundle'); + } + + protected function tearDown() + { + parent::tearDown(); + + $fs = new Filesystem(); + $fs->remove(sys_get_temp_dir().'/JMSSecurityExtraBundle'); + } + + protected function login($client, $username = null, $password = null) + { + if (empty($username) || empty($password)) { + $username = 'johannes'; + $password = 'test'; + } + + $crawler = $client->request('get', '/login')->selectButton('login'); + $form = $crawler->form(); + + $form['_username'] = $username; + $form['_password'] = $password; + $client->submit($form); + + $security = $client->getProfile()->getCollector('security'); + + $this->assertTrue(is_string($security->getUser()) && strlen($security->getUser()) > 0); + $this->assertTrue($security->isAuthenticated(), 'Logged in user is not authenticated.'); + } + + protected final function importDatabaseSchema() + { + $em = self::$kernel->getContainer()->get('em'); + + $metadata = $em->getMetadataFactory()->getAllMetadata(); + if (!empty($metadata)) { + $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em); + $schemaTool->createSchema($metadata); + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/MethodAccessControlTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/MethodAccessControlTest.php new file mode 100644 index 0000000..46c713b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/MethodAccessControlTest.php @@ -0,0 +1,77 @@ +createClient(array('config' => 'method_access_control.yml')); + + $client->request('GET', '/add'); + $response = $client->getResponse(); + + $this->assertEquals(302, $response->getStatusCode()); + $this->assertEquals('http://localhost/login', $response->headers->get('Location')); + } + + public function testControllerEditActionIsNotSecure() + { + $client = $this->createClient(array('config' => 'method_access_control.yml')); + + $client->request('GET', '/edit'); + $response = $client->getResponse(); + + $this->assertEquals(200, $response->getStatusCode()); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException + */ + public function testUserManagerDeleteIsSecure() + { + $this->createClient(array('config' => 'method_access_control.yml')); + + $manager = self::$kernel->getContainer()->get('user_manager'); + + $this->assertNotEquals( + 'JMS\SecurityExtraBundle\Tests\Functional\TestBundle\User\UserManager', + get_class($manager) + ); + $manager->delete(); + } + + public function testAcl() + { + $client = $this->createClient(array('config' => 'acl_enabled.yml')); + $client->insulate(); + + $this->importDatabaseSchema(); + $this->login($client); + + $client->request('POST', '/post/add', array('title' => 'Foo')); + + $response = $client->getResponse(); + $this->assertEquals('/post/edit/1', $response->headers->get('Location'), + substr($response, 0, 2000)); + + $client->request('GET', '/post/edit/1'); + $response = $client->getResponse(); + $this->assertEquals(200, $response->getStatusCode(), substr($response, 0, 2000)); + $this->assertEquals('Foo', $response->getContent()); + } + + public function testRoleHierarchyIsRespected() + { + $client = $this->createClient(array('config' => 'all_voters_disabled.yml')); + $client->insulate(); + + $this->login($client); + + $client->request('GET', '/post/list'); + + $response = $client->getResponse(); + $this->assertEquals(200, $response->getStatusCode(), substr($response, 0, 2000)); + $this->assertEquals('list', $response->getContent(), substr($response, 0, 2000)); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/Resources/views/base.html.twig b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/Resources/views/base.html.twig new file mode 100644 index 0000000..c19978f --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/Resources/views/base.html.twig @@ -0,0 +1,13 @@ + + + + + {% block title %}Welcome!{% endblock %} + {% block stylesheets %}{% endblock %} + + + + {% block body %}{% endblock %} + {% block javascripts %}{% endblock %} + + diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Controller/CrudController.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Controller/CrudController.php new file mode 100644 index 0000000..ae90060 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Controller/CrudController.php @@ -0,0 +1,18 @@ +request->request->get('title')) { + throw new HttpException(400); + } + + $this->em->getConnection()->beginTransaction(); + try { + $post = new Post($title); + $this->em->persist($post); + $this->em->flush(); + + $oid = ObjectIdentity::fromDomainObject($post); + $acl = $this->getAclProvider()->createAcl($oid); + + $sid = UserSecurityIdentity::fromToken($this->context->getToken()); + $acl->insertObjectAce($sid, MaskBuilder::MASK_OWNER); + $this->getAclProvider()->updateAcl($acl); + + $this->em->getConnection()->commit(); + + return new Response('', 201, array( + 'Location' => $this->router->generate('post_controller_edit', array('id' => $post->getId())), + )); + } catch (\Exception $ex) { + $this->em->getConnection()->rollBack(); + $this->em->close(); + + throw $ex; + } + } + + /** + * @PreAuthorize("hasPermission(#post, 'edit')") + */ + public function editPostAction(Post $post) + { + return new Response($post->getTitle()); + } + + /** + * @PreAuthorize("hasRole('ROLE_BAR')") + */ + public function listPostAction() + { + return new Response('list'); + } + + /** @DI\LookupMethod("security.acl.provider") */ + protected function getAclProvider() { } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Entity/Post.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Entity/Post.php new file mode 100644 index 0000000..07b8237 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Entity/Post.php @@ -0,0 +1,41 @@ + + */ +class Post +{ + /** + * @ORM\Id + * @ORM\GeneratedValue(strategy="AUTO") + * @ORM\Column(type="integer") + */ + private $id; + + /** + * @ORM\Column(type = "string") + */ + private $title; + + public function __construct($title) + { + $this->title = $title; + } + + public function getId() + { + return $this->id; + } + + public function getTitle() + { + return $this->title; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Logger/FileLogger.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Logger/FileLogger.php new file mode 100644 index 0000000..b8e7ed1 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Logger/FileLogger.php @@ -0,0 +1,60 @@ +dir = $logDir; + } + + public function emerg($message, array $context = array()) + { + $this->log('[EMERG] '.$message); + } + + public function alert($message, array $context = array()) + { + $this->log('[ALERT] '.$message); + } + + public function crit($message, array $context = array()) + { + $this->log('[CRIT] '.$message); + } + + public function err($message, array $context = array()) + { + $this->log('[ERR] '.$message); + } + + public function warn($message, array $context = array()) + { + $this->log('[WARN] '.$message); + } + + public function notice($message, array $context = array()) + { + $this->log('[NOTICE] '.$message); + } + + public function info($message, array $context = array()) + { + $this->log('[INFO] '.$message); + } + + public function debug($message, array $context = array()) + { + $this->log('[DEBUG] '.$message); + } + + private function log($message) + { + file_put_contents($this->dir.'/log', $message."\n", FILE_APPEND); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Resources/views/is_expr_granted.html.twig b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Resources/views/is_expr_granted.html.twig new file mode 100644 index 0000000..ba9d5fa --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/Resources/views/is_expr_granted.html.twig @@ -0,0 +1,5 @@ +{% if (is_expr_granted("hasRole('FOO')")) -%} +granted +{%- else -%} +denied +{%- endif %} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/TestBundle.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/TestBundle.php new file mode 100644 index 0000000..e1dda5d --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/TestBundle/TestBundle.php @@ -0,0 +1,10 @@ +context->setToken(new UsernamePasswordToken('foo', 'bar', 'baz', array('FOO'))); + + $this->assertEquals('granted', + $this->twig->render('TestBundle::is_expr_granted.html.twig')); + } + + public function testIsExprGranted() + { + $this->context->setToken(new AnonymousToken('foo', 'bar')); + + $this->assertEquals('denied', + $this->twig->render('TestBundle::is_expr_granted.html.twig')); + } + + protected function setUp() + { + parent::setUp(); + + $this->createClient(array('config' => 'all_voters_disabled.yml')); + $this->context = self::$kernel->getContainer()->get('security.context'); + $this->twig = self::$kernel->getContainer()->get('twig'); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/VoterDisablingTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/VoterDisablingTest.php new file mode 100644 index 0000000..3ef0a3b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/VoterDisablingTest.php @@ -0,0 +1,48 @@ +createClient(array('config' => 'all_voters_disabled.yml')); + $client->insulate(); + + $adm = self::$kernel->getContainer()->get('security.access.decision_manager'); + + $this->assertEquals(1, count($voters = $this->getField($adm, 'voters'))); + $this->assertInstanceOf('JMS\SecurityExtraBundle\Security\Authorization\Expression\LazyLoadingExpressionVoter', $voters[0]); + } + + public function testDefault() + { + $client = $this->createClient(array('config' => 'default.yml')); + $client->insulate(); + + $adm = self::$kernel->getContainer()->get('security.access.decision_manager'); + + $this->assertEquals(2, count($voters = $this->getField($adm, 'voters'))); + $this->assertInstanceOf('Symfony\Component\Security\Core\Authorization\Voter\RoleVoter', $voters[0]); + $this->assertInstanceOf('Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter', $voters[1]); + } + + public function testSomeVotersDisabled() + { + $client = $this->createClient(array('config' => 'some_voters_disabled.yml')); + $client->insulate(); + + $adm = self::$kernel->getContainer()->get('security.access.decision_manager'); + + $this->assertEquals(1, count($voters = $this->getField($adm, 'voters'))); + $this->assertInstanceOf('Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter', $voters[0]); + } + + private function getField($obj, $field) + { + $ref = new \ReflectionProperty($obj, $field); + $ref->setAccessible(true); + + return $ref->getValue($obj); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/acl_enabled.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/acl_enabled.yml new file mode 100644 index 0000000..8f5810a --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/acl_enabled.yml @@ -0,0 +1,9 @@ +imports: + - { resource: default.yml } + +security: + acl: ~ + +jms_security_extra: + expressions: true + voters: false \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/all_voters_disabled.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/all_voters_disabled.yml new file mode 100644 index 0000000..bc23cd5 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/all_voters_disabled.yml @@ -0,0 +1,6 @@ +imports: + - { resource: default.yml } + +jms_security_extra: + expressions: true + voters: false \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/default.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/default.yml new file mode 100644 index 0000000..b31f647 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/default.yml @@ -0,0 +1,5 @@ +imports: + - { resource: framework.yml } + - { resource: twig.yml } + - { resource: security.yml } + - { resource: doctrine.yml } diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/doctrine.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/doctrine.yml new file mode 100644 index 0000000..a065105 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/doctrine.yml @@ -0,0 +1,13 @@ +services: + em: @doctrine.orm.entity_manager + +doctrine: + dbal: + driver: pdo_sqlite + path: %kernel.cache_dir%/sqlite.db + + orm: + auto_generate_proxy_classes: %kernel.debug% + entity_managers: + default: + auto_mapping: true diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/framework.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/framework.yml new file mode 100644 index 0000000..a1268a2 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/framework.yml @@ -0,0 +1,18 @@ +services: + logger: + class: JMS\SecurityExtraBundle\Tests\Functional\TestBundle\Logger\FileLogger + arguments: [%kernel.cache_dir%] + +framework: + secret: test + profiler: ~ + test: ~ + session: + storage_id: session.storage.filesystem + form: true + csrf_protection: true + validation: + enabled: true + enable_annotations: true + router: + resource: %kernel.root_dir%/config/routing.yml \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/method_access_control.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/method_access_control.yml new file mode 100644 index 0000000..d05ed40 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/method_access_control.yml @@ -0,0 +1,12 @@ +imports: + - { resource: default.yml } + +services: + user_manager: + class: JMS\SecurityExtraBundle\Tests\Functional\TestBundle\User\UserManager + +jms_security_extra: + expressions: ~ + method_access_control: + 'UserManager::delete$': 'hasRole("FOO")' + 'TestBundle:Crud:add': 'hasRole("FOO")' \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/routing.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/routing.yml new file mode 100644 index 0000000..c9e4b6e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/routing.yml @@ -0,0 +1,27 @@ +crud_controller_add: + pattern: /add + defaults: + _controller: TestBundle:Crud:add + +crud_controller_edit: + pattern: /edit + defaults: + _controller: TestBundle:Crud:edit + +post_controller_add: + pattern: /post/add + defaults: + _controller: TestBundle:Post:newPost + +post_controller_edit: + pattern: /post/edit/{id} + defaults: + _controller: TestBundle:Post:editPost + +post_controller_list: + pattern: /post/list + defaults: + _controller: TestBundle:Post:listPost + +form_login_bundle: + resource: @FormLoginBundle/Resources/config/routing.yml \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/security.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/security.yml new file mode 100644 index 0000000..ef95b1d --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/security.yml @@ -0,0 +1,17 @@ +security: + providers: + in_memory: + users: + johannes: { password: test, roles: [ROLE_FOO] } + + role_hierarchy: + ROLE_FOO: [ROLE_BAR] + + encoders: + Symfony\Component\Security\Core\User\UserInterface: plaintext + + firewalls: + default: + form_login: ~ + anonymous: ~ + logout: ~ diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/some_voters_disabled.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/some_voters_disabled.yml new file mode 100644 index 0000000..0af61d2 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/some_voters_disabled.yml @@ -0,0 +1,10 @@ +imports: + - { resource: default.yml } + +security: + acl: ~ + +jms_security_extra: + voters: + disable_role: true + disable_acl: true diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/twig.yml b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/twig.yml new file mode 100644 index 0000000..2c8539a --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Functional/config/twig.yml @@ -0,0 +1,7 @@ +framework: + templating: + engines: [twig, php] + +twig: + debug: %kernel.debug% + strict_variables: %kernel.debug% \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/ClassMetadataTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/ClassMetadataTest.php new file mode 100644 index 0000000..1ec1d4d --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/ClassMetadataTest.php @@ -0,0 +1,117 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Metadata; + +use Doctrine\Common\Annotations\AnnotationReader; + +use JMS\SecurityExtraBundle\Metadata\Driver\AnnotationDriver; + +use Metadata\MetadataFactory; + +class ClassMetadataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @expectedException \RuntimeException + * @expectedMessage You have overridden a secured method "differentMethodSignature" in "SubService". Please copy over the applicable security metadata, and also add @SatisfiesParentSecurityPolicy. + */ + public function testAnalyzeThrowsExceptionWhenSecureMethodIsOverridden() + { + $this->getFactory()->getMetadataForClass('JMS\SecurityExtraBundle\Tests\Fixtures\SubService'); + } + + public function testAnalyzeThrowsNoExceptionWhenAbstractMethodIsNotOverridenInDirectChildClass() + { + $metadata = $this + ->getFactory() + ->getMetadataForClass('JMS\SecurityExtraBundle\Tests\Fixtures\AbstractMethodNotDirectlyOverwrittenInDirectChildService') + ; + + $this->assertTrue(isset($metadata->methodMetadata['abstractMethod'])); + + $metadata = $metadata->methodMetadata['abstractMethod']; + $this->assertEquals(array('VIEW'), $metadata->returnPermissions); + } + + public function testAnalyzeThrowsNoExceptionWhenSatisfiesParentSecurityPolicyIsDefined() + { + $metadata = $this + ->getFactory() + ->getMetadataForClass('JMS\SecurityExtraBundle\Tests\Fixtures\CorrectSubService') + ; + + $methods = $metadata->methodMetadata; + $this->assertTrue(isset($methods['differentMethodSignature'])); + + $metadata = $methods['differentMethodSignature']; + $this->assertEquals(array(), $metadata->roles); + $this->assertEquals(array(), $metadata->paramPermissions); + $this->assertEquals(array('VIEW'), $metadata->returnPermissions); + } + + public function testAnalyzeWithComplexHierarchy() + { + $metadata = $this + ->getFactory() + ->getMetadataForClass('JMS\SecurityExtraBundle\Tests\Fixtures\ComplexService') + ; + + $methods = $metadata->methodMetadata; + $this->assertTrue(isset($methods['delete'], $methods['retrieve'], $methods['abstractMethod'])); + + $metadata = $methods['delete']; + $this->assertEquals(array(0 => array('MASTER', 'EDIT'), 2 => array('OWNER')), $metadata->paramPermissions); + $this->assertEquals(array(), $metadata->returnPermissions); + $this->assertEquals(array(), $metadata->roles); + + $metadata = $methods['retrieve']; + $this->assertEquals(array('VIEW', 'UNDELETE'), $metadata->returnPermissions); + $this->assertEquals(array(), $metadata->paramPermissions); + $this->assertEquals(array(), $metadata->roles); + + $metadata = $methods['abstractMethod']; + $this->assertEquals(array('ROLE_FOO', 'IS_AUTHENTICATED_FULLY'), $metadata->roles); + $this->assertEquals(array(1 => array('FOO')), $metadata->paramPermissions); + $this->assertEquals(array('WOW'), $metadata->returnPermissions); + } + + public function testAnalyze() + { + $metadata = $this + ->getFactory() + ->getMetadataForClass('JMS\SecurityExtraBundle\Tests\Fixtures\MainService') + ; + + $methods = $metadata->methodMetadata; + $this->assertTrue(isset($methods['differentMethodSignature'])); + + $metadata = $methods['differentMethodSignature']; + $this->assertEquals(array(array('EDIT')), $metadata->paramPermissions); + $this->assertEquals(array(), $metadata->returnPermissions); + $this->assertEquals(array(), $metadata->roles); + $this->assertFalse($metadata->isDeclaredOnInterface()); + } + + private function getFactory() + { + $factory = new MetadataFactory(new AnnotationDriver(new AnnotationReader())); + $factory->setIncludeInterfaces(true); + + return $factory; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/AnnotationDriverTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/AnnotationDriverTest.php new file mode 100644 index 0000000..a300a4c --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/AnnotationDriverTest.php @@ -0,0 +1,66 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Mapping\Driver; + +use Doctrine\Common\Annotations\AnnotationReader; + +use JMS\SecurityExtraBundle\Metadata\Driver\AnnotationDriver; + +require_once __DIR__.'/Fixtures/services.php'; + +class AnnotationDriverTest extends \PHPUnit_Framework_TestCase +{ + public function testLoadMetadataFromClass() + { + $driver = new AnnotationDriver(new AnnotationReader()); + + $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Mapping\Driver\FooService')); + $this->assertTrue(isset($metadata->methodMetadata['foo'])); + $method = $metadata->methodMetadata['foo']; + $this->assertEquals(array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_SUPERADMIN'), $method->roles); + $this->assertEquals(array(), $method->returnPermissions); + $this->assertEquals(array(0 => array('VIEW')), $method->paramPermissions); + + $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Mapping\Driver\FooInterface')); + $this->assertTrue(isset($metadata->methodMetadata['foo'])); + $method = $metadata->methodMetadata['foo']; + $this->assertEquals(array(), $method->roles); + $this->assertEquals(array(0 => array('OWNER'), 1 => array('EDIT')), $method->paramPermissions); + $this->assertEquals(array('MASTER'), $method->returnPermissions); + } + + public function testLoadMetadataFromClassWithShortNotation() + { + $driver = new AnnotationDriver(new AnnotationReader()); + + $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Mapping\Driver\FooService')); + $this->assertTrue(isset($metadata->methodMetadata['shortNotation'])); + $method = $metadata->methodMetadata['shortNotation']; + $this->assertEquals(array('ROLE_FOO', 'ROLE_BAR'), $method->roles); + } + + public function testLoadMetadataFromClassDoesNotProcessMethodsForWhichNoSecurityMetadataExists() + { + $driver = new AnnotationDriver(new AnnotationReader()); + + $metadata = $driver->loadMetadataForClass(new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Fixtures\MainService')); + $this->assertTrue(class_exists('JMS\SecurityExtraBundle\Tests\Fixtures\Annotation\NonSecurityAnnotation', false)); + $this->assertFalse(isset($metadata->methodMetadata['foo'])); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/ConfigDriverTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/ConfigDriverTest.php new file mode 100644 index 0000000..fab043e --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/ConfigDriverTest.php @@ -0,0 +1,54 @@ + 'hasRole("FOO")', + )); + + $metadata = $driver->loadMetadataForClass($this->getClass('Controller\\CrudController')); + + $this->assertEquals(5, count($metadata->methodMetadata)); + + $metadata = $metadata->methodMetadata; + foreach (array('addAction', 'deleteAction', 'editAction', 'showAction', 'newAction') as $action) { + $this->assertArrayHasKey($action, $metadata); + $this->assertEquals(array(new Expression('hasRole("FOO")')), $metadata[$action]->roles); + } + } + + public function testLoadMetadataControllerNotation() + { + $driver = new ConfigDriver(array( + 'AcmeFooBundle' => 'JMS\SecurityExtraBundle\Tests\Metadata\Driver\Fixtures\AcmeFooBundle', + ), array( + '^AcmeFooBundle:.*:delete.*$' => 'hasRole("ROLE_ADMIN")', + )); + + $metadata = $driver->loadMetadataForClass($this->getClass('Controller\\CrudController')); + + $this->assertEquals(1, count($metadata->methodMetadata)); + $this->assertArrayHasKey('deleteAction', $metadata->methodMetadata); + $this->assertEquals(array(new Expression('hasRole("ROLE_ADMIN")')), $metadata->methodMetadata['deleteAction']->roles); + } + + public function testLoadMetadataWithoutConfig() + { + $driver = new ConfigDriver(array(), array()); + $this->assertNull($driver->loadMetadataForClass($this->getClass('Controller\\CrudController'))); + } + + private function getClass($name) + { + return new \ReflectionClass('JMS\SecurityExtraBundle\Tests\Metadata\Driver\Fixtures\\'.$name); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/Fixtures/Controller/CrudController.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/Fixtures/Controller/CrudController.php new file mode 100644 index 0000000..df1cbb8 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Metadata/Driver/Fixtures/Controller/CrudController.php @@ -0,0 +1,14 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Mapping\Driver; + +use JMS\SecurityExtraBundle\Annotation\SecureReturn; +use JMS\SecurityExtraBundle\Annotation\SecureParam; +use JMS\SecurityExtraBundle\Annotation\Secure; + +class FooService implements FooInterface +{ + /** + * @Secure(roles="ROLE_USER, ROLE_ADMIN, ROLE_SUPERADMIN") + * @SecureParam(name="param", permissions="VIEW") + */ + public function foo($param, $anotherParam) { } + + /** + * @Secure("ROLE_FOO, ROLE_BAR") + */ + public function shortNotation() { } +} +interface FooInterface +{ + /** + * @SecureParam(name="param", permissions="OWNER") + * @SecureParam(name="anotherParam", permissions="EDIT") + * @SecureReturn(permissions="MASTER") + */ + function foo($param, $anotherParam); +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/HasPermissionFunctionCompilerTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/HasPermissionFunctionCompilerTest.php new file mode 100644 index 0000000..551e755 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/HasPermissionFunctionCompilerTest.php @@ -0,0 +1,40 @@ +compiler->compile(new FunctionExpression('hasPermission', + array(new VariableExpression('foo'), new ConstantExpression('VIEW')))); + + $this->assertContains( + "\$context['permission_evaluator']->hasPermission(\$context['token'], \$context['foo'], 'VIEW');", + $source); + } + + public function testCompileUpperCasesPermissions() + { + $source = $this->compiler->compile(new FunctionExpression('hasPermission', + array(new VariableExpression('foo'), new ConstantExpression('view')))); + + $this->assertContains( + "\$context['permission_evaluator']->hasPermission(\$context['token'], \$context['foo'], 'VIEW');", + $source); + } + + protected function setUp() + { + $this->compiler = new ExpressionCompiler(); + $this->compiler->addFunctionCompiler(new HasPermissionFunctionCompiler()); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/PermissionEvaluatorTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/PermissionEvaluatorTest.php new file mode 100644 index 0000000..880914b --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Expression/PermissionEvaluatorTest.php @@ -0,0 +1,143 @@ +permissionMap->expects($this->once()) + ->method('getMasks') + ->with('VIEW', $this->oid) + ->will($this->returnValue(array(1, 2, 3, 4))); + $this->sidStrategy->expects($this->once()) + ->method('getSecurityIdentities') + ->with($this->token) + ->will($this->returnValue(array($this->sid))); + + $this->provider->expects($this->once()) + ->method('findAcl') + ->with($this->oid) + ->will($this->returnValue($this->acl)); + + $this->acl->expects($this->once()) + ->method('isGranted') + ->with(array(1, 2, 3, 4), array($this->sid), false) + ->will($this->returnValue(true)); + + $this->assertTrue($this->evaluator->hasPermission($this->token, $this->oid, 'VIEW')); + } + + public function testHasPermissionReturnsFalseWhenNoMasksExist() + { + $this->permissionMap->expects($this->once()) + ->method('getMasks') + ->with('FOO', $this->object) + ->will($this->returnValue(null)); + + $this->assertFalse($this->evaluator->hasPermission($this->token, $this->object, 'FOO')); + } + + public function testHasPermissionWhenNoObjectIsGiven() + { + $this->permissionMap->expects($this->once()) + ->method('getMasks') + ->with('FOO', null) + ->will($this->returnValue(array(1))); + + $this->assertTrue($this->evaluator->hasPermission($this->token, null, 'FOO')); + } + + public function testHasPermissionWhenNoObjectIdentityIsAvailable() + { + $this->permissionMap->expects($this->once()) + ->method('getMasks') + ->with('FOO', $this->object) + ->will($this->returnValue(array(1))); + + $this->oidStrategy->expects($this->once()) + ->method('getObjectIdentity') + ->with($this->object) + ->will($this->returnValue(null)); + + $this->assertTrue($this->evaluator->hasPermission($this->token, $this->object, 'FOO')); + } + + public function testHasPermissionWhenAclIsNotFound() + { + $this->permissionMap->expects($this->once()) + ->method('getMasks') + ->with('FOO', $this->oid) + ->will($this->returnValue(array(1))); + + $this->sidStrategy->expects($this->once()) + ->method('getSecurityIdentities') + ->with($this->token) + ->will($this->returnValue(array($this->sid))); + + $this->provider->expects($this->once()) + ->method('findAcl') + ->with($this->oid) + ->will($this->throwException(new AclNotFoundException())); + + $this->assertFalse($this->evaluator->hasPermission($this->token, $this->oid, 'FOO')); + } + + public function testHasPermissionWhenAceIsNotFound() + { + $this->permissionMap->expects($this->once()) + ->method('getMasks') + ->with('FOO', $this->oid) + ->will($this->returnValue(array(1))); + + $this->sidStrategy->expects($this->once()) + ->method('getSecurityIdentities') + ->with($this->token) + ->will($this->returnValue(array($this->sid))); + + $this->provider->expects($this->once()) + ->method('findAcl') + ->with($this->oid) + ->will($this->returnValue($this->acl)); + + $this->acl->expects($this->once()) + ->method('isGranted') + ->with(array(1), array($this->sid)) + ->will($this->throwException(new NoAceFoundException())); + + $this->assertFalse($this->evaluator->hasPermission($this->token, $this->oid, 'FOO')); + } + + protected function setUp() + { + $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $this->oid = $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityInterface'); + $this->sid = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface'); + $this->acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'); + $this->object = new \stdClass; + $this->provider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface'); + $this->oidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface'); + $this->sidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface'); + $this->permissionMap = $this->getMock('Symfony\Component\Security\Acl\Permission\PermissionMapInterface'); + $this->evaluator = new PermissionEvaluator($this->provider, $this->oidStrategy, $this->sidStrategy, $this->permissionMap); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Voter/AclVoterTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Voter/AclVoterTest.php new file mode 100644 index 0000000..16f2301 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Acl/Voter/AclVoterTest.php @@ -0,0 +1,396 @@ +getVoter(); + + $permissionMap + ->expects($this->once()) + ->method('contains') + ->with($this->identicalTo($attribute)) + ->will($this->returnValue($supported)) + ; + + $this->assertSame($supported, $voter->supportsAttribute($attribute)); + } + + public function getSupportsAttributeTests() + { + return array( + array('foo', true), + array('foo', false), + ); + } + + /** + * @dataProvider getSupportsClassTests + */ + public function testSupportsClass($class) + { + list($voter,,,,) = $this->getVoter(); + + $this->assertTrue($voter->supportsClass($class)); + } + + public function getSupportsClassTests() + { + return array( + array('foo'), + array('bar'), + array('moo'), + ); + } + + public function testVote() + { + list($voter,, $permissionMap,,) = $this->getVoter(); + $permissionMap + ->expects($this->atLeastOnce()) + ->method('getMasks') + ->will($this->returnValue(null)) + ; + + $this->assertSame(VoterInterface::ACCESS_ABSTAIN, $voter->vote($this->getToken(), null, array('VIEW', 'EDIT', 'DELETE'))); + } + + /** + * @dataProvider getTrueFalseTests + */ + public function testVoteWhenNoObjectIsPassed($allowIfObjectIdentityUnavailable) + { + list($voter,, $permissionMap,,) = $this->getVoter($allowIfObjectIdentityUnavailable); + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->will($this->returnValue(array())) + ; + + if ($allowIfObjectIdentityUnavailable) { + $vote = VoterInterface::ACCESS_GRANTED; + } else { + $vote = VoterInterface::ACCESS_ABSTAIN; + } + + $this->assertSame($vote, $voter->vote($this->getToken(), null, array('VIEW'))); + } + + /** + * @dataProvider getTrueFalseTests + */ + public function testVoteWhenOidStrategyReturnsNull($allowIfUnavailable) + { + list($voter,, $permissionMap, $oidStrategy,) = $this->getVoter($allowIfUnavailable); + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->will($this->returnValue(array())) + ; + + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue(null)) + ; + + if ($allowIfUnavailable) { + $vote = VoterInterface::ACCESS_GRANTED; + } else { + $vote = VoterInterface::ACCESS_ABSTAIN; + } + + $this->assertSame($vote, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); + } + + public function getTrueFalseTests() + { + return array(array(true), array(false)); + } + + public function testVoteNoAclFound() + { + list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); + + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->will($this->returnValue(array())) + ; + + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) + ; + + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) + ; + + $provider + ->expects($this->once()) + ->method('findAcl') + ->with($this->equalTo($oid), $this->equalTo($sids)) + ->will($this->throwException(new AclNotFoundException('Not found.'))) + ; + + $this->assertSame(VoterInterface::ACCESS_DENIED, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); + } + + /** + * @dataProvider getTrueFalseTests + */ + public function testVoteGrantsAccess($grant) + { + list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); + + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->with($this->equalTo('VIEW')) + ->will($this->returnValue($masks = array(1, 2, 3))) + ; + + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) + ; + + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) + ; + + $provider + ->expects($this->once()) + ->method('findAcl') + ->with($this->equalTo($oid), $this->equalTo($sids)) + ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ; + + $acl + ->expects($this->once()) + ->method('isGranted') + ->with($this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) + ->will($this->returnValue($grant)) + ; + + if ($grant) { + $vote = VoterInterface::ACCESS_GRANTED; + } else { + $vote = VoterInterface::ACCESS_DENIED; + } + + $this->assertSame($vote, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); + } + + public function testVoteNoAceFound() + { + list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); + + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->with($this->equalTo('VIEW')) + ->will($this->returnValue($masks = array(1, 2, 3))) + ; + + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) + ; + + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) + ; + + $provider + ->expects($this->once()) + ->method('findAcl') + ->with($this->equalTo($oid), $this->equalTo($sids)) + ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ; + + $acl + ->expects($this->once()) + ->method('isGranted') + ->with($this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) + ->will($this->throwException(new NoAceFoundException('No ACE'))) + ; + + $this->assertSame(VoterInterface::ACCESS_DENIED, $voter->vote($this->getToken(), new \stdClass(), array('VIEW'))); + } + + /** + * @dataProvider getTrueFalseTests + */ + public function testVoteGrantsFieldAccess($grant) + { + list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); + + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->with($this->equalTo('VIEW')) + ->will($this->returnValue($masks = array(1, 2, 3))) + ; + + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) + ; + + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) + ; + + $provider + ->expects($this->once()) + ->method('findAcl') + ->with($this->equalTo($oid), $this->equalTo($sids)) + ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ; + + $acl + ->expects($this->once()) + ->method('isFieldGranted') + ->with($this->identicalTo('foo'), $this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) + ->will($this->returnValue($grant)) + ; + + if ($grant) { + $vote = VoterInterface::ACCESS_GRANTED; + } else { + $vote = VoterInterface::ACCESS_DENIED; + } + + $this->assertSame($vote, $voter->vote($this->getToken(), new FieldVote(new \stdClass(), 'foo'), array('VIEW'))); + } + + public function testVoteNoFieldAceFound() + { + list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); + + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->with($this->equalTo('VIEW')) + ->will($this->returnValue($masks = array(1, 2, 3))) + ; + + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue($oid = new ObjectIdentity('1', 'Foo'))) + ; + + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) + ; + + $provider + ->expects($this->once()) + ->method('findAcl') + ->with($this->equalTo($oid), $this->equalTo($sids)) + ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ; + + $acl + ->expects($this->once()) + ->method('isFieldGranted') + ->with($this->identicalTo('foo'), $this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) + ->will($this->throwException(new NoAceFoundException('No ACE'))) + ; + + $this->assertSame(VoterInterface::ACCESS_DENIED, $voter->vote($this->getToken(), new FieldVote(new \stdClass(), 'foo'), array('VIEW'))); + } + + public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObjectIdentity() + { + list($voter, $provider, $permissionMap, $oidStrategy, $sidStrategy) = $this->getVoter(); + + $oid = new ObjectIdentity('someID','someType'); + + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->with($this->equalTo('VIEW')) + ->will($this->returnValue($masks = array(1, 2, 3))) + ; + + $oidStrategy + ->expects($this->never()) + ->method('getObjectIdentity') + ; + + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue($sids = array(new UserSecurityIdentity('johannes', 'Foo'), new RoleSecurityIdentity('ROLE_FOO')))) + ; + + $provider + ->expects($this->once()) + ->method('findAcl') + ->with($this->equalTo($oid), $this->equalTo($sids)) + ->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'))) + ; + + $acl + ->expects($this->once()) + ->method('isGranted') + ->with($this->identicalTo($masks), $this->equalTo($sids), $this->isFalse()) + ->will($this->throwException(new NoAceFoundException('No ACE'))) + ; + + $voter->vote($this->getToken(), $oid, array('VIEW')); + } + + protected function getToken() + { + return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + } + + protected function getVoter($allowIfObjectIdentityUnavailable = true) + { + $provider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface'); + $permissionMap = $this->getMock('Symfony\Component\Security\Acl\Permission\PermissionMapInterface'); + $oidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface'); + $sidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface'); + + return array( + new AclVoter($provider, $oidStrategy, $sidStrategy, $permissionMap, null, $allowIfObjectIdentityUnavailable), + $provider, + $permissionMap, + $oidStrategy, + $sidStrategy, + ); + } +} diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Provider/RunAsAuthenticationProviderTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Provider/RunAsAuthenticationProviderTest.php new file mode 100644 index 0000000..ddba3f7 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Provider/RunAsAuthenticationProviderTest.php @@ -0,0 +1,86 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Security\Authentication\Provider; + +use JMS\SecurityExtraBundle\Security\Authentication\Token\RunAsUserToken; + +use JMS\SecurityExtraBundle\Security\Authentication\Provider\RunAsAuthenticationProvider; + +class RunAsAuthenticationProviderTest extends \PHPUnit_Framework_TestCase +{ + public function testAuthenticateReturnsNullIfTokenISUnsupported() + { + $provider = new RunAsAuthenticationProvider('foo'); + $token = $this->GetMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + $this->assertNull($provider->authenticate($token)); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\BadCredentialsException + */ + public function testAuthenticateThrowsExceptionWhenKeysDontMatch() + { + $provider = new RunAsAuthenticationProvider('foo'); + $token = $this->getSupportedToken(); + $token + ->expects($this->once()) + ->method('getKey') + ->will($this->returnValue('moo')) + ; + + $provider->authenticate($token); + } + + public function testAuthenticate() + { + $provider = new RunAsAuthenticationProvider('foo'); + $token = $this->getSupportedToken(); + $token + ->expects($this->once()) + ->method('getKey') + ->will($this->returnValue('foo')) + ; + + $this->assertSame($token, $provider->authenticate($token)); + } + + public function testSupportsDoesNotAcceptInvalidToken() + { + $provider = new RunAsAuthenticationProvider('foo'); + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + $this->assertFalse($provider->supports($token)); + } + + public function testSupports() + { + $provider = new RunAsAuthenticationProvider('foo'); + + $token = $this->getSupportedToken(); + $this->assertTrue($provider->supports($token)); + } + + protected function getSupportedToken() + { + return $this->getMockBuilder('JMS\SecurityExtraBundle\Security\Authentication\Token\RunAsUserToken') + ->disableOriginalConstructor() + ->getMock(); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Token/RunAsUserTokenTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Token/RunAsUserTokenTest.php new file mode 100644 index 0000000..3c35ec2 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authentication/Token/RunAsUserTokenTest.php @@ -0,0 +1,54 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Security\Authentication\Token; + +use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; + +use Symfony\Component\Security\Core\Role\Role; +use JMS\SecurityExtraBundle\Security\Authentication\Token\RunAsUserToken; + +class RunAsUserTokenTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + $runAsToken = new RunAsUserToken('foo', $user, 'secret', array('ROLE_FOO'), $token); + $this->assertSame($user, $runAsToken->getUser()); + $this->assertSame('secret', $runAsToken->getCredentials()); + $this->assertSame($token, $runAsToken->getOriginalToken()); + $this->assertEquals(array(new Role('ROLE_FOO')), $runAsToken->getRoles()); + $this->assertSame('foo', $runAsToken->getKey()); + } + + public function testEraseCredentials() + { + $token = new RunAsUserToken('foo', 'foo', 'secret', array(), $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')); + $this->assertEquals('secret', $token->getCredentials()); + $token->eraseCredentials(); + $this->assertNull($token->getCredentials()); + } + + public function testSerializeUnserialize() + { + $token = new RunAsUserToken('foo', 'bar', 'secret', array(), new UsernamePasswordToken('foo', 'pass', 'foo', array())); + $this->assertEquals($token, unserialize(serialize($token))); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AclAfterInvocationProviderTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AclAfterInvocationProviderTest.php new file mode 100644 index 0000000..4dc39d3 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AclAfterInvocationProviderTest.php @@ -0,0 +1,248 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Security\Authorization\AfterInvocation; + +use Symfony\Component\Security\Acl\Exception\NoAceFoundException; + +use Symfony\Component\Security\Acl\Exception\AclNotFoundException; +use Symfony\Component\Security\Acl\Domain\ObjectIdentity; +use JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation\AclAfterInvocationProvider; + +class AclAfterInvocationProviderTest extends \PHPUnit_Framework_TestCase +{ + public function testDecideReturnsNullWhenObjectIsNull() + { + $provider = new AclAfterInvocationProvider($this->getAclProvider(), $this->getOidStrategy(), $this->getSidStrategy(), $this->getPermissionMap()); + + $this->assertNull($provider->decide($this->getToken(), null, array(), null)); + } + + public function testDecideDoesNotModifyReturnedObjectWhenNoAttributeIsSupported() + { + $provider = new AclAfterInvocationProvider($this->getAclProvider(), $this->getOidStrategy(), $this->getSidStrategy(), $this->getPermissionMap()); + + $returnedObject = new \stdClass; + $this->assertSame($returnedObject, $provider->decide($this->getToken(), null, array('foo', 'moo'), $returnedObject)); + } + + public function testDecideDoesNotModifyReturnedObjectWhenNoObjectIdentityCanBeRetrieved() + { + $oidStrategy = $this->getOidStrategy(); + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue(null)) + ; + + $permissionMap = $this->getPermissionMap(); + $permissionMap + ->expects($this->once()) + ->method('contains') + ->will($this->returnValue(true)) + ; + + $returnedObject = array('foo' => 'moo'); + $provider = new AclAfterInvocationProvider($this->getAclProvider(), $oidStrategy, $this->getSidStrategy(), $permissionMap); + $this->assertSame($returnedObject, $provider->decide($this->getToken(), null, array('foo'), $returnedObject)); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\AccessDeniedException + */ + public function testDecideThrowsAccessDeniedExceptionWhenNoAclIsFound() + { + $oidStrategy = $this->getOidStrategy(); + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue(new ObjectIdentity(1, 'foo'))) + ; + + $sidStrategy = $this->getSidStrategy(); + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue(array())) + ; + + $permissionMap = $this->getPermissionMap(); + $permissionMap + ->expects($this->once()) + ->method('contains') + ->will($this->returnValue(true)) + ; + + $aclProvider = $this->getAclProvider(); + $aclProvider + ->expects($this->once()) + ->method('findAcl') + ->will($this->throwException(new AclNotFoundException('No ACL'))) + ; + + $provider = new AclAfterInvocationProvider($aclProvider, $oidStrategy, $sidStrategy, $permissionMap); + $provider->decide($this->getToken(), null, array('foo'), 'foo'); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\AccessDeniedException + */ + public function testDecideThrowsAccessDeniedExceptionWhenNoAceIsFound() + { + $masks = array(1, 3); + $permissionMap = $this->getPermissionMap(); + $permissionMap + ->expects($this->once()) + ->method('contains') + ->will($this->returnValue(true)) + ; + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->will($this->returnValue($masks)) + ; + + $acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'); + $acl + ->expects($this->once()) + ->method('isGranted') + ->will($this->throwException(new NoAceFoundException('No ACE'))) + ; + + $aclProvider = $this->getAclProvider(); + $aclProvider + ->expects($this->once()) + ->method('findAcl') + ->will($this->returnValue($acl)) + ; + + $oidStrategy = $this->getOidStrategy(); + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue(new ObjectIdentity(1, 'foo'))) + ; + + $sidStrategy = $this->getSidStrategy(); + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue(array('foo'))) + ; + + $provider = new AclAfterInvocationProvider($aclProvider, $oidStrategy, $sidStrategy, $permissionMap); + $provider->decide($this->getToken(), null, array('foo'), array('foo')); + } + + public function testDecide() + { + $masks = array(1, 3); + $permissionMap = $this->getPermissionMap(); + $permissionMap + ->expects($this->once()) + ->method('contains') + ->will($this->returnValue(true)) + ; + $permissionMap + ->expects($this->once()) + ->method('getMasks') + ->will($this->returnValue($masks)) + ; + + $acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface'); + $acl + ->expects($this->once()) + ->method('isGranted') + ->will($this->returnValue(true)) + ; + + $aclProvider = $this->getAclProvider(); + $aclProvider + ->expects($this->once()) + ->method('findAcl') + ->will($this->returnValue($acl)) + ; + + $oidStrategy = $this->getOidStrategy(); + $oidStrategy + ->expects($this->once()) + ->method('getObjectIdentity') + ->will($this->returnValue(new ObjectIdentity(1, 'foo'))) + ; + + $sidStrategy = $this->getSidStrategy(); + $sidStrategy + ->expects($this->once()) + ->method('getSecurityIdentities') + ->will($this->returnValue(array('foo'))) + ; + + $provider = new AclAfterInvocationProvider($aclProvider, $oidStrategy, $sidStrategy, $permissionMap); + $this->assertSame(array('foo'), $provider->decide($this->getToken(), null, array('foo'), array('foo'))); + } + + public function testSupportsAttribute() + { + $aclProvider = $this->getAclProvider(); + $oidStrategy = $this->getOidStrategy(); + $sidStrategy = $this->getSidStrategy(); + $permissionMap = $this->getPermissionMap(); + + $permissionMap + ->expects($this->at(0)) + ->method('contains') + ->with($this->equalTo('foo')) + ->will($this->returnValue(true)) + ; + $permissionMap + ->expects($this->at(1)) + ->method('contains') + ->with($this->equalTo('asdf')) + ->wilL($this->returnValue(false)) + ; + + $provider = new AclAfterInvocationProvider($aclProvider, $oidStrategy, $sidStrategy, $permissionMap); + $this->assertTrue($provider->supportsAttribute('foo')); + $this->assertFalse($provider->supportsAttribute('asdf')); + } + + protected function getToken() + { + return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + } + + protected function getPermissionMap() + { + return $this->getMock('Symfony\Component\Security\Acl\Permission\PermissionMapInterface'); + } + + protected function getAclProvider() + { + return $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface'); + } + + protected function getOidStrategy() + { + return $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface'); + } + + protected function getSidStrategy() + { + return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface'); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AfterInvocationManagerTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AfterInvocationManagerTest.php new file mode 100644 index 0000000..fa88d0d --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/AfterInvocation/AfterInvocationManagerTest.php @@ -0,0 +1,107 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Security\Authorization\AfterInvocation; + +use JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation\AfterInvocationManager; + +class AfterInvocationManagerTest extends \PHPUnit_Framework_TestCase +{ + public function testDecide() + { + $attributes = array('FOO'); + + $provider1 = $this->getProvider(); + $provider1 + ->expects($this->once()) + ->method('decide') + ->with( + $this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'), + $this->anything(), + $this->equalTo($attributes), + $this->equalTo('foo') + ) + ->will($this->returnValue('bar')) + ; + + $provider2 = $this->getProvider(); + $provider2 + ->expects($this->once()) + ->method('decide') + ->with( + $this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'), + $this->anything(), + $this->equalTo($attributes), + $this->equalTo('bar') + ) + ->will($this->returnValue('moo')) + ; + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + $manager = new AfterInvocationManager(array($provider1, $provider2)); + $this->assertEquals('moo', $manager->decide($token, 'sth', $attributes, 'foo')); + } + + /** + * @dataProvider getSupportsTests + */ + public function testSupportsAttribute($attribute, $supported) + { + $provider = $this->getProvider(); + $provider + ->expects($this->once()) + ->method('supportsAttribute') + ->with($this->equalTo($attribute)) + ->will($this->returnValue($supported)) + ; + + $manager = new AfterInvocationManager(array($provider)); + $this->assertSame($supported, $manager->supportsAttribute($attribute)); + } + + /** + * @dataProvider getSupportsTests + */ + public function testSupportsClass($class, $supported) + { + $provider = $this->getProvider(); + $provider + ->expects($this->once()) + ->method('supportsClass') + ->with($this->equalTo($class)) + ->will($this->returnValue($supported)) + ; + + $manager = new AfterInvocationManager(array($provider)); + $this->assertSame($supported, $manager->supportsClass($class)); + } + + public function getSupportsTests() + { + return array( + array('FOO', true), + array('BAR', false), + ); + } + + protected function getProvider() + { + return $this->getMock('JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation\AfterInvocationProviderInterface'); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionCompilerTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionCompilerTest.php new file mode 100644 index 0000000..925a72d --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionCompilerTest.php @@ -0,0 +1,150 @@ +compiler->compileExpression(new Expression('isAnonymous()'))); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + $trustResolver = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface'); + $trustResolver->expects($this->once()) + ->method('isAnonymous') + ->with($token) + ->will($this->returnValue(true)); + + $context = array( + 'token' => $token, + 'trust_resolver' => $trustResolver, + ); + + $this->assertTrue($evaluator($context)); + } + + public function testCompileComplexExpression() + { + $evaluator = eval($this->compiler->compileExpression( + new Expression('hasRole("ADMIN") or hasAnyRole("FOO", "BAR")'))); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token->expects($this->once()) + ->method('getRoles') + ->will($this->returnValue(array(new Role('FOO')))); + $this->assertTrue($evaluator(array('token' => $token))); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token->expects($this->once()) + ->method('getRoles') + ->will($this->returnValue(array(new Role('BAZ')))); + $this->assertFalse($evaluator(array('token' => $token))); + } + + /** + * @dataProvider getPrecedenceTests + */ + public function testCompilePrecedence($expected, $a, $b, $c) + { + $evaluator = eval($this->compiler->compileExpression( + new Expression('A and (B or C)'))); + + $this->assertSame($expected, $evaluator(array('A' => $a, 'B' => $b, 'C' => $c))); + } + + public function getPrecedenceTests() + { + return array( + array(true, true, true, false), + array(true, true, true, true), + array(true, true, false, true), + array(false, true, false, false), + array(false, false, true, true), + array(false, false, true, false), + array(false, false, false, true), + array(false, false, false, false), + ); + } + + public function testCompileWhenParameterIsWrappedInMethodCall() + { + $this->compiler->addTypeCompiler(new ParameterExpressionCompiler()); + $this->compiler->addFunctionCompiler(new HasPermissionFunctionCompiler()); + + // the first call ensure that state is reset correctly + $this->compiler->compileExpression(new Expression( + 'hasPermission(#project.getCompany(), "OPERATOR")')); + $evaluator = eval($this->compiler->compileExpression( + new Expression('hasPermission(#project.getCompany(), "OPERATOR")'))); + + $secureObject = new SecuredObject(); + $project = new Project(); + $permissionEvaluator = $this->getMockBuilder('JMS\SecurityExtraBundle\Security\Acl\Expression\PermissionEvaluator') + ->disableOriginalConstructor() + ->getMock(); + $permissionEvaluator->expects($this->once()) + ->method('hasPermission') + ->will($this->returnValue(false)); + + $context = array( + 'token' => $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'), + 'object' => new MethodInvocation(new \ReflectionMethod($secureObject, 'delete'), $secureObject, array($project), array()), + 'permission_evaluator' => $permissionEvaluator, + ); + + $this->assertFalse($evaluator($context)); + } + + /** + * @dataProvider getUnaryNotTests + */ + public function testCompileWithUnaryOperator($roles, $expected) + { + $evaluator = eval($this->compiler->compileExpression(new Expression( + 'not hasRole("FOO") and !hasRole("BAR") and hasRole("BAZ")'))); + + $roles = array_map(function($v) { + return new Role($v); + }, $roles); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token->expects($this->once()) + ->method('getRoles') + ->will($this->returnValue($roles)); + + $this->assertSame($expected, $evaluator(array('token' => $token))); + } + + public function getUnaryNotTests() + { + return array( + array(array('FOO'), false), + array(array(), false), + array(array('BAR'), false), + array(array('BAZ'), true), + array(array('FOO', 'BAR'), false), + array(array('FOO', 'BAZ'), false), + array(array('BAR', 'BAZ'), false), + ); + } + + protected function setUp() + { + $this->compiler = new ExpressionCompiler(); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionLexerTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionLexerTest.php new file mode 100644 index 0000000..34b87d0 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionLexerTest.php @@ -0,0 +1,27 @@ +lexer->initialize('#contact'); + + $this->assertEquals(array( + 'type' => ExpressionLexer::T_PARAMETER, + 'value' => 'contact', + 'position' => 0, + ), $this->lexer->lookahead); + $this->assertFalse($this->lexer->next()); + } + + protected function setUp() + { + $this->lexer = new ExpressionLexer(); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionParserTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionParserTest.php new file mode 100644 index 0000000..3472470 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionParserTest.php @@ -0,0 +1,158 @@ +assertEquals(new FunctionExpression('isAnonymous', array()), + $this->parser->parse('isAnonymous()')); + } + + public function testSingleFunctionWithOneArgument() + { + $this->assertEquals(new FunctionExpression('hasRole', array( + new ConstantExpression('ROLE_ADMIN'))), + $this->parser->parse('hasRole("ROLE_ADMIN")')); + } + + public function testSingleFunctionWithMultipleArguments() + { + $this->assertEquals(new FunctionExpression('hasAnyRole', array( + new ConstantExpression('FOO'), new ConstantExpression('BAR'))), + $this->parser->parse('hasAnyRole("FOO", "BAR",)')); + } + + public function testComplexFunctionExpression() + { + $expected = new OrExpression(new FunctionExpression('hasRole', array( + new ConstantExpression('ADMIN'))), + new FunctionExpression('hasAnyRole', array(new ConstantExpression('FOO'), + new ConstantExpression('BAR')))); + + $this->assertEquals($expected, $this->parser->parse('hasRole("ADMIN") or hasAnyRole("FOO", "BAR")')); + } + + public function testAnd() + { + $expected = new AndExpression( + new FunctionExpression('isAnonymous', array()), + new FunctionExpression('hasRole', array(new ConstantExpression('FOO')))); + + $this->assertEquals($expected, $this->parser->parse('isAnonymous() && hasRole("FOO")')); + $this->assertEquals($expected, $this->parser->parse('isAnonymous() and hasRole("FOO")')); + } + + /** + * @dataProvider getPrecedenceTests + */ + public function testPrecendence($expected, $expr) + { + $this->assertEquals($expected, $this->parser->parse($expr)); + } + + public function getPrecedenceTests() + { + $tests = array(); + + $expected = new OrExpression( + new AndExpression(new VariableExpression('A'), new VariableExpression('B')), + new VariableExpression('C') + ); + $tests[] = array($expected, 'A && B || C'); + $tests[] = array($expected, '(A && B) || C'); + + $expected = new OrExpression( + new VariableExpression('C'), + new AndExpression(new VariableExpression('A'), new VariableExpression('B')) + ); + $tests[] = array($expected, 'C || A && B'); + $tests[] = array($expected, 'C || (A && B)'); + + $expected = new AndExpression( + new AndExpression(new VariableExpression('A'), new VariableExpression('B')), + new VariableExpression('C') + ); + $tests[] = array($expected, 'A && B && C'); + + $expected = new AndExpression( + new VariableExpression('A'), + new OrExpression(new VariableExpression('B'), new VariableExpression('C')) + ); + $tests[] = array($expected, 'A && (B || C)'); + + return $tests; + } + + public function testGetProperty() + { + $expected = new GetPropertyExpression(new VariableExpression('A'), 'foo'); + $this->assertEquals($expected, $this->parser->parse('A.foo')); + } + + public function testMethodCall() + { + $expected = new MethodCallExpression(new VariableExpression('A'), 'foo', array()); + $this->assertEquals($expected, $this->parser->parse('A.foo()')); + } + + public function testArray() + { + $expected = new ArrayExpression(array( + 'foo' => new ConstantExpression('bar'), + )); + $this->assertEquals($expected, $this->parser->parse('{"foo":"bar",}')); + $this->assertEquals($expected, $this->parser->parse('{"foo":"bar"}')); + + $expected = new ArrayExpression(array( + new ConstantExpression('foo'), + new ConstantExpression('bar'), + )); + $this->assertEquals($expected, $this->parser->parse('["foo","bar",]')); + $this->assertEquals($expected, $this->parser->parse('["foo","bar"]')); + } + + public function testGetItem() + { + $expected = new GetItemExpression( + new GetPropertyExpression(new VariableExpression('A'), 'foo'), + new ConstantExpression('foo') + ); + $this->assertEquals($expected, $this->parser->parse('A.foo["foo"]')); + } + + public function testParameter() + { + $expected = new ParameterExpression('contact'); + $this->assertEquals($expected, $this->parser->parse('#contact')); + } + + public function testIsEqual() + { + $expected = new IsEqualExpression(new MethodCallExpression( + new VariableExpression('user'), 'getUsername', array()), + new ConstantExpression('Johannes')); + $this->assertEquals($expected, $this->parser->parse('user.getUsername() == "Johannes"')); + } + + protected function setUp() + { + $this->parser = new ExpressionParser; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionVoterTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionVoterTest.php new file mode 100644 index 0000000..e162b34 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/ExpressionVoterTest.php @@ -0,0 +1,113 @@ +voter->setCacheDir(null); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token->expects($this->once()) + ->method('getRoles') + ->will($this->returnValue(array(new Role('ROLE_FOO')))); + + $this->assertSame(VoterInterface::ACCESS_GRANTED, $this->voter->vote( + $token, + new \stdClass, + array(new Expression('hasRole("ROLE_FOO")')) + )); + } + + /** + * @dataProvider getVoteTests + */ + public function testVote($token, $object, array $attributes, $expected) + { + $this->assertSame($expected, $this->voter->vote($token, $object, $attributes)); + } + + public function getVoteTests() + { + $tests = array(); + + $tests[] = array( + $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'), + new \stdClass(), + array('ROLE_FOO'), + VoterInterface::ACCESS_ABSTAIN, + ); + + $tests[] = array( + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken') + ->disableOriginalConstructor()->getMock(), + new \stdClass(), + array(new Expression('isAnonymous()')), + VoterInterface::ACCESS_GRANTED, + ); + + $tests[] = array( + $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken') + ->disableOriginalConstructor()->getMock(), + new \stdClass(), + array(new Expression('isAuthenticated()')), + VoterInterface::ACCESS_DENIED, + ); + + return $tests; + } + + public function testSupportsAttribute() + { + $this->assertFalse($this->voter->supportsAttribute('ROLE_FOO')); + $this->assertFalse($this->voter->supportsAttribute('A')); + $this->assertTrue($this->voter->supportsAttribute(new Expression('A'))); + } + + public function testSupportsClass() + { + $this->assertTrue($this->voter->supportsClass('stdClass')); + } + + protected function setUp() + { + $handler = new DefaultExpressionHandler(new AuthenticationTrustResolver( + 'Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', + 'Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')); + + $this->voter = new ExpressionVoter($handler); + $this->voter->setCompiler(new ExpressionCompiler()); + + $this->fs = new Filesystem(); + $this->cacheDir = sys_get_temp_dir().'/'.uniqid('expression_voter', true); + + if (is_dir($this->cacheDir)) { + $this->fs->remove($this->cacheDir); + } + + if (false === @mkdir($this->cacheDir, 0777, true)) { + throw new \RuntimeException(sprintf('Could not create cache dir "%s".', $this->cacheDir)); + } + } + + protected function tearDown() + { + if (null !== $this->fs) { + $this->fs->remove($this->cacheDir); + } + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/Project.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/Project.php new file mode 100644 index 0000000..ffacf2f --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/Project.php @@ -0,0 +1,18 @@ +company = new \stdClass; + } + + public function getCompany() + { + return $this->company; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/SecuredObject.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/SecuredObject.php new file mode 100644 index 0000000..027c610 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Expression/Fixture/Issue22/SecuredObject.php @@ -0,0 +1,14 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Security\Authorization\Expression; + +use CG\Proxy\MethodInvocation; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\ParameterExpressionCompiler; +use JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler; + +class ParameterExpressionCompilerTest extends \PHPUnit_Framework_TestCase +{ + private $compiler; + + public function testCompile() + { + $evaluator = eval($source = $this->compiler->compileExpression(new Expression( + '#foo == "bar"'))); + + $object = new ParameterAccessTest; + $reflection = new \ReflectionMethod($object, 'secure'); + $invocation = new MethodInvocation($reflection, $object, array('bar'), array()); + $this->assertTrue($evaluator(array('object' => $invocation))); + + $invocation->arguments = array('foo'); + $this->assertFalse($evaluator(array('object' => $invocation))); + } + + /** + * @expectedException \RuntimeException + */ + public function testCompileThrowsExceptionWhenNoMethodInvocation() + { + $evaluator = eval($this->compiler->compileExpression(new Expression( + '#foo == "fofo"'))); + + $evaluator(array('object' => new \stdClass)); + } + + protected function setUp() + { + $this->compiler = new ExpressionCompiler(); + $this->compiler->addTypeCompiler(new ParameterExpressionCompiler()); + } +} + +class ParameterAccessTest +{ + public function secure($foo) + { + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/MethodSecurityInterceptorTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/MethodSecurityInterceptorTest.php new file mode 100644 index 0000000..e6634b3 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/MethodSecurityInterceptorTest.php @@ -0,0 +1,314 @@ + + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception; + +use JMS\SecurityExtraBundle\Exception\RuntimeException; +use JMS\SecurityExtraBundle\Metadata\MethodMetadata; + +use JMS\SecurityExtraBundle\Metadata\ClassMetadata; + +use Metadata\MetadataFactoryInterface; + +use JMS\SecurityExtraBundle\Security\Authentication\Token\RunAsUserToken; +use Symfony\Component\Security\Core\Exception\AuthenticationException; +use JMS\SecurityExtraBundle\Security\Authorization\Interception\MethodSecurityInterceptor; +use CG\Proxy\MethodInvocation; + +class MethodSecurityInterceptorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @expectedException Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException + */ + public function testInvokeThrowsExceptionWhenSecurityContextHasNoToken() + { + list($interceptor, $securityContext,,,,) = $this->getInterceptor(); + + $securityContext + ->expects($this->once()) + ->method('getToken') + ->will($this->returnValue(null)) + ; + + $this->getInvocation($interceptor)->proceed(); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\AuthenticationException + */ + public function testInvokeAuthenticatesTokenIfItIsNotYetAuthenticated() + { + list($interceptor, $securityContext, $authManager,,,) = $this->getInterceptor(); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token + ->expects($this->once()) + ->method('isAuthenticated') + ->will($this->returnValue(false)) + ; + + $securityContext + ->expects($this->once()) + ->method('getToken') + ->will($this->returnValue($token)) + ; + + $authManager + ->expects($this->once()) + ->method('authenticate') + ->will($this->throwException(new AuthenticationException('Could not authenticate.'))) + ; + + $this->getInvocation($interceptor)->proceed(); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\AuthenticationException + */ + public function testInvokeAuthenticatesTokenIfAlwaysAuthenticateIsTrue() + { + list($interceptor, $securityContext, $authManager,,,) = $this->getInterceptor(); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + $securityContext + ->expects($this->once()) + ->method('getToken') + ->will($this->returnValue($token)) + ; + + $authManager + ->expects($this->once()) + ->method('authenticate') + ->will($this->throwException(new AuthenticationException('Could not authenticate.'))) + ; + + $invocation = $this->getInvocation($interceptor); + $interceptor->setAlwaysAuthenticate(true); + + $invocation->proceed(); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\AccessDeniedException + */ + public function testInvokeCallsADMForRolesAndThrowsExceptionWhenInsufficientPriviledges() + { + $factory = $this->getMock('Metadata\MetadataFactoryInterface'); + $metadata = new ClassMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService'); + $metadata->methodMetadata['foo'] = new MethodMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService', 'foo'); + $metadata->methodMetadata['foo']->roles = array('ROLE_FOO'); + $factory + ->expects($this->once()) + ->method('getMetadataForClass') + ->with($this->equalTo($metadata->reflection->name)) + ->will($this->returnValue($metadata)) + ; + + list($interceptor, $context, $authManager, $adm,,) = $this->getInterceptor($factory); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token + ->expects($this->once()) + ->method('isAuthenticated') + ->will($this->returnValue(false)) + ; + + $context + ->expects($this->once()) + ->method('getToken') + ->will($this->returnValue($token)) + ; + $context + ->expects($this->once()) + ->method('setToken') + ->with($this->equalTo($token)) + ; + + $authManager + ->expects($this->once()) + ->method('authenticate') + ->will($this->returnValue($token)) + ; + + $invocation = $this->getInvocation($interceptor); + $adm + ->expects($this->once()) + ->method('decide') + ->with($this->equalTo($token), $this->equalTo(array('ROLE_FOO')), $this->equalTo($invocation)) + ->will($this->returnValue(false)) + ; + + $invocation->proceed(); + } + + /** + * @expectedException Symfony\Component\Security\Core\Exception\AccessDeniedException + */ + public function testInvokeCallsADMForEachParamPermissionsAndThrowsExceptionOnInsufficientPermissions() + { + $factory = $this->getMock('Metadata\MetadataFactoryInterface'); + $metadata = new ClassMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService'); + $metadata->methodMetadata['foo'] = new MethodMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService', 'foo'); + $metadata->methodMetadata['foo']->paramPermissions = array( + $p0 = array('ROLE_FOO', 'ROLE_ASDF'), + $p1 = array('ROLE_MOO'), + ); + $factory + ->expects($this->once()) + ->method('getMetadataForClass') + ->with($this->equalTo($metadata->reflection->name)) + ->will($this->returnValue($metadata)) + ; + + list($interceptor, $context,, $adm,,) = $this->getInterceptor($factory); + + $context + ->expects($this->once()) + ->method('getToken') + ->will($this->returnValue($token = $this->getToken())) + ; + + $invocation = $this->getInvocation($interceptor); + $adm + ->expects($this->at(0)) + ->method('decide') + ->with($this->equalTo($token), $this->equalTo($p0), $this->equalTo(new \stdClass())) + ->will($this->returnValue(true)) + ; + $adm + ->expects($this->at(1)) + ->method('decide') + ->with($this->equalTo($token), $this->equalTo($p1), $this->equalTo(new \stdClass())) + ->will($this->returnValue(false)) + ; + + $invocation->proceed(); + } + + /** + * @expectedException \RuntimeException + */ + public function testInvokehandlesExceptionsFromWithintheInvokedMethodGracefully() + { + $factory = $this->getMock('Metadata\MetadataFactoryInterface'); + $metadata = new ClassMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService'); + $metadata->methodMetadata['throwException'] = new MethodMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService', 'foo'); + $metadata->methodMetadata['throwException']->runAsRoles = array('ROLE_FOO'); + $factory + ->expects($this->once()) + ->method('getMetadataForClass') + ->with($this->equalTo($metadata->reflection->name)) + ->will($this->returnValue($metadata)) + ; + + list($interceptor, $context,,,, $runAsManager) = $this->getInterceptor($factory); + $invocation = $this->getInvocation($interceptor, 'throwException'); + + $token = $this->getToken(); + $context + ->expects($this->once()) + ->method('getToken') + ->will($this->returnValue($token)) + ; + + $runAsToken = new RunAsUserToken('asdf', 'user', 'foo', array('ROLE_FOO'), $token); + $runAsManager + ->expects($this->once()) + ->method('buildRunAs') + ->will($this->returnValue($runAsToken)) + ; + + $context + ->expects($this->exactly(2)) + ->method('setToken') + ; + + $invocation->proceed(); + } + + protected function getToken($isAuthenticated = true) + { + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $token + ->expects($this->once()) + ->method('isAuthenticated') + ->will($this->returnValue($isAuthenticated)) + ; + + return $token; + } + + protected function getInterceptor(MetadataFactoryInterface $metadataFactory = null) + { + if (null === $metadataFactory) { + $metadataFactory = $this->getMock('Metadata\MetadataFactoryInterface'); + + $metadata = new ClassMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService'); + $metadata->methodMetadata['foo'] = new MethodMetadata('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService', 'foo'); + + $metadataFactory + ->expects($this->once()) + ->method('getMetadataForClass') + ->with($this->equalTo('JMS\SecurityExtraBundle\Tests\Security\Authorization\Interception\SecureService')) + ->will($this->returnValue($metadata)) + ; + } + + $securityContext = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContext') + ->disableOriginalConstructor() + ->getMock(); + + $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); + $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); + $afterInvocationManager = $this->getMock('JMS\SecurityExtraBundle\Security\Authorization\AfterInvocation\AfterInvocationManagerInterface'); + $runAsManager = $this->getMock('JMS\SecurityExtraBundle\Security\Authorization\RunAsManagerInterface'); + + return array( + new MethodSecurityInterceptor($securityContext, $authenticationManager, $accessDecisionManager, $afterInvocationManager, $runAsManager, $metadataFactory), + $securityContext, + $authenticationManager, + $accessDecisionManager, + $afterInvocationManager, + $runAsManager, + ); + } + + protected function getInvocation(MethodSecurityInterceptor $interceptor, $method = 'foo', $arguments = array()) + { + if ('foo' === $method && 0 === count($arguments)) { + $arguments = array(new \stdClass(), new \stdClass()); + } + $object = new SecureService(); + + return new MethodInvocation(new \ReflectionMethod($object, $method), $object, $arguments, array($interceptor)); + } +} + +class SecureService +{ + public function foo($param, $other) + { + return $param; + } + + public function throwException() + { + throw new RuntimeException; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/SecurityPointcutTest.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/SecurityPointcutTest.php new file mode 100644 index 0000000..b275568 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Tests/Security/Authorization/Interception/SecurityPointcutTest.php @@ -0,0 +1,34 @@ +metadataFactory, false, array( + 'Foo::bar' => 'foo', + 'login$' => 'foo', + )); + + $this->assertTrue($pointcut->matchesClass(new \ReflectionClass('stdClass'))); + } + + public function testMatchesClassReturnsFalseForControllerNotation() + { + $pointcut = new SecurityPointcut($this->metadataFactory, false, array( + 'AcmeFooBundle:Foo:foo' => 'foo', + )); + + $this->assertFalse($pointcut->matchesClass(new \ReflectionClass('stdClass'))); + } + + protected function setUp() + { + $this->metadataFactory = $this->getMock('Metadata\MetadataFactoryInterface'); + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Twig/SecurityExtension.php b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Twig/SecurityExtension.php new file mode 100644 index 0000000..21ad8aa --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/Twig/SecurityExtension.php @@ -0,0 +1,35 @@ +context = $context; + } + + public function getFunctions() + { + return array( + 'is_expr_granted' => new \Twig_Function_Method($this, 'isExprGranted', array( + 'is_safe' => true, + )), + ); + } + + public function isExprGranted($expr, $object = null) + { + return $this->context->isGranted(array(new Expression($expr)), $object); + } + + public function getName() + { + return 'jms_security_extra'; + } +} \ No newline at end of file diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/composer.json b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/composer.json new file mode 100644 index 0000000..00e4113 --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/composer.json @@ -0,0 +1,25 @@ +{ + "name": "jms/security-extra-bundle", + "description": "Enhances the Symfony2 Security Component by adding several new features", + "keywords": ["annotations","authorization"], + "type": "symfony-bundle", + "license": "Apache", + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "require": { + "symfony/framework-bundle": "2.*", + "jms/metadata": "1.1.*", + "jms/aop-bundle": "1.0.*" + }, + "recommend": { + "jms/di-extra-bundle": "1.0.*" + }, + "autoload": { + "psr-0": { "JMS\\SecurityExtraBundle": "" } + }, + "target-dir": "JMS/SecurityExtraBundle" +} diff --git a/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/phpunit.xml.dist b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/phpunit.xml.dist new file mode 100644 index 0000000..e57dcda --- /dev/null +++ b/vendor/jms/security-extra-bundle/JMS/SecurityExtraBundle/schmittjoh-JMSSecurityExtraBundle-3730eb1/phpunit.xml.dist @@ -0,0 +1,19 @@ + + + + + + ./Tests + + + diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/.gitignore b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/.gitignore new file mode 100644 index 0000000..aba4f4e --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/.gitignore @@ -0,0 +1,4 @@ +vendor +composer.phar +phpunit.xml +composer.lock diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/.travis.yml b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/.travis.yml new file mode 100644 index 0000000..eb35049 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/.travis.yml @@ -0,0 +1,11 @@ +language: php + +php: + - 5.3 + - 5.4 + +before_script: + - curl -s http://getcomposer.org/installer | php + - php composer.phar install --dev + +script: phpunit diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/CHANGELOG.mdown b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/CHANGELOG.mdown new file mode 100644 index 0000000..ddaa16e --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/CHANGELOG.mdown @@ -0,0 +1,38 @@ +* 1.1.0 (2012-04-23) + + Changes: + + * Added Monolog\Logger::isHandling() to check if a handler will + handle the given log level + * Added ChromePHPHandler + * Added MongoDBHandler + * Added GelfHandler (for use with Graylog2 servers) + * Added SocketHandler (for use with syslog-ng for example) + * Added NormalizerFormatter + * Added the possibility to change the activation strategy of the FingersCrossedHandler + * Added possibility to show microseconds in logs + * Added `server` and `referer` to WebProcessor output + +* 1.0.2 (2011-10-24) + + Changes: + + * Fixed bug in IE with large response headers and FirePHPHandler + +* 1.0.1 (2011-08-25) + + Changes: + + * Added MemoryPeakUsageProcessor and MemoryUsageProcessor + * Added Monolog\Logger::getName() to get a logger's channel name + +* 1.0.0 (2011-07-06) + + Changes: + + * Added IntrospectionProcessor to get info from where the logger was called + * Fixed WebProcessor in CLI + +* 1.0.0-RC1 (2011-07-01) + + * Initial release diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/LICENSE b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/LICENSE new file mode 100644 index 0000000..5df1c39 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/README.mdown b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/README.mdown new file mode 100644 index 0000000..786aac1 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/README.mdown @@ -0,0 +1,172 @@ +Monolog - Logging for PHP 5.3 +============================= + +[![Build Status](https://secure.travis-ci.org/Seldaek/monolog.png)](http://travis-ci.org/Seldaek/monolog) + +Usage +----- + + use Monolog\Logger; + use Monolog\Handler\StreamHandler; + + // create a log channel + $log = new Logger('name'); + $log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); + + // add records to the log + $log->addWarning('Foo'); + $log->addError('Bar'); + +Core Concepts +------------- + +Every Logger instance has a channel (name) and a stack of handlers. Whenever +you add a record to the logger, it traverses the handler stack. Each handler +decides whether it handled fully the record, and if so, the propagation of the +record ends there. + +This allow for flexible logging setups, for example having a FileHandler at +the bottom of the stack that will log anything to disk, and on top of that add +a MailHandler that will send emails only when an error message is logged. +Handlers also have a bubbling property which define whether they block the +record or not if they handled it. In this example, setting the MailHandler's +$bubble argument to true means that all records will propagate to the +FileHandler, even the errors that are handled by the MailHandler. + +You can create many Loggers, each defining a channel (e.g.: db, request, +router, ..) and each of them combining various handlers, which can be shared +or not. The channel is reflected in the logs and allows you to easily see or +filter records. + +Each Handler also has a Formatter, a default one with settings that make sense +will be created if you don't set one. The formatters normalize and format +incoming records so that they can be used by the handlers to output useful +information. + +Custom severity levels are not available. Only six levels (debug, info, +warning, error, critical, alert) are present for basic filtering purposes, but +for sorting and other use cases that would require flexibility, you should add +Processors to the Logger that can add extra information (tags, user ip, ..) to +the records before they are handled. + +Log Levels +---------- + +Monolog exposes 6 log levels. Although it is possible to add more by extending +the classes you need, these are generally enough. + +- **DEBUG** (100): Detailed debug information. + +- **INFO** (200): Interesting events. Examples: User logs in, SQL logs. + +- **WARNING** (300): Exceptional occurrences that are not errors. Examples: + Use of deprecated APIs, poor use of an API, undesirable things that are not + necessarily wrong. + +- **ERROR** (400): Runtime errors that do not require immediate action but + should typically be logged and monitored. + +- **CRITICAL** (500): Critical conditions. Example: Application component + unavailable, unexpected exception. + +- **ALERT** (550): Action must be taken immediately. Example: Entire website + down, database unavailable, etc. This should trigger the SMS alerts and wake + you up. + +Docs +==== + +**See the doc/ directory for more detailed documentation. The following is only a list of all parts that come with Monolog.** + +Handlers +-------- + +- _StreamHandler_: Logs records into any php stream, use this for log files. +- _RotatingFileHandler_: Logs records to a file and creates one logfile per day. + It will also delete files older than $maxFiles. You should use + [logrotate](http://linuxcommand.org/man_pages/logrotate8.html) for high profile + setups though, this is just meant as a quick and dirty solution. +- _FirePHPHandler_: Handler for [FirePHP](http://www.firephp.org/), providing + inline `console` messages within [FireBug](http://getfirebug.com/). +- _ChromePHPHandler_: Handler for [ChromePHP](http://www.chromephp.com/), providing + inline `console` messages within Chrome. +- _MongoDBHandler_: Handler to write records in MongoDB via a + [Mongo](http://pecl.php.net/package/mongo) extension connection. +- _NativeMailHandler_: Sends emails using PHP's mail() function. +- _SwiftMailerHandler_: Sends emails using a SwiftMailer instance. +- _SyslogHandler_: Logs records to the syslog. +- _GelfHandler_: Logs records to a [Graylog2](http://www.graylog2.org) server. +- _SocketHandler_: Logs records to [sockets](http://php.net/fsockopen), use this + for UNIX and TCP sockets. See an [example](https://github.com/Seldaek/monolog/blob/master/doc/sockets.md). + +Wrappers / Special Handlers +--------------------------- + +- _FingersCrossedHandler_: A very interesting wrapper. It takes a logger as + parameter and will accumulate log records of all levels until a record + exceeds the defined severity level. At which point it delivers all records, + including those of lower severity, to the handler it wraps. This means that + until an error actually happens you will not see anything in your logs, but + when it happens you will have the full information, including debug and info + records. This provides you with all the information you need, but only when + you need it. +- _NullHandler_: Any record it can handle will be thrown away. This can be used + to put on top of an existing handler stack to disable it temporarily. +- _BufferHandler_: This handler will buffer all the log records it receives + until close() is called at which point it will call handleBatch() on the + handler it wraps with all the log messages at once. This is very useful to + send an email with all records at once for example instead of having one mail + for every log record. +- _GroupHandler_: This handler groups other handlers. Every record received is + sent to all the handlers it is configured with. +- _TestHandler_: Used for testing, it records everything that is sent to it and + has accessors to read out the information. + +Formatters +---------- + +- _LineFormatter_: Formats a log record into a one-line string. +- _NormalizerFormatter_: Normalizes objects/resources down to strings so a record can easily be serialized/encoded. +- _JsonFormatter_: Encodes a log record into json. +- _WildfireFormatter_: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler. +- _ChromePHPFormatter_: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler. +- _GelfFormatter_: Used to format log records into Gelf message instances, only useful for the GelfHandler. + +Processors +---------- + +- _IntrospectionProcessor_: Adds the line/file/class/method from which the log call originated. +- _WebProcessor_: Adds the current request URI, request method and client IP to a log record. +- _MemoryUsageProcessor_: Adds the current memory usage to a log record. +- _MemoryPeakUsageProcessor_: Adds the peak memory usage to a log record. + +About +===== + +Requirements +------------ + +- Any flavor of PHP 5.3 should do +- [optional] PHPUnit 3.5+ to execute the test suite (phpunit --version) + +Submitting bugs and feature requests +------------------------------------ + +Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/monolog/issues) + +Author +------ + +Jordi Boggiano - -
+See also the list of [contributors](https://github.com/Seldaek/monolog/contributors) which participated in this project. + +License +------- + +Monolog is licensed under the MIT License - see the LICENSE file for details + +Acknowledgements +---------------- + +This library is heavily inspired by Python's [Logbook](http://packages.python.org/Logbook/) +library, although most concepts have been adjusted to fit to the PHP world. diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/composer.json b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/composer.json new file mode 100644 index 0000000..c8c28b0 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/composer.json @@ -0,0 +1,27 @@ +{ + "name": "monolog/monolog", + "description": "Logging for PHP 5.3", + "keywords": ["log","logging"], + "homepage": "http://github.com/Seldaek/monolog", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "mlehner/gelf-php": "1.0.*" + }, + "suggest": { + "mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server" + }, + "autoload": { + "psr-0": {"Monolog": "src/"} + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/extending.md b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/extending.md new file mode 100644 index 0000000..fcd7af2 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/extending.md @@ -0,0 +1,76 @@ +Extending Monolog +================= + +Monolog is fully extensible, allowing you to adapt your logger to your needs. + +Writing your own handler +------------------------ + +Monolog provides many built-in handlers. But if the one you need does not +exist, you can write it and use it in your logger. The only requirement is +to implement `Monolog\Handler\HandlerInterface`. + +Let's write a PDOHandler to log records to a database. We will extend the +abstract class provided by Monolog to keep things DRY. + +```php +pdo = $pdo; + parent::__construct($level, $bubble); + } + + protected function write(array $record) + { + if (!$this->initialized) { + $this->initialize(); + } + + $this->statement->execute(array( + 'channel' => $record['channel'], + 'level' => $record['level'], + 'message' => $record['formatted'], + 'time' => $record['datetime']->format('U'), + )); + } + + private function initialize() + { + $this->pdo->exec( + 'CREATE TABLE IF NOT EXISTS monolog ' + .'(channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)' + ); + $this->statement = $this->pdo->prepare( + 'INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)' + ); + + $this->initialized = true; + } +} +``` + +You can now use this handler in your logger: + +```php +pushHandler(new PDOHandler(new PDO('sqlite:logs.sqlite')); + +// You can now use your logger +$logger->addInfo('My logger is now ready'); +``` + +The `Monolog\Handler\AbstractProcessingHandler` class provides most of the +logic needed for the handler, including the use of processors and the formatting +of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``). diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/sockets.md b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/sockets.md new file mode 100644 index 0000000..fad30a9 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/sockets.md @@ -0,0 +1,37 @@ +Sockets Handler +=============== + +This handler allows you to write your logs to sockets using [fsockopen](http://php.net/fsockopen) +or [pfsockopen](http://php.net/pfsockopen). + +Persistent sockets are mainly useful in web environments where you gain some performance not closing/opening +the connections between requests. + +Basic Example +------------- + +```php +setPersistent(true); + +// Now add the handler +$logger->pushHandler($handler, Logger::DEBUG); + +// You can now use your logger +$logger->addInfo('My logger is now ready'); + +``` + +In this example, using syslog-ng, you should see the log on the log server: + + cweb1 [2012-02-26 00:12:03] my_logger.INFO: My logger is now ready [] [] + diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/usage.md b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/usage.md new file mode 100644 index 0000000..a3cfc7f --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/doc/usage.md @@ -0,0 +1,124 @@ +Using Monolog +============= + +Installation +------------ + +Monolog is available on Packagist ([monolog/monolog](http://packagist.org/packages/monolog/monolog)) +and as such installable via [Composer](http://getcomposer.org/). + +If you do not use Composer, you can grab the code from GitHub, and use any +PSR-0 compatible autoloader (e.g. the [Symfony2 ClassLoader component](https://github.com/symfony/ClassLoader)) +to load Monolog classes. + +Configuring a logger +-------------------- + +Here is a basic setup to log to a file and to firephp on the DEBUG level: + +```php +pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG)); +$logger->pushHandler(new FirePHPHandler()); + +// You can now use your logger +$logger->addInfo('My logger is now ready'); +``` + +Let's explain it. The first step is to create the logger instance which will +be used in your code. The argument is a channel name, which is useful when +you use several loggers (see below for more details about it). + +The logger itself does not know how to handle a record. It delegates it to +some handlers. The code above registers two handlers in the stack to allow +handling records in two different ways. + +Note that the FirePHPHandler is called first as it is added on top of the +stack. This allows you to temporarily add a logger with bubbling disabled if +you want to override other configured loggers. + +Adding extra data in the records +-------------------------------- + +Monolog provides two different ways to add extra informations along the simple +textual message. + +### Using the logging context + +The first way is the context, allowing to pass an array of data along the +record: + +```php +addInfo('Adding a new user', array('username' => 'Seldaek')); +``` + +Simple handlers (like the StreamHandler for instance) will simply format +the array to a string but richer handlers can take advantage of the context +(FirePHP is able to display arrays in pretty way for instance). + +### Using processors + +The second way is to add extra data for all records by using a processor. +Processors can be any callable. They will get the record as parameter and +must return it after having eventually changed the `extra` part of it. Let's +write a processor adding some dummy data in the record: + +```php +pushProcessor(function ($record) { + $record['extra']['dummy'] = 'Hello world!'; + + return $record; +}); +``` + +Monolog provides some built-in processors that can be used in your project. +Look at the README file for the list. + +> Tip: processors can also be registered on a specific handler instead of + the logger to apply only for this handler. + +Leveraging channels +------------------- + +Channels are a great way to identify to which part of the application a record +is related. This is useful in big applications (and is leveraged by +MonologBundle in Symfony2). You can then easily grep through log files for +example to filter this or that type of log record. + +Using different loggers with the same handlers allow to identify the logger +that issued the record (through the channel name) by keeping the same handlers +(for instance to use a single log file). + +```php +pushHandler($stream); +$logger->pushHandler($firephp); + +// Create a logger for the security-related stuff with a different channel +$securityLogger = new Logger('security'); +$securityLogger->pushHandler($stream); +$securityLogger->pushHandler($firephp); +``` diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/phpunit.xml.dist b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/phpunit.xml.dist new file mode 100644 index 0000000..1754570 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/phpunit.xml.dist @@ -0,0 +1,15 @@ + + + + + + tests/Monolog/ + + + + + + src/Monolog/ + + + diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/ChromePHPFormatter.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/ChromePHPFormatter.php new file mode 100644 index 0000000..44335b5 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/ChromePHPFormatter.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Formats a log message according to the ChromePHP array format + * + * @author Christophe Coevoet + */ +class ChromePHPFormatter implements FormatterInterface +{ + /** + * Translates Monolog log levels to Wildfire levels. + */ + private $logLevels = array( + Logger::DEBUG => 'log', + Logger::INFO => 'info', + Logger::WARNING => 'warn', + Logger::ERROR => 'error', + Logger::CRITICAL => 'error', + Logger::ALERT => 'error', + ); + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + // Retrieve the line and file if set and remove them from the formatted extra + $backtrace = 'unknown'; + if (isset($record['extra']['file']) && isset($record['extra']['line'])) { + $backtrace = $record['extra']['file'].' : '.$record['extra']['line']; + unset($record['extra']['file']); + unset($record['extra']['line']); + } + + $message = array('message' => $record['message']); + if ($record['context']) { + $message['context'] = $record['context']; + } + if ($record['extra']) { + $message['extra'] = $record['extra']; + } + if (count($message) === 1) { + $message = reset($message); + } + + return array( + $record['channel'], + $message, + $backtrace, + $this->logLevels[$record['level']], + ); + } + + public function formatBatch(array $records) + { + $formatted = array(); + + foreach ($records as $record) { + $formatted[] = $this->format($record); + } + + return $formatted; + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/FormatterInterface.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/FormatterInterface.php new file mode 100644 index 0000000..77891de --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/FormatterInterface.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * Interface for formatters + * + * @author Jordi Boggiano + */ +interface FormatterInterface +{ + /** + * Formats a log record. + * + * @param array $record A record to format + * @return mixed The formatted record + */ + function format(array $record); + + /** + * Formats a set of log records. + * + * @param array $records A set of records to format + * @return mixed The formatted set of records + */ + function formatBatch(array $records); +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/GelfMessageFormatter.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/GelfMessageFormatter.php new file mode 100644 index 0000000..95c17ad --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/GelfMessageFormatter.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; +use Gelf\Message; + +/** + * Serializes a log message according to Wildfire's header requirements + * + * @author Matt Lehner + */ +class GelfMessageFormatter extends NormalizerFormatter +{ + /** + * @var string the name of the system for the Gelf log message + */ + protected $systemName; + + /** + * @var string a prefix for 'extra' fields from the Monolog record (optional) + */ + protected $extraPrefix; + + /** + * @var string a prefix for 'context' fields from the Monolog record (optional) + */ + protected $contextPrefix; + + /** + * Translates Monolog log levels to Graylog2 log priorities. + */ + private $logLevels = array( + Logger::DEBUG => LOG_DEBUG, + Logger::INFO => LOG_INFO, + Logger::WARNING => LOG_WARNING, + Logger::ERROR => LOG_ERR, + Logger::CRITICAL => LOG_CRIT, + Logger::ALERT => LOG_ALERT, + ); + + public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_') + { + parent::__construct('U.u'); + + $this->systemName = $systemName ?: gethostname(); + + $this->extraPrefix = $extraPrefix; + $this->contextPrefix = $contextPrefix; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + $record = parent::format($record); + $message = new Message(); + $message + ->setTimestamp($record['datetime']) + ->setShortMessage((string) $record['message']) + ->setFacility($record['channel']) + ->setHost($this->systemName) + ->setLine(isset($record['extra']['line']) ? $record['extra']['line'] : null) + ->setFile(isset($record['extra']['file']) ? $record['extra']['file'] : null) + ->setLevel($this->logLevels[$record['level']]); + + // Do not duplicate these values in the additional fields + unset($record['extra']['line']); + unset($record['extra']['file']); + + foreach ($record['extra'] as $key => $val) { + $message->setAdditional($this->extraPrefix . $key, is_scalar($val) ? $val : $this->toJson($val)); + } + + foreach ($record['context'] as $key => $val) { + $message->setAdditional($this->contextPrefix . $key, is_scalar($val) ? $val : $this->toJson($val)); + } + + return $message; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/JsonFormatter.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/JsonFormatter.php new file mode 100644 index 0000000..ab20179 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/JsonFormatter.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Encodes whatever record data is passed to it as json + * + * This can be useful to log to databases or remote APIs + * + * @author Jordi Boggiano + */ +class JsonFormatter implements FormatterInterface +{ + /** + * {@inheritdoc} + */ + public function format(array $record) + { + return json_encode($record); + } + + /** + * {@inheritdoc} + */ + public function formatBatch(array $records) + { + return json_encode($records); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/LineFormatter.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/LineFormatter.php new file mode 100644 index 0000000..61d3b8c --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/LineFormatter.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Formats incoming records into a one-line string + * + * This is especially useful for logging to files + * + * @author Jordi Boggiano + * @author Christophe Coevoet + */ +class LineFormatter extends NormalizerFormatter +{ + const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; + + protected $format; + + /** + * @param string $format The format of the message + * @param string $dateFormat The format of the timestamp: one supported by DateTime::format + */ + public function __construct($format = null, $dateFormat = null) + { + $this->format = $format ?: static::SIMPLE_FORMAT; + parent::__construct($dateFormat); + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + $vars = parent::format($record); + + $output = $this->format; + foreach ($vars['extra'] as $var => $val) { + if (false !== strpos($output, '%extra.'.$var.'%')) { + $output = str_replace('%extra.'.$var.'%', $this->convertToString($val), $output); + unset($vars['extra'][$var]); + } + } + foreach ($vars as $var => $val) { + $output = str_replace('%'.$var.'%', $this->convertToString($val), $output); + } + + return $output; + } + + public function formatBatch(array $records) + { + $message = ''; + foreach ($records as $record) { + $message .= $this->format($record); + } + + return $message; + } + + protected function normalize($data) + { + if (is_bool($data) || is_null($data)) { + return var_export($data, true); + } + + return parent::normalize($data); + } + + protected function convertToString($data) + { + if (null === $data || is_scalar($data)) { + return (string) $data; + } + + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + return json_encode($this->normalize($data), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + return stripslashes(json_encode($this->normalize($data))); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/NormalizerFormatter.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/NormalizerFormatter.php new file mode 100644 index 0000000..09cadb7 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/NormalizerFormatter.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Normalizes incoming records to remove objects/resources so it's easier to dump to various targets + * + * @author Jordi Boggiano + */ +class NormalizerFormatter implements FormatterInterface +{ + const SIMPLE_DATE = "Y-m-d H:i:s"; + + protected $dateFormat; + + /** + * @param string $dateFormat The format of the timestamp: one supported by DateTime::format + */ + public function __construct($dateFormat = null) + { + $this->dateFormat = $dateFormat ?: static::SIMPLE_DATE; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + return $this->normalize($record); + } + + /** + * {@inheritdoc} + */ + public function formatBatch(array $records) + { + foreach ($records as $key => $record) { + $records[$key] = $this->format($record); + } + + return $records; + } + + protected function normalize($data) + { + if (null === $data || is_scalar($data)) { + return $data; + } + + if (is_array($data) || $data instanceof \Traversable) { + $normalized = array(); + + foreach ($data as $key => $value) { + $normalized[$key] = $this->normalize($value); + } + + return $normalized; + } + + if ($data instanceof \DateTime) { + return $data->format($this->dateFormat); + } + + if (is_resource($data)) { + return '[resource]'; + } + + return sprintf("[object] (%s: %s)", get_class($data), $this->toJson($data)); + } + + protected function toJson($data) + { + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + return json_encode($data); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/WildfireFormatter.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/WildfireFormatter.php new file mode 100644 index 0000000..4c393a9 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Formatter/WildfireFormatter.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Serializes a log message according to Wildfire's header requirements + * + * @author Eric Clemmons (@ericclemmons) + * @author Christophe Coevoet + * @author Kirill chEbba Chebunin + */ +class WildfireFormatter implements FormatterInterface +{ + /** + * Translates Monolog log levels to Wildfire levels. + */ + private $logLevels = array( + Logger::DEBUG => 'LOG', + Logger::INFO => 'INFO', + Logger::WARNING => 'WARN', + Logger::ERROR => 'ERROR', + Logger::CRITICAL => 'ERROR', + Logger::ALERT => 'ERROR', + ); + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + // Retrieve the line and file if set and remove them from the formatted extra + $file = $line = ''; + if (isset($record['extra']['file'])) { + $file = $record['extra']['file']; + unset($record['extra']['file']); + } + if (isset($record['extra']['line'])) { + $line = $record['extra']['line']; + unset($record['extra']['line']); + } + + $message = array('message' => $record['message']); + if ($record['context']) { + $message['context'] = $record['context']; + } + if ($record['extra']) { + $message['extra'] = $record['extra']; + } + if (count($message) === 1) { + $message = reset($message); + } + + // Create JSON object describing the appearance of the message in the console + $json = json_encode(array( + array( + 'Type' => $this->logLevels[$record['level']], + 'File' => $file, + 'Line' => $line, + 'Label' => $record['channel'], + ), + $message, + )); + + // The message itself is a serialization of the above JSON object + it's length + return sprintf( + '%s|%s|', + strlen($json), + $json + ); + } + + public function formatBatch(array $records) + { + throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter'); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractHandler.php new file mode 100644 index 0000000..1349c25 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractHandler.php @@ -0,0 +1,173 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\FormatterInterface; +use Monolog\Formatter\LineFormatter; + +/** + * Base Handler class providing the Handler structure + * + * @author Jordi Boggiano + */ +abstract class AbstractHandler implements HandlerInterface +{ + protected $level = Logger::DEBUG; + protected $bubble = false; + + /** + * @var FormatterInterface + */ + protected $formatter; + protected $processors = array(); + + /** + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($level = Logger::DEBUG, $bubble = true) + { + $this->level = $level; + $this->bubble = $bubble; + } + + /** + * {@inheritdoc} + */ + public function isHandling(array $record) + { + return $record['level'] >= $this->level; + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + foreach ($records as $record) { + $this->handle($record); + } + } + + /** + * Closes the handler. + * + * This will be called automatically when the object is destroyed + */ + public function close() + { + } + + /** + * {@inheritdoc} + */ + public function pushProcessor($callback) + { + if (!is_callable($callback)) { + throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); + } + array_unshift($this->processors, $callback); + } + + /** + * {@inheritdoc} + */ + public function popProcessor() + { + if (!$this->processors) { + throw new \LogicException('You tried to pop from an empty processor stack.'); + } + return array_shift($this->processors); + } + + /** + * {@inheritdoc} + */ + public function setFormatter(FormatterInterface $formatter) + { + $this->formatter = $formatter; + } + + /** + * {@inheritdoc} + */ + public function getFormatter() + { + if (!$this->formatter) { + $this->formatter = $this->getDefaultFormatter(); + } + + return $this->formatter; + } + + /** + * Sets minimum logging level at which this handler will be triggered. + * + * @param integer $level + */ + public function setLevel($level) + { + $this->level = $level; + } + + /** + * Gets minimum logging level at which this handler will be triggered. + * + * @return integer + */ + public function getLevel() + { + return $this->level; + } + + /** + * Sets the bubbling behavior. + * + * @param Boolean $bubble True means that bubbling is not permitted. + * False means that this handler allows bubbling. + */ + public function setBubble($bubble) + { + $this->bubble = $bubble; + } + + /** + * Gets the bubbling behavior. + * + * @return Boolean True means that bubbling is not permitted. + * False means that this handler allows bubbling. + */ + public function getBubble() + { + return $this->bubble; + } + + public function __destruct() + { + try { + $this->close(); + } catch(\Exception $e) { + // do nothing + } + } + + /** + * Gets the default formatter. + * + * @return FormatterInterface + */ + protected function getDefaultFormatter() + { + return new LineFormatter(); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractProcessingHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractProcessingHandler.php new file mode 100644 index 0000000..9babe03 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/AbstractProcessingHandler.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\FormatterInterface; +use Monolog\Formatter\LineFormatter; + +/** + * Base Handler class providing the Handler structure + * + * Classes extending it should (in most cases) only implement write($record) + * + * @author Jordi Boggiano + * @author Christophe Coevoet + */ +abstract class AbstractProcessingHandler extends AbstractHandler +{ + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($record['level'] < $this->level) { + return false; + } + + $record = $this->processRecord($record); + + $record['formatted'] = $this->getFormatter()->format($record); + + $this->write($record); + + return false === $this->bubble; + } + + /** + * Writes the record down to the log of the implementing handler + * + * @param array $record + * @return void + */ + abstract protected function write(array $record); + + /** + * Processes a record. + * + * @param array $record + * @return array + */ + protected function processRecord(array $record) + { + if ($this->processors) { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + } + + return $record; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/BufferHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/BufferHandler.php new file mode 100644 index 0000000..7031607 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/BufferHandler.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Buffers all records until closing the handler and then pass them as batch. + * + * This is useful for a MailHandler to send only one mail per request instead of + * sending one per log message. + * + * @author Christophe Coevoet + */ +class BufferHandler extends AbstractHandler +{ + protected $handler; + protected $bufferSize; + protected $buffer = array(); + + /** + * @param HandlerInterface $handler Handler. + * @param integer $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(HandlerInterface $handler, $bufferSize = 0, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + $this->handler = $handler; + $this->bufferSize = $bufferSize; + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($record['level'] < $this->level) { + return false; + } + + $this->buffer[] = $record; + if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) { + array_shift($this->buffer); + } + + return false === $this->bubble; + } + + /** + * {@inheritdoc} + */ + public function close() + { + $this->handler->handleBatch($this->buffer); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/ChromePHPHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/ChromePHPHandler.php new file mode 100644 index 0000000..4d7ae8c --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/ChromePHPHandler.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\ChromePHPFormatter; + +/** + * Handler sending logs to the ChromePHP extension (http://www.chromephp.com/) + * + * @author Christophe Coevoet + */ +class ChromePHPHandler extends AbstractProcessingHandler +{ + /** + * Version of the extension + */ + const VERSION = '3.0'; + + /** + * Header name + */ + const HEADER_NAME = 'X-ChromePhp-Data'; + + static protected $initialized = false; + + static protected $json = array( + 'version' => self::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array(), + ); + + protected $sendHeaders = true; + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + $messages = array(); + + foreach ($records as $record) { + if ($record['level'] < $this->level) { + continue; + } + $messages[] = $this->processRecord($record); + } + + if (!empty($messages)) { + $messages = $this->getFormatter()->formatBatch($messages); + self::$json['rows'] = array_merge(self::$json['rows'], $messages); + $this->send(); + } + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new ChromePHPFormatter(); + } + + /** + * Creates & sends header for a record + * + * @see sendHeader() + * @see send() + * @param array $record + */ + protected function write(array $record) + { + self::$json['rows'][] = $record['formatted']; + + $this->send(); + } + + /** + * Sends the log header + * + * @see sendHeader() + */ + protected function send() + { + if (!self::$initialized) { + $this->sendHeaders = $this->headersAccepted(); + self::$json['request_uri'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; + + self::$initialized = true; + } + + $this->sendHeader(self::HEADER_NAME, base64_encode(utf8_encode(json_encode(self::$json)))); + } + + /** + * Send header string to the client + * + * @param string $header + * @param string $content + */ + protected function sendHeader($header, $content) + { + if (!headers_sent() && $this->sendHeaders) { + header(sprintf('%s: %s', $header, $content)); + } + } + + /** + * Verifies if the headers are accepted by the current user agent + * + * @return Boolean + */ + protected function headersAccepted() + { + return !isset($_SERVER['HTTP_USER_AGENT']) + || preg_match('{\bChrome/\d+[\.\d+]*\b}', $_SERVER['HTTP_USER_AGENT']); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php new file mode 100644 index 0000000..54b9a8d --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler\FingersCrossed; + +/** + * Interface for activation strategies for the FingersCrossedHandler. + * + * @author Johannes M. Schmitt + */ +interface ActivationStrategyInterface +{ + /** + * Returns whether the given record activates the handler. + * + * @param array $record + * @return Boolean + */ + function isHandlerActivated(array $record); +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php new file mode 100644 index 0000000..2cfe6dd --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler\FingersCrossed; + +/** + * Error level based activation strategy. + * + * @author Johannes M. Schmitt + */ +class ErrorLevelActivationStrategy implements ActivationStrategyInterface +{ + private $actionLevel; + + public function __construct($actionLevel) + { + $this->actionLevel = $actionLevel; + } + + public function isHandlerActivated(array $record) + { + return $record['level'] >= $this->actionLevel; + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossedHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossedHandler.php new file mode 100644 index 0000000..3731fa8 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FingersCrossedHandler.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; +use Monolog\Handler\FingersCrossed\ActivationStrategyInterface; +use Monolog\Logger; + +/** + * Buffers all records until a certain level is reached + * + * The advantage of this approach is that you don't get any clutter in your log files. + * Only requests which actually trigger an error (or whatever your actionLevel is) will be + * in the logs, but they will contain all records, not only those above the level threshold. + * + * @author Jordi Boggiano + */ +class FingersCrossedHandler extends AbstractHandler +{ + protected $handler; + protected $activationStrategy; + protected $buffering = true; + protected $bufferSize; + protected $buffer = array(); + protected $stopBuffering; + + /** + * @param callback|HandlerInterface $handler Handler or factory callback($record, $fingersCrossedHandler). + * @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action + * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true) + */ + public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true) + { + if (null === $activationStrategy) { + $activationStrategy = new ErrorLevelActivationStrategy(Logger::WARNING); + } + if (!$activationStrategy instanceof ActivationStrategyInterface) { + $activationStrategy = new ErrorLevelActivationStrategy($activationStrategy); + } + + $this->handler = $handler; + $this->activationStrategy = $activationStrategy; + $this->bufferSize = $bufferSize; + $this->bubble = $bubble; + $this->stopBuffering = $stopBuffering; + } + + /** + * {@inheritdoc} + */ + public function isHandling(array $record) + { + return true; + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($this->buffering) { + $this->buffer[] = $record; + if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) { + array_shift($this->buffer); + } + if ($this->activationStrategy->isHandlerActivated($record)) { + if ($this->stopBuffering) { + $this->buffering = false; + } + if (!$this->handler instanceof HandlerInterface) { + $this->handler = call_user_func($this->handler, $record, $this); + } + if (!$this->handler instanceof HandlerInterface) { + throw new \RuntimeException("The factory callback should return a HandlerInterface"); + } + $this->handler->handleBatch($this->buffer); + $this->buffer = array(); + } + } else { + $this->handler->handle($record); + } + + return false === $this->bubble; + } + + /** + * Resets the state of the handler. Stops forwarding records to the wrapped handler. + */ + public function reset() + { + $this->buffering = true; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FirePHPHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FirePHPHandler.php new file mode 100644 index 0000000..8cc10e9 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/FirePHPHandler.php @@ -0,0 +1,161 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\WildfireFormatter; + +/** + * Simple FirePHP Handler (http://www.firephp.org/), which uses the Wildfire protocol. + * + * @author Eric Clemmons (@ericclemmons) + */ +class FirePHPHandler extends AbstractProcessingHandler +{ + /** + * WildFire JSON header message format + */ + const PROTOCOL_URI = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'; + + /** + * FirePHP structure for parsing messages & their presentation + */ + const STRUCTURE_URI = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; + + /** + * Must reference a "known" plugin, otherwise headers won't display in FirePHP + */ + const PLUGIN_URI = 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3'; + + /** + * Header prefix for Wildfire to recognize & parse headers + */ + const HEADER_PREFIX = 'X-Wf'; + + /** + * Whether or not Wildfire vendor-specific headers have been generated & sent yet + */ + protected static $initialized = false; + + /** + * Shared static message index between potentially multiple handlers + * @var int + */ + protected static $messageIndex = 1; + + protected $sendHeaders = true; + + /** + * Base header creation function used by init headers & record headers + * + * @param array $meta Wildfire Plugin, Protocol & Structure Indexes + * @param string $message Log message + * @return array Complete header string ready for the client as key and message as value + */ + protected function createHeader(array $meta, $message) + { + $header = sprintf('%s-%s', self::HEADER_PREFIX, join('-', $meta)); + + return array($header => $message); + } + + /** + * Creates message header from record + * + * @see createHeader() + * @param array $record + * @return string + */ + protected function createRecordHeader(array $record) + { + // Wildfire is extensible to support multiple protocols & plugins in a single request, + // but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake. + return $this->createHeader( + array(1, 1, 1, self::$messageIndex++), + $record['formatted'] + ); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new WildfireFormatter(); + } + + /** + * Wildfire initialization headers to enable message parsing + * + * @see createHeader() + * @see sendHeader() + * @return array + */ + protected function getInitHeaders() + { + // Initial payload consists of required headers for Wildfire + return array_merge( + $this->createHeader(array('Protocol', 1), self::PROTOCOL_URI), + $this->createHeader(array(1, 'Structure', 1), self::STRUCTURE_URI), + $this->createHeader(array(1, 'Plugin', 1), self::PLUGIN_URI) + ); + } + + /** + * Send header string to the client + * + * @param string $header + * @param string $content + */ + protected function sendHeader($header, $content) + { + if (!headers_sent() && $this->sendHeaders) { + header(sprintf('%s: %s', $header, $content)); + } + } + + /** + * Creates & sends header for a record, ensuring init headers have been sent prior + * + * @see sendHeader() + * @see sendInitHeaders() + * @param array $record + */ + protected function write(array $record) + { + // WildFire-specific headers must be sent prior to any messages + if (!self::$initialized) { + $this->sendHeaders = $this->headersAccepted(); + + foreach ($this->getInitHeaders() as $header => $content) { + $this->sendHeader($header, $content); + } + + self::$initialized = true; + } + + $header = $this->createRecordHeader($record); + $this->sendHeader(key($header), current($header)); + } + + /** + * Verifies if the headers are accepted by the current user agent + * + * @return Boolean + */ + protected function headersAccepted() + { + return !isset($_SERVER['HTTP_USER_AGENT']) + || preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT']) + || isset($_SERVER['HTTP_X_FIREPHP_VERSION']); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GelfHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GelfHandler.php new file mode 100644 index 0000000..7346029 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GelfHandler.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Gelf\IMessagePublisher; +use Monolog\Logger; +use Monolog\Handler\AbstractProcessingHandler; +use Monolog\Formatter\GelfMessageFormatter; + +/** + * Handler to send messages to a Graylog2 (http://www.graylog2.org) server + * + * @author Matt Lehner + */ +class GelfHandler extends AbstractProcessingHandler +{ + /** + * @var Gelf\IMessagePublisher the publisher object that sends the message to the server + */ + protected $publisher; + + /** + * @param Gelf\IMessagePublisher $publisher a publisher object + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(IMessagePublisher $publisher, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + + $this->publisher = $publisher; + } + + /** + * {@inheritdoc} + */ + public function close() + { + $this->publisher = null; + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $this->publisher->publish($record['formatted']); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new GelfMessageFormatter(); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GroupHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GroupHandler.php new file mode 100644 index 0000000..c94c52f --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/GroupHandler.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +/** + * Forwards records to multiple handlers + * + * @author Lenar Lõhmus + */ +class GroupHandler extends AbstractHandler +{ + protected $handlers; + + /** + * @param array $handlers Array of Handlers. + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(array $handlers, $bubble = true) + { + foreach ($handlers as $handler) { + if (!$handler instanceof HandlerInterface) { + throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.'); + } + } + + $this->handlers = $handlers; + $this->bubble = $bubble; + } + + /** + * {@inheritdoc} + */ + public function isHandling(array $record) + { + foreach ($this->handlers as $handler) { + if ($handler->isHandling($record)) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + foreach ($this->handlers as $handler) { + $handler->handle($record); + } + + return false === $this->bubble; + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + foreach ($this->handlers as $handler) { + $handler->handleBatch($records); + } + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/HandlerInterface.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/HandlerInterface.php new file mode 100644 index 0000000..24f82d7 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/HandlerInterface.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\FormatterInterface; + +/** + * Interface that all Monolog Handlers must implement + * + * @author Jordi Boggiano + */ +interface HandlerInterface +{ + /** + * Checks whether the given record will be handled by this handler. + * + * This is mostly done for performance reasons, to avoid calling processors for nothing. + * + * @return Boolean + */ + function isHandling(array $record); + + /** + * Handles a record. + * + * The return value of this function controls the bubbling process of the handler stack. + * + * @param array $record The record to handle + * @return Boolean True means that this handler handled the record, and that bubbling is not permitted. + * False means the record was either not processed or that this handler allows bubbling. + */ + function handle(array $record); + + /** + * Handles a set of records at once. + * + * @param array $records The records to handle (an array of record arrays) + */ + function handleBatch(array $records); + + /** + * Adds a processor in the stack. + * + * @param callable $callback + */ + function pushProcessor($callback); + + /** + * Removes the processor on top of the stack and returns it. + * + * @return callable + */ + function popProcessor(); + + /** + * Sets the formatter. + * + * @param FormatterInterface $formatter + */ + function setFormatter(FormatterInterface $formatter); + + /** + * Gets the formatter. + * + * @return FormatterInterface + */ + function getFormatter(); +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MailHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MailHandler.php new file mode 100644 index 0000000..94ed841 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MailHandler.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +/** + * Base class for all mail handlers + * + * @author Gyula Sallai + */ +abstract class MailHandler extends AbstractProcessingHandler +{ + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + $messages = array(); + + foreach ($records as $record) { + if ($record['level'] < $this->level) { + continue; + } + $messages[] = $this->processRecord($record); + } + + if (!empty($messages)) { + $this->send((string) $this->getFormatter()->formatBatch($messages), $messages); + } + } + + /** + * Send a mail with the given content + * + * @param string $content + * @param array $records the array of log records that formed this content + */ + abstract protected function send($content, array $records); + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $this->send((string) $record['formatted'], array($record)); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MongoDBHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MongoDBHandler.php new file mode 100644 index 0000000..210bb19 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/MongoDBHandler.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\NormalizerFormatter; + +/** + * Logs to a MongoDB database. + * + * usage example: + * + * $log = new Logger('application'); + * $mongodb = new MongoDBHandler(new \Mongo("mongodb://localhost:27017"), "logs", "prod"); + * $log->pushHandler($mongodb); + * + * @author Thomas Tourlourat + */ +class MongoDBHandler extends AbstractProcessingHandler +{ + private $mongoCollection; + + public function __construct(\Mongo $mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true) + { + $this->mongoCollection = $mongo->selectCollection($database, $collection); + + parent::__construct($level, $bubble); + } + + protected function write(array $record) + { + $this->mongoCollection->save($record["formatted"]); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new NormalizerFormatter(); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NativeMailerHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NativeMailerHandler.php new file mode 100644 index 0000000..6933ff6 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NativeMailerHandler.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * NativeMailerHandler uses the mail() function to send the emails + * + * @author Christophe Coevoet + */ +class NativeMailerHandler extends MailHandler +{ + protected $to; + protected $subject; + protected $headers; + + /** + * @param string $to The receiver of the mail + * @param string $subject The subject of the mail + * @param string $from The sender of the mail + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true) + { + parent::__construct($level, $bubble); + $this->to = $to; + $this->subject = $subject; + $this->headers = sprintf("From: %s\r\nContent-type: text/plain; charset=utf-8\r\n", $from); + } + + /** + * {@inheritdoc} + */ + protected function send($content, array $records) + { + mail($this->to, $this->subject, wordwrap($content, 70), $this->headers); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NullHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NullHandler.php new file mode 100644 index 0000000..7caf4a2 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/NullHandler.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Blackhole + * + * Any record it can handle will be thrown away. This can be used + * to put on top of an existing stack to override it temporarily. + * + * @author Jordi Boggiano + */ +class NullHandler extends AbstractHandler +{ + /** + * @param integer $level The minimum logging level at which this handler will be triggered + */ + public function __construct($level = Logger::DEBUG) + { + parent::__construct($level, false); + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($record['level'] < $this->level) { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/RotatingFileHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/RotatingFileHandler.php new file mode 100644 index 0000000..ebecd56 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/RotatingFileHandler.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Stores logs to files that are rotated every day and a limited number of files are kept. + * + * This rotation is only intended to be used as a workaround. Using logrotate to + * handle the rotation is strongly encouraged when you can use it. + * + * @author Christophe Coevoet + */ +class RotatingFileHandler extends StreamHandler +{ + protected $filename; + protected $maxFiles; + protected $mustRotate; + + /** + * @param string $filename + * @param integer $maxFiles The maximal amount of files to keep (0 means unlimited) + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true) + { + $this->filename = $filename; + $this->maxFiles = (int) $maxFiles; + + $fileInfo = pathinfo($this->filename); + $timedFilename = $fileInfo['dirname'].'/'.$fileInfo['filename'].'-'.date('Y-m-d'); + if (!empty($fileInfo['extension'])) { + $timedFilename .= '.'.$fileInfo['extension']; + } + + // disable rotation upfront if files are unlimited + if (0 === $this->maxFiles) { + $this->mustRotate = false; + } + + parent::__construct($timedFilename, $level, $bubble); + } + + /** + * {@inheritdoc} + */ + public function close() + { + parent::close(); + + if (true === $this->mustRotate) { + $this->rotate(); + } + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + // on the first record written, if the log is new, we should rotate (once per day) + if (null === $this->mustRotate) { + $this->mustRotate = !file_exists($this->url); + } + + parent::write($record); + } + + /** + * Rotates the files. + */ + protected function rotate() + { + $fileInfo = pathinfo($this->filename); + $glob = $fileInfo['dirname'].'/'.$fileInfo['filename'].'-*'; + if (!empty($fileInfo['extension'])) { + $glob .= '.'.$fileInfo['extension']; + } + $iterator = new \GlobIterator($glob); + $count = $iterator->count(); + if ($this->maxFiles >= $count) { + // no files to remove + return; + } + + // Sorting the files by name to remove the older ones + $array = iterator_to_array($iterator); + usort($array, function($a, $b) { + return strcmp($b->getFilename(), $a->getFilename()); + }); + + foreach (array_slice($array, $this->maxFiles) as $file) { + if ($file->isWritable()) { + unlink($file->getRealPath()); + } + } + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SocketHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SocketHandler.php new file mode 100644 index 0000000..b44fad7 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SocketHandler.php @@ -0,0 +1,272 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Stores to any socket - uses fsockopen() or pfsockopen(). + * + * @author Pablo de Leon Belloc + * @see http://php.net/manual/en/function.fsockopen.php + */ +class SocketHandler extends AbstractProcessingHandler +{ + private $connectionString; + private $connectionTimeout; + private $resource; + private $timeout = 0; + private $persistent = false; + private $errno; + private $errstr; + + /** + * @param string $connectionString Socket connection string + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + $this->connectionString = $connectionString; + $this->connectionTimeout = (float) ini_get('default_socket_timeout'); + } + + /** + * Connect (if necessary) and write to the socket + * + * @param array $record + * + * @throws \UnexpectedValueException + * @throws \RuntimeException + */ + public function write(array $record) + { + $this->connectIfNotConnected(); + $this->writeToSocket((string) $record['formatted']); + } + + /** + * We will not close a PersistentSocket instance so it can be reused in other requests. + */ + public function close() + { + if (!$this->isPersistent()) { + $this->closeSocket(); + } + } + + /** + * Close socket, if open + */ + public function closeSocket() + { + if (is_resource($this->resource)) { + fclose($this->resource); + $this->resource = null; + } + } + + /** + * Set socket connection to nbe persistent. It only has effect before the connection is initiated. + * + * @param type $boolean + */ + public function setPersistent($boolean) + { + $this->persistent = (boolean) $boolean; + } + + /** + * Set connection timeout. Only has effect before we connect. + * + * @param integer $seconds + * + * @see http://php.net/manual/en/function.fsockopen.php + */ + public function setConnectionTimeout($seconds) + { + $this->validateTimeout($seconds); + $this->connectionTimeout = (float) $seconds; + } + + /** + * Set write timeout. Only has effect before we connect. + * + * @param type $seconds + * + * @see http://php.net/manual/en/function.stream-set-timeout.php + */ + public function setTimeout($seconds) + { + $this->validateTimeout($seconds); + $this->timeout = (int) $seconds; + } + + /** + * Get current connection string + * + * @return string + */ + public function getConnectionString() + { + return $this->connectionString; + } + + /** + * Get persistent setting + * + * @return boolean + */ + public function isPersistent() + { + return $this->persistent; + } + + /** + * Get current connection timeout setting + * + * @return float + */ + public function getConnectionTimeout() + { + return $this->connectionTimeout; + } + + /** + * Get current in-transfer timeout + * + * @return float + */ + public function getTimeout() + { + return $this->timeout; + } + + /** + * Check to see if the socket is currently available. + * + * UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details. + * + * @return boolean + */ + public function isConnected() + { + return is_resource($this->resource) + && !feof($this->resource); // on TCP - other party can close connection. + } + + /** + * Wrapper to allow mocking + */ + protected function pfsockopen() + { + return @pfsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout); + } + + /** + * Wrapper to allow mocking + */ + protected function fsockopen() + { + return @fsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout); + } + + /** + * Wrapper to allow mocking + */ + protected function streamSetTimeout() + { + return stream_set_timeout($this->resource, $this->timeout); + } + + /** + * Wrapper to allow mocking + */ + protected function fwrite($data) + { + return @fwrite($this->resource, $data); + } + + /** + * Wrapper to allow mocking + */ + protected function streamGetMetadata() + { + return stream_get_meta_data($this->resource); + } + + private function validateTimeout($value) + { + $ok = filter_var($value, FILTER_VALIDATE_INT, array('options' => array( + 'min_range' => 0, + ))); + if ($ok === false) { + throw new \InvalidArgumentException("Timeout must be 0 or a positive integer (got $value)"); + } + } + + private function connectIfNotConnected() + { + if ($this->isConnected()) { + return; + } + $this->connect(); + } + + private function connect() + { + $this->createSocketResource(); + $this->setSocketTimeout(); + } + + private function createSocketResource() + { + if ($this->isPersistent()) { + $resource = $this->pfsockopen(); + } else { + $resource = $this->fsockopen(); + } + if (!$resource) { + throw new \UnexpectedValueException("Failed connecting to $this->connectionString ($this->errno: $this->errstr)"); + } + $this->resource = $resource; + } + + private function setSocketTimeout() + { + if (!$this->streamSetTimeout()) { + throw new \UnexpectedValueException("Failed setting timeout with stream_set_timeout()"); + } + } + + private function writeToSocket($data) + { + $length = strlen($data); + $sent = 0; + while ($this->isConnected() && $sent < $length) { + $chunk = $this->fwrite(substr($data, $sent)); + if ($chunk === false) { + throw new \RuntimeException("Could not write to socket"); + } + $sent += $chunk; + $socketInfo = $this->streamGetMetadata(); + if ($socketInfo['timed_out']) { + throw new \RuntimeException("Write timed-out"); + } + } + if (!$this->isConnected() && $sent < $length) { + throw new \RuntimeException("End-of-file reached, probably we got disconnected (sent $sent of $length)"); + } + } + +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/StreamHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/StreamHandler.php new file mode 100644 index 0000000..5593054 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/StreamHandler.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Stores to any stream resource + * + * Can be used to store into php://stderr, remote and local files, etc. + * + * @author Jordi Boggiano + */ +class StreamHandler extends AbstractProcessingHandler +{ + protected $stream; + protected $url; + + /** + * @param string $stream + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($stream, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + if (is_resource($stream)) { + $this->stream = $stream; + } else { + $this->url = $stream; + } + } + + /** + * {@inheritdoc} + */ + public function close() + { + if (is_resource($this->stream)) { + fclose($this->stream); + } + $this->stream = null; + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + if (null === $this->stream) { + if (!$this->url) { + throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().'); + } + $this->stream = @fopen($this->url, 'a'); + if (!is_resource($this->stream)) { + $this->stream = null; + throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened; it may be invalid or not writable.', $this->url)); + } + } + fwrite($this->stream, (string) $record['formatted']); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SwiftMailerHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SwiftMailerHandler.php new file mode 100644 index 0000000..addc4c4 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SwiftMailerHandler.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * SwiftMailerHandler uses Swift_Mailer to send the emails + * + * @author Gyula Sallai + */ +class SwiftMailerHandler extends MailHandler +{ + protected $mailer; + protected $message; + + /** + * @param \Swift_Mailer $mailer The mailer to use + * @param callback|\Swift_Message $message An example message for real messages, only the body will be replaced + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true) + { + parent::__construct($level, $bubble); + $this->mailer = $mailer; + if (!$message instanceof \Swift_Message && is_callable($message)) { + $message = call_user_func($message); + } + if (!$message instanceof \Swift_Message) { + throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callback returning it'); + } + $this->message = $message; + } + + /** + * {@inheritdoc} + */ + protected function send($content, array $records) + { + $message = clone $this->message; + $message->setBody($content); + + $this->mailer->send($message); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SyslogHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SyslogHandler.php new file mode 100644 index 0000000..444a592 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/SyslogHandler.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Logs to syslog service. + * + * usage example: + * + * $log = new Logger('application'); + * $syslog = new SyslogHandler('myfacility', 'local6'); + * $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%"); + * $syslog->setFormatter($formatter); + * $log->pushHandler($syslog); + * + * @author Sven Paulus + */ +class SyslogHandler extends AbstractProcessingHandler +{ + /** + * Translates Monolog log levels to syslog log priorities. + */ + private $logLevels = array( + Logger::DEBUG => LOG_DEBUG, + Logger::INFO => LOG_INFO, + Logger::WARNING => LOG_WARNING, + Logger::ERROR => LOG_ERR, + Logger::CRITICAL => LOG_CRIT, + Logger::ALERT => LOG_ALERT, + ); + + /** + * List of valid log facility names. + */ + private $facilities = array( + 'auth' => LOG_AUTH, + 'authpriv' => LOG_AUTHPRIV, + 'cron' => LOG_CRON, + 'daemon' => LOG_DAEMON, + 'kern' => LOG_KERN, + 'lpr' => LOG_LPR, + 'mail' => LOG_MAIL, + 'news' => LOG_NEWS, + 'syslog' => LOG_SYSLOG, + 'user' => LOG_USER, + 'uucp' => LOG_UUCP, + ); + + /** + * @param string $ident + * @param mixed $facility + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->facilities['local0'] = LOG_LOCAL0; + $this->facilities['local1'] = LOG_LOCAL1; + $this->facilities['local2'] = LOG_LOCAL2; + $this->facilities['local3'] = LOG_LOCAL3; + $this->facilities['local4'] = LOG_LOCAL4; + $this->facilities['local5'] = LOG_LOCAL5; + $this->facilities['local6'] = LOG_LOCAL6; + $this->facilities['local7'] = LOG_LOCAL7; + } + + // convert textual description of facility to syslog constant + if (array_key_exists(strtolower($facility), $this->facilities)) { + $facility = $this->facilities[strtolower($facility)]; + } else if (!in_array($facility, array_values($this->facilities), true)) { + throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given'); + } + + if (!openlog($ident, LOG_PID, $facility)) { + throw new \LogicException('Can\'t open syslog for ident "'.$ident.'" and facility "'.$facility.'"'); + } + } + + /** + * {@inheritdoc} + */ + public function close() + { + closelog(); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + syslog($this->logLevels[$record['level']], (string) $record['formatted']); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/TestHandler.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/TestHandler.php new file mode 100644 index 0000000..8f47855 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Handler/TestHandler.php @@ -0,0 +1,120 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Used for testing purposes. + * + * It records all records and gives you access to them for verification. + * + * @author Jordi Boggiano + */ +class TestHandler extends AbstractProcessingHandler +{ + protected $records = array(); + protected $recordsByLevel = array(); + + public function getRecords() + { + return $this->records; + } + + public function hasAlert($record) + { + return $this->hasRecord($record, Logger::ALERT); + } + + public function hasCritical($record) + { + return $this->hasRecord($record, Logger::CRITICAL); + } + + public function hasError($record) + { + return $this->hasRecord($record, Logger::ERROR); + } + + public function hasWarning($record) + { + return $this->hasRecord($record, Logger::WARNING); + } + + public function hasInfo($record) + { + return $this->hasRecord($record, Logger::INFO); + } + + public function hasDebug($record) + { + return $this->hasRecord($record, Logger::DEBUG); + } + + public function hasAlertRecords() + { + return isset($this->recordsByLevel[Logger::ALERT]); + } + + public function hasCriticalRecords() + { + return isset($this->recordsByLevel[Logger::CRITICAL]); + } + + public function hasErrorRecords() + { + return isset($this->recordsByLevel[Logger::ERROR]); + } + + public function hasWarningRecords() + { + return isset($this->recordsByLevel[Logger::WARNING]); + } + + public function hasInfoRecords() + { + return isset($this->recordsByLevel[Logger::INFO]); + } + + public function hasDebugRecords() + { + return isset($this->recordsByLevel[Logger::DEBUG]); + } + + protected function hasRecord($record, $level) + { + if (!isset($this->recordsByLevel[$level])) { + return false; + } + + if (is_array($record)) { + $record = $record['message']; + } + + foreach ($this->recordsByLevel[$level] as $rec) { + if ($rec['message'] === $record) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $this->recordsByLevel[$record['level']][] = $record; + $this->records[] = $record; + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Logger.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Logger.php new file mode 100644 index 0000000..91a6ca4 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Logger.php @@ -0,0 +1,421 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Monolog\Handler\HandlerInterface; +use Monolog\Handler\StreamHandler; + +/** + * Monolog log channel + * + * It contains a stack of Handlers and a stack of Processors, + * and uses them to store records that are added to it. + * + * @author Jordi Boggiano + */ +class Logger +{ + /** + * Detailed debug information + */ + const DEBUG = 100; + + /** + * Interesting events + * + * Examples: User logs in, SQL logs. + */ + const INFO = 200; + + /** + * Exceptional occurrences that are not errors + * + * Examples: Use of deprecated APIs, poor use of an API, + * undesirable things that are not necessarily wrong. + */ + const WARNING = 300; + + /** + * Runtime errors + */ + const ERROR = 400; + + /** + * Critical conditions + * + * Example: Application component unavailable, unexpected exception. + */ + const CRITICAL = 500; + + /** + * Action must be taken immediately + * + * Example: Entire website down, database unavailable, etc. + * This should trigger the SMS alerts and wake you up. + */ + const ALERT = 550; + + protected static $levels = array( + 100 => 'DEBUG', + 200 => 'INFO', + 300 => 'WARNING', + 400 => 'ERROR', + 500 => 'CRITICAL', + 550 => 'ALERT', + ); + + protected $name; + + /** + * The handler stack + * + * @var array of Monolog\Handler\HandlerInterface + */ + protected $handlers = array(); + + protected $processors = array(); + + /** + * @param string $name The logging channel + */ + public function __construct($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Pushes a handler on to the stack. + * + * @param HandlerInterface $handler + */ + public function pushHandler(HandlerInterface $handler) + { + array_unshift($this->handlers, $handler); + } + + /** + * Pops a handler from the stack + * + * @return HandlerInterface + */ + public function popHandler() + { + if (!$this->handlers) { + throw new \LogicException('You tried to pop from an empty handler stack.'); + } + return array_shift($this->handlers); + } + + /** + * Adds a processor on to the stack. + * + * @param callable $callback + */ + public function pushProcessor($callback) + { + if (!is_callable($callback)) { + throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); + } + array_unshift($this->processors, $callback); + } + + /** + * Removes the processor on top of the stack and returns it. + * + * @return callable + */ + public function popProcessor() + { + if (!$this->processors) { + throw new \LogicException('You tried to pop from an empty processor stack.'); + } + return array_shift($this->processors); + } + + /** + * Adds a log record. + * + * @param integer $level The logging level + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addRecord($level, $message, array $context = array()) + { + if (!$this->handlers) { + $this->pushHandler(new StreamHandler('php://stderr', self::DEBUG)); + } + $record = array( + 'message' => (string) $message, + 'context' => $context, + 'level' => $level, + 'level_name' => self::getLevelName($level), + 'channel' => $this->name, + 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))), + 'extra' => array(), + ); + // check if any message will handle this message + $handlerKey = null; + foreach ($this->handlers as $key => $handler) { + if ($handler->isHandling($record)) { + $handlerKey = $key; + break; + } + } + // none found + if (null === $handlerKey) { + return false; + } + // found at least one, process message and dispatch it + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + while (isset($this->handlers[$handlerKey]) && + false === $this->handlers[$handlerKey]->handle($record)) { + $handlerKey++; + } + + return true; + } + + /** + * Adds a log record at the DEBUG level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addDebug($message, array $context = array()) + { + return $this->addRecord(self::DEBUG, $message, $context); + } + + /** + * Adds a log record at the INFO level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addInfo($message, array $context = array()) + { + return $this->addRecord(self::INFO, $message, $context); + } + + /** + * Adds a log record at the WARNING level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addWarning($message, array $context = array()) + { + return $this->addRecord(self::WARNING, $message, $context); + } + + /** + * Adds a log record at the ERROR level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addError($message, array $context = array()) + { + return $this->addRecord(self::ERROR, $message, $context); + } + + /** + * Adds a log record at the CRITICAL level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addCritical($message, array $context = array()) + { + return $this->addRecord(self::CRITICAL, $message, $context); + } + + /** + * Adds a log record at the ALERT level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addAlert($message, array $context = array()) + { + return $this->addRecord(self::ALERT, $message, $context); + } + + /** + * Gets the name of the logging level. + * + * @param integer $level + * @return string + */ + public static function getLevelName($level) + { + return self::$levels[$level]; + } + + /** + * Checks whether the Logger has a handler that listens on the given level + * + * @param integer $level + * @return Boolean + */ + public function isHandling($level) + { + $record = array( + 'message' => '', + 'context' => array(), + 'level' => $level, + 'level_name' => self::getLevelName($level), + 'channel' => $this->name, + 'datetime' => new \DateTime(), + 'extra' => array(), + ); + + foreach ($this->handlers as $key => $handler) { + if ($handler->isHandling($record)) { + return true; + } + } + + return false; + } + + // ZF Logger Compat + + /** + * Adds a log record at the DEBUG level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function debug($message, array $context = array()) + { + return $this->addRecord(self::DEBUG, $message, $context); + } + + /** + * Adds a log record at the INFO level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function info($message, array $context = array()) + { + return $this->addRecord(self::INFO, $message, $context); + } + + /** + * Adds a log record at the INFO level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function notice($message, array $context = array()) + { + return $this->addRecord(self::INFO, $message, $context); + } + + /** + * Adds a log record at the WARNING level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function warn($message, array $context = array()) + { + return $this->addRecord(self::WARNING, $message, $context); + } + + /** + * Adds a log record at the ERROR level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function err($message, array $context = array()) + { + return $this->addRecord(self::ERROR, $message, $context); + } + + /** + * Adds a log record at the CRITICAL level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function crit($message, array $context = array()) + { + return $this->addRecord(self::CRITICAL, $message, $context); + } + + /** + * Adds a log record at the ALERT level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function alert($message, array $context = array()) + { + return $this->addRecord(self::ALERT, $message, $context); + } + + /** + * Adds a log record at the ALERT level. + * + * This method allows to have an easy ZF compatibility. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function emerg($message, array $context = array()) + { + return $this->addRecord(self::ALERT, $message, $context); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/IntrospectionProcessor.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/IntrospectionProcessor.php new file mode 100644 index 0000000..f03e347 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/IntrospectionProcessor.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Injects line/file:class/function where the log message came from + * + * Warning: This only works if the handler processes the logs directly. + * If you put the processor on a handler that is behind a FingersCrossedHandler + * for example, the processor will only be called once the trigger level is reached, + * and all the log records will have the same file/line/.. data from the call that + * triggered the FingersCrossedHandler. + * + * @author Jordi Boggiano + */ +class IntrospectionProcessor +{ + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + $trace = debug_backtrace(); + + // skip first since it's always the current method + array_shift($trace); + // the call_user_func call is also skipped + array_shift($trace); + + $i = 0; + while (isset($trace[$i]['class']) && false !== strpos($trace[$i]['class'], 'Monolog\\')) { + $i++; + } + + // we should have the call source now + $record['extra'] = array_merge( + $record['extra'], + array( + 'file' => isset($trace[$i-1]['file']) ? $trace[$i-1]['file'] : null, + 'line' => isset($trace[$i-1]['line']) ? $trace[$i-1]['line'] : null, + 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, + 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, + ) + ); + + return $record; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryPeakUsageProcessor.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryPeakUsageProcessor.php new file mode 100644 index 0000000..77e0324 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryPeakUsageProcessor.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Injects memory_get_peak_usage in all records + * + * @see Monolog\Processor\MemoryProcessor::__construct() for options + * @author Rob Jensen + */ +class MemoryPeakUsageProcessor extends MemoryProcessor +{ + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + $bytes = memory_get_peak_usage($this->realUsage); + $formatted = self::formatBytes($bytes); + + $record['extra'] = array_merge( + $record['extra'], + array( + 'memory_peak_usage' => $formatted, + ) + ); + + return $record; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryProcessor.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryProcessor.php new file mode 100644 index 0000000..7a41238 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryProcessor.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Some methods that are common for all memory processors + * + * @author Rob Jensen + */ +abstract class MemoryProcessor +{ + protected $realUsage; + + /** + * @param boolean $realUsage + */ + public function __construct($realUsage = true) + { + $this->realUsage = (boolean) $realUsage; + } + + /** + * Formats bytes into a human readable string + * + * @param int $bytes + * @return string + */ + protected static function formatBytes($bytes) + { + $bytes = (int) $bytes; + + if ($bytes > 1024*1024) { + return round($bytes/1024/1024, 2).' MB'; + } elseif ($bytes > 1024) { + return round($bytes/1024, 2).' KB'; + } + + return $bytes . ' B'; + } + +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryUsageProcessor.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryUsageProcessor.php new file mode 100644 index 0000000..0867459 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/MemoryUsageProcessor.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Injects memory_get_usage in all records + * + * @see Monolog\Processor\MemoryProcessor::__construct() for options + * @author Rob Jensen + */ +class MemoryUsageProcessor extends MemoryProcessor +{ + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + $bytes = memory_get_usage($this->realUsage); + $formatted = self::formatBytes($bytes); + + $record['extra'] = array_merge( + $record['extra'], + array( + 'memory_usage' => $formatted, + ) + ); + + return $record; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/WebProcessor.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/WebProcessor.php new file mode 100644 index 0000000..61000a0 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/src/Monolog/Processor/WebProcessor.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Injects url/method and remote IP of the current web request in all records + * + * @author Jordi Boggiano + */ +class WebProcessor +{ + protected $serverData; + + /** + * @param mixed $serverData array or object w/ ArrayAccess that provides access to the $_SERVER data + */ + public function __construct($serverData = null) + { + if (null === $serverData) { + $this->serverData =& $_SERVER; + } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) { + $this->serverData = $serverData; + } else { + throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.'); + } + } + + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + // skip processing if for some reason request data + // is not present (CLI or wonky SAPIs) + if (!isset($this->serverData['REQUEST_URI'])) { + return $record; + } + + if (!isset($this->serverData['HTTP_REFERER'])) { + $this->serverData['HTTP_REFERER'] = null; + } + + $record['extra'] = array_merge( + $record['extra'], + array( + 'url' => $this->serverData['REQUEST_URI'], + 'ip' => $this->serverData['REMOTE_ADDR'], + 'http_method' => $this->serverData['REQUEST_METHOD'], + 'server' => $this->serverData['SERVER_NAME'], + 'referrer' => $this->serverData['HTTP_REFERER'], + ) + ); + + return $record; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/ChromePHPFormatterTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/ChromePHPFormatterTest.php new file mode 100644 index 0000000..e7f7334 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/ChromePHPFormatterTest.php @@ -0,0 +1,158 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Formatter\ChromePHPFormatter::format + */ + public function testDefaultFormat() + { + $formatter = new ChromePHPFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1'), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertEquals( + array( + 'meh', + array( + 'message' => 'log', + 'context' => array('from' => 'logger'), + 'extra' => array('ip' => '127.0.0.1'), + ), + 'unknown', + 'error' + ), + $message + ); + } + + /** + * @covers Monolog\Formatter\ChromePHPFormatter::format + */ + public function testFormatWithFileAndLine() + { + $formatter = new ChromePHPFormatter(); + $record = array( + 'level' => Logger::CRITICAL, + 'level_name' => 'CRITICAL', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertEquals( + array( + 'meh', + array( + 'message' => 'log', + 'context' => array('from' => 'logger'), + 'extra' => array('ip' => '127.0.0.1'), + ), + 'test : 14', + 'error' + ), + $message + ); + } + + /** + * @covers Monolog\Formatter\ChromePHPFormatter::format + */ + public function testFormatWithoutContext() + { + $formatter = new ChromePHPFormatter(); + $record = array( + 'level' => Logger::DEBUG, + 'level_name' => 'DEBUG', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertEquals( + array( + 'meh', + 'log', + 'unknown', + 'log' + ), + $message + ); + } + + /** + * @covers Monolog\Formatter\ChromePHPFormatter::formatBatch + */ + public function testBatchFormatThrowException() + { + $formatter = new ChromePHPFormatter(); + $records = array( + array( + 'level' => Logger::INFO, + 'level_name' => 'INFO', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ), + array( + 'level' => Logger::WARNING, + 'level_name' => 'WARNING', + 'channel' => 'foo', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log2', + ), + ); + + $this->assertEquals( + array( + array( + 'meh', + 'log', + 'unknown', + 'info' + ), + array( + 'foo', + 'log2', + 'unknown', + 'warn' + ), + ), + $formatter->formatBatch($records) + ); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/GelfMessageFormatterTest.php new file mode 100644 index 0000000..9409268 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/GelfMessageFormatterTest.php @@ -0,0 +1,150 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testDefaultFormatter() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + $this->assertEquals(0, $message->getTimestamp()); + $this->assertEquals('log', $message->getShortMessage()); + $this->assertEquals('meh', $message->getFacility()); + $this->assertEquals(null, $message->getLine()); + $this->assertEquals(null, $message->getFile()); + $this->assertEquals(LOG_ERR, $message->getLevel()); + $this->assertNotEmpty($message->getHost()); + + $formatter = new GelfMessageFormatter('mysystem'); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + $this->assertEquals('mysystem', $message->getHost()); + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testFormatWithFileAndLine() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + $this->assertEquals('test', $message->getFile()); + $this->assertEquals(14, $message->getLine()); + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testFormatWithContext() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_ctxt_from', $message_array); + $this->assertEquals('logger', $message_array['_ctxt_from']); + + // Test with extraPrefix + $formatter = new GelfMessageFormatter(null, null, 'CTX'); + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_CTXfrom', $message_array); + $this->assertEquals('logger', $message_array['_CTXfrom']); + + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testFormatWithExtra() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_key', $message_array); + $this->assertEquals('pair', $message_array['_key']); + + // Test with extraPrefix + $formatter = new GelfMessageFormatter(null, 'EXT'); + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_EXTkey', $message_array); + $this->assertEquals('pair', $message_array['_EXTkey']); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/JsonFormatterTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/JsonFormatterTest.php new file mode 100644 index 0000000..ba6152c --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/JsonFormatterTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; +use Monolog\TestCase; + +class JsonFormatterTest extends TestCase +{ + /** + * @covers Monolog\Formatter\JsonFormatter::format + */ + public function testFormat() + { + $formatter = new JsonFormatter(); + $record = $this->getRecord(); + $this->assertEquals(json_encode($record), $formatter->format($record)); + } + + /** + * @covers Monolog\Formatter\JsonFormatter::formatBatch + */ + public function testFormatBatch() + { + $formatter = new JsonFormatter(); + $records = array( + $this->getRecord(Logger::WARNING), + $this->getRecord(Logger::DEBUG), + ); + $this->assertEquals(json_encode($records), $formatter->formatBatch($records)); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/LineFormatterTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/LineFormatterTest.php new file mode 100644 index 0000000..0c07dc2 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/LineFormatterTest.php @@ -0,0 +1,134 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * @covers Monolog\Formatter\LineFormatter + */ +class LineFormatterTest extends \PHPUnit_Framework_TestCase +{ + public function testDefFormatWithString() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'context' => array(), + 'message' => 'foo', + 'datetime' => new \DateTime, + 'extra' => array(), + )); + $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message); + } + + public function testDefFormatWithArrayContext() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'message' => 'foo', + 'datetime' => new \DateTime, + 'extra' => array(), + 'context' => array( + 'foo' => 'bar', + 'baz' => 'qux', + ) + )); + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foo {"foo":"bar","baz":"qux"} []'."\n", $message); + } + + public function testDefFormatExtras() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array('ip' => '127.0.0.1'), + 'message' => 'log', + )); + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] {"ip":"127.0.0.1"}'."\n", $message); + } + + public function testFormatExtras() + { + $formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra.file% %extra%\n", 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array('ip' => '127.0.0.1', 'file' => 'test'), + 'message' => 'log', + )); + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message); + } + + public function testDefFormatWithObject() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')), + 'message' => 'foobar', + )); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message); + } else { + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\Formatter\\TestFoo: {"foo":"foo"})","bar":"[object] (Monolog\\Formatter\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message); + } + } + + public function testBatchFormat() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->formatBatch(array( + array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'message' => 'foo', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + )); + $this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message); + } +} + +class TestFoo +{ + public $foo = 'foo'; +} + +class TestBar +{ + public function __toString() + { + return 'bar'; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/NormalizerFormatterTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/NormalizerFormatterTest.php new file mode 100644 index 0000000..8a5e6d6 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/NormalizerFormatterTest.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * @covers Monolog\Formatter\NormalizerFormatter + */ +class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase +{ + public function testFormat() + { + $formatter = new NormalizerFormatter('Y-m-d'); + $formatted = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'message' => 'foo', + 'datetime' => new \DateTime, + 'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')), + 'context' => array( + 'foo' => 'bar', + 'baz' => 'qux', + ) + )); + + $this->assertEquals(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'message' => 'foo', + 'datetime' => date('Y-m-d'), + 'extra' => array( + 'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})', + 'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: {})', + 'baz' => array(), + 'res' => '[resource]', + ), + 'context' => array( + 'foo' => 'bar', + 'baz' => 'qux', + ) + ), $formatted); + } + + public function testBatchFormat() + { + $formatter = new NormalizerFormatter('Y-m-d'); + $formatted = $formatter->formatBatch(array( + array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'message' => 'foo', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + )); + $this->assertEquals(array( + array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array(), + 'datetime' => date('Y-m-d'), + 'extra' => array(), + ), + array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'message' => 'foo', + 'context' => array(), + 'datetime' => date('Y-m-d'), + 'extra' => array(), + ), + ), $formatted); + } +} + +class TestFooNorm +{ + public $foo = 'foo'; +} + +class TestBarNorm +{ + public function __toString() + { + return 'bar'; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/WildfireFormatterTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/WildfireFormatterTest.php new file mode 100644 index 0000000..0b07e33 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Formatter/WildfireFormatterTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class WildfireFormatterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Formatter\WildfireFormatter::format + */ + public function testDefaultFormat() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1'), + 'message' => 'log', + ); + + $message = $wildfire->format($record); + + $this->assertEquals( + '125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},' + .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|', + $message + ); + } + + /** + * @covers Monolog\Formatter\WildfireFormatter::format + */ + public function testFormatWithFileAndLine() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = $wildfire->format($record); + + $this->assertEquals( + '129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},' + .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|', + $message + ); + } + + /** + * @covers Monolog\Formatter\WildfireFormatter::format + */ + public function testFormatWithoutContext() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = $wildfire->format($record); + + $this->assertEquals( + '58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|', + $message + ); + } + + /** + * @covers Monolog\Formatter\WildfireFormatter::formatBatch + * @expectedException BadMethodCallException + */ + public function testBatchFormatThrowException() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $wildfire->formatBatch(array($record)); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php new file mode 100644 index 0000000..49a4263 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +spl_autoload_register(function($class) +{ + $file = __DIR__.'/../../../../src/'.strtr($class, '\\', '/').'.php'; + if (file_exists($file)) { + require $file; + return true; + } +}); + +use Monolog\Logger; +use Monolog\Handler\FirePHPHandler; +use Monolog\Handler\ChromePHPHandler; + +$logger = new Logger('firephp'); +$logger->pushHandler(new FirePHPHandler); +$logger->pushHandler(new ChromePHPHandler()); + +$logger->addDebug('Debug'); +$logger->addInfo('Info'); +$logger->addWarning('Warning'); +$logger->addError('Error'); diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractHandlerTest.php new file mode 100644 index 0000000..01d522f --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractHandlerTest.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Formatter\LineFormatter; +use Monolog\Processor\WebProcessor; + +class AbstractHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\AbstractHandler::__construct + * @covers Monolog\Handler\AbstractHandler::getLevel + * @covers Monolog\Handler\AbstractHandler::setLevel + * @covers Monolog\Handler\AbstractHandler::getBubble + * @covers Monolog\Handler\AbstractHandler::setBubble + * @covers Monolog\Handler\AbstractHandler::getFormatter + * @covers Monolog\Handler\AbstractHandler::setFormatter + */ + public function testConstructAndGetSet() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false)); + $this->assertEquals(Logger::WARNING, $handler->getLevel()); + $this->assertEquals(false, $handler->getBubble()); + + $handler->setLevel(Logger::ERROR); + $handler->setBubble(true); + $handler->setFormatter($formatter = new LineFormatter); + $this->assertEquals(Logger::ERROR, $handler->getLevel()); + $this->assertEquals(true, $handler->getBubble()); + $this->assertSame($formatter, $handler->getFormatter()); + } + + /** + * @covers Monolog\Handler\AbstractHandler::handleBatch + */ + public function testHandleBatch() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + $handler->expects($this->exactly(2)) + ->method('handle'); + $handler->handleBatch(array($this->getRecord(), $this->getRecord())); + } + + /** + * @covers Monolog\Handler\AbstractHandler::isHandling + */ + public function testIsHandling() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false)); + $this->assertTrue($handler->isHandling($this->getRecord())); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\AbstractHandler::getFormatter + * @covers Monolog\Handler\AbstractHandler::getDefaultFormatter + */ + public function testGetFormatterInitializesDefault() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + $this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter()); + } + + /** + * @covers Monolog\Handler\AbstractHandler::pushProcessor + * @covers Monolog\Handler\AbstractHandler::popProcessor + * @expectedException LogicException + */ + public function testPushPopProcessor() + { + $logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + $processor1 = new WebProcessor; + $processor2 = new WebProcessor; + + $logger->pushProcessor($processor1); + $logger->pushProcessor($processor2); + + $this->assertEquals($processor2, $logger->popProcessor()); + $this->assertEquals($processor1, $logger->popProcessor()); + $logger->popProcessor(); + } + + /** + * @covers Monolog\Handler\AbstractHandler::pushProcessor + * @expectedException InvalidArgumentException + */ + public function testPushProcessorWithNonCallable() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + + $handler->pushProcessor(new \stdClass()); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractProcessingHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractProcessingHandlerTest.php new file mode 100644 index 0000000..a8d31a8 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/AbstractProcessingHandlerTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Processor\WebProcessor; + +class AbstractProcessingHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleLowerLevelMessage() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true)); + $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleBubbling() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true)); + $this->assertFalse($handler->handle($this->getRecord())); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleNotBubbling() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false)); + $this->assertTrue($handler->handle($this->getRecord())); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleIsFalseWhenNotHandled() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false)); + $this->assertTrue($handler->handle($this->getRecord())); + $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::processRecord + */ + public function testProcessRecord() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler'); + $handler->pushProcessor(new WebProcessor(array( + 'REQUEST_URI' => '', + 'REQUEST_METHOD' => '', + 'REMOTE_ADDR' => '', + 'REQUEST_URI' => '', + 'SERVER_NAME' => '', + ))); + $handledRecord = null; + $handler->expects($this->once()) + ->method('write') + ->will($this->returnCallback(function($record) use (&$handledRecord){ + $handledRecord = $record; + })) + ; + $handler->handle($this->getRecord()); + $this->assertEquals(5, count($handledRecord['extra'])); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/BufferHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/BufferHandlerTest.php new file mode 100644 index 0000000..dca29d1 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/BufferHandlerTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class BufferHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\BufferHandler::__construct + * @covers Monolog\Handler\BufferHandler::handle + * @covers Monolog\Handler\BufferHandler::close + */ + public function testHandleBuffers() + { + $test = new TestHandler(); + $handler = new BufferHandler($test); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + $handler->close(); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 2); + } + + /** + * @covers Monolog\Handler\BufferHandler::close + */ + public function testDestructPropagatesRecords() + { + $test = new TestHandler(); + $handler = new BufferHandler($test); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + unset($handler); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\BufferHandler::handle + */ + public function testHandleBufferLimit() + { + $test = new TestHandler(); + $handler = new BufferHandler($test, 2); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->close(); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertFalse($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\BufferHandler::handle + */ + public function testHandleLevel() + { + $test = new TestHandler(); + $handler = new BufferHandler($test, 0, Logger::INFO); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->close(); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertFalse($test->hasDebugRecords()); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/ChromePHPHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/ChromePHPHandlerTest.php new file mode 100644 index 0000000..812ea07 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/ChromePHPHandlerTest.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\ChromePHPHandler + */ +class ChromePHPHandlerTest extends TestCase +{ + protected function setUp() + { + TestChromePHPHandler::reset(); + } + + public function testHeaders() + { + $handler = new TestChromePHPHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-ChromePhp-Data' => base64_encode(utf8_encode(json_encode(array( + 'version' => ChromePHPHandler::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array( + 'test', + 'test', + ), + 'request_uri' => '', + )))) + ); + + $this->assertEquals($expected, $handler->getHeaders()); + } + + public function testConcurrentHandlers() + { + $handler = new TestChromePHPHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $handler2 = new TestChromePHPHandler(); + $handler2->setFormatter($this->getIdentityFormatter()); + $handler2->handle($this->getRecord(Logger::DEBUG)); + $handler2->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-ChromePhp-Data' => base64_encode(utf8_encode(json_encode(array( + 'version' => ChromePHPHandler::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array( + 'test', + 'test', + 'test', + 'test', + ), + 'request_uri' => '', + )))) + ); + + $this->assertEquals($expected, $handler2->getHeaders()); + } +} + +class TestChromePHPHandler extends ChromePHPHandler +{ + protected $headers = array(); + + public static function reset() + { + self::$initialized = false; + self::$json['rows'] = array(); + } + + protected function sendHeader($header, $content) + { + $this->headers[$header] = $content; + } + + public function getHeaders() + { + return $this->headers; + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FingersCrossedHandlerTest.php new file mode 100644 index 0000000..602324f --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FingersCrossedHandlerTest.php @@ -0,0 +1,151 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; + +class FingersCrossedHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\FingersCrossedHandler::__construct + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleBuffers() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 3); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleStopsBufferingAfterTrigger() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + * @covers Monolog\Handler\FingersCrossedHandler::reset + */ + public function testHandleRestartBufferingAfterReset() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->reset(); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleBufferLimit() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, Logger::WARNING, 2); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertFalse($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleWithCallback() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler(function($record, $handler) use ($test) { + return $test; + }); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 3); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + * @expectedException RuntimeException + */ + public function testHandleWithBadCallbackThrowsException() + { + $handler = new FingersCrossedHandler(function($record, $handler) { + return 'foo'; + }); + $handler->handle($this->getRecord(Logger::WARNING)); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::isHandling + */ + public function testIsHandlingAlways() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, Logger::ERROR); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::__construct + */ + public function testActivationStrategy() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $this->assertFalse($test->hasDebugRecords()); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasWarningRecords()); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FirePHPHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FirePHPHandlerTest.php new file mode 100644 index 0000000..a9e0b5b --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/FirePHPHandlerTest.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\FirePHPHandler + */ +class FirePHPHandlerTest extends TestCase +{ + public function setUp() + { + TestFirePHPHandler::reset(); + } + + public function testHeaders() + { + $handler = new TestFirePHPHandler; + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2', + 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1', + 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3', + 'X-Wf-1-1-1-1' => 'test', + 'X-Wf-1-1-1-2' => 'test', + ); + + $this->assertEquals($expected, $handler->getHeaders()); + } + + public function testConcurrentHandlers() + { + $handler = new TestFirePHPHandler; + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $handler2 = new TestFirePHPHandler; + $handler2->setFormatter($this->getIdentityFormatter()); + $handler2->handle($this->getRecord(Logger::DEBUG)); + $handler2->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2', + 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1', + 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3', + 'X-Wf-1-1-1-1' => 'test', + 'X-Wf-1-1-1-2' => 'test', + ); + + $expected2 = array( + 'X-Wf-1-1-1-3' => 'test', + 'X-Wf-1-1-1-4' => 'test', + ); + + $this->assertEquals($expected, $handler->getHeaders()); + $this->assertEquals($expected2, $handler2->getHeaders()); + } +} + +class TestFirePHPHandler extends FirePHPHandler +{ + protected $headers = array(); + + public static function reset() + { + self::$initialized = false; + self::$messageIndex = 1; + } + + protected function sendHeader($header, $content) + { + $this->headers[$header] = $content; + } + + public function getHeaders() + { + return $this->headers; + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/Fixtures/.gitkeep b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/Fixtures/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GelfHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GelfHandlerTest.php new file mode 100644 index 0000000..8b39590 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GelfHandlerTest.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Formatter\GelfMessageFormatter; +use Gelf\MessagePublisher; +use Gelf\Message; + +class MockMessagePublisher extends MessagePublisher +{ + public function publish(Message $message) { + $this->lastMessage = $message; + } + + public $lastMessage = null; +} + +class GelfHandlerTest extends TestCase +{ + public function setUp() + { + if (!class_exists("Gelf\MessagePublisher")) { + $this->markTestSkipped("mlehner/gelf-php not installed"); + } + } + + /** + * @covers Monolog\Handler\GelfHandler::__construct + */ + public function testConstruct() + { + $handler = new GelfHandler($this->getMessagePublisher()); + $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler); + } + + protected function getHandler($messagePublisher) + { + $handler = new GelfHandler($messagePublisher); + return $handler; + } + + protected function getMessagePublisher() + { + return new MockMessagePublisher('localhost'); + } + + public function testDebug() + { + $messagePublisher = $this->getMessagePublisher(); + $handler = $this->getHandler($messagePublisher); + + $record = $this->getRecord(Logger::DEBUG, "A test debug message"); + $handler->handle($record); + + $this->assertEquals(LOG_DEBUG, $messagePublisher->lastMessage->getLevel()); + $this->assertEquals('test', $messagePublisher->lastMessage->getFacility()); + $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage()); + $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage()); + } + + public function testWarning() + { + $messagePublisher = $this->getMessagePublisher(); + $handler = $this->getHandler($messagePublisher); + + $record = $this->getRecord(Logger::WARNING, "A test warning message"); + $handler->handle($record); + + $this->assertEquals(LOG_WARNING, $messagePublisher->lastMessage->getLevel()); + $this->assertEquals('test', $messagePublisher->lastMessage->getFacility()); + $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage()); + $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage()); + } + + public function testInjectedGelfMessageFormatter() + { + $messagePublisher = $this->getMessagePublisher(); + $handler = $this->getHandler($messagePublisher); + + $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX')); + + $record = $this->getRecord(Logger::WARNING, "A test warning message"); + $record['extra']['blarg'] = 'yep'; + $record['context']['from'] = 'logger'; + $handler->handle($record); + + $this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost()); + $this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray()); + $this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray()); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GroupHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GroupHandlerTest.php new file mode 100644 index 0000000..44d77a5 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/GroupHandlerTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class GroupHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\GroupHandler::__construct + * @expectedException InvalidArgumentException + */ + public function testConstructorOnlyTakesHandler() + { + new GroupHandler(array(new TestHandler(), "foo")); + } + + /** + * @covers Monolog\Handler\GroupHandler::__construct + * @covers Monolog\Handler\GroupHandler::handle + */ + public function testHandle() + { + $testHandlers = array(new TestHandler(), new TestHandler()); + $handler = new GroupHandler($testHandlers); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + foreach ($testHandlers as $test) { + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 2); + } + } + + /** + * @covers Monolog\Handler\GroupHandler::handleBatch + */ + public function testHandleBatch() + { + $testHandlers = array(new TestHandler(), new TestHandler()); + $handler = new GroupHandler($testHandlers); + $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO))); + foreach ($testHandlers as $test) { + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 2); + } + } + + /** + * @covers Monolog\Handler\GroupHandler::isHandling + */ + public function testIsHandling() + { + $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING)); + $handler = new GroupHandler($testHandlers); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR))); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING))); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MailHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MailHandlerTest.php new file mode 100644 index 0000000..c8d9ef5 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MailHandlerTest.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\TestCase; + +class MailHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\MailHandler::handleBatch + */ + public function testHandleBatch() + { + $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); + $formatter->expects($this->once()) + ->method('formatBatch'); // Each record is formatted + + $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); + $handler->expects($this->once()) + ->method('send'); + $handler->expects($this->never()) + ->method('write'); // write is for individual records + + $handler->setFormatter($formatter); + + $handler->handleBatch($this->getMultipleRecords()); + } + + /** + * @covers Monolog\Handler\MailHandler::handleBatch + */ + public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel() + { + $records = array( + $this->getRecord(Logger::DEBUG, 'debug message 1'), + $this->getRecord(Logger::DEBUG, 'debug message 2'), + $this->getRecord(Logger::INFO, 'information'), + ); + + $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); + $handler->expects($this->never()) + ->method('send'); + $handler->setLevel(Logger::ERROR); + + $handler->handleBatch($records); + } + + /** + * @covers Monolog\Handler\MailHandler::write + */ + public function testHandle() + { + $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); + + $record = $this->getRecord(); + $records = array($record); + $records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n"; + + $handler->expects($this->once()) + ->method('send') + ->with($records[0]['formatted'], $records); + + $handler->handle($record); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MongoDBHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MongoDBHandlerTest.php new file mode 100644 index 0000000..2326c98 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/MongoDBHandlerTest.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class MongoDBHandlerTest extends TestCase +{ + public function testHandle() + { + $mongo = $this->getMock('Mongo', array('selectCollection')); + $collection = $this->getMock('stdClass', array('save')); + + $mongo->expects($this->once()) + ->method('selectCollection') + ->with('DB', 'Collection') + ->will($this->returnValue($collection)); + + $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); + + $expected = array( + 'message' => 'test', + 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34), + 'level' => Logger::WARNING, + 'level_name' => 'WARNING', + 'channel' => 'test', + 'datetime' => $record['datetime']->format('Y-m-d H:i:s'), + 'extra' => array(), + ); + + $collection->expects($this->once()) + ->method('save') + ->with($expected); + + $handler = new MongoDBHandler($mongo, 'DB', 'Collection'); + $handler->handle($record); + } +} + +if (!class_exists('Mongo')) { + class Mongo { + public function selectCollection() {} + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/NullHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/NullHandlerTest.php new file mode 100644 index 0000000..12d1316 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/NullHandlerTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\NullHandler::handle + */ +class NullHandlerTest extends TestCase +{ + public function testHandle() + { + $handler = new NullHandler(); + $this->assertTrue($handler->handle($this->getRecord())); + } + + public function testHandleLowerLevelRecord() + { + $handler = new NullHandler(Logger::WARNING); + $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); + } +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/RotatingFileHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/RotatingFileHandlerTest.php new file mode 100644 index 0000000..790f216 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/RotatingFileHandlerTest.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\RotatingFileHandler + */ +class RotatingFileHandlerTest extends TestCase +{ + public function setUp() + { + $dir = __DIR__.'/Fixtures'; + chmod($dir, 0777); + if (!is_writable($dir)) { + $this->markTestSkipped($dir.' must be writeable to test the RotatingFileHandler.'); + } + } + + public function testRotationCreatesNewFile() + { + touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot'); + + $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot'); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord()); + + $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; + $this->assertTrue(file_exists($log)); + $this->assertEquals('test', file_get_contents($log)); + } + + /** + * @dataProvider rotationTests + */ + public function testRotation($createFile) + { + touch($old1 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot'); + touch($old2 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 2).'.rot'); + touch($old3 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 3).'.rot'); + touch($old4 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 4).'.rot'); + + $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; + + if ($createFile) { + touch($log); + } + + $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord()); + + $handler->close(); + + $this->assertTrue(file_exists($log)); + $this->assertTrue(file_exists($old1)); + $this->assertEquals($createFile, file_exists($old2)); + $this->assertEquals($createFile, file_exists($old3)); + $this->assertEquals($createFile, file_exists($old4)); + $this->assertEquals('test', file_get_contents($log)); + } + + public function rotationTests() + { + return array( + 'Rotation is triggered when the file of the current day is not present' + => array(true), + 'Rotation is not triggered when the file is already present' + => array(false), + ); + } + + public function testReuseCurrentFile() + { + $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; + file_put_contents($log, "foo"); + $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot'); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord()); + $this->assertEquals('footest', file_get_contents($log)); + } + + public function tearDown() + { + foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) { + unlink($file); + } + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SocketHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SocketHandlerTest.php new file mode 100644 index 0000000..741a412 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SocketHandlerTest.php @@ -0,0 +1,284 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @author Pablo de Leon Belloc + */ +class SocketHandlerTest extends TestCase +{ + /** + * @var Monolog\Handler\SocketHandler + */ + private $handler; + + /** + * @var resource + */ + private $res; + + /** + * @expectedException UnexpectedValueException + */ + public function testInvalidHostname() + { + $this->createHandler('garbage://here'); + $this->writeRecord('data'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testBadConnectionTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setConnectionTimeout(-1); + } + + public function testSetConnectionTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setConnectionTimeout(10); + $this->assertEquals(10, $this->handler->getConnectionTimeout()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testBadTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setTimeout(-1); + } + + public function testSetTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setTimeout(10); + $this->assertEquals(10, $this->handler->getTimeout()); + } + + public function testSetConnectionString() + { + $this->createHandler('tcp://localhost:9090'); + $this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString()); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testExceptionIsThrownOnFsockopenError() + { + $this->setMockHandler(array('fsockopen')); + $this->handler->expects($this->once()) + ->method('fsockopen') + ->will($this->returnValue(false)); + $this->writeRecord('Hello world'); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testExceptionIsThrownOnPfsockopenError() + { + $this->setMockHandler(array('pfsockopen')); + $this->handler->expects($this->once()) + ->method('pfsockopen') + ->will($this->returnValue(false)); + $this->handler->setPersistent(true); + $this->writeRecord('Hello world'); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testExceptionIsThrownIfCannotSetTimeout() + { + $this->setMockHandler(array('streamSetTimeout')); + $this->handler->expects($this->once()) + ->method('streamSetTimeout') + ->will($this->returnValue(false)); + $this->writeRecord('Hello world'); + } + + /** + * @expectedException RuntimeException + */ + public function testWriteFailsOnIfFwriteReturnsFalse() + { + $this->setMockHandler(array('fwrite')); + + $callback = function($arg) + { + $map = array( + 'Hello world' => 6, + 'world' => false, + ); + return $map[$arg]; + }; + + $this->handler->expects($this->exactly(2)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + + $this->writeRecord('Hello world'); + } + + /** + * @expectedException RuntimeException + */ + public function testWriteFailsIfStreamTimesOut() + { + $this->setMockHandler(array('fwrite', 'streamGetMetadata')); + + $callback = function($arg) + { + $map = array( + 'Hello world' => 6, + 'world' => 5, + ); + return $map[$arg]; + }; + + $this->handler->expects($this->exactly(1)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + $this->handler->expects($this->exactly(1)) + ->method('streamGetMetadata') + ->will($this->returnValue(array('timed_out' => true))); + + + $this->writeRecord('Hello world'); + } + + /** + * @expectedException RuntimeException + */ + public function testWriteFailsOnIncompleteWrite() + { + $this->setMockHandler(array('fwrite', 'streamGetMetadata')); + + $res = $this->res; + $callback = function($string) use ($res) + { + fclose($res); + return strlen('Hello'); + }; + + $this->handler->expects($this->exactly(1)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + $this->handler->expects($this->exactly(1)) + ->method('streamGetMetadata') + ->will($this->returnValue(array('timed_out' => false))); + + $this->writeRecord('Hello world'); + } + + public function testWriteWithMemoryFile() + { + $this->setMockHandler(); + $this->writeRecord('test1'); + $this->writeRecord('test2'); + $this->writeRecord('test3'); + fseek($this->res, 0); + $this->assertEquals('test1test2test3', fread($this->res, 1024)); + } + + public function testWriteWithMock() + { + $this->setMockHandler(array('fwrite')); + + $callback = function($arg) + { + $map = array( + 'Hello world' => 6, + 'world' => 5, + ); + return $map[$arg]; + }; + + $this->handler->expects($this->exactly(2)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + + $this->writeRecord('Hello world'); + } + + public function testClose() + { + $this->setMockHandler(); + $this->writeRecord('Hello world'); + $this->assertInternalType('resource', $this->res); + $this->handler->close(); + $this->assertFalse(is_resource($this->res), "Expected resource to be closed after closing handler"); + } + + public function testCloseDoesNotClosePersistentSocket() + { + $this->setMockHandler(); + $this->handler->setPersistent(true); + $this->writeRecord('Hello world'); + $this->assertTrue(is_resource($this->res)); + $this->handler->close(); + $this->assertTrue(is_resource($this->res)); + } + + private function createHandler($connectionString) + { + $this->handler = new SocketHandler($connectionString); + $this->handler->setFormatter($this->getIdentityFormatter()); + } + + private function writeRecord($string) + { + $this->handler->handle($this->getRecord(Logger::WARNING, $string)); + } + + private function setMockHandler(array $methods = array()) + { + $this->res = fopen('php://memory', 'a'); + + $defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout'); + $newMethods = array_diff($methods, $defaultMethods); + + $finalMethods = array_merge($defaultMethods, $newMethods); + + $this->handler = $this->getMock( + '\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234') + ); + + if (!in_array('fsockopen', $methods)) { + $this->handler->expects($this->any()) + ->method('fsockopen') + ->will($this->returnValue($this->res)); + } + + if (!in_array('pfsockopen', $methods)) { + $this->handler->expects($this->any()) + ->method('pfsockopen') + ->will($this->returnValue($this->res)); + } + + if (!in_array('streamSetTimeout', $methods)) { + $this->handler->expects($this->any()) + ->method('streamSetTimeout') + ->will($this->returnValue(true)); + } + + $this->handler->setFormatter($this->getIdentityFormatter()); + } + +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/StreamHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/StreamHandlerTest.php new file mode 100644 index 0000000..6f7cbec --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/StreamHandlerTest.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class StreamHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\StreamHandler::__construct + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWrite() + { + $handle = fopen('php://memory', 'a+'); + $handler = new StreamHandler($handle); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::WARNING, 'test')); + $handler->handle($this->getRecord(Logger::WARNING, 'test2')); + $handler->handle($this->getRecord(Logger::WARNING, 'test3')); + fseek($handle, 0); + $this->assertEquals('testtest2test3', fread($handle, 100)); + } + + /** + * @covers Monolog\Handler\StreamHandler::close + */ + public function testClose() + { + $handle = fopen('php://memory', 'a+'); + $handler = new StreamHandler($handle); + $this->assertTrue(is_resource($handle)); + $handler->close(); + $this->assertFalse(is_resource($handle)); + } + + /** + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWriteCreatesTheStreamResource() + { + $handler = new StreamHandler('php://memory'); + $handler->handle($this->getRecord()); + } + + /** + * @expectedException LogicException + * @covers Monolog\Handler\StreamHandler::__construct + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWriteMissingResource() + { + $handler = new StreamHandler(null); + $handler->handle($this->getRecord()); + } + + /** + * @expectedException UnexpectedValueException + * @covers Monolog\Handler\StreamHandler::__construct + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWriteInvalidResource() + { + $handler = new StreamHandler('bogus://url'); + $handler->handle($this->getRecord()); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SyslogHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SyslogHandlerTest.php new file mode 100644 index 0000000..b2382f4 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/SyslogHandlerTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +class SyslogHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Handler\SyslogHandler::__construct + */ + public function testConstruct() + { + $handler = new SyslogHandler('test'); + $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); + + $handler = new SyslogHandler('test', LOG_USER); + $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); + + $handler = new SyslogHandler('test', 'user'); + $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); + } + + /** + * @covers Monolog\Handler\SyslogHandler::__construct + */ + public function testConstructInvalidFacility() + { + $this->setExpectedException('UnexpectedValueException'); + $handler = new SyslogHandler('test', 'unknown'); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/TestHandlerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/TestHandlerTest.php new file mode 100644 index 0000000..1addf7e --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Handler/TestHandlerTest.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\TestHandler + */ +class TestHandlerTest extends TestCase +{ + /** + * @dataProvider methodProvider + */ + public function testHandler($method, $level) + { + $handler = new TestHandler; + $record = $this->getRecord($level, 'test'.$method); + $this->assertFalse($handler->{'has'.$method}($record)); + $this->assertFalse($handler->{'has'.$method.'Records'}()); + $handler->handle($record); + + $this->assertFalse($handler->{'has'.$method}('bar')); + $this->assertTrue($handler->{'has'.$method}($record)); + $this->assertTrue($handler->{'has'.$method}('test'.$method)); + $this->assertTrue($handler->{'has'.$method.'Records'}()); + + $records = $handler->getRecords(); + unset($records[0]['formatted']); + $this->assertEquals(array($record), $records); + } + + public function methodProvider() + { + return array( + array('Alert' , Logger::ALERT), + array('Critical', Logger::CRITICAL), + array('Error' , Logger::ERROR), + array('Warning' , Logger::WARNING), + array('Info' , Logger::INFO), + array('Debug' , Logger::DEBUG), + ); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/LoggerTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/LoggerTest.php new file mode 100644 index 0000000..403913b --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/LoggerTest.php @@ -0,0 +1,367 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Monolog\Processor\WebProcessor; +use Monolog\Handler\TestHandler; + +class LoggerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Logger::getName + */ + public function testGetName() + { + $logger = new Logger('foo'); + $this->assertEquals('foo', $logger->getName()); + } + + /** + * @covers Monolog\Logger::__construct + */ + public function testChannel() + { + $logger = new Logger('foo'); + $handler = new TestHandler; + $logger->pushHandler($handler); + $logger->addWarning('test'); + list($record) = $handler->getRecords(); + $this->assertEquals('foo', $record['channel']); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testLog() + { + $logger = new Logger(__METHOD__); + + $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle')); + $handler->expects($this->once()) + ->method('handle'); + $logger->pushHandler($handler); + + $this->assertTrue($logger->addWarning('test')); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testLogNotHandled() + { + $logger = new Logger(__METHOD__); + + $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'), array(Logger::ERROR)); + $handler->expects($this->never()) + ->method('handle'); + $logger->pushHandler($handler); + + $this->assertFalse($logger->addWarning('test')); + } + + /** + * @covers Monolog\Logger::pushHandler + * @covers Monolog\Logger::popHandler + * @expectedException LogicException + */ + public function testPushPopHandler() + { + $logger = new Logger(__METHOD__); + $handler1 = new TestHandler; + $handler2 = new TestHandler; + + $logger->pushHandler($handler1); + $logger->pushHandler($handler2); + + $this->assertEquals($handler2, $logger->popHandler()); + $this->assertEquals($handler1, $logger->popHandler()); + $logger->popHandler(); + } + + /** + * @covers Monolog\Logger::pushProcessor + * @covers Monolog\Logger::popProcessor + * @expectedException LogicException + */ + public function testPushPopProcessor() + { + $logger = new Logger(__METHOD__); + $processor1 = new WebProcessor; + $processor2 = new WebProcessor; + + $logger->pushProcessor($processor1); + $logger->pushProcessor($processor2); + + $this->assertEquals($processor2, $logger->popProcessor()); + $this->assertEquals($processor1, $logger->popProcessor()); + $logger->popProcessor(); + } + + /** + * @covers Monolog\Logger::pushProcessor + * @expectedException InvalidArgumentException + */ + public function testPushProcessorWithNonCallable() + { + $logger = new Logger(__METHOD__); + + $logger->pushProcessor(new \stdClass()); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testProcessorsAreExecuted() + { + $logger = new Logger(__METHOD__); + $handler = new TestHandler; + $logger->pushHandler($handler); + $logger->pushProcessor(function($record) { + $record['extra']['win'] = true; + return $record; + }); + $logger->addError('test'); + list($record) = $handler->getRecords(); + $this->assertTrue($record['extra']['win']); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testProcessorsAreCalledOnlyOnce() + { + $logger = new Logger(__METHOD__); + $handler = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler->expects($this->any()) + ->method('handle') + ->will($this->returnValue(true)) + ; + $logger->pushHandler($handler); + + $processor = $this->getMockBuilder('Monolog\Processor\WebProcessor') + ->disableOriginalConstructor() + ->setMethods(array('__invoke')) + ->getMock() + ; + $processor->expects($this->once()) + ->method('__invoke') + ->will($this->returnArgument(0)) + ; + $logger->pushProcessor($processor); + + $logger->addError('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testProcessorsNotCalledWhenNotHandled() + { + $logger = new Logger(__METHOD__); + $handler = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler->expects($this->once()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler); + $that = $this; + $logger->pushProcessor(function($record) use ($that){ + $that->fail('The processor should not be called'); + }); + $logger->addAlert('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testHandlersNotCalledBeforeFirstHandling() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->never()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + $handler1->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler1); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->once()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler2->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler2); + + $handler3 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler3->expects($this->once()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + $handler3->expects($this->never()) + ->method('handle') + ; + $logger->pushHandler($handler3); + + $logger->debug('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testBubblingWhenTheHandlerReturnsFalse() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler1->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler1); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler2->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler2); + + $logger->debug('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testNotBubblingWhenTheHandlerReturnsTrue() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler1->expects($this->never()) + ->method('handle') + ; + $logger->pushHandler($handler1); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler2->expects($this->once()) + ->method('handle') + ->will($this->returnValue(true)) + ; + $logger->pushHandler($handler2); + + $logger->debug('test'); + } + + /** + * @covers Monolog\Logger::isHandling + */ + public function testIsHandling() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + + $logger->pushHandler($handler1); + $this->assertFalse($logger->isHandling(Logger::DEBUG)); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + + $logger->pushHandler($handler2); + $this->assertTrue($logger->isHandling(Logger::DEBUG)); + } + + /** + * @dataProvider logMethodProvider + * @covers Monolog\Logger::addDebug + * @covers Monolog\Logger::addInfo + * @covers Monolog\Logger::addWarning + * @covers Monolog\Logger::addError + * @covers Monolog\Logger::addCritical + * @covers Monolog\Logger::addAlert + * @covers Monolog\Logger::debug + * @covers Monolog\Logger::info + * @covers Monolog\Logger::notice + * @covers Monolog\Logger::warn + * @covers Monolog\Logger::err + * @covers Monolog\Logger::crit + * @covers Monolog\Logger::alert + * @covers Monolog\Logger::emerg + */ + public function testLogMethods($method, $expectedLevel) + { + $logger = new Logger('foo'); + $handler = new TestHandler; + $logger->pushHandler($handler); + $logger->{$method}('test'); + list($record) = $handler->getRecords(); + $this->assertEquals($expectedLevel, $record['level']); + } + + public function logMethodProvider() + { + return array( + // monolog methods + array('addDebug', Logger::DEBUG), + array('addInfo', Logger::INFO), + array('addWarning', Logger::WARNING), + array('addError', Logger::ERROR), + array('addCritical', Logger::CRITICAL), + array('addAlert', Logger::ALERT), + + // ZF/Sf2 compat methods + array('debug', Logger::DEBUG), + array('info', Logger::INFO), + array('notice', Logger::INFO), + array('warn', Logger::WARNING), + array('err', Logger::ERROR), + array('crit', Logger::CRITICAL), + array('alert', Logger::ALERT), + array('emerg', Logger::ALERT), + ); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/IntrospectionProcessorTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/IntrospectionProcessorTest.php new file mode 100644 index 0000000..be78df8 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/IntrospectionProcessorTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; +use Monolog\Handler\TestHandler; + +class IntrospectionProcessorTest extends TestCase +{ + public function getHandler() + { + $processor = new IntrospectionProcessor(); + $handler = new TestHandler(); + $handler->pushProcessor($processor); + return $handler; + } + + public function testProcessorFromClass() + { + $handler = $this->getHandler(); + $tester = new \Acme\Tester; + $tester->test($handler, $this->getRecord()); + list($record) = $handler->getRecords(); + $this->assertEquals(__FILE__, $record['extra']['file']); + $this->assertEquals(57, $record['extra']['line']); + $this->assertEquals('Acme\Tester', $record['extra']['class']); + $this->assertEquals('test', $record['extra']['function']); + } + + public function testProcessorFromFunc() + { + $handler = $this->getHandler(); + \Acme\tester($handler, $this->getRecord()); + list($record) = $handler->getRecords(); + $this->assertEquals(__FILE__, $record['extra']['file']); + $this->assertEquals(63, $record['extra']['line']); + $this->assertEquals(null, $record['extra']['class']); + $this->assertEquals('Acme\tester', $record['extra']['function']); + } +} + +namespace Acme; + +class Tester +{ + function test($handler, $record) + { + $handler->handle($record); + } +} + +function tester($handler, $record) +{ + $handler->handle($record); +} \ No newline at end of file diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php new file mode 100644 index 0000000..4bdf22c --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class MemoryPeakUsageProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke + * @covers Monolog\Processor\MemoryProcessor::formatBytes + */ + public function testProcessor() + { + $processor = new MemoryPeakUsageProcessor(); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('memory_peak_usage', $record['extra']); + $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryUsageProcessorTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryUsageProcessorTest.php new file mode 100644 index 0000000..a30d6de --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/MemoryUsageProcessorTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class MemoryUsageProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\MemoryUsageProcessor::__invoke + * @covers Monolog\Processor\MemoryProcessor::formatBytes + */ + public function testProcessor() + { + $processor = new MemoryUsageProcessor(); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('memory_usage', $record['extra']); + $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/WebProcessorTest.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/WebProcessorTest.php new file mode 100644 index 0000000..04a5422 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/Processor/WebProcessorTest.php @@ -0,0 +1,68 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class WebProcessorTest extends TestCase +{ + public function testProcessor() + { + $server = array( + 'REQUEST_URI' => 'A', + 'REMOTE_ADDR' => 'B', + 'REQUEST_METHOD' => 'C', + 'HTTP_REFERER' => 'D', + 'SERVER_NAME' => 'F', + ); + + $processor = new WebProcessor($server); + $record = $processor($this->getRecord()); + $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']); + $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']); + $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']); + $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); + $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']); + } + + public function testProcessorDoNothingIfNoRequestUri() + { + $server = array( + 'REMOTE_ADDR' => 'B', + 'REQUEST_METHOD' => 'C', + ); + $processor = new WebProcessor($server); + $record = $processor($this->getRecord()); + $this->assertEmpty($record['extra']); + } + + public function testProcessorReturnNullIfNoHttpReferer() + { + $server = array( + 'REQUEST_URI' => 'A', + 'REMOTE_ADDR' => 'B', + 'REQUEST_METHOD' => 'C', + 'SERVER_NAME' => 'F', + ); + $processor = new WebProcessor($server); + $record = $processor($this->getRecord()); + $this->assertNull($record['extra']['referrer']); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testInvalidData() + { + new WebProcessor(new \stdClass); + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/TestCase.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/TestCase.php new file mode 100644 index 0000000..1067b91 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/Monolog/TestCase.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +class TestCase extends \PHPUnit_Framework_TestCase +{ + /** + * @return array Record + */ + protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array()) + { + return array( + 'message' => $message, + 'context' => $context, + 'level' => $level, + 'level_name' => Logger::getLevelName($level), + 'channel' => 'test', + 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))), + 'extra' => array(), + ); + } + + /** + * @return array + */ + protected function getMultipleRecords() + { + return array( + $this->getRecord(Logger::DEBUG, 'debug message 1'), + $this->getRecord(Logger::DEBUG, 'debug message 2'), + $this->getRecord(Logger::INFO, 'information'), + $this->getRecord(Logger::WARNING, 'warning'), + $this->getRecord(Logger::ERROR, 'error') + ); + } + + /** + * @return Monolog\Formatter\FormatterInterface + */ + protected function getIdentityFormatter() + { + $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); + $formatter->expects($this->any()) + ->method('format') + ->will($this->returnCallback(function($record) { return $record['message']; })); + + return $formatter; + } +} diff --git a/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/bootstrap.php b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/bootstrap.php new file mode 100644 index 0000000..b5a1963 --- /dev/null +++ b/vendor/monolog/monolog/Seldaek-monolog-abc80e0/tests/bootstrap.php @@ -0,0 +1,13 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__ . "/../vendor/autoload.php"; +require_once __DIR__.'/Monolog/TestCase.php'; diff --git a/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 8cfef35..94aa955 100644 --- a/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -256,7 +256,6 @@ class FrameworkExtension extends Extension $container->setParameter('request_listener.https_port', $config['https_port']); $this->addClassesToCompile(array( - 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher', 'Symfony\\Component\\Routing\\Generator\\UrlGenerator', 'Symfony\\Component\\Routing\\RequestContext', 'Symfony\\Component\\Routing\\Router', diff --git a/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php index 422e3a7..f39235c 100644 --- a/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ b/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php @@ -23,7 +23,13 @@ class NativeFileSessionHandler extends NativeSessionHandler /** * Constructor. * - * @param string $savePath Path of directory to save session files. Default null will leave setting as defined by PHP. + * @param string $savePath Path of directory to save session files. + * Default null will leave setting as defined by PHP. + * '/path', 'N;/path', or 'N;octal-mode;/path + * + * @see http://php.net/session.configuration.php#ini.session.save-path for further details. + * + * @throws \InvalidArgumentException On invalid $savePath */ public function __construct($savePath = null) { @@ -31,11 +37,22 @@ class NativeFileSessionHandler extends NativeSessionHandler $savePath = ini_get('session.save_path'); } - if ($savePath && !is_dir($savePath)) { - mkdir($savePath, 0777, true); + $baseDir = $savePath; + + if ($count = substr_count($savePath, ';')) { + if ($count > 2) { + throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'', $savePath)); + } + + // characters after last ';' are the path + $baseDir = ltrim(strrchr($savePath, ';'), ';'); + } + + if ($baseDir && !is_dir($baseDir)) { + mkdir($baseDir, 0777, true); } - ini_set('session.save_handler', 'files'); ini_set('session.save_path', $savePath); + ini_set('session.save_handler', 'files'); } } diff --git a/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index 7bdf3a1..fdb0b99 100644 --- a/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; */ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase { - public function testConstruct() + public function test__Construct() { $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); @@ -39,6 +39,37 @@ class NativeFileSessionHandlerTest extends \PHPUnit_Framework_TestCase $this->assertEquals('TESTING', ini_get('session.name')); } + /** + * @dataProvider savePathDataProvider + */ + public function test__ConstructSavePath($savePath, $expectedSavePath, $path) + { + $handler = new NativeFileSessionHandler($savePath); + $this->assertEquals($expectedSavePath, ini_get('session.save_path')); + $dir = realpath('/'.$path); + $this->assertTrue(is_dir(realpath($dir))); + + rmdir($dir); + } + + public function savePathDataProvider() + { + $base = sys_get_temp_dir(); + return array( + array("$base/foo", "$base/foo", "$base/foo"), + array("5;$base/foo", "5;$base/foo", "$base/foo"), + array("5;0600;$base/foo", "5;0600;$base/foo", "$base/foo"), + ); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function test__ConstructException() + { + $handler = new NativeFileSessionHandler('something;invalid;with;too-many-args'); + } + public function testConstructDefault() { $path = ini_get('session.save_path'); diff --git a/vendor/twig/extensions/.gitignore b/vendor/twig/extensions/.gitignore new file mode 100644 index 0000000..cc66c71 --- /dev/null +++ b/vendor/twig/extensions/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +phpunit.xml \ No newline at end of file diff --git a/vendor/twig/extensions/README b/vendor/twig/extensions/README new file mode 100644 index 0000000..a78292c --- /dev/null +++ b/vendor/twig/extensions/README @@ -0,0 +1,7 @@ +Twig Extensions Repository +========================== + +This repository hosts Twig Extensions that do not belong to the core but can +be nonetheless interesting to share with other developers. + +Fork this repository, add your extension, and request a pull. diff --git a/vendor/twig/extensions/doc/debug.rst b/vendor/twig/extensions/doc/debug.rst new file mode 100644 index 0000000..5838bd2 --- /dev/null +++ b/vendor/twig/extensions/doc/debug.rst @@ -0,0 +1,30 @@ +The Debug Extension +=================== + +.. caution:: + + This extension is deprecated as of Twig 1.5. Use the Twig built-in `dump`_ + function instead. + +The ``debug`` extension provides a ``debug`` tag that can be used to +output the content of the current context: + +.. code-block:: jinja + + {% debug %} + +This is really useful when a template does not work as expected. You can also +output a specific variable or an expression: + +.. code-block:: jinja + + {% debug items %} + + {% debug post.body %} + +.. caution:: + + The ``debug`` tag only works when the ``debug`` environment option is set + to ``true``. + +.. _`dump`: http://twig.sensiolabs.org/dump diff --git a/vendor/twig/extensions/doc/i18n.rst b/vendor/twig/extensions/doc/i18n.rst new file mode 100644 index 0000000..9b0227b --- /dev/null +++ b/vendor/twig/extensions/doc/i18n.rst @@ -0,0 +1,156 @@ +The i18n Extension +================== + +Configuration +------------- + +The ``i18n`` extension adds `gettext`_ support to Twig. It defines one tag, +``trans``. + +You need to register this extension before using the ``trans`` block:: + + $twig->addExtension(new Twig_Extensions_Extension_I18n()); + +Note that you must configure the ``gettext`` extension before rendering any +internationalized template. Here is a simple configuration example from the +PHP `documentation`_:: + + // Set language to French + putenv('LC_ALL=fr_FR'); + setlocale(LC_ALL, 'fr_FR'); + + // Specify the location of the translation tables + bindtextdomain('myAppPhp', 'includes/locale'); + bind_textdomain_codeset('myAppPhp', 'UTF-8'); + + // Choose domain + textdomain('myAppPhp'); + +.. caution:: + + The ``i18n`` extension only works if the PHP `gettext`_ extension is + enabled. + +Usage +----- + +Use the ``trans`` block to mark parts in the template as translatable: + +.. code-block:: jinja + + {% trans "Hello World!" %} + + {% trans string_var %} + + {% trans %} + Hello World! + {% endtrans %} + +In a translatable string, you can embed variables: + +.. code-block:: jinja + + {% trans %} + Hello {{ name }}! + {% endtrans %} + +During the gettext lookup these placeholders are converted. ``{{ name }}`` becomes ``%name%`` so the gettext ``msgid`` for this string would be ``Hello %name%!``. + +.. note:: + + ``{% trans "Hello {{ name }}!" %}`` is not a valid statement. + +If you need to apply filters to the variables, you first need to assign the +result to a variable: + +.. code-block:: jinja + + {% set name = name|capitalize %} + + {% trans %} + Hello {{ name }}! + {% endtrans %} + +To pluralize a translatable string, use the ``plural`` block: + +.. code-block:: jinja + + {% trans %} + Hey {{ name }}, I have one apple. + {% plural apple_count %} + Hey {{ name }}, I have {{ count }} apples. + {% endtrans %} + +The ``plural`` tag should provide the ``count`` used to select the right +string. Within the translatable string, the special ``count`` variable always +contain the count value (here the value of ``apple_count``). + +Within an expression or in a tag, you can use the ``trans`` filter to translate +simple strings or variables: + +.. code-block:: jinja + + {{ var|default(default_value|trans) }} + +Complex Translations within an Expression or Tag +------------------------------------------------ + +Translations can be done with both the ``trans`` tag and the ``trans`` filter. +The filter is less powerful as it only works for simple variables or strings. +For more complex scenario, like pluralization, you can use a two-step +strategy: + +.. code-block:: jinja + + {# assign the translation to a temporary variable #} + {% set default_value %} + {% trans %} + Hey {{ name }}, I have one apple. + {% plural apple_count %} + Hey {{ name }}, I have {{ count }} apples. + {% endtrans %} + {% endset %} + + {# use the temporary variable within an expression #} + {{ var|default(default_value|trans) }} + +Extracting Template Strings +--------------------------- + +If you use the Twig I18n extension, you will probably need to extract the +template strings at some point. Unfortunately, the ``xgettext`` utility does +not understand Twig templates natively. But there is a simple workaround: as +Twig converts templates to PHP files, you can use ``xgettext`` on the template +cache instead. + +Create a script that forces the generation of the cache for all your +templates. Here is a simple example to get you started:: + + $tplDir = dirname(__FILE__).'/templates'; + $tmpDir = '/tmp/cache/'; + $loader = new Twig_Loader_Filesystem($tplDir); + + // force auto-reload to always have the latest version of the template + $twig = new Twig_Environment($loader, array( + 'cache' => $tmpDir, + 'auto_reload' => true + )); + $twig->addExtension(new Twig_Extensions_Extension_I18n()); + // configure Twig the way you want + + // iterate over all your templates + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tplDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) + { + // force compilation + $twig->loadTemplate(str_replace($tplDir.'/', '', $file)); + } + +Use the standard ``xgettext`` utility as you would have done with plain PHP +code: + +.. code-block:: text + + xgettext --default-domain=messages -p ./locale --from-code=UTF-8 -n --omit-header -L PHP /tmp/cache/*.php + +.. _`gettext`: http://www.php.net/gettext +.. _`documentation`: http://fr.php.net/manual/en/function.gettext.php diff --git a/vendor/twig/extensions/doc/index.rst b/vendor/twig/extensions/doc/index.rst new file mode 100644 index 0000000..0ccd8f4 --- /dev/null +++ b/vendor/twig/extensions/doc/index.rst @@ -0,0 +1,18 @@ +Twig Extensions +=============== + +.. toctree:: + :hidden: + + debug + text + i18n + +The Twig Extensions repository provides several useful extensions for Twig: + +* :doc:`Debug `: Provides tags and filters to ease template debugging; + +* :doc:`Text `: Provides useful filters for text manipulation; + +* :doc:`I18n `: Adds internationalization support via the ``gettext`` + library. diff --git a/vendor/twig/extensions/doc/text.rst b/vendor/twig/extensions/doc/text.rst new file mode 100644 index 0000000..ee96a5f --- /dev/null +++ b/vendor/twig/extensions/doc/text.rst @@ -0,0 +1,8 @@ +The Text Extension +================== + +The Text extensions provides the following filters: + +* ``truncate`` +* ``wordwrap`` +* ``nl2br`` diff --git a/vendor/twig/extensions/phpunit.xml.dist b/vendor/twig/extensions/phpunit.xml.dist new file mode 100644 index 0000000..2c38c3d --- /dev/null +++ b/vendor/twig/extensions/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + + ./test/Twig/ + + + + + + ./lib/Twig/ + + + + + + + + diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/ArgumentsTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/ArgumentsTest.php new file mode 100644 index 0000000..a6ee612 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/ArgumentsTest.php @@ -0,0 +1,19 @@ +assertEquals('', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/ArrayTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/ArrayTest.php new file mode 100644 index 0000000..66f7a6a --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/ArrayTest.php @@ -0,0 +1,19 @@ +assertEquals('', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/BodyTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/BodyTest.php new file mode 100644 index 0000000..6ba5a9c --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/BodyTest.php @@ -0,0 +1,19 @@ +assertEquals('', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/BooleanTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/BooleanTest.php new file mode 100644 index 0000000..4894d51 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/BooleanTest.php @@ -0,0 +1,19 @@ +assertEquals('', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/ConstantTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/ConstantTest.php new file mode 100644 index 0000000..d5d89b1 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/ConstantTest.php @@ -0,0 +1,19 @@ +assertEquals('foo', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/ExpressionTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/ExpressionTest.php new file mode 100644 index 0000000..5323a21 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/ExpressionTest.php @@ -0,0 +1,19 @@ +assertEquals('', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/NumberTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/NumberTest.php new file mode 100644 index 0000000..a803904 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/NumberTest.php @@ -0,0 +1,19 @@ +assertEquals('', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/OptionalTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/OptionalTest.php new file mode 100644 index 0000000..704c294 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/OptionalTest.php @@ -0,0 +1,19 @@ +assertEquals('[foo ]', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Grammar/TagTest.php b/vendor/twig/extensions/test/Twig/Tests/Grammar/TagTest.php new file mode 100644 index 0000000..3254d1b --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Grammar/TagTest.php @@ -0,0 +1,23 @@ +assertEquals('foo [foo ]', (string) $grammar); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Node/DebugTest.php b/vendor/twig/extensions/test/Twig/Tests/Node/DebugTest.php new file mode 100644 index 0000000..9fd03ef --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Node/DebugTest.php @@ -0,0 +1,67 @@ +assertEquals($expr, $node->getNode('expr')); + + $node = new Twig_Extensions_Node_Debug(null, 0); + $this->assertEquals(null, $node->getNode('expr')); + } + + /** + * @covers Twig_Node_Debug::compile + * @dataProvider getTests + */ + public function testCompile($node, $source, $environment = null) + { + parent::testCompile($node, $source, $environment); + } + + public function getTests() + { + $tests = array(); + + $tests[] = array(new Twig_Extensions_Node_Debug(null, 0), <<env->isDebug()) { + \$vars = array(); + foreach (\$context as \$key => \$value) { + if (!\$value instanceof Twig_Template) { + \$vars[\$key] = \$value; + } + } + var_dump(\$vars); +} +EOF + ); + + $expr = new Twig_Node_Expression_Name('foo', 0); + $node = new Twig_Extensions_Node_Debug($expr, 0); + + $tests[] = array($node, sprintf(<<env->isDebug()) { + var_dump(%s); +} +EOF + , $this->getVariableGetter('foo'))); + + return $tests; + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/Node/TransTest.php b/vendor/twig/extensions/test/Twig/Tests/Node/TransTest.php new file mode 100644 index 0000000..7009dec --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/Node/TransTest.php @@ -0,0 +1,93 @@ +assertEquals($body, $node->getNode('body')); + $this->assertEquals($count, $node->getNode('count')); + $this->assertEquals($plural, $node->getNode('plural')); + } + + public function getTests() + { + $tests = array(); + + $body = new Twig_Node_Expression_Name('foo', 0); + $node = new Twig_Extensions_Node_Trans($body, null, null, 0); + $tests[] = array($node, sprintf('echo gettext(%s);', $this->getVariableGetter('foo'))); + + $body = new Twig_Node_Expression_Constant('Hello', 0); + $node = new Twig_Extensions_Node_Trans($body, null, null, 0); + $tests[] = array($node, 'echo gettext("Hello");'); + + $body = new Twig_Node(array( + new Twig_Node_Text('Hello', 0), + ), array(), 0); + $node = new Twig_Extensions_Node_Trans($body, null, null, 0); + $tests[] = array($node, 'echo gettext("Hello");'); + + $body = new Twig_Node(array( + new Twig_Node_Text('J\'ai ', 0), + new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0), + new Twig_Node_Text(' pommes', 0), + ), array(), 0); + $node = new Twig_Extensions_Node_Trans($body, null, null, 0); + $tests[] = array($node, sprintf('echo strtr(gettext("J\'ai %%foo%% pommes"), array("%%foo%%" => %s, ));', $this->getVariableGetter('foo'))); + + $count = new Twig_Node_Expression_Constant(12, 0); + $body = new Twig_Node(array( + new Twig_Node_Text('Hey ', 0), + new Twig_Node_Print(new Twig_Node_Expression_Name('name', 0), 0), + new Twig_Node_Text(', I have one apple', 0), + ), array(), 0); + $plural = new Twig_Node(array( + new Twig_Node_Text('Hey ', 0), + new Twig_Node_Print(new Twig_Node_Expression_Name('name', 0), 0), + new Twig_Node_Text(', I have ', 0), + new Twig_Node_Print(new Twig_Node_Expression_Name('count', 0), 0), + new Twig_Node_Text(' apples', 0), + ), array(), 0); + $node = new Twig_Extensions_Node_Trans($body, $plural, $count, 0); + $tests[] = array($node, sprintf('echo strtr(ngettext("Hey %%name%%, I have one apple", "Hey %%name%%, I have %%count%% apples", abs(12)), array("%%name%%" => %s, "%%name%%" => %s, "%%count%%" => abs(12), ));', $this->getVariableGetter('name'), $this->getVariableGetter('name'))); + + // with escaper extension set to on + $body = new Twig_Node(array( + new Twig_Node_Text('J\'ai ', 0), + new Twig_Node_Print(new Twig_Node_Expression_Filter(new Twig_Node_Expression_Name('foo', 0), new Twig_Node_Expression_Constant('escape', 0), new Twig_Node(), 0), 0), + new Twig_Node_Text(' pommes', 0), + ), array(), 0); + + $node = new Twig_Extensions_Node_Trans($body, null, null, 0); + $tests[] = array($node, sprintf('echo strtr(gettext("J\'ai %%foo%% pommes"), array("%%foo%%" => %s, ));', $this->getVariableGetter('foo'))); + + return $tests; + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/SimpleTokenParser.php b/vendor/twig/extensions/test/Twig/Tests/SimpleTokenParser.php new file mode 100644 index 0000000..245aae1 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/SimpleTokenParser.php @@ -0,0 +1,48 @@ +tag = $tag; + $this->grammar = $grammar; + } + + public function getGrammar() + { + return $this->grammar; + } + + public function getTag() + { + return $this->tag; + } + + public function getNode(array $values, $line) + { + $nodes = array(); + $nodes[] = new Twig_Node_Print(new Twig_Node_Expression_Constant('|', $line), $line); + foreach ($values as $value) { + if ($value instanceof Twig_NodeInterface) { + $nodes[] = new Twig_Node_Print($value, $line); + } else { + $nodes[] = new Twig_Node_Print(new Twig_Node_Expression_Constant($value, $line), $line); + } + $nodes[] = new Twig_Node_Print(new Twig_Node_Expression_Constant('|', $line), $line); + } + + return new Twig_Node($nodes); + } +} \ No newline at end of file diff --git a/vendor/twig/extensions/test/Twig/Tests/SimpleTokenParserTest.php b/vendor/twig/extensions/test/Twig/Tests/SimpleTokenParserTest.php new file mode 100644 index 0000000..60f8358 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/SimpleTokenParserTest.php @@ -0,0 +1,112 @@ +assertEquals($grammar, Twig_Extensions_SimpleTokenParser::parseGrammar($str), '::parseGrammar() parses a grammar'); + } + + public function testParseGrammarExceptions() + { + try { + Twig_Extensions_SimpleTokenParser::parseGrammar(''); + $this->fail(); + } catch (Exception $e) { + $this->assertEquals('Twig_Error_Runtime', get_class($e)); + } + + try { + Twig_Extensions_SimpleTokenParser::parseGrammar('fail(); + } catch (Exception $e) { + $this->assertEquals('Twig_Error_Runtime', get_class($e)); + } + + try { + Twig_Extensions_SimpleTokenParser::parseGrammar(' (with'); + $this->fail(); + } catch (Exception $e) { + $this->assertEquals('Twig_Error_Runtime', get_class($e)); + } + } + + public function getTests() + { + return array( + array('', new Twig_Extensions_Grammar_Tag()), + array('const', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Constant('const') + )), + array(' const ', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Constant('const') + )), + array('', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Expression('expr') + )), + array('', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Expression('expr') + )), + array(' ', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Expression('expr') + )), + array('', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Number('nb') + )), + array('', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Boolean('bool') + )), + array('', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Body('content') + )), + array(' [with ]', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Expression('expr'), + new Twig_Extensions_Grammar_Optional( + new Twig_Extensions_Grammar_Constant('with'), + new Twig_Extensions_Grammar_Array('arguments') + ) + )), + array(' [ with ] ', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Expression('expr'), + new Twig_Extensions_Grammar_Optional( + new Twig_Extensions_Grammar_Constant('with'), + new Twig_Extensions_Grammar_Array('arguments') + ) + )), + array(' [with [or ]]', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Expression('expr'), + new Twig_Extensions_Grammar_Optional( + new Twig_Extensions_Grammar_Constant('with'), + new Twig_Extensions_Grammar_Array('arguments'), + new Twig_Extensions_Grammar_Optional( + new Twig_Extensions_Grammar_Constant('or'), + new Twig_Extensions_Grammar_Expression('optional') + ) + ) + )), + array(' [with [, ]]', new Twig_Extensions_Grammar_Tag( + new Twig_Extensions_Grammar_Expression('expr'), + new Twig_Extensions_Grammar_Optional( + new Twig_Extensions_Grammar_Constant('with'), + new Twig_Extensions_Grammar_Array('arguments'), + new Twig_Extensions_Grammar_Optional( + new Twig_Extensions_Grammar_Constant(',', Twig_Token::PUNCTUATION_TYPE), + new Twig_Extensions_Grammar_Expression('optional') + ) + ) + )), + ); + } +} diff --git a/vendor/twig/extensions/test/Twig/Tests/grammarTest.php b/vendor/twig/extensions/test/Twig/Tests/grammarTest.php new file mode 100644 index 0000000..0a63d13 --- /dev/null +++ b/vendor/twig/extensions/test/Twig/Tests/grammarTest.php @@ -0,0 +1,63 @@ + false)); + $twig->addTokenParser(new SimpleTokenParser($tag, $grammar)); + + $ok = true; + try { + $template = $twig->loadTemplate($template); + } catch (Exception $e) { + $ok = false; + + if (false === $exception) { + $this->fail('Exception not expected'); + } else { + $this->assertEquals($exception, get_class($e)); + } + } + + if ($ok) { + if (false !== $exception) { + $this->fail(sprintf('Exception "%s" expected', $exception)); + } + + $actual = $template->render(array()); + $this->assertEquals($output, $actual); + } + } + + public function getTests() + { + return array( + array('foo1', '', '{% foo1 %}', '|', false), + array('foo2', '', '{% foo2 "bar" %}', '|', 'Twig_Error_Syntax'), + array('foo3', '', '{% foo3 "bar" %}', '|bar|', false), + array('foo4', '', '{% foo4 1 + 2 %}', '|3|', false), + array('foo5', '', '{% foo5 1 + 2 %}', '|3|', false), + array('foo6', '', '{% foo6 1 + 2 %}', '|3|', 'Twig_Error_Syntax'), + array('foo7', '', '{% foo7 %}', '|3|', 'Twig_Error_Syntax'), + array('foo8', '', '{% foo8 [1, 2] %}', '|Array|', false), + array('foo9', ' with ', '{% foo9 "bar" with "foobar" %}', '|bar|with|foobar|', false), + array('foo10', ' [with ]', '{% foo10 "bar" with "foobar" %}', '|bar|with|foobar|', false), + array('foo11', ' [with ]', '{% foo11 "bar" %}', '|bar|', false), + ); + } +} diff --git a/vendor/twig/extensions/test/bootstrap.php b/vendor/twig/extensions/test/bootstrap.php new file mode 100644 index 0000000..fba42fc --- /dev/null +++ b/vendor/twig/extensions/test/bootstrap.php @@ -0,0 +1,20 @@ +