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); }
/** * Returns the name of the collection this object should be stored in * * @param string $collection * @return string */ public function collection($collection = null) { if (!is_null($collection)) { $this->Collection = $collection; } elseif (is_null($this->Collection)) { //defaults collection name to class name $this->Collection = Morph_Utils::collectionName($this); } return $this->Collection; }
/** * (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; }