changes on the new test suite.
This commit is contained in:
parent
36708c91ba
commit
373a0ac994
22
tests/dbproperties.xml.dev
Normal file
22
tests/dbproperties.xml.dev
Normal 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>
|
@ -2,6 +2,7 @@
|
|||||||
require_once 'PHPUnit/Framework.php';
|
require_once 'PHPUnit/Framework.php';
|
||||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||||
require_once 'Doctrine_TestCase.php';
|
require_once 'Doctrine_TestCase.php';
|
||||||
|
require_once 'Doctrine_TestUtil.php';
|
||||||
require_once 'Doctrine_DbalTestCase.php';
|
require_once 'Doctrine_DbalTestCase.php';
|
||||||
require_once 'Doctrine_OrmTestCase.php';
|
require_once 'Doctrine_OrmTestCase.php';
|
||||||
require_once 'Doctrine_TestSuite.php';
|
require_once 'Doctrine_TestSuite.php';
|
||||||
|
@ -18,8 +18,7 @@ class Doctrine_DbalTestCase extends Doctrine_TestCase
|
|||||||
// to run tests that use a connection standalone.
|
// to run tests that use a connection standalone.
|
||||||
// @todo Make DBMS choice configurable
|
// @todo Make DBMS choice configurable
|
||||||
if ( ! isset($this->sharedFixture['connection'])) {
|
if ( ! isset($this->sharedFixture['connection'])) {
|
||||||
$pdo = new PDO('sqlite::memory:');
|
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
|
||||||
$this->sharedFixture['connection'] = Doctrine_Manager::connection($pdo, 'sqlite_memory');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,8 +12,7 @@ class Doctrine_DbalTestSuite extends Doctrine_TestSuite
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
// @todo Make DBMS choice configurable
|
// @todo Make DBMS choice configurable
|
||||||
$pdo = new PDO('sqlite::memory:');
|
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
|
||||||
$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadConnection($conn, $name)
|
protected function loadConnection($conn, $name)
|
||||||
|
@ -36,8 +36,7 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
|
|||||||
// to run tests that use a connection standalone.
|
// to run tests that use a connection standalone.
|
||||||
// @todo Make DBMS choice configurable
|
// @todo Make DBMS choice configurable
|
||||||
if ( ! isset($this->sharedFixture['connection'])) {
|
if ( ! isset($this->sharedFixture['connection'])) {
|
||||||
$pdo = new PDO('sqlite::memory:');
|
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
|
||||||
$this->sharedFixture['connection'] = Doctrine_Manager::connection($pdo, 'sqlite_memory');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,9 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
// @todo Make DBMS choice configurable
|
// @todo Make DBMS choice configurable
|
||||||
$pdo = new PDO('sqlite::memory:');
|
//$pdo = new PDO('sqlite::memory:');
|
||||||
$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
|
//$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
|
||||||
|
$this->sharedFixture['connection'] = Doctrine_TestUtil::getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadConnection($conn, $name)
|
protected function loadConnection($conn, $name)
|
||||||
|
17
tests/lib/Doctrine_TestUtil.php
Normal file
17
tests/lib/Doctrine_TestUtil.php
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user