1
0
mirror of synced 2025-01-31 04:21:44 +03:00

changes on the new test suite.

This commit is contained in:
romanb 2008-02-10 19:08:31 +00:00
parent 36708c91ba
commit 373a0ac994
7 changed files with 46 additions and 8 deletions

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Use this configuration file as a template to run the tests against any dbms.
Procedure:
1) Save a copy of this file with a name of your chosing. It doesn't matter
where you place it as long as you know where it is.
i.e. "mysqlconf.xml" (It needs the ending .xml).
2) Edit the file and fill in your settings (database name, type, username, etc.)
Just change the "value"s, not the names of the var elements.
3) To run the tests against the database type the following from within the
tests/ folder: phpunit --configuration <filename> ...
Example: phpunit --configuration mysqlconf.xml AllTests
-->
<phpunit>
<php>
<var name="db_type" value="mysql"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="foo" />
<var name="db_password" value="bar" />
<var name="db_name" value="doctrinetests" />
</php>
</phpunit>

View File

@ -2,6 +2,7 @@
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'Doctrine_TestCase.php';
require_once 'Doctrine_TestUtil.php';
require_once 'Doctrine_DbalTestCase.php';
require_once 'Doctrine_OrmTestCase.php';
require_once 'Doctrine_TestSuite.php';

View File

@ -18,8 +18,7 @@ class Doctrine_DbalTestCase extends Doctrine_TestCase
// to run tests that use a connection standalone.
// @todo Make DBMS choice configurable
if ( ! isset($this->sharedFixture['connection'])) {
$pdo = new PDO('sqlite::memory:');
$this->sharedFixture['connection'] = Doctrine_Manager::connection($pdo, 'sqlite_memory');
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
}
}
}

View File

@ -12,8 +12,7 @@ class Doctrine_DbalTestSuite extends Doctrine_TestSuite
protected function setUp()
{
// @todo Make DBMS choice configurable
$pdo = new PDO('sqlite::memory:');
$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
}
protected function loadConnection($conn, $name)

View File

@ -36,8 +36,7 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
// to run tests that use a connection standalone.
// @todo Make DBMS choice configurable
if ( ! isset($this->sharedFixture['connection'])) {
$pdo = new PDO('sqlite::memory:');
$this->sharedFixture['connection'] = Doctrine_Manager::connection($pdo, 'sqlite_memory');
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
}
}

View File

@ -11,8 +11,9 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite
protected function setUp()
{
// @todo Make DBMS choice configurable
$pdo = new PDO('sqlite::memory:');
$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
//$pdo = new PDO('sqlite::memory:');
//$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
}
protected function loadConnection($conn, $name)

View File

@ -0,0 +1,17 @@
<?php
class Doctrine_TestUtil
{
public static function getConnection()
{
if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'],
$GLOBALS['db_host'], $GLOBALS['db_name'])) {
$dsn = "{$GLOBALS['db_type']}://{$GLOBALS['db_username']}:{$GLOBALS['db_password']}@{$GLOBALS['db_host']}/{$GLOBALS['db_name']}";
return Doctrine_Manager::connection($dsn, 'testconn');
} else {
return Doctrine_Manager::connection(new PDO('sqlite::memory:'), 'testconn');
}
}
}