public function testGetCorrectDefinitionAfterDefinitionDeleted() { $req = new Test_DataModel_Requirement(); $oDef1 = $req->getDefinition(); DataModel_Definitions::destroy(); $req2 = new Test_DataModel_Requirement(); $oDef2 = $req2->getDefinition(); $this->assertNotSame($oDef1, $oDef2); }
function constraint_mustBeValidModel($model) { $oDef = DataModel_Definitions::getIfExists($model); }
} public function validateRegistration(Messages $messages, Datastore $oDB) { $objs = $this->findObjsForMethod('validateRegistration'); foreach ($objs as $obj) { // var_dump('Calling ' . get_class($obj) . '::validateRegistration()'); $obj->validateRegistration($messages, $oDB); } if (count($return) > 0) { // validation failed ... tell the user why var_dump($return); } } } // define the minimum fields for a user $oDef = DataModel_Definitions::get('User'); $oDef->addField('uid'); $oDef->addField('username'); $oDef->addFakeField('authType')->setDefaultValue(User::AUTHTYPE_ANON); $oDef->addFakeField('authenticated'); $oDef->addField('alias'); $oDef->addField('constructed')->setDefaultValue(0); $oDef->setPrimaryKey('uid'); // this is used by App::loadThemeEngine to determine whether the user // can personalise their theme or not // // the mainLoop() of the various App_Engines can choose to use the user // theme or not as appropriate // // the User_Theme_Ext extension changes the default value of this field $oDef->addFakeField('supportsThemePref')->setDefaultValue(false);
public function extractInto($model, $view = 'default') { if (is_string($model)) { $oDef = DataModel_Definitions::get($model); } else { if ($model instanceof Datastore_Record) { $oDef = $model->getDefinition(); } else { if ($model instanceof DataModel) { $oDef = $model->getDefinition(); } else { throw new Exception(); } } } $this->extractInto[] = $oDef->getView($view); return $this; }
public function requireTheirModelDefinition() { $this->requireTheirModelName(); if (isset($this->theirModelDef)) { return; } $this->theirModelDef = DataModel_Definitions::get($this->theirModelName); }
public function testCanRetrieveWhenFakeFieldsAreDefined() { // $this->setup(); $oDef = DataModel_Definitions::get('Test_Customer'); $oDef->addFakeField('trouble'); $custQ = $this->db->newQuery()->findFirst('Test_Customer')->withUniqueID(1); $customer = $this->db->search($custQ); $this->assertTrue($customer instanceof Test_Customer); $this->assertEquals(1, (int) $customer->customerId); }