public function testObjectReference() { $object = $this->getMock('Morph_Object', array('id', 'collection')); $object->expects($this->once())->method('id')->will($this->returnValue('anId')); $object->expects($this->once())->method('collection')->will($this->returnValue('aCollection')); $ref = Morph_Utils::objectReference($object); $expectedArray = array('$ref' => 'aCollection', '$id' => 'anId'); $this->assertEquals($ref, $expectedArray); }
/** * (non-PHPdoc) * @see tao/classes/Morph/property/Morph_Property_Generic#__getRawValue() */ public function __getRawValue() { if (!is_null($this->Value) && is_null($this->Reference)) { if ($this->Value->state() != Morph_Object::STATE_CLEAN) { //save value $this->Storage->save($this->Value); } $this->Reference = Morph_Utils::objectReference($this->Value); } return $this->Reference; }
/** * (non-PHPdoc) * @see tao/classes/Morph/property/Morph_Property_Generic#__getRawValue() */ public function __getRawValue() { if (count($this->Value) > 0) { $refs = array(); foreach ($this->Value as $object) { if ($object->state() != Morph_Object::STATE_CLEAN) { $this->Storage->save($object); } $refs[] = Morph_Utils::objectReference($object); } $this->References = $refs; } return $this->Reference; }