File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
src/Illuminate/Support/Facades Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,22 @@ public static function shouldReceive()
90
90
return $ mock ->shouldReceive (...func_get_args ());
91
91
}
92
92
93
+ /**
94
+ * Initiate a mock expectation on the facade.
95
+ *
96
+ * @return \Mockery\Expectation
97
+ */
98
+ public static function expects ()
99
+ {
100
+ $ name = static ::getFacadeAccessor ();
101
+
102
+ $ mock = static ::isMock ()
103
+ ? static ::$ resolvedInstance [$ name ]
104
+ : static ::createFreshMockInstance ();
105
+
106
+ return $ mock ->expects (...func_get_args ());
107
+ }
108
+
93
109
/**
94
110
* Create a fresh mock instance for the given class.
95
111
*
Original file line number Diff line number Diff line change @@ -70,6 +70,16 @@ public function testCanBeMockedWithoutUnderlyingInstance()
70
70
FacadeStub::shouldReceive ('foo ' )->once ()->andReturn ('bar ' );
71
71
$ this ->assertSame ('bar ' , FacadeStub::foo ());
72
72
}
73
+
74
+ public function testExpectsReturnsAMockeryMockWithExpectationRequired ()
75
+ {
76
+ $ app = new ApplicationStub ;
77
+ $ app ->setAttributes (['foo ' => new stdClass ]);
78
+ FacadeStub::setFacadeApplication ($ app );
79
+
80
+ $ this ->assertInstanceOf (MockInterface::class, $ mock = FacadeStub::expects ('foo ' )->with ('bar ' )->andReturn ('baz ' )->getMock ());
81
+ $ this ->assertSame ('baz ' , $ app ['foo ' ]->foo ('bar ' ));
82
+ }
73
83
}
74
84
75
85
class FacadeStub extends Facade
You can’t perform that action at this time.
0 commit comments