/**
  * @covers ::getValues
  */
 public function testGetValues()
 {
     $values = ['FOO' => 'BAR'];
     // Use PHPUnit for mocking, because Prophecy cannot mock methods that return
     // by reference. See \Prophecy\Doubler\Generator\Node::getCode().
     $decorated_form_state = $this->getMock(FormStateInterface::class);
     $decorated_form_state->expects($this->once())->method('getValues')->willReturn($values);
     $this->formStateDecoratorBase = new NonAbstractFormStateDecoratorBase($decorated_form_state);
     $this->assertSame($values, $this->formStateDecoratorBase->getValues());
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function &getValues()
 {
     $exists = NULL;
     $values =& NestedArray::getValue(parent::getValues(), $this->getParents('#parents'), $exists);
     if (!$exists) {
         $values = [];
     } elseif (!is_array($values)) {
         throw new \UnexpectedValueException('The form state values do not belong to the subform.');
     }
     return $values;
 }