changes to the new test setup.
This commit is contained in:
parent
e757ccc5e4
commit
00fa362ebb
@ -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());
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?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());
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?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'));
|
8
tests/lib/Doctrine_DbalTestCase.php
Normal file
8
tests/lib/Doctrine_DbalTestCase.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Base testcase class for all dbal testcases.
|
||||
*/
|
||||
class Doctrine_DbalTestCase extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
}
|
29
tests/lib/Doctrine_DbalTestSuite.php
Normal file
29
tests/lib/Doctrine_DbalTestSuite.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
26
tests/lib/Doctrine_OrmTestCase.php
Normal file
26
tests/lib/Doctrine_OrmTestCase.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
27
tests/lib/Doctrine_OrmTestSuite.php
Normal file
27
tests/lib/Doctrine_OrmTestSuite.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
@ -1,39 +1,8 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Doctrine's basic test suite implementation. Provides functionality needed by all
|
||||
* test suites.
|
||||
*/
|
||||
class Doctrine_TestSuite extends PHPUnit_Framework_TestSuite
|
||||
{
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user