2007-11-12 04:45:23 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Doctrine_Record_Inheritance_TestCase
|
|
|
|
*
|
|
|
|
* This test case demonstrates the use of inheritance involving subclasses of
|
2008-05-14 01:20:34 +04:00
|
|
|
* Doctrine_Entity. This type of inheritance is heavily used in sfDoctrine,
|
2007-11-12 04:45:23 +03:00
|
|
|
* and as new inheritance-related features get added to Doctrine it seems to
|
|
|
|
* be an area where subtle breakage can sneak in.
|
|
|
|
*
|
|
|
|
* @package Doctrine
|
|
|
|
* @author David Brewer <dbrewer@secondstory.com>
|
|
|
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
|
|
|
* @category Object Relational Mapping
|
2008-02-22 21:11:35 +03:00
|
|
|
* @link www.phpdoctrine.org
|
2007-11-12 04:45:23 +03:00
|
|
|
* @since 1.0
|
|
|
|
* @version $Revision$
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Doctrine_Record_Inheritance_TestCase extends Doctrine_UnitTestCase
|
|
|
|
{
|
|
|
|
public function prepareTables()
|
|
|
|
{
|
|
|
|
$this->tables = array_merge($this->tables, array('SymfonyRecord'));
|
|
|
|
parent::prepareTables();
|
|
|
|
}
|
|
|
|
public function prepareData()
|
|
|
|
{
|
|
|
|
parent::prepareData();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInit()
|
|
|
|
{
|
|
|
|
$record = new SymfonyRecord();
|
|
|
|
$record['name'] = 'Test me';
|
|
|
|
$record->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testInstantiatingRecordWithAbstractParents()
|
|
|
|
{
|
|
|
|
// load our record
|
|
|
|
$record = Doctrine_Query::create()->query(
|
|
|
|
'SELECT * FROM SymfonyRecord r', array())->getFirst();
|
|
|
|
|
|
|
|
// did we get a record object?
|
|
|
|
$this->assertTrue($record instanceof SymfonyRecord);
|
|
|
|
$this->assertTrue($record->exists());
|
|
|
|
|
|
|
|
// does it have the appropriate parentage?
|
|
|
|
$this->assertTrue($record instanceof PluginSymfonyRecord);
|
|
|
|
$this->assertTrue($record instanceof BaseSymfonyRecord);
|
2008-05-14 01:20:34 +04:00
|
|
|
$this->assertTrue($record instanceof Doctrine_Entity);
|
2007-11-12 04:45:23 +03:00
|
|
|
|
|
|
|
// does it have the expected data?
|
|
|
|
$this->assertEqual($record['name'], 'Test me');
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|