From 2ee78d7d85e265e69bf008728fc4c57e773eb0a2 Mon Sep 17 00:00:00 2001 From: dbrewer Date: Mon, 12 Nov 2007 01:45:23 +0000 Subject: [PATCH] Added test case and models for sfDoctrine-style inheritance in record and table classes. --- models/BaseSymfonyRecord.php | 13 ++++++ models/PluginSymfonyRecord.php | 15 +++++++ models/PluginSymfonyRecordTable.php | 5 +++ models/SymfonyRecord.php | 14 +++++++ models/SymfonyRecordTable.php | 7 ++++ tests/Record/InheritanceTestCase.php | 59 ++++++++++++++++++++++++++++ tests/run.php | 1 + 7 files changed, 114 insertions(+) create mode 100644 models/BaseSymfonyRecord.php create mode 100644 models/PluginSymfonyRecord.php create mode 100644 models/PluginSymfonyRecordTable.php create mode 100644 models/SymfonyRecord.php create mode 100644 models/SymfonyRecordTable.php create mode 100644 tests/Record/InheritanceTestCase.php diff --git a/models/BaseSymfonyRecord.php b/models/BaseSymfonyRecord.php new file mode 100644 index 000000000..e8a45d68e --- /dev/null +++ b/models/BaseSymfonyRecord.php @@ -0,0 +1,13 @@ +hasColumn('name', 'string', 30); + } + +} diff --git a/models/PluginSymfonyRecord.php b/models/PluginSymfonyRecord.php new file mode 100644 index 000000000..5cd72f599 --- /dev/null +++ b/models/PluginSymfonyRecord.php @@ -0,0 +1,15 @@ + + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @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); + $this->assertTrue($record instanceof Doctrine_Record); + + // does it have the expected data? + $this->assertEqual($record['name'], 'Test me'); + + + } +} diff --git a/tests/run.php b/tests/run.php index db2ff96b8..fd2faff15 100644 --- a/tests/run.php +++ b/tests/run.php @@ -210,6 +210,7 @@ $record->addTestCase(new Doctrine_Record_SerializeUnserialize_TestCase()); $record->addTestCase(new Doctrine_Record_Lock_TestCase()); $record->addTestCase(new Doctrine_Record_ZeroValues_TestCase()); //$record->addTestCase(new Doctrine_Record_SaveBlankRecord_TestCase()); +$record->addTestCase(new Doctrine_Record_Inheritance_TestCase()); $test->addTestCase($record); $test->addTestCase(new Doctrine_CustomPrimaryKey_TestCase());