Exemplo n.º 1
0
             it("throw an exception with invalid definition", function () {
                 $closure = function () {
                     $foo = new Foo();
                     Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->methods(['bar' => 'Hello Bar!']);
                 };
                 $message = "Stubbed method definition for `bar` must be a closure or an array of returned value(s).";
                 expect($closure)->toThrow(new InvalidArgumentException($message));
             });
         });
     });
     context("with a trait", function () {
         it("stubs a method", function () {
             Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\SubBar')->method('traitMethod')->andReturn('trait method stubbed !');
             $subBar = new SubBar();
             expect($subBar->traitMethod())->toBe('trait method stubbed !');
             $subBar2 = new SubBar();
             expect($subBar2->traitMethod())->toBe('trait method stubbed !');
         });
     });
 });
 describe("::registered()", function () {
     describe("without provided hash", function () {
         it("returns an empty array when no instance are registered", function () {
             expect(Stub::registered())->toBe([]);
         });
         it("returns an array of registered instances", function () {
             Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->method('foo', function () {
             });
             expect(Stub::registered())->toBeA('array')->toBe(['Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo']);
         });
     });
Exemplo n.º 2
0
             $foo = new Foo();
             expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->not->toReceive('message');
         });
         it("expects called method to be uncalled using a wrong classname", function () {
             $foo = new Foo();
             expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\FooFoo')->not->toReceive('message');
             $foo->message();
         });
         it("expects not overrided method to also be called on method's __CLASS__", function () {
             $bar = new SubBar();
             expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Bar')->toReceive('send');
             expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\SubBar')->toReceive('send');
             $bar->send();
         });
         it("expects overrided method to not be called on method's __CLASS__", function () {
             $bar = new SubBar();
             expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Bar')->not->toReceive('overrided');
             expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\SubBar')->toReceive('overrided');
             $bar->overrided();
         });
     });
 });
 context("with static call", function () {
     it("expects called method to be called", function () {
         expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->toReceive('::version');
         Foo::version();
     });
     it("expects called method to not be dynamically called", function () {
         expect('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->not->toReceive('version');
         Foo::version();
     });