-
-
Save Ilyes512/a28ec9ad2feb863e87ebff590a8ebb3a to your computer and use it in GitHub Desktop.
Revisions
-
ramsey revised this gist
Jan 15, 2016 . No changes.There are no files selected for viewing
-
ramsey created this gist
Jan 15, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ <?php namespace Ramsey\Talks; class Bar { public function getSomething(Foo $foo, $arg1, $arg2) { $result = $foo->bar()->baz($arg1)->qux()->quux($arg2); return "Now, we're {$result}"; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ <?php namespace Ramsey\Talks\Test; class FluentTest extends \PHPUnit_Framework_TestCase { public function tearDown() { \Mockery::close(); } public function testFluentInterfacesWithParameterAtEndOfChain() { $mock = \Mockery::mock('Ramsey\\Talks\\Foo'); $mock->shouldReceive('bar->baz->qux->quux') ->with(123) ->andReturn('awesome!'); $mock->shouldReceive('bar->baz->qux->quux') ->with(321) ->andReturn('cool!'); $bar = new \Ramsey\Talks\Bar; $this->assertEquals("Now, we're awesome!", $bar->getSomething($mock, null, 123)); $this->assertEquals("Now, we're cool!", $bar->getSomething($mock, null, 321)); } public function testFluentInterfacesWithInterveningParameters() { $baz = \Mockery::mock('baz'); $baz->shouldReceive('qux->quux') ->with(321) ->andReturn('rad!'); $mock = \Mockery::mock('Ramsey\\Talks\\Foo'); $mock->shouldReceive('bar->baz') ->with(123) ->andReturn($baz); $bar = new \Ramsey\Talks\Bar; $this->assertEquals("Now, we're rad!", $bar->getSomething($mock, 123, 321)); } }