General dev on tests.
This commit is contained in:
parent
838ccd68c9
commit
e757ccc5e4
14 changed files with 74 additions and 26 deletions
|
@ -3,10 +3,9 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
|
|||
define('PHPUnit_MAIN_METHOD', 'AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
require_once 'lib/Doctrine_TestSuite.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
// Suites
|
||||
require_once 'Dbal/AllTests.php';
|
||||
require_once 'Orm/AllTests.php';
|
||||
require_once 'Ticket/AllTests.php';
|
||||
|
@ -20,7 +19,7 @@ class AllTests
|
|||
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new Doctrine_TestSuite('Doctrine');
|
||||
$suite = new Doctrine_TestSuite('Doctrine Tests');
|
||||
|
||||
$suite->addTest(Dbal_AllTests::suite());
|
||||
$suite->addTest(Orm_AllTests::suite());
|
||||
|
|
|
@ -3,10 +3,9 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
|
|||
define('PHPUnit_MAIN_METHOD', 'Dbal_AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
require_once 'lib/Doctrine_TestSuite.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
// Suites
|
||||
require_once 'Dbal/Component/AllTests.php';
|
||||
|
||||
class Dbal_AllTests
|
||||
|
|
|
@ -3,10 +3,9 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
|
|||
define('PHPUnit_MAIN_METHOD', 'Dbal_Component_AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
require_once 'lib/Doctrine_TestSuite.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
// Tests
|
||||
require_once 'Dbal/Component/TestTest.php';
|
||||
|
||||
class Dbal_Component_AllTests
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once 'lib/Doctrine_TestCase.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
class Dbal_Component_TestTest extends Doctrine_TestCase
|
||||
{
|
||||
|
|
|
@ -3,10 +3,9 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
|
|||
define('PHPUnit_MAIN_METHOD', 'Orm_AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
require_once 'lib/Doctrine_TestSuite.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
// Suites
|
||||
require_once 'Orm/Component/AllTests.php';
|
||||
|
||||
class Orm_AllTests
|
||||
|
|
|
@ -3,10 +3,9 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
|
|||
define('PHPUnit_MAIN_METHOD', 'Dbal_Component_AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
require_once 'lib/Doctrine_TestSuite.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
// Tests
|
||||
require_once 'Orm/Component/TestTest.php';
|
||||
|
||||
class Orm_Component_AllTests
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once 'lib/Doctrine_TestCase.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
class Orm_Component_TestTest extends Doctrine_TestCase
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once 'lib/Doctrine_TestCase.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
class Ticket_1Test extends Doctrine_TestCase
|
||||
{
|
||||
|
|
|
@ -3,10 +3,9 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
|
|||
define('PHPUnit_MAIN_METHOD', 'Ticket_AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
require_once 'lib/Doctrine_TestSuite.php';
|
||||
require_once 'lib/DoctrineTestInit.php';
|
||||
|
||||
// Tests
|
||||
require_once 'Ticket/1Test.php';
|
||||
|
||||
class Ticket_AllTests
|
||||
|
|
5
tests/fixtures/cms/data/CmsUser.yml
vendored
Normal file
5
tests/fixtures/cms/data/CmsUser.yml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
CmsUser:
|
||||
CmsUser_1:
|
||||
username: jwage
|
||||
password: changeme
|
10
tests/fixtures/cms/models/CmsUser.php
vendored
Normal file
10
tests/fixtures/cms/models/CmsUser.php
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
class CmsUser extends Doctrine_Record
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
$class->setColumn('id', 'integer', 4, array('primary' => true, 'autoincrement' => true));
|
||||
$class->setColumn('username', 'string', 255);
|
||||
$class->setColumn('username', 'string', 255);
|
||||
}
|
||||
}
|
8
tests/lib/DoctrineTestInit.php
Normal file
8
tests/lib/DoctrineTestInit.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
require_once 'Doctrine_TestCase.php';
|
||||
require_once 'Doctrine_TestSuite.php';
|
||||
|
||||
require_once '../lib/Doctrine.php';
|
||||
spl_autoload_register(array('Doctrine', 'autoload'));
|
|
@ -1,6 +1,39 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
|
||||
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,6 +1,4 @@
|
|||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
|
||||
class Doctrine_TestSuite extends PHPUnit_Framework_TestSuite
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue