Explorar el Código

Mse a jour / réinstallation des Bundles vendors (et ajout du bundle FOSUsers)

bastien hace 12 años
padre
commit
8a750ddc65
Se han modificado 100 ficheros con 9442 adiciones y 22 borrados
  1. 36 0
      app/logs/dev.log
  2. 4 0
      deps
  3. 59 0
      deps~
  4. 1 0
      vendor/assetic/.gitignore
  5. 1 0
      vendor/bundles/FOS/UserBundle
  6. BIN
      vendor/bundles/Sensio/Bundle/DistributionBundle/.DS_Store
  7. BIN
      vendor/bundles/Sensio/Bundle/DistributionBundle/Configurator/.DS_Store
  8. BIN
      vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/.DS_Store
  9. BIN
      vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/public/.DS_Store
  10. BIN
      vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/views/.DS_Store
  11. 0 22
      vendor/bundles/Sensio/Bundle/DistributionBundle/TODO.txt
  12. 1 0
      vendor/bundles/Symfony/Bundle/AsseticBundle/.gitignore
  13. 5 0
      vendor/doctrine-common/.gitignore
  14. 14 0
      vendor/doctrine-common/build.properties.dev
  15. 160 0
      vendor/doctrine-common/build.xml
  16. 3 0
      vendor/doctrine-common/tests/.gitignore
  17. 378 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php
  18. 13 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php
  19. 56 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php
  20. 27 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php
  21. 389 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
  22. 26 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php
  23. 11 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Autoload.php
  24. 9 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Route.php
  25. 17 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Secure.php
  26. 13 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php
  27. 300 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php
  28. 9 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/MultipleClassesInFile.php
  29. 10 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/MultipleImportsInUseStatement.php
  30. 10 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/NonNamespacedClass.php
  31. 13 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php
  32. 160 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php
  33. 60 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php
  34. 258 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Regression/BCAnnotationReaderTest.php
  35. 66 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php
  36. 7 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php
  37. 20 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php
  38. 13 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php
  39. 93 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/CacheTest.php
  40. 30 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php
  41. 20 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php
  42. 41 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php
  43. 45 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest.php
  44. 6 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php
  45. 6 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassB.class.php
  46. 6 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassC.class.php
  47. 5 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassD.php
  48. 195 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php
  49. 0 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php
  50. 88 0
      vendor/doctrine-common/tests/Doctrine/Tests/Common/EventManagerTest.php
  51. 10 0
      vendor/doctrine-common/tests/Doctrine/Tests/DoctrineTestCase.php
  52. 27 0
      vendor/doctrine-common/tests/Doctrine/Tests/TestInit.php
  53. 246 0
      vendor/doctrine-common/tests/NativePhpunitTask.php
  54. 27 0
      vendor/doctrine-common/tests/README.markdown
  55. 7 0
      vendor/doctrine-dbal/.gitignore
  56. 6 0
      vendor/doctrine-dbal/.gitmodules
  57. 4 0
      vendor/doctrine-dbal/bin/doctrine-dbal
  58. 43 0
      vendor/doctrine-dbal/bin/doctrine-dbal.php
  59. 42 0
      vendor/doctrine-dbal/bin/doctrine.php
  60. 16 0
      vendor/doctrine-dbal/build.properties.dev
  61. 203 0
      vendor/doctrine-dbal/build.xml
  62. 3 0
      vendor/doctrine-dbal/tests/.gitignore
  63. 142 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php
  64. 117 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
  65. 33 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
  66. 33 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
  67. 210 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
  68. 272 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
  69. 54 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php
  70. 110 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php
  71. 90 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
  72. 12 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
  73. 12 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/MsSqlSchemaManagerTest.php
  74. 50 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
  75. 39 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
  76. 173 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
  77. 525 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
  78. 60 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
  79. 94 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
  80. 134 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
  81. 41 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
  82. 218 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
  83. 175 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
  84. 207 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
  85. 207 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
  86. 219 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
  87. 47 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php
  88. 129 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
  89. 82 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php
  90. 201 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
  91. 551 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
  92. 119 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
  93. 107 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
  94. 714 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
  95. 84 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
  96. 67 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
  97. 109 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
  98. 211 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
  99. 476 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
  100. 0 0
      vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php

+ 36 - 0
app/logs/dev.log Ver fichero

@@ -2613,3 +2613,39 @@
2613 2613
 [2011-09-07 18:23:33] doctrine.DEBUG: CREATE TABLE element (id INT NOT NULL, element_type_id VARCHAR(12) DEFAULT NULL, url VARCHAR(1024) NOT NULL, name VARCHAR(128) NOT NULL, date_added TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id)) ([]) [] []
2614 2614
 [2011-09-07 18:23:34] doctrine.DEBUG: CREATE INDEX IDX_41405E3932A7CCC7 ON element (element_type_id) ([]) [] []
2615 2615
 [2011-09-07 18:23:34] doctrine.DEBUG: ALTER TABLE element ADD CONSTRAINT FK_41405E3932A7CCC7 FOREIGN KEY (element_type_id) REFERENCES element_type(id) NOT DEFERRABLE INITIALLY IMMEDIATE ([]) [] []
2616
+[2011-09-08 08:53:00] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\RouterListener::onEarlyKernelRequest". [] []
2617
+[2011-09-08 08:53:00] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
2618
+[2011-09-08 08:53:00] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
2619
+[2011-09-08 08:53:00] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\RouterListener::onKernelRequest". [] []
2620
+[2011-09-08 08:53:07] request.INFO: Matched route "index" (parameters: "_controller": "Muzich\IndexBundle\Controller\IndexController::indexAction", "_route": "index") [] []
2621
+[2011-09-08 08:53:07] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". [] []
2622
+[2011-09-08 08:53:07] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector::onKernelController". [] []
2623
+[2011-09-08 08:53:07] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". [] []
2624
+[2011-09-08 08:53:07] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". [] []
2625
+[2011-09-08 08:53:07] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". [] []
2626
+[2011-09-08 08:53:07] event.DEBUG: Notified event "kernel.controller" to listener "Acme\DemoBundle\ControllerListener::onKernelController". [] []
2627
+[2011-09-08 08:53:07] event.DEBUG: Notified event "kernel.controller" to listener "JMS\SecurityExtraBundle\Controller\ControllerListener::onCoreController". [] []
2628
+[2011-09-08 08:53:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] []
2629
+[2011-09-08 08:53:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\SecurityBundle\EventListener\ResponseListener::onKernelResponse". [] []
2630
+[2011-09-08 08:53:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] []
2631
+[2011-09-08 08:53:08] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] []
2632
+[2011-09-08 08:53:08] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] []
2633
+[2011-09-08 08:53:10] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] []
2634
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\RouterListener::onEarlyKernelRequest". [] []
2635
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] []
2636
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest". [] []
2637
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\RouterListener::onKernelRequest". [] []
2638
+[2011-09-08 08:53:12] request.INFO: Matched route "_wdt" (parameters: "_controller": "Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController::toolbarAction", "token": "4e68746492229", "_route": "_wdt") [] []
2639
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest". [] []
2640
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector::onKernelController". [] []
2641
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController". [] []
2642
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController". [] []
2643
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController". [] []
2644
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.controller" to listener "Acme\DemoBundle\ControllerListener::onKernelController". [] []
2645
+[2011-09-08 08:53:12] event.DEBUG: Notified event "kernel.controller" to listener "JMS\SecurityExtraBundle\Controller\ControllerListener::onCoreController". [] []
2646
+[2011-09-08 08:53:13] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ResponseListener::onKernelResponse". [] []
2647
+[2011-09-08 08:53:13] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\SecurityBundle\EventListener\ResponseListener::onKernelResponse". [] []
2648
+[2011-09-08 08:53:13] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bridge\Monolog\Handler\FirePHPHandler::onKernelResponse". [] []
2649
+[2011-09-08 08:53:13] event.DEBUG: Notified event "kernel.response" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\CacheListener::onKernelResponse". [] []
2650
+[2011-09-08 08:53:13] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelResponse". [] []
2651
+[2011-09-08 08:53:13] event.DEBUG: Notified event "kernel.response" to listener "Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::onKernelResponse". [] []

+ 4 - 0
deps Ver fichero

@@ -57,3 +57,7 @@
57 57
     git=http://github.com/symfony/AsseticBundle.git
58 58
     target=/bundles/Symfony/Bundle/AsseticBundle
59 59
     version=v1.0.0
60
+
61
+[FOSUserBundle]
62
+    git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
63
+    target=bundles/FOS/UserBundle

+ 59 - 0
deps~ Ver fichero

@@ -0,0 +1,59 @@
1
+[symfony]
2
+    git=http://github.com/symfony/symfony.git
3
+    version=v2.0.1
4
+
5
+[twig]
6
+    git=http://github.com/fabpot/Twig.git
7
+    version=v1.1.2
8
+
9
+[monolog]
10
+    git=http://github.com/Seldaek/monolog.git
11
+    version=1.0.1
12
+
13
+[doctrine-common]
14
+    git=http://github.com/doctrine/common.git
15
+    version=2.1.1
16
+
17
+[doctrine-dbal]
18
+    git=http://github.com/doctrine/dbal.git
19
+    version=2.1.1
20
+
21
+[doctrine]
22
+    git=http://github.com/doctrine/doctrine2.git
23
+    version=2.1.1
24
+
25
+[swiftmailer]
26
+    git=http://github.com/swiftmailer/swiftmailer.git
27
+    version=v4.1.1
28
+
29
+[assetic]
30
+    git=http://github.com/kriswallsmith/assetic.git
31
+    version=v1.0.1
32
+
33
+[twig-extensions]
34
+    git=http://github.com/fabpot/Twig-extensions.git
35
+
36
+[metadata]
37
+    git=http://github.com/schmittjoh/metadata.git
38
+    version=1.0.0
39
+
40
+[SensioFrameworkExtraBundle]
41
+    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
42
+    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
43
+
44
+[JMSSecurityExtraBundle]
45
+    git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
46
+    target=/bundles/JMS/SecurityExtraBundle
47
+
48
+[SensioDistributionBundle]
49
+    git=http://github.com/sensio/SensioDistributionBundle.git
50
+    target=/bundles/Sensio/Bundle/DistributionBundle
51
+
52
+[SensioGeneratorBundle]
53
+    git=http://github.com/sensio/SensioGeneratorBundle.git
54
+    target=/bundles/Sensio/Bundle/GeneratorBundle
55
+
56
+[AsseticBundle]
57
+    git=http://github.com/symfony/AsseticBundle.git
58
+    target=/bundles/Symfony/Bundle/AsseticBundle
59
+    version=v1.0.0

+ 1 - 0
vendor/assetic/.gitignore Ver fichero

@@ -0,0 +1 @@
1
+phpunit.xml

+ 1 - 0
vendor/bundles/FOS/UserBundle

@@ -0,0 +1 @@
1
+Subproject commit ce316132d0701fd96cac7df3b1998be0d4986ac7

BIN
vendor/bundles/Sensio/Bundle/DistributionBundle/.DS_Store Ver fichero


BIN
vendor/bundles/Sensio/Bundle/DistributionBundle/Configurator/.DS_Store Ver fichero


BIN
vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/.DS_Store Ver fichero


BIN
vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/public/.DS_Store Ver fichero


BIN
vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/views/.DS_Store Ver fichero


+ 0 - 22
vendor/bundles/Sensio/Bundle/DistributionBundle/TODO.txt Ver fichero

@@ -1,22 +0,0 @@
1
-* Create a command that can be run when a project code has been updated on
2
-  the production servers:
3
-
4
-    ./build_bootstrap.php (à inclure dans cache:clear)
5
-    cache:clear --env=prod --without-debug
6
-    assets:install --env=prod web/
7
-    assetic:dump --env=prod web/
8
-
9
-    On ne pourrait la mettre que dans Symfony SE sauf si on la configure
10
-    quelque part:
11
-
12
-    ./app/console project:prepare
13
-    ./app/console project:update --env=prod
14
-
15
-* faire une commande upgrade pour Symfony SE (mettre à jour le build_bootstrap pour la RC1 -> performance win)
16
-
17
-* add a command that installs a list pre-defined bundles
18
-  this list is hosted somewhere under symfony.com, retrieved, cached
19
-  and propose a one-click install (via Git or download?)
20
-
21
-* Add a CLI to send feedback to the Symfony server -> the resulting anonymous
22
-  database is free to access for everyone?

+ 1 - 0
vendor/bundles/Symfony/Bundle/AsseticBundle/.gitignore Ver fichero

@@ -0,0 +1 @@
1
+phpunit.xml

+ 5 - 0
vendor/doctrine-common/.gitignore Ver fichero

@@ -0,0 +1,5 @@
1
+build.properties
2
+build/
3
+logs/
4
+reports/
5
+dist/

+ 14 - 0
vendor/doctrine-common/build.properties.dev Ver fichero

@@ -0,0 +1,14 @@
1
+version=2.0.0BETA2
2
+stability=beta
3
+build.dir=build
4
+dist.dir=dist
5
+report.dir=reports
6
+log.archive.dir=logs
7
+svn.path=/usr/bin/svn
8
+test.phpunit_configuration_file=
9
+test.phpunit_generate_coverage=0
10
+test.pmd_reports=0
11
+test.pdepend_exec=
12
+test.phpmd_exec=
13
+project.pirum_dir=
14
+project.download_dir=

+ 160 - 0
vendor/doctrine-common/build.xml Ver fichero

@@ -0,0 +1,160 @@
1
+<?xml version="1.0"?>
2
+
3
+<!--
4
+    Doctrine 2 build file.
5
+-->
6
+
7
+<project name="Doctrine2" default="build" basedir=".">
8
+    <taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" />
9
+
10
+    <property file="build.properties" />
11
+    
12
+    <!-- 
13
+        Fileset for artifacts shared across all distributed packages.
14
+    -->
15
+    <fileset id="shared-artifacts" dir=".">
16
+        <include name="LICENSE"/>
17
+        <include name="COPYRIGHT"/>
18
+        <include name="CHANGELOG"/>
19
+    </fileset>
20
+
21
+    <!-- 
22
+        Fileset for the sources of the Doctrine Common package.
23
+    -->
24
+    <fileset id="common-sources" dir="./lib">
25
+        <include name="Doctrine/Common/**"/>
26
+    </fileset>
27
+
28
+    <!--
29
+        Clean the directory for the next build.
30
+    -->
31
+    <target name="clean">
32
+        <available file="./build.properties" property="build_properties_exist" value="true"/>
33
+        <fail unless="build_properties_exist" message="The build.properties file is missing." />
34
+
35
+        <delete dir="${build.dir}" includeemptydirs="true" />
36
+        <delete dir="${dist.dir}" includeemptydirs="true" />
37
+        <delete dir="${report.dir}" includeemptydirs="true" />
38
+    </target>
39
+
40
+    <!--
41
+        Prepare the new build directories after cleaning
42
+    -->
43
+    <target name="prepare" depends="clean">
44
+        <echo msg="Creating build directory: ${build.dir}" />
45
+        <mkdir dir="${build.dir}" />
46
+        <echo msg="Creating distribution directory: ${dist.dir}" />
47
+        <mkdir dir="${dist.dir}" />
48
+        <echo msg="Creating report directory: ${report.dir}" />
49
+        <mkdir dir="${report.dir}" />
50
+        <mkdir dir="${build.dir}/logs"/>
51
+        <mkdir dir="${report.dir}/tests"/>
52
+    </target>
53
+
54
+    <!--
55
+        Builds Common package, preparing it for distribution.
56
+    -->
57
+    <target name="build-common">
58
+        <copy todir="${build.dir}/common">
59
+            <fileset refid="shared-artifacts"/>
60
+        </copy>
61
+        <copy todir="${build.dir}/common">
62
+            <fileset refid="common-sources"/>
63
+        </copy>
64
+    </target>
65
+
66
+    <target name="build" depends="prepare,build-common"/>
67
+    
68
+    <!-- 
69
+        Runs the full test suite.
70
+    -->
71
+    <target name="test" depends="prepare">
72
+        <if><equals arg1="${test.phpunit_generate_coverage}" arg2="1" />
73
+            <then>
74
+                <property name="test.phpunit_coverage_file" value="${build.dir}/logs/clover.xml" />
75
+            </then>
76
+            <else>
77
+                <property name="test.phpunit_coverage_file" value="false" />
78
+            </else>
79
+        </if>
80
+
81
+        <nativephpunit
82
+            testfile="./tests/Doctrine/Tests/AllTests.php" junitlogfile="${build.dir}/logs/testsuites.xml"
83
+            testdirectory="./tests"  coverageclover="${test.phpunit_coverage_file}" configuration="${test.phpunit_configuration_file}"
84
+        />
85
+        <phpunitreport infile="${build.dir}/logs/testsuites.xml" format="frames" todir="${report.dir}/tests" />
86
+
87
+        <tstamp/>
88
+        <copy file="${build.dir}/logs/testsuites.xml" tofile="${log.archive.dir}/latest/log.xml" overwrite="true"/>
89
+
90
+        <if><equals arg1="${test.pmd_reports}" arg2="1" />
91
+            <then>
92
+                <exec command="${test.pdepend_exec} --jdepend-xml=${build.dir}/logs/jdepend.xml ./lib/Doctrine" />
93
+                <exec command="${test.phpmd_exec} ./lib/Doctrine xml codesize --reportfile ${build.dir}/logs/phpmd.xml" />
94
+
95
+                <copy file="${build.dir}/logs/jdepend.xml" tofile="${log.archive.dir}/latest/jdepend.xml" overwrite="true"/>
96
+                <copy file="${build.dir}/logs/phpmd.xml" tofile="${log.archive.dir}/latest/phpmd.xml" overwrite="true"/>
97
+            </then>
98
+        </if>
99
+    </target>
100
+
101
+    <!-- 
102
+        Builds distributable PEAR packages.
103
+    -->
104
+    <target name="build-packages" depends="build">
105
+        <d51pearpkg2 baseinstalldir="/" dir="${build.dir}/common">
106
+           <name>DoctrineCommon</name>
107
+           <summary>Doctrine Common PHP Extensions</summary>
108
+           <channel>pear.doctrine-project.org</channel>
109
+           <description>The Doctrine Common package contains shared code between the other packages.</description>
110
+           <lead user="jwage" name="Jonathan H. Wage" email="jonwage@gmail.com" />
111
+           <lead user="guilhermeblanco" name="Guilherme Blanco" email="guilhermeblanco@gmail.com" />
112
+           <lead user="romanb" name="Roman Borschel" email="roman@code-factory.org" />
113
+           <lead user="beberlei" name="Benjamin Eberlei" email="kontakt@beberlei.de" />
114
+           <license>LGPL</license>
115
+           <version release="${version}" api="${version}" />
116
+           <stability release="${stability}" api="${stability}" />
117
+           <notes>-</notes>
118
+           <dependencies>
119
+               <php minimum_version="5.3.0" />
120
+               <pear minimum_version="1.6.0" recommended_version="1.6.1" />
121
+           </dependencies>
122
+        </d51pearpkg2>
123
+        <exec command="pear package" dir="${build.dir}/common" passthru="true" />
124
+        <exec command="mv DoctrineCommon-${version}.tgz ../../dist" dir="${build.dir}/common" passthru="true" />
125
+        <tar destfile="dist/DoctrineCommon-${version}-full.tar.gz" compression="gzip" basedir="${build.dir}">
126
+            <fileset dir="${build.dir}">
127
+                <include name="**/**" />
128
+                <exclude name="logs/" />
129
+            </fileset>
130
+        </tar>
131
+    </target>
132
+
133
+    <target name="git-tag">
134
+        <exec command="grep '${version}-DEV' ${project.basedir}/lib/Doctrine/Common/Version.php" checkreturn="true"/>
135
+        <exec command="sed 's/${version}-DEV/${version}/' ${project.basedir}/lib/Doctrine/Common/Version.php > ${project.basedir}/lib/Doctrine/Common/Version2.php" passthru="true" />
136
+        <exec command="mv ${project.basedir}/lib/Doctrine/Common/Version2.php ${project.basedir}/lib/Doctrine/Common/Version.php" passthru="true" />
137
+        <exec command="git commit -a -m 'Release ${version}'" />
138
+        <exec command="git tag -m 'Tag ${version}' -a ${version}" passthru="true" />
139
+    </target>
140
+
141
+    <target name="pirum-release">
142
+        <exec command="sudo pirum add ${project.pirum_dir} ${project.basedir}/dist/DoctrineCommon-${version}.tgz" dir="."  passthru="true" />
143
+        <exec command="sudo pirum build ${project.pirum_dir}" passthru="true" />
144
+    </target>
145
+
146
+    <target name="distribute-download">
147
+        <copy file="dist/DoctrineCommon-${version}-full.tar.gz" todir="${project.download_dir}" />
148
+    </target>
149
+
150
+    <target name="update-dev-version">
151
+        <exec command="grep '${version}' ${project.basedir}/lib/Doctrine/Common/Version.php" checkreturn="true"/>
152
+        <propertyprompt propertyName="next_version" defaultValue="${version}" promptText="Enter next version string (without -DEV)" />
153
+        <exec command="sed 's/${version}/${next_version}-DEV/' ${project.basedir}/lib/Doctrine/Common/Version.php > ${project.basedir}/lib/Doctrine/Common/Version2.php" passthru="true" />
154
+        <exec command="mv ${project.basedir}/lib/Doctrine/Common/Version2.php ${project.basedir}/lib/Doctrine/Common/Version.php" passthru="true" />
155
+        <exec command="git add ${project.basedir}/lib/Doctrine/Common/Version.php" passthru="true" />
156
+        <exec command="git commit -m 'Bump Dev Version to ${next_version}'" passthru="true" />
157
+    </target>
158
+
159
+    <target name="release" depends="git-tag,build-packages,distribute-download,pirum-release,update-dev-version" />
160
+</project>

+ 3 - 0
vendor/doctrine-common/tests/.gitignore Ver fichero

@@ -0,0 +1,3 @@
1
+Doctrine/Tests/Proxies/
2
+Doctrine/Tests/ORM/Proxy/generated/
3
+Doctrine/Tests/ORM/Tools/Export/export

+ 378 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php Ver fichero

@@ -0,0 +1,378 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Common\Annotations\DoctrineReader;
6
+use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
7
+use Doctrine\Common\Annotations\Annotation\IgnorePhpDoc;
8
+use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader;
9
+
10
+use Doctrine\Tests\Common\Annotations\DummyAnnotation;
11
+use Doctrine\Tests\Common\Annotations\Name;
12
+use Doctrine\Tests\Common\Annotations\DummyId;
13
+use Doctrine\Tests\Common\Annotations\DummyJoinTable;
14
+use Doctrine\Tests\Common\Annotations\DummyJoinColumn;
15
+use Doctrine\Tests\Common\Annotations\DummyColumn;
16
+use Doctrine\Tests\Common\Annotations\DummyGeneratedValue;
17
+
18
+require_once __DIR__ . '/TopLevelAnnotation.php';
19
+
20
+abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase
21
+{
22
+    public function testAnnotations()
23
+    {
24
+        $reader = $this->getReader();
25
+
26
+        $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClass');
27
+        $this->assertEquals(1, count($reader->getClassAnnotations($class)));
28
+        $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName));
29
+        $this->assertEquals("hello", $annot->dummyValue);
30
+
31
+        $field1Prop = $class->getProperty('field1');
32
+        $propAnnots = $reader->getPropertyAnnotations($field1Prop);
33
+        $this->assertEquals(1, count($propAnnots));
34
+        $this->assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName));
35
+        $this->assertEquals("fieldHello", $annot->dummyValue);
36
+
37
+        $getField1Method = $class->getMethod('getField1');
38
+        $methodAnnots = $reader->getMethodAnnotations($getField1Method);
39
+        $this->assertEquals(1, count($methodAnnots));
40
+        $this->assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName));
41
+        $this->assertEquals(array(1, 2, "three"), $annot->value);
42
+
43
+        $field2Prop = $class->getProperty('field2');
44
+        $propAnnots = $reader->getPropertyAnnotations($field2Prop);
45
+        $this->assertEquals(1, count($propAnnots));
46
+        $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyJoinTable', $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName));
47
+        $this->assertEquals(1, count($joinTableAnnot->joinColumns));
48
+        $this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
49
+        $this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn);
50
+        $this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn);
51
+        $this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
52
+        $this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
53
+        $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
54
+        $this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
55
+
56
+        $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
57
+        $this->assertEquals('', $dummyAnnot->dummyValue);
58
+        $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value);
59
+
60
+        $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
61
+        $this->assertEquals('fieldHello', $dummyAnnot->dummyValue);
62
+
63
+        $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
64
+        $this->assertEquals('hello', $classAnnot->dummyValue);
65
+    }
66
+
67
+    /**
68
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
69
+     * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in class Doctrine\Tests\Common\Annotations\DummyClassSyntaxError.
70
+     */
71
+    public function testClassSyntaxErrorContext()
72
+    {
73
+        $reader = $this->getReader();
74
+        $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassSyntaxError'));
75
+    }
76
+
77
+    /**
78
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
79
+     * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in method Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError::foo().
80
+     */
81
+    public function testMethodSyntaxErrorContext()
82
+    {
83
+        $reader = $this->getReader();
84
+        $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError', 'foo'));
85
+    }
86
+
87
+    /**
88
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
89
+     * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in property Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError::$foo.
90
+     */
91
+    public function testPropertySyntaxErrorContext()
92
+    {
93
+        $reader = $this->getReader();
94
+        $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError', 'foo'));
95
+    }
96
+
97
+    /**
98
+     * @group regression
99
+     */
100
+    public function testMultipleAnnotationsOnSameLine()
101
+    {
102
+        $reader = $this->getReader();
103
+        $annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id'));
104
+        $this->assertEquals(3, count($annots));
105
+    }
106
+
107
+    public function testNonAnnotationProblem()
108
+    {
109
+        $reader = $this->getReader();
110
+
111
+        $this->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassNonAnnotationProblem', 'foo'), $name = 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
112
+        $this->assertType($name, $annot);
113
+    }
114
+
115
+    public function testImportWithConcreteAnnotation()
116
+    {
117
+        $reader = $this->getReader();
118
+        $property = new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestImportWithConcreteAnnotation', 'field');
119
+        $annotations = $reader->getPropertyAnnotations($property);
120
+        $this->assertEquals(1, count($annotations));
121
+        $this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
122
+    }
123
+
124
+    public function testImportWithInheritance()
125
+    {
126
+        $reader = $this->getReader();
127
+
128
+        $class = new TestParentClass();
129
+        $ref = new \ReflectionClass($class);
130
+
131
+        $childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child'));
132
+        $this->assertEquals(1, count($childAnnotations));
133
+        $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations));
134
+
135
+        $parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent'));
136
+        $this->assertEquals(1, count($parentAnnotations));
137
+        $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations));
138
+    }
139
+
140
+    /**
141
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
142
+     * @expectedExceptionMessage The annotation "@NameFoo" in property Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass::$field was never imported.
143
+     */
144
+    public function testImportDetectsNotImportedAnnotation()
145
+    {
146
+        $reader = $this->getReader();
147
+        $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass', 'field'));
148
+    }
149
+
150
+    /**
151
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
152
+     * @expectedExceptionMessage The annotation "@Foo\Bar\Name" in property Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass::$field was never imported.
153
+     */
154
+    public function testImportDetectsNonExistentAnnotation()
155
+    {
156
+        $reader = $this->getReader();
157
+        $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass', 'field'));
158
+    }
159
+
160
+    public function testTopLevelAnnotation()
161
+    {
162
+        $reader = $this->getReader();
163
+        $annotations = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestTopLevelAnnotationClass', 'field'));
164
+
165
+        $this->assertEquals(1, count($annotations));
166
+        $this->assertInstanceOf('\TopLevelAnnotation', reset($annotations));
167
+    }
168
+
169
+    public function testIgnoresAnnotationsNotPrefixedWithWhitespace()
170
+    {
171
+        $reader = $this->getReader();
172
+
173
+        $annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), 'Doctrine\Tests\Common\Annotations\Name');
174
+        $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annotation);
175
+    }
176
+
177
+    abstract protected function getReader();
178
+}
179
+
180
+/**
181
+ * @parseAnnotation("var")
182
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
183
+ *
184
+ */
185
+class TestParseAnnotationClass
186
+{
187
+    /**
188
+     * @var
189
+     */
190
+    private $field;
191
+}
192
+
193
+/**
194
+ * @Name
195
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
196
+ */
197
+class TestIgnoresNonAnnotationsClass
198
+{
199
+}
200
+
201
+class TestTopLevelAnnotationClass
202
+{
203
+    /**
204
+     * @\TopLevelAnnotation
205
+     */
206
+    private $field;
207
+}
208
+
209
+class TestNonExistentAnnotationClass
210
+{
211
+    /**
212
+     * @Foo\Bar\Name
213
+     */
214
+    private $field;
215
+}
216
+
217
+class TestAnnotationNotImportedClass
218
+{
219
+    /**
220
+     * @NameFoo
221
+     */
222
+    private $field;
223
+}
224
+
225
+class TestChildClass
226
+{
227
+    /**
228
+     * @\Doctrine\Tests\Common\Annotations\Foo\Name(name = "foo")
229
+     */
230
+    protected $child;
231
+}
232
+
233
+class TestParentClass extends TestChildClass
234
+{
235
+    /**
236
+     * @\Doctrine\Tests\Common\Annotations\Bar\Name(name = "bar")
237
+     */
238
+    private $parent;
239
+}
240
+
241
+class TestImportWithConcreteAnnotation
242
+{
243
+    /**
244
+     * @DummyAnnotation(dummyValue = "bar")
245
+     */
246
+    private $field;
247
+}
248
+
249
+/**
250
+ * A description of this class.
251
+ *
252
+ * Let's see if the parser recognizes that this @ is not really referring to an
253
+ * annotation. Also make sure that @var \ is not concated to "@var\is".
254
+ *
255
+ * @author robo
256
+ * @since 2.0
257
+ * @DummyAnnotation(dummyValue="hello")
258
+ */
259
+class DummyClass {
260
+    /**
261
+     * A nice property.
262
+     *
263
+     * @var mixed
264
+     * @DummyAnnotation(dummyValue="fieldHello")
265
+     */
266
+    private $field1;
267
+
268
+    /**
269
+     * @DummyJoinTable(name="join_table",
270
+     *      joinColumns={@DummyJoinColumn(name="col1", referencedColumnName="col2")},
271
+     *      inverseJoinColumns={
272
+     *          @DummyJoinColumn(name="col3", referencedColumnName="col4")
273
+     *      })
274
+     */
275
+    private $field2;
276
+
277
+    /**
278
+     * Gets the value of field1.
279
+     *
280
+     * @return mixed
281
+     * @DummyAnnotation({1,2,"three"})
282
+     */
283
+    public function getField1() {
284
+    }
285
+}
286
+
287
+/**
288
+ * @ignoreAnnotation("var")
289
+ */
290
+class DummyClass2 {
291
+    /**
292
+     * @DummyId @DummyColumn(type="integer") @DummyGeneratedValue
293
+     * @var integer
294
+     */
295
+    private $id;
296
+}
297
+
298
+class DummyId extends \Doctrine\Common\Annotations\Annotation {}
299
+class DummyColumn extends \Doctrine\Common\Annotations\Annotation {
300
+    public $type;
301
+}
302
+class DummyGeneratedValue extends \Doctrine\Common\Annotations\Annotation {}
303
+class DummyAnnotation extends \Doctrine\Common\Annotations\Annotation {
304
+    public $dummyValue;
305
+}
306
+class DummyJoinColumn extends \Doctrine\Common\Annotations\Annotation {
307
+    public $name;
308
+    public $referencedColumnName;
309
+}
310
+class DummyJoinTable extends \Doctrine\Common\Annotations\Annotation {
311
+    public $name;
312
+    public $joinColumns;
313
+    public $inverseJoinColumns;
314
+}
315
+
316
+/**
317
+ * @DummyAnnotation(@)
318
+ */
319
+class DummyClassSyntaxError
320
+{
321
+
322
+}
323
+
324
+class DummyClassMethodSyntaxError
325
+{
326
+    /**
327
+     * @DummyAnnotation(@)
328
+     */
329
+    public function foo()
330
+    {
331
+
332
+    }
333
+}
334
+
335
+class DummyClassPropertySyntaxError
336
+{
337
+    /**
338
+     * @DummyAnnotation(@)
339
+     */
340
+    public $foo;
341
+}
342
+
343
+/**
344
+ * @ignoreAnnotation({"since", "var"})
345
+ */
346
+class DummyClassNonAnnotationProblem
347
+{
348
+    /**
349
+     * @DummyAnnotation
350
+     *
351
+     * @var \Test
352
+     * @since 0.1
353
+     */
354
+    public $foo;
355
+}
356
+
357
+
358
+/**
359
+* @DummyAnnotation Foo bar <foobar@1domain.com>
360
+*/
361
+class DummyClassWithEmail
362
+{
363
+    
364
+}
365
+
366
+namespace Doctrine\Tests\Common\Annotations\Foo;
367
+
368
+class Name extends \Doctrine\Common\Annotations\Annotation
369
+{
370
+    public $name;
371
+}
372
+
373
+namespace Doctrine\Tests\Common\Annotations\Bar;
374
+
375
+class Name extends \Doctrine\Common\Annotations\Annotation
376
+{
377
+    public $name;
378
+}

+ 13 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php Ver fichero

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Common\Annotations\AnnotationReader;
6
+
7
+class AnnotationReaderTest extends AbstractReaderTest
8
+{
9
+    protected function getReader()
10
+    {
11
+        return new AnnotationReader();
12
+    }
13
+}

+ 56 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php Ver fichero

@@ -0,0 +1,56 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
6
+use Doctrine\Common\Annotations\AnnotationReader;
7
+use Doctrine\Common\Annotations\CachedReader;
8
+use Doctrine\Common\Cache\ArrayCache;
9
+
10
+class CachedReaderTest extends AbstractReaderTest
11
+{
12
+    private $cache;
13
+
14
+    public function testIgnoresStaleCache()
15
+    {
16
+        $file = __DIR__.'/Fixtures/Controller.php';
17
+        touch($file);
18
+        $name = 'Doctrine\Tests\Common\Annotations\Fixtures\Controller';
19
+        $cacheKey = $name.'@[Annot]';
20
+
21
+        $cache = $this->getMock('Doctrine\Common\Cache\Cache');
22
+        $cache
23
+            ->expects($this->at(0))
24
+            ->method('fetch')
25
+            ->with($this->equalTo($cacheKey))
26
+            ->will($this->returnValue(array()))
27
+        ;
28
+        $cache
29
+            ->expects($this->at(1))
30
+            ->method('fetch')
31
+            ->with($this->equalTo('[C]'.$cacheKey))
32
+            ->will($this->returnValue(time() - 10))
33
+        ;
34
+        $cache
35
+            ->expects($this->at(2))
36
+            ->method('save')
37
+            ->with($this->equalTo($cacheKey))
38
+        ;
39
+        $cache
40
+            ->expects($this->at(3))
41
+            ->method('save')
42
+            ->with($this->equalTo('[C]'.$cacheKey))
43
+        ;
44
+
45
+        $reader = new CachedReader(new AnnotationReader(), $cache, true);
46
+        $this->assertEquals(array(
47
+            new Route(array('value' => '/someprefix')),
48
+        ), $reader->getClassAnnotations(new \ReflectionClass($name)));
49
+    }
50
+
51
+    protected function getReader()
52
+    {
53
+        $this->cache = new ArrayCache();
54
+        return new CachedReader(new AnnotationReader(), $this->cache);
55
+    }
56
+}

+ 27 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php Ver fichero

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Common\Annotations\DocLexer;
6
+
7
+class DocLexerTest extends \PHPUnit_Framework_TestCase
8
+{
9
+    public function testMarkerAnnotation()
10
+    {
11
+        $lexer = new DocLexer;
12
+
13
+        $lexer->setInput("@Name");
14
+        $this->assertNull($lexer->token);
15
+        $this->assertNull($lexer->lookahead);
16
+
17
+        $this->assertTrue($lexer->moveNext());
18
+        $this->assertNull($lexer->token);
19
+        $this->assertEquals('@', $lexer->lookahead['value']);
20
+
21
+        $this->assertTrue($lexer->moveNext());
22
+        $this->assertEquals('@', $lexer->token['value']);
23
+        $this->assertEquals('Name', $lexer->lookahead['value']);
24
+
25
+        $this->assertFalse($lexer->moveNext());
26
+    }
27
+}

+ 389 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php Ver fichero

@@ -0,0 +1,389 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Common\Annotations\Annotation\IgnorePhpDoc;
6
+use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
7
+use Doctrine\Common\Annotations\DocParser;
8
+use Doctrine\Common\Annotations\AnnotationRegistry;
9
+
10
+class DocParserTest extends \PHPUnit_Framework_TestCase
11
+{
12
+    public function testNestedArraysWithNestedAnnotation()
13
+    {
14
+        $parser = $this->createTestParser();
15
+
16
+        // Nested arrays with nested annotations
17
+        $result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})');
18
+        $annot = $result[0];
19
+
20
+        $this->assertTrue($annot instanceof Name);
21
+        $this->assertNull($annot->value);
22
+        $this->assertEquals(3, count($annot->foo));
23
+        $this->assertEquals(1, $annot->foo[0]);
24
+        $this->assertEquals(2, $annot->foo[1]);
25
+        $this->assertTrue(is_array($annot->foo[2]));
26
+
27
+        $nestedArray = $annot->foo[2];
28
+        $this->assertTrue(isset($nestedArray['key']));
29
+        $this->assertTrue($nestedArray['key'] instanceof Name);
30
+    }
31
+
32
+    public function testBasicAnnotations()
33
+    {
34
+        $parser = $this->createTestParser();
35
+
36
+        // Marker annotation
37
+        $result = $parser->parse("@Name");
38
+        $annot = $result[0];
39
+        $this->assertTrue($annot instanceof Name);
40
+        $this->assertNull($annot->value);
41
+        $this->assertNull($annot->foo);
42
+
43
+        // Associative arrays
44
+        $result = $parser->parse('@Name(foo={"key1" = "value1"})');
45
+        $annot = $result[0];
46
+        $this->assertNull($annot->value);
47
+        $this->assertTrue(is_array($annot->foo));
48
+        $this->assertTrue(isset($annot->foo['key1']));
49
+
50
+        // Numerical arrays
51
+        $result = $parser->parse('@Name({2="foo", 4="bar"})');
52
+        $annot = $result[0];
53
+        $this->assertTrue(is_array($annot->value));
54
+        $this->assertEquals('foo', $annot->value[2]);
55
+        $this->assertEquals('bar', $annot->value[4]);
56
+        $this->assertFalse(isset($annot->value[0]));
57
+        $this->assertFalse(isset($annot->value[1]));
58
+        $this->assertFalse(isset($annot->value[3]));
59
+
60
+        // Multiple values
61
+        $result = $parser->parse('@Name(@Name, @Name)');
62
+        $annot = $result[0];
63
+
64
+        $this->assertTrue($annot instanceof Name);
65
+        $this->assertTrue(is_array($annot->value));
66
+        $this->assertTrue($annot->value[0] instanceof Name);
67
+        $this->assertTrue($annot->value[1] instanceof Name);
68
+
69
+        // Multiple types as values
70
+        $result = $parser->parse('@Name(foo="Bar", @Name, {"key1"="value1", "key2"="value2"})');
71
+        $annot = $result[0];
72
+
73
+        $this->assertTrue($annot instanceof Name);
74
+        $this->assertTrue(is_array($annot->value));
75
+        $this->assertTrue($annot->value[0] instanceof Name);
76
+        $this->assertTrue(is_array($annot->value[1]));
77
+        $this->assertEquals('value1', $annot->value[1]['key1']);
78
+        $this->assertEquals('value2', $annot->value[1]['key2']);
79
+
80
+        // Complete docblock
81
+        $docblock = <<<DOCBLOCK
82
+/**
83
+ * Some nifty class.
84
+ *
85
+ * @author Mr.X
86
+ * @Name(foo="bar")
87
+ */
88
+DOCBLOCK;
89
+
90
+        $result = $parser->parse($docblock);
91
+        $this->assertEquals(1, count($result));
92
+        $annot = $result[0];
93
+        $this->assertTrue($annot instanceof Name);
94
+        $this->assertEquals("bar", $annot->foo);
95
+        $this->assertNull($annot->value);
96
+   }
97
+
98
+    public function testNamespacedAnnotations()
99
+    {
100
+        $parser = new DocParser;
101
+        $parser->setIgnoreNotImportedAnnotations(true);
102
+
103
+        $docblock = <<<DOCBLOCK
104
+/**
105
+ * Some nifty class.
106
+ *
107
+ * @package foo
108
+ * @subpackage bar
109
+ * @author Mr.X <mr@x.com>
110
+ * @Doctrine\Tests\Common\Annotations\Name(foo="bar")
111
+ * @ignore
112
+ */
113
+DOCBLOCK;
114
+
115
+        $result = $parser->parse($docblock);
116
+        $this->assertEquals(1, count($result));
117
+        $annot = $result[0];
118
+        $this->assertTrue($annot instanceof Name);
119
+        $this->assertEquals("bar", $annot->foo);
120
+    }
121
+
122
+    /**
123
+     * @group debug
124
+     */
125
+    public function testTypicalMethodDocBlock()
126
+    {
127
+        $parser = $this->createTestParser();
128
+
129
+        $docblock = <<<DOCBLOCK
130
+/**
131
+ * Some nifty method.
132
+ *
133
+ * @since 2.0
134
+ * @Doctrine\Tests\Common\Annotations\Name(foo="bar")
135
+ * @param string \$foo This is foo.
136
+ * @param mixed \$bar This is bar.
137
+ * @return string Foo and bar.
138
+ * @This is irrelevant
139
+ * @Marker
140
+ */
141
+DOCBLOCK;
142
+
143
+        $result = $parser->parse($docblock);
144
+        $this->assertEquals(2, count($result));
145
+        $this->assertTrue(isset($result[0]));
146
+        $this->assertTrue(isset($result[1]));
147
+        $annot = $result[0];
148
+        $this->assertTrue($annot instanceof Name);
149
+        $this->assertEquals("bar", $annot->foo);
150
+        $marker = $result[1];
151
+        $this->assertTrue($marker instanceof Marker);
152
+    }
153
+
154
+    /**
155
+     * @group DDC-575
156
+     */
157
+    public function testRegressionDDC575()
158
+    {
159
+        $parser = $this->createTestParser();
160
+
161
+        $docblock = <<<DOCBLOCK
162
+/**
163
+ * @Name
164
+ *
165
+ * Will trigger error.
166
+ */
167
+DOCBLOCK;
168
+
169
+        $result = $parser->parse($docblock);
170
+
171
+        $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]);
172
+
173
+        $docblock = <<<DOCBLOCK
174
+/**
175
+ * @Name
176
+ * @Marker
177
+ *
178
+ * Will trigger error.
179
+ */
180
+DOCBLOCK;
181
+
182
+        $result = $parser->parse($docblock);
183
+
184
+        $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]);
185
+    }
186
+
187
+    /**
188
+     * @group DDC-77
189
+     */
190
+    public function testAnnotationWithoutClassIsIgnoredWithoutWarning()
191
+    {
192
+        $parser = new DocParser();
193
+        $parser->setIgnoreNotImportedAnnotations(true);
194
+        $result = $parser->parse("@param");
195
+
196
+        $this->assertEquals(0, count($result));
197
+    }
198
+
199
+    /**
200
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
201
+     * @expectedExceptionMessage Expected PlainValue, got ''' at position 10.
202
+     */
203
+    public function testAnnotationDontAcceptSingleQuotes()
204
+    {
205
+        $parser = $this->createTestParser();
206
+        $parser->parse("@Name(foo='bar')");
207
+    }
208
+
209
+    /**
210
+     * @group DCOM-41
211
+     */
212
+    public function testAnnotationDoesntThrowExceptionWhenAtSignIsNotFollowedByIdentifier()
213
+    {
214
+        $parser = new DocParser();
215
+        $result = $parser->parse("'@'");
216
+
217
+        $this->assertEquals(0, count($result));
218
+    }
219
+
220
+    /**
221
+     * @group DCOM-41
222
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
223
+     */
224
+    public function testAnnotationThrowsExceptionWhenAtSignIsNotFollowedByIdentifierInNestedAnnotation()
225
+    {
226
+        $parser = new DocParser();
227
+        $result = $parser->parse("@Doctrine\Tests\Common\Annotations\Name(@')");
228
+    }
229
+    
230
+    /**
231
+     * @group DCOM-56
232
+     */
233
+    public function testAutoloadAnnotation()
234
+    {
235
+        $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.');
236
+        
237
+        $parser = new DocParser();
238
+        
239
+        AnnotationRegistry::registerAutoloadNamespace('Doctrine\Tests\Common\Annotations\Fixtures\Annotation', __DIR__ . '/../../../../');
240
+        
241
+        $parser->setImports(array(
242
+            'autoload' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload',
243
+        ));
244
+        $annotations = $parser->parse('@Autoload');
245
+        
246
+        $this->assertEquals(1, count($annotations));
247
+        $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]);
248
+    }
249
+
250
+    public function createTestParser()
251
+    {
252
+        $parser = new DocParser();
253
+        $parser->setIgnoreNotImportedAnnotations(true);
254
+        $parser->setImports(array(
255
+            'name' => 'Doctrine\Tests\Common\Annotations\Name',
256
+            '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations',
257
+        ));
258
+
259
+        return $parser;
260
+    }
261
+
262
+    /**
263
+     * @group DDC-78
264
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
265
+     * @expectedExceptionMessage Expected PlainValue, got ''' at position 10 in class \Doctrine\Tests\Common\Annotations\Name
266
+     */
267
+    public function testSyntaxErrorWithContextDescription()
268
+    {
269
+        $parser = $this->createTestParser();
270
+        $parser->parse("@Name(foo='bar')", "class \Doctrine\Tests\Common\Annotations\Name");
271
+    }
272
+
273
+    /**
274
+     * @group DDC-183
275
+     */
276
+    public function testSyntaxErrorWithUnknownCharacters()
277
+    {
278
+        $docblock = <<<DOCBLOCK
279
+/**
280
+ * @test at.
281
+ */
282
+class A {
283
+}
284
+DOCBLOCK;
285
+
286
+        //$lexer = new \Doctrine\Common\Annotations\Lexer();
287
+        //$lexer->setInput(trim($docblock, '/ *'));
288
+        //var_dump($lexer);
289
+
290
+        try {
291
+            $parser = $this->createTestParser();
292
+            $result = $parser->parse($docblock);
293
+        } catch (Exception $e) {
294
+            $this->fail($e->getMessage());
295
+        }
296
+    }
297
+
298
+    /**
299
+     * @group DCOM-14
300
+     */
301
+    public function testIgnorePHPDocThrowTag()
302
+    {
303
+        $docblock = <<<DOCBLOCK
304
+/**
305
+ * @throws \RuntimeException
306
+ */
307
+class A {
308
+}
309
+DOCBLOCK;
310
+
311
+        try {
312
+            $parser = $this->createTestParser();
313
+            $result = $parser->parse($docblock);
314
+        } catch (Exception $e) {
315
+            $this->fail($e->getMessage());
316
+        }
317
+    }
318
+
319
+    /**
320
+     * @group DCOM-38
321
+     */
322
+    public function testCastInt()
323
+    {
324
+        $parser = $this->createTestParser();
325
+
326
+        $result = $parser->parse("@Name(foo=1234)");
327
+        $annot = $result[0];
328
+        $this->assertInternalType('int', $annot->foo);
329
+    }
330
+
331
+    /**
332
+     * @group DCOM-38
333
+     */
334
+    public function testCastFloat()
335
+    {
336
+        $parser = $this->createTestParser();
337
+
338
+        $result = $parser->parse("@Name(foo=1234.345)");
339
+        $annot = $result[0];
340
+        $this->assertInternalType('float', $annot->foo);
341
+    }
342
+
343
+    public function testReservedKeywordsInAnnotations()
344
+    {
345
+        $parser = $this->createTestParser();
346
+
347
+        $result = $parser->parse('@Doctrine\Tests\Common\Annotations\True');
348
+        $this->assertTrue($result[0] instanceof True);
349
+        $result = $parser->parse('@Doctrine\Tests\Common\Annotations\False');
350
+        $this->assertTrue($result[0] instanceof False);
351
+        $result = $parser->parse('@Doctrine\Tests\Common\Annotations\Null');
352
+        $this->assertTrue($result[0] instanceof Null);
353
+
354
+        $result = $parser->parse('@True');
355
+        $this->assertTrue($result[0] instanceof True);
356
+        $result = $parser->parse('@False');
357
+        $this->assertTrue($result[0] instanceof False);
358
+        $result = $parser->parse('@Null');
359
+        $this->assertTrue($result[0] instanceof Null);
360
+    }
361
+
362
+    /**
363
+     * @expectedException Doctrine\Common\Annotations\AnnotationException
364
+     * @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.
365
+     */
366
+    public function testInvalidIdentifierInAnnotation()
367
+    {
368
+        $parser = $this->createTestParser();
369
+
370
+        $result = $parser->parse('@Foo\3.42');
371
+    }
372
+}
373
+
374
+class Name extends \Doctrine\Common\Annotations\Annotation {
375
+    public $foo;
376
+}
377
+
378
+class Marker extends \Doctrine\Common\Annotations\Annotation {}
379
+
380
+class True extends \Doctrine\Common\Annotations\Annotation {}
381
+
382
+class False extends \Doctrine\Common\Annotations\Annotation {}
383
+
384
+class Null extends \Doctrine\Common\Annotations\Annotation {}
385
+
386
+namespace Doctrine\Tests\Common\Annotations\FooBar;
387
+
388
+class Name extends \Doctrine\Common\Annotations\Annotation {
389
+}

+ 26 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php Ver fichero

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Common\Annotations\AnnotationReader;
6
+use Doctrine\Common\Annotations\FileCacheReader;
7
+
8
+class FileCacheReaderTest extends AbstractReaderTest
9
+{
10
+    private $cacheDir;
11
+    
12
+    protected function getReader()
13
+    {
14
+        $this->cacheDir = sys_get_temp_dir() . "/annotations_". uniqid();
15
+        @mkdir($this->cacheDir);
16
+        return new FileCacheReader(new AnnotationReader(), $this->cacheDir);
17
+    }
18
+    
19
+    public function tearDown()
20
+    {
21
+        foreach (glob($this->cacheDir.'/*.php') AS $file) {
22
+            unlink($file);
23
+        }
24
+        rmdir($this->cacheDir);
25
+    }
26
+}

+ 11 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Autoload.php Ver fichero

@@ -0,0 +1,11 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
4
+
5
+/**
6
+ * @Annotation
7
+ */
8
+class Autoload extends \Doctrine\Common\Annotations\Annotation
9
+{
10
+    
11
+}

+ 9 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Route.php Ver fichero

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
4
+
5
+class Route extends \Doctrine\Common\Annotations\Annotation
6
+{
7
+    private $pattern;
8
+    private $name;
9
+}

+ 17 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Secure.php Ver fichero

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
4
+
5
+class Secure
6
+{
7
+    private $roles;
8
+
9
+    public function __construct(array $values)
10
+    {
11
+        if (is_string($values['value'])) {
12
+            $values['value'] = array($values['value']);
13
+        }
14
+
15
+        $this->roles = $values['value'];
16
+    }
17
+}

+ 13 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Annotation/Template.php Ver fichero

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures\Annotation;
4
+
5
+class Template
6
+{
7
+    private $name;
8
+
9
+    public function __construct(array $values)
10
+    {
11
+        $this->name = isset($values['value']) ? $values['value'] : null;
12
+    }
13
+}

+ 300 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php Ver fichero

@@ -0,0 +1,300 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
4
+
5
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
6
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
7
+
8
+/**
9
+ * @Route("/someprefix")
10
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
11
+ */
12
+class Controller
13
+{
14
+    /**
15
+     * @Route("/", name="_demo")
16
+     * @Template()
17
+     */
18
+    public function indexAction()
19
+    {
20
+        return array();
21
+    }
22
+
23
+    /**
24
+     * @Route("/hello/{name}", name="_demo_hello")
25
+     * @Template()
26
+     */
27
+    public function helloAction($name)
28
+    {
29
+        return array('name' => $name);
30
+    }
31
+
32
+    /**
33
+     * @Route("/contact", name="_demo_contact")
34
+     * @Template()
35
+     */
36
+    public function contactAction()
37
+    {
38
+        $form = ContactForm::create($this->get('form.context'), 'contact');
39
+
40
+        $form->bind($this->container->get('request'), $form);
41
+        if ($form->isValid()) {
42
+            $form->send($this->get('mailer'));
43
+
44
+            $this->get('session')->setFlash('notice', 'Message sent!');
45
+
46
+            return new RedirectResponse($this->generateUrl('_demo'));
47
+        }
48
+
49
+        return array('form' => $form);
50
+    }
51
+
52
+    /**
53
+     * Creates the ACL for the passed object identity
54
+     *
55
+     * @param ObjectIdentityInterface $oid
56
+     * @return void
57
+     */
58
+    private function createObjectIdentity(ObjectIdentityInterface $oid)
59
+    {
60
+        $classId = $this->createOrRetrieveClassId($oid->getType());
61
+
62
+        $this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true));
63
+    }
64
+
65
+    /**
66
+     * Returns the primary key for the passed class type.
67
+     *
68
+     * If the type does not yet exist in the database, it will be created.
69
+     *
70
+     * @param string $classType
71
+     * @return integer
72
+     */
73
+    private function createOrRetrieveClassId($classType)
74
+    {
75
+        if (false !== $id = $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn()) {
76
+            return $id;
77
+        }
78
+
79
+        $this->connection->executeQuery($this->getInsertClassSql($classType));
80
+
81
+        return $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn();
82
+    }
83
+
84
+    /**
85
+     * Returns the primary key for the passed security identity.
86
+     *
87
+     * If the security identity does not yet exist in the database, it will be
88
+     * created.
89
+     *
90
+     * @param SecurityIdentityInterface $sid
91
+     * @return integer
92
+     */
93
+    private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid)
94
+    {
95
+        if (false !== $id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn()) {
96
+            return $id;
97
+        }
98
+
99
+        $this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid));
100
+
101
+        return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn();
102
+    }
103
+
104
+    /**
105
+     * Deletes all ACEs for the given object identity primary key.
106
+     *
107
+     * @param integer $oidPK
108
+     * @return void
109
+     */
110
+    private function deleteAccessControlEntries($oidPK)
111
+    {
112
+        $this->connection->executeQuery($this->getDeleteAccessControlEntriesSql($oidPK));
113
+    }
114
+
115
+    /**
116
+     * Deletes the object identity from the database.
117
+     *
118
+     * @param integer $pk
119
+     * @return void
120
+     */
121
+    private function deleteObjectIdentity($pk)
122
+    {
123
+        $this->connection->executeQuery($this->getDeleteObjectIdentitySql($pk));
124
+    }
125
+
126
+    /**
127
+     * Deletes all entries from the relations table from the database.
128
+     *
129
+     * @param integer $pk
130
+     * @return void
131
+     */
132
+    private function deleteObjectIdentityRelations($pk)
133
+    {
134
+        $this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
135
+    }
136
+
137
+    /**
138
+     * This regenerates the ancestor table which is used for fast read access.
139
+     *
140
+     * @param AclInterface $acl
141
+     * @return void
142
+     */
143
+    private function regenerateAncestorRelations(AclInterface $acl)
144
+    {
145
+        $pk = $acl->getId();
146
+        $this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
147
+        $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
148
+
149
+        $parentAcl = $acl->getParentAcl();
150
+        while (null !== $parentAcl) {
151
+            $this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId()));
152
+
153
+            $parentAcl = $parentAcl->getParentAcl();
154
+        }
155
+    }
156
+
157
+    /**
158
+     * This processes changes on an ACE related property (classFieldAces, or objectFieldAces).
159
+     *
160
+     * @param string $name
161
+     * @param array $changes
162
+     * @return void
163
+     */
164
+    private function updateFieldAceProperty($name, array $changes)
165
+    {
166
+        $sids = new \SplObjectStorage();
167
+        $classIds = new \SplObjectStorage();
168
+        $currentIds = array();
169
+        foreach ($changes[1] as $field => $new) {
170
+            for ($i=0,$c=count($new); $i<$c; $i++) {
171
+                $ace = $new[$i];
172
+
173
+                if (null === $ace->getId()) {
174
+                    if ($sids->contains($ace->getSecurityIdentity())) {
175
+                        $sid = $sids->offsetGet($ace->getSecurityIdentity());
176
+                    } else {
177
+                        $sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
178
+                    }
179
+
180
+                    $oid = $ace->getAcl()->getObjectIdentity();
181
+                    if ($classIds->contains($oid)) {
182
+                        $classId = $classIds->offsetGet($oid);
183
+                    } else {
184
+                        $classId = $this->createOrRetrieveClassId($oid->getType());
185
+                    }
186
+
187
+                    $objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId();
188
+
189
+                    $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure()));
190
+                    $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))->fetchColumn();
191
+                    $this->loadedAces[$aceId] = $ace;
192
+
193
+                    $aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
194
+                    $aceIdProperty->setAccessible(true);
195
+                    $aceIdProperty->setValue($ace, intval($aceId));
196
+                } else {
197
+                    $currentIds[$ace->getId()] = true;
198
+                }
199
+            }
200
+        }
201
+
202
+        foreach ($changes[0] as $old) {
203
+            for ($i=0,$c=count($old); $i<$c; $i++) {
204
+                $ace = $old[$i];
205
+
206
+                if (!isset($currentIds[$ace->getId()])) {
207
+                    $this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
208
+                    unset($this->loadedAces[$ace->getId()]);
209
+                }
210
+            }
211
+        }
212
+    }
213
+
214
+    /**
215
+     * This processes changes on an ACE related property (classAces, or objectAces).
216
+     *
217
+     * @param string $name
218
+     * @param array $changes
219
+     * @return void
220
+     */
221
+    private function updateAceProperty($name, array $changes)
222
+    {
223
+        list($old, $new) = $changes;
224
+
225
+        $sids = new \SplObjectStorage();
226
+        $classIds = new \SplObjectStorage();
227
+        $currentIds = array();
228
+        for ($i=0,$c=count($new); $i<$c; $i++) {
229
+            $ace = $new[$i];
230
+
231
+            if (null === $ace->getId()) {
232
+                if ($sids->contains($ace->getSecurityIdentity())) {
233
+                    $sid = $sids->offsetGet($ace->getSecurityIdentity());
234
+                } else {
235
+                    $sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
236
+                }
237
+
238
+                $oid = $ace->getAcl()->getObjectIdentity();
239
+                if ($classIds->contains($oid)) {
240
+                    $classId = $classIds->offsetGet($oid);
241
+                } else {
242
+                    $classId = $this->createOrRetrieveClassId($oid->getType());
243
+                }
244
+
245
+                $objectIdentityId = $name === 'classAces' ? null : $ace->getAcl()->getId();
246
+
247
+                $this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, null, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure()));
248
+                $aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, null, $i))->fetchColumn();
249
+                $this->loadedAces[$aceId] = $ace;
250
+
251
+                $aceIdProperty = new \ReflectionProperty($ace, 'id');
252
+                $aceIdProperty->setAccessible(true);
253
+                $aceIdProperty->setValue($ace, intval($aceId));
254
+            } else {
255
+                $currentIds[$ace->getId()] = true;
256
+            }
257
+        }
258
+
259
+        for ($i=0,$c=count($old); $i<$c; $i++) {
260
+            $ace = $old[$i];
261
+
262
+            if (!isset($currentIds[$ace->getId()])) {
263
+                $this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
264
+                unset($this->loadedAces[$ace->getId()]);
265
+            }
266
+        }
267
+    }
268
+
269
+    /**
270
+     * Persists the changes which were made to ACEs to the database.
271
+     *
272
+     * @param \SplObjectStorage $aces
273
+     * @return void
274
+     */
275
+    private function updateAces(\SplObjectStorage $aces)
276
+    {
277
+        foreach ($aces as $ace) {
278
+            $propertyChanges = $aces->offsetGet($ace);
279
+            $sets = array();
280
+
281
+            if (isset($propertyChanges['mask'])) {
282
+                $sets[] = sprintf('mask = %d', $propertyChanges['mask'][1]);
283
+            }
284
+            if (isset($propertyChanges['strategy'])) {
285
+                $sets[] = sprintf('granting_strategy = %s', $this->connection->quote($propertyChanges['strategy']));
286
+            }
287
+            if (isset($propertyChanges['aceOrder'])) {
288
+                $sets[] = sprintf('ace_order = %d', $propertyChanges['aceOrder'][1]);
289
+            }
290
+            if (isset($propertyChanges['auditSuccess'])) {
291
+                $sets[] = sprintf('audit_success = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditSuccess'][1]));
292
+            }
293
+            if (isset($propertyChanges['auditFailure'])) {
294
+                $sets[] = sprintf('audit_failure = %s', $this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['auditFailure'][1]));
295
+            }
296
+
297
+            $this->connection->executeQuery($this->getUpdateAccessControlEntrySql($ace->getId(), $sets));
298
+        }
299
+    }
300
+}

+ 9 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/MultipleClassesInFile.php Ver fichero

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
4
+
5
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
6
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
7
+
8
+class AnotherClass { }
9
+class MultipleClassesInFile { }

+ 10 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/MultipleImportsInUseStatement.php Ver fichero

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
4
+
5
+use
6
+    Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route,
7
+    Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure
8
+;
9
+
10
+class MultipleImportsInUseStatement {}

+ 10 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/NonNamespacedClass.php Ver fichero

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template;
4
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route;
5
+
6
+/**
7
+ * @Route("foo")
8
+ * @Template
9
+ */
10
+class AnnotationsTestsFixturesNonNamespacedClass { }

+ 13 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php Ver fichero

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Fixtures;
4
+
5
+use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure;
6
+
7
+interface TestInterface
8
+{
9
+    /**
10
+     * @Secure
11
+     */
12
+    function foo();
13
+}

+ 160 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php Ver fichero

@@ -0,0 +1,160 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Common\Annotations\FileCacheReader;
6
+use Doctrine\Common\Cache\ArrayCache;
7
+use Doctrine\Common\Annotations\CachedReader;
8
+use Doctrine\Common\Annotations\DocLexer;
9
+use Doctrine\Common\Annotations\DocParser;
10
+use Doctrine\Common\Annotations\AnnotationReader;
11
+
12
+require_once __DIR__ . '/Fixtures/Annotation/Route.php';
13
+require_once __DIR__ . '/Fixtures/Annotation/Template.php';
14
+require_once __DIR__ . '/Fixtures/Annotation/Secure.php';
15
+
16
+class PerformanceTest extends \PHPUnit_Framework_TestCase
17
+{
18
+    /**
19
+     * @group performance
20
+     */
21
+    public function testCachedReadPerformanceWithInMemory()
22
+    {
23
+        $reader = new CachedReader(new AnnotationReader(), new ArrayCache());
24
+        $method = $this->getMethod();
25
+
26
+        $time = microtime(true);
27
+        for ($i=0,$c=500; $i<$c; $i++) {
28
+            $reader->getMethodAnnotations($method);
29
+        }
30
+        $time = microtime(true) - $time;
31
+
32
+        $this->printResults('cached reader (in-memory)', $time, $c);
33
+    }
34
+
35
+    /**
36
+     * @group performance
37
+     */
38
+    public function testCachedReadPerformanceWithFileCache()
39
+    {
40
+        $method = $this->getMethod();
41
+
42
+        // prime cache
43
+        $reader = new FileCacheReader(new AnnotationReader(), sys_get_temp_dir());
44
+        $reader->getMethodAnnotations($method);
45
+
46
+        $time = microtime(true);
47
+        for ($i=0,$c=500; $i<$c; $i++) {
48
+            $reader = new FileCacheReader(new AnnotationReader(), sys_get_temp_dir());
49
+            $reader->getMethodAnnotations($method);
50
+            clearstatcache();
51
+        }
52
+        $time = microtime(true) - $time;
53
+
54
+        $this->printResults('cached reader (file)', $time, $c);
55
+    }
56
+
57
+    /**
58
+     * @group performance
59
+     */
60
+    public function testReadPerformance()
61
+    {
62
+        $reader = new AnnotationReader();
63
+        $method = $this->getMethod();
64
+
65
+        $time = microtime(true);
66
+        for ($i=0,$c=150; $i<$c; $i++) {
67
+            $reader = new AnnotationReader();
68
+            $reader->getMethodAnnotations($method);
69
+        }
70
+        $time = microtime(true) - $time;
71
+
72
+        $this->printResults('reader', $time, $c);
73
+    }
74
+
75
+    /**
76
+     * @group performance
77
+     */
78
+    public function testDocParsePerformance()
79
+    {
80
+        $imports = array(
81
+            'ignorephpdoc'     => 'Annotations\Annotation\IgnorePhpDoc',
82
+            'ignoreannotation' => 'Annotations\Annotation\IgnoreAnnotation',
83
+            'route'            => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route',
84
+            'template'         => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template',
85
+            '__NAMESPACE__'    => 'Doctrine\Tests\Common\Annotations\Fixtures',
86
+        );
87
+        $ignored = array(
88
+            'access', 'author', 'copyright', 'deprecated', 'example', 'ignore',
89
+            'internal', 'link', 'see', 'since', 'tutorial', 'version', 'package',
90
+            'subpackage', 'name', 'global', 'param', 'return', 'staticvar',
91
+            'static', 'var', 'throws', 'inheritdoc',
92
+        );
93
+
94
+        $parser = new DocParser();
95
+        $method = $this->getMethod();
96
+        $methodComment = $method->getDocComment();
97
+        $classComment = $method->getDeclaringClass()->getDocComment();
98
+
99
+        $time = microtime(true);
100
+        for ($i=0,$c=200; $i<$c; $i++) {
101
+            $parser = new DocParser();
102
+            $parser->setImports($imports);
103
+            $parser->setIgnoredAnnotationNames($ignored);
104
+
105
+            $parser->parse($methodComment);
106
+            $parser->parse($classComment);
107
+        }
108
+        $time = microtime(true) - $time;
109
+
110
+        $this->printResults('doc-parser', $time, $c);
111
+    }
112
+
113
+    /**
114
+     * @group performance
115
+     */
116
+    public function testDocLexerPerformance()
117
+    {
118
+        $lexer = new DocLexer();
119
+        $method = $this->getMethod();
120
+        $methodComment = $method->getDocComment();
121
+        $classComment = $method->getDeclaringClass()->getDocComment();
122
+
123
+        $time = microtime(true);
124
+        for ($i=0,$c=500; $i<$c; $i++) {
125
+            $lexer = new DocLexer();
126
+            $lexer->setInput($methodComment);
127
+            $lexer->setInput($classComment);
128
+        }
129
+        $time = microtime(true) - $time;
130
+
131
+        $this->printResults('doc-lexer', $time, $c);
132
+    }
133
+
134
+    private function getMethod()
135
+    {
136
+        return new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\Controller', 'helloAction');
137
+    }
138
+
139
+    private function printResults($test, $time, $iterations)
140
+    {
141
+        if (0 == $iterations) {
142
+            throw new \InvalidArgumentException('$iterations cannot be zero.');
143
+        }
144
+
145
+        $title = $test." results:\n";
146
+        $iterationsText = sprintf("Iterations:         %d\n", $iterations);
147
+        $totalTime      = sprintf("Total Time:         %.3f s\n", $time);
148
+        $iterationTime  = sprintf("Time per iteration: %.3f ms\n", $time/$iterations * 1000);
149
+
150
+        $max = max(strlen($title), strlen($iterationTime)) - 1;
151
+
152
+        echo "\n".str_repeat('-', $max)."\n";
153
+        echo $title;
154
+        echo str_repeat('=', $max)."\n";
155
+        echo $iterationsText;
156
+        echo $totalTime;
157
+        echo $iterationTime;
158
+        echo str_repeat('-', $max)."\n";
159
+    }
160
+}

+ 60 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php Ver fichero

@@ -0,0 +1,60 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations;
4
+
5
+use Doctrine\Common\Annotations\PhpParser;
6
+
7
+require_once __DIR__.'/AnnotationReaderTest.php';
8
+require_once __DIR__.'/Fixtures/NonNamespacedClass.php';
9
+
10
+class PhpParserTest extends \PHPUnit_Framework_TestCase
11
+{
12
+    public function testParseClassWithMultipleClassesInFile()
13
+    {
14
+        $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\MultipleClassesInFile');
15
+        $parser = new PhpParser();
16
+
17
+        $this->assertEquals(array(
18
+            'route'  => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route',
19
+            'secure' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure',
20
+        ), $parser->parseClass($class));
21
+    }
22
+
23
+    public function testParseClassWithMultipleImportsInUseStatement()
24
+    {
25
+        $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\MultipleImportsInUseStatement');
26
+        $parser = new PhpParser();
27
+
28
+        $this->assertEquals(array(
29
+            'route'  => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route',
30
+            'secure' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure',
31
+        ), $parser->parseClass($class));
32
+    }
33
+
34
+    public function testParseClassWhenNotUserDefined()
35
+    {
36
+        $parser = new PhpParser();
37
+        $this->assertEquals(array(), $parser->parseClass(new \ReflectionClass('\stdClass')));
38
+    }
39
+
40
+    public function testParseClassWhenClassIsNotNamespaced()
41
+    {
42
+        $parser = new PhpParser();
43
+        $class = new \ReflectionClass('\AnnotationsTestsFixturesNonNamespacedClass');
44
+
45
+        $this->assertEquals(array(
46
+            'route'  => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route',
47
+            'template' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template',
48
+        ), $parser->parseClass($class));
49
+    }
50
+
51
+    public function testParseClassWhenClassIsInterface()
52
+    {
53
+        $parser = new PhpParser();
54
+        $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\TestInterface');
55
+
56
+        $this->assertEquals(array(
57
+            'secure' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Secure',
58
+        ), $parser->parseClass($class));
59
+    }
60
+}

+ 258 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Regression/BCAnnotationReaderTest.php Ver fichero

@@ -0,0 +1,258 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Regression;
4
+
5
+use ReflectionClass;
6
+use Doctrine\Common\Annotations\AnnotationReader;
7
+use Doctrine\Common\Annotations\IndexedReader;
8
+
9
+use Doctrine\Tests\Common\Annotations\DummyJoinTable;
10
+use Doctrine\Tests\Common\Annotations\DummyId;
11
+
12
+/**
13
+ * Important: This class needs a different namespace than Doctrine\Tests\Common\Annotations\
14
+ * to be able to really test the set default annotation namespace functionality.
15
+ */
16
+class BCAnnotationReaderTest extends \Doctrine\Tests\DoctrineTestCase
17
+{
18
+    public function testAnnotations()
19
+    {
20
+        $reader = $this->createAnnotationReader();
21
+    
22
+        $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Regression\DummyClass');
23
+        $classAnnots = $reader->getClassAnnotations($class);
24
+        
25
+        $annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation';
26
+        $this->assertEquals(1, count($classAnnots));
27
+        $this->assertTrue($classAnnots[$annotName] instanceof \Doctrine\Tests\Common\Annotations\DummyAnnotation); // no use!
28
+        $this->assertEquals("hello", $classAnnots[$annotName]->dummyValue);
29
+        
30
+        $field1Prop = $class->getProperty('field1');
31
+        $propAnnots = $reader->getPropertyAnnotations($field1Prop);
32
+        $this->assertEquals(1, count($propAnnots));
33
+        $this->assertTrue($propAnnots[$annotName] instanceof \Doctrine\Tests\Common\Annotations\DummyAnnotation); // no use!
34
+        $this->assertEquals("fieldHello", $propAnnots[$annotName]->dummyValue);
35
+        
36
+        $getField1Method = $class->getMethod('getField1');
37
+        $methodAnnots = $reader->getMethodAnnotations($getField1Method);
38
+        $this->assertEquals(1, count($methodAnnots));
39
+        $this->assertTrue($methodAnnots[$annotName] instanceof \Doctrine\Tests\Common\Annotations\DummyAnnotation); // no use!
40
+        $this->assertEquals(array(1, 2, "three"), $methodAnnots[$annotName]->value);
41
+        
42
+        $field2Prop = $class->getProperty('field2');
43
+        $propAnnots = $reader->getPropertyAnnotations($field2Prop);
44
+        $this->assertEquals(1, count($propAnnots));
45
+        $this->assertTrue(isset($propAnnots['Doctrine\Tests\Common\Annotations\DummyJoinTable']));
46
+        $joinTableAnnot = $propAnnots['Doctrine\Tests\Common\Annotations\DummyJoinTable'];
47
+        $this->assertEquals(1, count($joinTableAnnot->joinColumns));
48
+        $this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
49
+        $this->assertTrue($joinTableAnnot->joinColumns[0] instanceof \Doctrine\Tests\Common\Annotations\DummyJoinColumn); // no use!
50
+        $this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof \Doctrine\Tests\Common\Annotations\DummyJoinColumn); // no use!
51
+        $this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
52
+        $this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
53
+        $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
54
+        $this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
55
+
56
+        $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
57
+        $this->assertEquals('', $dummyAnnot->dummyValue);
58
+        $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value);
59
+
60
+        $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
61
+        $this->assertEquals('fieldHello', $dummyAnnot->dummyValue);
62
+
63
+        $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
64
+        $this->assertEquals('hello', $classAnnot->dummyValue);
65
+    }
66
+
67
+    /**
68
+     * @group regression
69
+     */
70
+    public function testMultipleAnnotationsOnSameLine()
71
+    {
72
+        $reader = $this->createAnnotationReader();
73
+        $class = new ReflectionClass('\Doctrine\Tests\Common\Annotations\Regression\DummyClass2');
74
+        $annotations = $reader->getPropertyAnnotations($class->getProperty('id'));
75
+        $this->assertEquals(3, count($annotations));
76
+    }
77
+
78
+    public function testCustomAnnotationCreationFunction()
79
+    {
80
+        $reader = $this->createAnnotationReader();
81
+        $reader->setAnnotationCreationFunction(function($name, $values) {
82
+            if ($name == 'Doctrine\Tests\Common\Annotations\DummyAnnotation') {
83
+                $a = new CustomDummyAnnotationClass;
84
+                $a->setDummyValue($values['dummyValue']);
85
+                return $a;
86
+            }
87
+        });
88
+
89
+        $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Regression\DummyClass');
90
+        $classAnnots = $reader->getClassAnnotations($class);
91
+        $this->assertTrue(isset($classAnnots['Doctrine\Tests\Common\Annotations\Regression\CustomDummyAnnotationClass']));
92
+        $annot = $classAnnots['Doctrine\Tests\Common\Annotations\Regression\CustomDummyAnnotationClass'];
93
+        $this->assertEquals('hello', $annot->getDummyValue());
94
+    }
95
+
96
+    public function testNonAnnotationProblem()
97
+    {
98
+        $reader = $this->createAnnotationReader();
99
+
100
+        $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Regression\DummyClassNonAnnotationProblem');
101
+        $annotations = $reader->getPropertyAnnotations($class->getProperty('foo'));
102
+        $this->assertArrayHasKey('Doctrine\Tests\Common\Annotations\DummyAnnotation', $annotations);
103
+        $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\DummyAnnotation', $annotations['Doctrine\Tests\Common\Annotations\DummyAnnotation']);
104
+    }
105
+
106
+    /**
107
+     * @return AnnotationReader
108
+     */
109
+    public function createAnnotationReader()
110
+    {
111
+        $reader = new IndexedReader(new AnnotationReader(new \Doctrine\Common\Cache\ArrayCache));
112
+        $reader->setDefaultAnnotationNamespace('Doctrine\Tests\Common\Annotations\\');
113
+        $reader->setEnableParsePhpImports(false);
114
+        return $reader;
115
+    }
116
+    
117
+    public function testEmailAsAnnotation()
118
+    {
119
+        $reader = new AnnotationReader(new \Doctrine\Common\Cache\ArrayCache);
120
+        $reader->setDefaultAnnotationNamespace('Doctrine\Tests\Common\Annotations\\');
121
+        
122
+        $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Regression\DummyClassWithEmail');
123
+        $classAnnots = $reader->getClassAnnotations($class);
124
+        
125
+        $this->assertEquals(1, count($classAnnots));
126
+    }
127
+    
128
+    public function testNamespaceAliasedAnnotations()
129
+    {
130
+        $reader = new IndexedReader(new AnnotationReader(new \Doctrine\Common\Cache\ArrayCache));
131
+        $reader->setAnnotationNamespaceAlias('Doctrine\Tests\Common\Annotations\\', 'alias');
132
+
133
+        $reflClass = new ReflectionClass('Doctrine\Tests\Common\Annotations\Regression\AliasNamespace');
134
+        
135
+        $result = $reader->getPropertyAnnotations($reflClass->getProperty('bar'));
136
+        $this->assertEquals(1, count($result));
137
+        $annot = $result['Doctrine\Tests\Common\Annotations\Name'];
138
+        $this->assertTrue($annot instanceof \Doctrine\Tests\Common\Annotations\Name); // no use!
139
+        $this->assertEquals('bar', $annot->foo);
140
+    }
141
+
142
+    /**
143
+     * @group DCOM-4
144
+     */
145
+    public function testNamespaceAliasAnnotationWithSeparator()
146
+    {
147
+        $reader = new IndexedReader(new AnnotationReader(new \Doctrine\Common\Cache\ArrayCache));
148
+        $reader->setAnnotationNamespaceAlias('Doctrine\Tests\Common\\', 'alias');
149
+
150
+        $reflClass = new ReflectionClass('Doctrine\Tests\Common\Annotations\Regression\AliasNamespace');
151
+        
152
+        $result = $reader->getPropertyAnnotations($reflClass->getProperty('foo'));
153
+        $this->assertEquals(1, count($result));
154
+        $annot = $result['Doctrine\Tests\Common\Annotations\Name'];
155
+        $this->assertTrue($annot instanceof \Doctrine\Tests\Common\Annotations\Name); // no use!
156
+        $this->assertEquals('bar', $annot->foo);
157
+    }
158
+}
159
+
160
+class CustomDummyAnnotationClass {
161
+    private $dummyValue;
162
+
163
+    public function setDummyValue($value) {
164
+        $this->dummyValue = $value;
165
+    }
166
+
167
+    public function getDummyValue() {
168
+        return $this->dummyValue;
169
+    }
170
+}
171
+
172
+class AliasNamespace
173
+{
174
+
175
+    /**
176
+     * @alias:Name(foo="bar")
177
+     */
178
+    public $bar;
179
+    /**
180
+     * @alias:Annotations\Name(foo="bar")
181
+     */
182
+    public $foo;
183
+}
184
+
185
+/**
186
+ * A description of this class.
187
+ *
188
+ * Let's see if the parser recognizes that this @ is not really referring to an
189
+ * annotation. Also make sure that @var \ is not concated to "@var\is".
190
+ * 
191
+ * Copy of the class one namespace up to avoid matches against __NAMESPACE__
192
+ *
193
+ * @author robo
194
+ * @since 2.0
195
+ * @DummyAnnotation(dummyValue="hello")
196
+ */
197
+class DummyClass {
198
+    /**
199
+     * A nice property.
200
+     *
201
+     * @var mixed
202
+     * @DummyAnnotation(dummyValue="fieldHello")
203
+     */
204
+    private $field1;
205
+
206
+    /**
207
+     * @DummyJoinTable(name="join_table",
208
+     *      joinColumns={@DummyJoinColumn(name="col1", referencedColumnName="col2")},
209
+     *      inverseJoinColumns={
210
+     *          @DummyJoinColumn(name="col3", referencedColumnName="col4")
211
+     *      })
212
+     */
213
+    private $field2;
214
+
215
+    /**
216
+     * Gets the value of field1.
217
+     *
218
+     * @return mixed
219
+     * @DummyAnnotation({1,2,"three"})
220
+     */
221
+    public function getField1() {
222
+    }
223
+}
224
+
225
+
226
+/**
227
+ * @ignoreAnnotation("var")
228
+ */
229
+class DummyClass2 {
230
+    /**
231
+     * @DummyId @DummyColumn(type="integer") @DummyGeneratedValue
232
+     * @var integer
233
+     */
234
+    private $id;
235
+}
236
+
237
+/**
238
+ * @ignoreAnnotation({"since", "var"})
239
+ */
240
+class DummyClassNonAnnotationProblem
241
+{
242
+    /**
243
+     * @DummyAnnotation
244
+     *
245
+     * @var \Test
246
+     * @since 0.1
247
+     */
248
+    public $foo;
249
+}
250
+
251
+
252
+/**
253
+* @DummyAnnotation Foo bar <foobar@1domain.com>
254
+*/
255
+class DummyClassWithEmail
256
+{
257
+    
258
+}

+ 66 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php Ver fichero

@@ -0,0 +1,66 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Annotations\Ticket;
4
+
5
+use Doctrine\Tests\Common\Annotations\Fixtures\Controller;
6
+use Doctrine\Common\Annotations\AnnotationRegistry;
7
+
8
+/**
9
+ * @group
10
+ */
11
+class DCOM55Test extends \PHPUnit_Framework_TestCase
12
+{
13
+    public function testIssue()
14
+    {
15
+        AnnotationRegistry::registerAutoloadNamespace('Doctrine\Tests\Common\Annotations\Fixtures', __DIR__ . '/../../../../../');
16
+
17
+        $class = new \ReflectionClass(__NAMESPACE__ . '\\Dummy');
18
+        $reader = new \Doctrine\Common\Annotations\AnnotationReader();
19
+        $annots = $reader->getClassAnnotations($class);
20
+        
21
+        $this->assertEquals(0, count($annots));
22
+    }
23
+    
24
+    public function testAnnotation()
25
+    {
26
+        $class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Consumer');
27
+        $reader = new \Doctrine\Common\Annotations\AnnotationReader();
28
+        $annots = $reader->getClassAnnotations($class);
29
+        
30
+        $this->assertEquals(1, count($annots));
31
+        $this->assertInstanceOf(__NAMESPACE__.'\\DCOM55Annotation', $annots[0]);
32
+    }
33
+    
34
+    public function testParseAnnotationDocblocks()
35
+    {
36
+        $class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Annotation');
37
+        $reader = new \Doctrine\Common\Annotations\AnnotationReader();
38
+        $annots = $reader->getClassAnnotations($class);
39
+        
40
+        $this->assertEquals(0, count($annots));
41
+    }
42
+}
43
+
44
+/**
45
+ * @Controller
46
+ */
47
+class Dummy
48
+{
49
+    
50
+}
51
+
52
+/**
53
+ * @Annotation
54
+ */
55
+class DCOM55Annotation
56
+{
57
+    
58
+}
59
+
60
+/**
61
+ * @DCOM55Annotation
62
+ */
63
+class DCOM55Consumer
64
+{
65
+    
66
+}

+ 7 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Annotations/TopLevelAnnotation.php Ver fichero

@@ -0,0 +1,7 @@
1
+<?php
2
+
3
+use Doctrine\Common\Annotations\Annotation;
4
+
5
+class TopLevelAnnotation extends Annotation
6
+{
7
+}

+ 20 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php Ver fichero

@@ -0,0 +1,20 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Cache;
4
+
5
+use Doctrine\Common\Cache\ApcCache;
6
+
7
+class ApcCacheTest extends CacheTest
8
+{
9
+    public function setUp()
10
+    {
11
+        if ( ! extension_loaded('apc') || false === @apc_cache_info()) {
12
+            $this->markTestSkipped('The ' . __CLASS__ .' requires the use of APC');
13
+        }
14
+    }
15
+
16
+    protected function _getCacheDriver()
17
+    {
18
+        return new ApcCache();
19
+    }
20
+}

+ 13 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/ArrayCacheTest.php Ver fichero

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Cache;
4
+
5
+use Doctrine\Common\Cache\ArrayCache;
6
+
7
+class ArrayCacheTest extends CacheTest
8
+{
9
+    protected function _getCacheDriver()
10
+    {
11
+        return new ArrayCache();
12
+    }
13
+}

+ 93 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/CacheTest.php Ver fichero

@@ -0,0 +1,93 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Cache;
4
+
5
+abstract class CacheTest extends \Doctrine\Tests\DoctrineTestCase
6
+{
7
+    public function testBasics()
8
+    {
9
+        $cache = $this->_getCacheDriver();
10
+
11
+        // Test save
12
+        $cache->save('test_key', 'testing this out');
13
+
14
+        // Test contains to test that save() worked
15
+        $this->assertTrue($cache->contains('test_key'));
16
+
17
+        // Test fetch
18
+        $this->assertEquals('testing this out', $cache->fetch('test_key'));
19
+
20
+        // Test delete
21
+        $cache->save('test_key2', 'test2');
22
+        $cache->delete('test_key2');
23
+        $this->assertFalse($cache->contains('test_key2'));
24
+    }
25
+
26
+    public function testDeleteAll()
27
+    {
28
+        $cache = $this->_getCacheDriver();
29
+        $cache->save('test_key1', '1');
30
+        $cache->save('test_key2', '2');
31
+        $cache->deleteAll();
32
+
33
+        $this->assertFalse($cache->contains('test_key1'));
34
+        $this->assertFalse($cache->contains('test_key2'));
35
+    }
36
+
37
+    public function testDeleteByRegex()
38
+    {
39
+        $cache = $this->_getCacheDriver();
40
+        $cache->save('test_key1', '1');
41
+        $cache->save('test_key2', '2');
42
+        $cache->deleteByRegex('/test_key[0-9]/');
43
+
44
+        $this->assertFalse($cache->contains('test_key1'));
45
+        $this->assertFalse($cache->contains('test_key2'));
46
+    }
47
+
48
+    public function testDeleteByPrefix()
49
+    {
50
+        $cache = $this->_getCacheDriver();
51
+        $cache->save('test_key1', '1');
52
+        $cache->save('test_key2', '2');
53
+        $cache->deleteByPrefix('test_key');
54
+
55
+        $this->assertFalse($cache->contains('test_key1'));
56
+        $this->assertFalse($cache->contains('test_key2'));
57
+    }
58
+
59
+    public function testDeleteBySuffix()
60
+    {
61
+        $cache = $this->_getCacheDriver();
62
+        $cache->save('1test_key', '1');
63
+        $cache->save('2test_key', '2');
64
+        $cache->deleteBySuffix('test_key');
65
+
66
+        $this->assertFalse($cache->contains('1test_key'));
67
+        $this->assertFalse($cache->contains('2test_key'));
68
+    }
69
+
70
+    public function testDeleteByWildcard()
71
+    {
72
+        $cache = $this->_getCacheDriver();
73
+        $cache->save('test_key1', '1');
74
+        $cache->save('test_key2', '2');
75
+        $cache->delete('test_key*');
76
+
77
+        $this->assertFalse($cache->contains('test_key1'));
78
+        $this->assertFalse($cache->contains('test_key2'));
79
+    }
80
+
81
+    public function testNamespace()
82
+    {
83
+        $cache = $this->_getCacheDriver();
84
+        $cache->setNamespace('test_');
85
+        $cache->save('key1', 'test');
86
+        $this->assertTrue($cache->contains('key1'));
87
+
88
+        $ids = $cache->getIds();
89
+        $this->assertTrue(in_array('test_key1', $ids));
90
+    }
91
+
92
+    abstract protected function _getCacheDriver();
93
+}

+ 30 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/MemcacheCacheTest.php Ver fichero

@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Cache;
4
+
5
+use Doctrine\Common\Cache\MemcacheCache;
6
+
7
+class MemcacheCacheTest extends CacheTest
8
+{
9
+    private $_memcache;
10
+
11
+    public function setUp()
12
+    {
13
+        if (extension_loaded('memcache')) {
14
+            $this->_memcache = new \Memcache;
15
+            $ok = @$this->_memcache->connect('localhost', 11211);
16
+            if (!$ok) {
17
+                $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
18
+            }
19
+        } else {
20
+            $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
21
+        }
22
+    }
23
+
24
+    protected function _getCacheDriver()
25
+    {
26
+        $driver = new MemcacheCache();
27
+        $driver->setMemcache($this->_memcache);
28
+        return $driver;
29
+    }
30
+}

+ 20 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/XcacheCacheTest.php Ver fichero

@@ -0,0 +1,20 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Cache;
4
+
5
+use Doctrine\Common\Cache\XcacheCache;
6
+
7
+class XcacheCacheTest extends CacheTest
8
+{
9
+    public function setUp()
10
+    {
11
+        if ( ! extension_loaded('xcache')) {
12
+            $this->markTestSkipped('The ' . __CLASS__ .' requires the use of xcache');
13
+        }
14
+    }
15
+
16
+    protected function _getCacheDriver()
17
+    {
18
+        return new XcacheCache();
19
+    }
20
+}

+ 41 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Cache/ZendDataCacheTest.php Ver fichero

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Cache;
4
+
5
+use Doctrine\Common\Cache\ZendDataCache;
6
+
7
+require_once __DIR__ . '/../../TestInit.php';
8
+
9
+class ZendDataCacheTest extends \Doctrine\Tests\DoctrineTestCase
10
+{
11
+    public function setUp()
12
+    {
13
+        if (!function_exists('zend_shm_cache_fetch') || (php_sapi_name() != 'apache2handler')) {
14
+            $this->markTestSkipped('The ' . __CLASS__ .' requires the use of Zend Data Cache which only works in apache2handler SAPI');
15
+        }
16
+    }
17
+
18
+    protected function _getCacheDriver()
19
+    {
20
+        return new ZendDataCache();
21
+    }
22
+    
23
+    public function testBasics()
24
+    {
25
+        $cache = $this->_getCacheDriver();
26
+
27
+        // Test save
28
+        $cache->save('test_key', 'testing this out');
29
+
30
+        // Test contains to test that save() worked
31
+        $this->assertTrue($cache->contains('test_key'));
32
+
33
+        // Test fetch
34
+        $this->assertEquals('testing this out', $cache->fetch('test_key'));
35
+
36
+        // Test delete
37
+        $cache->save('test_key2', 'test2');
38
+        $cache->delete('test_key2');
39
+        $this->assertFalse($cache->contains('test_key2'));
40
+    }
41
+}

+ 45 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest.php Ver fichero

@@ -0,0 +1,45 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common;
4
+
5
+use Doctrine\Common\ClassLoader;
6
+
7
+class ClassLoaderTest extends \Doctrine\Tests\DoctrineTestCase
8
+{
9
+    public function testClassLoader()
10
+    {
11
+        $classLoader = new ClassLoader('ClassLoaderTest');
12
+        $classLoader->setIncludePath(__DIR__);
13
+        $classLoader->setFileExtension('.class.php');
14
+        $classLoader->setNamespaceSeparator('_');
15
+
16
+        $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassA'));
17
+        $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassB'));
18
+        $this->assertTrue($classLoader->canLoadClass('ClassLoaderTest_ClassC'));
19
+        $this->assertFalse($classLoader->canLoadClass('OtherClass'));
20
+        $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassA'), true);
21
+        $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassB'), true);
22
+        $this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassC'), true);
23
+    }
24
+
25
+    public function testClassExists()
26
+    {
27
+        $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\ClassD'));
28
+        $badLoader = function($className) {
29
+            require __DIR__ . '/ClassLoaderTest/ClassD.php';
30
+            return true;
31
+        };
32
+        spl_autoload_register($badLoader);
33
+        $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\ClassD'));
34
+        spl_autoload_unregister($badLoader);
35
+    }
36
+
37
+    public function testGetClassLoader()
38
+    {
39
+        $cl = new ClassLoader('ClassLoaderTest', __DIR__);
40
+        $cl->register();
41
+        $this->assertTrue(ClassLoader::getClassLoader('ClassLoaderTest\ClassD') instanceof \Doctrine\Common\ClassLoader);
42
+        $this->assertNull(ClassLoader::getClassLoader('This\Class\Does\Not\Exist'));
43
+        $cl->unregister();
44
+    }
45
+}

+ 6 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassA.class.php Ver fichero

@@ -0,0 +1,6 @@
1
+<?php
2
+
3
+class ClassLoaderTest_ClassA
4
+{
5
+    
6
+}

+ 6 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassB.class.php Ver fichero

@@ -0,0 +1,6 @@
1
+<?php
2
+
3
+class ClassLoaderTest_ClassB
4
+{
5
+    
6
+}

+ 6 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassC.class.php Ver fichero

@@ -0,0 +1,6 @@
1
+<?php
2
+
3
+class ClassLoaderTest_ClassC
4
+{
5
+    
6
+}

+ 5 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/ClassLoaderTest/ClassD.php Ver fichero

@@ -0,0 +1,5 @@
1
+<?php
2
+
3
+namespace ClassLoaderTest;
4
+
5
+class ClassD {}

+ 195 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/Collections/CollectionTest.php Ver fichero

@@ -0,0 +1,195 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common\Collections;
4
+
5
+use Doctrine\Tests;
6
+
7
+class CollectionTest extends \Doctrine\Tests\DoctrineTestCase
8
+{
9
+    /**
10
+     * @var \Doctrine\Common\Collections\Collection
11
+     */
12
+    private $_coll;
13
+
14
+    protected function setUp()
15
+    {
16
+        $this->_coll = new \Doctrine\Common\Collections\ArrayCollection;
17
+    }
18
+
19
+    public function testIssetAndUnset()
20
+    {
21
+        $this->assertFalse(isset($this->_coll[0]));
22
+        $this->_coll->add('testing');
23
+        $this->assertTrue(isset($this->_coll[0]));
24
+        unset($this->_coll[0]);
25
+        $this->assertFalse(isset($this->_coll[0]));
26
+    }
27
+
28
+    public function testToString()
29
+    {
30
+        $this->_coll->add('testing');
31
+        $this->assertTrue(is_string((string) $this->_coll));
32
+    }
33
+
34
+    public function testRemovingNonExistentEntryReturnsNull()
35
+    {
36
+        $this->assertEquals(null, $this->_coll->remove('testing_does_not_exist'));
37
+    }
38
+
39
+    public function testExists()
40
+    {
41
+        $this->_coll->add("one");
42
+        $this->_coll->add("two");
43
+        $exists = $this->_coll->exists(function($k, $e) { return $e == "one"; });
44
+        $this->assertTrue($exists);
45
+        $exists = $this->_coll->exists(function($k, $e) { return $e == "other"; });
46
+        $this->assertFalse($exists);
47
+    }
48
+
49
+    public function testMap()
50
+    {
51
+        $this->_coll->add(1);
52
+        $this->_coll->add(2);
53
+        $res = $this->_coll->map(function($e) { return $e * 2; });
54
+        $this->assertEquals(array(2, 4), $res->toArray());
55
+    }
56
+
57
+    public function testFilter()
58
+    {
59
+        $this->_coll->add(1);
60
+        $this->_coll->add("foo");
61
+        $this->_coll->add(3);
62
+        $res = $this->_coll->filter(function($e) { return is_numeric($e); });
63
+        $this->assertEquals(array(0 => 1, 2 => 3), $res->toArray());
64
+    }
65
+
66
+    public function testFirstAndLast()
67
+    {
68
+        $this->_coll->add('one');
69
+        $this->_coll->add('two');
70
+
71
+        $this->assertEquals($this->_coll->first(), 'one');
72
+        $this->assertEquals($this->_coll->last(), 'two');
73
+    }
74
+
75
+    public function testArrayAccess()
76
+    {
77
+        $this->_coll[] = 'one';
78
+        $this->_coll[] = 'two';
79
+
80
+        $this->assertEquals($this->_coll[0], 'one');
81
+        $this->assertEquals($this->_coll[1], 'two');
82
+
83
+        unset($this->_coll[0]);
84
+        $this->assertEquals($this->_coll->count(), 1);
85
+    }
86
+
87
+    public function testContainsKey()
88
+    {
89
+        $this->_coll[5] = 'five';
90
+        $this->assertTrue($this->_coll->containsKey(5));
91
+    }
92
+
93
+    public function testContains()
94
+    {
95
+        $this->_coll[0] = 'test';
96
+        $this->assertTrue($this->_coll->contains('test'));
97
+    }
98
+
99
+    public function testSearch()
100
+    {
101
+        $this->_coll[0] = 'test';
102
+        $this->assertEquals(0, $this->_coll->indexOf('test'));
103
+    }
104
+
105
+    public function testGet()
106
+    {
107
+        $this->_coll[0] = 'test';
108
+        $this->assertEquals('test', $this->_coll->get(0));
109
+    }
110
+
111
+    public function testGetKeys()
112
+    {
113
+        $this->_coll[] = 'one';
114
+        $this->_coll[] = 'two';
115
+        $this->assertEquals(array(0, 1), $this->_coll->getKeys());
116
+    }
117
+
118
+    public function testGetValues()
119
+    {
120
+        $this->_coll[] = 'one';
121
+        $this->_coll[] = 'two';
122
+        $this->assertEquals(array('one', 'two'), $this->_coll->getValues());
123
+    }
124
+
125
+    public function testCount()
126
+    {
127
+        $this->_coll[] = 'one';
128
+        $this->_coll[] = 'two';
129
+        $this->assertEquals($this->_coll->count(), 2);
130
+        $this->assertEquals(count($this->_coll), 2);
131
+    }
132
+
133
+    public function testForAll()
134
+    {
135
+        $this->_coll[] = 'one';
136
+        $this->_coll[] = 'two';
137
+        $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_string($e); }), true);
138
+        $this->assertEquals($this->_coll->forAll(function($k, $e) { return is_array($e); }), false);
139
+    }
140
+
141
+    public function testPartition()
142
+    {
143
+        $this->_coll[] = true;
144
+        $this->_coll[] = false;
145
+        $partition = $this->_coll->partition(function($k, $e) { return $e == true; });
146
+        $this->assertEquals($partition[0][0], true);
147
+        $this->assertEquals($partition[1][0], false);
148
+    }
149
+
150
+    public function testClear()
151
+    {
152
+        $this->_coll[] = 'one';
153
+        $this->_coll[] = 'two';
154
+        $this->_coll->clear();
155
+        $this->assertEquals($this->_coll->isEmpty(), true);
156
+    }
157
+
158
+    public function testRemove()
159
+    {
160
+        $this->_coll[] = 'one';
161
+        $this->_coll[] = 'two';
162
+        $el = $this->_coll->remove(0);
163
+
164
+        $this->assertEquals('one', $el);
165
+        $this->assertEquals($this->_coll->contains('one'), false);
166
+        $this->assertNull($this->_coll->remove(0));
167
+    }
168
+
169
+    public function testRemoveElement()
170
+    {
171
+        $this->_coll[] = 'one';
172
+        $this->_coll[] = 'two';
173
+        
174
+        $this->assertTrue($this->_coll->removeElement('two'));
175
+        $this->assertFalse($this->_coll->contains('two'));
176
+        $this->assertFalse($this->_coll->removeElement('two'));
177
+    }
178
+
179
+    public function testSlice()
180
+    {
181
+        $this->_coll[] = 'one';
182
+        $this->_coll[] = 'two';
183
+        $this->_coll[] = 'three';
184
+
185
+        $slice = $this->_coll->slice(0, 1);
186
+        $this->assertInternalType('array', $slice);
187
+        $this->assertEquals(array('one'), $slice);
188
+
189
+        $slice = $this->_coll->slice(1);
190
+        $this->assertEquals(array(1 => 'two', 2 => 'three'), $slice);
191
+
192
+        $slice = $this->_coll->slice(1, 1);
193
+        $this->assertEquals(array(1 => 'two'), $slice);
194
+    }
195
+}

vendor/bundles/Sensio/Bundle/FrameworkExtraBundle/phpunit.xml.dist → vendor/doctrine-common/tests/Doctrine/Tests/Common/DoctrineExceptionTest.php Ver fichero


+ 88 - 0
vendor/doctrine-common/tests/Doctrine/Tests/Common/EventManagerTest.php Ver fichero

@@ -0,0 +1,88 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\Common;
4
+
5
+use Doctrine\Common\EventManager;
6
+use Doctrine\Common\EventArgs;
7
+
8
+class EventManagerTest extends \Doctrine\Tests\DoctrineTestCase
9
+{
10
+    /* Some pseudo events */
11
+    const preFoo = 'preFoo';
12
+    const postFoo = 'postFoo';
13
+    const preBar = 'preBar';
14
+    const postBar = 'postBar';
15
+
16
+    private $_preFooInvoked = false;
17
+    private $_postFooInvoked = false;
18
+
19
+    private $_eventManager;
20
+
21
+    protected function setUp()
22
+    {
23
+        $this->_eventManager = new EventManager;
24
+        $this->_preFooInvoked = false;
25
+        $this->_postFooInvoked = false;
26
+    }
27
+
28
+    public function testInitialState()
29
+    {
30
+        $this->assertEquals(array(), $this->_eventManager->getListeners());
31
+        $this->assertFalse($this->_eventManager->hasListeners(self::preFoo));
32
+        $this->assertFalse($this->_eventManager->hasListeners(self::postFoo));
33
+    }
34
+
35
+    public function testAddEventListener()
36
+    {
37
+        $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this);
38
+        $this->assertTrue($this->_eventManager->hasListeners(self::preFoo));
39
+        $this->assertTrue($this->_eventManager->hasListeners(self::postFoo));
40
+        $this->assertEquals(1, count($this->_eventManager->getListeners(self::preFoo)));
41
+        $this->assertEquals(1, count($this->_eventManager->getListeners(self::postFoo)));
42
+        $this->assertEquals(2, count($this->_eventManager->getListeners()));
43
+    }
44
+
45
+    public function testDispatchEvent()
46
+    {
47
+        $this->_eventManager->addEventListener(array('preFoo', 'postFoo'), $this);
48
+        $this->_eventManager->dispatchEvent(self::preFoo);
49
+        $this->assertTrue($this->_preFooInvoked);
50
+        $this->assertFalse($this->_postFooInvoked);
51
+    }
52
+
53
+    public function testRemoveEventListener()
54
+    {
55
+        $this->_eventManager->addEventListener(array('preBar'), $this);
56
+        $this->assertTrue($this->_eventManager->hasListeners(self::preBar));
57
+        $this->_eventManager->removeEventListener(array('preBar'), $this);
58
+        $this->assertFalse($this->_eventManager->hasListeners(self::preBar));
59
+    }
60
+
61
+    public function testAddEventSubscriber()
62
+    {
63
+        $eventSubscriber = new TestEventSubscriber();
64
+        $this->_eventManager->addEventSubscriber($eventSubscriber);
65
+        $this->assertTrue($this->_eventManager->hasListeners(self::preFoo));
66
+        $this->assertTrue($this->_eventManager->hasListeners(self::postFoo));
67
+    }
68
+
69
+    /* Listener methods */
70
+
71
+    public function preFoo(EventArgs $e)
72
+    {
73
+        $this->_preFooInvoked = true;
74
+    }
75
+
76
+    public function postFoo(EventArgs $e)
77
+    {
78
+        $this->_postFooInvoked = true;
79
+    }
80
+}
81
+
82
+class TestEventSubscriber implements \Doctrine\Common\EventSubscriber
83
+{
84
+    public function getSubscribedEvents()
85
+    {
86
+        return array('preFoo', 'postFoo');
87
+    }
88
+}

+ 10 - 0
vendor/doctrine-common/tests/Doctrine/Tests/DoctrineTestCase.php Ver fichero

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests;
4
+
5
+/**
6
+ * Base testcase class for all Doctrine testcases.
7
+ */
8
+abstract class DoctrineTestCase extends \PHPUnit_Framework_TestCase
9
+{
10
+}

+ 27 - 0
vendor/doctrine-common/tests/Doctrine/Tests/TestInit.php Ver fichero

@@ -0,0 +1,27 @@
1
+<?php
2
+/*
3
+ * This file bootstraps the test environment.
4
+ */
5
+namespace Doctrine\Tests;
6
+
7
+error_reporting(E_ALL | E_STRICT);
8
+
9
+// register silently failing autoloader
10
+spl_autoload_register(function($class)
11
+{
12
+    if (0 === strpos($class, 'Doctrine\Tests\\')) {
13
+        $path = __DIR__.'/../../'.strtr($class, '\\', '/').'.php';
14
+        if (file_exists($path) && is_readable($path)) {
15
+            require_once $path;
16
+
17
+            return true;
18
+        }
19
+    } else if (0 === strpos($class, 'Doctrine\Common\\')) {
20
+        $path = __DIR__.'/../../../lib/'.($class = strtr($class, '\\', '/')).'.php';
21
+        if (file_exists($path) && is_readable($path)) {
22
+            require_once $path;
23
+
24
+            return true;
25
+        }
26
+    }
27
+});

+ 246 - 0
vendor/doctrine-common/tests/NativePhpunitTask.php Ver fichero

@@ -0,0 +1,246 @@
1
+<?php
2
+/**
3
+ * Native PHPUnit Task
4
+ *
5
+ * LICENSE
6
+ *
7
+ * This source file is subject to the new BSD license that is bundled
8
+ * with this package in the file LICENSE.txt.
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to kontakt@beberlei.de so I can send you a copy immediately.
12
+ */
13
+
14
+require_once 'PHPUnit/Autoload.php';
15
+
16
+/**
17
+ * A more flexible and powerful PHPUnit Task than the native Phing one.
18
+ *
19
+ * Plus forward compability for PHPUnit 3.5 and later is ensured by using the PHPUnit Test Runner instead of implementing one.
20
+ *
21
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
22
+ */
23
+class NativePhpunitTask extends Task
24
+{
25
+    private $test;
26
+    private $testfile;
27
+    private $testdirectory;
28
+    private $configuration = null;
29
+    private $coverageClover = null;
30
+    private $junitlogfile = null;
31
+    private $haltonfailure = true;
32
+    private $haltonerror = true;
33
+
34
+    public function setTestdirectory($directory) {
35
+        $this->testdirectory = $directory;
36
+    }
37
+
38
+    public function setTest($test) {
39
+        $this->test = $test;
40
+    }
41
+
42
+    public function setTestfile($testfile) {
43
+        $this->testfile = $testfile;
44
+    }
45
+
46
+    public function setJunitlogfile($junitlogfile) {
47
+        if (strlen($junitlogfile) == 0) {
48
+            $junitlogfile = NULL;
49
+        }
50
+
51
+        $this->junitlogfile = $junitlogfile;
52
+    }
53
+
54
+    public function setConfiguration($configuration) {
55
+        if (strlen($configuration) == 0) {
56
+            $configuration = NULL;
57
+        }
58
+
59
+        $this->configuration = $configuration;
60
+    }
61
+
62
+    public function setCoverageClover($coverageClover) {
63
+        if (strlen($coverageClover) == 0) {
64
+            $coverageClover = NULL;
65
+        }
66
+
67
+        $this->coverageClover = $coverageClover;
68
+    }
69
+
70
+    public function setHaltonfailure($haltonfailures) {
71
+        $this->haltonfailure = $haltonfailures;
72
+    }
73
+
74
+    public function setHaltonerror($haltonerrors) {
75
+        $this->haltonerror = $haltonerrors;
76
+    }
77
+
78
+    public function init()
79
+    {
80
+        require_once "PHPUnit/Runner/Version.php";
81
+        $version = PHPUnit_Runner_Version::id();
82
+
83
+        if (version_compare($version, '3.4.0') < 0) {
84
+            throw new BuildException("NativePHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation());
85
+        }
86
+
87
+        require_once 'PHPUnit/Util/Filter.php';
88
+
89
+        // point PHPUnit_MAIN_METHOD define to non-existing method
90
+        if (!defined('PHPUnit_MAIN_METHOD')) {
91
+            define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
92
+        }
93
+    }
94
+
95
+    public function main()
96
+    {
97
+        if (!is_dir(realpath($this->testdirectory))) {
98
+            throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '".$this->testdirectory."' given.");
99
+        }
100
+        set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path());
101
+
102
+        $printer = new NativePhpunitPrinter();
103
+
104
+        $arguments = array(
105
+            'configuration' => $this->configuration,
106
+            'coverageClover' => $this->coverageClover,
107
+            'junitLogfile' => $this->junitlogfile,
108
+            'printer' => $printer,
109
+        );
110
+
111
+        $runner = new PHPUnit_TextUI_TestRunner();
112
+        $suite = $runner->getTest($this->test, $this->testfile, true);
113
+
114
+        try {
115
+            $result = $runner->doRun($suite, $arguments);
116
+            /* @var $result PHPUnit_Framework_TestResult */
117
+
118
+            if ( ($this->haltonfailure && $result->failureCount() > 0) || ($this->haltonerror && $result->errorCount() > 0) ) {
119
+                throw new BuildException("PHPUnit: ".$result->failureCount()." Failures and ".$result->errorCount()." Errors, ".
120
+                    "last failure message: ".$printer->getMessages());
121
+            }
122
+
123
+            $this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ".
124
+                "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)");
125
+
126
+            // Hudson for example doesn't like the backslash in class names
127
+            if (file_exists($this->coverageClover)) {
128
+                $this->log("Generated Clover Coverage XML to: ".$this->coverageClover);
129
+                $content = file_get_contents($this->coverageClover);
130
+                $content = str_replace("\\", ".", $content);
131
+                file_put_contents($this->coverageClover, $content);
132
+                unset($content);
133
+            }
134
+
135
+        } catch(\Exception $e) {
136
+            throw new BuildException("NativePhpunitTask failed: ".$e->getMessage());
137
+        }
138
+    }
139
+}
140
+
141
+class NativePhpunitPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener
142
+{
143
+    private $_messages = array();
144
+
145
+    public function write($buffer)
146
+    {
147
+        // do nothing
148
+    }
149
+
150
+    public function getMessages()
151
+    {
152
+        return $this->_messages;
153
+    }
154
+
155
+    /**
156
+     * An error occurred.
157
+     *
158
+     * @param  PHPUnit_Framework_Test $test
159
+     * @param  Exception              $e
160
+     * @param  float                  $time
161
+     */
162
+    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
163
+    {
164
+        $this->_messages[] = "Test ERROR: ".$test->getName().": ".$e->getMessage();
165
+    }
166
+
167
+    /**
168
+     * A failure occurred.
169
+     *
170
+     * @param  PHPUnit_Framework_Test                 $test
171
+     * @param  PHPUnit_Framework_AssertionFailedError $e
172
+     * @param  float                                  $time
173
+     */
174
+    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
175
+    {
176
+        $this->_messages[] = "Test FAILED: ".$test->getName().": ".$e->getMessage();
177
+    }
178
+
179
+    /**
180
+     * Incomplete test.
181
+     *
182
+     * @param  PHPUnit_Framework_Test $test
183
+     * @param  Exception              $e
184
+     * @param  float                  $time
185
+     */
186
+    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
187
+    {
188
+
189
+    }
190
+
191
+    /**
192
+     * Skipped test.
193
+     *
194
+     * @param  PHPUnit_Framework_Test $test
195
+     * @param  Exception              $e
196
+     * @param  float                  $time
197
+     * @since  Method available since Release 3.0.0
198
+     */
199
+    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
200
+    {
201
+
202
+    }
203
+
204
+    /**
205
+     * A test suite started.
206
+     *
207
+     * @param  PHPUnit_Framework_TestSuite $suite
208
+     * @since  Method available since Release 2.2.0
209
+     */
210
+    public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
211
+    {
212
+
213
+    }
214
+
215
+    /**
216
+     * A test suite ended.
217
+     *
218
+     * @param  PHPUnit_Framework_TestSuite $suite
219
+     * @since  Method available since Release 2.2.0
220
+     */
221
+    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
222
+    {
223
+
224
+    }
225
+
226
+    /**
227
+     * A test started.
228
+     *
229
+     * @param  PHPUnit_Framework_Test $test
230
+     */
231
+    public function startTest(PHPUnit_Framework_Test $test)
232
+    {
233
+
234
+    }
235
+
236
+    /**
237
+     * A test ended.
238
+     *
239
+     * @param  PHPUnit_Framework_Test $test
240
+     * @param  float                  $time
241
+     */
242
+    public function endTest(PHPUnit_Framework_Test $test, $time)
243
+    {
244
+        
245
+    }
246
+}

+ 27 - 0
vendor/doctrine-common/tests/README.markdown Ver fichero

@@ -0,0 +1,27 @@
1
+# Running the Doctrine 2 Testsuite
2
+
3
+## Running tests
4
+
5
+Execute PHPUnit in the root folder of your doctrine-common clone.
6
+
7
+    phpunit
8
+
9
+## Testing Lock-Support
10
+
11
+The Lock support in Doctrine 2 is tested using Gearman, which allows to run concurrent tasks in parallel.
12
+Install Gearman with PHP as follows:
13
+
14
+1. Go to http://www.gearman.org and download the latest Gearman Server
15
+2. Compile it and then call ldconfig
16
+3. Start it up "gearmand -vvvv"
17
+4. Install pecl/gearman by calling "gearman-beta"
18
+
19
+You can then go into tests/ and start up two workers:
20
+
21
+    php Doctrine/Tests/ORM/Functional/Locking/LockAgentWorker.php
22
+
23
+Then run the locking test-suite:
24
+
25
+    phpunit --configuration <myconfig.xml> Doctrine/Tests/ORM/Functional/Locking/GearmanLockTest.php
26
+
27
+This can run considerable time, because it is using sleep() to test for the timing ranges of locks.

+ 7 - 0
vendor/doctrine-dbal/.gitignore Ver fichero

@@ -0,0 +1,7 @@
1
+build.properties
2
+build/
3
+logs/
4
+reports/
5
+dist/
6
+download/
7
+lib/Doctrine/Common/

+ 6 - 0
vendor/doctrine-dbal/.gitmodules Ver fichero

@@ -0,0 +1,6 @@
1
+[submodule "lib/vendor/doctrine-common"]
2
+	path = lib/vendor/doctrine-common
3
+	url = git://github.com/doctrine/common.git
4
+[submodule "lib/vendor/Symfony/Component/Console"]
5
+	path = lib/vendor/Symfony/Component/Console
6
+	url = git://github.com/symfony/Console.git

+ 4 - 0
vendor/doctrine-dbal/bin/doctrine-dbal Ver fichero

@@ -0,0 +1,4 @@
1
+#!/usr/bin/env php
2
+<?php
3
+
4
+include('doctrine-dbal.php');

+ 43 - 0
vendor/doctrine-dbal/bin/doctrine-dbal.php Ver fichero

@@ -0,0 +1,43 @@
1
+<?php
2
+
3
+require_once 'Doctrine/Common/ClassLoader.php';
4
+
5
+$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
6
+$classLoader->register();
7
+
8
+$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
9
+$classLoader->register();
10
+
11
+$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
12
+
13
+$helperSet = null;
14
+if (file_exists($configFile)) {
15
+    if ( ! is_readable($configFile)) {
16
+        trigger_error(
17
+            'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
18
+        );
19
+    }
20
+
21
+    require $configFile;
22
+    
23
+    foreach ($GLOBALS as $helperSetCandidate) {
24
+        if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
25
+            $helperSet = $helperSetCandidate;
26
+            break;
27
+        }
28
+    }
29
+}
30
+
31
+$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet();
32
+
33
+$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\DBAL\Version::VERSION);
34
+$cli->setCatchExceptions(true);
35
+$cli->setHelperSet($helperSet);
36
+$cli->addCommands(array(
37
+    // DBAL Commands
38
+    new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
39
+    new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
40
+    new \Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand(),
41
+
42
+));
43
+$cli->run();

+ 42 - 0
vendor/doctrine-dbal/bin/doctrine.php Ver fichero

@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+require_once 'Doctrine/Common/ClassLoader.php';
4
+
5
+$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
6
+$classLoader->register();
7
+
8
+$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
9
+$classLoader->register();
10
+
11
+$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
12
+
13
+$helperSet = null;
14
+if (file_exists($configFile)) {
15
+    if ( ! is_readable($configFile)) {
16
+        trigger_error(
17
+            'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
18
+        );
19
+    }
20
+
21
+    require $configFile;
22
+    
23
+    foreach ($GLOBALS as $helperSetCandidate) {
24
+        if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
25
+            $helperSet = $helperSetCandidate;
26
+            break;
27
+        }
28
+    }
29
+}
30
+
31
+$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet();
32
+
33
+$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\DBAL\Version::VERSION);
34
+$cli->setCatchExceptions(true);
35
+$cli->setHelperSet($helperSet);
36
+$cli->addCommands(array(
37
+    // DBAL Commands
38
+    new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
39
+    new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
40
+
41
+));
42
+$cli->run();

+ 16 - 0
vendor/doctrine-dbal/build.properties.dev Ver fichero

@@ -0,0 +1,16 @@
1
+version_name=2.0.2
2
+stability=stable
3
+build.dir=build
4
+dist.dir=dist
5
+report.dir=reports
6
+project.pirum_dir=
7
+project.download_dir=
8
+log.archive.dir=logs
9
+svn.path=/usr/bin/svn
10
+test.phpunit_configuration_file=
11
+test.phpunit_generate_coverage=0
12
+test.pmd_reports=0
13
+test.pdepend_exec=
14
+test.phpmd_exec=
15
+dependencies.common=2.0.1
16
+dependencies.sfconsole=2.0.0

+ 203 - 0
vendor/doctrine-dbal/build.xml Ver fichero

@@ -0,0 +1,203 @@
1
+<?xml version="1.0"?>
2
+
3
+<!--
4
+    Doctrine 2 build file.
5
+-->
6
+
7
+<project name="Doctrine DBAL" default="build" basedir=".">
8
+    <taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" />
9
+
10
+    <property file="build.properties" />
11
+
12
+    <!--
13
+        Fileset for artifacts shared across all distributed packages.
14
+    -->
15
+    <fileset id="shared-artifacts" dir=".">
16
+        <include name="LICENSE"/>
17
+    </fileset>
18
+
19
+    <!--
20
+        Fileset for command line scripts
21
+    -->
22
+    <fileset id="bin-scripts" dir="./bin">
23
+        <include name="doctrine-dbal"/>
24
+        <include name="doctrine-dbal.php"/>
25
+    </fileset>
26
+
27
+    <!--
28
+        Fileset for the sources of the Doctrine Common dependency.
29
+    -->
30
+    <fileset id="common-sources" dir="./lib/vendor/doctrine-common/lib">
31
+        <include name="Doctrine/Common/**"/>
32
+    </fileset>
33
+
34
+    <!--
35
+        Fileset for the sources of the Doctrine DBAL package.
36
+    -->
37
+    <fileset id="dbal-sources" dir="./lib">
38
+        <include name="Doctrine/DBAL/**"/>
39
+    </fileset>
40
+
41
+    <!--
42
+      Fileset for source of the Symfony YAML and Console components.
43
+    -->
44
+    <fileset id="symfony-sources" dir="./lib/vendor">
45
+        <include name="Symfony/Component**"/>
46
+    </fileset>
47
+
48
+    <!--
49
+        Clean the directory for the next build.
50
+    -->
51
+    <target name="clean">
52
+        <available file="./build.properties" property="build_properties_exist" value="true"/>
53
+        <fail unless="build_properties_exist" message="The build.properties file is missing." />
54
+
55
+        <delete dir="${build.dir}" includeemptydirs="true" />
56
+        <delete dir="${dist.dir}" includeemptydirs="true" />
57
+        <delete dir="${report.dir}" includeemptydirs="true" />
58
+    </target>
59
+
60
+    <!--
61
+        Prepare the new build directories after cleaning
62
+    -->
63
+    <target name="prepare" depends="clean">
64
+        <echo msg="Creating build directory: ${build.dir}" />
65
+        <mkdir dir="${build.dir}" />
66
+        <echo msg="Creating distribution directory: ${dist.dir}" />
67
+        <mkdir dir="${dist.dir}" />
68
+        <echo msg="Creating report directory: ${report.dir}" />
69
+        <mkdir dir="${report.dir}" />
70
+        <mkdir dir="${build.dir}/logs"/>
71
+        <mkdir dir="${report.dir}/tests"/>
72
+    </target>
73
+
74
+    <!--
75
+        Builds DBAL package, preparing it for distribution.
76
+    -->
77
+    <target name="build-dbal" depends="prepare">
78
+        <exec command="grep '${version}' ${project.basedir}/lib/Doctrine/DBAL/Version.php" checkreturn="true"/>
79
+        <copy todir="${build.dir}/doctrine-dbal">
80
+            <fileset refid="shared-artifacts"/>
81
+        </copy>
82
+        <copy todir="${build.dir}/doctrine-dbal">
83
+            <fileset refid="common-sources"/>
84
+            <fileset refid="dbal-sources"/>
85
+        </copy>
86
+        <copy todir="${build.dir}/doctrine-dbal/Doctrine">
87
+            <fileset refid="symfony-sources"/>
88
+        </copy>
89
+        <copy todir="${build.dir}/doctrine-dbal/bin">
90
+            <fileset refid="bin-scripts"/>
91
+        </copy>
92
+        <exec command="sed 's/${version}-DEV/${version}/' ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version.php > ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version2.php" passthru="true" />
93
+        <exec command="mv ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version2.php ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version.php" passthru="true" />
94
+    </target>
95
+
96
+    <target name="build" depends="test,build-dbal"/>
97
+
98
+    <!--
99
+        Runs the full test suite.
100
+    -->
101
+    <target name="test" depends="prepare">
102
+        <if><equals arg1="${test.phpunit_generate_coverage}" arg2="1" />
103
+            <then>
104
+                <property name="test.phpunit_coverage_option" value="--coverage-clover ${build.dir}/logs/clover.xml" />
105
+            </then>
106
+            <else>
107
+                <property name="test.phpunit_coverage_option" value="" />
108
+            </else>
109
+        </if>
110
+
111
+        <if><equals arg1="${test.phpunit_configuration_file}" arg2="" />
112
+            <then>
113
+                <property name="test.phpunit_configuration_option" value="" />
114
+            </then>
115
+            <else>
116
+                <property name="test.phpunit_configuration_option" value="--configuration ${test.phpunit_configuration_file}" />
117
+            </else>
118
+        </if>
119
+
120
+        <exec command="phpunit ${test.phpunit_configuration_option} ${test.phpunit_coverage_option} --log-junit ../${build.dir}/logs/testsuites.xml Doctrine/Tests/AllTests.php" dir="./tests" />
121
+        <phpunitreport infile="${build.dir}/logs/testsuites.xml" format="frames" todir="${report.dir}/tests" />
122
+
123
+        <tstamp/>
124
+        <copy file="${build.dir}/logs/testsuites.xml" tofile="${log.archive.dir}/latest/log.xml" overwrite="true"/>
125
+
126
+        <if><equals arg1="${test.pmd_reports}" arg2="1" />
127
+            <then>
128
+                <exec command="${test.pdepend_exec} --jdepend-xml=${build.dir}/logs/jdepend.xml ./lib/Doctrine" />
129
+                <exec command="${test.phpmd_exec} ./lib/Doctrine xml codesize --reportfile ${build.dir}/logs/phpmd.xml" />
130
+
131
+                <copy file="${build.dir}/logs/jdepend.xml" tofile="${log.archive.dir}/latest/jdepend.xml" overwrite="true"/>
132
+                <copy file="${build.dir}/logs/phpmd.xml" tofile="${log.archive.dir}/latest/phpmd.xml" overwrite="true"/>
133
+            </then>
134
+        </if>
135
+    </target>
136
+
137
+    <!--
138
+        Builds distributable PEAR packages.
139
+    -->
140
+    <target name="build-packages" depends="build-dbal">
141
+        <d51pearpkg2 baseinstalldir="/" dir="${build.dir}/doctrine-dbal">
142
+           <name>DoctrineDBAL</name>
143
+           <summary>Doctrine Database Abstraction Layer</summary>
144
+           <channel>pear.doctrine-project.org</channel>
145
+           <description>The Doctrine DBAL package is the database abstraction layer used to power the ORM package.</description>
146
+           <lead user="jwage" name="Jonathan H. Wage" email="jonwage@gmail.com" />
147
+           <lead user="guilhermeblanco" name="Guilherme Blanco" email="guilhermeblanco@gmail.com" />
148
+           <lead user="romanb" name="Roman Borschel" email="roman@code-factory.org" />
149
+           <lead user="beberlei" name="Benjamin Eberlei" email="kontakt@beberlei.de" />
150
+           <license>LGPL</license>
151
+           <version release="${version}" api="${version}" />
152
+           <stability release="${stability}" api="${stability}" />
153
+           <notes>-</notes>
154
+           <dependencies>
155
+               <php minimum_version="5.3.2" />
156
+               <pear minimum_version="1.6.0" recommended_version="1.6.1" />
157
+               <package name="DoctrineCommon" channel="pear.doctrine-project.org" minimum_version="${dependencies.common}" />
158
+               <!-- Doctrine Symfony Console PEAR package is generated in ORM build.xml process -->
159
+               <package name="DoctrineSymfonyConsole" channel="pear.doctrine-project.org" minimum_version="${dependencies.sfconsole}" />
160
+           </dependencies>
161
+           <dirroles key="bin">script</dirroles>
162
+           <ignore>Doctrine/Common/</ignore>
163
+           <ignore>Doctrine/Symfony/</ignore>
164
+           <release>
165
+                <install as="doctrine-dbal" name="bin/doctrine-dbal" />
166
+                <install as="doctrine-dbal.php" name="bin/doctrine-dbal.php" />
167
+           </release>
168
+        </d51pearpkg2>
169
+        <exec command="pear package" dir="${build.dir}/doctrine-dbal" passthru="true" />
170
+        <exec command="mv DoctrineDBAL-${version}.tgz ../../dist" dir="${build.dir}/doctrine-dbal" passthru="true" />
171
+        <tar destfile="dist/DoctrineDBAL-${version}-full.tar.gz" compression="gzip" basedir="${build.dir}">
172
+            <fileset dir="${build.dir}">
173
+                <include name="**/**" />
174
+                <exclude name="logs/" />
175
+            </fileset>
176
+        </tar>
177
+    </target>
178
+
179
+    <target name="git-tag">
180
+        <exec command="grep '${version}' ${project.basedir}/lib/Doctrine/DBAL/Version.php" checkreturn="true"/>
181
+        <exec command="git tag -a ${version}" passthru="true" />
182
+    </target>
183
+
184
+    <target name="pirum-release">
185
+        <exec command="sudo pirum add ${project.pirum_dir} ${project.basedir}/dist/DoctrineDBAL-${version}.tgz" dir="."  passthru="true" />
186
+        <exec command="sudo pirum build ${project.pirum_dir}" passthru="true" />
187
+    </target>
188
+
189
+    <target name="distribute-download">
190
+        <copy file="dist/DoctrineDBAL-${version}-full.tar.gz" todir="${project.download_dir}" />
191
+    </target>
192
+
193
+    <target name="update-dev-version">
194
+        <exec command="grep '${version}' ${project.basedir}/lib/Doctrine/DBAL/Version.php" checkreturn="true"/>
195
+        <propertyprompt propertyName="next_version" defaultValue="${version}" promptText="Enter next version string (without -DEV)" />
196
+        <exec command="sed 's/${version}-DEV/${next_version}-DEV/' ${project.basedir}/lib/Doctrine/DBAL/Version.php > ${project.basedir}/lib/Doctrine/DBAL/Version2.php" passthru="true" />
197
+        <exec command="mv ${project.basedir}/lib/Doctrine/DBAL/Version2.php ${project.basedir}/lib/Doctrine/DBAL/Version.php" passthru="true" />
198
+        <exec command="git add ${project.basedir}/lib/Doctrine/DBAL/Version.php" passthru="true" />
199
+        <exec command="git commit -m 'Bump Dev Version to ${next_version}'" passthru="true" />
200
+    </target>
201
+
202
+    <target name="release" depends="git-tag,build-packages,distribute-download,pirum-release,update-dev-version" />
203
+</project>

+ 3 - 0
vendor/doctrine-dbal/tests/.gitignore Ver fichero

@@ -0,0 +1,3 @@
1
+Doctrine/Tests/Proxies/
2
+Doctrine/Tests/ORM/Proxy/generated/
3
+Doctrine/Tests/ORM/Tools/Export/export

+ 142 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/ConnectionTest.php Ver fichero

@@ -0,0 +1,142 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL;
4
+
5
+require_once __DIR__ . '/../TestInit.php';
6
+
7
+use Doctrine\DBAL\Connection;
8
+use Doctrine\Common\EventManager;
9
+use Doctrine\DBAL\Configuration;
10
+use Doctrine\DBAL\Events;
11
+ 
12
+class ConnectionTest extends \Doctrine\Tests\DbalTestCase
13
+{
14
+    /**
15
+     * @var Doctrine\DBAL\Connection
16
+     */
17
+    protected $_conn = null;
18
+
19
+    public function setUp()
20
+    {
21
+        $params = array(
22
+            'driver' => 'pdo_mysql',
23
+            'host' => 'localhost',
24
+            'user' => 'root',
25
+            'password' => 'password',
26
+            'port' => '1234'
27
+        );
28
+        $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($params);
29
+    }
30
+
31
+    public function testIsConnected()
32
+    {
33
+        $this->assertFalse($this->_conn->isConnected());
34
+    }
35
+
36
+    public function testNoTransactionActiveByDefault()
37
+    {
38
+        $this->assertFalse($this->_conn->isTransactionActive());
39
+    }
40
+
41
+    public function testCommitWithNoActiveTransaction_ThrowsException()
42
+    {
43
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException');
44
+        $this->_conn->commit();
45
+    }
46
+
47
+    public function testRollbackWithNoActiveTransaction_ThrowsException()
48
+    {
49
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException');
50
+        $this->_conn->rollback();
51
+    }
52
+
53
+    public function testSetRollbackOnlyNoActiveTransaction_ThrowsException()
54
+    {
55
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException');
56
+        $this->_conn->setRollbackOnly();
57
+    }
58
+
59
+    public function testIsRollbackOnlyNoActiveTransaction_ThrowsException()
60
+    {
61
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException');
62
+        $this->_conn->isRollbackOnly();
63
+    }
64
+
65
+    public function testGetConfiguration()
66
+    {
67
+        $config = $this->_conn->getConfiguration();
68
+
69
+        $this->assertInstanceOf('Doctrine\DBAL\Configuration', $config);
70
+    }
71
+
72
+    public function testGetHost()
73
+    {
74
+        $this->assertEquals('localhost', $this->_conn->getHost());
75
+    }
76
+
77
+    public function testGetPort()
78
+    {
79
+        $this->assertEquals('1234', $this->_conn->getPort());
80
+    }
81
+
82
+    public function testGetUsername()
83
+    {
84
+        $this->assertEquals('root', $this->_conn->getUsername());
85
+    }
86
+
87
+    public function testGetPassword()
88
+    {
89
+        $this->assertEquals('password', $this->_conn->getPassword());
90
+    }
91
+
92
+    public function testGetDriver()
93
+    {
94
+        $this->assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $this->_conn->getDriver());
95
+    }
96
+
97
+    public function testGetEventManager()
98
+    {
99
+        $this->assertInstanceOf('Doctrine\Common\EventManager', $this->_conn->getEventManager());
100
+    }
101
+
102
+    public function testConnectDispatchEvent()
103
+    {
104
+        $listenerMock = $this->getMock('ConnectDispatchEventListener', array('postConnect'));
105
+        $listenerMock->expects($this->once())->method('postConnect');
106
+
107
+        $eventManager = new EventManager();
108
+        $eventManager->addEventListener(array(Events::postConnect), $listenerMock);
109
+
110
+        $driverMock = $this->getMock('Doctrine\DBAL\Driver');
111
+        $driverMock->expects(($this->at(0)))
112
+                   ->method('connect');
113
+        $platform = new Mocks\MockPlatform();
114
+
115
+        $conn = new Connection(array('platform' => $platform), $driverMock, new Configuration(), $eventManager);
116
+        $conn->connect();
117
+    }
118
+
119
+    /**
120
+     * Pretty dumb test, however we want to check that the EchoSQLLogger correctly implements the interface.
121
+     *
122
+     * @group DBAL-11
123
+     */
124
+    public function testEchoSQLLogger()
125
+    {
126
+        $logger = new \Doctrine\DBAL\Logging\EchoSQLLogger();
127
+        $this->_conn->getConfiguration()->setSQLLogger($logger);
128
+        $this->assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger());
129
+    }
130
+
131
+    /**
132
+     * Pretty dumb test, however we want to check that the DebugStack correctly implements the interface.
133
+     *
134
+     * @group DBAL-11
135
+     */
136
+    public function testDebugSQLStack()
137
+    {
138
+        $logger = new \Doctrine\DBAL\Logging\DebugStack();
139
+        $this->_conn->getConfiguration()->setSQLLogger($logger);
140
+        $this->assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger());
141
+    }
142
+}

+ 117 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php Ver fichero

@@ -0,0 +1,117 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL;
4
+
5
+require_once __DIR__ . '/../TestInit.php';
6
+ 
7
+class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
8
+{
9
+    /**
10
+     * @expectedException \Doctrine\DBAL\DBALException
11
+     */
12
+    public function testInvalidPdoInstance()
13
+    {
14
+        $options = array(
15
+            'pdo' => 'test'
16
+        );
17
+        $test = \Doctrine\DBAL\DriverManager::getConnection($options);
18
+    }
19
+
20
+    public function testValidPdoInstance()
21
+    {
22
+        $options = array(
23
+            'pdo' => new \PDO('sqlite::memory:')
24
+        );
25
+        $conn = \Doctrine\DBAL\DriverManager::getConnection($options);
26
+        $this->assertEquals('sqlite', $conn->getDatabasePlatform()->getName());
27
+    }
28
+
29
+    /**
30
+     * @group DBAL-32
31
+     */
32
+    public function testPdoInstanceSetErrorMode()
33
+    {
34
+        $pdo = new \PDO('sqlite::memory:');
35
+        $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
36
+        $options = array(
37
+            'pdo' => $pdo
38
+        );
39
+
40
+        $conn = \Doctrine\DBAL\DriverManager::getConnection($options);
41
+        $this->assertEquals(\PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(\PDO::ATTR_ERRMODE));
42
+    }
43
+
44
+    /**
45
+     * @expectedException \Doctrine\DBAL\DBALException
46
+     */
47
+    public function testCheckParams()
48
+    {
49
+        $conn = \Doctrine\DBAL\DriverManager::getConnection(array());
50
+    }
51
+
52
+    /**
53
+     * @expectedException \Doctrine\DBAL\DBALException
54
+     */
55
+    public function testInvalidDriver()
56
+    {
57
+        $conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'invalid_driver'));
58
+    }
59
+
60
+    public function testCustomPlatform()
61
+    {
62
+        $mockPlatform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
63
+        $options = array(
64
+            'pdo' => new \PDO('sqlite::memory:'),
65
+            'platform' => $mockPlatform
66
+        );
67
+
68
+        $conn = \Doctrine\DBAL\DriverManager::getConnection($options);
69
+        $this->assertSame($mockPlatform, $conn->getDatabasePlatform());
70
+    }
71
+
72
+    public function testCustomWrapper()
73
+    {
74
+        $wrapperClass = 'Doctrine\Tests\Mocks\ConnectionMock';
75
+
76
+        $options = array(
77
+            'pdo' => new \PDO('sqlite::memory:'),
78
+            'wrapperClass' => $wrapperClass,
79
+        );
80
+
81
+        $conn = \Doctrine\DBAL\DriverManager::getConnection($options);
82
+        $this->assertInstanceOf($wrapperClass, $conn);
83
+    }
84
+
85
+    public function testInvalidWrapperClass()
86
+    {
87
+        $this->setExpectedException('\Doctrine\DBAL\DBALException');
88
+
89
+        $options = array(
90
+            'pdo' => new \PDO('sqlite::memory:'),
91
+            'wrapperClass' => 'stdClass',
92
+        );
93
+
94
+        $conn = \Doctrine\DBAL\DriverManager::getConnection($options);
95
+    }
96
+
97
+    public function testInvalidDriverClass()
98
+    {
99
+        $this->setExpectedException('\Doctrine\DBAL\DBALException');
100
+
101
+        $options = array(
102
+            'driverClass' => 'stdClass'
103
+        );
104
+
105
+        $conn = \Doctrine\DBAL\DriverManager::getConnection($options);
106
+    }
107
+
108
+    public function testValidDriverClass()
109
+    {
110
+        $options = array(
111
+            'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
112
+        );
113
+
114
+        $conn = \Doctrine\DBAL\DriverManager::getConnection($options);
115
+        $this->assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $conn->getDriver());
116
+    }
117
+}

+ 33 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php Ver fichero

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Events;
4
+
5
+use Doctrine\Tests\DbalTestCase;
6
+use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
7
+use Doctrine\DBAL\Event\ConnectionEventArgs;
8
+use Doctrine\DBAL\Events;
9
+
10
+require_once __DIR__ . '/../../TestInit.php';
11
+
12
+class MysqlSessionInitTest extends DbalTestCase
13
+{
14
+    public function testPostConnect()
15
+    {
16
+        $connectionMock = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
17
+        $connectionMock->expects($this->once())
18
+                       ->method('executeUpdate')
19
+                       ->with($this->equalTo("SET NAMES foo COLLATE bar"));
20
+
21
+        $eventArgs = new ConnectionEventArgs($connectionMock);
22
+
23
+
24
+        $listener = new MysqlSessionInit('foo', 'bar');
25
+        $listener->postConnect($eventArgs);
26
+    }
27
+
28
+    public function testGetSubscribedEvents()
29
+    {
30
+        $listener = new MysqlSessionInit();
31
+        $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
32
+    }
33
+}

+ 33 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php Ver fichero

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Events;
4
+
5
+use Doctrine\Tests\DbalTestCase;
6
+use Doctrine\DBAL\Event\Listeners\OracleSessionInit;
7
+use Doctrine\DBAL\Event\ConnectionEventArgs;
8
+use Doctrine\DBAL\Events;
9
+
10
+require_once __DIR__ . '/../../TestInit.php';
11
+
12
+class OracleSessionInitTest extends DbalTestCase
13
+{
14
+    public function testPostConnect()
15
+    {
16
+        $connectionMock = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
17
+        $connectionMock->expects($this->once())
18
+                       ->method('executeUpdate')
19
+                       ->with($this->isType('string'));
20
+
21
+        $eventArgs = new ConnectionEventArgs($connectionMock);
22
+
23
+
24
+        $listener = new OracleSessionInit();
25
+        $listener->postConnect($eventArgs);
26
+    }
27
+
28
+    public function testGetSubscribedEvents()
29
+    {
30
+        $listener = new OracleSessionInit();
31
+        $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
32
+    }
33
+}

+ 210 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php Ver fichero

@@ -0,0 +1,210 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional;
4
+
5
+use Doctrine\DBAL\ConnectionException;
6
+
7
+require_once __DIR__ . '/../../TestInit.php';
8
+
9
+class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
10
+{
11
+    public function setUp()
12
+    {
13
+        $this->resetSharedConn();
14
+        parent::setUp();
15
+    }
16
+
17
+    public function tearDown()
18
+    {
19
+        parent::tearDown();
20
+        $this->resetSharedConn();
21
+    }
22
+
23
+    public function testGetWrappedConnection()
24
+    {
25
+        $this->assertInstanceOf('Doctrine\DBAL\Driver\Connection', $this->_conn->getWrappedConnection());
26
+    }
27
+
28
+    public function testCommitWithRollbackOnlyThrowsException()
29
+    {
30
+        $this->_conn->beginTransaction();
31
+        $this->_conn->setRollbackOnly();
32
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException');
33
+        $this->_conn->commit();
34
+    }
35
+
36
+    public function testTransactionNestingBehavior()
37
+    {
38
+        try {
39
+            $this->_conn->beginTransaction();
40
+            $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
41
+            
42
+            try {
43
+                $this->_conn->beginTransaction();
44
+                $this->assertEquals(2, $this->_conn->getTransactionNestingLevel());
45
+                throw new \Exception;
46
+                $this->_conn->commit(); // never reached
47
+            } catch (\Exception $e) {
48
+                $this->_conn->rollback();
49
+                $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
50
+                //no rethrow                
51
+            }
52
+            $this->assertTrue($this->_conn->isRollbackOnly());
53
+
54
+            $this->_conn->commit(); // should throw exception
55
+            $this->fail('Transaction commit after failed nested transaction should fail.');
56
+        } catch (ConnectionException $e) {
57
+            $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
58
+            $this->_conn->rollback();
59
+            $this->assertEquals(0, $this->_conn->getTransactionNestingLevel());
60
+        }
61
+    }
62
+
63
+    public function testTransactionNestingBehaviorWithSavepoints()
64
+    {
65
+        if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) {
66
+            $this->markTestSkipped('This test requires the platform to support savepoints.');
67
+        }
68
+
69
+        $this->_conn->setNestTransactionsWithSavepoints(true);
70
+        try {
71
+            $this->_conn->beginTransaction();
72
+            $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
73
+
74
+            try {
75
+                $this->_conn->beginTransaction();
76
+                $this->assertEquals(2, $this->_conn->getTransactionNestingLevel());
77
+                $this->_conn->beginTransaction();
78
+                $this->assertEquals(3, $this->_conn->getTransactionNestingLevel());
79
+                $this->_conn->commit();
80
+                $this->assertEquals(2, $this->_conn->getTransactionNestingLevel());
81
+                throw new \Exception;
82
+                $this->_conn->commit(); // never reached
83
+            } catch (\Exception $e) {
84
+                $this->_conn->rollback();
85
+                $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
86
+                //no rethrow
87
+            }
88
+            $this->assertFalse($this->_conn->isRollbackOnly());
89
+            try {
90
+                $this->_conn->setNestTransactionsWithSavepoints(false);
91
+                $this->fail('Should not be able to disable savepoints in usage for nested transactions inside an open transaction.');
92
+            } catch (ConnectionException $e) {
93
+                $this->assertTrue($this->_conn->getNestTransactionsWithSavepoints());
94
+            }
95
+            $this->_conn->commit(); // should not throw exception
96
+        } catch (ConnectionException $e) {
97
+            $this->fail('Transaction commit after failed nested transaction should not fail when using savepoints.');
98
+            $this->_conn->rollback();
99
+        }
100
+    }
101
+
102
+    public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction()
103
+    {
104
+        if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) {
105
+            $this->markTestSkipped('This test requires the platform to support savepoints.');
106
+        }
107
+
108
+        $this->_conn->beginTransaction();
109
+        try {
110
+            $this->_conn->setNestTransactionsWithSavepoints(true);
111
+            $this->fail('An exception should have been thrown by chaning the nesting transaction behavior within an transaction.');
112
+        } catch(ConnectionException $e) {
113
+            $this->_conn->rollBack();
114
+        }
115
+    }
116
+
117
+    public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException()
118
+    {
119
+        if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
120
+            $this->markTestSkipped('This test requires the platform not to support savepoints.');
121
+        }
122
+
123
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
124
+
125
+        $this->_conn->setNestTransactionsWithSavepoints(true);
126
+    }
127
+
128
+    public function testCreateSavepointsNotSupportedThrowsException()
129
+    {
130
+        if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
131
+            $this->markTestSkipped('This test requires the platform not to support savepoints.');
132
+        }
133
+
134
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
135
+
136
+        $this->_conn->createSavepoint('foo');
137
+    }
138
+
139
+    public function testReleaseSavepointsNotSupportedThrowsException()
140
+    {
141
+        if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
142
+            $this->markTestSkipped('This test requires the platform not to support savepoints.');
143
+        }
144
+
145
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
146
+
147
+        $this->_conn->releaseSavepoint('foo');
148
+    }
149
+
150
+    public function testRollbackSavepointsNotSupportedThrowsException()
151
+    {
152
+        if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
153
+            $this->markTestSkipped('This test requires the platform not to support savepoints.');
154
+        }
155
+
156
+        $this->setExpectedException('Doctrine\DBAL\ConnectionException', "Savepoints are not supported by this driver.");
157
+
158
+        $this->_conn->rollbackSavepoint('foo');
159
+    }
160
+
161
+    public function testTransactionBehaviorWithRollback()
162
+    {
163
+        try {
164
+            $this->_conn->beginTransaction();
165
+            $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
166
+            
167
+            throw new \Exception;
168
+              
169
+            $this->_conn->commit(); // never reached
170
+        } catch (\Exception $e) {
171
+            $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
172
+            $this->_conn->rollback();
173
+            $this->assertEquals(0, $this->_conn->getTransactionNestingLevel());
174
+        }
175
+    }
176
+
177
+    public function testTransactionBehaviour()
178
+    {
179
+        try {
180
+            $this->_conn->beginTransaction();
181
+            $this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
182
+            $this->_conn->commit();
183
+        } catch (\Exception $e) {
184
+            $this->_conn->rollback();
185
+            $this->assertEquals(0, $this->_conn->getTransactionNestingLevel());
186
+        }
187
+
188
+        $this->assertEquals(0, $this->_conn->getTransactionNestingLevel());
189
+    }
190
+
191
+    public function testTransactionalWithException()
192
+    {
193
+        try {
194
+            $this->_conn->transactional(function($conn) {
195
+                $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
196
+                throw new \RuntimeException("Ooops!");
197
+            });
198
+        } catch (\RuntimeException $expected) {
199
+            $this->assertEquals(0, $this->_conn->getTransactionNestingLevel());
200
+        }
201
+    }
202
+
203
+    public function testTransactional()
204
+    {
205
+        $this->_conn->transactional(function($conn) {
206
+            /* @var $conn Connection */
207
+            $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
208
+        });
209
+    }
210
+}

+ 272 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php Ver fichero

@@ -0,0 +1,272 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional;
4
+
5
+use Doctrine\DBAL\Types\Type;
6
+use Doctrine\DBAL\Connection;
7
+use PDO;
8
+
9
+require_once __DIR__ . '/../../TestInit.php';
10
+
11
+class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
12
+{
13
+    public function setUp()
14
+    {
15
+        parent::setUp();
16
+
17
+        try {
18
+            /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
19
+            $table = new \Doctrine\DBAL\Schema\Table("fetch_table");
20
+            $table->addColumn('test_int', 'integer');
21
+            $table->addColumn('test_string', 'string');
22
+            $table->addColumn('test_datetime', 'datetime', array('notnull' => false));
23
+
24
+            $sm = $this->_conn->getSchemaManager();
25
+            $sm->createTable($table);
26
+
27
+            $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10'));
28
+        } catch(\Exception $e) {
29
+            
30
+        }
31
+    }
32
+
33
+    public function testPrepareWithBindValue()
34
+    {
35
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
36
+        $stmt = $this->_conn->prepare($sql);
37
+        $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
38
+
39
+        $stmt->bindValue(1, 1);
40
+        $stmt->bindValue(2, 'foo');
41
+        $stmt->execute();
42
+
43
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
44
+        $row = array_change_key_case($row, \CASE_LOWER);
45
+        $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
46
+    }
47
+
48
+    public function testPrepareWithBindParam()
49
+    {
50
+        $paramInt = 1;
51
+        $paramStr = 'foo';
52
+
53
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
54
+        $stmt = $this->_conn->prepare($sql);
55
+        $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
56
+
57
+        $stmt->bindParam(1, $paramInt);
58
+        $stmt->bindParam(2, $paramStr);
59
+        $stmt->execute();
60
+
61
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
62
+        $row = array_change_key_case($row, \CASE_LOWER);
63
+        $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
64
+    }
65
+
66
+    public function testPrepareWithFetchAll()
67
+    {
68
+        $paramInt = 1;
69
+        $paramStr = 'foo';
70
+
71
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
72
+        $stmt = $this->_conn->prepare($sql);
73
+        $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
74
+
75
+        $stmt->bindParam(1, $paramInt);
76
+        $stmt->bindParam(2, $paramStr);
77
+        $stmt->execute();
78
+
79
+        $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
80
+        $rows[0] = array_change_key_case($rows[0], \CASE_LOWER);
81
+        $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]);
82
+    }
83
+
84
+    public function testPrepareWithFetchColumn()
85
+    {
86
+        $paramInt = 1;
87
+        $paramStr = 'foo';
88
+
89
+        $sql = "SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?";
90
+        $stmt = $this->_conn->prepare($sql);
91
+        $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
92
+
93
+        $stmt->bindParam(1, $paramInt);
94
+        $stmt->bindParam(2, $paramStr);
95
+        $stmt->execute();
96
+
97
+        $column = $stmt->fetchColumn();
98
+        $this->assertEquals(1, $column);
99
+    }
100
+
101
+    public function testPrepareWithQuoted()
102
+    {
103
+        $table = 'fetch_table';
104
+        $paramInt = 1;
105
+        $paramStr = 'foo';
106
+
107
+        $sql = "SELECT test_int, test_string FROM " . $this->_conn->quoteIdentifier($table) . " ".
108
+               "WHERE test_int = " . $this->_conn->quote($paramInt) . " AND test_string = " . $this->_conn->quote($paramStr);
109
+        $stmt = $this->_conn->prepare($sql);
110
+        $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
111
+    }
112
+
113
+    public function testPrepareWithExecuteParams()
114
+    {
115
+        $paramInt = 1;
116
+        $paramStr = 'foo';
117
+
118
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
119
+        $stmt = $this->_conn->prepare($sql);
120
+        $this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
121
+        $stmt->execute(array($paramInt, $paramStr));
122
+
123
+        $row = $stmt->fetch(\PDO::FETCH_ASSOC);
124
+        $row = array_change_key_case($row, \CASE_LOWER);
125
+        $this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
126
+    }
127
+
128
+    public function testFetchAll()
129
+    {
130
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
131
+        $data = $this->_conn->fetchAll($sql, array(1, 'foo'));
132
+
133
+        $this->assertEquals(1, count($data));
134
+
135
+        $row = $data[0];
136
+        $this->assertEquals(2, count($row));
137
+
138
+        $row = array_change_key_case($row, \CASE_LOWER);
139
+        $this->assertEquals(1, $row['test_int']);
140
+        $this->assertEquals('foo', $row['test_string']);
141
+    }
142
+
143
+    public function testFetchRow()
144
+    {
145
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
146
+        $row = $this->_conn->fetchAssoc($sql, array(1, 'foo'));
147
+
148
+        $row = array_change_key_case($row, \CASE_LOWER);
149
+        
150
+        $this->assertEquals(1, $row['test_int']);
151
+        $this->assertEquals('foo', $row['test_string']);
152
+    }
153
+
154
+    public function testFetchArray()
155
+    {
156
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
157
+        $row = $this->_conn->fetchArray($sql, array(1, 'foo'));
158
+
159
+        $this->assertEquals(1, $row[0]);
160
+        $this->assertEquals('foo', $row[1]);
161
+    }
162
+
163
+    public function testFetchColumn()
164
+    {
165
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
166
+        $testInt = $this->_conn->fetchColumn($sql, array(1, 'foo'), 0);
167
+
168
+        $this->assertEquals(1, $testInt);
169
+
170
+        $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
171
+        $testString = $this->_conn->fetchColumn($sql, array(1, 'foo'), 1);
172
+
173
+        $this->assertEquals('foo', $testString);
174
+    }
175
+
176
+    /**
177
+     * @group DDC-697
178
+     */
179
+    public function testExecuteQueryBindDateTimeType()
180
+    {
181
+        $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
182
+        $stmt = $this->_conn->executeQuery($sql,
183
+            array(1 => new \DateTime('2010-01-01 10:10:10')),
184
+            array(1 => Type::DATETIME)
185
+        );
186
+
187
+        $this->assertEquals(1, $stmt->fetchColumn());
188
+    }
189
+
190
+    /**
191
+     * @group DDC-697
192
+     */
193
+    public function testExecuteUpdateBindDateTimeType()
194
+    {
195
+        $datetime = new \DateTime('2010-02-02 20:20:20');
196
+
197
+        $sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
198
+        $affectedRows = $this->_conn->executeUpdate($sql,
199
+            array(1 => 1,               2 => 'foo',             3 => $datetime),
200
+            array(1 => PDO::PARAM_INT,  2 => PDO::PARAM_STR,    3 => Type::DATETIME)
201
+        );
202
+
203
+        $this->assertEquals(1, $affectedRows);
204
+        $this->assertEquals(1, $this->_conn->executeQuery(
205
+            'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?',
206
+            array(1 => $datetime),
207
+            array(1 => Type::DATETIME)
208
+        )->fetchColumn());
209
+    }
210
+
211
+    /**
212
+     * @group DDC-697
213
+     */
214
+    public function testPrepareQueryBindValueDateTimeType()
215
+    {
216
+        $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
217
+        $stmt = $this->_conn->prepare($sql);
218
+        $stmt->bindValue(1, new \DateTime('2010-01-01 10:10:10'), Type::DATETIME);
219
+        $stmt->execute();
220
+
221
+        $this->assertEquals(1, $stmt->fetchColumn());
222
+    }
223
+    
224
+    /**
225
+     * @group DBAL-78
226
+     */
227
+    public function testNativeArrayListSupport()
228
+    {
229
+        for ($i = 100; $i < 110; $i++) {
230
+            $this->_conn->insert('fetch_table', array('test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10'));
231
+        }
232
+        
233
+        $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_int IN (?)',
234
+            array(array(100, 101, 102, 103, 104)), array(Connection::PARAM_INT_ARRAY));
235
+        
236
+        $data = $stmt->fetchAll(PDO::FETCH_NUM);
237
+        $this->assertEquals(5, count($data));
238
+        $this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data);
239
+        
240
+        $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_string IN (?)',
241
+            array(array('foo100', 'foo101', 'foo102', 'foo103', 'foo104')), array(Connection::PARAM_STR_ARRAY));
242
+        
243
+        $data = $stmt->fetchAll(PDO::FETCH_NUM);
244
+        $this->assertEquals(5, count($data));
245
+        $this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data);
246
+    }
247
+
248
+    /**
249
+     * @group DDC-1014
250
+     */
251
+    public function testDateArithmetics()
252
+    {
253
+        $p = $this->_conn->getDatabasePlatform();
254
+        $sql = 'SELECT ';
255
+        $sql .= $p->getDateDiffExpression('test_datetime', $p->getCurrentTimestampSQL()) .' AS diff, ';
256
+        $sql .= $p->getDateAddDaysExpression('test_datetime', 10) .' AS add_days, ';
257
+        $sql .= $p->getDateSubDaysExpression('test_datetime', 10) .' AS sub_days, ';
258
+        $sql .= $p->getDateAddMonthExpression('test_datetime', 2) .' AS add_month, ';
259
+        $sql .= $p->getDateSubMonthExpression('test_datetime', 2) .' AS sub_month ';
260
+        $sql .= 'FROM fetch_table';
261
+
262
+        $row = $this->_conn->fetchAssoc($sql);
263
+        $row = array_change_key_case($row, CASE_LOWER);
264
+
265
+        $diff = floor( (strtotime('2010-01-01')-time()) / 3600 / 24);
266
+        $this->assertEquals($diff, (int)$row['diff'], "Date difference should be approx. ".$diff." days.", 1);
267
+        $this->assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])), "Adding date should end up on 2010-01-11");
268
+        $this->assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])), "Subtracting date should end up on 2009-12-22");
269
+        $this->assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])), "Adding month should end up on 2010-03-01");
270
+        $this->assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])), "Adding month should end up on 2009-11-01");
271
+    }
272
+}

+ 54 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php Ver fichero

@@ -0,0 +1,54 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional;
4
+
5
+require_once __DIR__ . '/../../TestInit.php';
6
+
7
+class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase
8
+{
9
+    public function testLogExecuteQuery()
10
+    {
11
+        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
12
+
13
+        $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
14
+        $logMock->expects($this->at(0))
15
+                ->method('startQuery')
16
+                ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
17
+        $logMock->expects($this->at(1))
18
+                ->method('stopQuery');
19
+        $this->_conn->getConfiguration()->setSQLLogger($logMock);
20
+        $this->_conn->executeQuery($sql, array());
21
+    }
22
+
23
+    public function testLogExecuteUpdate()
24
+    {
25
+        $this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).');
26
+
27
+        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
28
+
29
+        $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
30
+        $logMock->expects($this->at(0))
31
+                ->method('startQuery')
32
+                ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
33
+        $logMock->expects($this->at(1))
34
+                ->method('stopQuery');
35
+        $this->_conn->getConfiguration()->setSQLLogger($logMock);
36
+        $this->_conn->executeUpdate($sql, array());
37
+    }
38
+
39
+    public function testLogPrepareExecute()
40
+    {
41
+        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
42
+
43
+        $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
44
+        $logMock->expects($this->once())
45
+                ->method('startQuery')
46
+                ->with($this->equalTo($sql), $this->equalTo(array()));
47
+        $logMock->expects($this->at(1))
48
+                ->method('stopQuery');
49
+        $this->_conn->getConfiguration()->setSQLLogger($logMock);
50
+
51
+        $stmt = $this->_conn->prepare($sql);
52
+        $stmt->execute();
53
+    }
54
+}

+ 110 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php Ver fichero

@@ -0,0 +1,110 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional;
4
+
5
+use Doctrine\DBAL\Types\Type;
6
+use Doctrine\DBAL\Connection;
7
+use PDO;
8
+
9
+require_once __DIR__ . '/../../TestInit.php';
10
+
11
+class ModifyLimitQueryTest extends \Doctrine\Tests\DbalFunctionalTestCase
12
+{
13
+    private static $tableCreated = false;
14
+    
15
+    public function setUp()
16
+    {
17
+        parent::setUp();
18
+
19
+        if (!self::$tableCreated) {
20
+            /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
21
+            $table = new \Doctrine\DBAL\Schema\Table("modify_limit_table");
22
+            $table->addColumn('test_int', 'integer');
23
+            
24
+            $table2 = new \Doctrine\DBAL\Schema\Table("modify_limit_table2");
25
+            $table2->addColumn('test_int', 'integer');
26
+
27
+            $sm = $this->_conn->getSchemaManager();
28
+            $sm->createTable($table);
29
+            $sm->createTable($table2);
30
+            self::$tableCreated = true;
31
+        }
32
+        $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table'));
33
+        $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2'));
34
+    }
35
+    
36
+    public function testModifyLimitQuerySimpleQuery()
37
+    {
38
+        $this->_conn->insert('modify_limit_table', array('test_int' => 1));
39
+        $this->_conn->insert('modify_limit_table', array('test_int' => 2));
40
+        $this->_conn->insert('modify_limit_table', array('test_int' => 3));
41
+        $this->_conn->insert('modify_limit_table', array('test_int' => 4));
42
+        
43
+        $sql = "SELECT * FROM modify_limit_table";
44
+        
45
+        $this->assertLimitResult(array(1, 2, 3, 4), $sql, 10, 0);
46
+        $this->assertLimitResult(array(1, 2), $sql, 2, 0);
47
+        $this->assertLimitResult(array(3, 4), $sql, 2, 2);
48
+    }
49
+    
50
+    public function testModifyLimitQueryJoinQuery()
51
+    {
52
+        $this->_conn->insert('modify_limit_table', array('test_int' => 1));
53
+        $this->_conn->insert('modify_limit_table', array('test_int' => 2));
54
+        
55
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
56
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
57
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
58
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
59
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
60
+        
61
+        $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";
62
+        
63
+        $this->assertLimitResult(array(1, 1, 1, 2, 2), $sql, 10, 0);
64
+        $this->assertLimitResult(array(1, 1, 1), $sql, 3, 0);
65
+        $this->assertLimitResult(array(2, 2), $sql, 2, 3);
66
+    }
67
+    
68
+    public function testModifyLimitQueryOrderBy()
69
+    {
70
+        $this->_conn->insert('modify_limit_table', array('test_int' => 1));
71
+        $this->_conn->insert('modify_limit_table', array('test_int' => 2));
72
+        $this->_conn->insert('modify_limit_table', array('test_int' => 3));
73
+        $this->_conn->insert('modify_limit_table', array('test_int' => 4));
74
+        
75
+        $sql = "SELECT * FROM modify_limit_table ORDER BY test_int DESC";
76
+        
77
+        $this->assertLimitResult(array(4, 3, 2, 1), $sql, 10, 0);
78
+        $this->assertLimitResult(array(4, 3), $sql, 2, 0);
79
+        $this->assertLimitResult(array(2, 1), $sql, 2, 2);
80
+    }
81
+    
82
+    public function testModifyLimitQueryGroupBy()
83
+    {
84
+        $this->_conn->insert('modify_limit_table', array('test_int' => 1));
85
+        $this->_conn->insert('modify_limit_table', array('test_int' => 2));
86
+        
87
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
88
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
89
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
90
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
91
+        $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
92
+        
93
+        $sql = "SELECT modify_limit_table.test_int FROM modify_limit_table " .
94
+               "INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ".
95
+               "GROUP BY modify_limit_table.test_int";
96
+        $this->assertLimitResult(array(1, 2), $sql, 10, 0);
97
+        $this->assertLimitResult(array(1), $sql, 1, 0);
98
+        $this->assertLimitResult(array(2), $sql, 1, 1);
99
+    }
100
+    
101
+    public function assertLimitResult($expectedResults, $sql, $limit, $offset)
102
+    {
103
+        $p = $this->_conn->getDatabasePlatform();
104
+        $data = array();
105
+        foreach ($this->_conn->fetchAll($p->modifyLimitQuery($sql, $limit, $offset)) AS $row) {
106
+            $data[] = current($row);
107
+        }
108
+        $this->assertEquals($expectedResults, $data);
109
+    }
110
+}

+ 90 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php Ver fichero

@@ -0,0 +1,90 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional;
4
+
5
+use Doctrine\DBAL\Types\Type;
6
+use Doctrine\DBAL\Connection;
7
+use Doctrine\DBAL\DriverManager;
8
+use PDO;
9
+
10
+require_once __DIR__ . '/../../TestInit.php';
11
+
12
+/**
13
+ * @group DBAL-56
14
+ */
15
+class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
16
+{
17
+    static private $hasTable = false;
18
+    
19
+    private $portableConnection;
20
+    
21
+    public function tearDown()
22
+    {
23
+        if ($this->portableConnection) {
24
+            $this->portableConnection->close();
25
+        }
26
+    }
27
+    
28
+    private function getPortableConnection($portabilityMode = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL, $case = \PDO::CASE_LOWER)
29
+    {
30
+        if (!$this->portableConnection) {
31
+            $params = $this->_conn->getParams();
32
+            $params['wrapperClass'] = 'Doctrine\DBAL\Portability\Connection';
33
+            $params['portability'] = $portabilityMode;
34
+            $params['fetch_case'] = $case;
35
+            $this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager());
36
+
37
+            try {
38
+                /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
39
+                $table = new \Doctrine\DBAL\Schema\Table("portability_table");
40
+                $table->addColumn('Test_Int', 'integer');
41
+                $table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32));
42
+                $table->addColumn('Test_Null', 'string', array('notnull' => false));
43
+
44
+                $sm = $this->portableConnection->getSchemaManager();
45
+                $sm->createTable($table);
46
+
47
+                $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => ''));
48
+                $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo  ', 'Test_Null' => null));
49
+            } catch(\Exception $e) {
50
+                
51
+            }
52
+        }
53
+        
54
+        return $this->portableConnection;
55
+    }
56
+    
57
+    public function testFullFetchMode()
58
+    {
59
+        $rows = $this->getPortableConnection()->fetchAll('SELECT * FROM portability_table');
60
+        $this->assertFetchResultRows($rows);
61
+        
62
+        $stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table');
63
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
64
+            $this->assertFetchResultRow($row);
65
+        }
66
+        
67
+        $stmt = $this->getPortableConnection()->prepare('SELECT * FROM portability_table');
68
+        $stmt->execute();
69
+        
70
+        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
71
+            $this->assertFetchResultRow($row);
72
+        }
73
+    }
74
+    
75
+    public function assertFetchResultRows($rows)
76
+    {
77
+        $this->assertEquals(2, count($rows));
78
+        foreach ($rows AS $row) {
79
+            $this->assertFetchResultRow($row);
80
+        }
81
+    }
82
+    
83
+    public function assertFetchResultRow($row)
84
+    {
85
+        $this->assertEquals(1, $row['test_int']);
86
+        $this->assertArrayHasKey('test_string', $row, "Case should be lowered.");
87
+        $this->assertEquals(3, strlen($row['test_string']), "test_string should be rtrimed to length of three for CHAR(32) column.");
88
+        $this->assertNull($row['test_null']);
89
+    }
90
+}

+ 12 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php Ver fichero

@@ -0,0 +1,12 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional\Schema;
4
+
5
+use Doctrine\DBAL\Schema;
6
+
7
+require_once __DIR__ . '/../../../TestInit.php';
8
+
9
+class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase
10
+{
11
+
12
+}

+ 12 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/MsSqlSchemaManagerTest.php Ver fichero

@@ -0,0 +1,12 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional\Schema;
4
+
5
+use Doctrine\DBAL\Schema;
6
+
7
+require_once __DIR__ . '/../../../TestInit.php';
8
+ 
9
+class MsSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
10
+{
11
+    
12
+}

+ 50 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php Ver fichero

@@ -0,0 +1,50 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional\Schema;
4
+
5
+use Doctrine\DBAL\Schema\Table;
6
+use Doctrine\DBAL\Schema\Schema;
7
+
8
+require_once __DIR__ . '/../../../TestInit.php';
9
+ 
10
+class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
11
+{
12
+    public function testSwitchPrimaryKeyColumns()
13
+    {
14
+        $tableOld = new Table("switch_primary_key_columns");
15
+        $tableOld->addColumn('foo_id', 'integer');
16
+        $tableOld->addColumn('bar_id', 'integer');
17
+        $tableNew = clone $tableOld;
18
+
19
+        $this->_sm->createTable($tableOld);
20
+        $tableFetched = $this->_sm->listTableDetails("switch_primary_key_columns");
21
+        $tableNew = clone $tableFetched;
22
+        $tableNew->setPrimaryKey(array('bar_id', 'foo_id'));
23
+
24
+        $comparator = new \Doctrine\DBAL\Schema\Comparator;
25
+        $this->_sm->alterTable($comparator->diffTable($tableFetched, $tableNew));
26
+    }
27
+
28
+    public function testDiffTableBug()
29
+    {
30
+        $schema = new Schema();
31
+        $table = $schema->createTable('diffbug_routing_translations');
32
+        $table->addColumn('id', 'integer');
33
+        $table->addColumn('route', 'string');
34
+        $table->addColumn('locale', 'string');
35
+        $table->addColumn('attribute', 'string');
36
+        $table->addColumn('localized_value', 'string');
37
+        $table->addColumn('original_value', 'string');
38
+        $table->setPrimaryKey(array('id'));
39
+        $table->addUniqueIndex(array('route', 'locale', 'attribute'));
40
+        $table->addIndex(array('localized_value')); // this is much more selective than the unique index
41
+
42
+        $this->_sm->createTable($table);
43
+        $tableFetched = $this->_sm->listTableDetails("diffbug_routing_translations");
44
+        
45
+        $comparator = new \Doctrine\DBAL\Schema\Comparator;
46
+        $diff = $comparator->diffTable($tableFetched, $table);
47
+
48
+        $this->assertFalse($diff, "no changes expected.");
49
+    }
50
+}

+ 39 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php Ver fichero

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional\Schema;
4
+
5
+use Doctrine\DBAL\Schema;
6
+
7
+require_once __DIR__ . '/../../../TestInit.php';
8
+ 
9
+class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
10
+{
11
+    public function setUp()
12
+    {
13
+        parent::setUp();
14
+
15
+        if(!isset($GLOBALS['db_username'])) {
16
+            $this->markTestSkipped('Foo');
17
+        }
18
+
19
+        $username = $GLOBALS['db_username'];
20
+
21
+        $query = "GRANT ALL PRIVILEGES TO ".$username;
22
+
23
+        $conn = \Doctrine\Tests\TestUtil::getTempConnection();
24
+        $conn->executeUpdate($query);
25
+    }
26
+
27
+    public function testRenameTable()
28
+    {
29
+        $this->_sm->tryMethod('DropTable', 'list_tables_test');
30
+        $this->_sm->tryMethod('DropTable', 'list_tables_test_new_name');
31
+
32
+        $this->createTestTable('list_tables_test');
33
+        $this->_sm->renameTable('list_tables_test', 'list_tables_test_new_name');
34
+
35
+        $tables = $this->_sm->listTables();
36
+
37
+        $this->assertHasTable($tables, 'list_tables_test_new_name');
38
+    }
39
+}

+ 173 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php Ver fichero

@@ -0,0 +1,173 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional\Schema;
4
+
5
+use Doctrine\DBAL\Schema;
6
+use Doctrine\DBAL\Types\Type;
7
+use Doctrine\DBAL\Platforms\AbstractPlatform;
8
+
9
+require_once __DIR__ . '/../../../TestInit.php';
10
+ 
11
+class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
12
+{
13
+    /**
14
+     * @group DBAL-21
15
+     */
16
+    public function testSupportDomainTypeFallback()
17
+    {
18
+        $createDomainTypeSQL = "CREATE DOMAIN MyMoney AS DECIMAL(18,2)";
19
+        $this->_conn->exec($createDomainTypeSQL);
20
+
21
+        $createTableSQL = "CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)";
22
+        $this->_conn->exec($createTableSQL);
23
+
24
+        $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test');
25
+        $this->assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $table->getColumn('value')->getType());
26
+
27
+        Type::addType('MyMoney', 'Doctrine\Tests\DBAL\Functional\Schema\MoneyType');
28
+        $this->_conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'MyMoney');
29
+
30
+        $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test');
31
+        $this->assertInstanceOf('Doctrine\Tests\DBAL\Functional\Schema\MoneyType', $table->getColumn('value')->getType());
32
+    }
33
+
34
+    /**
35
+     * @group DBAL-37
36
+     */
37
+    public function testDetectsAutoIncrement()
38
+    {
39
+        $autoincTable = new \Doctrine\DBAL\Schema\Table('autoinc_table');
40
+        $column = $autoincTable->addColumn('id', 'integer');
41
+        $column->setAutoincrement(true);
42
+        $this->_sm->createTable($autoincTable);
43
+        $autoincTable = $this->_sm->listTableDetails('autoinc_table');
44
+
45
+        $this->assertTrue($autoincTable->getColumn('id')->getAutoincrement());
46
+    }
47
+
48
+    /**
49
+     * @group DBAL-37
50
+     */
51
+    public function testAlterTableAutoIncrementAdd()
52
+    {
53
+        $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_add');
54
+        $column = $tableFrom->addColumn('id', 'integer');
55
+        $this->_sm->createTable($tableFrom);
56
+        $tableFrom = $this->_sm->listTableDetails('autoinc_table_add');
57
+        $this->assertFalse($tableFrom->getColumn('id')->getAutoincrement());
58
+
59
+        $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_add');
60
+        $column = $tableTo->addColumn('id', 'integer');
61
+        $column->setAutoincrement(true);
62
+
63
+        $c = new \Doctrine\DBAL\Schema\Comparator();
64
+        $diff = $c->diffTable($tableFrom, $tableTo);
65
+        $sql = $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff);
66
+        $this->assertEquals(array(
67
+            "CREATE SEQUENCE autoinc_table_add_id_seq",
68
+            "SELECT setval('autoinc_table_add_id_seq', (SELECT MAX(id) FROM autoinc_table_add))",
69
+            "ALTER TABLE autoinc_table_add ALTER id SET DEFAULT nextval('autoinc_table_add_id_seq')",
70
+        ), $sql);
71
+
72
+        $this->_sm->alterTable($diff);
73
+        $tableFinal = $this->_sm->listTableDetails('autoinc_table_add');
74
+        $this->assertTrue($tableFinal->getColumn('id')->getAutoincrement());
75
+    }
76
+
77
+    /**
78
+     * @group DBAL-37
79
+     */
80
+    public function testAlterTableAutoIncrementDrop()
81
+    {
82
+        $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop');
83
+        $column = $tableFrom->addColumn('id', 'integer');
84
+        $column->setAutoincrement(true);
85
+        $this->_sm->createTable($tableFrom);
86
+        $tableFrom = $this->_sm->listTableDetails('autoinc_table_drop');
87
+        $this->assertTrue($tableFrom->getColumn('id')->getAutoincrement());
88
+
89
+        $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop');
90
+        $column = $tableTo->addColumn('id', 'integer');
91
+
92
+        $c = new \Doctrine\DBAL\Schema\Comparator();
93
+        $diff = $c->diffTable($tableFrom, $tableTo);
94
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $diff, "There should be a difference and not false being returned from the table comparison");
95
+        $this->assertEquals(array("ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT"), $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff));
96
+
97
+        $this->_sm->alterTable($diff);
98
+        $tableFinal = $this->_sm->listTableDetails('autoinc_table_drop');
99
+        $this->assertFalse($tableFinal->getColumn('id')->getAutoincrement());
100
+    }
101
+
102
+    /**
103
+     * @group DBAL-75
104
+     */
105
+    public function testTableWithSchema()
106
+    {
107
+        $this->_conn->exec('CREATE SCHEMA nested');
108
+
109
+        $nestedRelatedTable = new \Doctrine\DBAL\Schema\Table('nested.schemarelated');
110
+        $column = $nestedRelatedTable->addColumn('id', 'integer');
111
+        $column->setAutoincrement(true);
112
+        $nestedRelatedTable->setPrimaryKey(array('id'));
113
+
114
+        $nestedSchemaTable = new \Doctrine\DBAL\Schema\Table('nested.schematable');
115
+        $column = $nestedSchemaTable->addColumn('id', 'integer');
116
+        $column->setAutoincrement(true);
117
+        $nestedSchemaTable->setPrimaryKey(array('id'));
118
+        $nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, array('id'), array('id'));
119
+        
120
+        $this->_sm->createTable($nestedRelatedTable);
121
+        $this->_sm->createTable($nestedSchemaTable);
122
+
123
+        $tables = $this->_sm->listTableNames();
124
+        $this->assertContains('nested.schematable', $tables, "The table should be detected with its non-public schema.");
125
+
126
+        $nestedSchemaTable = $this->_sm->listTableDetails('nested.schematable');
127
+        $this->assertTrue($nestedSchemaTable->hasColumn('id'));
128
+        $this->assertEquals(array('id'), $nestedSchemaTable->getPrimaryKey()->getColumns());
129
+
130
+        $relatedFks = $nestedSchemaTable->getForeignKeys();
131
+        $this->assertEquals(1, count($relatedFks));
132
+        $relatedFk = array_pop($relatedFks);
133
+        $this->assertEquals("nested.schemarelated", $relatedFk->getForeignTableName());
134
+    }
135
+
136
+    /**
137
+     * @group DBAL-91
138
+     * @group DBAL-88
139
+     */
140
+    public function testReturnQuotedAssets()
141
+    {
142
+        $sql = 'create table dbal91_something ( id integer  CONSTRAINT id_something PRIMARY KEY NOT NULL  ,"table"   integer );';
143
+        $this->_conn->exec($sql);
144
+
145
+        $sql = 'ALTER TABLE dbal91_something ADD CONSTRAINT something_input FOREIGN KEY( "table" ) REFERENCES dbal91_something ON UPDATE CASCADE;';
146
+        $this->_conn->exec($sql);
147
+
148
+        $table = $this->_sm->listTableDetails('dbal91_something');
149
+
150
+        $this->assertEquals(
151
+            array(
152
+                "CREATE TABLE dbal91_something (id INT NOT NULL, table INT DEFAULT NULL, PRIMARY KEY(id))",
153
+                "CREATE INDEX IDX_A9401304ECA7352B ON dbal91_something (\"table\")",
154
+            ),
155
+            $this->_conn->getDatabasePlatform()->getCreateTableSQL($table)
156
+        );
157
+    }
158
+}
159
+
160
+class MoneyType extends Type
161
+{
162
+
163
+    public function getName()
164
+    {
165
+        return "MyMoney";
166
+    }
167
+
168
+    public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
169
+    {
170
+        return 'MyMoney';
171
+    }
172
+
173
+}

+ 525 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php Ver fichero

@@ -0,0 +1,525 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional\Schema;
4
+
5
+use Doctrine\DBAL\Types\Type,
6
+    Doctrine\DBAL\Schema\AbstractSchemaManager;
7
+use Doctrine\DBAL\Platforms\AbstractPlatform;
8
+
9
+require_once __DIR__ . '/../../../TestInit.php';
10
+
11
+class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTestCase
12
+{
13
+    /**
14
+     * @var \Doctrine\DBAL\Schema\AbstractSchemaManager
15
+     */
16
+    protected $_sm;
17
+
18
+    protected function setUp()
19
+    {
20
+        parent::setUp();
21
+
22
+        $class = get_class($this);
23
+        $e = explode('\\', $class);
24
+        $testClass = end($e);
25
+        $dbms = strtolower(str_replace('SchemaManagerTest', null, $testClass));
26
+
27
+        if ($this->_conn->getDatabasePlatform()->getName() !== $dbms) {
28
+            $this->markTestSkipped('The ' . $testClass .' requires the use of ' . $dbms);
29
+        }
30
+
31
+        $this->_sm = $this->_conn->getSchemaManager();
32
+    }
33
+
34
+    public function testListSequences()
35
+    {
36
+        if(!$this->_conn->getDatabasePlatform()->supportsSequences()) {
37
+            $this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.');
38
+        }
39
+
40
+        $sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10);
41
+        $this->_sm->createSequence($sequence);
42
+        
43
+        $sequences = $this->_sm->listSequences();
44
+        
45
+        $this->assertInternalType('array', $sequences, 'listSequences() should return an array.');
46
+
47
+        $foundSequence = null;
48
+        foreach($sequences AS $sequence) {
49
+            $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $sequence, 'Array elements of listSequences() should be Sequence instances.');
50
+            if(strtolower($sequence->getName()) == 'list_sequences_test_seq') {
51
+                $foundSequence = $sequence;
52
+            }
53
+        }
54
+
55
+        $this->assertNotNull($foundSequence, "Sequence with name 'list_sequences_test_seq' was not found.");
56
+        $this->assertEquals(20, $foundSequence->getAllocationSize(), "Allocation Size is expected to be 20.");
57
+        $this->assertEquals(10, $foundSequence->getInitialValue(), "Initial Value is expected to be 10.");
58
+    }
59
+
60
+    public function testListDatabases()
61
+    {
62
+        if (!$this->_sm->getDatabasePlatform()->supportsCreateDropDatabase()) {
63
+            $this->markTestSkipped('Cannot drop Database client side with this Driver.');
64
+        }
65
+
66
+        $this->_sm->dropAndCreateDatabase('test_create_database');
67
+        $databases = $this->_sm->listDatabases();
68
+
69
+        $databases = \array_map('strtolower', $databases);
70
+        
71
+        $this->assertEquals(true, \in_array('test_create_database', $databases));
72
+    }
73
+
74
+    public function testListTables()
75
+    {
76
+        $this->createTestTable('list_tables_test');
77
+        $tables = $this->_sm->listTables();
78
+
79
+        $this->assertInternalType('array', $tables);
80
+        $this->assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'.");
81
+
82
+        $foundTable = false;
83
+        foreach ($tables AS $table) {
84
+            $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table);
85
+            if (strtolower($table->getName()) == 'list_tables_test') {
86
+                $foundTable = true;
87
+
88
+                $this->assertTrue($table->hasColumn('id'));
89
+                $this->assertTrue($table->hasColumn('test'));
90
+                $this->assertTrue($table->hasColumn('foreign_key_test'));
91
+            }
92
+        }
93
+
94
+        $this->assertTrue( $foundTable , "The 'list_tables_test' table has to be found.");
95
+    }
96
+
97
+    public function createListTableColumns()
98
+    {
99
+        $table = new \Doctrine\DBAL\Schema\Table('list_table_columns');
100
+        $table->addColumn('id', 'integer', array('notnull' => true));
101
+        $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false));
102
+        $table->addColumn('foo', 'text', array('notnull' => true));
103
+        $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false));
104
+        $table->addColumn('baz1', 'datetime');
105
+        $table->addColumn('baz2', 'time');
106
+        $table->addColumn('baz3', 'date');
107
+
108
+        return $table;
109
+    }
110
+
111
+    public function testListTableColumns()
112
+    {
113
+        $table = $this->createListTableColumns();
114
+
115
+        $this->_sm->dropAndCreateTable($table);
116
+
117
+        $columns = $this->_sm->listTableColumns('list_table_columns');
118
+
119
+        $this->assertArrayHasKey('id', $columns);
120
+        $this->assertEquals('id',   strtolower($columns['id']->getname()));
121
+        $this->assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype());
122
+        $this->assertEquals(false,  $columns['id']->getunsigned());
123
+        $this->assertEquals(true,   $columns['id']->getnotnull());
124
+        $this->assertEquals(null,   $columns['id']->getdefault());
125
+        $this->assertInternalType('array',  $columns['id']->getPlatformOptions());
126
+
127
+        $this->assertArrayHasKey('test', $columns);
128
+        $this->assertEquals('test', strtolower($columns['test']->getname()));
129
+        $this->assertInstanceOf('Doctrine\DBAL\Types\StringType', $columns['test']->gettype());
130
+        $this->assertEquals(255,    $columns['test']->getlength());
131
+        $this->assertEquals(false,  $columns['test']->getfixed());
132
+        $this->assertEquals(false,  $columns['test']->getnotnull());
133
+        $this->assertEquals(null,   $columns['test']->getdefault());
134
+        $this->assertInternalType('array',  $columns['test']->getPlatformOptions());
135
+
136
+        $this->assertEquals('foo',  strtolower($columns['foo']->getname()));
137
+        $this->assertInstanceOf('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype());
138
+        $this->assertEquals(false,  $columns['foo']->getunsigned());
139
+        $this->assertEquals(false,  $columns['foo']->getfixed());
140
+        $this->assertEquals(true,   $columns['foo']->getnotnull());
141
+        $this->assertEquals(null,   $columns['foo']->getdefault());
142
+        $this->assertInternalType('array',  $columns['foo']->getPlatformOptions());
143
+
144
+        $this->assertEquals('bar',  strtolower($columns['bar']->getname()));
145
+        $this->assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype());
146
+        $this->assertEquals(null,   $columns['bar']->getlength());
147
+        $this->assertEquals(10,     $columns['bar']->getprecision());
148
+        $this->assertEquals(4,      $columns['bar']->getscale());
149
+        $this->assertEquals(false,  $columns['bar']->getunsigned());
150
+        $this->assertEquals(false,  $columns['bar']->getfixed());
151
+        $this->assertEquals(false,  $columns['bar']->getnotnull());
152
+        $this->assertEquals(null,   $columns['bar']->getdefault());
153
+        $this->assertInternalType('array',  $columns['bar']->getPlatformOptions());
154
+
155
+        $this->assertEquals('baz1', strtolower($columns['baz1']->getname()));
156
+        $this->assertInstanceOf('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype());
157
+        $this->assertEquals(true,   $columns['baz1']->getnotnull());
158
+        $this->assertEquals(null,   $columns['baz1']->getdefault());
159
+        $this->assertInternalType('array',  $columns['baz1']->getPlatformOptions());
160
+
161
+        $this->assertEquals('baz2', strtolower($columns['baz2']->getname()));
162
+        $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime'));
163
+        $this->assertEquals(true,   $columns['baz2']->getnotnull());
164
+        $this->assertEquals(null,   $columns['baz2']->getdefault());
165
+        $this->assertInternalType('array',  $columns['baz2']->getPlatformOptions());
166
+        
167
+        $this->assertEquals('baz3', strtolower($columns['baz3']->getname()));
168
+        $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime'));
169
+        $this->assertEquals(true,   $columns['baz3']->getnotnull());
170
+        $this->assertEquals(null,   $columns['baz3']->getdefault());
171
+        $this->assertInternalType('array',  $columns['baz3']->getPlatformOptions());
172
+    }
173
+
174
+    public function testDiffListTableColumns()
175
+    {
176
+        if ($this->_sm->getDatabasePlatform()->getName() == 'oracle') {
177
+            $this->markTestSkipped('Does not work with Oracle, since it cannot detect DateTime, Date and Time differenecs (at the moment).');
178
+        }
179
+
180
+        $offlineTable = $this->createListTableColumns();
181
+        $onlineTable = $this->_sm->listTableDetails('list_table_columns');
182
+
183
+        $comparator = new \Doctrine\DBAL\Schema\Comparator();
184
+        $diff = $comparator->diffTable($offlineTable, $onlineTable);
185
+
186
+        $this->assertFalse($diff, "No differences should be detected with the offline vs online schema.");
187
+    }
188
+
189
+    public function testListTableIndexes()
190
+    {
191
+        $table = $this->getTestTable('list_table_indexes_test');
192
+        $table->addUniqueIndex(array('test'), 'test_index_name');
193
+        $table->addIndex(array('id', 'test'), 'test_composite_idx');
194
+
195
+        $this->_sm->createTable($table);
196
+
197
+        $tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_test');
198
+
199
+        $this->assertEquals(3, count($tableIndexes));
200
+
201
+        $this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
202
+        $this->assertEquals(array('id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
203
+        $this->assertTrue($tableIndexes['primary']->isUnique());
204
+        $this->assertTrue($tableIndexes['primary']->isPrimary());
205
+
206
+        $this->assertEquals('test_index_name', $tableIndexes['test_index_name']->getName());
207
+        $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test_index_name']->getColumns()));
208
+        $this->assertTrue($tableIndexes['test_index_name']->isUnique());
209
+        $this->assertFalse($tableIndexes['test_index_name']->isPrimary());
210
+
211
+        $this->assertEquals('test_composite_idx', $tableIndexes['test_composite_idx']->getName());
212
+        $this->assertEquals(array('id', 'test'), array_map('strtolower', $tableIndexes['test_composite_idx']->getColumns()));
213
+        $this->assertFalse($tableIndexes['test_composite_idx']->isUnique());
214
+        $this->assertFalse($tableIndexes['test_composite_idx']->isPrimary());
215
+    }
216
+
217
+    public function testDropAndCreateIndex()
218
+    {
219
+        $table = $this->getTestTable('test_create_index');
220
+        $table->addUniqueIndex(array('test'), 'test');
221
+        $this->_sm->dropAndCreateTable($table);
222
+
223
+        $this->_sm->dropAndCreateIndex($table->getIndex('test'), $table);
224
+        $tableIndexes = $this->_sm->listTableIndexes('test_create_index');
225
+        $this->assertInternalType('array', $tableIndexes);
226
+
227
+        $this->assertEquals('test',        strtolower($tableIndexes['test']->getName()));
228
+        $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns()));
229
+        $this->assertTrue($tableIndexes['test']->isUnique());
230
+        $this->assertFalse($tableIndexes['test']->isPrimary());
231
+    }
232
+
233
+    public function testCreateTableWithForeignKeys()
234
+    {
235
+        if(!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
236
+            $this->markTestSkipped('Platform does not support foreign keys.');
237
+        }
238
+
239
+        $tableB = $this->getTestTable('test_foreign');
240
+
241
+        $this->_sm->dropAndCreateTable($tableB);
242
+
243
+        $tableA = $this->getTestTable('test_create_fk');
244
+        $tableA->addForeignKeyConstraint('test_foreign', array('foreign_key_test'), array('id'));
245
+
246
+        $this->_sm->dropAndCreateTable($tableA);
247
+
248
+        $fkTable = $this->_sm->listTableDetails('test_create_fk');
249
+        $fkConstraints = $fkTable->getForeignKeys();
250
+        $this->assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key.");
251
+
252
+        $fkConstraint = current($fkConstraints);
253
+        $this->assertType('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint);
254
+        $this->assertEquals('test_foreign',             strtolower($fkConstraint->getForeignTableName()));
255
+        $this->assertEquals(array('foreign_key_test'),  array_map('strtolower', $fkConstraint->getColumns()));
256
+        $this->assertEquals(array('id'),                array_map('strtolower', $fkConstraint->getForeignColumns()));
257
+
258
+        $this->assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), "The columns of a foreign key constraint should always be indexed.");
259
+    }
260
+
261
+    public function testListForeignKeys()
262
+    {
263
+        if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
264
+            $this->markTestSkipped('Does not support foreign key constraints.');
265
+        }
266
+
267
+        $this->createTestTable('test_create_fk1');
268
+        $this->createTestTable('test_create_fk2');
269
+
270
+        $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
271
+            array('foreign_key_test'), 'test_create_fk2', array('id'), 'foreign_key_test_fk', array('onDelete' => 'CASCADE')
272
+        );
273
+
274
+        $this->_sm->createForeignKey($foreignKey, 'test_create_fk1');
275
+
276
+        $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');
277
+
278
+        $this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key.");
279
+        
280
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
281
+        $this->assertEquals(array('foreign_key_test'),  array_map('strtolower', $fkeys[0]->getLocalColumns()));
282
+        $this->assertEquals(array('id'),                array_map('strtolower', $fkeys[0]->getForeignColumns()));
283
+        $this->assertEquals('test_create_fk2',          strtolower($fkeys[0]->getForeignTableName()));
284
+
285
+        if($fkeys[0]->hasOption('onDelete')) {
286
+            $this->assertEquals('CASCADE', $fkeys[0]->getOption('onDelete'));
287
+        }
288
+    }
289
+
290
+    protected function getCreateExampleViewSql()
291
+    {
292
+        $this->markTestSkipped('No Create Example View SQL was defined for this SchemaManager');
293
+    }
294
+
295
+    public function testCreateSchema()
296
+    {
297
+        $this->createTestTable('test_table');
298
+
299
+        $schema = $this->_sm->createSchema();
300
+
301
+        $this->assertTrue($schema->hasTable('test_table'));
302
+    }
303
+
304
+    public function testAlterTableScenario()
305
+    {
306
+        if(!$this->_sm->getDatabasePlatform()->supportsAlterTable()) {
307
+            $this->markTestSkipped('Alter Table is not supported by this platform.');
308
+        }
309
+
310
+        $this->createTestTable('alter_table');
311
+        $this->createTestTable('alter_table_foreign');
312
+
313
+        $table = $this->_sm->listTableDetails('alter_table');
314
+        $this->assertTrue($table->hasColumn('id'));
315
+        $this->assertTrue($table->hasColumn('test'));
316
+        $this->assertTrue($table->hasColumn('foreign_key_test'));
317
+        $this->assertEquals(0, count($table->getForeignKeys()));
318
+        $this->assertEquals(1, count($table->getIndexes()));
319
+
320
+        $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
321
+        $tableDiff->addedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', Type::getType('integer'));
322
+        $tableDiff->removedColumns['test'] = $table->getColumn('test');
323
+
324
+        $this->_sm->alterTable($tableDiff);
325
+
326
+        $table = $this->_sm->listTableDetails('alter_table');
327
+        $this->assertFalse($table->hasColumn('test'));
328
+        $this->assertTrue($table->hasColumn('foo'));
329
+
330
+        $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
331
+        $tableDiff->addedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo'));
332
+
333
+        $this->_sm->alterTable($tableDiff);
334
+
335
+        $table = $this->_sm->listTableDetails('alter_table');
336
+        $this->assertEquals(2, count($table->getIndexes()));
337
+        $this->assertTrue($table->hasIndex('foo_idx'));
338
+        $this->assertEquals(array('foo'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns()));
339
+        $this->assertFalse($table->getIndex('foo_idx')->isPrimary());
340
+        $this->assertFalse($table->getIndex('foo_idx')->isUnique());
341
+
342
+        $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
343
+        $tableDiff->changedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test'));
344
+
345
+        $this->_sm->alterTable($tableDiff);
346
+
347
+        $table = $this->_sm->listTableDetails('alter_table');
348
+        $this->assertEquals(2, count($table->getIndexes()));
349
+        $this->assertTrue($table->hasIndex('foo_idx'));
350
+        $this->assertEquals(array('foo', 'foreign_key_test'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns()));
351
+
352
+        $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
353
+        $tableDiff->removedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test'));
354
+        $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('foreign_key_test'), 'alter_table_foreign', array('id'));
355
+        $tableDiff->addedForeignKeys[] = $fk;
356
+
357
+        $this->_sm->alterTable($tableDiff);
358
+        $table = $this->_sm->listTableDetails('alter_table');
359
+
360
+        // dont check for index size here, some platforms automatically add indexes for foreign keys.
361
+        $this->assertFalse($table->hasIndex('foo_idx'));
362
+
363
+        $this->assertEquals(1, count($table->getForeignKeys()));
364
+        $fks = $table->getForeignKeys();
365
+        $foreignKey = current($fks);
366
+        $this->assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName()));
367
+        $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $foreignKey->getColumns()));
368
+        $this->assertEquals(array('id'), array_map('strtolower', $foreignKey->getForeignColumns()));
369
+    }
370
+
371
+    public function testCreateAndListViews()
372
+    {
373
+        $this->createTestTable('view_test_table');
374
+
375
+        $name = "doctrine_test_view";
376
+        $sql = "SELECT * FROM view_test_table";
377
+
378
+        $view = new \Doctrine\DBAL\Schema\View($name, $sql);
379
+
380
+        $this->_sm->dropAndCreateView($view);
381
+
382
+        $views = $this->_sm->listViews();
383
+    }
384
+
385
+    public function testAutoincrementDetection()
386
+    {
387
+        if (!$this->_sm->getDatabasePlatform()->supportsIdentityColumns()) {
388
+            $this->markTestSkipped('This test is only supported on platforms that have autoincrement');
389
+        }
390
+
391
+        $table = new \Doctrine\DBAL\Schema\Table('test_autoincrement');
392
+        $table->setSchemaConfig($this->_sm->createSchemaConfig());
393
+        $table->addColumn('id', 'integer', array('autoincrement' => true));
394
+        $table->setPrimaryKey(array('id'));
395
+
396
+        $this->_sm->createTable($table);
397
+
398
+        $inferredTable = $this->_sm->listTableDetails('test_autoincrement');
399
+        $this->assertTrue($inferredTable->hasColumn('id'));
400
+        $this->assertTrue($inferredTable->getColumn('id')->getAutoincrement());
401
+    }
402
+    
403
+    /**
404
+     * @group DDC-887
405
+     */
406
+    public function testUpdateSchemaWithForeignKeyRenaming()
407
+    {
408
+        if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
409
+            $this->markTestSkipped('This test is only supported on platforms that have foreign keys.');
410
+        }
411
+        
412
+        $table = new \Doctrine\DBAL\Schema\Table('test_fk_base');
413
+        $table->addColumn('id', 'integer');
414
+        $table->setPrimaryKey(array('id'));
415
+        
416
+        $tableFK = new \Doctrine\DBAL\Schema\Table('test_fk_rename');
417
+        $tableFK->setSchemaConfig($this->_sm->createSchemaConfig());
418
+        $tableFK->addColumn('id', 'integer');
419
+        $tableFK->addColumn('fk_id', 'integer');
420
+        $tableFK->setPrimaryKey(array('id'));
421
+        $tableFK->addIndex(array('fk_id'), 'fk_idx');
422
+        $tableFK->addForeignKeyConstraint('test_fk_base', array('fk_id'), array('id'));
423
+        
424
+        $this->_sm->createTable($table);
425
+        $this->_sm->createTable($tableFK);
426
+        
427
+        $tableFKNew = new \Doctrine\DBAL\Schema\Table('test_fk_rename');
428
+        $tableFKNew->setSchemaConfig($this->_sm->createSchemaConfig());
429
+        $tableFKNew->addColumn('id', 'integer');
430
+        $tableFKNew->addColumn('rename_fk_id', 'integer');
431
+        $tableFKNew->setPrimaryKey(array('id'));
432
+        $tableFKNew->addIndex(array('rename_fk_id'), 'fk_idx');
433
+        $tableFKNew->addForeignKeyConstraint('test_fk_base', array('rename_fk_id'), array('id'));
434
+        
435
+        $c = new \Doctrine\DBAL\Schema\Comparator();
436
+        $tableDiff = $c->diffTable($tableFK, $tableFKNew);
437
+        
438
+        $this->_sm->alterTable($tableDiff);
439
+    }
440
+
441
+    /**
442
+     * @group DBAL-42
443
+     */
444
+    public function testGetColumnComment()
445
+    {
446
+        if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) {
447
+            $this->markTestSkipped('Database does not support column comments.');
448
+        }
449
+
450
+        $table = new \Doctrine\DBAL\Schema\Table('column_comment_test');
451
+        $table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
452
+        $table->setPrimaryKey(array('id'));
453
+
454
+        $this->_sm->createTable($table);
455
+
456
+        $columns = $this->_sm->listTableColumns("column_comment_test");
457
+        $this->assertEquals(1, count($columns));
458
+        $this->assertEquals('This is a comment', $columns['id']->getComment());
459
+    }
460
+
461
+    /**
462
+     * @group DBAL-42
463
+     */
464
+    public function testAutomaticallyAppendCommentOnMarkedColumns()
465
+    {
466
+        if (!$this->_conn->getDatabasePlatform()->supportsInlineColumnComments() && !$this->_conn->getDatabasePlatform()->supportsCommentOnStatement()) {
467
+            $this->markTestSkipped('Database does not support column comments.');
468
+        }
469
+
470
+        $table = new \Doctrine\DBAL\Schema\Table('column_comment_test2');
471
+        $table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
472
+        $table->addColumn('obj', 'object', array('comment' => 'This is a comment'));
473
+        $table->addColumn('arr', 'array', array('comment' => 'This is a comment'));
474
+        $table->setPrimaryKey(array('id'));
475
+
476
+        $this->_sm->createTable($table);
477
+
478
+        $columns = $this->_sm->listTableColumns("column_comment_test2");
479
+        $this->assertEquals(3, count($columns));
480
+        $this->assertEquals('This is a comment', $columns['id']->getComment());
481
+        $this->assertEquals('This is a comment', $columns['obj']->getComment(), "The Doctrine2 Typehint should be stripped from comment.");
482
+        $this->assertInstanceOf('Doctrine\DBAL\Types\ObjectType', $columns['obj']->getType(), "The Doctrine2 should be detected from comment hint.");
483
+        $this->assertEquals('This is a comment', $columns['arr']->getComment(), "The Doctrine2 Typehint should be stripped from comment.");
484
+        $this->assertInstanceOf('Doctrine\DBAL\Types\ArrayType', $columns['arr']->getType(), "The Doctrine2 should be detected from comment hint.");
485
+    }
486
+
487
+    /**
488
+     * @param string $name
489
+     * @param array $data
490
+     */
491
+    protected function createTestTable($name = 'test_table', $data = array())
492
+    {
493
+        $options = array();
494
+        if (isset($data['options'])) {
495
+            $options = $data['options'];
496
+        }
497
+
498
+        $table = $this->getTestTable($name, $options);
499
+
500
+        $this->_sm->dropAndCreateTable($table);
501
+    }
502
+
503
+    protected function getTestTable($name, $options=array())
504
+    {
505
+        $table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), false, $options);
506
+        $table->setSchemaConfig($this->_sm->createSchemaConfig());
507
+        $table->addColumn('id', 'integer', array('notnull' => true));
508
+        $table->setPrimaryKey(array('id'));
509
+        $table->addColumn('test', 'string', array('length' => 255));
510
+        $table->addColumn('foreign_key_test', 'integer');
511
+        return $table;
512
+    }
513
+
514
+    protected function assertHasTable($tables, $tableName)
515
+    {
516
+        $foundTable = false;
517
+        foreach ($tables AS $table) {
518
+            $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table, 'No Table instance was found in tables array.');
519
+            if (strtolower($table->getName()) == 'list_tables_test_new_name') {
520
+                $foundTable = true;
521
+            }
522
+        }
523
+        $this->assertTrue($foundTable, "Could not find new table");
524
+    }
525
+}

+ 60 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php Ver fichero

@@ -0,0 +1,60 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional\Schema;
4
+
5
+use Doctrine\DBAL\Schema;
6
+
7
+require_once __DIR__ . '/../../../TestInit.php';
8
+ 
9
+class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
10
+{
11
+    /**
12
+     * SQLITE does not support databases.
13
+     * 
14
+     * @expectedException \Exception
15
+     */
16
+    public function testListDatabases()
17
+    {
18
+        $this->_sm->listDatabases();
19
+    }
20
+
21
+    public function testCreateAndDropDatabase()
22
+    {
23
+        $path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite';
24
+
25
+        $this->_sm->createDatabase($path);
26
+        $this->assertEquals(true, file_exists($path));
27
+        $this->_sm->dropDatabase($path);
28
+        $this->assertEquals(false, file_exists($path));
29
+    }
30
+
31
+    /**
32
+     * @expectedException \Exception
33
+     */
34
+    // This test is not correct. createSequence expects an object.
35
+    // PHPUnit wrapping the PHP error in an exception hides this but it shows up
36
+    // when the tests are run in the build (phing).
37
+    /*public function testCreateSequence()
38
+    {
39
+        $this->_sm->createSequence('seqname', 1, 1);
40
+    }*/
41
+
42
+    /**
43
+     * @expectedException \Exception
44
+     */
45
+    // This test is not correct. createForeignKey expects an object.
46
+    // PHPUnit wrapping the PHP error in an exception hides this but it shows up
47
+    // when the tests are run in the build (phing).
48
+    /*public function testCreateForeignKey()
49
+    {
50
+        $this->_sm->createForeignKey('table', array());
51
+    }*/
52
+
53
+    /**
54
+     * @expectedException \Exception
55
+     */
56
+    public function testRenameTable()
57
+    {
58
+        $this->_sm->renameTable('oldname', 'newname');
59
+    }
60
+}

+ 94 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php Ver fichero

@@ -0,0 +1,94 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional;
4
+
5
+use Doctrine\DBAL\Types\Type;
6
+
7
+require_once __DIR__ . '/../../TestInit.php';
8
+
9
+class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
10
+{
11
+    static private $typeCounter = 0;
12
+
13
+    public function setUp()
14
+    {
15
+        parent::setUp();
16
+
17
+        /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
18
+        $sm = $this->_conn->getSchemaManager();
19
+
20
+        if (!$sm->tablesExist(array('type_conversion'))) {
21
+
22
+            $table = new \Doctrine\DBAL\Schema\Table("type_conversion");
23
+            $table->addColumn('id', 'integer', array('notnull' => false));
24
+            $table->addColumn('test_string', 'string', array('notnull' => false));
25
+            $table->addColumn('test_boolean', 'boolean', array('notnull' => false));
26
+            $table->addColumn('test_bigint', 'bigint', array('notnull' => false));
27
+            $table->addColumn('test_smallint', 'bigint', array('notnull' => false));
28
+            $table->addColumn('test_datetime', 'datetime', array('notnull' => false));
29
+            $table->addColumn('test_datetimetz', 'datetimetz', array('notnull' => false));
30
+            $table->addColumn('test_date', 'date', array('notnull' => false));
31
+            $table->addColumn('test_time', 'time', array('notnull' => false));
32
+            $table->addColumn('test_text', 'text', array('notnull' => false));
33
+            $table->addColumn('test_array', 'array', array('notnull' => false));
34
+            $table->addColumn('test_object', 'object', array('notnull' => false));
35
+            $table->addColumn('test_float', 'float', array('notnull' => false));
36
+            $table->addColumn('test_decimal', 'decimal', array('notnull' => false, 'scale' => 2, 'precision' => 10));
37
+            $table->setPrimaryKey(array('id'));
38
+
39
+            $sm->createTable($table);
40
+        }
41
+    }
42
+
43
+    static public function dataIdempotentDataConversion()
44
+    {
45
+        $obj = new \stdClass();
46
+        $obj->foo = "bar";
47
+        $obj->bar = "baz";
48
+
49
+        return array(
50
+            array('string',     'ABCDEFGaaaBBB', 'string'),
51
+            array('boolean',    true, 'bool'),
52
+            array('boolean',    false, 'bool'),
53
+            array('bigint',     12345678, 'string'),
54
+            array('smallint',   123, 'int'),
55
+            array('datetime',   new \DateTime('2010-04-05 10:10:10'), 'DateTime'),
56
+            array('datetimetz', new \DateTime('2010-04-05 10:10:10'), 'DateTime'),
57
+            array('date',       new \DateTime('2010-04-05'), 'DateTime'),
58
+            array('time',       new \DateTime('10:10:10'), 'DateTime'),
59
+            array('text',       str_repeat('foo ', 1000), 'string'),
60
+            array('array',      array('foo' => 'bar'), 'array'),
61
+            array('object',     $obj, 'object'),
62
+            array('float',      1.5, 'float'),
63
+            array('decimal',    1.55, 'string'),
64
+        );
65
+    }
66
+
67
+    /**
68
+     * @dataProvider dataIdempotentDataConversion
69
+     * @param string $type
70
+     * @param mixed $originalValue
71
+     * @param string $expectedPhpType
72
+     */
73
+    public function testIdempotentDataConversion($type, $originalValue, $expectedPhpType)
74
+    {
75
+        $columnName = "test_" . $type;
76
+        $typeInstance = Type::getType($type);
77
+        $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->_conn->getDatabasePlatform());
78
+
79
+        $this->_conn->insert('type_conversion', array('id' => ++self::$typeCounter, $columnName => $insertionValue));
80
+
81
+        $sql = "SELECT " . $columnName . " FROM type_conversion WHERE id = " . self::$typeCounter;
82
+        $actualDbValue = $typeInstance->convertToPHPValue($this->_conn->fetchColumn($sql), $this->_conn->getDatabasePlatform());
83
+
84
+        $this->assertType($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType);
85
+
86
+        if ($type !== "datetimetz") {
87
+            $this->assertEquals($originalValue, $actualDbValue, "Conversion between values should produce the same out as in value, but doesnt!");
88
+
89
+            if ($originalValue instanceof \DateTime) {
90
+                $this->assertEquals($originalValue->getTimezone()->getName(), $actualDbValue->getTimezone()->getName(), "Timezones should be the same.");
91
+            }
92
+        }
93
+    }
94
+}

+ 134 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php Ver fichero

@@ -0,0 +1,134 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Functional;
4
+use Doctrine\DBAL\Types\Type;
5
+use PDO;
6
+
7
+require_once __DIR__ . '/../../TestInit.php';
8
+
9
+class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
10
+{
11
+    public function setUp()
12
+    {
13
+        parent::setUp();
14
+
15
+        try {
16
+            /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
17
+            $table = new \Doctrine\DBAL\Schema\Table("write_table");
18
+            $table->addColumn('test_int', 'integer');
19
+            $table->addColumn('test_string', 'string', array('notnull' => false));
20
+
21
+            $sm = $this->_conn->getSchemaManager();
22
+            $sm->createTable($table);
23
+        } catch(\Exception $e) {
24
+
25
+        }
26
+        $this->_conn->executeUpdate('DELETE FROM write_table');
27
+    }
28
+
29
+    /**
30
+     * @group DBAL-80
31
+     */
32
+    public function testExecuteUpdateFirstTypeIsNull()
33
+    {
34
+        $sql = "INSERT INTO write_table (test_string, test_int) VALUES (?, ?)";
35
+        $this->_conn->executeUpdate($sql, array("text", 1111), array(null, PDO::PARAM_INT));
36
+
37
+        $sql = "SELECT * FROM write_table WHERE test_string = ? AND test_int = ?";
38
+        $this->assertTrue((bool)$this->_conn->fetchColumn($sql, array("text", 1111)));
39
+    }
40
+
41
+    public function testExecuteUpdate()
42
+    {
43
+        $sql = "INSERT INTO write_table (test_int) VALUES ( " . $this->_conn->quote(1) . ")";
44
+        $affected = $this->_conn->executeUpdate($sql);
45
+
46
+        $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!");
47
+    }
48
+
49
+    public function testExecuteUpdateWithTypes()
50
+    {
51
+        $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
52
+        $affected = $this->_conn->executeUpdate($sql, array(1, 'foo'), array(\PDO::PARAM_INT, \PDO::PARAM_STR));
53
+
54
+        $this->assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!");
55
+    }
56
+
57
+    public function testPrepareRowCountReturnsAffectedRows()
58
+    {
59
+        $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
60
+        $stmt = $this->_conn->prepare($sql);
61
+
62
+        $stmt->bindValue(1, 1);
63
+        $stmt->bindValue(2, "foo");
64
+        $stmt->execute();
65
+
66
+        $this->assertEquals(1, $stmt->rowCount());
67
+    }
68
+
69
+    public function testPrepareWithPdoTypes()
70
+    {
71
+        $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
72
+        $stmt = $this->_conn->prepare($sql);
73
+
74
+        $stmt->bindValue(1, 1, \PDO::PARAM_INT);
75
+        $stmt->bindValue(2, "foo", \PDO::PARAM_STR);
76
+        $stmt->execute();
77
+
78
+        $this->assertEquals(1, $stmt->rowCount());
79
+    }
80
+
81
+    public function testPrepareWithDbalTypes()
82
+    {
83
+        $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
84
+        $stmt = $this->_conn->prepare($sql);
85
+
86
+        $stmt->bindValue(1, 1, Type::getType('integer'));
87
+        $stmt->bindValue(2, "foo", Type::getType('string'));
88
+        $stmt->execute();
89
+
90
+        $this->assertEquals(1, $stmt->rowCount());
91
+    }
92
+
93
+    public function testPrepareWithDbalTypeNames()
94
+    {
95
+        $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
96
+        $stmt = $this->_conn->prepare($sql);
97
+
98
+        $stmt->bindValue(1, 1, 'integer');
99
+        $stmt->bindValue(2, "foo", 'string');
100
+        $stmt->execute();
101
+
102
+        $this->assertEquals(1, $stmt->rowCount());
103
+    }
104
+
105
+    public function insertRows()
106
+    {
107
+        $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 1)));
108
+        $this->assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 2)));
109
+    }
110
+
111
+    public function testInsert()
112
+    {
113
+        $this->insertRows();
114
+    }
115
+
116
+    public function testDelete()
117
+    {
118
+        $this->insertRows();
119
+
120
+        $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 2)));
121
+        $this->assertEquals(1, count($this->_conn->fetchAll('SELECT * FROM write_table')));
122
+
123
+        $this->assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 1)));
124
+        $this->assertEquals(0, count($this->_conn->fetchAll('SELECT * FROM write_table')));
125
+    }
126
+
127
+    public function testUpdate()
128
+    {
129
+        $this->insertRows();
130
+
131
+        $this->assertEquals(1, $this->_conn->update('write_table', array('test_int' => 2), array('test_int' => 1)));
132
+        $this->assertEquals(2, $this->_conn->update('write_table', array('test_int' => 3), array('test_int' => 2)));
133
+    }
134
+}

+ 41 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php Ver fichero

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Mocks;
4
+
5
+use Doctrine\DBAL\Platforms;
6
+
7
+class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
8
+{
9
+    public function getBooleanTypeDeclarationSQL(array $columnDef) {}
10
+    public function getIntegerTypeDeclarationSQL(array $columnDef) {}
11
+    public function getBigIntTypeDeclarationSQL(array $columnDef) {}
12
+    public function getSmallIntTypeDeclarationSQL(array $columnDef) {}
13
+    public function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {}
14
+
15
+    public function getVarcharTypeDeclarationSQL(array $field)
16
+    {
17
+        return "DUMMYVARCHAR()";
18
+    }
19
+    
20
+    /** @override */
21
+    public function getClobTypeDeclarationSQL(array $field)
22
+    {
23
+        return 'DUMMYCLOB';
24
+    }
25
+
26
+    public function getVarcharDefaultLength()
27
+    {
28
+        return 255;
29
+    }
30
+
31
+    public function getName()
32
+    {
33
+        return 'mock';
34
+    }
35
+    protected function initializeDoctrineTypeMappings() {
36
+    }
37
+    protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
38
+    {
39
+
40
+    }
41
+}

+ 218 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php Ver fichero

@@ -0,0 +1,218 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Platforms;
4
+
5
+abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
6
+{
7
+    /**
8
+     * @var Doctrine\DBAL\Platforms\AbstractPlatform
9
+     */
10
+    protected $_platform;
11
+
12
+    abstract public function createPlatform();
13
+
14
+    public function setUp()
15
+    {
16
+        $this->_platform = $this->createPlatform();
17
+    }
18
+
19
+    public function testGetInvalidtForeignKeyReferentialActionSQL()
20
+    {
21
+        $this->setExpectedException('InvalidArgumentException');
22
+        $this->_platform->getForeignKeyReferentialActionSQL('unknown');
23
+    }
24
+
25
+    public function testGetUnknownDoctrineMappingType()
26
+    {
27
+        $this->setExpectedException('Doctrine\DBAL\DBALException');
28
+        $this->_platform->getDoctrineTypeMapping('foobar');
29
+    }
30
+
31
+    public function testRegisterDoctrineMappingType()
32
+    {
33
+        $this->_platform->registerDoctrineTypeMapping('foo', 'integer');
34
+        $this->assertEquals('integer', $this->_platform->getDoctrineTypeMapping('foo'));
35
+    }
36
+
37
+    public function testRegisterUnknownDoctrineMappingType()
38
+    {
39
+        $this->setExpectedException('Doctrine\DBAL\DBALException');
40
+        $this->_platform->registerDoctrineTypeMapping('foo', 'bar');
41
+    }
42
+
43
+    public function testCreateWithNoColumns()
44
+    {
45
+        $table = new \Doctrine\DBAL\Schema\Table('test');
46
+
47
+        $this->setExpectedException('Doctrine\DBAL\DBALException');
48
+        $sql = $this->_platform->getCreateTableSQL($table);
49
+    }
50
+
51
+    public function testGeneratesTableCreationSql()
52
+    {
53
+        $table = new \Doctrine\DBAL\Schema\Table('test');
54
+        $table->addColumn('id', 'integer', array('notnull' => true, 'autoincrement' => true));
55
+        $table->addColumn('test', 'string', array('notnull' => false, 'length' => 255));
56
+        $table->setPrimaryKey(array('id'));
57
+
58
+        $sql = $this->_platform->getCreateTableSQL($table);
59
+        $this->assertEquals($this->getGenerateTableSql(), $sql[0]);
60
+    }
61
+
62
+    abstract public function getGenerateTableSql();
63
+
64
+    public function testGenerateTableWithMultiColumnUniqueIndex()
65
+    {
66
+        $table = new \Doctrine\DBAL\Schema\Table('test');
67
+        $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255));
68
+        $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255));
69
+        $table->addUniqueIndex(array("foo", "bar"));
70
+
71
+        $sql = $this->_platform->getCreateTableSQL($table);
72
+        $this->assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql);
73
+    }
74
+
75
+    abstract public function getGenerateTableWithMultiColumnUniqueIndexSql();
76
+
77
+    public function testGeneratesIndexCreationSql()
78
+    {
79
+        $indexDef = new \Doctrine\DBAL\Schema\Index('my_idx', array('user_name', 'last_login'));
80
+
81
+        $this->assertEquals(
82
+            $this->getGenerateIndexSql(),
83
+            $this->_platform->getCreateIndexSQL($indexDef, 'mytable')
84
+        );
85
+    }
86
+
87
+    abstract public function getGenerateIndexSql();
88
+
89
+    public function testGeneratesUniqueIndexCreationSql()
90
+    {
91
+        $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true);
92
+
93
+        $sql = $this->_platform->getCreateIndexSQL($indexDef, 'test');
94
+        $this->assertEquals($this->getGenerateUniqueIndexSql(), $sql);
95
+    }
96
+
97
+    abstract public function getGenerateUniqueIndexSql();
98
+
99
+    public function testGeneratesForeignKeyCreationSql()
100
+    {
101
+        $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), '');
102
+
103
+        $sql = $this->_platform->getCreateForeignKeySQL($fk, 'test');
104
+        $this->assertEquals($sql, $this->getGenerateForeignKeySql());
105
+    }
106
+
107
+    abstract public function getGenerateForeignKeySql();
108
+
109
+    public function testGeneratesConstraintCreationSql()
110
+    {
111
+        $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false);
112
+        $sql = $this->_platform->getCreateConstraintSQL($idx, 'test');
113
+        $this->assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql);
114
+
115
+        $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true);
116
+        $sql = $this->_platform->getCreateConstraintSQL($pk, 'test');
117
+        $this->assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql);
118
+
119
+        $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
120
+        $sql = $this->_platform->getCreateConstraintSQL($fk, 'test');
121
+        $this->assertEquals($this->getGenerateConstraintForeignKeySql(), $sql);
122
+    }
123
+
124
+    public function getGenerateConstraintUniqueIndexSql()
125
+    {
126
+        return 'ALTER TABLE test ADD CONSTRAINT constraint_name UNIQUE (test)';
127
+    }
128
+
129
+    public function getGenerateConstraintPrimaryIndexSql()
130
+    {
131
+        return 'ALTER TABLE test ADD CONSTRAINT constraint_name PRIMARY KEY (test)';
132
+    }
133
+
134
+    public function getGenerateConstraintForeignKeySql()
135
+    {
136
+        return 'ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES foreign (id)';
137
+    }
138
+
139
+    abstract public function getGenerateAlterTableSql();
140
+
141
+    public function testGeneratesTableAlterationSql()
142
+    {
143
+        $expectedSql = $this->getGenerateAlterTableSql();
144
+
145
+        $columnDiff = new \Doctrine\DBAL\Schema\ColumnDiff(
146
+            'bar', new \Doctrine\DBAL\Schema\Column(
147
+                'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('default' => 'def')
148
+            ),
149
+            array('type', 'notnull', 'default')
150
+        );
151
+
152
+        $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
153
+        $tableDiff->newName = 'userlist';
154
+        $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('notnull' => false));
155
+        $tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer'));
156
+        $tableDiff->changedColumns['bar'] = $columnDiff;
157
+
158
+        $sql = $this->_platform->getAlterTableSQL($tableDiff);
159
+
160
+        $this->assertEquals($expectedSql, $sql);
161
+    }
162
+
163
+    public function testGetCustomColumnDeclarationSql()
164
+    {
165
+        $field = array('columnDefinition' => 'MEDIUMINT(6) UNSIGNED');
166
+        $this->assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSQL('foo', $field));
167
+    }
168
+
169
+    /**
170
+     * @group DBAL-42
171
+     */
172
+    public function testCreateTableColumnComments()
173
+    {
174
+        $table = new \Doctrine\DBAL\Schema\Table('test');
175
+        $table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
176
+        $table->setPrimaryKey(array('id'));
177
+
178
+        $this->assertEquals($this->getCreateTableColumnCommentsSQL(), $this->_platform->getCreateTableSQL($table));
179
+    }
180
+
181
+    /**
182
+     * @group DBAL-42
183
+     */
184
+    public function testAlterTableColumnComments()
185
+    {
186
+        $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
187
+        $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('comment' => 'A comment'));
188
+        $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff(
189
+            'bar', new \Doctrine\DBAL\Schema\Column(
190
+                'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('comment' => 'B comment')
191
+            ),
192
+            array('comment')
193
+        );
194
+
195
+        $this->assertEquals($this->getAlterTableColumnCommentsSQL(), $this->_platform->getAlterTableSQL($tableDiff));
196
+    }
197
+
198
+    public function getCreateTableColumnCommentsSQL()
199
+    {
200
+        $this->markTestSkipped('Platform does not support Column comments.');
201
+    }
202
+
203
+    public function getAlterTableColumnCommentsSQL()
204
+    {
205
+        $this->markTestSkipped('Platform does not support Column comments.');
206
+    }
207
+    
208
+    /**
209
+     * @group DBAL-45
210
+     */
211
+    public function testKeywordList()
212
+    {
213
+        $keywordList = $this->_platform->getReservedKeywordsList();
214
+        $this->assertInstanceOf('Doctrine\DBAL\Platforms\Keywords\KeywordList', $keywordList);
215
+        
216
+        $this->assertTrue($keywordList->isKeyword('table'));
217
+    }
218
+}

+ 175 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php Ver fichero

@@ -0,0 +1,175 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Platforms;
4
+
5
+use Doctrine\DBAL\Platforms\MsSqlPlatform;
6
+use Doctrine\DBAL\Types\Type;
7
+
8
+require_once __DIR__ . '/../../TestInit.php';
9
+
10
+class MsSqlPlatformTest extends AbstractPlatformTestCase
11
+{
12
+
13
+    public function createPlatform()
14
+    {
15
+        return new MsSqlPlatform;
16
+    }
17
+
18
+    public function getGenerateTableSql()
19
+    {
20
+        return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
21
+    }
22
+
23
+    public function getGenerateTableWithMultiColumnUniqueIndexSql()
24
+    {
25
+        return array(
26
+            'CREATE TABLE test (foo NVARCHAR(255) DEFAULT NULL, bar NVARCHAR(255) DEFAULT NULL)',
27
+            'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar) WHERE foo IS NOT NULL AND bar IS NOT NULL'
28
+        );
29
+    }
30
+
31
+    public function getGenerateAlterTableSql()
32
+    {
33
+        return array(
34
+            'ALTER TABLE mytable RENAME TO userlist',
35
+            'ALTER TABLE mytable ADD quota INT DEFAULT NULL',
36
+            'ALTER TABLE mytable DROP COLUMN foo',
37
+            'ALTER TABLE mytable CHANGE bar baz NVARCHAR(255) DEFAULT \'def\' NOT NULL',
38
+        );
39
+    }
40
+
41
+    public function testGeneratesSqlSnippets()
42
+    {
43
+        $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
44
+        $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
45
+        $this->assertEquals('(column1 + column2 + column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
46
+    }
47
+
48
+    public function testGeneratesTransactionsCommands()
49
+    {
50
+        $this->assertEquals(
51
+                'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
52
+                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
53
+        );
54
+        $this->assertEquals(
55
+                'SET TRANSACTION ISOLATION LEVEL READ COMMITTED',
56
+                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
57
+        );
58
+        $this->assertEquals(
59
+                'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ',
60
+                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
61
+        );
62
+        $this->assertEquals(
63
+                'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
64
+                $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
65
+        );
66
+    }
67
+
68
+    public function testGeneratesDDLSnippets()
69
+    {
70
+        $dropDatabaseExpectation = 'DROP DATABASE foobar';
71
+
72
+        $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
73
+        $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
74
+        $this->assertEquals($dropDatabaseExpectation, $this->_platform->getDropDatabaseSQL('foobar'));
75
+        $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
76
+    }
77
+
78
+    public function testGeneratesTypeDeclarationForIntegers()
79
+    {
80
+        $this->assertEquals(
81
+                'INT',
82
+                $this->_platform->getIntegerTypeDeclarationSQL(array())
83
+        );
84
+        $this->assertEquals(
85
+                'INT IDENTITY',
86
+                $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
87
+        ));
88
+        $this->assertEquals(
89
+                'INT IDENTITY',
90
+                $this->_platform->getIntegerTypeDeclarationSQL(
91
+                        array('autoincrement' => true, 'primary' => true)
92
+        ));
93
+    }
94
+
95
+    public function testGeneratesTypeDeclarationsForStrings()
96
+    {
97
+        $this->assertEquals(
98
+                'NCHAR(10)',
99
+                $this->_platform->getVarcharTypeDeclarationSQL(
100
+                        array('length' => 10, 'fixed' => true)
101
+        ));
102
+        $this->assertEquals(
103
+                'NVARCHAR(50)',
104
+                $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
105
+                'Variable string declaration is not correct'
106
+        );
107
+        $this->assertEquals(
108
+                'NVARCHAR(255)',
109
+                $this->_platform->getVarcharTypeDeclarationSQL(array()),
110
+                'Long string declaration is not correct'
111
+        );
112
+    }
113
+
114
+    public function testPrefersIdentityColumns()
115
+    {
116
+        $this->assertTrue($this->_platform->prefersIdentityColumns());
117
+    }
118
+
119
+    public function testSupportsIdentityColumns()
120
+    {
121
+        $this->assertTrue($this->_platform->supportsIdentityColumns());
122
+    }
123
+
124
+    public function testDoesNotSupportSavePoints()
125
+    {
126
+        $this->assertTrue($this->_platform->supportsSavepoints());
127
+    }
128
+
129
+    public function getGenerateIndexSql()
130
+    {
131
+        return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
132
+    }
133
+
134
+    public function getGenerateUniqueIndexSql()
135
+    {
136
+        return 'CREATE UNIQUE INDEX index_name ON test (test, test2) WHERE test IS NOT NULL AND test2 IS NOT NULL';
137
+    }
138
+
139
+    public function getGenerateForeignKeySql()
140
+    {
141
+        return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)';
142
+    }
143
+
144
+    public function testModifyLimitQuery()
145
+    {
146
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
147
+        $this->assertEquals('SELECT TOP 10 * FROM user', $sql);
148
+    }
149
+
150
+    public function testModifyLimitQueryWithEmptyOffset()
151
+    {
152
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
153
+        $this->assertEquals('SELECT TOP 10 * FROM user', $sql);
154
+    }
155
+
156
+    public function testModifyLimitQueryWithOffset()
157
+    {
158
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5);
159
+        $this->assertEquals('WITH outer_tbl AS (SELECT ROW_NUMBER() OVER (ORDER BY username DESC) AS "doctrine_rownum", * FROM (SELECT * FROM user) AS inner_tbl) SELECT * FROM outer_tbl WHERE "doctrine_rownum" BETWEEN 6 AND 15', $sql);
160
+    }
161
+
162
+    public function testModifyLimitQueryWithAscOrderBy()
163
+    {
164
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10);
165
+        $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username ASC', $sql);
166
+    }
167
+
168
+    public function testModifyLimitQueryWithDescOrderBy()
169
+    {
170
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10);
171
+        $this->assertEquals('SELECT TOP 10 * FROM user ORDER BY username DESC', $sql);
172
+    }
173
+
174
+    
175
+}

+ 207 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php Ver fichero

@@ -0,0 +1,207 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Platforms;
4
+
5
+use Doctrine\DBAL\Platforms\MySqlPlatform;
6
+use Doctrine\DBAL\Types\Type;
7
+use Doctrine\DBAL\Schema\Table;
8
+use Doctrine\DBAL\Schema\Schema;
9
+
10
+require_once __DIR__ . '/../../TestInit.php';
11
+ 
12
+class MySqlPlatformTest extends AbstractPlatformTestCase
13
+{
14
+    public function createPlatform()
15
+    {
16
+        return new MysqlPlatform;
17
+    }
18
+
19
+    public function testGenerateMixedCaseTableCreate()
20
+    {
21
+        $table = new Table("Foo");
22
+        $table->addColumn("Bar", "integer");
23
+
24
+        $sql = $this->_platform->getCreateTableSQL($table);
25
+        $this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) ENGINE = InnoDB', array_shift($sql));
26
+    }
27
+
28
+    public function getGenerateTableSql()
29
+    {
30
+        return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) ENGINE = InnoDB';
31
+    }
32
+
33
+    public function getGenerateTableWithMultiColumnUniqueIndexSql()
34
+    {
35
+        return array(
36
+            'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) ENGINE = InnoDB'
37
+        );
38
+    }
39
+
40
+    public function getGenerateAlterTableSql()
41
+    {
42
+        return array(
43
+            "ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL"
44
+        );
45
+    }
46
+
47
+    public function testGeneratesSqlSnippets()
48
+    {
49
+        $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
50
+        $this->assertEquals('`', $this->_platform->getIdentifierQuoteCharacter(), 'Quote character is not correct');
51
+        $this->assertEquals('CONCAT(column1, column2, column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct');
52
+    }
53
+
54
+    public function testGeneratesTransactionsCommands()
55
+    {
56
+        $this->assertEquals(
57
+            'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
58
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED),
59
+            ''
60
+        );
61
+        $this->assertEquals(
62
+            'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
63
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
64
+        );
65
+        $this->assertEquals(
66
+            'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ',
67
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
68
+        );
69
+        $this->assertEquals(
70
+            'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE',
71
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
72
+        );
73
+    }
74
+
75
+
76
+    public function testGeneratesDDLSnippets()
77
+    {
78
+        $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
79
+        $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
80
+        $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
81
+        $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
82
+    }
83
+
84
+    public function testGeneratesTypeDeclarationForIntegers()
85
+    {
86
+        $this->assertEquals(
87
+            'INT',
88
+            $this->_platform->getIntegerTypeDeclarationSQL(array())
89
+        );
90
+        $this->assertEquals(
91
+            'INT AUTO_INCREMENT',
92
+            $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
93
+        ));
94
+        $this->assertEquals(
95
+            'INT AUTO_INCREMENT',
96
+            $this->_platform->getIntegerTypeDeclarationSQL(
97
+                array('autoincrement' => true, 'primary' => true)
98
+        ));
99
+    }
100
+
101
+    public function testGeneratesTypeDeclarationForStrings()
102
+    {
103
+        $this->assertEquals(
104
+            'CHAR(10)',
105
+            $this->_platform->getVarcharTypeDeclarationSQL(
106
+                array('length' => 10, 'fixed' => true)
107
+        ));
108
+        $this->assertEquals(
109
+            'VARCHAR(50)',
110
+            $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
111
+            'Variable string declaration is not correct'
112
+        );
113
+        $this->assertEquals(
114
+            'VARCHAR(255)',
115
+            $this->_platform->getVarcharTypeDeclarationSQL(array()),
116
+            'Long string declaration is not correct'
117
+        );
118
+    }
119
+
120
+    public function testPrefersIdentityColumns()
121
+    {
122
+        $this->assertTrue($this->_platform->prefersIdentityColumns());
123
+    }
124
+
125
+    public function testSupportsIdentityColumns()
126
+    {
127
+        $this->assertTrue($this->_platform->supportsIdentityColumns());
128
+    }
129
+
130
+    public function testDoesSupportSavePoints()
131
+    {
132
+        $this->assertTrue($this->_platform->supportsSavepoints());   
133
+    }
134
+
135
+    public function getGenerateIndexSql()
136
+    {
137
+        return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
138
+    }
139
+
140
+    public function getGenerateUniqueIndexSql()
141
+    {
142
+        return 'CREATE UNIQUE INDEX index_name ON test (test, test2)';
143
+    }
144
+
145
+    public function getGenerateForeignKeySql()
146
+    {
147
+        return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)';
148
+    }
149
+    
150
+    /**
151
+     * @group DBAL-126
152
+     */
153
+    public function testUniquePrimaryKey()
154
+    {        
155
+        $keyTable = new Table("foo");
156
+        $keyTable->addColumn("bar", "integer");
157
+        $keyTable->addColumn("baz", "string");
158
+        $keyTable->setPrimaryKey(array("bar"));
159
+        $keyTable->addUniqueIndex(array("baz"));
160
+        
161
+        $oldTable = new Table("foo");
162
+        $oldTable->addColumn("bar", "integer");
163
+        $oldTable->addColumn("baz", "string");
164
+        
165
+        $c = new \Doctrine\DBAL\Schema\Comparator;
166
+        $diff = $c->diffTable($oldTable, $keyTable);
167
+        
168
+        $sql = $this->_platform->getAlterTableSQL($diff);
169
+        
170
+        $this->assertEquals(array(
171
+            "ALTER TABLE foo ADD PRIMARY KEY (bar)",
172
+            "CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)",
173
+        ), $sql);
174
+    }
175
+
176
+    public function testModifyLimitQuery()
177
+    {
178
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
179
+        $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql);
180
+    }
181
+
182
+    public function testModifyLimitQueryWithEmptyOffset()
183
+    {
184
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
185
+        $this->assertEquals('SELECT * FROM user LIMIT 10', $sql);
186
+    }
187
+
188
+    /**
189
+     * @group DDC-118
190
+     */
191
+    public function testGetDateTimeTypeDeclarationSql()
192
+    {
193
+        $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => false)));
194
+        $this->assertEquals("TIMESTAMP", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => true)));
195
+        $this->assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array()));
196
+    }
197
+
198
+    public function getCreateTableColumnCommentsSQL()
199
+    {
200
+        return array("CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) ENGINE = InnoDB");
201
+    }
202
+
203
+    public function getAlterTableColumnCommentsSQL()
204
+    {
205
+        return array("ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'");
206
+    }
207
+}

+ 207 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php Ver fichero

@@ -0,0 +1,207 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Platforms;
4
+
5
+use Doctrine\DBAL\Platforms\OraclePlatform;
6
+use Doctrine\DBAL\Types\Type;
7
+
8
+require_once __DIR__ . '/../../TestInit.php';
9
+ 
10
+class OraclePlatformTest extends AbstractPlatformTestCase
11
+{
12
+    public function createPlatform()
13
+    {
14
+        return new OraclePlatform;
15
+    }
16
+
17
+    public function getGenerateTableSql()
18
+    {
19
+        return 'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL, PRIMARY KEY(id))';
20
+    }
21
+
22
+    public function getGenerateTableWithMultiColumnUniqueIndexSql()
23
+    {
24
+        return array(
25
+            'CREATE TABLE test (foo VARCHAR2(255) DEFAULT NULL, bar VARCHAR2(255) DEFAULT NULL)',
26
+            'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
27
+        );
28
+    }
29
+
30
+    public function getGenerateAlterTableSql()
31
+    {
32
+        return array(
33
+            'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL)',
34
+            "ALTER TABLE mytable MODIFY (baz  VARCHAR2(255) DEFAULT 'def' NOT NULL)",
35
+            "ALTER TABLE mytable DROP (foo)",
36
+            "ALTER TABLE mytable RENAME TO userlist",
37
+        );
38
+    }
39
+
40
+    /**
41
+     * @expectedException Doctrine\DBAL\DBALException
42
+     */
43
+    public function testRLike()
44
+    {
45
+        $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
46
+    }
47
+
48
+    public function testGeneratesSqlSnippets()
49
+    {
50
+        $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
51
+        $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
52
+    }
53
+
54
+    public function testGeneratesTransactionsCommands()
55
+    {
56
+        $this->assertEquals(
57
+            'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
58
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
59
+        );
60
+        $this->assertEquals(
61
+            'SET TRANSACTION ISOLATION LEVEL READ COMMITTED',
62
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
63
+        );
64
+        $this->assertEquals(
65
+            'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
66
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
67
+        );
68
+        $this->assertEquals(
69
+            'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
70
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
71
+        );
72
+    }
73
+
74
+    /**
75
+     * @expectedException Doctrine\DBAL\DBALException
76
+     */
77
+    public function testShowDatabasesThrowsException()
78
+    {
79
+        $this->assertEquals('SHOW DATABASES', $this->_platform->getShowDatabasesSQL());
80
+    }
81
+
82
+    /**
83
+     * @expectedException Doctrine\DBAL\DBALException
84
+     */
85
+    public function testCreateDatabaseThrowsException()
86
+    {
87
+        $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
88
+    }
89
+
90
+    public function testDropDatabaseThrowsException()
91
+    {
92
+        $this->assertEquals('DROP USER foobar CASCADE', $this->_platform->getDropDatabaseSQL('foobar'));
93
+    }
94
+
95
+    public function testDropTable()
96
+    {
97
+        $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));        
98
+    }
99
+
100
+    public function testGeneratesTypeDeclarationForIntegers()
101
+    {
102
+        $this->assertEquals(
103
+            'NUMBER(10)',
104
+            $this->_platform->getIntegerTypeDeclarationSQL(array())
105
+        );
106
+        $this->assertEquals(
107
+            'NUMBER(10)',
108
+            $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
109
+        ));
110
+        $this->assertEquals(
111
+            'NUMBER(10)',
112
+            $this->_platform->getIntegerTypeDeclarationSQL(
113
+                array('autoincrement' => true, 'primary' => true)
114
+        ));
115
+    }
116
+
117
+    public function testGeneratesTypeDeclarationsForStrings()
118
+    {
119
+        $this->assertEquals(
120
+            'CHAR(10)',
121
+            $this->_platform->getVarcharTypeDeclarationSQL(
122
+                array('length' => 10, 'fixed' => true)
123
+        ));
124
+        $this->assertEquals(
125
+            'VARCHAR2(50)',
126
+            $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
127
+            'Variable string declaration is not correct'
128
+        );
129
+        $this->assertEquals(
130
+            'VARCHAR2(255)',
131
+            $this->_platform->getVarcharTypeDeclarationSQL(array()),
132
+            'Long string declaration is not correct'
133
+        );
134
+    }
135
+
136
+    public function testPrefersIdentityColumns()
137
+    {
138
+        $this->assertFalse($this->_platform->prefersIdentityColumns());
139
+    }
140
+
141
+    public function testSupportsIdentityColumns()
142
+    {
143
+        $this->assertFalse($this->_platform->supportsIdentityColumns());
144
+    }
145
+
146
+    public function testSupportsSavePoints()
147
+    {
148
+        $this->assertTrue($this->_platform->supportsSavepoints());   
149
+    }
150
+    
151
+    public function getGenerateIndexSql()
152
+    {
153
+        return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
154
+    }
155
+
156
+    public function getGenerateUniqueIndexSql()
157
+    {
158
+        return 'CREATE UNIQUE INDEX index_name ON test (test, test2)';
159
+    }
160
+
161
+    public function getGenerateForeignKeySql()
162
+    {
163
+        return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)';
164
+    }
165
+
166
+    public function testModifyLimitQuery()
167
+    {
168
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
169
+        $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql);
170
+    }
171
+
172
+    public function testModifyLimitQueryWithEmptyOffset()
173
+    {
174
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
175
+        $this->assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql);
176
+    }
177
+
178
+    public function testModifyLimitQueryWithAscOrderBy()
179
+    {
180
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10);
181
+        $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username ASC) a WHERE ROWNUM <= 10', $sql);
182
+    }
183
+
184
+    public function testModifyLimitQueryWithDescOrderBy()
185
+    {
186
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10);
187
+        $this->assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10', $sql);
188
+    }
189
+
190
+    public function getCreateTableColumnCommentsSQL()
191
+    {
192
+        return array(
193
+            "CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))",
194
+            "COMMENT ON COLUMN test.id IS 'This is a comment'",
195
+        );
196
+    }
197
+
198
+    public function getAlterTableColumnCommentsSQL()
199
+    {
200
+        return array(
201
+            "ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)",
202
+            "ALTER TABLE mytable MODIFY (baz  VARCHAR2(255) NOT NULL)",
203
+            "COMMENT ON COLUMN mytable.quota IS 'A comment'",
204
+            "COMMENT ON COLUMN mytable.baz IS 'B comment'",
205
+        );
206
+    }
207
+}

+ 219 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php Ver fichero

@@ -0,0 +1,219 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Platforms;
4
+
5
+use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
6
+use Doctrine\DBAL\Types\Type;
7
+
8
+require_once __DIR__ . '/../../TestInit.php';
9
+ 
10
+class PostgreSqlPlatformTest extends AbstractPlatformTestCase
11
+{
12
+    public function createPlatform()
13
+    {
14
+        return new PostgreSqlPlatform;
15
+    }
16
+
17
+    public function getGenerateTableSql()
18
+    {
19
+        return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
20
+    }
21
+
22
+    public function getGenerateTableWithMultiColumnUniqueIndexSql()
23
+    {
24
+        return array(
25
+            'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)',
26
+            'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)'
27
+        );
28
+    }
29
+
30
+    public function getGenerateAlterTableSql()
31
+    {
32
+        return array(
33
+            'ALTER TABLE mytable ADD quota INT DEFAULT NULL',
34
+            'ALTER TABLE mytable DROP foo',
35
+            'ALTER TABLE mytable ALTER bar TYPE VARCHAR(255)',
36
+            "ALTER TABLE mytable ALTER bar SET  DEFAULT 'def'",
37
+            'ALTER TABLE mytable ALTER bar SET NOT NULL',
38
+            'ALTER TABLE mytable RENAME TO userlist',
39
+        );
40
+    }
41
+
42
+    public function getGenerateIndexSql()
43
+    {
44
+        return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
45
+    }
46
+
47
+    public function getGenerateForeignKeySql()
48
+    {
49
+        return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id) NOT DEFERRABLE INITIALLY IMMEDIATE';
50
+    }
51
+
52
+    public function testGeneratesForeignKeySqlForNonStandardOptions()
53
+    {
54
+        $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
55
+                array('foreign_id'), 'my_table', array('id'), 'my_fk', array('onDelete' => 'CASCADE')
56
+        );
57
+        $this->assertEquals(
58
+            "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE",
59
+            $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
60
+        );
61
+    }
62
+
63
+    public function testGeneratesSqlSnippets()
64
+    {
65
+        $this->assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
66
+        $this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
67
+        $this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
68
+        $this->assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
69
+        $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct');
70
+    }
71
+
72
+    public function testGeneratesTransactionCommands()
73
+    {
74
+        $this->assertEquals(
75
+            'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
76
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
77
+        );
78
+        $this->assertEquals(
79
+            'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED',
80
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
81
+        );
82
+        $this->assertEquals(
83
+            'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ',
84
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
85
+        );
86
+        $this->assertEquals(
87
+            'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE',
88
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
89
+        );
90
+    }
91
+
92
+    public function testGeneratesDDLSnippets()
93
+    {
94
+        $this->assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
95
+        $this->assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
96
+        $this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
97
+    }
98
+
99
+    public function testGenerateTableWithAutoincrement()
100
+    {
101
+        $table = new \Doctrine\DBAL\Schema\Table('autoinc_table');
102
+        $column = $table->addColumn('id', 'integer');
103
+        $column->setAutoincrement(true);
104
+
105
+        $this->assertEquals(array('CREATE TABLE autoinc_table (id SERIAL NOT NULL)'), $this->_platform->getCreateTableSQL($table));
106
+    }
107
+
108
+    public function testGeneratesTypeDeclarationForIntegers()
109
+    {
110
+        $this->assertEquals(
111
+            'INT',
112
+            $this->_platform->getIntegerTypeDeclarationSQL(array())
113
+        );
114
+        $this->assertEquals(
115
+            'SERIAL',
116
+            $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
117
+        ));
118
+        $this->assertEquals(
119
+            'SERIAL',
120
+            $this->_platform->getIntegerTypeDeclarationSQL(
121
+                array('autoincrement' => true, 'primary' => true)
122
+        ));
123
+    }
124
+
125
+    public function testGeneratesTypeDeclarationForStrings()
126
+    {
127
+        $this->assertEquals(
128
+            'CHAR(10)',
129
+            $this->_platform->getVarcharTypeDeclarationSQL(
130
+                array('length' => 10, 'fixed' => true))
131
+        );
132
+        $this->assertEquals(
133
+            'VARCHAR(50)',
134
+            $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
135
+            'Variable string declaration is not correct'
136
+        );
137
+        $this->assertEquals(
138
+            'VARCHAR(255)',
139
+            $this->_platform->getVarcharTypeDeclarationSQL(array()),
140
+            'Long string declaration is not correct'
141
+        );
142
+    }
143
+
144
+    public function getGenerateUniqueIndexSql()
145
+    {
146
+        return 'CREATE UNIQUE INDEX index_name ON test (test, test2)';
147
+    }
148
+
149
+    public function testGeneratesSequenceSqlCommands()
150
+    {
151
+        $sequence = new \Doctrine\DBAL\Schema\Sequence('myseq', 20, 1);
152
+        $this->assertEquals(
153
+            'CREATE SEQUENCE myseq INCREMENT BY 20 MINVALUE 1 START 1',
154
+            $this->_platform->getCreateSequenceSQL($sequence)
155
+        );
156
+        $this->assertEquals(
157
+            'DROP SEQUENCE myseq',
158
+            $this->_platform->getDropSequenceSQL('myseq')
159
+        );
160
+        $this->assertEquals(
161
+            "SELECT NEXTVAL('myseq')",
162
+            $this->_platform->getSequenceNextValSQL('myseq')
163
+        );
164
+    }
165
+
166
+    public function testDoesNotPreferIdentityColumns()
167
+    {
168
+        $this->assertFalse($this->_platform->prefersIdentityColumns());
169
+    }
170
+
171
+    public function testPrefersSequences()
172
+    {
173
+        $this->assertTrue($this->_platform->prefersSequences());
174
+    }
175
+
176
+    public function testSupportsIdentityColumns()
177
+    {
178
+        $this->assertTrue($this->_platform->supportsIdentityColumns());
179
+    }
180
+
181
+    public function testSupportsSavePoints()
182
+    {
183
+        $this->assertTrue($this->_platform->supportsSavepoints());
184
+    }
185
+
186
+    public function testSupportsSequences()
187
+    {
188
+        $this->assertTrue($this->_platform->supportsSequences());
189
+    }
190
+
191
+    public function testModifyLimitQuery()
192
+    {
193
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
194
+        $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql);
195
+    }
196
+
197
+    public function testModifyLimitQueryWithEmptyOffset()
198
+    {
199
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
200
+        $this->assertEquals('SELECT * FROM user LIMIT 10', $sql);
201
+    }
202
+
203
+    public function getCreateTableColumnCommentsSQL()
204
+    {
205
+        return array(
206
+            "CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))",
207
+            "COMMENT ON COLUMN test.id IS 'This is a comment'",
208
+        );
209
+    }
210
+
211
+    public function getAlterTableColumnCommentsSQL()
212
+    {
213
+        return array(
214
+            "ALTER TABLE mytable ADD quota INT NOT NULL",
215
+            "COMMENT ON COLUMN mytable.quota IS 'A comment'",
216
+            "COMMENT ON COLUMN mytable.baz IS 'B comment'",
217
+        );
218
+    }
219
+}

+ 47 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php Ver fichero

@@ -0,0 +1,47 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Platforms;
4
+
5
+use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator;
6
+use Doctrine\DBAL\Schema\Table;
7
+use Doctrine\DBAL\Schema\Column;
8
+use Doctrine\DBAL\Types\Type;
9
+
10
+class ReservedKeywordsValidatorTest extends \Doctrine\Tests\DbalTestCase
11
+{
12
+    /**
13
+     * @var ReservedKeywordsValidator
14
+     */
15
+    private $validator;
16
+    
17
+    public function setUp()
18
+    {
19
+        $this->validator = new ReservedKeywordsValidator(array(
20
+            new \Doctrine\DBAL\Platforms\Keywords\MySQLKeywords()
21
+        ));
22
+    }
23
+    
24
+    public function testReservedTableName()
25
+    {
26
+        $table = new Table("TABLE");
27
+        $this->validator->acceptTable($table);
28
+        
29
+        $this->assertEquals(
30
+            array('Table TABLE keyword violations: MySQL'),
31
+            $this->validator->getViolations()
32
+        );
33
+    }
34
+    
35
+    public function testReservedColumnName()
36
+    {
37
+        $table = new Table("TABLE");
38
+        $column = $table->addColumn('table', 'string');
39
+        
40
+        $this->validator->acceptColumn($table, $column);
41
+        
42
+        $this->assertEquals(
43
+            array('Table TABLE column table keyword violations: MySQL'),
44
+            $this->validator->getViolations()
45
+        );
46
+    }
47
+}

+ 129 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php Ver fichero

@@ -0,0 +1,129 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Platforms;
4
+
5
+use Doctrine\DBAL\Platforms\SqlitePlatform;
6
+use Doctrine\DBAL\Types\Type;
7
+
8
+require_once __DIR__ . '/../../TestInit.php';
9
+ 
10
+class SqlitePlatformTest extends AbstractPlatformTestCase
11
+{
12
+    public function createPlatform()
13
+    {
14
+        return new SqlitePlatform;
15
+    }
16
+
17
+    public function getGenerateTableSql()
18
+    {
19
+        return 'CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL)';
20
+    }
21
+
22
+    public function getGenerateTableWithMultiColumnUniqueIndexSql()
23
+    {
24
+        return array(
25
+            'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)',
26
+            'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
27
+        );
28
+    }
29
+
30
+    public function testGeneratesSqlSnippets()
31
+    {
32
+        $this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
33
+        $this->assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
34
+        $this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct');
35
+    }
36
+
37
+    public function testGeneratesTransactionCommands()
38
+    {
39
+        $this->assertEquals(
40
+            'PRAGMA read_uncommitted = 0', 
41
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
42
+        );
43
+        $this->assertEquals(
44
+            'PRAGMA read_uncommitted = 1', 
45
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
46
+        );
47
+        $this->assertEquals(
48
+            'PRAGMA read_uncommitted = 1', 
49
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
50
+        );
51
+        $this->assertEquals(
52
+            'PRAGMA read_uncommitted = 1', 
53
+            $this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
54
+        );
55
+    }
56
+
57
+    public function testPrefersIdentityColumns()
58
+    {
59
+        $this->assertTrue($this->_platform->prefersIdentityColumns());
60
+    }
61
+
62
+    public function testGeneratesTypeDeclarationForIntegers()
63
+    {
64
+        $this->assertEquals(
65
+            'INTEGER',
66
+            $this->_platform->getIntegerTypeDeclarationSQL(array())
67
+        );
68
+        $this->assertEquals(
69
+            'INTEGER AUTOINCREMENT',
70
+            $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true))
71
+        );
72
+        $this->assertEquals(
73
+            'INTEGER PRIMARY KEY AUTOINCREMENT',
74
+            $this->_platform->getIntegerTypeDeclarationSQL(
75
+                array('autoincrement' => true, 'primary' => true))
76
+        );
77
+    }
78
+
79
+    public function testGeneratesTypeDeclarationForStrings()
80
+    {
81
+        $this->assertEquals(
82
+            'CHAR(10)',
83
+            $this->_platform->getVarcharTypeDeclarationSQL(
84
+                array('length' => 10, 'fixed' => true))
85
+        );
86
+        $this->assertEquals(
87
+            'VARCHAR(50)',
88
+            $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
89
+            'Variable string declaration is not correct'
90
+        );
91
+        $this->assertEquals(
92
+            'VARCHAR(255)',
93
+            $this->_platform->getVarcharTypeDeclarationSQL(array()),
94
+            'Long string declaration is not correct'
95
+        );
96
+    }
97
+
98
+    public function getGenerateIndexSql()
99
+    {
100
+        return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
101
+    }
102
+
103
+    public function getGenerateUniqueIndexSql()
104
+    {
105
+        return 'CREATE UNIQUE INDEX index_name ON test (test, test2)';
106
+    }
107
+
108
+    public function getGenerateForeignKeySql()
109
+    {
110
+        $this->markTestSkipped('SQLite does not support ForeignKeys.');
111
+    }
112
+
113
+    public function testModifyLimitQuery()
114
+    {
115
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
116
+        $this->assertEquals('SELECT * FROM user LIMIT 10 OFFSET 0', $sql);
117
+    }
118
+
119
+    public function testModifyLimitQueryWithEmptyOffset()
120
+    {
121
+        $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
122
+        $this->assertEquals('SELECT * FROM user LIMIT 10', $sql);
123
+    }
124
+
125
+    public function getGenerateAlterTableSql()
126
+    {
127
+        $this->markTestSkipped('SQlite does not support ALTER Table.');
128
+    }
129
+}

+ 82 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php Ver fichero

@@ -0,0 +1,82 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Query\Expression;
4
+
5
+use Doctrine\DBAL\Query\Expression\CompositeExpression;
6
+
7
+require_once __DIR__ . '/../../../TestInit.php';
8
+
9
+/**
10
+ * @group DBAL-12
11
+ */
12
+class CompositeExpressionTest extends \Doctrine\Tests\DbalTestCase
13
+{
14
+    public function testCount()
15
+    {
16
+        $expr = new CompositeExpression(CompositeExpression::TYPE_OR, array('u.group_id = 1'));
17
+        
18
+        $this->assertEquals(1, count($expr));
19
+        
20
+        $expr->add('u.group_id = 2');
21
+        
22
+        $this->assertEquals(2, count($expr));
23
+    }
24
+    
25
+    /**
26
+     * @dataProvider provideDataForConvertToString
27
+     */
28
+    public function testCompositeUsageAndGeneration($type, $parts, $expects)
29
+    {
30
+        $expr = new CompositeExpression($type, $parts);
31
+        
32
+        $this->assertEquals($expects, (string) $expr);
33
+    }
34
+    
35
+    public function provideDataForConvertToString()
36
+    {
37
+        return array(
38
+            array(
39
+                CompositeExpression::TYPE_AND, 
40
+                array('u.user = 1'), 
41
+                'u.user = 1'
42
+            ),
43
+            array(
44
+                CompositeExpression::TYPE_AND, 
45
+                array('u.user = 1', 'u.group_id = 1'), 
46
+                '(u.user = 1) AND (u.group_id = 1)'
47
+            ),
48
+            array(
49
+                CompositeExpression::TYPE_OR, 
50
+                array('u.user = 1'), 
51
+                'u.user = 1'
52
+            ),
53
+            array(
54
+                CompositeExpression::TYPE_OR, 
55
+                array('u.group_id = 1', 'u.group_id = 2'), 
56
+                '(u.group_id = 1) OR (u.group_id = 2)'
57
+            ),
58
+            array(
59
+                CompositeExpression::TYPE_AND, 
60
+                array(
61
+                    'u.user = 1', 
62
+                    new CompositeExpression(
63
+                        CompositeExpression::TYPE_OR,
64
+                        array('u.group_id = 1', 'u.group_id = 2')
65
+                    )
66
+                ), 
67
+                '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))'
68
+            ),
69
+            array(
70
+                CompositeExpression::TYPE_OR, 
71
+                array(
72
+                    'u.group_id = 1', 
73
+                    new CompositeExpression(
74
+                        CompositeExpression::TYPE_AND,
75
+                        array('u.user = 1', 'u.group_id = 2')
76
+                    )
77
+                ), 
78
+                '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))'
79
+            ),
80
+        );
81
+    }
82
+}

+ 201 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php Ver fichero

@@ -0,0 +1,201 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Query\Expression;
4
+
5
+use Doctrine\DBAL\Query\Expression\ExpressionBuilder,
6
+    Doctrine\DBAL\Query\Expression\CompositeExpression;
7
+
8
+require_once __DIR__ . '/../../../TestInit.php';
9
+
10
+/**
11
+ * @group DBAL-12
12
+ */
13
+class ExpressionBuilderTest extends \Doctrine\Tests\DbalTestCase
14
+{
15
+    protected $expr;
16
+    
17
+    public function setUp()
18
+    {
19
+        $conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
20
+        
21
+        $this->expr = new ExpressionBuilder($conn);
22
+        
23
+        $conn->expects($this->any())
24
+             ->method('getExpressionBuilder')
25
+             ->will($this->returnValue($this->expr));
26
+    }
27
+    
28
+    /**
29
+     * @dataProvider provideDataForAndX
30
+     */
31
+    public function testAndX($parts, $expected)
32
+    {
33
+        $composite = $this->expr->andX();
34
+        
35
+        foreach ($parts as $part) {
36
+            $composite->add($part);
37
+        }
38
+        
39
+        $this->assertEquals($expected, (string) $composite);
40
+    }
41
+    
42
+    public function provideDataForAndX()
43
+    {
44
+        return array(
45
+            array(
46
+                array('u.user = 1'), 
47
+                'u.user = 1'
48
+            ),
49
+            array(
50
+                array('u.user = 1', 'u.group_id = 1'), 
51
+                '(u.user = 1) AND (u.group_id = 1)'
52
+            ),
53
+            array(
54
+                array('u.user = 1'), 
55
+                'u.user = 1'
56
+            ),
57
+            array(
58
+                array('u.group_id = 1', 'u.group_id = 2'), 
59
+                '(u.group_id = 1) AND (u.group_id = 2)'
60
+            ),
61
+            array(
62
+                array(
63
+                    'u.user = 1', 
64
+                    new CompositeExpression(
65
+                        CompositeExpression::TYPE_OR,
66
+                        array('u.group_id = 1', 'u.group_id = 2')
67
+                    )
68
+                ), 
69
+                '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))'
70
+            ),
71
+            array(
72
+                array(
73
+                    'u.group_id = 1', 
74
+                    new CompositeExpression(
75
+                        CompositeExpression::TYPE_AND,
76
+                        array('u.user = 1', 'u.group_id = 2')
77
+                    )
78
+                ), 
79
+                '(u.group_id = 1) AND ((u.user = 1) AND (u.group_id = 2))'
80
+            ),
81
+        );
82
+    }
83
+    
84
+    /**
85
+     * @dataProvider provideDataForOrX
86
+     */
87
+    public function testOrX($parts, $expected)
88
+    {
89
+        $composite = $this->expr->orX();
90
+        
91
+        foreach ($parts as $part) {
92
+            $composite->add($part);
93
+        }
94
+        
95
+        $this->assertEquals($expected, (string) $composite);
96
+    }
97
+    
98
+    public function provideDataForOrX()
99
+    {
100
+        return array(
101
+            array(
102
+                array('u.user = 1'), 
103
+                'u.user = 1'
104
+            ),
105
+            array(
106
+                array('u.user = 1', 'u.group_id = 1'), 
107
+                '(u.user = 1) OR (u.group_id = 1)'
108
+            ),
109
+            array(
110
+                array('u.user = 1'), 
111
+                'u.user = 1'
112
+            ),
113
+            array(
114
+                array('u.group_id = 1', 'u.group_id = 2'), 
115
+                '(u.group_id = 1) OR (u.group_id = 2)'
116
+            ),
117
+            array(
118
+                array(
119
+                    'u.user = 1', 
120
+                    new CompositeExpression(
121
+                        CompositeExpression::TYPE_OR,
122
+                        array('u.group_id = 1', 'u.group_id = 2')
123
+                    )
124
+                ), 
125
+                '(u.user = 1) OR ((u.group_id = 1) OR (u.group_id = 2))'
126
+            ),
127
+            array(
128
+                array(
129
+                    'u.group_id = 1', 
130
+                    new CompositeExpression(
131
+                        CompositeExpression::TYPE_AND,
132
+                        array('u.user = 1', 'u.group_id = 2')
133
+                    )
134
+                ), 
135
+                '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))'
136
+            ),
137
+        );
138
+    }
139
+    
140
+    /**
141
+     * @dataProvider provideDataForComparison
142
+     */
143
+    public function testComparison($leftExpr, $operator, $rightExpr, $expected)
144
+    {
145
+        $part = $this->expr->comparison($leftExpr, $operator, $rightExpr);
146
+        
147
+        $this->assertEquals($expected, (string) $part);
148
+    }
149
+    
150
+    public function provideDataForComparison()
151
+    {
152
+        return array(
153
+            array('u.user_id', ExpressionBuilder::EQ, '1', 'u.user_id = 1'),
154
+            array('u.user_id', ExpressionBuilder::NEQ, '1', 'u.user_id <> 1'),
155
+            array('u.salary', ExpressionBuilder::LT, '10000', 'u.salary < 10000'),
156
+            array('u.salary', ExpressionBuilder::LTE, '10000', 'u.salary <= 10000'),
157
+            array('u.salary', ExpressionBuilder::GT, '10000', 'u.salary > 10000'),
158
+            array('u.salary', ExpressionBuilder::GTE, '10000', 'u.salary >= 10000'),
159
+        );
160
+    }
161
+    
162
+    public function testEq()
163
+    {
164
+        $this->assertEquals('u.user_id = 1', $this->expr->eq('u.user_id', '1'));
165
+    }
166
+    
167
+    public function testNeq()
168
+    {
169
+        $this->assertEquals('u.user_id <> 1', $this->expr->neq('u.user_id', '1'));
170
+    }
171
+    
172
+    public function testLt()
173
+    {
174
+        $this->assertEquals('u.salary < 10000', $this->expr->lt('u.salary', '10000'));
175
+    }
176
+    
177
+    public function testLte()
178
+    {
179
+        $this->assertEquals('u.salary <= 10000', $this->expr->lte('u.salary', '10000'));
180
+    }
181
+    
182
+    public function testGt()
183
+    {
184
+        $this->assertEquals('u.salary > 10000', $this->expr->gt('u.salary', '10000'));
185
+    }
186
+    
187
+    public function testGte()
188
+    {
189
+        $this->assertEquals('u.salary >= 10000', $this->expr->gte('u.salary', '10000'));
190
+    }
191
+    
192
+    public function testIsNull()
193
+    {
194
+        $this->assertEquals('u.deleted IS NULL', $this->expr->isNull('u.deleted'));
195
+    }
196
+    
197
+    public function testIsNotNull()
198
+    {
199
+        $this->assertEquals('u.updated IS NOT NULL', $this->expr->isNotNull('u.updated'));
200
+    }
201
+}

+ 551 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php Ver fichero

@@ -0,0 +1,551 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Query;
4
+
5
+use Doctrine\DBAL\Query\Expression\ExpressionBuilder,
6
+    Doctrine\DBAL\Query\QueryBuilder;
7
+
8
+require_once __DIR__ . '/../../TestInit.php';
9
+
10
+/**
11
+ * @group DBAL-12
12
+ */
13
+class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
14
+{
15
+    protected $conn;
16
+    
17
+    public function setUp()
18
+    {
19
+        $this->conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
20
+        
21
+        $expressionBuilder = new ExpressionBuilder($this->conn);
22
+        
23
+        $this->conn->expects($this->any())
24
+                   ->method('getExpressionBuilder')
25
+                   ->will($this->returnValue($expressionBuilder));
26
+    }
27
+    
28
+    public function testSimpleSelect()
29
+    {
30
+        $qb = new QueryBuilder($this->conn);
31
+                    
32
+        $qb->select('u.id')
33
+           ->from('users', 'u');
34
+           
35
+        $this->assertEquals('SELECT u.id FROM users u', (string) $qb);
36
+    }
37
+    
38
+    public function testSelectWithSimpleWhere()
39
+    {
40
+        $qb   = new QueryBuilder($this->conn);
41
+        $expr = $qb->expr();           
42
+        
43
+        $qb->select('u.id')
44
+           ->from('users', 'u')
45
+           ->where($expr->andX($expr->eq('u.nickname', '?')));
46
+           
47
+        $this->assertEquals("SELECT u.id FROM users u WHERE u.nickname = ?", (string) $qb);
48
+    }
49
+    
50
+    public function testSelectWithLeftJoin()
51
+    {
52
+        $qb   = new QueryBuilder($this->conn);
53
+        $expr = $qb->expr();           
54
+        
55
+        $qb->select('u.*', 'p.*')
56
+           ->from('users', 'u')
57
+           ->leftJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
58
+           
59
+        $this->assertEquals('SELECT u.*, p.* FROM users u LEFT JOIN phones p ON p.user_id = u.id', (string) $qb);
60
+    }
61
+    
62
+    public function testSelectWithJoin()
63
+    {
64
+        $qb   = new QueryBuilder($this->conn);
65
+        $expr = $qb->expr();           
66
+        
67
+        $qb->select('u.*', 'p.*')
68
+           ->from('users', 'u')
69
+           ->Join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
70
+           
71
+        $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb);
72
+    }
73
+    
74
+    public function testSelectWithInnerJoin()
75
+    {
76
+        $qb   = new QueryBuilder($this->conn);
77
+        $expr = $qb->expr();           
78
+        
79
+        $qb->select('u.*', 'p.*')
80
+           ->from('users', 'u')
81
+           ->innerJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
82
+           
83
+        $this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb);
84
+    }
85
+    
86
+    public function testSelectWithRightJoin()
87
+    {
88
+        $qb   = new QueryBuilder($this->conn);
89
+        $expr = $qb->expr();
90
+        
91
+        $qb->select('u.*', 'p.*')
92
+           ->from('users', 'u')
93
+           ->rightJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
94
+           
95
+        $this->assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb);
96
+    }
97
+    
98
+    public function testSelectWithAndWhereConditions()
99
+    {
100
+        $qb   = new QueryBuilder($this->conn);
101
+        $expr = $qb->expr();
102
+        
103
+        $qb->select('u.*', 'p.*')
104
+           ->from('users', 'u')
105
+           ->where('u.username = ?')
106
+           ->andWhere('u.name = ?');
107
+           
108
+        $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb);
109
+    }
110
+    
111
+    public function testSelectWithOrWhereConditions()
112
+    {
113
+        $qb   = new QueryBuilder($this->conn);
114
+        $expr = $qb->expr();
115
+        
116
+        $qb->select('u.*', 'p.*')
117
+           ->from('users', 'u')
118
+           ->where('u.username = ?')
119
+           ->orWhere('u.name = ?');
120
+           
121
+        $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
122
+    }
123
+    
124
+    public function testSelectWithOrOrWhereConditions()
125
+    {
126
+        $qb   = new QueryBuilder($this->conn);
127
+        $expr = $qb->expr();
128
+        
129
+        $qb->select('u.*', 'p.*')
130
+           ->from('users', 'u')
131
+           ->orWhere('u.username = ?')
132
+           ->orWhere('u.name = ?');
133
+           
134
+        $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
135
+    }
136
+    
137
+    public function testSelectWithAndOrWhereConditions()
138
+    {
139
+        $qb   = new QueryBuilder($this->conn);
140
+        $expr = $qb->expr();
141
+        
142
+        $qb->select('u.*', 'p.*')
143
+           ->from('users', 'u')
144
+           ->where('u.username = ?')
145
+           ->andWhere('u.username = ?')
146
+           ->orWhere('u.name = ?')
147
+           ->andWhere('u.name = ?');
148
+           
149
+        $this->assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb);
150
+    }
151
+    
152
+    public function testSelectGroupBy()
153
+    {
154
+        $qb   = new QueryBuilder($this->conn);
155
+        $expr = $qb->expr();
156
+        
157
+        $qb->select('u.*', 'p.*')
158
+           ->from('users', 'u')
159
+           ->groupBy('u.id');
160
+        
161
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb);
162
+    }
163
+    
164
+    public function testSelectEmptyGroupBy()
165
+    {
166
+        $qb   = new QueryBuilder($this->conn);
167
+        $expr = $qb->expr();
168
+        
169
+        $qb->select('u.*', 'p.*')
170
+           ->groupBy(array())
171
+           ->from('users', 'u');
172
+        
173
+        $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
174
+    }
175
+    
176
+    public function testSelectEmptyAddGroupBy()
177
+    {
178
+        $qb   = new QueryBuilder($this->conn);
179
+        $expr = $qb->expr();
180
+        
181
+        $qb->select('u.*', 'p.*')
182
+           ->addGroupBy(array())
183
+           ->from('users', 'u');
184
+        
185
+        $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
186
+    }
187
+    
188
+    public function testSelectAddGroupBy()
189
+    {
190
+        $qb   = new QueryBuilder($this->conn);
191
+        $expr = $qb->expr();
192
+        
193
+        $qb->select('u.*', 'p.*')
194
+           ->from('users', 'u')
195
+           ->groupBy('u.id')
196
+           ->addGroupBy('u.foo');
197
+        
198
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb);
199
+    }
200
+    
201
+    public function testSelectAddGroupBys()
202
+    {
203
+        $qb   = new QueryBuilder($this->conn);
204
+        $expr = $qb->expr();
205
+        
206
+        $qb->select('u.*', 'p.*')
207
+           ->from('users', 'u')
208
+           ->groupBy('u.id')
209
+           ->addGroupBy('u.foo', 'u.bar');
210
+        
211
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb);
212
+    }
213
+    
214
+    public function testSelectHaving()
215
+    {
216
+        $qb   = new QueryBuilder($this->conn);
217
+        $expr = $qb->expr();
218
+        
219
+        $qb->select('u.*', 'p.*')
220
+           ->from('users', 'u')
221
+           ->groupBy('u.id')
222
+           ->having('u.name = ?');
223
+        
224
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
225
+    }
226
+    
227
+    public function testSelectAndHaving()
228
+    {
229
+        $qb   = new QueryBuilder($this->conn);
230
+        $expr = $qb->expr();
231
+        
232
+        $qb->select('u.*', 'p.*')
233
+           ->from('users', 'u')
234
+           ->groupBy('u.id')
235
+           ->andHaving('u.name = ?');
236
+        
237
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
238
+    }
239
+    
240
+    public function testSelectHavingAndHaving()
241
+    {
242
+        $qb   = new QueryBuilder($this->conn);
243
+        $expr = $qb->expr();
244
+        
245
+        $qb->select('u.*', 'p.*')
246
+           ->from('users', 'u')
247
+           ->groupBy('u.id')
248
+           ->having('u.name = ?')
249
+           ->andHaving('u.username = ?');
250
+        
251
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb);
252
+    }
253
+    
254
+    public function testSelectHavingOrHaving()
255
+    {
256
+        $qb   = new QueryBuilder($this->conn);
257
+        $expr = $qb->expr();
258
+        
259
+        $qb->select('u.*', 'p.*')
260
+           ->from('users', 'u')
261
+           ->groupBy('u.id')
262
+           ->having('u.name = ?')
263
+           ->orHaving('u.username = ?');
264
+        
265
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb);
266
+    }
267
+    
268
+    public function testSelectOrHavingOrHaving()
269
+    {
270
+        $qb   = new QueryBuilder($this->conn);
271
+        $expr = $qb->expr();
272
+        
273
+        $qb->select('u.*', 'p.*')
274
+           ->from('users', 'u')
275
+           ->groupBy('u.id')
276
+           ->orHaving('u.name = ?')
277
+           ->orHaving('u.username = ?');
278
+        
279
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb);
280
+    }
281
+    
282
+    public function testSelectHavingAndOrHaving()
283
+    {
284
+        $qb   = new QueryBuilder($this->conn);
285
+        $expr = $qb->expr();
286
+        
287
+        $qb->select('u.*', 'p.*')
288
+           ->from('users', 'u')
289
+           ->groupBy('u.id')
290
+           ->having('u.name = ?')
291
+           ->orHaving('u.username = ?')
292
+           ->andHaving('u.username = ?');
293
+        
294
+        $this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb);
295
+    }
296
+    
297
+    public function testSelectOrderBy()
298
+    {
299
+        $qb   = new QueryBuilder($this->conn);
300
+        $expr = $qb->expr();
301
+        
302
+        $qb->select('u.*', 'p.*')
303
+           ->from('users', 'u')
304
+           ->orderBy('u.name');
305
+        
306
+        $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb);
307
+    }
308
+    
309
+    public function testSelectAddOrderBy()
310
+    {
311
+        $qb   = new QueryBuilder($this->conn);
312
+        $expr = $qb->expr();
313
+        
314
+        $qb->select('u.*', 'p.*')
315
+           ->from('users', 'u')
316
+           ->orderBy('u.name')
317
+           ->addOrderBy('u.username', 'DESC');
318
+        
319
+        $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
320
+    }
321
+    
322
+    public function testSelectAddAddOrderBy()
323
+    {
324
+        $qb   = new QueryBuilder($this->conn);
325
+        $expr = $qb->expr();
326
+        
327
+        $qb->select('u.*', 'p.*')
328
+           ->from('users', 'u')
329
+           ->addOrderBy('u.name')
330
+           ->addOrderBy('u.username', 'DESC');
331
+        
332
+        $this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
333
+    }
334
+    
335
+    public function testEmptySelect()
336
+    {
337
+        $qb   = new QueryBuilder($this->conn);
338
+        $qb2 = $qb->select();
339
+        
340
+        $this->assertSame($qb, $qb2);
341
+        $this->assertEquals(QueryBuilder::SELECT, $qb->getType());
342
+    }
343
+    
344
+    public function testSelectAddSelect()
345
+    {
346
+        $qb   = new QueryBuilder($this->conn);
347
+        $expr = $qb->expr();
348
+        
349
+        $qb->select('u.*')
350
+           ->addSelect('p.*')
351
+           ->from('users', 'u');
352
+        
353
+        $this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
354
+    }
355
+    
356
+    public function testEmptyAddSelect()
357
+    {
358
+        $qb   = new QueryBuilder($this->conn);
359
+        $qb2 = $qb->addSelect();
360
+        
361
+        $this->assertSame($qb, $qb2);
362
+        $this->assertEquals(QueryBuilder::SELECT, $qb->getType());
363
+    }
364
+    
365
+    public function testSelectMultipleFrom()
366
+    {
367
+        $qb   = new QueryBuilder($this->conn);
368
+        $expr = $qb->expr();
369
+        
370
+        $qb->select('u.*')
371
+           ->addSelect('p.*')
372
+           ->from('users', 'u')
373
+           ->from('phonenumbers', 'p');
374
+        
375
+        $this->assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb);
376
+    }
377
+    
378
+    public function testUpdate()
379
+    {
380
+        $qb   = new QueryBuilder($this->conn);
381
+        $qb->update('users', 'u')
382
+           ->set('u.foo', '?')
383
+           ->set('u.bar', '?');
384
+        
385
+        $this->assertEquals(QueryBuilder::UPDATE, $qb->getType());
386
+        $this->assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb);
387
+    }
388
+    
389
+    public function testUpdateWithoutAlias()
390
+    {
391
+        $qb   = new QueryBuilder($this->conn);
392
+        $qb->update('users')
393
+           ->set('foo', '?')
394
+           ->set('bar', '?');
395
+        
396
+        $this->assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb);
397
+    }
398
+    
399
+    public function testUpdateWhere()
400
+    {
401
+        $qb   = new QueryBuilder($this->conn);
402
+        $qb->update('users', 'u')
403
+           ->set('u.foo', '?')
404
+           ->where('u.foo = ?');
405
+        
406
+        $this->assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb);
407
+    }
408
+    
409
+    public function testEmptyUpdate()
410
+    {
411
+        $qb   = new QueryBuilder($this->conn);
412
+        $qb2 = $qb->update();
413
+        
414
+        $this->assertEquals(QueryBuilder::UPDATE, $qb->getType());
415
+        $this->assertSame($qb2, $qb);
416
+    }
417
+    
418
+    public function testDelete()
419
+    {
420
+        $qb   = new QueryBuilder($this->conn);
421
+        $qb->delete('users', 'u');
422
+        
423
+        $this->assertEquals(QueryBuilder::DELETE, $qb->getType());
424
+        $this->assertEquals('DELETE FROM users u', (string) $qb);
425
+    }
426
+    
427
+    public function testDeleteWithoutAlias()
428
+    {
429
+        $qb   = new QueryBuilder($this->conn);
430
+        $qb->delete('users');
431
+        
432
+        $this->assertEquals(QueryBuilder::DELETE, $qb->getType());
433
+        $this->assertEquals('DELETE FROM users', (string) $qb);
434
+    }
435
+    
436
+    public function testDeleteWhere()
437
+    {
438
+        $qb   = new QueryBuilder($this->conn);
439
+        $qb->delete('users', 'u')
440
+           ->where('u.foo = ?');
441
+        
442
+        $this->assertEquals('DELETE FROM users u WHERE u.foo = ?', (string) $qb);
443
+    }
444
+    
445
+    public function testEmptyDelete()
446
+    {
447
+        $qb   = new QueryBuilder($this->conn);
448
+        $qb2 = $qb->delete();
449
+        
450
+        $this->assertEquals(QueryBuilder::DELETE, $qb->getType());
451
+        $this->assertSame($qb2, $qb);
452
+    }
453
+    
454
+    public function testGetConnection()
455
+    {
456
+        $qb   = new QueryBuilder($this->conn);
457
+        $this->assertSame($this->conn, $qb->getConnection());
458
+    }
459
+    
460
+    public function testGetState()
461
+    {
462
+        $qb   = new QueryBuilder($this->conn);
463
+        
464
+        $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState());
465
+        
466
+        $qb->select('u.*')->from('users', 'u');
467
+        
468
+        $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
469
+        
470
+        $sql1 = $qb->getSQL();
471
+        
472
+        $this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState());
473
+        $this->assertEquals($sql1, $qb->getSQL());
474
+    }
475
+    
476
+    public function testSetMaxResults()
477
+    {
478
+        $qb   = new QueryBuilder($this->conn);
479
+        $qb->setMaxResults(10);
480
+        
481
+        $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
482
+        $this->assertEQuals(10, $qb->getMaxResults());
483
+    }
484
+    
485
+    public function testSetFirstResult()
486
+    {
487
+        $qb   = new QueryBuilder($this->conn);
488
+        $qb->setFirstResult(10);
489
+        
490
+        $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
491
+        $this->assertEQuals(10, $qb->getFirstResult());
492
+    }
493
+    
494
+    public function testResetQueryPart()
495
+    {
496
+        $qb   = new QueryBuilder($this->conn);
497
+        
498
+        $qb->select('u.*')->from('users', 'u')->where('u.name = ?');
499
+        
500
+        $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb);
501
+        $qb->resetQueryPart('where');
502
+        $this->assertEquals('SELECT u.* FROM users u', (string)$qb);
503
+    }
504
+    
505
+    public function testResetQueryParts()
506
+    {
507
+        $qb   = new QueryBuilder($this->conn);
508
+        
509
+        $qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name');
510
+        
511
+        $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ? ORDER BY u.name ASC', (string)$qb);
512
+        $qb->resetQueryParts(array('where', 'orderBy'));
513
+        $this->assertEquals('SELECT u.* FROM users u', (string)$qb);
514
+    }
515
+    
516
+    public function testCreateNamedParameter()
517
+    {
518
+        $qb   = new QueryBuilder($this->conn);
519
+        
520
+        $qb->select('u.*')->from('users', 'u')->where(
521
+            $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT))
522
+        );
523
+        
524
+        $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :dcValue1', (string)$qb);
525
+        $this->assertEquals(10, $qb->getParameter('dcValue1'));
526
+    }
527
+    
528
+    public function testCreateNamedParameterCustomPlaceholder()
529
+    {
530
+        $qb   = new QueryBuilder($this->conn);
531
+        
532
+        $qb->select('u.*')->from('users', 'u')->where(
533
+            $qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT, ':test'))
534
+        );
535
+        
536
+        $this->assertEquals('SELECT u.* FROM users u WHERE u.name = :test', (string)$qb);
537
+        $this->assertEquals(10, $qb->getParameter('test'));
538
+    }
539
+    
540
+    public function testCreatePositionalParameter()
541
+    {
542
+        $qb   = new QueryBuilder($this->conn);
543
+        
544
+        $qb->select('u.*')->from('users', 'u')->where(
545
+            $qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT))
546
+        );
547
+        
548
+        $this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb);
549
+        $this->assertEquals(10, $qb->getParameter(1));
550
+    }
551
+}

+ 119 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php Ver fichero

@@ -0,0 +1,119 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL;
4
+
5
+use Doctrine\DBAL\Connection;
6
+use Doctrine\DBAL\SQLParserUtils;
7
+
8
+require_once __DIR__ . '/../TestInit.php';
9
+
10
+/**
11
+ * @group DBAL-78
12
+ */
13
+class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
14
+{
15
+    static public function dataGetPlaceholderPositions()
16
+    {
17
+        return array(
18
+            // none
19
+            array('SELECT * FROM Foo', true, array()),
20
+            array('SELECT * FROM Foo', false, array()),
21
+            
22
+            // Positionals
23
+            array('SELECT ?', true, array(7)),
24
+            array('SELECT * FROM Foo WHERE bar IN (?, ?, ?)', true, array(32, 35, 38)),
25
+            array('SELECT ? FROM ?', true, array(7, 14)),
26
+            array('SELECT "?" FROM foo', true, array()),
27
+            array("SELECT '?' FROM foo", true, array()),
28
+            array('SELECT "?" FROM foo WHERE bar = ?', true, array(32)),
29
+            array("SELECT '?' FROM foo WHERE bar = ?", true, array(32)),
30
+            
31
+            // named
32
+            array('SELECT :foo FROM :bar', false, array(':foo' => array(7), ':bar' => array(17))),
33
+            array('SELECT * FROM Foo WHERE bar IN (:name1, :name2)', false, array(':name1' => array(32), ':name2' => array(40))),
34
+            array('SELECT ":foo" FROM Foo WHERE bar IN (:name1, :name2)', false, array(':name1' => array(37), ':name2' => array(45))),
35
+            array("SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, array(':name1' => array(37), ':name2' => array(45))),
36
+        );
37
+    }
38
+    
39
+    /**
40
+     * @dataProvider dataGetPlaceholderPositions
41
+     * @param type $query
42
+     * @param type $isPositional
43
+     * @param type $expectedParamPos
44
+     */
45
+    public function testGetPlaceholderPositions($query, $isPositional, $expectedParamPos)
46
+    {
47
+        $actualParamPos = SQLParserUtils::getPlaceholderPositions($query, $isPositional);
48
+        $this->assertEquals($expectedParamPos, $actualParamPos);
49
+    }
50
+    
51
+    static public function dataExpandListParameters()
52
+    {
53
+        return array(
54
+            // Positional: Very simple with one needle
55
+            array(
56
+                "SELECT * FROM Foo WHERE foo IN (?)",
57
+                array(array(1, 2, 3)),
58
+                array(Connection::PARAM_INT_ARRAY),
59
+                'SELECT * FROM Foo WHERE foo IN (?, ?, ?)',
60
+                array(1, 2, 3),
61
+                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
62
+            ),
63
+            // Positional: One non-list before d one after list-needle
64
+            array(
65
+                "SELECT * FROM Foo WHERE foo = ? AND bar IN (?)",
66
+                array("string", array(1, 2, 3)),
67
+                array(\PDO::PARAM_STR, Connection::PARAM_INT_ARRAY),
68
+                'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)',
69
+                array("string", 1, 2, 3),
70
+                array(\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
71
+            ),
72
+            // Positional: One non-list after list-needle
73
+            array(
74
+                "SELECT * FROM Foo WHERE bar IN (?) AND baz = ?",
75
+                array(array(1, 2, 3), "foo"),
76
+                array(Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR),
77
+                'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?',
78
+                array(1, 2, 3, "foo"),
79
+                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_STR)
80
+            ),
81
+            // Positional: One non-list before and one after list-needle
82
+            array(
83
+                "SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?",
84
+                array(1, array(1, 2, 3), 4),
85
+                array(\PDO::PARAM_INT, Connection::PARAM_INT_ARRAY, \PDO::PARAM_INT),
86
+                'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?',
87
+                array(1, 1, 2, 3, 4),
88
+                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
89
+            ),
90
+            // Positional: Two lists
91
+            array(
92
+                "SELECT * FROM Foo WHERE foo IN (?, ?)",
93
+                array(array(1, 2, 3), array(4, 5)),
94
+                array(Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY),
95
+                'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)',
96
+                array(1, 2, 3, 4, 5),
97
+                array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
98
+            ),
99
+        );
100
+    }
101
+    
102
+    /**
103
+     * @dataProvider dataExpandListParameters
104
+     * @param type $q
105
+     * @param type $p
106
+     * @param type $t
107
+     * @param type $expectedQuery
108
+     * @param type $expectedParams
109
+     * @param type $expectedTypes
110
+     */
111
+    public function testExpandListParameters($q, $p, $t, $expectedQuery, $expectedParams, $expectedTypes)
112
+    {
113
+        list($query, $params, $types) = SQLParserUtils::expandListParameters($q, $p, $t);
114
+        
115
+        $this->assertEquals($expectedQuery, $query, "Query was not rewritten correctly.");
116
+        $this->assertEquals($expectedParams, $params, "Params dont match");
117
+        $this->assertEquals($expectedTypes, $types, "Types dont match");
118
+    }
119
+}

+ 107 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php Ver fichero

@@ -0,0 +1,107 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Schema;
4
+
5
+require_once __DIR__ . '/../../TestInit.php';
6
+
7
+use Doctrine\DBAL\Schema\Schema;
8
+use Doctrine\DBAL\Schema\Table;
9
+use Doctrine\DBAL\Schema\Column;
10
+use Doctrine\DBAL\Types\Type;
11
+
12
+class ColumnTest extends \PHPUnit_Framework_TestCase
13
+{
14
+    public function testGet()
15
+    {
16
+        $column = $this->createColumn();
17
+
18
+        $this->assertEquals("foo", $column->getName());
19
+        $this->assertSame(Type::getType('string'), $column->getType());
20
+
21
+        $this->assertEquals(200, $column->getLength());
22
+        $this->assertEquals(5, $column->getPrecision());
23
+        $this->assertEquals(2, $column->getScale());
24
+        $this->assertTrue($column->getUnsigned());
25
+        $this->assertFalse($column->getNotNull());
26
+        $this->assertTrue($column->getFixed());
27
+        $this->assertEquals("baz", $column->getDefault());
28
+
29
+        $this->assertEquals(array('foo' => 'bar'), $column->getPlatformOptions());
30
+        $this->assertTrue($column->hasPlatformOption('foo'));
31
+        $this->assertEquals('bar', $column->getPlatformOption('foo'));
32
+        $this->assertFalse($column->hasPlatformOption('bar'));
33
+    }
34
+
35
+    public function testToArray()
36
+    {
37
+        $expected = array(
38
+            'name' => 'foo',
39
+            'type' => Type::getType('string'),
40
+            'default' => 'baz',
41
+            'notnull' => false,
42
+            'length' => 200,
43
+            'precision' => 5,
44
+            'scale' => 2,
45
+            'fixed' => true,
46
+            'unsigned' => true,
47
+            'autoincrement' => false,
48
+            'columnDefinition' => null,
49
+            'comment' => null,
50
+            'foo' => 'bar',
51
+        );
52
+
53
+        $this->assertEquals($expected, $this->createColumn()->toArray());
54
+    }
55
+
56
+    /**
57
+     * @return Column
58
+     */
59
+    public function createColumn()
60
+    {
61
+        $options = array(
62
+            'length' => 200,
63
+            'precision' => 5,
64
+            'scale' => 2,
65
+            'unsigned' => true,
66
+            'notnull' => false,
67
+            'fixed' => true,
68
+            'default' => 'baz',
69
+            'platformOptions' => array('foo' => 'bar'),
70
+        );
71
+
72
+        $string = Type::getType('string');
73
+        return new Column("foo", $string, $options);
74
+    }
75
+
76
+    /**
77
+     * @group DBAL-64
78
+     */
79
+    public function testQuotedColumnName()
80
+    {
81
+        $string = Type::getType('string');
82
+        $column = new Column("`bar`", $string, array());
83
+
84
+        $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform();
85
+        $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform();
86
+
87
+        $this->assertEquals('bar', $column->getName());
88
+        $this->assertEquals('`bar`', $column->getQuotedName($mysqlPlatform));
89
+        $this->assertEquals('"bar"', $column->getQuotedName($sqlitePlatform));
90
+    }
91
+
92
+    /**
93
+     * @group DBAL-42
94
+     */
95
+    public function testColumnComment()
96
+    {
97
+        $column = new Column("bar", Type::getType('string'));
98
+        $this->assertNull($column->getComment());
99
+
100
+        $column->setComment("foo");
101
+        $this->assertEquals("foo", $column->getComment());
102
+
103
+        $columnArray = $column->toArray();
104
+        $this->assertArrayHasKey('comment', $columnArray);
105
+        $this->assertEquals('foo', $columnArray['comment']);
106
+    }
107
+}

+ 714 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php Ver fichero

@@ -0,0 +1,714 @@
1
+<?php
2
+/*
3
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
+ *
15
+ * This software consists of voluntary contributions made by many individuals
16
+ * and is licensed under the LGPL. For more information, see
17
+ * <http://www.doctrine-project.org>.
18
+ */
19
+
20
+namespace Doctrine\Tests\DBAL\Schema;
21
+
22
+require_once __DIR__ . '/../../TestInit.php';
23
+
24
+use Doctrine\DBAL\Schema\Schema,
25
+    Doctrine\DBAL\Schema\Table,
26
+    Doctrine\DBAL\Schema\Column,
27
+    Doctrine\DBAL\Schema\Index,
28
+    Doctrine\DBAL\Schema\Sequence,
29
+    Doctrine\DBAL\Schema\SchemaDiff,
30
+    Doctrine\DBAL\Schema\TableDiff,
31
+    Doctrine\DBAL\Schema\Comparator,
32
+    Doctrine\DBAL\Types\Type,
33
+    Doctrine\DBAL\Schema\ForeignKeyConstraint;
34
+
35
+/**
36
+ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
37
+ * @link    www.doctrine-project.org
38
+ * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
39
+ * @license http://ez.no/licenses/new_bsd New BSD License
40
+ * @since   2.0
41
+ * @version $Revision$
42
+ * @author  Benjamin Eberlei <kontakt@beberlei.de>
43
+ */
44
+class ComparatorTest extends \PHPUnit_Framework_TestCase
45
+{
46
+    public function testCompareSame1()
47
+    {
48
+        $schema1 = new Schema( array(
49
+            'bugdb' => new Table('bugdb',
50
+                array (
51
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer' ) ),
52
+                )
53
+            ),
54
+        ) );
55
+        $schema2 = new Schema( array(
56
+            'bugdb' => new Table('bugdb',
57
+                array (
58
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer') ),
59
+                )
60
+            ),
61
+        ) );
62
+
63
+        $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) );
64
+    }
65
+
66
+    public function testCompareSame2()
67
+    {
68
+        $schema1 = new Schema( array(
69
+            'bugdb' => new Table('bugdb',
70
+                array (
71
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
72
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
73
+                )
74
+            ),
75
+        ) );
76
+        $schema2 = new Schema( array(
77
+            'bugdb' => new Table('bugdb',
78
+                array (
79
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
80
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
81
+                )
82
+            ),
83
+        ) );
84
+        $this->assertEquals(new SchemaDiff(), Comparator::compareSchemas( $schema1, $schema2 ) );
85
+    }
86
+
87
+    public function testCompareMissingTable()
88
+    {
89
+        $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig;
90
+        $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer'))));
91
+        $table->setSchemaConfig($schemaConfig);
92
+        
93
+        $schema1 = new Schema( array($table), array(), $schemaConfig );
94
+        $schema2 = new Schema( array(),       array(), $schemaConfig );
95
+
96
+        $expected = new SchemaDiff( array(), array(), array('bugdb' => $table) );
97
+        
98
+        $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
99
+    }
100
+
101
+    public function testCompareNewTable()
102
+    {
103
+        $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig;
104
+        $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer'))));
105
+        $table->setSchemaConfig($schemaConfig);
106
+
107
+        $schema1 = new Schema( array(),       array(), $schemaConfig );
108
+        $schema2 = new Schema( array($table), array(), $schemaConfig );
109
+
110
+        $expected = new SchemaDiff( array('bugdb' => $table), array(), array() );
111
+        $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
112
+    }
113
+
114
+    public function testCompareOnlyAutoincrementChanged()
115
+    {
116
+        $column1 = new Column('foo', Type::getType('integer'), array('autoincrement' => true));
117
+        $column2 = new Column('foo', Type::getType('integer'), array('autoincrement' => false));
118
+
119
+        $comparator = new Comparator();
120
+        $changedProperties = $comparator->diffColumn($column1, $column2);
121
+
122
+        $this->assertEquals(array('autoincrement'), $changedProperties);
123
+    }
124
+
125
+    public function testCompareMissingField()
126
+    {
127
+        $missingColumn = new Column('integerfield1', Type::getType('integer'));
128
+        $schema1 = new Schema( array(
129
+            'bugdb' => new Table('bugdb',
130
+                array (
131
+                    'integerfield1' => $missingColumn,
132
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
133
+                )
134
+            ),
135
+        ) );
136
+        $schema2 = new Schema( array(
137
+            'bugdb' => new Table('bugdb',
138
+                array (
139
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
140
+                )
141
+            ),
142
+        ) );
143
+
144
+        $expected = new SchemaDiff ( array(),
145
+            array (
146
+                'bugdb' => new TableDiff( 'bugdb', array(), array(),
147
+                    array (
148
+                        'integerfield1' => $missingColumn,
149
+                    )
150
+                )
151
+            )
152
+        );
153
+        $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
154
+    }
155
+
156
+    public function testCompareNewField()
157
+    {
158
+        $schema1 = new Schema( array(
159
+            'bugdb' => new Table('bugdb',
160
+                array (
161
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
162
+                )
163
+            ),
164
+        ) );
165
+        $schema2 = new Schema( array(
166
+            'bugdb' => new Table('bugdb',
167
+                array (
168
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
169
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
170
+                )
171
+            ),
172
+        ) );
173
+
174
+        $expected = new SchemaDiff ( array(),
175
+            array (
176
+                'bugdb' => new TableDiff ('bugdb',
177
+                    array (
178
+                        'integerfield2' => new Column('integerfield2', Type::getType('integer')),
179
+                    )
180
+                ),
181
+            )
182
+        );
183
+        $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
184
+    }
185
+
186
+    public function testCompareChangedColumns_ChangeType()
187
+    {
188
+        $column1 = new Column('charfield1', Type::getType('string'));
189
+        $column2 = new Column('charfield1', Type::getType('integer'));
190
+
191
+        $c = new Comparator();
192
+        $this->assertEquals(array('type'), $c->diffColumn($column1, $column2));
193
+        $this->assertEquals(array(), $c->diffColumn($column1, $column1));
194
+    }
195
+
196
+    public function testCompareRemovedIndex()
197
+    {
198
+        $schema1 = new Schema( array(
199
+            'bugdb' => new Table('bugdb',
200
+                array (
201
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
202
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
203
+                ),
204
+                array (
205
+                    'primary' => new Index('primary',
206
+                        array(
207
+                            'integerfield1'
208
+                        ),
209
+                        true
210
+                    )
211
+                )
212
+            ),
213
+        ) );
214
+        $schema2 = new Schema( array(
215
+            'bugdb' => new Table('bugdb',
216
+                array (
217
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
218
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
219
+                )
220
+            ),
221
+        ) );
222
+
223
+        $expected = new SchemaDiff ( array(),
224
+            array (
225
+                'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), array(),
226
+                    array (
227
+                        'primary' => new Index('primary',
228
+                        array(
229
+                            'integerfield1'
230
+                        ),
231
+                        true
232
+                    )
233
+                    )
234
+                ),
235
+            )
236
+        );
237
+        $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
238
+    }
239
+
240
+    public function testCompareNewIndex()
241
+    {
242
+        $schema1 = new Schema( array(
243
+            'bugdb' => new Table('bugdb',
244
+                array (
245
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
246
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
247
+                )
248
+            ),
249
+        ) );
250
+        $schema2 = new Schema( array(
251
+            'bugdb' => new Table('bugdb',
252
+                array (
253
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
254
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
255
+                ),
256
+                array (
257
+                    'primary' => new Index('primary',
258
+                        array(
259
+                            'integerfield1'
260
+                        ),
261
+                        true
262
+                    )
263
+                )
264
+            ),
265
+        ) );
266
+
267
+        $expected = new SchemaDiff ( array(),
268
+            array (
269
+                'bugdb' => new TableDiff( 'bugdb', array(), array(), array(),
270
+                    array (
271
+                        'primary' => new Index('primary',
272
+                            array(
273
+                                'integerfield1'
274
+                            ),
275
+                            true
276
+                        )
277
+                    )
278
+                ),
279
+            )
280
+        );
281
+        $this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
282
+    }
283
+
284
+    public function testCompareChangedIndex()
285
+    {
286
+        $schema1 = new Schema( array(
287
+            'bugdb' => new Table('bugdb',
288
+                array (
289
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
290
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
291
+                ),
292
+                array (
293
+                    'primary' => new Index('primary',
294
+                        array(
295
+                            'integerfield1'
296
+                        ),
297
+                        true
298
+                    )
299
+                )
300
+            ),
301
+        ) );
302
+        $schema2 = new Schema( array(
303
+            'bugdb' => new Table('bugdb',
304
+                array (
305
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
306
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
307
+                ),
308
+                array (
309
+                    'primary' => new Index('primary',
310
+                        array('integerfield1', 'integerfield2'),
311
+                        true
312
+                    )
313
+                )
314
+            ),
315
+        ) );
316
+
317
+        $expected = new SchemaDiff ( array(),
318
+            array (
319
+                'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(),
320
+                    array (
321
+                        'primary' => new Index('primary',
322
+                            array(
323
+                                'integerfield1',
324
+                                'integerfield2'
325
+                            ),
326
+                            true
327
+                        )
328
+                    )
329
+                ),
330
+            )
331
+        );
332
+        $actual = Comparator::compareSchemas( $schema1, $schema2 );
333
+        $this->assertEquals($expected, $actual);
334
+    }
335
+
336
+    public function testCompareChangedIndexFieldPositions()
337
+    {
338
+        $schema1 = new Schema( array(
339
+            'bugdb' => new Table('bugdb',
340
+                array (
341
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
342
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
343
+                ),
344
+                array (
345
+                    'primary' => new Index('primary', array('integerfield1', 'integerfield2'), true)
346
+                )
347
+            ),
348
+        ) );
349
+        $schema2 = new Schema( array(
350
+            'bugdb' => new Table('bugdb',
351
+                array (
352
+                    'integerfield1' => new Column('integerfield1', Type::getType('integer')),
353
+                    'integerfield2' => new Column('integerfield2', Type::getType('integer')),
354
+                ),
355
+                array (
356
+                    'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)
357
+                )
358
+            ),
359
+        ) );
360
+
361
+        $expected = new SchemaDiff ( array(),
362
+            array (
363
+                'bugdb' => new TableDiff('bugdb', array(), array(), array(), array(),
364
+                    array (
365
+                        'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)
366
+                    )
367
+                ),
368
+            )
369
+        );
370
+        $actual = Comparator::compareSchemas( $schema1, $schema2 );
371
+        $this->assertEquals($expected, $actual);
372
+    }
373
+
374
+    public function testCompareSequences()
375
+    {
376
+        $seq1 = new Sequence('foo', 1, 1);
377
+        $seq2 = new Sequence('foo', 1, 2);
378
+        $seq3 = new Sequence('foo', 2, 1);
379
+
380
+        $c = new Comparator();
381
+
382
+        $this->assertTrue($c->diffSequence($seq1, $seq2));
383
+        $this->assertTrue($c->diffSequence($seq1, $seq3));
384
+    }
385
+
386
+    public function testRemovedSequence()
387
+    {
388
+        $schema1 = new Schema();
389
+        $seq = $schema1->createSequence('foo');
390
+
391
+        $schema2 = new Schema();
392
+
393
+        $c = new Comparator();
394
+        $diffSchema = $c->compare($schema1, $schema2);
395
+
396
+        $this->assertEquals(1, count($diffSchema->removedSequences));
397
+        $this->assertSame($seq, $diffSchema->removedSequences[0]);
398
+    }
399
+
400
+    public function testAddedSequence()
401
+    {
402
+        $schema1 = new Schema();
403
+
404
+        $schema2 = new Schema();
405
+        $seq = $schema2->createSequence('foo');
406
+
407
+        $c = new Comparator();
408
+        $diffSchema = $c->compare($schema1, $schema2);
409
+
410
+        $this->assertEquals(1, count($diffSchema->newSequences));
411
+        $this->assertSame($seq, $diffSchema->newSequences[0]);
412
+    }
413
+
414
+    public function testTableAddForeignKey()
415
+    {
416
+        $tableForeign = new Table("bar");
417
+        $tableForeign->addColumn('id', 'integer');
418
+
419
+        $table1 = new Table("foo");
420
+        $table1->addColumn('fk', 'integer');
421
+
422
+        $table2 = new Table("foo");
423
+        $table2->addColumn('fk', 'integer');
424
+        $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
425
+
426
+        $c = new Comparator();
427
+        $tableDiff = $c->diffTable($table1, $table2);
428
+
429
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
430
+        $this->assertEquals(1, count($tableDiff->addedForeignKeys));
431
+    }
432
+
433
+    public function testTableRemoveForeignKey()
434
+    {
435
+        $tableForeign = new Table("bar");
436
+        $tableForeign->addColumn('id', 'integer');
437
+
438
+        $table1 = new Table("foo");
439
+        $table1->addColumn('fk', 'integer');
440
+
441
+        $table2 = new Table("foo");
442
+        $table2->addColumn('fk', 'integer');
443
+        $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
444
+
445
+        $c = new Comparator();
446
+        $tableDiff = $c->diffTable($table2, $table1);
447
+
448
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
449
+        $this->assertEquals(1, count($tableDiff->removedForeignKeys));
450
+    }
451
+
452
+    public function testTableUpdateForeignKey()
453
+    {
454
+        $tableForeign = new Table("bar");
455
+        $tableForeign->addColumn('id', 'integer');
456
+
457
+        $table1 = new Table("foo");
458
+        $table1->addColumn('fk', 'integer');
459
+        $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
460
+
461
+        $table2 = new Table("foo");
462
+        $table2->addColumn('fk', 'integer');
463
+        $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'), array('onUpdate' => 'CASCADE'));
464
+
465
+        $c = new Comparator();
466
+        $tableDiff = $c->diffTable($table1, $table2);
467
+
468
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
469
+        $this->assertEquals(1, count($tableDiff->changedForeignKeys));
470
+    }
471
+
472
+    public function testTablesCaseInsensitive()
473
+    {
474
+        $schemaA = new Schema();
475
+        $schemaA->createTable('foo');
476
+        $schemaA->createTable('bAr');
477
+        $schemaA->createTable('BAZ');
478
+        $schemaA->createTable('new');
479
+
480
+        $schemaB = new Schema();
481
+        $schemaB->createTable('FOO');
482
+        $schemaB->createTable('bar');
483
+        $schemaB->createTable('Baz');
484
+        $schemaB->createTable('old');
485
+
486
+        $c = new Comparator();
487
+        $diff = $c->compare($schemaA, $schemaB);
488
+
489
+        $this->assertSchemaTableChangeCount($diff, 1, 0, 1);
490
+    }
491
+
492
+    public function testSequencesCaseInsenstive()
493
+    {
494
+        $schemaA = new Schema();
495
+        $schemaA->createSequence('foo');
496
+        $schemaA->createSequence('BAR');
497
+        $schemaA->createSequence('Baz');
498
+        $schemaA->createSequence('new');
499
+
500
+        $schemaB = new Schema();
501
+        $schemaB->createSequence('FOO');
502
+        $schemaB->createSequence('Bar');
503
+        $schemaB->createSequence('baz');
504
+        $schemaB->createSequence('old');
505
+        
506
+        $c = new Comparator();
507
+        $diff = $c->compare($schemaA, $schemaB);
508
+
509
+        $this->assertSchemaSequenceChangeCount($diff, 1, 0, 1);
510
+    }
511
+
512
+    public function testCompareColumnCompareCaseInsensitive()
513
+    {
514
+        $tableA = new Table("foo");
515
+        $tableA->addColumn('id', 'integer');
516
+
517
+        $tableB = new Table("foo");
518
+        $tableB->addColumn('ID', 'integer');
519
+
520
+        $c = new Comparator();
521
+        $tableDiff = $c->diffTable($tableA, $tableB);
522
+
523
+        $this->assertFalse($tableDiff);
524
+    }
525
+
526
+    public function testCompareIndexBasedOnPropertiesNotName()
527
+    {
528
+        $tableA = new Table("foo");
529
+        $tableA->addColumn('id', 'integer');
530
+        $tableA->addIndex(array("id"), "foo_bar_idx");
531
+
532
+        $tableB = new Table("foo");
533
+        $tableB->addColumn('ID', 'integer');
534
+        $tableB->addIndex(array("id"), "bar_foo_idx");
535
+
536
+        $c = new Comparator();
537
+        $tableDiff = $c->diffTable($tableA, $tableB);
538
+
539
+        $this->assertFalse($tableDiff);
540
+    }
541
+
542
+    public function testCompareForeignKeyBasedOnPropertiesNotName()
543
+    {
544
+        $tableA = new Table("foo");
545
+        $tableA->addColumn('id', 'integer');
546
+        $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id'));
547
+
548
+        $tableB = new Table("foo");
549
+        $tableB->addColumn('ID', 'integer');
550
+        $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id'));
551
+
552
+        $c = new Comparator();
553
+        $tableDiff = $c->diffTable($tableA, $tableB);
554
+
555
+        $this->assertFalse($tableDiff);
556
+    }
557
+
558
+    public function testCompareForeignKey_RestrictNoAction_AreTheSame()
559
+    {
560
+        $fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION'));
561
+        $fk2 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'RESTRICT'));
562
+
563
+        $c = new Comparator();
564
+        $this->assertFalse($c->diffForeignKey($fk1, $fk2));
565
+    }
566
+
567
+    public function testDetectRenameColumn()
568
+    {
569
+        $tableA = new Table("foo");
570
+        $tableA->addColumn('foo', 'integer');
571
+
572
+        $tableB = new Table("foo");
573
+        $tableB->addColumn('bar', 'integer');
574
+
575
+        $c = new Comparator();
576
+        $tableDiff = $c->diffTable($tableA, $tableB);
577
+
578
+        $this->assertEquals(0, count($tableDiff->addedColumns));
579
+        $this->assertEquals(0, count($tableDiff->removedColumns));
580
+        $this->assertArrayHasKey('foo', $tableDiff->renamedColumns);
581
+        $this->assertEquals('bar', $tableDiff->renamedColumns['foo']->getName());
582
+    }
583
+
584
+    /**
585
+     * You can easily have ambiguouties in the column renaming. If these
586
+     * are detected no renaming should take place, instead adding and dropping
587
+     * should be used exclusively.
588
+     *
589
+     * @group DBAL-24
590
+     */
591
+    public function testDetectRenameColumnAmbiguous()
592
+    {
593
+        $tableA = new Table("foo");
594
+        $tableA->addColumn('foo', 'integer');
595
+        $tableA->addColumn('bar', 'integer');
596
+
597
+        $tableB = new Table("foo");
598
+        $tableB->addColumn('baz', 'integer');
599
+        
600
+        $c = new Comparator();
601
+        $tableDiff = $c->diffTable($tableA, $tableB);
602
+
603
+        $this->assertEquals(1, count($tableDiff->addedColumns), "'baz' should be added, not created through renaming!");
604
+        $this->assertArrayHasKey('baz', $tableDiff->addedColumns, "'baz' should be added, not created through renaming!");
605
+        $this->assertEquals(2, count($tableDiff->removedColumns), "'foo' and 'bar' should both be dropped, an ambigouty exists which one could be renamed to 'baz'.");
606
+        $this->assertArrayHasKey('foo', $tableDiff->removedColumns, "'foo' should be removed.");
607
+        $this->assertArrayHasKey('bar', $tableDiff->removedColumns, "'bar' should be removed.");
608
+        $this->assertEquals(0, count($tableDiff->renamedColumns), "no renamings should take place.");
609
+    }
610
+
611
+    public function testDetectChangeIdentifierType()
612
+    {
613
+        $this->markTestSkipped('DBAL-2 was reopened, this test cannot work anymore.');
614
+
615
+        $tableA = new Table("foo");
616
+        $tableA->addColumn('id', 'integer', array('autoincrement' => false));
617
+
618
+        $tableB = new Table("foo");
619
+        $tableB->addColumn('id', 'integer', array('autoincrement' => true));
620
+
621
+        $c = new Comparator();
622
+        $tableDiff = $c->diffTable($tableA, $tableB);
623
+
624
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
625
+        $this->assertArrayHasKey('id', $tableDiff->changedColumns);
626
+    }
627
+
628
+
629
+    /**
630
+     * @group DBAL-105
631
+     */
632
+    public function testDiff()
633
+    {
634
+        $table = new \Doctrine\DBAL\Schema\Table('twitter_users');
635
+        $table->addColumn('id', 'integer', array('autoincrement' => true));
636
+        $table->addColumn('twitterId', 'integer', array('nullable' => false));
637
+        $table->addColumn('displayName', 'string', array('nullable' => false));
638
+        $table->setPrimaryKey(array('id'));
639
+
640
+        $newtable = new \Doctrine\DBAL\Schema\Table('twitter_users');
641
+        $newtable->addColumn('id', 'integer', array('autoincrement' => true));
642
+        $newtable->addColumn('twitter_id', 'integer', array('nullable' => false));
643
+        $newtable->addColumn('display_name', 'string', array('nullable' => false));
644
+        $newtable->addColumn('logged_in_at', 'datetime', array('nullable' => true));
645
+        $newtable->setPrimaryKey(array('id'));
646
+
647
+        $c = new Comparator();
648
+        $tableDiff = $c->diffTable($table, $newtable);
649
+
650
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
651
+        $this->assertEquals(array('twitterid', 'displayname'), array_keys($tableDiff->renamedColumns));
652
+        $this->assertEquals(array('logged_in_at'), array_keys($tableDiff->addedColumns));
653
+        $this->assertEquals(0, count($tableDiff->removedColumns));
654
+    }
655
+    
656
+    
657
+    /**
658
+     * @group DBAL-112
659
+     */
660
+    public function testChangedSequence()
661
+    {
662
+        $schema = new Schema();
663
+        $sequence = $schema->createSequence('baz');
664
+        
665
+        $schemaNew = clone $schema;
666
+        /* @var $schemaNew Schema */
667
+        $schemaNew->getSequence('baz')->setAllocationSize(20);
668
+        
669
+        $c = new \Doctrine\DBAL\Schema\Comparator;
670
+        $diff = $c->compare($schema, $schemaNew);
671
+        
672
+        $this->assertSame($diff->changedSequences[0] , $schemaNew->getSequence('baz'));
673
+    }
674
+
675
+    /**
676
+     * @group DBAL-106
677
+     */
678
+    public function testDiffDecimalWithNullPrecision()
679
+    {
680
+        $column = new Column('foo', Type::getType('decimal'));
681
+        $column->setPrecision(null);
682
+
683
+        $column2 = new Column('foo', Type::getType('decimal'));
684
+
685
+        $c = new Comparator();
686
+        $this->assertEquals(array(), $c->diffColumn($column, $column2));
687
+    }
688
+
689
+    /**
690
+     * @param SchemaDiff $diff
691
+     * @param int $newTableCount
692
+     * @param int $changeTableCount
693
+     * @param int $removeTableCount
694
+     */
695
+    public function assertSchemaTableChangeCount($diff, $newTableCount=0, $changeTableCount=0, $removeTableCount=0)
696
+    {
697
+        $this->assertEquals($newTableCount, count($diff->newTables));
698
+        $this->assertEquals($changeTableCount, count($diff->changedTables));
699
+        $this->assertEquals($removeTableCount, count($diff->removedTables));
700
+    }
701
+
702
+    /**
703
+     * @param SchemaDiff $diff
704
+     * @param int $newSequenceCount
705
+     * @param int $changeSequenceCount
706
+     * @param int $changeSequenceCount
707
+     */
708
+    public function assertSchemaSequenceChangeCount($diff, $newSequenceCount=0, $changeSequenceCount=0, $removeSequenceCount=0)
709
+    {
710
+        $this->assertEquals($newSequenceCount, count($diff->newSequences), "Expected number of new sequences is wrong.");
711
+        $this->assertEquals($changeSequenceCount, count($diff->changedSequences), "Expected number of changed sequences is wrong.");
712
+        $this->assertEquals($removeSequenceCount, count($diff->removedSequences), "Expected number of removed sequences is wrong.");
713
+    }
714
+}

+ 84 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php Ver fichero

@@ -0,0 +1,84 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Schema;
4
+
5
+require_once __DIR__ . '/../../TestInit.php';
6
+
7
+use Doctrine\DBAL\Schema\Schema;
8
+use Doctrine\DBAL\Schema\Table;
9
+use Doctrine\DBAL\Schema\Column;
10
+use Doctrine\DBAL\Schema\Index;
11
+
12
+class IndexTest extends \PHPUnit_Framework_TestCase
13
+{
14
+    public function createIndex($unique=false, $primary=false)
15
+    {
16
+        return new Index("foo", array("bar", "baz"), $unique, $primary);
17
+    }
18
+
19
+    public function testCreateIndex()
20
+    {
21
+        $idx = $this->createIndex();
22
+        $this->assertEquals("foo", $idx->getName());
23
+        $columns = $idx->getColumns();
24
+        $this->assertEquals(2, count($columns));
25
+        $this->assertEquals(array("bar", "baz"), $columns);
26
+        $this->assertFalse($idx->isUnique());
27
+        $this->assertFalse($idx->isPrimary());
28
+    }
29
+
30
+    public function testCreatePrimary()
31
+    {
32
+        $idx = $this->createIndex(false, true);
33
+        $this->assertTrue($idx->isUnique());
34
+        $this->assertTrue($idx->isPrimary());
35
+    }
36
+
37
+    public function testCreateUnique()
38
+    {
39
+        $idx = $this->createIndex(true, false);
40
+        $this->assertTrue($idx->isUnique());
41
+        $this->assertFalse($idx->isPrimary());
42
+    }
43
+
44
+    /**
45
+     * @group DBAL-50
46
+     */
47
+    public function testFullfilledByUnique()
48
+    {
49
+        $idx1 = $this->createIndex(true, false);
50
+        $idx2 = $this->createIndex(true, false);
51
+        $idx3 = $this->createIndex();
52
+
53
+        $this->assertTrue($idx1->isFullfilledBy($idx2));
54
+        $this->assertFalse($idx1->isFullfilledBy($idx3));
55
+    }
56
+
57
+    /**
58
+     * @group DBAL-50
59
+     */
60
+    public function testFullfilledByPrimary()
61
+    {
62
+        $idx1 = $this->createIndex(true, true);
63
+        $idx2 = $this->createIndex(true, true);
64
+        $idx3 = $this->createIndex(true, false);
65
+
66
+        $this->assertTrue($idx1->isFullfilledBy($idx2));
67
+        $this->assertFalse($idx1->isFullfilledBy($idx3));
68
+    }
69
+
70
+    /**
71
+     * @group DBAL-50
72
+     */
73
+    public function testFullfilledByIndex()
74
+    {
75
+        $idx1 = $this->createIndex();
76
+        $idx2 = $this->createIndex();
77
+        $pri = $this->createIndex(true, true);
78
+        $uniq = $this->createIndex(true);
79
+
80
+        $this->assertTrue($idx1->isFullfilledBy($idx2));
81
+        $this->assertTrue($idx1->isFullfilledBy($pri));
82
+        $this->assertTrue($idx1->isFullfilledBy($uniq));
83
+    }
84
+}

+ 67 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php Ver fichero

@@ -0,0 +1,67 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Schema\Platforms;
4
+
5
+require_once __DIR__ . '/../../../TestInit.php';
6
+
7
+use Doctrine\DBAL\Schema\Schema;
8
+use Doctrine\DBAL\Schema\Table;
9
+use Doctrine\DBAL\Schema\Column;
10
+use Doctrine\DBAL\Types\Type;
11
+
12
+class MySQLSchemaTest extends \PHPUnit_Framework_TestCase
13
+{
14
+    /**
15
+     * @var Comparator
16
+     */
17
+    private $comparator;
18
+    /**
19
+     *
20
+     * @var \Doctrine\DBAL\Platforms\AbstractPlatform
21
+     */
22
+    private $platform;
23
+
24
+    public function setUp()
25
+    {
26
+        $this->comparator = new \Doctrine\DBAL\Schema\Comparator;
27
+        $this->platform = new \Doctrine\DBAL\Platforms\MySqlPlatform;
28
+    }
29
+
30
+    public function testSwitchPrimaryKeyOrder()
31
+    {
32
+        $tableOld = new Table("test");
33
+        $tableOld->addColumn('foo_id', 'integer');
34
+        $tableOld->addColumn('bar_id', 'integer');
35
+        $tableNew = clone $tableOld;
36
+
37
+        $tableOld->setPrimaryKey(array('foo_id', 'bar_id'));
38
+        $tableNew->setPrimaryKey(array('bar_id', 'foo_id'));
39
+
40
+        $diff = $this->comparator->diffTable($tableOld, $tableNew);
41
+        $sql = $this->platform->getAlterTableSQL($diff);
42
+
43
+        $this->assertEquals(
44
+            array(
45
+                'ALTER TABLE test DROP PRIMARY KEY',
46
+                'ALTER TABLE test ADD PRIMARY KEY (bar_id, foo_id)'
47
+            ), $sql
48
+        );
49
+    }
50
+
51
+    /**
52
+     * @group DBAL-132
53
+     */
54
+    public function testGenerateForeignKeySQL()
55
+    {
56
+        $tableOld = new Table("test");
57
+        $tableOld->addColumn('foo_id', 'integer');
58
+        $tableOld->addUnnamedForeignKeyConstraint('test_foreign', array('foo_id'), array('foo_id'));
59
+
60
+        $sqls = array();
61
+        foreach ($tableOld->getForeignKeys() AS $fk) {
62
+            $sqls[] = $this->platform->getCreateForeignKeySQL($fk, $tableOld);
63
+        }
64
+
65
+        $this->assertEquals(array("ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C8E48560F FOREIGN KEY (foo_id) REFERENCES test_foreign(foo_id)"), $sqls);
66
+    }
67
+}

+ 109 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php Ver fichero

@@ -0,0 +1,109 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Schema;
4
+
5
+require_once __DIR__ . '/../../TestInit.php';
6
+
7
+use Doctrine\DBAL\Schema\Schema,
8
+    Doctrine\DBAL\Schema\Table,
9
+    Doctrine\DBAL\Schema\Column,
10
+    Doctrine\DBAL\Schema\Index,
11
+    Doctrine\DBAL\Schema\Sequence,
12
+    Doctrine\DBAL\Schema\SchemaDiff,
13
+    Doctrine\DBAL\Schema\TableDiff,
14
+    Doctrine\DBAL\Schema\Comparator,
15
+    Doctrine\DBAL\Types\Type;
16
+
17
+class SchemaDiffTest extends \PHPUnit_Framework_TestCase
18
+{
19
+    public function testSchemaDiffToSql()
20
+    {
21
+        $diff = $this->createSchemaDiff();
22
+        $platform = $this->createPlatform(true);
23
+
24
+        $sql = $diff->toSql($platform);
25
+
26
+        $expected = array('drop_orphan_fk', 'alter_seq', 'drop_seq', 'create_seq', 'create_table', 'create_foreign_key', 'drop_table', 'alter_table');
27
+
28
+        $this->assertEquals($expected, $sql);
29
+    }
30
+
31
+    public function testSchemaDiffToSaveSql()
32
+    {
33
+        $diff = $this->createSchemaDiff();
34
+        $platform = $this->createPlatform(false);
35
+
36
+        $sql = $diff->toSaveSql($platform);
37
+
38
+        $expected = array('alter_seq', 'create_seq', 'create_table', 'create_foreign_key', 'alter_table');
39
+
40
+        $this->assertEquals($expected, $sql);
41
+    }
42
+
43
+    public function createPlatform($unsafe = false)
44
+    {
45
+        $platform = $this->getMock('Doctrine\Tests\DBAL\Mocks\MockPlatform');
46
+        if ($unsafe) {
47
+            $platform->expects($this->exactly(1))
48
+                 ->method('getDropSequenceSql')
49
+                 ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence'))
50
+                 ->will($this->returnValue('drop_seq'));
51
+        }
52
+        $platform->expects($this->exactly(1))
53
+                 ->method('getAlterSequenceSql')
54
+                 ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence'))
55
+                 ->will($this->returnValue('alter_seq'));
56
+        $platform->expects($this->exactly(1))
57
+                 ->method('getCreateSequenceSql')
58
+                 ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence'))
59
+                 ->will($this->returnValue('create_seq'));
60
+        if ($unsafe) {
61
+            $platform->expects($this->exactly(1))
62
+                     ->method('getDropTableSql')
63
+                     ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table'))
64
+                     ->will($this->returnValue('drop_table'));
65
+        }
66
+        $platform->expects($this->exactly(1))
67
+                 ->method('getCreateTableSql')
68
+                 ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table'))
69
+                 ->will($this->returnValue(array('create_table')));
70
+        $platform->expects($this->exactly(1))
71
+                 ->method('getCreateForeignKeySQL')
72
+                 ->with($this->isInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint'))
73
+                 ->will($this->returnValue('create_foreign_key'));
74
+        $platform->expects($this->exactly(1))
75
+                 ->method('getAlterTableSql')
76
+                 ->with($this->isInstanceOf('Doctrine\DBAL\Schema\TableDiff'))
77
+                 ->will($this->returnValue(array('alter_table')));
78
+        if ($unsafe) {
79
+            $platform->expects($this->exactly(1))
80
+                     ->method('getDropForeignKeySql')
81
+                     ->with($this->isInstanceof('Doctrine\DBAL\Schema\ForeignKeyConstraint'), $this->equalTo('local_table'))
82
+                     ->will($this->returnValue('drop_orphan_fk'));
83
+        }
84
+        $platform->expects($this->exactly(1))
85
+                ->method('supportsSequences')
86
+                ->will($this->returnValue(true));
87
+        $platform->expects($this->exactly(2))
88
+                ->method('supportsForeignKeyConstraints')
89
+                ->will($this->returnValue(true));
90
+        return $platform;
91
+    }
92
+
93
+    public function createSchemaDiff()
94
+    {
95
+        $diff = new SchemaDiff();
96
+        $diff->changedSequences['foo_seq'] = new Sequence('foo_seq');
97
+        $diff->newSequences['bar_seq'] = new Sequence('bar_seq');
98
+        $diff->removedSequences['baz_seq'] = new Sequence('baz_seq');
99
+        $diff->newTables['foo_table'] = new Table('foo_table');
100
+        $diff->removedTables['bar_table'] = new Table('bar_table');
101
+        $diff->changedTables['baz_table'] = new TableDiff('baz_table');
102
+        $diff->newTables['foo_table']->addColumn('foreign_id', 'integer');
103
+        $diff->newTables['foo_table']->addForeignKeyConstraint('foreign_table', array('foreign_id'), array('id'));
104
+        $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('id'), 'foreign_table', array('id'));
105
+        $fk->setLocalTable(new Table('local_table'));
106
+        $diff->orphanedForeignKeys[] = $fk;
107
+        return $diff;
108
+    }
109
+}

+ 211 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php Ver fichero

@@ -0,0 +1,211 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Schema;
4
+
5
+require_once __DIR__ . '/../../TestInit.php';
6
+
7
+use Doctrine\DBAL\Schema\Schema;
8
+use Doctrine\DBAL\Schema\Table;
9
+use Doctrine\DBAL\Schema\Sequence;
10
+
11
+class SchemaTest extends \PHPUnit_Framework_TestCase
12
+{
13
+    public function testAddTable()
14
+    {
15
+        $tableName = "foo";
16
+        $table = new Table($tableName);
17
+
18
+        $schema = new Schema(array($table));
19
+
20
+        $this->assertTrue($schema->hasTable($tableName));
21
+
22
+        $tables = $schema->getTables();
23
+        $this->assertTrue( isset($tables[$tableName]) );
24
+        $this->assertSame($table, $tables[$tableName]);
25
+        $this->assertSame($table, $schema->getTable($tableName));
26
+        $this->assertTrue($schema->hasTable($tableName));
27
+    }
28
+
29
+    public function testTableMatchingCaseInsenstive()
30
+    {
31
+        $table = new Table("Foo");
32
+
33
+        $schema = new Schema(array($table));
34
+        $this->assertTrue($schema->hasTable("foo"));
35
+        $this->assertTrue($schema->hasTable("FOO"));
36
+
37
+        $this->assertSame($table, $schema->getTable('FOO'));
38
+        $this->assertSame($table, $schema->getTable('foo'));
39
+        $this->assertSame($table, $schema->getTable('Foo'));
40
+    }
41
+
42
+    public function testGetUnknownTableThrowsException()
43
+    {
44
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
45
+
46
+        $schema = new Schema();
47
+        $schema->getTable("unknown");
48
+    }
49
+
50
+    public function testCreateTableTwiceThrowsException()
51
+    {
52
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
53
+
54
+        $tableName = "foo";
55
+        $table = new Table($tableName);
56
+        $tables = array($table, $table);
57
+
58
+        $schema = new Schema($tables);
59
+    }
60
+
61
+    public function testRenameTable()
62
+    {
63
+        $tableName = "foo";
64
+        $table = new Table($tableName);
65
+        $schema = new Schema(array($table));
66
+
67
+        $this->assertTrue($schema->hasTable("foo"));
68
+        $schema->renameTable("foo", "bar");
69
+        $this->assertFalse($schema->hasTable("foo"));
70
+        $this->assertTrue($schema->hasTable("bar"));
71
+        $this->assertSame($table, $schema->getTable("bar"));
72
+    }
73
+
74
+    public function testDropTable()
75
+    {
76
+        $tableName = "foo";
77
+        $table = new Table($tableName);
78
+        $schema = new Schema(array($table));
79
+
80
+        $this->assertTrue($schema->hasTable("foo"));
81
+
82
+        $schema->dropTable("foo");
83
+
84
+        $this->assertFalse($schema->hasTable("foo"));
85
+    }
86
+
87
+    public function testCreateTable()
88
+    {
89
+        $schema = new Schema();
90
+
91
+        $this->assertFalse($schema->hasTable("foo"));
92
+
93
+        $table = $schema->createTable("foo");
94
+
95
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Table', $table);
96
+        $this->assertEquals("foo", $table->getName());
97
+        $this->assertTrue($schema->hasTable("foo"));
98
+    }
99
+
100
+    public function testAddSequences()
101
+    {
102
+        $sequence = new Sequence("a_seq", 1, 1);
103
+
104
+        $schema = new Schema(array(), array($sequence));
105
+
106
+        $this->assertTrue($schema->hasSequence("a_seq"));
107
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq"));
108
+
109
+        $sequences = $schema->getSequences();
110
+        $this->assertArrayHasKey('a_seq', $sequences);
111
+    }
112
+
113
+    public function testSequenceAccessCaseInsensitive()
114
+    {
115
+        $sequence = new Sequence("a_Seq");
116
+
117
+        $schema = new Schema(array(), array($sequence));
118
+        $this->assertTrue($schema->hasSequence('a_seq'));
119
+        $this->assertTrue($schema->hasSequence('a_Seq'));
120
+        $this->assertTrue($schema->hasSequence('A_SEQ'));
121
+
122
+        $this->assertEquals($sequence, $schema->getSequence('a_seq'));
123
+        $this->assertEquals($sequence, $schema->getSequence('a_Seq'));
124
+        $this->assertEquals($sequence, $schema->getSequence('A_SEQ'));
125
+    }
126
+
127
+    public function testGetUnknownSequenceThrowsException()
128
+    {
129
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
130
+
131
+        $schema = new Schema();
132
+        $schema->getSequence("unknown");
133
+    }
134
+
135
+    public function testCreateSequence()
136
+    {
137
+        $schema = new Schema();
138
+        $sequence = $schema->createSequence('a_seq', 10, 20);
139
+
140
+        $this->assertEquals('a_seq', $sequence->getName());
141
+        $this->assertEquals(10, $sequence->getAllocationSize());
142
+        $this->assertEquals(20, $sequence->getInitialValue());
143
+
144
+        $this->assertTrue($schema->hasSequence("a_seq"));
145
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq"));
146
+
147
+        $sequences = $schema->getSequences();
148
+        $this->assertArrayHasKey('a_seq', $sequences);
149
+    }
150
+
151
+    public function testDropSequence()
152
+    {
153
+        $sequence = new Sequence("a_seq", 1, 1);
154
+
155
+        $schema = new Schema(array(), array($sequence));
156
+
157
+        $schema->dropSequence("a_seq");
158
+        $this->assertFalse($schema->hasSequence("a_seq"));
159
+    }
160
+
161
+    public function testAddSequenceTwiceThrowsException()
162
+    {
163
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
164
+
165
+        $sequence = new Sequence("a_seq", 1, 1);
166
+
167
+        $schema = new Schema(array(), array($sequence, $sequence));
168
+    }
169
+
170
+    public function testConfigMaxIdentifierLength()
171
+    {
172
+        $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig();
173
+        $schemaConfig->setMaxIdentifierLength(5);
174
+
175
+        $schema = new Schema(array(), array(), $schemaConfig);
176
+        $table = $schema->createTable("smalltable");
177
+        $table->addColumn('long_id', 'integer');
178
+        $table->addIndex(array('long_id'));
179
+
180
+        $index = current($table->getIndexes());
181
+        $this->assertEquals(5, strlen($index->getName()));
182
+    }
183
+
184
+    public function testDeepClone()
185
+    {
186
+        $schema = new Schema();
187
+        $sequence = $schema->createSequence('baz');
188
+
189
+        $tableA = $schema->createTable('foo');
190
+        $tableA->addColumn('id', 'integer');
191
+
192
+        $tableB = $schema->createTable('bar');
193
+        $tableB->addColumn('id', 'integer');
194
+        $tableB->addColumn('foo_id', 'integer');
195
+        $tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id'));
196
+
197
+        $schemaNew = clone $schema;
198
+
199
+        $this->assertNotSame($sequence, $schemaNew->getSequence('baz'));
200
+
201
+        $this->assertNotSame($tableA, $schemaNew->getTable('foo'));
202
+        $this->assertNotSame($tableA->getColumn('id'), $schemaNew->getTable('foo')->getColumn('id'));
203
+
204
+        $this->assertNotSame($tableB, $schemaNew->getTable('bar'));
205
+        $this->assertNotSame($tableB->getColumn('id'), $schemaNew->getTable('bar')->getColumn('id'));
206
+
207
+        $fk = $schemaNew->getTable('bar')->getForeignKeys();
208
+        $fk = current($fk);
209
+        $this->assertSame($schemaNew->getTable('bar'), $this->readAttribute($fk, '_localTable'));
210
+    }
211
+}

+ 476 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/TableTest.php Ver fichero

@@ -0,0 +1,476 @@
1
+<?php
2
+
3
+namespace Doctrine\Tests\DBAL\Schema;
4
+
5
+require_once __DIR__ . '/../../TestInit.php';
6
+
7
+use Doctrine\DBAL\Schema\Schema;
8
+use Doctrine\DBAL\Schema\Table;
9
+use Doctrine\DBAL\Schema\TableBuilder;
10
+use Doctrine\DBAL\Schema\Column;
11
+use Doctrine\DBAL\Schema\Index;
12
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
13
+use Doctrine\DBAL\Types\Type;
14
+
15
+class TableTest extends \PHPUnit_Framework_TestCase
16
+{
17
+    public function testCreateWithInvalidTableName()
18
+    {
19
+        $this->setExpectedException('Doctrine\DBAL\DBALException');
20
+        $table = new \Doctrine\DBAL\Schema\Table('');
21
+    }
22
+
23
+    public function testGetName()
24
+    {
25
+        $table =  new Table("foo", array(), array(), array());
26
+        $this->assertEquals("foo", $table->getName());
27
+    }
28
+
29
+    public function testColumns()
30
+    {
31
+        $type = Type::getType('integer');
32
+        $columns = array();
33
+        $columns[] = new Column("foo", $type);
34
+        $columns[] = new Column("bar", $type);
35
+        $table = new Table("foo", $columns, array(), array());
36
+
37
+        $this->assertTrue($table->hasColumn("foo"));
38
+        $this->assertTrue($table->hasColumn("bar"));
39
+        $this->assertFalse($table->hasColumn("baz"));
40
+
41
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("foo"));
42
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("bar"));
43
+
44
+        $this->assertEquals(2, count($table->getColumns()));
45
+    }
46
+
47
+    public function testColumnsCaseInsensitive()
48
+    {
49
+        $table = new Table("foo");
50
+        $column = $table->addColumn('Foo', 'integer');
51
+
52
+        $this->assertTrue($table->hasColumn('Foo'));
53
+        $this->assertTrue($table->hasColumn('foo'));
54
+        $this->assertTrue($table->hasColumn('FOO'));
55
+
56
+        $this->assertSame($column, $table->getColumn('Foo'));
57
+        $this->assertSame($column, $table->getColumn('foo'));
58
+        $this->assertSame($column, $table->getColumn('FOO'));
59
+    }
60
+
61
+    public function testCreateColumn()
62
+    {
63
+        $type = Type::getType('integer');
64
+
65
+        $table = new Table("foo");
66
+
67
+        $this->assertFalse($table->hasColumn("bar"));
68
+        $table->addColumn("bar", 'integer');
69
+        $this->assertTrue($table->hasColumn("bar"));
70
+        $this->assertSame($type, $table->getColumn("bar")->getType());
71
+    }
72
+
73
+    public function testDropColumn()
74
+    {
75
+        $type = Type::getType('integer');
76
+        $columns = array();
77
+        $columns[] = new Column("foo", $type);
78
+        $columns[] = new Column("bar", $type);
79
+        $table = new Table("foo", $columns, array(), array());
80
+
81
+        $this->assertTrue($table->hasColumn("foo"));
82
+        $this->assertTrue($table->hasColumn("bar"));
83
+
84
+        $table->dropColumn("foo")->dropColumn("bar");
85
+
86
+        $this->assertFalse($table->hasColumn("foo"));
87
+        $this->assertFalse($table->hasColumn("bar"));
88
+    }
89
+
90
+    public function testGetUnknownColumnThrowsException()
91
+    {
92
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
93
+
94
+        $table = new Table("foo", array(), array(), array());
95
+        $table->getColumn('unknown');
96
+    }
97
+
98
+    public function testAddColumnTwiceThrowsException()
99
+    {
100
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
101
+
102
+        $type = \Doctrine\DBAL\Types\Type::getType('integer');
103
+        $columns = array();
104
+        $columns[] = new Column("foo", $type);
105
+        $columns[] = new Column("foo", $type);
106
+        $table = new Table("foo", $columns, array(), array());
107
+    }
108
+
109
+    public function testCreateIndex()
110
+    {
111
+        $type = \Doctrine\DBAL\Types\Type::getType('integer');
112
+        $columns = array(new Column("foo", $type), new Column("bar", $type), new Column("baz", $type));
113
+        $table = new Table("foo", $columns);
114
+        
115
+        $table->addIndex(array("foo", "bar"), "foo_foo_bar_idx");
116
+        $table->addUniqueIndex(array("bar", "baz"), "foo_bar_baz_uniq");
117
+
118
+        $this->assertTrue($table->hasIndex("foo_foo_bar_idx"));
119
+        $this->assertTrue($table->hasIndex("foo_bar_baz_uniq"));
120
+    }
121
+
122
+    public function testIndexCaseInsensitive()
123
+    {
124
+        $type = \Doctrine\DBAL\Types\Type::getType('integer');
125
+        $columns = array(
126
+            new Column("foo", $type),
127
+            new Column("bar", $type),
128
+            new Column("baz", $type)
129
+        );
130
+        $table = new Table("foo", $columns);
131
+
132
+        $table->addIndex(array("foo", "bar", "baz"), "Foo_Idx");
133
+
134
+        $this->assertTrue($table->hasIndex('foo_idx'));
135
+        $this->assertTrue($table->hasIndex('Foo_Idx'));
136
+        $this->assertTrue($table->hasIndex('FOO_IDX'));
137
+    }
138
+
139
+    public function testAddIndexes()
140
+    {
141
+        $type = \Doctrine\DBAL\Types\Type::getType('integer');
142
+        $columns = array(
143
+            new Column("foo", $type),
144
+            new Column("bar", $type),
145
+        );
146
+        $indexes = array(
147
+            new Index("the_primary", array("foo"), true, true),
148
+            new Index("bar_idx", array("bar"), false, false),
149
+        );
150
+        $table = new Table("foo", $columns, $indexes, array());
151
+
152
+        $this->assertTrue($table->hasIndex("the_primary"));
153
+        $this->assertTrue($table->hasIndex("bar_idx"));
154
+        $this->assertFalse($table->hasIndex("some_idx"));
155
+
156
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey());
157
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('the_primary'));
158
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('bar_idx'));
159
+    }
160
+
161
+    public function testGetUnknownIndexThrowsException()
162
+    {
163
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
164
+
165
+        $table = new Table("foo", array(), array(), array());
166
+        $table->getIndex("unknownIndex");
167
+    }
168
+
169
+    public function testAddTwoPrimaryThrowsException()
170
+    {
171
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
172
+
173
+        $type = \Doctrine\DBAL\Types\Type::getType('integer');
174
+        $columns = array(new Column("foo", $type), new Column("bar", $type));
175
+        $indexes = array(
176
+            new Index("the_primary", array("foo"), true, true),
177
+            new Index("other_primary", array("bar"), true, true),
178
+        );
179
+        $table = new Table("foo", $columns, $indexes, array());
180
+    }
181
+
182
+    public function testAddTwoIndexesWithSameNameThrowsException()
183
+    {
184
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
185
+
186
+        $type = \Doctrine\DBAL\Types\Type::getType('integer');
187
+        $columns = array(new Column("foo", $type), new Column("bar", $type));
188
+        $indexes = array(
189
+            new Index("an_idx", array("foo"), false, false),
190
+            new Index("an_idx", array("bar"), false, false),
191
+        );
192
+        $table = new Table("foo", $columns, $indexes, array());
193
+    }
194
+
195
+    public function testConstraints()
196
+    {
197
+        $constraint = new ForeignKeyConstraint(array(), "foo", array());
198
+
199
+        $tableA = new Table("foo", array(), array(), array($constraint));
200
+        $constraints = $tableA->getForeignKeys();
201
+
202
+        $this->assertEquals(1, count($constraints));
203
+        $this->assertSame($constraint, array_shift($constraints));
204
+    }
205
+
206
+    public function testOptions()
207
+    {
208
+        $table = new Table("foo", array(), array(), array(), false, array("foo" => "bar"));
209
+
210
+        $this->assertTrue($table->hasOption("foo"));
211
+        $this->assertEquals("bar", $table->getOption("foo"));
212
+    }
213
+
214
+    public function testBuilderSetPrimaryKey()
215
+    {
216
+        $table = new Table("foo");
217
+
218
+        $table->addColumn("bar", 'integer');
219
+        $table->setPrimaryKey(array("bar"));
220
+
221
+        $this->assertTrue($table->hasIndex("primary"));
222
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey());
223
+        $this->assertTrue($table->getIndex("primary")->isUnique());
224
+        $this->assertTrue($table->getIndex("primary")->isPrimary());
225
+    }
226
+
227
+    public function testBuilderAddUniqueIndex()
228
+    {
229
+        $table = new Table("foo");
230
+
231
+        $table->addColumn("bar", 'integer');
232
+        $table->addUniqueIndex(array("bar"), "my_idx");
233
+
234
+        $this->assertTrue($table->hasIndex("my_idx"));
235
+        $this->assertTrue($table->getIndex("my_idx")->isUnique());
236
+        $this->assertFalse($table->getIndex("my_idx")->isPrimary());
237
+    }
238
+
239
+    public function testBuilderAddIndex()
240
+    {
241
+        $table = new Table("foo");
242
+
243
+        $table->addColumn("bar", 'integer');
244
+        $table->addIndex(array("bar"), "my_idx");
245
+
246
+        $this->assertTrue($table->hasIndex("my_idx"));
247
+        $this->assertFalse($table->getIndex("my_idx")->isUnique());
248
+        $this->assertFalse($table->getIndex("my_idx")->isPrimary());
249
+    }
250
+
251
+    public function testBuilderAddIndexWithInvalidNameThrowsException()
252
+    {
253
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
254
+
255
+        $table = new Table("foo");
256
+        $table->addColumn("bar",'integer');
257
+        $table->addIndex(array("bar"), "invalid name %&/");
258
+    }
259
+
260
+    public function testBuilderAddIndexWithUnknownColumnThrowsException()
261
+    {
262
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
263
+
264
+        $table = new Table("foo");
265
+        $table->addIndex(array("bar"), "invalidName");
266
+    }
267
+
268
+    public function testBuilderOptions()
269
+    {
270
+        $table = new Table("foo");
271
+        $table->addOption("foo", "bar");
272
+        $this->assertTrue($table->hasOption("foo"));
273
+        $this->assertEquals("bar", $table->getOption("foo"));
274
+    }
275
+
276
+    public function testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException()
277
+    {
278
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
279
+
280
+        $table = new Table("foo");
281
+        $table->addColumn("id", 'integer');
282
+
283
+        $foreignTable = new Table("bar");
284
+        $foreignTable->addColumn("id", 'integer');
285
+
286
+        $table->addForeignKeyConstraint($foreignTable, array("foo"), array("id"));
287
+    }
288
+
289
+    public function testAddForeignKeyConstraint_UnknownForeignColumn_ThrowsException()
290
+    {
291
+        $this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
292
+
293
+        $table = new Table("foo");
294
+        $table->addColumn("id", 'integer');
295
+
296
+        $foreignTable = new Table("bar");
297
+        $foreignTable->addColumn("id", 'integer');
298
+
299
+        $table->addForeignKeyConstraint($foreignTable, array("id"), array("foo"));
300
+    }
301
+
302
+    public function testAddForeignKeyConstraint()
303
+    {
304
+        $table = new Table("foo");
305
+        $table->addColumn("id", 'integer');
306
+
307
+        $foreignTable = new Table("bar");
308
+        $foreignTable->addColumn("id", 'integer');
309
+
310
+        $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar"));
311
+
312
+        $constraints = $table->getForeignKeys();
313
+        $this->assertEquals(1, count($constraints));
314
+        $constraint = current($constraints);
315
+        
316
+        $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $constraint);
317
+
318
+        $this->assertTrue($constraint->hasOption("foo"));
319
+        $this->assertEquals("bar", $constraint->getOption("foo"));
320
+    }
321
+
322
+    public function testAddIndexWithCaseSensitiveColumnProblem()
323
+    {
324
+        $table = new Table("foo");
325
+        $table->addColumn("id", 'integer');
326
+
327
+        $table->addIndex(array("ID"), "my_idx");
328
+
329
+        $this->assertTrue($table->hasIndex('my_idx'));
330
+        $this->assertEquals(array("ID"), $table->getIndex("my_idx")->getColumns());
331
+        $this->assertTrue($table->getIndex('my_idx')->spansColumns(array('id')));
332
+    }
333
+
334
+    public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull()
335
+    {
336
+        $table = new Table("foo");
337
+        $column = $table->addColumn("id", 'integer', array('notnull' => false));
338
+
339
+        $this->assertFalse($column->getNotnull());
340
+
341
+        $table->setPrimaryKey(array('id'));
342
+        
343
+        $this->assertTrue($column->getNotnull());
344
+    }
345
+
346
+    /**
347
+     * @group DDC-133
348
+     */
349
+    public function testAllowImplicitSchemaTableInAutogeneratedIndexNames()
350
+    {
351
+        $table = new Table("foo.bar");
352
+        $table->addColumn('baz', 'integer', array());
353
+        $table->addIndex(array('baz'));
354
+
355
+        $this->assertEquals(1, count($table->getIndexes()));
356
+    }
357
+
358
+    /**
359
+     * @group DBAL-50
360
+     */
361
+    public function testAddIndexTwice_IgnoreSecond()
362
+    {
363
+        $table = new Table("foo.bar");
364
+        $table->addColumn('baz', 'integer', array());
365
+        $table->addIndex(array('baz'));
366
+        $table->addIndex(array('baz'));
367
+
368
+        $this->assertEquals(1, count($table->getIndexes()));
369
+    }
370
+
371
+    /**
372
+     * @group DBAL-50
373
+     */
374
+    public function testAddForeignKeyIndexImplicitly()
375
+    {
376
+        $table = new Table("foo");
377
+        $table->addColumn("id", 'integer');
378
+
379
+        $foreignTable = new Table("bar");
380
+        $foreignTable->addColumn("id", 'integer');
381
+
382
+        $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar"));
383
+
384
+        $indexes = $table->getIndexes();
385
+        $this->assertEquals(1, count($indexes));
386
+        $index = current($indexes);
387
+
388
+        $this->assertTrue($table->hasIndex($index->getName()));
389
+        $this->assertEquals(array('id'), $index->getColumns());
390
+    }
391
+
392
+    /**
393
+     * @group DBAL-50
394
+     */
395
+    public function testOverruleIndex()
396
+    {
397
+        $table = new Table("bar");
398
+        $table->addColumn('baz', 'integer', array());
399
+        $table->addIndex(array('baz'));
400
+
401
+        $indexes = $table->getIndexes();
402
+        $this->assertEquals(1, count($indexes));
403
+        $index = current($indexes);
404
+
405
+        $table->addUniqueIndex(array('baz'));
406
+        $this->assertEquals(1, count($table->getIndexes()));
407
+        $this->assertFalse($table->hasIndex($index->getName()));
408
+    }
409
+    
410
+    public function testPrimaryKeyOverrulesUniqueIndex()
411
+    {
412
+        $table = new Table("bar");
413
+        $table->addColumn('baz', 'integer', array());
414
+        $table->addUniqueIndex(array('baz'));
415
+        
416
+        $table->setPrimaryKey(array('baz'));
417
+        
418
+        $indexes = $table->getIndexes();        
419
+        $this->assertEquals(1, count($indexes), "Table should only contain the primary key table index, not the unique one anymore, because it was overruled.");
420
+        
421
+        $index = current($indexes);
422
+        $this->assertTrue($index->isPrimary());
423
+    }
424
+
425
+    /**
426
+     * @group DBAL-64
427
+     */
428
+    public function testQuotedTableName()
429
+    {
430
+        $table = new Table("`bar`");
431
+
432
+        $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform();
433
+        $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform();
434
+
435
+        $this->assertEquals('bar', $table->getName());
436
+        $this->assertEquals('`bar`', $table->getQuotedName($mysqlPlatform));
437
+        $this->assertEquals('"bar"', $table->getQuotedName($sqlitePlatform));
438
+    }
439
+
440
+    /**
441
+     * @group DBAL-79
442
+     */
443
+    public function testTableHasPrimaryKey()
444
+    {
445
+        $table = new Table("test");
446
+
447
+        $this->assertFalse($table->hasPrimaryKey());
448
+
449
+        $table->addColumn("foo", "integer");
450
+        $table->setPrimaryKey(array("foo"));
451
+
452
+        $this->assertTrue($table->hasPrimaryKey());
453
+    }
454
+
455
+    /**
456
+     * @group DBAL-91
457
+     */
458
+    public function testAddIndexWithQuotedColumns()
459
+    {
460
+        $table = new Table("test");
461
+        $table->addColumn('"foo"', 'integer');
462
+        $table->addColumn('bar', 'integer');
463
+        $table->addIndex(array('"foo"', '"bar"'));
464
+    }
465
+
466
+    /**
467
+     * @group DBAL-91
468
+     */
469
+    public function testAddForeignKeyWithQuotedColumnsAndTable()
470
+    {
471
+        $table = new Table("test");
472
+        $table->addColumn('"foo"', 'integer');
473
+        $table->addColumn('bar', 'integer');
474
+        $table->addForeignKeyConstraint('"boing"', array('"foo"', '"bar"'), array("id"));
475
+    }
476
+}

+ 0 - 0
vendor/doctrine-dbal/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php Ver fichero


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio