@@ -80,6 +80,40 @@ public function testExpectsReturnsAMockeryMockWithExpectationRequired()
8080 $ this ->assertInstanceOf (MockInterface::class, $ mock = FacadeStub::expects ('foo ' )->with ('bar ' )->andReturn ('baz ' )->getMock ());
8181 $ this ->assertSame ('baz ' , $ app ['foo ' ]->foo ('bar ' ));
8282 }
83+
84+ public function testFacadeResolvesAgainAfterClearingSpecific ()
85+ {
86+ $ app = new ApplicationStub ;
87+ $ app ->setAttributes (['foo ' => $ mock = m::mock (stdClass::class)]);
88+ $ mock ->shouldReceive ('bar ' )->times (3 )->andReturn ('baz ' );
89+
90+ // Resolve for the first time
91+ FacadeStub::setFacadeApplication ($ app );
92+ $ this ->assertSame ('baz ' , FacadeStub::bar ());
93+
94+ // Clear resolved instance and resolve the second time
95+ FacadeStub::clearResolvedInstance ();
96+ $ this ->assertSame ('baz ' , FacadeStub::bar ());
97+
98+ // Clear resolved instance through parent and resolve the third time
99+ Facade::clearResolvedInstance ('foo ' );
100+ $ this ->assertSame ('baz ' , FacadeStub::bar ());
101+ }
102+
103+ public function testFacadeResolvesAgainAfterClearingAll ()
104+ {
105+ $ app = new ApplicationStub ;
106+ $ app ->setAttributes (['foo ' => $ mock = m::mock (stdClass::class)]);
107+ $ mock ->shouldReceive ('bar ' )->times (2 )->andReturn ('baz ' );
108+
109+ // Resolve for the first time
110+ FacadeStub::setFacadeApplication ($ app );
111+ $ this ->assertSame ('baz ' , FacadeStub::bar ());
112+
113+ // Clear all resolved instances and resolve a second time
114+ Facade::clearResolvedInstances ();
115+ $ this ->assertSame ('baz ' , FacadeStub::bar ());
116+ }
83117}
84118
85119class FacadeStub extends Facade
0 commit comments