Revision: 393
Author: coretxt
Date: Wed May 19 05:10:50 2010
Log: adding initial test for Record::baseAncestor
http://code.google.com/p/floe/source/detail?r=393
Added:
/trunk/dev/tests/repository.test.php
Deleted:
/trunk/src/repository/ImprovedRecord.class.php
Modified:
/trunk/src/repository/Record.class.php
=======================================
--- /dev/null
+++ /trunk/dev/tests/repository.test.php Wed May 19 05:10:50 2010
@@ -0,0 +1,41 @@
+<?php
+require_once "simpletest/autorun.php";
+require_once dirname(__FILE__).'/../../src/repository/Record.class.php';
+
+class DomainObject extends Record {
+
+ function __define() {
+ $this->property("key1", "string");
+ }
+
+ function getValueCheck() {
+ return "value";
+ }
+
+}
+
+class ConcreteDomainObject extends DomainObject {
+
+ function __define() {
+ $this->property("key2", "string");
+ }
+
+}
+
+class RepositoryRecordSemanticsTest extends UnitTestCase {
+
+ function setUp() {
+ Record::baseAncestor('DomainObject');
+ }
+
+ function testBaseAncestorInheritance() {
+ $obj = new ConcreteDomainObject();
+ $this->assertEqual("value", $obj->getValueCheck());
+ }
+
+ function tearDown() {
+ Record::baseAncestor('Record');
+ }
+}
+
+?>
=======================================
--- /trunk/src/repository/ImprovedRecord.class.php Tue May 18 08:24:06 2010
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * This file is part of Floe, a graceful PHP framework.
- * Copyright (C) 2005-2010 Mark Rickerby <
http://maetl.net>
- *
- * See the LICENSE file distributed with this software for full copyright,
disclaimer
- * of liability, and the specific limitations that govern the use of this
software.
- *
- * $Id: Query.class.php 362 2010-03-10 00:53:10Z coretxt $
- * @package repository
- */
-
-/**
- * A rewrite of the repository for floe 0.7 series.
- *
- * Will run alongside existing code until all tests pass. The goal is to
use higher level
- * abstractions for query methods, whilst cleaning up some of the ORM
functionality
- * and making the relational behavior more consistent.
- */
-class ImprovedRecord {
-
- /**
- * Constructor for active record objects.
- *
- * @param $object hash/stdClass of data to wrap, or int of record id
- */
- function __construct($object=false) {
- // identity mapperrrrrrrrrrrr
- }
-
-}
-
-?>
=======================================
--- /trunk/src/repository/Record.class.php Fri Apr 30 11:08:32 2010
+++ /trunk/src/repository/Record.class.php Wed May 19 05:10:50 2010
@@ -1,12 +1,25 @@
<?php
/**
+ * This file is part of Floe, a graceful PHP framework.
+ * Copyright (C) 2005-2010 Mark Rickerby <
http://maetl.net>
+ *
+ * See the LICENSE file distributed with this software for full copyright,
disclaimer
+ * of liability, and the specific limitations that govern the use of this
software.
+ *
* $Id$
* @package repository
*/
+
require_once 'DependentRelation.class.php';
require_once 'store/StorageAdaptor.class.php';
require_once dirname(__FILE__) .'/../language/en/Inflect.class.php';
+/**
+ * Name of the hook method used to construct model properties,
relationships and rules.
+ * @todo change name for 0.7 release
+ */
+if (!defined('Record_DefinitionHook'))
define('Record_DefinitionHook', '__define');
+
/**
* Active record base class.
*
@@ -45,7 +58,8 @@
}
if ($record) {
if (is_numeric($record)) {
- $record = $this->findObjectById($record);
+ $this->storage->selectById($this->tableName, $id);
+ $record = $this->storage->getObject();
if (!$record) {
require_once dirname(__FILE__).'/RecordNotFound.class.php';
throw new RecordNotFound(get_class($this), dirname(__FILE__));
@@ -116,7 +130,7 @@
private function initializeDefinedAncestors() {
$class = get_class($this);
while ($class != self::$baseAncestor) {
- $parentDefinition = new ReflectionMethod($class, '__define');
+ $parentDefinition = new ReflectionMethod($class, Record_DefinitionHook);
$parentDefinition->invoke($this);
$this->tableName = Inflect::toTableName($class);
$class = get_parent_class($class);
@@ -125,7 +139,7 @@
private function initializeAsBaseAncestor() {
$class = get_class($this);
- if (method_exists($this, '__define')) $this->__define();
+ if (method_exists($this, Record_DefinitionHook))
$this->{Record_DefinitionHook}();
$this->tableName = Inflect::toTableName($class);
if ($this->hasProperty('type')) $this->setProperty("type",
get_class($this));
}
@@ -592,14 +606,6 @@
function remove() {
$this->storage->delete($this->tableName, array('id'=>$this->id));
}
-
- /**
- * @deprecated
- */
- function findObjectById($id) {
- $this->storage->selectById($this->tableName, $id);
- return $this->storage->getObject();
- }
function toArray() {
return (array)$this->recordInstance;
--
You received this message because you are subscribed to the Google Groups "Floe Commits" group.
To post to this group, send email to
floe-c...@googlegroups.com.
To unsubscribe from this group, send email to
floe-commits...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/floe-commits?hl=en.