$select = $query->b();
expect($select->c())->toBe('something');
});
it("expects not called chain to be uncalled", function () {
$foo = new Foo();
allow($foo)->toReceive('a', 'b', 'c')->andReturn('something');
expect($foo)->not->toReceive('a', 'c', 'b')->once();
$query = $foo->a();
$select = $query->b();
$select->c();
});
it('auto monkey patch core classes using a stub when possible', function () {
allow('PDO')->toReceive('prepare', 'fetchAll')->andReturn([['name' => 'bob']]);
expect('PDO')->toReceive('prepare')->once();
$user = new User();
expect($user->all())->toBe([['name' => 'bob']]);
});
it('allows to mix static/dynamic methods', function () {
allow('Kahlan\\Spec\\Fixture\\Plugin\\Monkey\\User')->toReceive('::create', 'all')->andReturn([['name' => 'bob']]);
expect('Kahlan\\Spec\\Fixture\\Plugin\\Monkey\\User')->toReceive('::create', 'all')->once();
$user = User::create();
expect($user->all())->toBe([['name' => 'bob']]);
});
});
context("with chain of methods and arguments requirements", function () {
it("expects called method to be called with correct arguments", function () {
$foo = new Foo();
expect($foo)->toReceive('message')->where(['message' => ['My Message', 'My Other Message']]);
$foo->message('My Message', 'My Other Message');
});
it("expects stubbed chain called with matching arguments are called", function () {