create() public static method

public static create ( )
Esempio n. 1
0
         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 () {
         $foo = new Foo();
         allow($foo)->toReceive('a', 'b', 'c');
         expect($foo)->toReceive('a', 'b', 'c')->where(['a' => [1], 'b' => [2], 'c' => [3]]);
         $query = $foo->a(1);
         $select = $query->b(2);