/**
  * @depends testReadingGroupWithProperty
  */
 public function testReadingGroupWithBooleanProperty()
 {
     $xml = '
         <config>
             <group title="Test Group">
                 <property name="testProperty1" type="boolean">Enter yes or no</property>
             </group>
         </config>
     ';
     $this->reader->fromString($xml);
     $this->reader->read();
     $this->reader->read();
     $this->reader->read();
     $this->assertTrue($this->reader->isBooleanProperty(), 'Element is expected to be a boolean property.');
     $this->assertEquals('testProperty1', $this->reader->getAttribute('name'));
     $this->assertEquals('Enter yes or no', $this->reader->getElementValue());
     $this->assertFalse($this->reader->read());
 }
Example #2
0
 /**
  * Read config from xml
  *
  * @param string $xmlString
  * @return $this
  */
 public function readFromXml($xmlString)
 {
     $this->xmlReader->fromString($xmlString);
     while ($this->xmlReader->read()) {
         if ($this->xmlReader->isGroup()) {
             $groupTitle = $this->xmlReader->getAttribute('title');
             $groupIdentifier = $this->xmlReader->getElementIdentifier();
             $this->propertyGroups[$groupIdentifier] = new PropertyGroup($groupTitle);
         } elseif ($this->xmlReader->isMultipleProperty()) {
             $property = new Property();
             $property->setName($this->xmlReader->getAttribute('name'));
             $property->setQuestion($this->xmlReader->getElementValue());
             $property->setType(Property::TYPE_MULTIPLE);
             $this->propertyGroups[$groupIdentifier]->addProperty($property);
         } elseif ($this->xmlReader->isBooleanProperty()) {
             $property = new Property();
             $property->setName($this->xmlReader->getAttribute('name'));
             $property->setQuestion($this->xmlReader->getElementValue());
             $property->setType(Property::TYPE_BOOL);
             $this->propertyGroups[$groupIdentifier]->addProperty($property);
         } elseif ($this->xmlReader->isProperty()) {
             $property = new Property();
             $property->setName($this->xmlReader->getAttribute('name'));
             $property->setQuestion($this->xmlReader->getElementValue());
             $property->setType(Property::TYPE_MIXED);
             $this->propertyGroups[$groupIdentifier]->addProperty($property);
         } elseif ($this->xmlReader->isPropertyWithOptions()) {
             $property = new Property();
             $property->setName($this->xmlReader->getAttribute('name'));
             $property->setQuestion($this->xmlReader->getAttribute('title'));
             foreach ($this->xmlReader->getPropertyOptions() as $value => $name) {
                 $property->addOption($name, $value);
             }
             $this->propertyGroups[$groupIdentifier]->addProperty($property);
             $this->xmlReader->next();
         }
     }
     return $this;
 }