Search code examples
phpphpspec

phpspec - get return value


I want to get the actual return value of the object rather than a chainable object.

class Foo
{
   public $attribute = 'data';
}

class FooSpec extends ObjectBehavior
{
   public function it_is_a_test()
   {
       $attribute = $this->attribute; // I want to get 'data'
   }
}

Is there any way for this to happen?

Thanks.


Solution

  • Just in case anyone needs it

    $attribute = $this->attribute->getWrappedObject();
    

    It returns the actual return value of the function/attribute.