Skip to content

Commit

Permalink
updated mongodb test bootstraper and added mongodb specific autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
chirimoya committed Nov 27, 2011
1 parent de7267d commit 94396bd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
17 changes: 17 additions & 0 deletions src/autoload.mongodb.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
§<?php

$vendorDir = __DIR__.'/../lib/phpcr-utils/lib/vendor';
require_once $vendorDir.'/Symfony/Component/ClassLoader/UniversalClassLoader.php';

$doctrineCommonDir = __DIR__.'/../lib/vendor/mongodb/lib/vendor/doctrine-common/lib';
$doctrineMongoDBDir = __DIR__.'/../lib/vendor/mongodb/lib';
$classLoader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
$classLoader->register();

$classLoader->registerNamespaces(array(
'Jackalope' => __DIR__.'/',
'PHPCR' => array(__DIR__.'/../lib/phpcr-utils/src', __DIR__.'/../lib/phpcr/src'),
'Symfony\Component\Console' => __DIR__.'/../lib/phpcr-utils/lib/vendor',
'Symfony\Component\ClassLoader' => __DIR__.'/../lib/phpcr-utils/lib/vendor',
'Doctrine' => array($doctrineCommonDir, $doctrineMongoDBDir),
));
49 changes: 26 additions & 23 deletions tests/bootstrap_mongodb.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,42 @@
}

/**
* Bootstrap file for jackalope mongodb
* Bootstrap file for jackalope mongodb tests
*
* If you want to overwrite the defaults, you can to specify the autoloader and doctrine sources
*/

// Make sure we have the necessary config
$necessaryConfigValues = array(
'phpcr.doctrine.loader',
'phpcr.doctrine.commondir',
'phpcr.doctrine.mongodbdir',
'phpcr.doctrine.mongodb.server',
'phpcr.doctrine.mongodb.dbname',
);
foreach ($necessaryConfigValues as $val) {
if (empty($GLOBALS[$val])) {
die('Please set '.$val.' in your phpunit.xml.' . "\n");
if (isset($GLOBALS['phpcr.doctrine.loader'])) {
require_once $GLOBALS['phpcr.doctrine.loader'];
// Make sure we have the necessary config
$necessaryConfigValues = array(
'phpcr.doctrine.loader',
'phpcr.doctrine.commondir',
'phpcr.doctrine.mongodbdir',
'phpcr.doctrine.mongodb.server',
'phpcr.doctrine.mongodb.dbname',
);

foreach ($necessaryConfigValues as $val) {
if (empty($GLOBALS[$val])) {
die('Please set '.$val.' in your phpunit.xml.' . "\n");
}
}
}

require_once($GLOBALS['phpcr.doctrine.loader']);
$loader = new \Doctrine\Common\ClassLoader("Doctrine\Common", $GLOBALS['phpcr.doctrine.commondir']);
$loader->register();

$loader = new \Doctrine\Common\ClassLoader("Doctrine\Common", $GLOBALS['phpcr.doctrine.commondir']);
$loader->register();

$loader = new \Doctrine\Common\ClassLoader("Doctrine\MongoDB", $GLOBALS['phpcr.doctrine.mongodbdir']);
$loader->register();
$loader = new \Doctrine\Common\ClassLoader("Doctrine\MongoDB", $GLOBALS['phpcr.doctrine.mongodbdir']);
$loader->register();
}

/**
* autoloader: jackalope-api-tests relies on an autoloader.
*/
require_once(dirname(__FILE__) . '/../src/Jackalope/autoloader.php');
require_once(dirname(__FILE__) . '/../src/autoload.mongodb.dist.php');

### Load classes needed for jackalope unit tests ###
require 'Jackalope/TestCase.php';
require 'Jackalope/Transport/Jackrabbit/DavexTestCase.php';
require 'Jackalope/Transport/Jackrabbit/JackrabbitTestCase.php';
require 'Jackalope/Transport/DoctrineDBAL/DoctrineDBALTestCase.php';
require 'Jackalope/Transport/MongoDB/MongoDBTestCase.php';

Expand Down

0 comments on commit 94396bd

Please sign in to comment.