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()
9090 return $ mock ->shouldReceive (...func_get_args ());
9191 }
9292
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+
93109 /**
94110 * Create a fresh mock instance for the given class.
95111 *
Original file line number Diff line number Diff line change @@ -70,6 +70,16 @@ public function testCanBeMockedWithoutUnderlyingInstance()
7070 FacadeStub::shouldReceive ('foo ' )->once ()->andReturn ('bar ' );
7171 $ this ->assertSame ('bar ' , FacadeStub::foo ());
7272 }
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+ }
7383}
7484
7585class FacadeStub extends Facade
You can’t perform that action at this time.
0 commit comments