From 1c81cb302582838e6a2f51d13ea4aff65710aa0e Mon Sep 17 00:00:00 2001 From: doctrine Date: Tue, 30 May 2006 22:47:01 +0000 Subject: [PATCH] --- Doctrine/Record.php | 15 +++++++++++++++ tests/RecordTestCase.class.php | 7 ++++++- tests/run.php | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Doctrine/Record.php b/Doctrine/Record.php index 6e4a3d986..39aa8590b 100644 --- a/Doctrine/Record.php +++ b/Doctrine/Record.php @@ -1104,6 +1104,21 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite final public function hasColumn($name, $type, $length = 20, $options = "") { $this->table->setColumn($name, $type, $length, $options); } + /** + * __call + * @param string $m + * @param array $a + */ + public function __call($m,$a) { + if( ! function_exists($m)) + throw new Doctrine_Record_Exception("unknown callback"); + + if(isset($a[0])) { + $column = $a[0]; + $this->data[$column] = $m($this->get($column)); + } + return $this; + } /** * returns a string representation of this object */ diff --git a/tests/RecordTestCase.class.php b/tests/RecordTestCase.class.php index 79e5f5fea..5bda33b7a 100644 --- a/tests/RecordTestCase.class.php +++ b/tests/RecordTestCase.class.php @@ -2,7 +2,12 @@ require_once("UnitTestCase.class.php"); class Doctrine_RecordTestCase extends Doctrine_UnitTestCase { - + public function testCallback() { + $user = new User(); + $user->name = " zYne "; + $user->trim('name'); + $this->assertEqual($user->name, 'zYne'); + } public function testJoinTableSelfReferencing() { $e = new Entity(); $e->name = "Entity test"; diff --git a/tests/run.php b/tests/run.php index 892fd0e96..c0f10a6a4 100644 --- a/tests/run.php +++ b/tests/run.php @@ -25,7 +25,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests"); //$test->addTestCase(new Sensei_UnitTestCase()); $test->addTestCase(new Doctrine_RecordTestCase()); - +/** $test->addTestCase(new Doctrine_SessionTestCase()); $test->addTestCase(new Doctrine_TableTestCase()); @@ -47,7 +47,7 @@ $test->addTestCase(new Doctrine_Collection_OffsetTestCase()); $test->addTestCase(new Doctrine_CollectionTestCase()); $test->addTestCase(new Doctrine_QueryTestCase()); - +*/ //$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());