Exemple #1
0
 public function testParameters()
 {
     $b = new Behavior();
     $this->assertEquals($b->getParameters(), array(), 'Behavior parameters is an empty array by default');
     $b->addParameter(array('name' => 'foo', 'value' => 'bar'));
     $this->assertEquals($b->getParameters(), array('foo' => 'bar'), 'addParameter() sets a parameter from an associative array');
     $b->addParameter(array('name' => 'foo2', 'value' => 'bar2'));
     $this->assertEquals($b->getParameters(), array('foo' => 'bar', 'foo2' => 'bar2'), 'addParameter() adds a parameter from an associative array');
     $b->addParameter(array('name' => 'foo', 'value' => 'bar3'));
     $this->assertEquals($b->getParameters(), array('foo' => 'bar3', 'foo2' => 'bar2'), 'addParameter() changes a parameter from an associative array');
     $this->assertEquals($b->getParameter('foo'), 'bar3', 'getParameter() retrieves a parameter value by name');
     $b->setParameters(array('foo3' => 'bar3', 'foo4' => 'bar4'));
     $this->assertEquals($b->getParameters(), array('foo3' => 'bar3', 'foo4' => 'bar4'), 'setParameters() changes the whole parameter array');
 }
Exemple #2
0
 /**
  * Appends the generated <behavior> XML node to its parent node.
  *
  * @param Behavior $behavior   The Behavior model instance
  * @param \DOMNode $parentNode The parent DOMNode object
  */
 private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode)
 {
     $behaviorNode = $parentNode->appendChild($this->document->createElement('behavior'));
     $behaviorNode->setAttribute('name', $behavior->getName());
     if ($behavior->allowMultiple()) {
         $behaviorNode->setAttribute('id', $behavior->getId());
     }
     foreach ($behavior->getParameters() as $name => $value) {
         $parameterNode = $behaviorNode->appendChild($this->document->createElement('parameter'));
         $parameterNode->setAttribute('name', $name);
         $parameterNode->setAttribute('value', $value);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getParameters()
 {
     $parameters = parent::getParameters();
     $parameters['transition'] = implode($parameters['transition'], '|');
     return $parameters;
 }