Commit e354e527 authored by romanb's avatar romanb

small refactorings

parent be5aac16
......@@ -480,25 +480,24 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* addMappedColumn
* Maps a column of the class' database table to a property of the entity.
*
* @param string $name
* @param string $type
* @param integer $length
* @param string $name The name of the column to map. Syntax: columnName [as propertyName].
* The property name is optional. If not used the column will be
* mapped to a property with the same name.
* @param string $type The type of the column.
* @param integer $length The length of the column.
* @param mixed $options
* @param boolean $prepend Whether to prepend or append the new column to the column list.
* By default the column gets appended.
* @param boolean $prepend Whether to prepend or append the new column to the column list.
* By default the column gets appended.
*
* @throws Doctrine_ClassMetadata_Exception If trying use wrongly typed parameter.
*/
public function mapColumn($name, $type, $length = null, $options = array(), $prepend = false)
{
if (is_string($options)) {
$options = explode('|', $options);
}
foreach ($options as $k => $option) {
if (is_numeric($k)) {
if ( ! empty($option)) {
if ( ! empty($option) && $option !== false) {
$options[$option] = true;
}
unset($options[$k]);
......@@ -598,7 +597,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* hasDefaultValues
* returns true if this table has default values, otherwise false
* returns true if this class has default values, otherwise false
*
* @return boolean
*/
......@@ -609,7 +608,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* getDefaultValueOf
* returns the default value(if any) for given column
* returns the default value(if any) for given field
*
* @param string $fieldName
* @return mixed
......
......@@ -20,8 +20,7 @@
*/
/**
* Doctrine
* the base class of Doctrine framework
* Testcase for basic accessor/mutator functionality.
*
* @package Doctrine
* @author Bjarte Stien Karlsen <doctrine@bjartek.org>
......@@ -32,6 +31,8 @@
*/
require_once 'lib/DoctrineTestInit.php';
class AccessStub extends Doctrine_Access {}
class Orm_Component_AccessTest extends Doctrine_OrmTestCase
{
......@@ -66,7 +67,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
*/
public function shouldSetSingleValueInRecord()
{
$this->user->username ='meus';
$this->user->username = 'meus';
$this->assertEquals('meus', $this->user->username);
$this->assertEquals('meus', $this->user['username']);
}
......@@ -106,7 +107,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
*/
public function shouldNotBeAbleToSetNonExistantField()
{
$this->user->rat ='meus';
$this->user->rat = 'meus';
}
/**
......@@ -115,7 +116,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
*/
public function shouldNotBeAbleToSetNonExistantFieldWithOffset()
{
$this->user['rat'] ='meus';
$this->user['rat'] = 'meus';
}
/**
......@@ -126,7 +127,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
{
$this->user->setArray(array(
'rat' => 'meus',
'id' => 22));
'id' => 22));
}
......@@ -139,7 +140,6 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
$col = new Doctrine_Collection('ForumUser');
$this->assertEquals(0, count($col));
$this->assertFalse(isset($coll[0]));
$this->assertFalse(isset($coll[0]));
}
/**
......@@ -218,5 +218,3 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase
$stub['foo'];
}
}
class AccessStub extends Doctrine_Access {}
......@@ -21,9 +21,9 @@ class Orm_Component_AllTests
{
$suite = new Doctrine_TestSuite('Doctrine Orm Component');
// $suite->addTestSuite('Orm_Component_TestTest');
$suite->addTestSuite('Orm_Component_AccessTest');
$suite->addTestSuite('Orm_Component_CollectionTest');
//$suite->addTestSuite('Orm_Component_TestTest');
$suite->addTestSuite('Orm_Component_AccessTest');
$suite->addTestSuite('Orm_Component_CollectionTest');
return $suite;
}
......
......@@ -98,7 +98,7 @@ class Orm_Component_CollectionTest extends Doctrine_OrmTestCase
{
$serializedFormCollection='C:19:"Doctrine_Collection":158:{a:7:{s:4:"data";a:0:{}s:7:"_mapper";s:9:"ForumUser";s:9:"_snapshot";a:0:{}s:14:"referenceField";N;s:9:"keyColumn";N;s:8:"_locator";N;s:10:"_resources";a:0:{}}}';
$coll = unserialize($serializedFormCollection);
$this->assertEquals(Doctrine_Collection, get_class($coll));
$this->assertEquals('Doctrine_Collection', get_class($coll));
}
/**
......
<?php
class CustomPK extends Doctrine_Record {
public static function initMetadata($class) {
$class->setColumn('uid', 'integer',11, 'autoincrement|primary');
$class->setColumn('uid', 'integer',11, array('autoincrement' => true, 'primary' => true));
$class->setColumn('name', 'string',255);
}
}
<?php
class Email extends Doctrine_Record
class Email extends Doctrine_Record
{
public static function initMetadata($class)
public static function initMetadata($class)
{
$class->setColumn('address', 'string', 150, 'email|unique');
$class->setColumn('address', 'string', 150, array('email', 'unique' => true));
}
......
......@@ -3,8 +3,8 @@ class EntityReference extends Doctrine_Record
{
public static function initMetadata($class)
{
$class->setColumn('entity1', 'integer', null, 'primary');
$class->setColumn('entity2', 'integer', null, 'primary');
$class->setColumn('entity1', 'integer', null, array('primary' => true));
$class->setColumn('entity2', 'integer', null, array('primary' => true));
}
}
......@@ -3,7 +3,7 @@ class Error extends Doctrine_Record {
public static function initMetadata($class) {
$class->setColumn('message', 'string',200);
$class->setColumn('code', 'integer',11);
$class->setColumn('file_md5', 'string',32, 'primary');
$class->setColumn('file_md5', 'string',32, array('primary' => true));
$class->hasMany('Description', array('local' => 'file_md5', 'foreign' => 'file_md5'));
}
}
......
......@@ -3,8 +3,8 @@ class MysqlTestRecord extends Doctrine_Record
{
public static function initMetadata($class)
{
$class->setColumn('name', 'string', null, 'primary');
$class->setColumn('code', 'integer', null, 'primary');
$class->setColumn('name', 'string', null, array('primary' => true));
$class->setColumn('code', 'integer', null, array('primary' => true));
$class->setTableOption('type', 'INNODB');
}
......
......@@ -3,7 +3,7 @@ class NestReference extends Doctrine_Record
{
public static function initMetadata($class)
{
$class->setColumn('parent_id', 'integer', 4, 'primary');
$class->setColumn('child_id', 'integer', 4, 'primary');
$class->setColumn('parent_id', 'integer', 4, array('primary' => true));
$class->setColumn('child_id', 'integer', 4, array('primary' => true));
}
}
<?php
class NotNullTest extends Doctrine_Record {
public static function initMetadata($class) {
$class->setColumn('name', 'string', 100, 'notnull');
$class->setColumn('type', 'integer', 11);
$class->setColumn('name', 'string', 100, array('notnull' => true));
$class->setColumn('type', 'integer', 11);
}
}
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