Commit 7ab2e586 authored by meus's avatar meus

added setSubclasses to abstractRecord. Fixed classes in tests. added some more...

added setSubclasses to abstractRecord. Fixed classes in tests. added some more output to the Test.php script
parent 57a6200b
......@@ -95,6 +95,20 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access
{
$this->_table->setOption('inheritanceMap', $map);
}
public function setSubclasses($map){
if(isset($map[get_class($this)])){
$this->_table->setOption('inheritanceMap', $map[get_class($this)]);
return;
}
$this->_table->setOption('subclasses', array_keys($map));
$conn = $this->_table->getConnection();
foreach($map as $key => $value){
$table = $conn->getTable($key);
// $table->setOption('inheritanceMap', $value);
}
}
/**
* attribute
* sets or retrieves an option
......
......@@ -66,7 +66,12 @@ class UnitTestCase
if ($value == $value2) {
$this->_passed++;
} else {
$this->_fail();
$seperator = "<br>";
if(PHP_SAPI === "cli"){
$seperator = "\n";
}
$message = "$seperator Value1: $value $seperator != $seperator Value2: $value2 $seperator";
$this->_fail($message);
}
}
......@@ -107,11 +112,11 @@ class UnitTestCase
{
$this->_passed++;
}
public function fail()
public function fail($message = "")
{
$this->_fail();
$this->_fail($message);
}
public function _fail()
public function _fail($message = "")
{
$trace = debug_backtrace();
array_shift($trace);
......@@ -126,7 +131,7 @@ class UnitTestCase
}
$errorMessage = $class->getName() . ' : method ' . $stack['function'] . ' failed on line ' . $line;
$this->_messages[] = $errorMessage;
$this->_messages[] = $errorMessage . " " . $message;
break;
}
$line = $stack['line'];
......
......@@ -21,7 +21,8 @@ class Entity extends Doctrine_Record
$this->hasColumn('created', 'integer',11);
$this->hasColumn('updated', 'integer',11);
$this->hasColumn('email_id', 'integer');
$this->option('subclasses', array('User','Group'));
// $this->option('subclasses', array('User','Group'));
$this->setSubclasses(array("User" => array("type" => 0), "Group" => array("type" => 1)));
}
}
class FieldNameTest extends Doctrine_Record
......@@ -83,7 +84,7 @@ class Group extends Entity {
public function setUp() {
parent::setUp();
$this->hasMany('User', 'Groupuser.user_id');
$this->option('inheritanceMap', array('type' => 1));
// $this->option('inheritanceMap', array('type' => 1));
}
}
class Error extends Doctrine_Record {
......@@ -114,7 +115,7 @@ class User extends Entity
$this->ownsMany('Album', 'Album.user_id');
$this->ownsMany('Book', 'Book.user_id');
$this->hasMany('Group', 'Groupuser.group_id');
$this->option('inheritanceMap', array('type' => 0));
// $this->option('inheritanceMap', array('type' => 0));
}
/** Custom validation */
public function validate()
......
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