Skip to content

Commit 35df766

Browse files
committed
add test for booting callbacks
1 parent aa8f695 commit 35df766

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

tests/Foundation/FoundationApplicationTest.php

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,24 +221,58 @@ public function testAfterBootstrappingAddsClosure()
221221

222222
public function testBootingCallbacks()
223223
{
224-
$app = new Application;
224+
$application = new Application;
225225

226226
$counter = 0;
227-
$closure = function ($app) use (&$counter) {
227+
$closure = function ($app) use (&$counter, $application) {
228228
$counter++;
229-
$this->assertInstanceOf(Application::class, $app);
229+
$this->assertSame($application, $app);
230230
};
231231

232-
$closure2 = function ($app) use (&$counter) {
232+
$closure2 = function ($app) use (&$counter, $application) {
233233
$counter++;
234-
$this->assertInstanceOf(Application::class, $app);
234+
$this->assertSame($application, $app);
235235
};
236236

237-
$app->booting($closure);
238-
$app->booting($closure2);
239-
$app->boot();
237+
$application->booting($closure);
238+
$application->booting($closure2);
239+
240+
$application->boot();
241+
240242
$this->assertEquals(2, $counter);
241243
}
244+
245+
public function testBootedCallbacks()
246+
{
247+
$application = new Application;
248+
249+
$counter = 0;
250+
$closure = function ($app) use (&$counter, $application) {
251+
$counter++;
252+
$this->assertSame($application, $app);
253+
};
254+
255+
$closure2 = function ($app) use (&$counter, $application) {
256+
$counter++;
257+
$this->assertSame($application, $app);
258+
};
259+
260+
$closure3 = function ($app) use (&$counter, $application) {
261+
$counter++;
262+
$this->assertSame($application, $app);
263+
};
264+
265+
$application->booting($closure);
266+
$application->booted($closure);
267+
$application->booted($closure2);
268+
$application->boot();
269+
270+
$this->assertEquals(3, $counter);
271+
272+
$application->booted($closure3);
273+
274+
$this->assertEquals(4, $counter);
275+
}
242276
}
243277

244278
class ApplicationBasicServiceProviderStub extends ServiceProvider

0 commit comments

Comments
 (0)