Commit c43f9588 authored by romanb's avatar romanb

Cleanups, improvements, fixes.

parent 3cd7b954
This diff is collapsed.
...@@ -130,7 +130,7 @@ class Doctrine_ClassMetadata_Factory ...@@ -130,7 +130,7 @@ class Doctrine_ClassMetadata_Factory
protected function _addInheritedFields($subClass, $parentClass) protected function _addInheritedFields($subClass, $parentClass)
{ {
foreach ($parentClass->getColumns() as $name => $definition) { foreach ($parentClass->getFieldMappings() as $name => $definition) {
$fullName = "$name as " . $parentClass->getFieldName($name); $fullName = "$name as " . $parentClass->getFieldName($name);
$definition['inherited'] = true; $definition['inherited'] = true;
$subClass->mapColumn( $subClass->mapColumn(
...@@ -246,7 +246,7 @@ class Doctrine_ClassMetadata_Factory ...@@ -246,7 +246,7 @@ class Doctrine_ClassMetadata_Factory
case 1: // A single identifier is in the mapping case 1: // A single identifier is in the mapping
foreach ($class->getIdentifier() as $pk) { foreach ($class->getIdentifier() as $pk) {
$columnName = $class->getColumnName($pk); $columnName = $class->getColumnName($pk);
$thisColumns = $class->getColumns(); $thisColumns = $class->getFieldMappings();
$e = $thisColumns[$columnName]; $e = $thisColumns[$columnName];
$found = false; $found = false;
......
...@@ -342,12 +342,12 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable ...@@ -342,12 +342,12 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable
$this->_data = array_merge($this->_data, $this->_id); $this->_data = array_merge($this->_data, $this->_id);
foreach ($this->_data as $k => $v) { foreach ($this->_data as $k => $v) {
if ($v instanceof Doctrine_Entity && $this->_class->getTypeOf($k) != 'object') { if ($v instanceof Doctrine_Entity && $this->_class->getTypeOfField($k) != 'object') {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
} else if ($v === Doctrine_Null::$INSTANCE) { } else if ($v === Doctrine_Null::$INSTANCE) {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
} else { } else {
switch ($this->_class->getTypeOf($k)) { switch ($this->_class->getTypeOfField($k)) {
case 'array': case 'array':
case 'object': case 'object':
$vars['_data'][$k] = serialize($vars['_data'][$k]); $vars['_data'][$k] = serialize($vars['_data'][$k]);
...@@ -400,7 +400,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable ...@@ -400,7 +400,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable
$this->_class = $this->_em->getClassMetadata($this->_entityName); $this->_class = $this->_em->getClassMetadata($this->_entityName);
foreach ($this->_data as $k => $v) { foreach ($this->_data as $k => $v) {
switch ($this->_class->getTypeOf($k)) { switch ($this->_class->getTypeOfField($k)) {
case 'array': case 'array':
case 'object': case 'object':
$this->_data[$k] = unserialize($this->_data[$k]); $this->_data[$k] = unserialize($this->_data[$k]);
...@@ -1024,7 +1024,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable ...@@ -1024,7 +1024,7 @@ abstract class Doctrine_Entity extends Doctrine_Access implements Serializable
} }
foreach ($modifiedFields as $field) { foreach ($modifiedFields as $field) {
$type = $this->_class->getTypeOf($field); $type = $this->_class->getTypeOfField($field);
if ($this->_data[$field] === Doctrine_Null::$INSTANCE) { if ($this->_data[$field] === Doctrine_Null::$INSTANCE) {
$dataSet[$field] = null; $dataSet[$field] = null;
......
This diff is collapsed.
<?php
/**
* A MappingException indicates that something is wrong with the mapping setup.
*
* @since 2.0
*/
class Doctrine_MappingException extends Doctrine_Exception
{
public static function identifierRequired($entityName)
{
return new self("No identifier specified for Entity '$entityName'."
. " Every Entity must have an identifier.");
}
}
?>
\ No newline at end of file
...@@ -133,7 +133,7 @@ class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrin ...@@ -133,7 +133,7 @@ class Doctrine_Query_Production_PathExpressionEndingWithAsterisk extends Doctrin
} }
// Generating the SQL piece // Generating the SQL piece
$fields = $this->_queryComponent['metadata']->getMappedColumns(); $fields = $this->_queryComponent['metadata']->getFieldMappings();
$tableAlias = $parserResult->getTableAliasFromComponentAlias($componentAlias); $tableAlias = $parserResult->getTableAliasFromComponentAlias($componentAlias);
$str = ''; $str = '';
......
<?php <?php
require_once 'lib/DoctrineTestInit.php'; require_once 'lib/DoctrineTestInit.php';
class Orm_Entity_AccessorTestCase extends Doctrine_OrmTestCase class Orm_Entity_AccessorTest extends Doctrine_OrmTestCase
{ {
public function testGetterSetterOverride() public function testGetterSetterOverride()
{ {
$em = new Doctrine_EntityManager(new Doctrine_Connection_Mock());
$entity1 = new CustomAccessorMutatorTestEntity(); $entity1 = new CustomAccessorMutatorTestEntity();
$entity1->username = 'romanb'; $entity1->username = 'romanb';
$this->assertEquals('romanb?!', $entity1->username); $this->assertEquals('romanb?!', $entity1->username);
...@@ -14,10 +12,14 @@ class Orm_Entity_AccessorTestCase extends Doctrine_OrmTestCase ...@@ -14,10 +12,14 @@ class Orm_Entity_AccessorTestCase extends Doctrine_OrmTestCase
$entity2 = new MagicAccessorMutatorTestEntity(); $entity2 = new MagicAccessorMutatorTestEntity();
$entity2->username = 'romanb'; $entity2->username = 'romanb';
$this->assertEquals('romanb?!', $entity1->username); $this->assertEquals('romanb?!', $entity1->username);
} }
} }
/* Local test classes */
class CustomAccessorMutatorTestEntity extends Doctrine_Entity class CustomAccessorMutatorTestEntity extends Doctrine_Entity
{ {
public static function initMetadata($class) public static function initMetadata($class)
......
...@@ -6,7 +6,7 @@ if (!defined('PHPUnit_MAIN_METHOD')) { ...@@ -6,7 +6,7 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
require_once 'lib/DoctrineTestInit.php'; require_once 'lib/DoctrineTestInit.php';
// Tests // Tests
require_once 'Orm/Entity/AccessorTestCase.php'; require_once 'Orm/Entity/AccessorTest.php';
require_once 'Orm/Entity/ConstructorTest.php'; require_once 'Orm/Entity/ConstructorTest.php';
class Orm_Entity_AllTests class Orm_Entity_AllTests
...@@ -20,7 +20,7 @@ class Orm_Entity_AllTests ...@@ -20,7 +20,7 @@ class Orm_Entity_AllTests
{ {
$suite = new Doctrine_TestSuite('Doctrine Orm Entity Tests'); $suite = new Doctrine_TestSuite('Doctrine Orm Entity Tests');
$suite->addTestSuite('Orm_Entity_AccessorTestCase'); $suite->addTestSuite('Orm_Entity_AccessorTest');
$suite->addTestSuite('Orm_Entity_ConstructorTest'); $suite->addTestSuite('Orm_Entity_ConstructorTest');
return $suite; return $suite;
......
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