/** * @test */ public function propertyFunctionsUseAContentObjectIfOneHasBeenDefined() { $this->inject($this->nodeData, 'persistenceManager', $this->createMock(PersistenceManagerInterface::class)); $className = uniqid('Test'); eval(' class ' . $className . ' { public $title = "My Title"; public $body = "My Body"; } '); $contentObject = new $className(); $this->nodeData->setContentObject($contentObject); $this->assertTrue($this->nodeData->hasProperty('title')); $this->assertFalse($this->nodeData->hasProperty('iltfh')); $this->assertEquals('My Body', $this->nodeData->getProperty('body')); $this->assertEquals('My Title', $this->nodeData->getProperty('title')); $this->assertEquals(array('title' => 'My Title', 'body' => 'My Body'), $this->nodeData->getProperties()); $actualPropertyNames = $this->nodeData->getPropertyNames(); sort($actualPropertyNames); $this->assertEquals(array('body', 'title'), $actualPropertyNames); $this->nodeData->setProperty('title', 'My Other Title'); $this->nodeData->setProperty('body', 'My Other Body'); $this->assertEquals('My Other Body', $this->nodeData->getProperty('body')); $this->assertEquals('My Other Title', $this->nodeData->getProperty('title')); }
/** * Returns TRUE if the given node has the property and the value is not empty. * * @param NodeData $node * @return boolean */ public function matches(NodeData $node) { if ($node->hasProperty($this->propertyName)) { $propertyValue = $node->getProperty($this->propertyName); return !empty($propertyValue); } return false; }
/** * If the given node has the property this transformation should work on, this * returns TRUE. * * @param NodeData $node * @return boolean */ public function isTransformable(NodeData $node) { return $node->hasProperty($this->propertyName); }
/** * If this node has a property with the given name. * * If the node has a content object attached, the property will be checked * there. * * @param string $propertyName * @return boolean * @api */ public function hasProperty($propertyName) { return $this->nodeData->hasProperty($propertyName); }