This commit is contained in:
parent
ade4cd2af1
commit
48c67aba21
@ -16,7 +16,7 @@ class Orm_Component_TestTest extends Doctrine_OrmTestCase
|
||||
|
||||
public function testFixture()
|
||||
{
|
||||
$forumUsers = $this->sharedFixture['connection']->query("FROM Forum_User u");
|
||||
$forumUsers = $this->sharedFixture['connection']->query("FROM ForumUser u");
|
||||
$this->assertEquals(2, count($forumUsers));
|
||||
$forumUsers[0]->delete();
|
||||
unset($forumUsers[0]);
|
||||
@ -25,7 +25,7 @@ class Orm_Component_TestTest extends Doctrine_OrmTestCase
|
||||
|
||||
public function testFixture2()
|
||||
{
|
||||
$forumUsers = $this->sharedFixture['connection']->query("FROM Forum_User u");
|
||||
$forumUsers = $this->sharedFixture['connection']->query("FROM ForumUser u");
|
||||
$this->assertEquals(2, count($forumUsers));
|
||||
}
|
||||
}
|
2
tests/fixtures/forum/common/users.php
vendored
2
tests/fixtures/forum/common/users.php
vendored
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$fixture = array(
|
||||
'model' => 'Forum_User',
|
||||
'model' => 'ForumUser',
|
||||
'rows' => array(
|
||||
array(
|
||||
'id' => 1,
|
||||
|
@ -10,4 +10,23 @@ require_once 'Doctrine_OrmTestSuite.php';
|
||||
require_once 'Doctrine_DbalTestSuite.php';
|
||||
|
||||
require_once '../lib/Doctrine.php';
|
||||
spl_autoload_register(array('Doctrine', 'autoload'));
|
||||
spl_autoload_register(array('Doctrine', 'autoload'));
|
||||
|
||||
$modelDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'models';
|
||||
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
|
||||
Doctrine::loadModels($modelDir);
|
||||
|
||||
/*
|
||||
//spl_autoload_register(array('Doctrine_TestUtil', 'autoload'));
|
||||
|
||||
$modelDir = dirname(__FILE__)
|
||||
. DIRECTORY_SEPARATOR . '..'
|
||||
. DIRECTORY_SEPARATOR . 'models'
|
||||
. DIRECTORY_SEPARATOR;
|
||||
|
||||
set_include_path(
|
||||
get_include_path()
|
||||
. PATH_SEPARATOR . $modelDir . 'cms'
|
||||
. PATH_SEPARATOR . $modelDir . 'ecommerce'
|
||||
. PATH_SEPARATOR . $modelDir . 'forum');
|
||||
*/
|
@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Doctrine_TestUtil
|
||||
{
|
||||
|
||||
{
|
||||
public static function getConnection()
|
||||
{
|
||||
if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'],
|
||||
@ -14,4 +13,12 @@ class Doctrine_TestUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static function autoloadModel($className)
|
||||
{
|
||||
$modelDir = dirname(__CLASS__) . '/../models/';
|
||||
$fileName = $modelDir . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
|
||||
if (file_exists($fileName)) {
|
||||
require $fileName;
|
||||
}
|
||||
}
|
||||
}
|
9
tests/models/forum/ForumAdministrator.php
Normal file
9
tests/models/forum/ForumAdministrator.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class ForumAdministrator extends ForumUser
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
$class->addMappedColumn('foo', 'string', 50);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Forum_User extends Doctrine_Record
|
||||
class ForumUser extends Doctrine_Record
|
||||
{
|
||||
public static function initMetadata($class)
|
||||
{
|
||||
@ -8,10 +8,10 @@ class Forum_User extends Doctrine_Record
|
||||
$class->setInheritanceType(Doctrine::INHERITANCETYPE_JOINED, array(
|
||||
'discriminatorColumn' => 'dtype',
|
||||
'discriminatorMap' => array(
|
||||
1 => 'Forum_User',
|
||||
2 => 'Forum_Administrator')
|
||||
1 => 'ForumUser',
|
||||
2 => 'ForumAdministrator')
|
||||
));
|
||||
$class->setSubclasses(array('Forum_Administrator'));
|
||||
$class->setSubclasses(array('ForumAdministrator'));
|
||||
|
||||
// property mapping
|
||||
$class->addMappedColumn('id', 'integer', 4, array(
|
Loading…
x
Reference in New Issue
Block a user