From ba2c29a692455a0cdbace4732ac2ce54865e8233 Mon Sep 17 00:00:00 2001 From: crynobone Date: Sat, 4 Jan 2014 21:18:31 +0800 Subject: [PATCH] Return instance. Signed-off-by: crynobone --- src/Orchestra/Support/Messages.php | 4 +++- tests/MessagesTest.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Orchestra/Support/Messages.php b/src/Orchestra/Support/Messages.php index b8ee7d0..7d26f4f 100644 --- a/src/Orchestra/Support/Messages.php +++ b/src/Orchestra/Support/Messages.php @@ -75,12 +75,14 @@ public function retrieve() * Extend Messages instance from session. * * @param \Closure $callback - * @return void + * @return Messages */ public function extend(Closure $callback) { $instance = $this->retrieve(); call_user_func($callback, $instance); + + return $instance; } /** diff --git a/tests/MessagesTest.php b/tests/MessagesTest.php index 23ee7ab..64f2eee 100644 --- a/tests/MessagesTest.php +++ b/tests/MessagesTest.php @@ -116,11 +116,12 @@ public function testExtendMethod() }; $stub = with(new Messages)->setSession($session); - $stub->extend($callback); + $output = $stub->extend($callback); $retrieve = $stub->retrieve(); $retrieve->setFormat(); + $this->assertInstanceOf('\Orchestra\Support\Messages', $output); $this->assertInstanceOf('\Orchestra\Support\Messages', $retrieve); $this->assertEquals(array('Hi World', 'Hi Orchestra Platform'), $retrieve->get('hello')); }