initDatabase(); /** @var Authenticator|MockObject $auth */ $auth = $this->createMock(Authenticator::class); $request = new Request(); $theme = ['name' => 'Testtheme', 'navbar_classes' => 'something']; $theme2 = ['name' => 'Bar']; $theme3 = ['name' => 'Lorem']; $user = User::factory() ->has(Settings::factory(['theme' => 42])) ->create(); $config = new Config(['theme' => 23, 'themes' => [42 => $theme, 23 => $theme2, 1337 => $theme3]]); $auth->expects($this->exactly(3)) ->method('user') ->willReturnOnConsecutiveCalls( null, $user, null ); $this->app->instance('config', $config); $extension = new Globals($auth, $request); $globals = $extension->getGlobals(); $this->assertGlobalsExists('user', [], $globals); $this->assertGlobalsExists('request', $request, $globals); $this->assertGlobalsExists('themeId', 23, $globals); $this->assertGlobalsExists('theme', $theme2, $globals); $globals = $extension->getGlobals(); $this->assertGlobalsExists('user', $user, $globals); $this->assertGlobalsExists('themeId', 42, $globals); $this->assertGlobalsExists('theme', $theme, $globals); $request->query->set('theme', 1337); $globals = $extension->getGlobals(); $this->assertGlobalsExists('user', [], $globals); $this->assertGlobalsExists('themeId', 1337, $globals); $this->assertGlobalsExists('theme', $theme3, $globals); } }