jaggy
jaggy

Reputation: 822

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.

Upvotes: 5

Views: 895

Answers (1)

jaggy
jaggy

Reputation: 822

Just in case anyone needs it

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

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

Upvotes: 10

Related Questions