예제 #1
0
 /**
  * @expectedException \RuntimeException
  */
 public function testGetDefaultOptionsWithValidInvalidFlip()
 {
     Choice::$list = array(1 => 'error', 2 => 'error');
     $type = new StatusType('Sonata\\CoreBundle\\Tests\\Form\\Type\\Choice', 'getList', 'choice_type', true);
     $this->assertEquals('choice_type', $type->getName());
     $this->assertEquals('choice', $type->getParent());
     FormHelper::configureOptions($type, $resolver = new OptionsResolver());
     $options = $resolver->resolve(array());
 }
예제 #2
0
 public function testGetDefaultOptions()
 {
     $type = new StatusType('Sonata\\CoreBundle\\Tests\\Form\\Type\\Choice', 'getList', 'choice_type');
     $this->assertEquals('choice_type', $type->getName());
     $this->assertEquals('choice', $type->getParent());
     FormHelper::configureOptions($type, $resolver = new OptionsResolver());
     $options = $resolver->resolve(array());
     $this->assertArrayHasKey('choices', $options);
     $this->assertEquals($options['choices'], array(1 => 'salut'));
 }
예제 #3
0
 /**
  * @internal
  *
  * @param \SimpleXMLElement $xml
  *
  * @return StatusType
  */
 public static function fromXml(\SimpleXMLElement $xml)
 {
     $statusType = new StatusType();
     $statusType->setIsResponse();
     if (isset($xml->Code)) {
         $statusType->setCode((string) $xml->Code);
     }
     if (isset($xml->Description)) {
         $statusType->setDescription((string) $xml->Description);
     }
     return $statusType;
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getType()
 {
     return $this->hasOne(StatusType::className(), ['id' => 'type_id']);
 }