Skip to content
This repository
Browse code

Use composer for test suite

This commit is in place of merging in commits from the master branch, as Symfony 2.0 required special handling. Until FrameworkBundle's composer.json is fixed (possibly 2.0.16), it is necessary to depend on "symfony/symfony". Additionally, autoloading must be manually specified for test classes, as they do not live within the "src/" directory.
  • Loading branch information...
commit 9b009bb5af5c6dce43aeae442a00908761002f36 1 parent 932efed
Jeremy Mikola authored June 10, 2012
3  .gitignore
... ...
@@ -1 +1,4 @@
  1
+vendor
  2
+composer.phar
  3
+composer.lock
1 4
 phpunit.xml
30  Tests/autoload.php.dist
... ...
@@ -1,30 +0,0 @@
1  
-<?php
2  
-
3  
-require_once $_SERVER['SYMFONY'].'/Symfony/Component/ClassLoader/UniversalClassLoader.php';
4  
-
5  
-use Symfony\Component\ClassLoader\UniversalClassLoader;
6  
-use Doctrine\Common\Annotations\AnnotationRegistry;
7  
-
8  
-$loader = new UniversalClassLoader();
9  
-$loader->registerNamespaces(array(
10  
-    'Symfony\\Tests'         => $_SERVER['SYMFONY_TESTS'],
11  
-    'Symfony'                => $_SERVER['SYMFONY'],
12  
-    'Doctrine\\ODM\\MongoDB' => $_SERVER['DOCTRINE_MONGODB_ODM'],
13  
-    'Doctrine\\MongoDB'      => $_SERVER['DOCTRINE_MONGODB'],
14  
-    'Doctrine\\Common'       => $_SERVER['DOCTRINE_COMMON'],
15  
-));
16  
-$loader->register();
17  
-
18  
-spl_autoload_register(function($class)
19  
-{
20  
-    if (0 === strpos($class, 'Symfony\\Bundle\\DoctrineMongoDBBundle\\') &&
21  
-        file_exists($file = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 3)).'.php')) {
22  
-        require_once $file;
23  
-    }
24  
-});
25  
-
26  
-AnnotationRegistry::registerLoader(function($class) use ($loader) {
27  
-    $loader->loadClass($class);
28  
-    return class_exists($class, false);
29  
-});
30  
-AnnotationRegistry::registerFile($_SERVER['DOCTRINE_MONGODB_ODM'].'/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php');
31  Tests/bootstrap.php
... ...
@@ -1,24 +1,15 @@
1 1
 <?php
2 2
 
3  
-/*
4  
- * This file is part of the Symfony package.
5  
- *
6  
- * (c) Fabien Potencier <fabien@symfony.com>
7  
- *
8  
- * For the full copyright and license information, please view the LICENSE
9  
- * file that was distributed with this source code.
10  
- */
11  
-
12  
-if (file_exists($file = __DIR__.'/autoload.php')) {
13  
-    require_once $file;
14  
-} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
15  
-    require_once $file;
  3
+$file = __DIR__.'/../vendor/autoload.php';
  4
+if (!file_exists($file)) {
  5
+    throw new RuntimeException('Install dependencies to run test suite.');
16 6
 }
17 7
 
18  
-register_shutdown_function(function() {
19  
-    try {
20  
-        $mongo = new Mongo();
21  
-        $mongo->doctrine->drop();
22  
-    } catch (\MongoException $e) {
23  
-    }
24  
-});
  8
+$loader = require_once $file;
  9
+
  10
+// Specify autoloading for Symfony component test classes (2.0 only)
  11
+$loader->add('Symfony\Tests',  __DIR__.'/../vendor/symfony/symfony/tests/');
  12
+
  13
+use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
  14
+
  15
+AnnotationDriver::registerAnnotationClasses();
3  composer.json
@@ -13,8 +13,7 @@
13 13
     "require": {
14 14
         "php": ">=5.3.2",
15 15
         "doctrine/mongodb-odm": "*",
16  
-        "symfony/doctrine-bridge": "2.0.*",
17  
-        "symfony/framework-bundle": "2.0.*"
  16
+        "symfony/symfony": "2.0.*"
18 17
     },
19 18
     "autoload": {
20 19
         "psr-0": {

0 notes on commit 9b009bb

Please sign in to comment.
Something went wrong with that request. Please try again.