Commit 00fa362e authored by romanb's avatar romanb

changes to the new test setup.

parent e757ccc5
......@@ -17,7 +17,7 @@ class Dbal_AllTests
public static function suite()
{
$suite = new Doctrine_TestSuite('Doctrine Dbal');
$suite = new Doctrine_DbalTestSuite('Doctrine Dbal');
$suite->addTest(Dbal_Component_AllTests::suite());
......
<?php
require_once 'lib/DoctrineTestInit.php';
class Dbal_Component_TestTest extends Doctrine_TestCase
class Dbal_Component_TestTest extends Doctrine_DbalTestCase
{
public function testTest()
{
......
......@@ -17,7 +17,7 @@ class Orm_AllTests
public static function suite()
{
$suite = new Doctrine_TestSuite('Doctrine Orm');
$suite = new Doctrine_OrmTestSuite('Doctrine Orm');
$suite->addTest(Orm_Component_AllTests::suite());
......
<?php
require_once 'lib/DoctrineTestInit.php';
class Orm_Component_TestTest extends Doctrine_TestCase
class Orm_Component_TestTest extends Doctrine_OrmTestCase
{
public function testTest()
{
......
......@@ -2,7 +2,11 @@
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'Doctrine_TestCase.php';
require_once 'Doctrine_DbalTestCase.php';
require_once 'Doctrine_OrmTestCase.php';
require_once 'Doctrine_TestSuite.php';
require_once 'Doctrine_OrmTestSuite.php';
require_once 'Doctrine_DbalTestSuite.php';
require_once '../lib/Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
\ No newline at end of file
<?php
/**
* Base testcase class for all dbal testcases.
*/
class Doctrine_DbalTestCase extends PHPUnit_Framework_TestCase
{
}
\ No newline at end of file
<?php
/**
* The outermost test suite for all dbal related testcases & suites.
*
* Currently the dbal suite uses a normal connection object, too, just like the orm suite.
* Upon separation of the DBAL and ORM package this suite should just use a DBAL
* connection in the shared fixture.
*/
class Doctrine_DbalTestSuite extends Doctrine_TestSuite
{
protected function setUp()
{
$pdo = new PDO('sqlite::memory:');
$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
}
protected function loadConnection($conn, $name)
{
return Doctrine_Manager::connection($conn, $name);
}
protected function tearDown()
{
Doctrine_Manager::getInstance()->getConnection('sqlite_memory')->close();
$this->sharedFixture = NULL;
}
}
\ No newline at end of file
<?php
/**
* Base testcase class for all orm testcases.
*
* Provides the testcases with fixture support and other orm related capabilities.
*/
class Doctrine_OrmTestCase extends Doctrine_TestCase
{
public function loadFixturesPackage($package, $models = array())
{
$packagePath = 'fixtures' . DIRECTORY_SEPARATOR . $package;
if ( ! file_exists($packagePath)) {
throw new Exception("Could not find fixtures package: $package.");
}
$modelsPath = $packagePath . DIRECTORY_SEPARATOR . 'models';
$dataPath = $packagePath . DIRECTORY_SEPARATOR . 'data';
Doctrine::loadModels($modelsPath);
Doctrine::createTablesFromModels($modelsPath);
$data = new Doctrine_Data();
$data->importData($dataPath, 'yml', $models);
}
}
\ No newline at end of file
<?php
/**
* The outermost test suite for all orm related testcases & suites.
*
* Currently the orm suite uses a normal connection object.
* Upon separation of the DBAL and ORM package this suite should just use a orm
* connection/session/manager instance as the shared fixture.
*/
class Doctrine_OrmTestSuite extends Doctrine_TestSuite
{
protected function setUp()
{
$pdo = new PDO('sqlite::memory:');
$this->sharedFixture['connection'] = $this->loadConnection($pdo, 'sqlite_memory');
}
protected function loadConnection($conn, $name)
{
return Doctrine_Manager::connection($conn, $name);
}
protected function tearDown()
{
Doctrine_Manager::getInstance()->getConnection('sqlite_memory')->close();
$this->sharedFixture = NULL;
}
}
\ No newline at end of file
<?php
/**
* Base testcase class for all Doctrine testcases.
*/
class Doctrine_TestCase extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$pdo = new PDO('sqlite::memory:');
$this->sharedFixture = $this->loadConnection($pdo, 'sqlite_memory');
}
public function loadConnection($conn, $name)
{
return Doctrine_Manager::connection($conn, $name);
}
public function loadFixturesPackage($package, $models = array())
{
$packagePath = 'fixtures' . DIRECTORY_SEPARATOR . $package;
if ( ! file_exists($packagePath)) {
throw new Exception('Could not find fixtures package: "' . $package . '"');
}
$modelsPath = $packagePath . DIRECTORY_SEPARATOR . 'models';
$dataPath = $packagePath . DIRECTORY_SEPARATOR . 'data';
Doctrine::loadModels($modelsPath);
Doctrine::createTablesFromModels($modelsPath);
$data = new Doctrine_Data();
$data->importData($dataPath, 'yml', $models);
}
public function tearDown()
{
Doctrine_Manager::getInstance()->getConnection('sqlite_memory')->close();
$this->sharedFixture = NULL;
}
}
\ No newline at end of file
<?php
/**
* Doctrine's basic test suite implementation. Provides functionality needed by all
* test suites.
*/
class Doctrine_TestSuite extends PHPUnit_Framework_TestSuite
{
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment