This commit is contained in:
parent
ade4cd2af1
commit
48c67aba21
6 changed files with 45 additions and 10 deletions
|
@ -16,7 +16,7 @@ class Orm_Component_TestTest extends Doctrine_OrmTestCase
|
||||||
|
|
||||||
public function testFixture()
|
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));
|
$this->assertEquals(2, count($forumUsers));
|
||||||
$forumUsers[0]->delete();
|
$forumUsers[0]->delete();
|
||||||
unset($forumUsers[0]);
|
unset($forumUsers[0]);
|
||||||
|
@ -25,7 +25,7 @@ class Orm_Component_TestTest extends Doctrine_OrmTestCase
|
||||||
|
|
||||||
public function testFixture2()
|
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));
|
$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
|
<?php
|
||||||
$fixture = array(
|
$fixture = array(
|
||||||
'model' => 'Forum_User',
|
'model' => 'ForumUser',
|
||||||
'rows' => array(
|
'rows' => array(
|
||||||
array(
|
array(
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
|
|
|
@ -10,4 +10,23 @@ require_once 'Doctrine_OrmTestSuite.php';
|
||||||
require_once 'Doctrine_DbalTestSuite.php';
|
require_once 'Doctrine_DbalTestSuite.php';
|
||||||
|
|
||||||
require_once '../lib/Doctrine.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
|
<?php
|
||||||
|
|
||||||
class Doctrine_TestUtil
|
class Doctrine_TestUtil
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function getConnection()
|
public static function getConnection()
|
||||||
{
|
{
|
||||||
if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'],
|
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
|
<?php
|
||||||
|
|
||||||
class Forum_User extends Doctrine_Record
|
class ForumUser extends Doctrine_Record
|
||||||
{
|
{
|
||||||
public static function initMetadata($class)
|
public static function initMetadata($class)
|
||||||
{
|
{
|
||||||
|
@ -8,10 +8,10 @@ class Forum_User extends Doctrine_Record
|
||||||
$class->setInheritanceType(Doctrine::INHERITANCETYPE_JOINED, array(
|
$class->setInheritanceType(Doctrine::INHERITANCETYPE_JOINED, array(
|
||||||
'discriminatorColumn' => 'dtype',
|
'discriminatorColumn' => 'dtype',
|
||||||
'discriminatorMap' => array(
|
'discriminatorMap' => array(
|
||||||
1 => 'Forum_User',
|
1 => 'ForumUser',
|
||||||
2 => 'Forum_Administrator')
|
2 => 'ForumAdministrator')
|
||||||
));
|
));
|
||||||
$class->setSubclasses(array('Forum_Administrator'));
|
$class->setSubclasses(array('ForumAdministrator'));
|
||||||
|
|
||||||
// property mapping
|
// property mapping
|
||||||
$class->addMappedColumn('id', 'integer', 4, array(
|
$class->addMappedColumn('id', 'integer', 4, array(
|
Loading…
Add table
Reference in a new issue