Commit 34a8acba authored by pookey's avatar pookey

adding a test to show a situation where cascading inserts do not work

parent 5cbc3fc8
<?php
/**
* Tests in this file are unsorted, and should be placed in an appropriate
* test file. If you are unsure where to put a unit test, place them in here
* and hopefully someone else will move them.
*/
class Doctrine_UnsortedTestCase extends Doctrine_UnitTestCase {
public function testCascadingInsert()
{
$package = new Package();
$package->description = 'Package';
$packageverison = new PackageVersion();
$packageverison->description = 'Version';
$packageverisonnotes = new PackageVersionNotes();
$packageverisonnotes->description = 'Notes';
$package->Version[0] = $packageverison;
$package->Version[0]->Note[0] = $packageverisonnotes;
$package->save();
$this->assertNotNull($package->id);
$this->assertNotNull($package->Version[0]->id);
$this->assertNotNull($package->Version[0]->Note[0]->id);
}
}
...@@ -68,7 +68,6 @@ class Group extends Entity { ...@@ -68,7 +68,6 @@ class Group extends Entity {
parent::setUp(); parent::setUp();
$this->hasMany("User","Groupuser.user_id"); $this->hasMany("User","Groupuser.user_id");
$this->setInheritanceMap(array("type"=>1)); $this->setInheritanceMap(array("type"=>1));
} }
} }
class Error extends Doctrine_Record { class Error extends Doctrine_Record {
...@@ -128,7 +127,7 @@ class Phonenumber extends Doctrine_Record { ...@@ -128,7 +127,7 @@ class Phonenumber extends Doctrine_Record {
$this->hasColumn("entity_id","integer"); $this->hasColumn("entity_id","integer");
} }
public function setUp() { public function setUp() {
$this->hasOne("Entity", "Phonenumber.entity_id"); $this->hasOne("Entity", "Phonenumber.entity_id");
} }
} }
...@@ -558,5 +557,36 @@ class BoardWithPosition extends Doctrine_Record { ...@@ -558,5 +557,36 @@ class BoardWithPosition extends Doctrine_Record {
$this->hasOne("CategoryWithPosition as Category", "BoardWithPosition.category_id"); $this->hasOne("CategoryWithPosition as Category", "BoardWithPosition.category_id");
} }
} }
class Package extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->ownsMany('PackageVersion as Version', 'PackageVersion.package_id');
}
}
class PackageVersion extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('package_id', 'integer');
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->hasOne('Package', 'PackageVersion.package_id');
$this->hasMany('PackageVersionNotes as Note', 'PackageVersionNotes.package_version_id');
}
}
class PackageVersionNotes extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('package_version_id', 'integer');
$this->hasColumn('description', 'string', 255);
}
public function setUp()
{
$this->hasOne('PackageVersion', 'PackageVersionNotes.package_version_id');
}
}
?> ?>
...@@ -49,6 +49,9 @@ require_once("RelationTestCase.php"); ...@@ -49,6 +49,9 @@ require_once("RelationTestCase.php");
require_once("DataDictSqliteTestCase.php"); require_once("DataDictSqliteTestCase.php");
require_once("CustomResultSetOrderTestCase.php"); require_once("CustomResultSetOrderTestCase.php");
// unsorted tests are here, these should be moved somewhere sensible
require_once("UnsortedTestCase.php");
error_reporting(E_ALL); error_reporting(E_ALL);
print "<pre>"; print "<pre>";
...@@ -132,6 +135,7 @@ $test->addTestCase(new Doctrine_Query_From_TestCase()); ...@@ -132,6 +135,7 @@ $test->addTestCase(new Doctrine_Query_From_TestCase());
$test->addTestCase(new Doctrine_Query_Select_TestCase()); $test->addTestCase(new Doctrine_Query_Select_TestCase());
$test->addTestCase(new Doctrine_UnsortedTestCase());
//$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment