Skip to content

Instantly share code, notes, and snippets.

@manchuck
Created May 20, 2015 16:14
Show Gist options
  • Save manchuck/6506a0b3e6b34bc7b566 to your computer and use it in GitHub Desktop.
Save manchuck/6506a0b3e6b34bc7b566 to your computer and use it in GitHub Desktop.
My mistake you do not need ordered just have define the times it should be called
<?php
include 'vendor/autoload.php';
class FileObject {
public function readBytes() { /* ... */}
}
$stub = \Mockery::mock('FileObject');
$stub->shouldReceive('readBytes')
->andReturn('foo')
->once();
$stub->shouldReceive('readBytes')
->once()
->andReturn('bar');
$stub->shouldReceive('readBytes')
->atLeast(1)
->andReturn('baz');
var_dump($stub->readBytes());
var_dump($stub->readBytes());
var_dump($stub->readBytes());
var_dump($stub->readBytes());
string(3) "foo"
string(3) "bar"
string(3) "baz"
string(3) "baz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment