Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: use SebastianBergmann\Exporter\Exporter; Chris@0: Chris@0: /** Chris@0: * Stubs a method by returning a user-defined stack of values. Chris@0: * Chris@0: * @since Class available since Release 1.0.0 Chris@0: */ Chris@0: class PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls implements PHPUnit_Framework_MockObject_Stub Chris@0: { Chris@0: protected $stack; Chris@0: protected $value; Chris@0: Chris@0: public function __construct($stack) Chris@0: { Chris@0: $this->stack = $stack; Chris@0: } Chris@0: Chris@0: public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) Chris@0: { Chris@0: $this->value = array_shift($this->stack); Chris@0: Chris@0: if ($this->value instanceof PHPUnit_Framework_MockObject_Stub) { Chris@0: $this->value = $this->value->invoke($invocation); Chris@0: } Chris@0: Chris@0: return $this->value; Chris@0: } Chris@0: Chris@0: public function toString() Chris@0: { Chris@0: $exporter = new Exporter; Chris@0: Chris@0: return sprintf( Chris@0: 'return user-specified value %s', Chris@0: $exporter->export($this->value) Chris@0: ); Chris@0: } Chris@0: }