From 1eb8b54d816cb41abde4897e8f64f15f53ead3a2 Mon Sep 17 00:00:00 2001 From: zYne Date: Sun, 21 Jan 2007 18:31:51 +0000 Subject: [PATCH] lots of refactorings --- lib/Doctrine/Collection.php | 8 +- lib/Doctrine/Connection.php | 2 +- lib/Doctrine/Connection/UnitOfWork.php | 4 +- lib/Doctrine/Export/Sqlite.php | 2 +- lib/Doctrine/Record.php | 45 ++- lib/Doctrine/Table.php | 123 ++++---- lib/Doctrine/Tree/NestedSet.php | 8 +- tests/BooleanTestCase.php | 6 +- tests/CollectionTestCase.php | 30 +- tests/ConnectionTestCase.php | 2 +- tests/Db/ProfilerTestCase.php | 24 +- tests/EventListener/ChainTestCase.php | 4 +- tests/EventListenerChainTestCase.php | 2 +- tests/EventListenerTestCase.php | 2 +- tests/QueryTestCase.php | 42 +-- tests/RawSqlTestCase.php | 8 +- tests/RecordTestCase.php | 72 ++--- tests/TableTestCase.php | 2 +- tests/ValidatorTestCase.php | 36 +-- tests/ViewTestCase.php | 2 +- tests/classes.php | 396 ++++++++++++------------- 21 files changed, 439 insertions(+), 381 deletions(-) diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index 283c646bc..5152b7c94 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -660,8 +660,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator } } elseif ($rel instanceof Doctrine_Relation_ForeignKey) { foreach ($this->data as $key => $record) { - if ($record->getState() == Doctrine_Record::STATE_TCLEAN - || $record->getState() == Doctrine_Record::STATE_TDIRTY + if ($record->state() == Doctrine_Record::STATE_TCLEAN + || $record->state() == Doctrine_Record::STATE_TDIRTY ) { continue; } @@ -682,8 +682,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator $name = $table->getComponentName(); foreach ($this->data as $key => $record) { - if ($record->getState() == Doctrine_Record::STATE_TCLEAN - || $record->getState() == Doctrine_Record::STATE_TDIRTY + if ($record->state() == Doctrine_Record::STATE_TCLEAN + || $record->state() == Doctrine_Record::STATE_TDIRTY ) { continue; } diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index 0ad491458..3e040a169 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -886,7 +886,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun { $record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreSave($record); - switch ($record->getState()) { + switch ($record->state()) { case Doctrine_Record::STATE_TDIRTY: $this->unitOfWork->insert($record); break; diff --git a/lib/Doctrine/Connection/UnitOfWork.php b/lib/Doctrine/Connection/UnitOfWork.php index bd2224a13..6fd5cde3e 100644 --- a/lib/Doctrine/Connection/UnitOfWork.php +++ b/lib/Doctrine/Connection/UnitOfWork.php @@ -157,7 +157,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen // ONE-TO-ONE relationship $obj = $record->get($fk->getAlias()); - if ($obj->getState() != Doctrine_Record::STATE_TCLEAN) { + if ($obj->state() != Doctrine_Record::STATE_TCLEAN) { $obj->save(); } } @@ -261,7 +261,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen $set[] = $name." = ?"; if ($value instanceof Doctrine_Record) { - switch ($value->getState()) { + switch ($value->state()) { case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TDIRTY: $record->save(); diff --git a/lib/Doctrine/Export/Sqlite.php b/lib/Doctrine/Export/Sqlite.php index 33714a605..2dc18ac7a 100644 --- a/lib/Doctrine/Export/Sqlite.php +++ b/lib/Doctrine/Export/Sqlite.php @@ -157,7 +157,7 @@ class Doctrine_Export_Sqlite extends Doctrine_Export $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); $query = 'CREATE TABLE ' . $sequenceName . ' (' . $seqcolName . ' INTEGER PRIMARY KEY DEFAULT 0 NOT NULL)'; - + $this->conn->exec($query); if ($start == 1) { diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 688c410b7..28d7c53b7 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -186,7 +186,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } // set the default values for this record - $this->setDefaultValues(); + $this->assignDefaultValues(); // listen the onCreate event $this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onCreate($this); @@ -309,6 +309,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite { return $this->_errorStack; } + /** + * errorStack + * assigns / returns record errorStack + * + * @param Doctrine_Validator_ErrorStack errorStack to be assigned for this record + * @return void|Doctrine_Validator_ErrorStack returns the errorStack associated with this record + */ + public function errorStack($stack = null) + { + if($stack !== null) { + if( ! ($stack instanceof Doctrine_Validator_ErrorStack)) { + throw new Doctrine_Record_Exception('Argument should be an instance of Doctrine_Validator_ErrorStack.'); + } + $this->_errorStack = $stack; + } else { + return $this->_errorStack; + } + } /** * setDefaultValues * sets the default values for records internal data @@ -316,7 +334,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * @param boolean $overwrite whether or not to overwrite the already set values * @return boolean */ - public function setDefaultValues($overwrite = false) + public function assignDefaultValues($overwrite = false) { if ( ! $this->_table->hasDefaultValues()) { return false; @@ -1462,6 +1480,29 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite { $this->_table->setEnumValues($column, $values); } + /** + * attribute + * sets or retrieves an option + * + * @see Doctrine::ATTR_* constants availible attributes + * @param mixed $attr + * @param mixed $value + * @return mixed + */ + public function attribute($attr, $value) + { + if ($value == null) { + if (is_array($attr)) { + foreach ($attr as $k => $v) { + $this->_table->setAttribute($k, $v); + } + } else { + return $this->_table->getAttribute($attr); + } + } else { + $this->_table->setAttribute($attr, $value); + } + } /** * option * sets or retrieves an option diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 5b558a396..5ed1ee508 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -260,7 +260,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable } } }; + /** + if ( ! isset($definition['values'])) { + throw new Doctrine_Table_Exception('No values set for enum column ' . $name); + } + if ( ! is_array($definition['values'])) { + throw new Doctrine_Table_Exception('Enum column values should be specified as an array.'); + } + + */ if ($this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) { $this->export(); } @@ -276,7 +285,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable array_pop($names); $this->parents = $names; - $this->query = "SELECT ".implode(", ",array_keys($this->columns))." FROM ".$this->getTableName(); + $this->query = 'SELECT ' . implode(', ', array_keys($this->columns)) . ' FROM ' . $this->getTableName(); // check if an instance of this table is already initialized if ( ! $this->conn->addTable($this)) { @@ -294,35 +303,44 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable * false if table already existed in the database */ public function export() { - if (Doctrine::isValidClassname($this->options['declaringClass']->getName())) { - try { - $columns = array(); - $primary = array(); - foreach ($this->columns as $name => $column) { - $definition = $column[2]; - $definition['type'] = $column[0]; - $definition['length'] = $column[1]; + if ( ! Doctrine::isValidClassname($this->options['declaringClass']->getName())) { + throw new Doctrine_Table_Exception('Class name not valid.'); + } - if ($definition['type'] == 'enum' && isset($definition['default'])) { - $definition['default'] = $this->enumIndex($name, $definition['default']); - } - if ($definition['type'] == 'boolean' && isset($definition['default'])) { - $definition['default'] = (int) $definition['default']; - } - $columns[$name] = $definition; - - if(isset($definition['primary']) && $definition['primary']) { - $primary[] = $name; - } - } - $options['primary'] = $primary; + try { + $columns = array(); + $primary = array(); - $this->conn->export->createTable($this->options['tableName'], $columns, array_merge($this->options, $options)); - } catch(Doctrine_Connection_Exception $e) { - // we only want to silence table already exists errors - if($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { - throw $e; + foreach ($this->columns as $name => $column) { + $definition = $column[2]; + $definition['type'] = $column[0]; + $definition['length'] = $column[1]; + + switch ($definition['type']) { + case 'enum': + if (isset($definition['default'])) { + $definition['default'] = $this->enumIndex($name, $definition['default']); + } + break; + case 'boolean': + if (isset($definition['default'])) { + $definition['default'] = (int) $definition['default']; + } + break; } + $columns[$name] = $definition; + + if(isset($definition['primary']) && $definition['primary']) { + $primary[] = $name; + } + } + $options['primary'] = $primary; + + $this->conn->export->createTable($this->options['tableName'], $columns, array_merge($this->options, $options)); + } catch(Doctrine_Connection_Exception $e) { + // we only want to silence table already exists errors + if($e->getPortableCode() !== Doctrine::ERR_ALREADY_EXISTS) { + throw $e; } } } @@ -902,12 +920,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable $id = array_values($id); } - $query = $this->query." WHERE ".implode(" = ? AND ",$this->primaryKeys)." = ?"; + $query = $this->query . ' WHERE ' . implode(' = ? AND ', $this->primaryKeys) . ' = ?'; $query = $this->applyInheritance($query); $params = array_merge($id, array_values($this->options['inheritanceMap'])); - $stmt = $this->conn->execute($query,$params); + $stmt = $this->conn->execute($query, $params); $this->data = $stmt->fetch(PDO::FETCH_ASSOC); @@ -928,10 +946,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable if ( ! empty($this->options['inheritanceMap'])) { $a = array(); foreach ($this->options['inheritanceMap'] as $field => $value) { - $a[] = $field." = ?"; + $a[] = $field . ' = ?'; } - $i = implode(" AND ",$a); - $where .= " AND $i"; + $i = implode(' AND ', $a); + $where .= ' AND ' . $i; } return $where; } @@ -1017,7 +1035,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable final public function getProxy($id = null) { if ($id !== null) { - $query = "SELECT ".implode(", ",$this->primaryKeys)." FROM ".$this->getTableName()." WHERE ".implode(" = ? && ",$this->primaryKeys)." = ?"; + $query = 'SELECT ' . implode(', ',$this->primaryKeys) + . ' FROM ' . $this->getTableName() + . ' WHERE ' . implode(' = ? && ',$this->primaryKeys).' = ?'; $query = $this->applyInheritance($query); $params = array_merge(array($id), array_values($this->options['inheritanceMap'])); @@ -1104,12 +1124,29 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable * @param integer $index * @return mixed */ - final public function enumValue($field, $index) + public function enumValue($field, $index) { if ($index instanceof Doctrine_Null) return $index; - return isset($this->options['enumMap'][$field][$index]) ? $this->options['enumMap'][$field][$index] : $index; + return isset($this->columns[$field][2]['values'][$index]) ? $this->columns[$field][2]['values'][$index] : $index; + } + /** + * enumIndex + * + * @param string $field + * @param mixed $value + * @return mixed + */ + public function enumIndex($field, $value) + { + if ( ! isset($this->columns[$field][2]['values'])) { + $values = array(); + } else { + $values = $this->columns[$field][2]['values']; + } + + return array_search($value, $values); } /** * invokeSet @@ -1155,23 +1192,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable return $value; } - /** - * enumIndex - * - * @param string $field - * @param mixed $value - * @return mixed - */ - final public function enumIndex($field, $value) - { - if ( ! isset($this->options['enumMap'][$field])) { - $values = array(); - } else { - $values = $this->options['enumMap'][$field]; - } - return array_search($value, $values); - } /** * getDefinitionOf * diff --git a/lib/Doctrine/Tree/NestedSet.php b/lib/Doctrine/Tree/NestedSet.php index edd9e9846..29286765a 100644 --- a/lib/Doctrine/Tree/NestedSet.php +++ b/lib/Doctrine/Tree/NestedSet.php @@ -53,7 +53,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int */ public function setTableDefinition() { - if ($root = $this->getAttribute('root_column_name')) { + if ($root = $this->getAttribute('rootColumnName')) { $this->table->setColumn($root, 'integer', 11); } @@ -207,7 +207,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int public function getMaxRootId() { $component = $this->table->getComponentName(); - $column = $this->getAttribute('root_column_name'); + $column = $this->getAttribute('rootColumnName'); // cannot get this dql to work, cannot retrieve result using $coll[0]->max //$dql = "SELECT MAX(c.$column) FROM $component c"; @@ -229,10 +229,10 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int * @param object $query Doctrine_Query * @param integer $root_id id of destination root * @return object Doctrine_Query - */ + */ public function returnQueryWithRootId($query, $rootId = 1) { - if ($root = $this->getAttribute('root_column_name')) { + if ($root = $this->getAttribute('rootColumnName')) { $query->addWhere($root . ' = ?', $rootId); } diff --git a/tests/BooleanTestCase.php b/tests/BooleanTestCase.php index 0b0f13060..7a10b2f4b 100644 --- a/tests/BooleanTestCase.php +++ b/tests/BooleanTestCase.php @@ -42,7 +42,7 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase { $test->is_working = false; $this->assertEqual($test->is_working, false); - $this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $test->save(); $test->refresh(); @@ -98,7 +98,7 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase { $this->is_working = null; $this->assertEqual($this->is_working, null); - $this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $test->save(); $test->refresh(); @@ -108,7 +108,7 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase { $this->is_working_notnull = null; $this->assertEqual($this->is_working_notnull, false); - $this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY); $test->save(); $test->refresh(); diff --git a/tests/CollectionTestCase.php b/tests/CollectionTestCase.php index 4d9f93bc7..f55d2293d 100644 --- a/tests/CollectionTestCase.php +++ b/tests/CollectionTestCase.php @@ -240,7 +240,7 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase { $this->assertEqual(count($coll), 3); - $this->assertEqual($coll[2]->getState(), Doctrine_Record::STATE_PROXY); + $this->assertEqual($coll[2]->state(), Doctrine_Record::STATE_PROXY); @@ -268,33 +268,33 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase { } public function testFetchCollectionWithIdAsIndex() { $user = new User(); - $user->setAttribute(Doctrine::ATTR_COLL_KEY, 'id'); + $user->attribute(Doctrine::ATTR_COLL_KEY, 'id'); $users = $user->getTable()->findAll(); $this->assertFalse($users->contains(0)); $this->assertEqual($users->count(), 8); - $this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_TCLEAN); - $this->assertEqual($users[4]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN); } public function testFetchCollectionWithNameAsIndex() { $user = new User(); - $user->setAttribute(Doctrine::ATTR_COLL_KEY, 'name'); + $user->attribute(Doctrine::ATTR_COLL_KEY, 'name'); $users = $user->getTable()->findAll(); $this->assertFalse($users->contains(0)); $this->assertEqual($users->count(), 8); - $this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_TCLEAN); - $this->assertEqual($users['zYne']->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($users['zYne']->state(), Doctrine_Record::STATE_CLEAN); } public function testFetchMultipleCollections() { $this->connection->clear(); $user = new User(); - $user->setAttribute(Doctrine::ATTR_COLL_KEY, 'id'); + $user->attribute(Doctrine::ATTR_COLL_KEY, 'id'); $phonenumber = new Phonenumber(); - $phonenumber->setAttribute(Doctrine::ATTR_COLL_KEY, 'id'); + $phonenumber->attribute(Doctrine::ATTR_COLL_KEY, 'id'); $q = new Doctrine_Query(); @@ -302,16 +302,16 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase { $this->assertFalse($users->contains(0)); $this->assertEqual($users->count(), 8); - $this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_TCLEAN); - $this->assertEqual($users[2]->getState(), Doctrine_Record::STATE_TCLEAN); - $this->assertEqual($users[3]->getState(), Doctrine_Record::STATE_TCLEAN); - $this->assertEqual($users[4]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($users[2]->state(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($users[3]->state(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($users[4]->name, 'zYne'); $this->assertEqual($users[4]->Phonenumber[0]->exists(), false); - $this->assertEqual($users[4]->Phonenumber[0]->getState(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($users[4]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($users[4]->Phonenumber[1]->exists(), false); - $this->assertEqual($users[4]->Phonenumber[2]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($users[4]->Phonenumber[2]->state(), Doctrine_Record::STATE_CLEAN); } } diff --git a/tests/ConnectionTestCase.php b/tests/ConnectionTestCase.php index d31e4dd58..40b1217c6 100644 --- a/tests/ConnectionTestCase.php +++ b/tests/ConnectionTestCase.php @@ -135,7 +135,7 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { public function testDelete() { $user = $this->connection->create('User'); $this->connection->delete($user); - $this->assertEqual($user->getState(),Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN); } public function testGetTable() { $table = $this->connection->getTable('Group'); diff --git a/tests/Db/ProfilerTestCase.php b/tests/Db/ProfilerTestCase.php index 84b21c304..1acb3d1f2 100644 --- a/tests/Db/ProfilerTestCase.php +++ b/tests/Db/ProfilerTestCase.php @@ -17,7 +17,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'CREATE TABLE test (id INT)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::QUERY); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::QUERY); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertEqual($this->dbh->count(), 1); @@ -29,14 +29,14 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($event->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::PREPARE); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::PREPARE); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $stmt->execute(array(1)); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::EXECUTE); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertEqual($this->dbh->count(), 2); @@ -46,13 +46,13 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { $stmt = $this->dbh->prepare('INSERT INTO test (id) VALUES (?)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::PREPARE); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::PREPARE); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $stmt2 = $this->dbh->prepare('INSERT INTO test (id) VALUES (?)'); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::PREPARE); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::PREPARE); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $stmt->execute(array(1)); @@ -60,7 +60,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::EXECUTE); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertEqual($this->dbh->count(), 4); @@ -77,12 +77,12 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { } $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::EXECUTE); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); $this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)'); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::EXECUTE); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); } public function testTransactionRollback() { @@ -94,7 +94,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { } $this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::BEGIN); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::BEGIN); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); try { @@ -106,7 +106,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::ROLLBACK); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::ROLLBACK); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); } public function testTransactionCommit() { @@ -118,7 +118,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { } $this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::BEGIN); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::BEGIN); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); try { @@ -131,7 +131,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->profiler->lastEvent()->getQuery(), null); $this->assertTrue($this->profiler->lastEvent()->hasEnded()); - $this->assertEqual($this->profiler->lastEvent()->getType(), Doctrine_Db_Event::COMMIT); + $this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::COMMIT); $this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs())); } } diff --git a/tests/EventListener/ChainTestCase.php b/tests/EventListener/ChainTestCase.php index 514aaa02d..20d39b17b 100644 --- a/tests/EventListener/ChainTestCase.php +++ b/tests/EventListener/ChainTestCase.php @@ -29,7 +29,7 @@ * @link www.phpdoctrine.com * @since 1.0 * @version $Revision$ - */ + */ class Doctrine_EventListener_Chain_TestCase extends Doctrine_UnitTestCase { public function testAccessorInvokerChain() { @@ -79,7 +79,7 @@ class EventListenerChainTest extends Doctrine_Record { $chain = new Doctrine_EventListener_Chain(); $chain->add(new Doctrine_EventListener_TestA()); $chain->add(new Doctrine_EventListener_TestB()); - $this->setAttribute(Doctrine::ATTR_LISTENER, $chain); + $this->attribute(Doctrine::ATTR_LISTENER, $chain); } } diff --git a/tests/EventListenerChainTestCase.php b/tests/EventListenerChainTestCase.php index 3553262a3..3107af20d 100644 --- a/tests/EventListenerChainTestCase.php +++ b/tests/EventListenerChainTestCase.php @@ -38,7 +38,7 @@ class EventListenerChainTest extends Doctrine_Record { $chain = new Doctrine_EventListener_Chain(); $chain->add(new Doctrine_EventListener_TestA()); $chain->add(new Doctrine_EventListener_TestB()); - $this->setAttribute(Doctrine::ATTR_LISTENER, $chain); + $this->attribute(Doctrine::ATTR_LISTENER, $chain); } } diff --git a/tests/EventListenerTestCase.php b/tests/EventListenerTestCase.php index 6576ccc34..3ac2bbabc 100644 --- a/tests/EventListenerTestCase.php +++ b/tests/EventListenerTestCase.php @@ -36,7 +36,7 @@ class EventListenerTest extends Doctrine_Record { $this->hasColumn("password", "string", 8); } public function setUp() { - $this->setAttribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker()); + $this->attribute(Doctrine::ATTR_LISTENER, new Doctrine_EventListener_AccessorInvoker()); } public function getName($name) { return strtoupper($name); diff --git a/tests/QueryTestCase.php b/tests/QueryTestCase.php index f3887d8b7..adc306a85 100644 --- a/tests/QueryTestCase.php +++ b/tests/QueryTestCase.php @@ -524,14 +524,14 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $query->from("Task-l:ResourceAlias-l"); $tasks = $query->execute(); $this->assertEqual($tasks->count(), 3); - $this->assertTrue($tasks instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks instanceof Doctrine_Collection); $this->assertEqual($tasks[0]->ResourceAlias->count(), 2); - $this->assertTrue($tasks[0]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[0]->ResourceAlias instanceof Doctrine_Collection); $this->assertEqual($tasks[1]->ResourceAlias->count(), 4); - $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection); // sanity checking $this->assertEqual($tasks[1]->ResourceAlias[0]->getState(), Doctrine_Record::STATE_PROXY); $this->assertEqual($tasks[1]->ResourceAlias[1]->getState(), Doctrine_Record::STATE_PROXY); @@ -548,7 +548,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $this->assertEqual(count($this->dbh), ($count + 4)); $this->assertEqual($tasks[2]->ResourceAlias->count(), 1); - $this->assertTrue($tasks[2]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[2]->ResourceAlias instanceof Doctrine_Collection); } public function testManyToManyFetchingWithDotOperator() { @@ -560,16 +560,16 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $tasks = $query->query("FROM Task-l.ResourceAlias-l"); $this->assertEqual($tasks->count(), 4); - $this->assertTrue($tasks instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks instanceof Doctrine_Collection); $this->assertEqual($tasks[0]->ResourceAlias->count(), 2); - $this->assertTrue($tasks[0]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[0]->ResourceAlias instanceof Doctrine_Collection); $this->assertEqual($tasks[1]->ResourceAlias->count(), 4); - $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection); $this->assertEqual($tasks[1]->ResourceAlias->count(), 4); - $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection); // sanity checking $this->assertEqual($tasks[1]->ResourceAlias[0]->getState(), Doctrine_Record::STATE_PROXY); $this->assertEqual($tasks[1]->ResourceAlias[1]->getState(), Doctrine_Record::STATE_PROXY); @@ -586,7 +586,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $this->assertEqual(count($this->dbh), ($count + 4)); $this->assertEqual($tasks[2]->ResourceAlias->count(), 1); - $this->assertTrue($tasks[2]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[2]->ResourceAlias instanceof Doctrine_Collection); $this->assertEqual($tasks[3]->ResourceAlias->count(), 0); $this->assertTrue($tasks[3]->ResourceAlias instanceof Doctrine_Collection); @@ -597,16 +597,16 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $tasks = $query->query("FROM Task-l.ResourceAlias-l"); $this->assertEqual($tasks->count(), 4); - $this->assertTrue($tasks instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks instanceof Doctrine_Collection); $this->assertEqual($tasks[0]->ResourceAlias->count(), 2); - $this->assertTrue($tasks[0]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[0]->ResourceAlias instanceof Doctrine_Collection); $this->assertEqual($tasks[1]->ResourceAlias->count(), 4); - $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection_Lazy); - + $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection); + $this->assertEqual($tasks[1]->ResourceAlias->count(), 4); - $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[1]->ResourceAlias instanceof Doctrine_Collection); // sanity checking $this->assertEqual($tasks[1]->ResourceAlias[0]->getState(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($tasks[1]->ResourceAlias[1]->getState(), Doctrine_Record::STATE_CLEAN); @@ -623,7 +623,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $this->assertEqual(count($this->dbh), $count); $this->assertEqual($tasks[2]->ResourceAlias->count(), 1); - $this->assertTrue($tasks[2]->ResourceAlias instanceof Doctrine_Collection_Lazy); + $this->assertTrue($tasks[2]->ResourceAlias instanceof Doctrine_Collection); $this->assertEqual($tasks[3]->ResourceAlias->count(), 0); $this->assertTrue($tasks[3]->ResourceAlias instanceof Doctrine_Collection); @@ -755,7 +755,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $q->from("User-l(name, email_id)"); $users = $q->execute(); $this->assertEqual($users->count(), 8); - $this->assertTrue($users instanceof Doctrine_Collection_Lazy); + $this->assertTrue($users instanceof Doctrine_Collection); $count = count($this->dbh); $this->assertTrue(is_string($users[0]->name)); $this->assertEqual($count, count($this->dbh)); @@ -768,7 +768,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $q->from("User-b(name, email_id)"); $users = $q->execute(); $this->assertEqual($users->count(), 8); - $this->assertTrue($users instanceof Doctrine_Collection_Batch); + $this->assertTrue($users instanceof Doctrine_Collection); $count = count($this->dbh); $this->assertTrue(is_string($users[0]->name)); $this->assertEqual($count, count($this->dbh)); @@ -830,7 +830,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $count = $this->dbh->count(); $users = $this->query->from("User-l:Email-i")->execute(); $this->assertEqual(($count + 1), $this->dbh->count()); - $this->assertTrue($users instanceof Doctrine_Collection_Lazy); + $this->assertTrue($users instanceof Doctrine_Collection); $count = $this->dbh->count(); foreach($users as $user) { @@ -858,7 +858,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $count = $this->dbh->count(); $users = $this->query->from("User-l:Account-i")->execute(); $this->assertEqual(($count + 1), $this->dbh->count()); - $this->assertTrue($users instanceof Doctrine_Collection_Lazy); + $this->assertTrue($users instanceof Doctrine_Collection); $this->assertEqual($users->count(), 1); $this->assertEqual($users[0]->Account->amount,3000); @@ -1003,7 +1003,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { $this->assertFalse(strpos($query->getQuery(),"LIMIT")); $coll = $query->execute(); - $this->assertTrue($coll instanceof Doctrine_Collection_Lazy); + $this->assertTrue($coll instanceof Doctrine_Collection); $this->assertEqual($coll->count(), 1); @@ -1054,7 +1054,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase { "SELECT e.id AS e__id FROM entity e WHERE (e.type = 0)"); $this->assertEqual($users[0]->name, "zYne"); - $this->assertTrue($users instanceof Doctrine_Collection_Lazy); + $this->assertTrue($users instanceof Doctrine_Collection); } diff --git a/tests/RawSqlTestCase.php b/tests/RawSqlTestCase.php index 7ae949425..5d5b10ecf 100644 --- a/tests/RawSqlTestCase.php +++ b/tests/RawSqlTestCase.php @@ -49,8 +49,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($coll->count(), 11); - $this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_PROXY); - $this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_PROXY); + $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY); + $this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY); } public function testSmartMapping() { @@ -66,8 +66,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($coll->count(), 11); - $this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_PROXY); - $this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_PROXY); + $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY); + $this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY); } public function testMultipleComponents() { diff --git a/tests/RecordTestCase.php b/tests/RecordTestCase.php index 243f89020..f1a0e07da 100644 --- a/tests/RecordTestCase.php +++ b/tests/RecordTestCase.php @@ -80,8 +80,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertTrue($e->Entity[0] instanceof Entity); $this->assertTrue($e->Entity[1] instanceof Entity); - $this->assertEqual($e->Entity[0]->getState(), Doctrine_Record::STATE_TCLEAN); - $this->assertEqual($e->Entity[1]->getState(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TCLEAN); $e->Entity[0]->name = "Friend 1"; $e->Entity[1]->name = "Friend 2"; @@ -102,15 +102,15 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($e->Entity[1]->Entity[1]->name, "Friend 2 2"); - $this->assertEqual($e->Entity[0]->getState(), Doctrine_Record::STATE_TDIRTY); - $this->assertEqual($e->Entity[1]->getState(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TDIRTY); $count = count($this->dbh); $e->save(); $this->assertEqual(($count + 13), $this->dbh->count()); - $this->assertEqual($e->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($e->state(), Doctrine_Record::STATE_CLEAN); $this->assertTrue($e->Entity[0] instanceof Entity); $this->assertTrue($e->Entity[1] instanceof Entity); @@ -124,8 +124,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($e->Entity[1]->Entity[0]->name, "Friend 2 1"); $this->assertEqual($e->Entity[1]->Entity[1]->name, "Friend 2 2"); - $this->assertEqual($e->Entity[0]->getState(), Doctrine_Record::STATE_CLEAN); - $this->assertEqual($e->Entity[1]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN); $this->assertTrue(is_numeric($e->id)); @@ -168,12 +168,12 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertEqual(count($this->dbh), ($count + 3)); - $this->assertEqual($e->Entity[0]->getState(), Doctrine_Record::STATE_CLEAN); - $this->assertEqual($e->Entity[1]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN); $coll = $this->connection->query("FROM Entity WHERE Entity.name = 'Friend 1'"); $this->assertEqual($coll->count(), 1); - $this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($coll[0]->name, "Friend 1"); @@ -302,23 +302,23 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($record->getTable()->getIdentifier(), array("entity1","entity2")); $this->assertEqual($record->getTable()->getIdentifierType(), Doctrine_Identifier::COMPOSITE); $this->assertEqual($record->obtainIdentifier(), array("entity1" => null, "entity2" => null)); - $this->assertEqual($record->getState(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($record->state(), Doctrine_Record::STATE_TCLEAN); $record->entity1 = 3; $record->entity2 = 4; $this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity1, 3); - $this->assertEqual($record->getState(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($record->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($record->obtainIdentifier(), array("entity1" => null, "entity2" => null)); $record->save(); - $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity1, 3); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 3, "entity2" => 4)); $record = $record->getTable()->find($record->obtainIdentifier()); - $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->entity2, 4); $this->assertEqual($record->entity1, 3); @@ -326,25 +326,25 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $record->entity2 = 5; $record->entity1 = 2; - $this->assertEqual($record->getState(), Doctrine_Record::STATE_DIRTY); + $this->assertEqual($record->state(), Doctrine_Record::STATE_DIRTY); $this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity1, 2); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 3, "entity2" => 4)); $record->save(); - $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity1, 2); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 2, "entity2" => 5)); $record = $record->getTable()->find($record->obtainIdentifier()); - $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity1, 2); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 2, "entity2" => 5)); $record->refresh(); - $this->assertEqual($record->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($record->entity2, 5); $this->assertEqual($record->entity1, 2); $this->assertEqual($record->obtainIdentifier(), array("entity1" => 2, "entity2" => 5)); @@ -356,9 +356,9 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $coll = $this->connection->query("FROM EntityReference-b"); $this->assertTrue($coll[0] instanceof EntityReference); - $this->assertEqual($coll[0]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertTrue($coll[1] instanceof EntityReference); - $this->assertEqual($coll[1]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($coll[1]->state(), Doctrine_Record::STATE_CLEAN); $coll = $this->connection->query("FROM EntityReference-b WHERE EntityReference.entity2 = 5"); $this->assertEqual($coll->count(), 1); @@ -380,12 +380,12 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $task = new Task(); $this->assertTrue($task instanceof Task); - $this->assertEqual($task->getState(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($task->state(), Doctrine_Record::STATE_TCLEAN); $this->assertTrue($task->Subtask[0] instanceof Task); - //$this->assertEqual($task->Subtask[0]->getState(), Doctrine_Record::STATE_TDIRTY); + //$this->assertEqual($task->Subtask[0]->state(), Doctrine_Record::STATE_TDIRTY); $this->assertTrue($task->ResourceAlias[0] instanceof Resource); - $this->assertEqual($task->ResourceAlias[0]->getState(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($task->ResourceAlias[0]->state(), Doctrine_Record::STATE_TCLEAN); $task->name = "Task 1"; $task->ResourceAlias[0]->name = "Resource 1"; @@ -414,7 +414,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $account = $user->Account; $account->amount = 1000; $this->assertTrue($account instanceof Account); - $this->assertEqual($account->getState(), Doctrine_Record::STATE_TDIRTY); + $this->assertEqual($account->state(), Doctrine_Record::STATE_TDIRTY); $this->assertEqual($account->entity_id, $user); $this->assertEqual($account->amount, 1000); $this->assertEqual($user->name, "Richard Linklater"); @@ -424,7 +424,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $user->refresh(); $account = $user->Account; $this->assertTrue($account instanceof Account); - $this->assertEqual($account->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($account->entity_id, $user->id); $this->assertEqual($account->amount, 1000); $this->assertEqual($user->name, "Richard Linklater"); @@ -437,7 +437,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($account->getTable()->getColumnNames(), array("id","entity_id","amount")); $this->connection->flush(); - $this->assertEqual($user->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); $this->assertTrue($account instanceof Account); $this->assertEqual($account->getTable()->getColumnNames(), array("id","entity_id","amount")); @@ -446,13 +446,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $user = $user->getTable()->find($user->id); - $this->assertEqual($user->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN); $account = $user->Account; $this->assertTrue($account instanceof Account); - $this->assertEqual($account->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($account->getTable()->getColumnNames(), array("id","entity_id","amount")); $this->assertEqual($account->entity_id, $user->id); @@ -482,13 +482,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($this->connection->getTable("User")->getData(), array()); $user = new User(); - $this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->getState()), Doctrine_Lib::getRecordStateAsString(Doctrine_Record::STATE_TCLEAN)); + $this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->state()), Doctrine_Lib::getRecordStateAsString(Doctrine_Record::STATE_TCLEAN)); $user->name = "John Locke"; $this->assertTrue($user->name,"John Locke"); - $this->assertTrue($user->getState() == Doctrine_Record::STATE_TDIRTY); + $this->assertTrue($user->state() == Doctrine_Record::STATE_TDIRTY); $user->save(); - $this->assertTrue($user->getState() == Doctrine_Record::STATE_CLEAN); + $this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN); $this->assertTrue($user->name,"John Locke"); } @@ -627,10 +627,10 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertTrue(is_numeric($user->id) && $user->id > 0); $this->assertTrue($user->getModified() == array()); - $this->assertTrue($user->getState() == Doctrine_Record::STATE_CLEAN); + $this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN); $user->delete(); - $this->assertEqual($user->getState(), Doctrine_Record::STATE_TCLEAN); + $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN); } public function testUpdate() { @@ -650,7 +650,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $new = $user->copy(); $this->assertTrue($new instanceof Doctrine_Record); - $this->assertTrue($new->getState() == Doctrine_Record::STATE_TDIRTY); + $this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY); $new = $user->copy(); $new->save(); @@ -666,7 +666,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $new = $user->copy(); $this->assertTrue($new instanceof Doctrine_Record); - $this->assertTrue($new->getState() == Doctrine_Record::STATE_TDIRTY); + $this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY); $new->loginname = 'jackd'; @@ -782,7 +782,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase { $this->assertTrue($user->Email instanceof Email); $this->assertEqual($user->Email->id, $user->email_id); - $this->assertEqual($user->Email->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($user->Email->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($user->Email->address, "drinker@drinkmore.info"); $id = $user->Email->id; diff --git a/tests/TableTestCase.php b/tests/TableTestCase.php index 32bc5ded2..03f3e73c6 100644 --- a/tests/TableTestCase.php +++ b/tests/TableTestCase.php @@ -135,7 +135,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase { public function testCreate() { $record = $this->objTable->create(); $this->assertTrue($record instanceof Doctrine_Record); - $this->assertTrue($record->getState() == Doctrine_Record::STATE_TCLEAN); + $this->assertTrue($record->state() == Doctrine_Record::STATE_TCLEAN); } public function testFind() { $record = $this->objTable->find(4); diff --git a/tests/ValidatorTestCase.php b/tests/ValidatorTestCase.php index 736069c58..81f2f45c5 100644 --- a/tests/ValidatorTestCase.php +++ b/tests/ValidatorTestCase.php @@ -119,7 +119,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $validator = new Doctrine_Validator(); $validator->validateRecord($test); - $stack = $test->getErrorStack(); + $stack = $test->errorStack(); $this->assertTrue($stack instanceof Doctrine_Validator_ErrorStack); @@ -137,15 +137,15 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { * Tests Doctrine_Validator::validateRecord() */ public function testValidate() { - $user = $this->connection->getTable("User")->find(4); + $user = $this->connection->getTable('User')->find(4); - $set = array("password" => "this is an example of too long password", - "loginname" => "this is an example of too long loginname", - "name" => "valid name", - "created" => "invalid"); + $set = array('password' => 'this is an example of too long password', + 'loginname' => 'this is an example of too long loginname', + 'name' => 'valid name', + 'created' => 'invalid'); $user->setArray($set); $email = $user->Email; - $email->address = "zYne@invalid"; + $email->address = 'zYne@invalid'; $this->assertTrue($user->getModified() == $set); @@ -153,7 +153,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $validator->validateRecord($user); - $stack = $user->getErrorStack(); + $stack = $user->errorStack(); $this->assertTrue($stack instanceof Doctrine_Validator_ErrorStack); $this->assertTrue(in_array('length', $stack['loginname'])); @@ -161,12 +161,12 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $this->assertTrue(in_array('type', $stack['created'])); $validator->validateRecord($email); - $stack = $email->getErrorStack(); + $stack = $email->errorStack(); $this->assertTrue(in_array('email', $stack['address'])); - $email->address = "arnold@example.com"; + $email->address = 'arnold@example.com'; $validator->validateRecord($email); - $stack = $email->getErrorStack(); + $stack = $email->errorStack(); $this->assertTrue(in_array('unique', $stack['address'])); } @@ -205,7 +205,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($e->count(), 1); $invalidRecords = $e->getInvalidRecords(); $this->assertEqual(count($invalidRecords), 1); - $stack = $invalidRecords[0]->getErrorStack(); + $stack = $invalidRecords[0]->errorStack(); $this->assertTrue(in_array('length', $stack['name'])); } @@ -222,8 +222,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $this->assertTrue(is_array($a)); - $emailStack = $a[array_search($user->Email, $a)]->getErrorStack(); - $userStack = $a[array_search($user, $a)]->getErrorStack(); + $emailStack = $a[array_search($user->Email, $a)]->errorStack(); + $userStack = $a[array_search($user, $a)]->errorStack(); $this->assertTrue(in_array('email', $emailStack['address'])); $this->assertTrue(in_array('length', $userStack['name'])); @@ -247,8 +247,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $this->assertEqual($e->count(), 1); $invalidRecords = $e->getInvalidRecords(); $this->assertEqual(count($invalidRecords), 1); - - $stack = $invalidRecords[0]->getErrorStack(); + + $stack = $invalidRecords[0]->errorStack(); $this->assertEqual($stack->count(), 2); $this->assertTrue(in_array('notTheSaint', $stack['name'])); // validate() hook constraint @@ -267,7 +267,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $invalidRecords = $e->getInvalidRecords(); $this->assertEqual(count($invalidRecords), 1); - $stack = $invalidRecords[0]->getErrorStack(); + $stack = $invalidRecords[0]->errorStack(); $this->assertEqual($stack->count(), 1); $this->assertTrue(in_array('notNobody', $stack['loginname'])); // validateOnUpdate() hook constraint @@ -290,7 +290,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase { $user->save(); $this->fail(); } catch (Doctrine_Validator_Exception $ex) { - $errors = $user->getErrorStack(); + $errors = $user->errorStack(); $this->assertTrue(in_array('pwNotTopSecret', $errors['password'])); } diff --git a/tests/ViewTestCase.php b/tests/ViewTestCase.php index 80132387e..b8f17e201 100644 --- a/tests/ViewTestCase.php +++ b/tests/ViewTestCase.php @@ -56,7 +56,7 @@ class Doctrine_View_TestCase extends Doctrine_UnitTestCase { $this->assertTrue($users instanceof Doctrine_Collection); $this->assertEqual($users->count(), 8); $this->assertEqual($users[0]->name, 'zYne'); - $this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_CLEAN); + $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN); $this->assertEqual($count, $this->dbh->count()); $success = true; diff --git a/tests/classes.php b/tests/classes.php index fc9593985..c8c23185b 100644 --- a/tests/classes.php +++ b/tests/classes.php @@ -1,473 +1,469 @@ ownsOne("Email","Entity.email_id"); - $this->ownsMany("Phonenumber","Phonenumber.entity_id"); - $this->ownsOne("Account","Account.entity_id"); - $this->hasMany("Entity","EntityReference.entity1-entity2"); + $this->ownsOne('Email', 'Entity.email_id'); + $this->ownsMany('Phonenumber', 'Phonenumber.entity_id'); + $this->ownsOne('Account', 'Account.entity_id'); + $this->hasMany('Entity', 'EntityReference.entity1-entity2'); } public function setTableDefinition() { - $this->hasColumn("id","integer",20,"autoincrement|primary"); - $this->hasColumn("name","string",50); - $this->hasColumn("loginname","string",20, array("unique")); - $this->hasColumn("password","string",16); - $this->hasColumn("type","integer",1); - $this->hasColumn("created","integer",11); - $this->hasColumn("updated","integer",11); - $this->hasColumn("email_id","integer"); + $this->hasColumn('id', 'integer',20, 'autoincrement|primary'); + $this->hasColumn('name', 'string',50); + $this->hasColumn('loginname', 'string',20, array('unique')); + $this->hasColumn('password', 'string',16); + $this->hasColumn('type', 'integer',1); + $this->hasColumn('created', 'integer',11); + $this->hasColumn('updated', 'integer',11); + $this->hasColumn('email_id', 'integer'); } } class FieldNameTest extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("someColumn", "string", 200, array('default' => 'some string')); - $this->hasColumn("someEnum", "enum", 4, array('default' => 'php')); - $this->hasColumn("someArray", "array", 100, array('default' => array())); - $this->hasColumn("someObject", "object", 200, array('default' => new stdClass)); - $this->hasColumn("someInt", "integer", 20, array('default' => 11)); - - - $this->setEnumValues("someEnum", array('php', 'java', 'python')); + $this->hasColumn('someColumn', 'string', 200, array('default' => 'some string')); + $this->hasColumn('someEnum', 'enum', 4, array('default' => 'php', 'values' => array('php', 'java', 'python'))); + $this->hasColumn('someArray', 'array', 100, array('default' => array())); + $this->hasColumn('someObject', 'object', 200, array('default' => new stdClass)); + $this->hasColumn('someInt', 'integer', 20, array('default' => 11)); } } class EntityReference extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("entity1","integer"); - $this->hasColumn("entity2","integer"); - $this->setPrimaryKey(array("entity1","entity2")); + $this->hasColumn('entity1', 'integer', null, 'primary'); + $this->hasColumn('entity2', 'integer', null, 'primary'); + //$this->setPrimaryKey(array('entity1', 'entity2')); } } class Account extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("entity_id","integer"); - $this->hasColumn("amount","integer"); + $this->hasColumn('entity_id', 'integer'); + $this->hasColumn('amount', 'integer'); } } class EntityAddress extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("entity_id","integer"); - $this->hasColumn("address_id","integer"); + $this->hasColumn('entity_id', 'integer'); + $this->hasColumn('address_id', 'integer'); } } class Address extends Doctrine_Record { public function setUp() { - $this->hasMany("User","Entityaddress.entity_id"); + $this->hasMany('User', 'Entityaddress.entity_id'); } public function setTableDefinition() { - $this->hasColumn("address","string",200); + $this->hasColumn('address', 'string',200); } } // grouptable doesn't extend Doctrine_Table -> Doctrine_Connection -// won't initialize grouptable when Doctrine_Connection->getTable("Group") is called +// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called class GroupTable { } class Group extends Entity { public function setUp() { parent::setUp(); - $this->hasMany("User","Groupuser.user_id"); - $this->setInheritanceMap(array("type"=>1)); + $this->hasMany('User', 'Groupuser.user_id'); + $this->option('inheritanceMap', array('type' => 1)); } } class Error extends Doctrine_Record { public function setUp() { - $this->ownsMany("Description","Description.file_md5","file_md5"); + $this->ownsMany('Description', 'Description.file_md5', 'file_md5'); } public function setTableDefinition() { - $this->hasColumn("message","string",200); - $this->hasColumn("code","integer",11); - $this->hasColumn("file_md5","string",32,"primary"); + $this->hasColumn('message', 'string',200); + $this->hasColumn('code', 'integer',11); + $this->hasColumn('file_md5', 'string',32, 'primary'); } } class Description extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("description","string",3000); - $this->hasColumn("file_md5","string",32); + $this->hasColumn('description', 'string',3000); + $this->hasColumn('file_md5', 'string',32); } } class UserTable extends Doctrine_Table { } class User extends Entity { public function setUp() { parent::setUp(); - $this->hasMany("Address","Entityaddress.address_id"); - $this->ownsMany("Album","Album.user_id"); - $this->ownsMany("Book", "Book.user_id"); - $this->hasMany("Group","Groupuser.group_id"); - $this->setInheritanceMap(array("type"=>0)); + $this->hasMany('Address', 'Entityaddress.address_id'); + $this->ownsMany('Album', 'Album.user_id'); + $this->ownsMany('Book', 'Book.user_id'); + $this->hasMany('Group', 'Groupuser.group_id'); + $this->option('inheritanceMap', array('type' => 0)); } /** Custom validation */ public function validate() { // Allow only one name! if ($this->name !== 'The Saint') { - $this->getErrorStack()->add('name', 'notTheSaint'); + $this->errorStack()->add('name', 'notTheSaint'); } } public function validateOnInsert() { if ($this->password !== 'Top Secret') { - $this->getErrorStack()->add('password', 'pwNotTopSecret'); + $this->errorStack()->add('password', 'pwNotTopSecret'); } } public function validateOnUpdate() { if ($this->loginname !== 'Nobody') { - $this->getErrorStack()->add('loginname', 'notNobody'); + $this->errorStack()->add('loginname', 'notNobody'); } } } class Groupuser extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("added","integer"); - $this->hasColumn("group_id","integer"); - $this->hasColumn("user_id","integer"); + $this->hasColumn('added', 'integer'); + $this->hasColumn('group_id', 'integer'); + $this->hasColumn('user_id', 'integer'); } } class Phonenumber extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("phonenumber","string",20); - $this->hasColumn("entity_id","integer"); + $this->hasColumn('phonenumber', 'string',20); + $this->hasColumn('entity_id', 'integer'); } public function setUp() { - $this->hasOne("Entity", "Phonenumber.entity_id"); + $this->hasOne('Entity', 'Phonenumber.entity_id'); } } class Element extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 100); - $this->hasColumn("parent_id", "integer"); + $this->hasColumn('name', 'string', 100); + $this->hasColumn('parent_id', 'integer'); } public function setUp() { - $this->hasMany("Element as Child","Child.parent_id"); - $this->hasOne("Element as Parent","Element.parent_id"); + $this->hasMany('Element as Child', 'Child.parent_id'); + $this->hasOne('Element as Parent', 'Element.parent_id'); } } class Email extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("address","string",150,"email|unique"); + $this->hasColumn('address', 'string',150, 'email|unique'); } } class Book extends Doctrine_Record { public function setUp() { - $this->ownsMany("Author","Author.book_id"); + $this->ownsMany('Author', 'Author.book_id'); } public function setTableDefinition() { - $this->hasColumn("user_id","integer"); - $this->hasColumn("name","string",20); + $this->hasColumn('user_id', 'integer'); + $this->hasColumn('name', 'string',20); } } class Author extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("book_id","integer"); - $this->hasColumn("name","string",20); + $this->hasColumn('book_id', 'integer'); + $this->hasColumn('name', 'string',20); } } class Album extends Doctrine_Record { public function setUp() { - $this->ownsMany("Song","Song.album_id"); + $this->ownsMany('Song', 'Song.album_id'); } public function setTableDefinition() { - $this->hasColumn("user_id","integer"); - $this->hasColumn("name","string",20); + $this->hasColumn('user_id', 'integer'); + $this->hasColumn('name', 'string',20); } } class Song extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("album_id","integer"); - $this->hasColumn("genre","string",20); - $this->hasColumn("title","string",30); + $this->hasColumn('album_id', 'integer'); + $this->hasColumn('genre', 'string',20); + $this->hasColumn('title', 'string',30); } } class Task extends Doctrine_Record { public function setUp() { - $this->hasMany("Resource as ResourceAlias","Assignment.resource_id"); - $this->hasMany("Task as Subtask","Subtask.parent_id"); + $this->hasMany('Resource as ResourceAlias', 'Assignment.resource_id'); + $this->hasMany('Task as Subtask', 'Subtask.parent_id'); } public function setTableDefinition() { - $this->hasColumn("name","string",100); - $this->hasColumn("parent_id","integer"); + $this->hasColumn('name', 'string',100); + $this->hasColumn('parent_id', 'integer'); } } class Resource extends Doctrine_Record { public function setUp() { - $this->hasMany("Task as TaskAlias", "Assignment.task_id"); - $this->hasMany("ResourceType as Type", "ResourceReference.type_id"); + $this->hasMany('Task as TaskAlias', 'Assignment.task_id'); + $this->hasMany('ResourceType as Type', 'ResourceReference.type_id'); } public function setTableDefinition() { - $this->hasColumn("name","string",100); + $this->hasColumn('name', 'string',100); } } class ResourceReference extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("type_id","integer"); - $this->hasColumn("resource_id","integer"); + $this->hasColumn('type_id', 'integer'); + $this->hasColumn('resource_id', 'integer'); } } class ResourceType extends Doctrine_Record { public function setUp() { - $this->hasMany("Resource as ResourceAlias", "ResourceReference.resource_id"); + $this->hasMany('Resource as ResourceAlias', 'ResourceReference.resource_id'); } public function setTableDefinition() { - $this->hasColumn("type","string",100); + $this->hasColumn('type', 'string',100); } } class Assignment extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("task_id","integer"); - $this->hasColumn("resource_id","integer"); + $this->hasColumn('task_id', 'integer'); + $this->hasColumn('resource_id', 'integer'); } } class Forum_Category extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("root_category_id", "integer", 10); - $this->hasColumn("parent_category_id", "integer", 10); - $this->hasColumn("name", "string", 50); - $this->hasColumn("description", "string", 99999); + $this->hasColumn('root_category_id', 'integer', 10); + $this->hasColumn('parent_category_id', 'integer', 10); + $this->hasColumn('name', 'string', 50); + $this->hasColumn('description', 'string', 99999); } public function setUp() { - $this->hasMany("Forum_Category as Subcategory", "Subcategory.parent_category_id"); - $this->hasOne("Forum_Category as Parent", "Forum_Category.parent_category_id"); - $this->hasOne("Forum_Category as Rootcategory", "Forum_Category.root_category_id"); + $this->hasMany('Forum_Category as Subcategory', 'Subcategory.parent_category_id'); + $this->hasOne('Forum_Category as Parent', 'Forum_Category.parent_category_id'); + $this->hasOne('Forum_Category as Rootcategory', 'Forum_Category.root_category_id'); } } class Forum_Board extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("category_id", "integer", 10); - $this->hasColumn("name", "string", 100); - $this->hasColumn("description", "string", 5000); + $this->hasColumn('category_id', 'integer', 10); + $this->hasColumn('name', 'string', 100); + $this->hasColumn('description', 'string', 5000); } public function setUp() { - $this->hasOne("Forum_Category as Category", "Forum_Board.category_id"); - $this->ownsMany("Forum_Thread as Threads", "Forum_Thread.board_id"); + $this->hasOne('Forum_Category as Category', 'Forum_Board.category_id'); + $this->ownsMany('Forum_Thread as Threads', 'Forum_Thread.board_id'); } } class Forum_Entry extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("author", "string", 50); - $this->hasColumn("topic", "string", 100); - $this->hasColumn("message", "string", 99999); - $this->hasColumn("parent_entry_id", "integer", 10); - $this->hasColumn("thread_id", "integer", 10); - $this->hasColumn("date", "integer", 10); + $this->hasColumn('author', 'string', 50); + $this->hasColumn('topic', 'string', 100); + $this->hasColumn('message', 'string', 99999); + $this->hasColumn('parent_entry_id', 'integer', 10); + $this->hasColumn('thread_id', 'integer', 10); + $this->hasColumn('date', 'integer', 10); } public function setUp() { - $this->hasOne("Forum_Entry as Parent", "Forum_Entry.parent_entry_id"); - $this->hasOne("Forum_Thread as Thread", "Forum_Entry.thread_id"); + $this->hasOne('Forum_Entry as Parent', 'Forum_Entry.parent_entry_id'); + $this->hasOne('Forum_Thread as Thread', 'Forum_Entry.thread_id'); } } class Forum_Thread extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("board_id", "integer", 10); - $this->hasColumn("updated", "integer", 10); - $this->hasColumn("closed", "integer", 1); + $this->hasColumn('board_id', 'integer', 10); + $this->hasColumn('updated', 'integer', 10); + $this->hasColumn('closed', 'integer', 1); } public function setUp() { - $this->hasOne("Forum_Board as Board", "Forum_Thread.board_id"); - $this->ownsMany("Forum_Entry as Entries", "Forum_Entry.thread_id"); + $this->hasOne('Forum_Board as Board', 'Forum_Thread.board_id'); + $this->ownsMany('Forum_Entry as Entries', 'Forum_Entry.thread_id'); } } class App extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 32); - $this->hasColumn("user_id", "integer", 11); - $this->hasColumn("app_category_id", "integer", 11); + $this->hasColumn('name', 'string', 32); + $this->hasColumn('user_id', 'integer', 11); + $this->hasColumn('app_category_id', 'integer', 11); } public function setUp() { - $this->hasOne("User","User.id"); - $this->hasMany("App_Category as Category","App_Category.id"); + $this->hasOne('User', 'User.id'); + $this->hasMany('App_Category as Category', 'App_Category.id'); } } class App_User extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("first_name", "string", 32); - $this->hasColumn("last_name", "string", 32); - $this->hasColumn("email", "string", 128, "email"); - $this->hasColumn("username", "string", 16, "unique, nospace"); - $this->hasColumn("password", "string", 128, "notblank"); - $this->hasColumn("country", "string", 2, "country"); - $this->hasColumn("zipcode", "string", 9, "nospace"); + $this->hasColumn('first_name', 'string', 32); + $this->hasColumn('last_name', 'string', 32); + $this->hasColumn('email', 'string', 128, 'email'); + $this->hasColumn('username', 'string', 16, 'unique, nospace'); + $this->hasColumn('password', 'string', 128, 'notblank'); + $this->hasColumn('country', 'string', 2, 'country'); + $this->hasColumn('zipcode', 'string', 9, 'nospace'); } public function setUp() { - $this->hasMany("App","App.user_id"); + $this->hasMany('App', 'App.user_id'); } } class App_Category extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 32); - $this->hasColumn("parent_id","integer"); + $this->hasColumn('name', 'string', 32); + $this->hasColumn('parent_id', 'integer'); } public function setUp() { - $this->hasMany("App","App.app_category_id"); - $this->hasMany("App_Category as Parent","App_Category.parent_id"); + $this->hasMany('App', 'App.app_category_id'); + $this->hasMany('App_Category as Parent', 'App_Category.parent_id'); } } class ORM_TestEntry extends Doctrine_Record { public function setTableDefinition() { $this->setTableName('test_entries'); - $this->hasColumn("id", "integer", 11, "autoincrement|primary"); - $this->hasColumn("name", "string", 255); - $this->hasColumn("stamp", "timestamp"); - $this->hasColumn("amount", "float"); - $this->hasColumn("itemID", "integer"); + $this->hasColumn('id', 'integer', 11, 'autoincrement|primary'); + $this->hasColumn('name', 'string', 255); + $this->hasColumn('stamp', 'timestamp'); + $this->hasColumn('amount', 'float'); + $this->hasColumn('itemID', 'integer'); } public function setUp() { - $this->hasOne("ORM_TestItem", "ORM_TestEntry.itemID"); + $this->hasOne('ORM_TestItem', 'ORM_TestEntry.itemID'); } } class ORM_TestItem extends Doctrine_Record { public function setTableDefinition() { $this->setTableName('test_items'); - $this->hasColumn("id", "integer", 11, "autoincrement|primary"); - $this->hasColumn("name", "string", 255); + $this->hasColumn('id', 'integer', 11, 'autoincrement|primary'); + $this->hasColumn('name', 'string', 255); } public function setUp() { - $this->hasOne("ORM_TestEntry", "ORM_TestEntry.itemID"); + $this->hasOne('ORM_TestEntry', 'ORM_TestEntry.itemID'); } } class ORM_AccessControl extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 255); + $this->hasColumn('name', 'string', 255); } public function setUp() { - $this->hasMany("ORM_AccessGroup as accessGroups", "ORM_AccessControlsGroups.accessGroupID"); + $this->hasMany('ORM_AccessGroup as accessGroups', 'ORM_AccessControlsGroups.accessGroupID'); } } class ORM_AccessGroup extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 255); + $this->hasColumn('name', 'string', 255); } public function setUp() { - $this->hasMany("ORM_AccessControl as accessControls", "ORM_AccessControlsGroups.accessControlID"); + $this->hasMany('ORM_AccessControl as accessControls', 'ORM_AccessControlsGroups.accessControlID'); } } class ORM_AccessControlsGroups extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("accessControlID", "integer", 11); - $this->hasColumn("accessGroupID", "integer", 11); + $this->hasColumn('accessControlID', 'integer', 11); + $this->hasColumn('accessGroupID', 'integer', 11); - $this->setPrimaryKey(array("accessControlID", "accessGroupID")); + $this->setPrimaryKey(array('accessControlID', 'accessGroupID')); } } class EnumTest extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("status","enum",11); - $this->setEnumValues("status", array("open","verified","closed")); + $this->hasColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed'))); } } class FilterTest extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name","string",100); + $this->hasColumn('name', 'string',100); } public function setUp() { - $this->ownsMany("FilterTest2 as filtered", "FilterTest2.test1_id"); + $this->ownsMany('FilterTest2 as filtered', 'FilterTest2.test1_id'); } } class FilterTest2 extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name","string",100); - $this->hasColumn("test1_id","integer"); + $this->hasColumn('name', 'string',100); + $this->hasColumn('test1_id', 'integer'); } } class CustomPK extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("uid","integer",11,"autoincrement|primary"); - $this->hasColumn("name","string",255); + $this->hasColumn('uid', 'integer',11, 'autoincrement|primary'); + $this->hasColumn('name', 'string',255); } } class Log_Entry extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("stamp", "timestamp"); - $this->hasColumn("status_id", "integer"); + $this->hasColumn('stamp', 'timestamp'); + $this->hasColumn('status_id', 'integer'); } public function setUp() { - $this->hasOne("Log_Status", "Log_Entry.status_id"); + $this->hasOne('Log_Status', 'Log_Entry.status_id'); } } class CPK_Test extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 255); + $this->hasColumn('name', 'string', 255); } public function setUp() { - $this->hasMany("CPK_Test2 as Test","CPK_Association.test2_id"); + $this->hasMany('CPK_Test2 as Test', 'CPK_Association.test2_id'); } } class CPK_Test2 extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 255); + $this->hasColumn('name', 'string', 255); } public function setUp() { - $this->hasMany("CPK_Test as Test","CPK_Association.test1_id"); + $this->hasMany('CPK_Test as Test', 'CPK_Association.test1_id'); } } class CPK_Association extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("test1_id", "integer", 11, "primary"); - $this->hasColumn("test2_id", "integer", 11, "primary"); + $this->hasColumn('test1_id', 'integer', 11, 'primary'); + $this->hasColumn('test2_id', 'integer', 11, 'primary'); } } class Log_Status extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 255); + $this->hasColumn('name', 'string', 255); } } class ValidatorTest extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("mymixed","string", 100); - $this->hasColumn("mystring","string", 100, "notnull|unique"); - $this->hasColumn("myarray", "array", 1000); - $this->hasColumn("myobject", "object", 1000); - $this->hasColumn("myinteger", "integer", 11); - $this->hasColumn("myrange", "integer", 11, array('range' => array(4,123))); - $this->hasColumn("myregexp", "string", 5, array('regexp' => '/^[0-9]+$/')); + $this->hasColumn('mymixed', 'string', 100); + $this->hasColumn('mystring', 'string', 100, 'notnull|unique'); + $this->hasColumn('myarray', 'array', 1000); + $this->hasColumn('myobject', 'object', 1000); + $this->hasColumn('myinteger', 'integer', 11); + $this->hasColumn('myrange', 'integer', 11, array('range' => array(4,123))); + $this->hasColumn('myregexp', 'string', 5, array('regexp' => '/^[0-9]+$/')); - $this->hasColumn("myemail", "string", 100, "email"); - $this->hasColumn("myemail2", "string", 100, "email|notblank"); + $this->hasColumn('myemail', 'string', 100, 'email'); + $this->hasColumn('myemail2', 'string', 100, 'email|notblank'); } } class DateTest extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("date", "date", 20); + $this->hasColumn('date', 'date', 20); } } class GzipTest extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("gzip", "gzip", 100000); + $this->hasColumn('gzip', 'gzip', 100000); } } class Tag extends Doctrine_Record { public function setUp() { - $this->hasMany("Photo", "Phototag.photo_id"); + $this->hasMany('Photo', 'Phototag.photo_id'); } public function setTableDefinition() { - $this->hasColumn("tag", "string", 100); + $this->hasColumn('tag', 'string', 100); } } class Photo extends Doctrine_Record { public function setUp() { - $this->hasMany("Tag", "Phototag.tag_id"); + $this->hasMany('Tag', 'Phototag.tag_id'); } public function setTableDefinition() { - $this->hasColumn("name", "string", 100); + $this->hasColumn('name', 'string', 100); } } class Phototag extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("photo_id", "integer"); - $this->hasColumn("tag_id", "integer"); + $this->hasColumn('photo_id', 'integer'); + $this->hasColumn('tag_id', 'integer'); } } @@ -479,82 +475,82 @@ class BooleanTest extends Doctrine_Record { } class Data_File extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("filename", "string"); - $this->hasColumn("file_owner_id", "integer"); + $this->hasColumn('filename', 'string'); + $this->hasColumn('file_owner_id', 'integer'); } public function setUp() { - $this->hasOne("File_Owner", "Data_File.file_owner_id"); + $this->hasOne('File_Owner', 'Data_File.file_owner_id'); } } class NotNullTest extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 100, "notnull"); - $this->hasColumn("type", "integer", 11); + $this->hasColumn('name', 'string', 100, 'notnull'); + $this->hasColumn('type', 'integer', 11); } } class File_Owner extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string", 255); + $this->hasColumn('name', 'string', 255); } public function setUp() { - $this->hasOne("Data_File", "Data_File.file_owner_id"); + $this->hasOne('Data_File', 'Data_File.file_owner_id'); } } class MyUser extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string"); + $this->hasColumn('name', 'string'); } public function setUp() { - $this->hasMany("MyOneThing", "MyOneThing.user_id"); - $this->hasMany("MyOtherThing", "MyOtherThing.user_id"); + $this->hasMany('MyOneThing', 'MyOneThing.user_id'); + $this->hasMany('MyOtherThing', 'MyOtherThing.user_id'); } } class MyOneThing extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string"); - $this->hasColumn("user_id", "integer"); + $this->hasColumn('name', 'string'); + $this->hasColumn('user_id', 'integer'); } public function setUp() { - $this->hasMany("MyUserOneThing", "MyUserOneThing.one_thing_id"); + $this->hasMany('MyUserOneThing', 'MyUserOneThing.one_thing_id'); } } class MyOtherThing extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("name", "string"); - $this->hasColumn("user_id", "integer"); + $this->hasColumn('name', 'string'); + $this->hasColumn('user_id', 'integer'); } public function setUp() { - $this->hasMany("MyUserOtherThing", "MyUserOtherThing.other_thing_id"); + $this->hasMany('MyUserOtherThing', 'MyUserOtherThing.other_thing_id'); } } class MyUserOneThing extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("user_id", "integer"); - $this->hasColumn("one_thing_id", "integer"); + $this->hasColumn('user_id', 'integer'); + $this->hasColumn('one_thing_id', 'integer'); } } class MyUserOtherThing extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("user_id", "integer"); - $this->hasColumn("other_thing_id", "integer"); + $this->hasColumn('user_id', 'integer'); + $this->hasColumn('other_thing_id', 'integer'); } } class CategoryWithPosition extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("position", "integer"); - $this->hasColumn("name", "string", 255); + $this->hasColumn('position', 'integer'); + $this->hasColumn('name', 'string', 255); } public function setUp() { - $this->ownsMany("BoardWithPosition as Boards", "BoardWithPosition.category_id"); + $this->ownsMany('BoardWithPosition as Boards', 'BoardWithPosition.category_id'); } } class BoardWithPosition extends Doctrine_Record { public function setTableDefinition() { - $this->hasColumn("position", "integer"); - $this->hasColumn("category_id", "integer"); + $this->hasColumn('position', 'integer'); + $this->hasColumn('category_id', 'integer'); } public function setUp() { - $this->hasOne("CategoryWithPosition as Category", "BoardWithPosition.category_id"); + $this->hasOne('CategoryWithPosition as Category', 'BoardWithPosition.category_id'); } } class Package extends Doctrine_Record {