/**
  * @return StructValueContainer
  */
 public static function instance()
 {
     $struct = StructTest::instance('Foo', 'true');
     $structValueContainer = new StructValueContainer(self::getBingGeneratorInstance());
     $structValueContainer->add(new StructValue(self::getBingGeneratorInstance(), 1, 0, $struct));
     $structValueContainer->add(new StructValue(self::getBingGeneratorInstance(), 2, 1, $struct));
     $structValueContainer->add(new StructValue(self::getBingGeneratorInstance(), 'any', 2, $struct));
     $structValueContainer->add(new StructValue(self::getBingGeneratorInstance(), 'bar', 3, $struct));
     return $structValueContainer;
 }
Example #2
0
 /**
  * Adds value to values array
  * @uses Struct::getValue()
  * @uses Struct::getValues()
  * @param mixed $value the original value
  * @return Struct
  */
 public function addValue($value)
 {
     if ($this->getValue($value) === null) {
         $this->values->add(new StructValue($this->getGenerator(), $value, $this->getValues()->count(), $this));
         $this->setIsRestriction(true);
         $this->setIsStruct(true);
     }
     return $this;
 }
 /**
  *
  */
 public function testReforma()
 {
     $tagEnumerationParser = self::reformaInstance();
     $tagEnumerationParser->parse();
     $count = 0;
     foreach ($tagEnumerationParser->getGenerator()->getStructs() as $struct) {
         if ($struct instanceof Struct && $struct->getIsRestriction() === true) {
             if ($struct->getName() === 'HouseStateEnum') {
                 $values = new StructValueContainer($tagEnumerationParser->getGenerator());
                 $one = new StructValue($tagEnumerationParser->getGenerator(), '1', 0, $struct);
                 $one->setMeta(array('label' => 'normal', 'description' => 'Исправный'));
                 $values->add($one);
                 $two = new StructValue($tagEnumerationParser->getGenerator(), '2', 1, $struct);
                 $two->setMeta(array('label' => 'warning', 'description' => 'Требующий капитального ремонта'));
                 $values->add($two);
                 $three = new StructValue($tagEnumerationParser->getGenerator(), '3', 2, $struct);
                 $three->setMeta(array('label' => 'alarm', 'description' => 'Аварийный'));
                 $values->add($three);
                 $four = new StructValue($tagEnumerationParser->getGenerator(), '4', 3, $struct);
                 $four->setMeta(array('label' => 'noinfo', 'description' => 'Нет данных'));
                 $values->add($four);
                 $this->assertEquals($values, $struct->getValues());
                 $count++;
             } elseif ($struct->getName() === 'HouseStageEnum') {
                 $values = new StructValueContainer($tagEnumerationParser->getGenerator());
                 $one = new StructValue($tagEnumerationParser->getGenerator(), '1', 0, $struct);
                 $one->setMeta(array('label' => 'exploited', 'description' => 'Эксплуатируемый'));
                 $values->add($one);
                 $two = new StructValue($tagEnumerationParser->getGenerator(), '2', 1, $struct);
                 $two->setMeta(array('label' => 'decommissioned', 'description' => 'Выведенный из эксплуатации'));
                 $values->add($two);
                 $three = new StructValue($tagEnumerationParser->getGenerator(), '3', 2, $struct);
                 $three->setMeta(array('label' => 'drifting', 'description' => 'Снесенный'));
                 $values->add($three);
                 $struct->getValues()->rewind();
                 $this->assertEquals($values, $struct->getValues());
                 $count++;
             }
         }
     }
     $this->assertSame(2, $count);
 }