messageStatic() public static method

public static messageStatic ( $message = null )
Example #1
0
 it("stubs a static method", function () {
     Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->method('::messageStatic')->andReturn('Good Bye!');
     expect(Foo::messageStatic())->toBe('Good Bye!');
 });
 it("stubs a method using a closure", function () {
     Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->method('message', function ($param) {
         return $param;
     });
     $foo = new Foo();
     expect($foo->message('Good Bye!'))->toBe('Good Bye!');
 });
 it("stubs a static method using a closure", function () {
     Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->method('::messageStatic', function ($param) {
         return $param;
     });
     expect(Foo::messageStatic('Good Bye!'))->toBe('Good Bye!');
 });
 it("stubs a magic method multiple times", function () {
     Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->method('::magic')->with('hello')->andReturn('world');
     Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->method('::magic')->with('world')->andReturn('hello');
     expect(Foo::magic('hello'))->toBe('world');
     expect(Foo::magic('world'))->toBe('hello');
 });
 context("with multiple return values", function () {
     it("stubs a method", function () {
         Stub::on('Kahlan\\Spec\\Fixture\\Plugin\\Pointcut\\Foo')->method('message')->andReturn('Good Evening World!', 'Good Bye World!');
         $foo = new Foo();
         expect($foo->message())->toBe('Good Evening World!');
         $foo2 = new Foo();
         expect($foo2->message())->toBe('Good Bye World!');
     });