diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..24dcf08
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,32 @@
+# see http://about.travis-ci.org/docs/user/languages/php/ for more hints
+language: php
+
+# list any PHP version you want to test against
+php:
+ # using major version aliases
+ - 5.3.3
+ - 5.3
+ - 5.4
+
+services:
+ - mongodb
+
+# optionally specify a list of environments, for example to test different RDBMS
+env:
+ - DB=mysql
+ - DB=mongo
+
+# execute any number of scripts before the test run, custom env's are available as variables
+before_script:
+ - if [[ "$DB" == "mongo" ]]; then
+ pecl -q install mongo && echo "extension=mongo.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`;
+ fi
+ - if [[ "$DB" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS spot_test;" -uroot; fi
+
+# omitting "script:" will default to phpunit
+# use the $DB env variable to determine the phpunit.xml to use
+script: phpunit --configuration phpunit_$DB.xml --coverage-text
+
+# configure notifications (email, IRC, campfire etc)
+#notifications:
+# irc: "irc.freenode.org#travis"
diff --git a/phpunit.xml b/phpunit_mongo.xml
similarity index 80%
rename from phpunit.xml
rename to phpunit_mongo.xml
index b3cdcb5..d56da2d 100644
--- a/phpunit.xml
+++ b/phpunit_mongo.xml
@@ -10,6 +10,11 @@
syntaxCheck="false"
bootstrap="./tests/init.php"
>
+
+
+
+
+
./tests/Test
diff --git a/phpunit_mysql.xml b/phpunit_mysql.xml
new file mode 100644
index 0000000..f41e4db
--- /dev/null
+++ b/phpunit_mysql.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+ ./tests/Test
+
+
+
diff --git a/tests/init.php b/tests/init.php
index 53f0b77..9dc7efe 100644
--- a/tests/init.php
+++ b/tests/init.php
@@ -1,7 +1,7 @@
--addConnection('test_mysql', 'mysql://test:password@localhost/spot_test');
-// MongoDB with adapter options
-$adapter = $cfg->addConnection('test_mongodb', 'mongodb://localhost:28017', array(
- 'cursor' => array(
- 'timeout' => 10
- ),
- 'mapper' => array(
- 'translate_id' => true
- )
-));
-
+
+if ($_ENV['db_type'] == "mysql") {
+ // MySQL
+ $cfg->addConnection('test', $_ENV['db_dsn']);
+}
+elseif ($GLOBALS['db_type'] == "mongo")
+{
+ // MongoDB with adapter options
+ $cfg->addConnection('test_mongodb', $_ENV['db_dsn'], array(
+ 'cursor' => array(
+ 'timeout' => 10
+ ),
+ 'mapper' => array(
+ 'translate_id' => true
+ )
+ ));
+}
+else
+{
+ // Db Type hasn't been configured
+ exit(1);
+}
/**
- * Return Spot mapper for use
- */
+* Return Spot mapper for use
+*/
$mapper = new \Spot\Mapper($cfg);
function test_spot_mapper() {
global $mapper;
@@ -36,8 +46,8 @@ function test_spot_mapper() {
/**
- * Autoload test fixtures
- */
+* Autoload test fixtures
+*/
function test_spot_autoloader($className) {
// Only autoload classes that start with "Test_" and "Entity_"
if(false === strpos($className, 'Test_') && false === strpos($className, 'Entity_')) {