|
|
@ -29,16 +29,18 @@ class GlobalsTest extends ExtensionTest
|
|
|
|
$theme = ['name' => 'Testtheme', 'navbar_classes' => 'something'];
|
|
|
|
$theme = ['name' => 'Testtheme', 'navbar_classes' => 'something'];
|
|
|
|
$theme2 = ['name' => 'Bar'];
|
|
|
|
$theme2 = ['name' => 'Bar'];
|
|
|
|
$theme3 = ['name' => 'Lorem'];
|
|
|
|
$theme3 = ['name' => 'Lorem'];
|
|
|
|
|
|
|
|
/** @var User $user */
|
|
|
|
$user = User::factory()
|
|
|
|
$user = User::factory()
|
|
|
|
->has(Settings::factory(['theme' => 42]))
|
|
|
|
->has(Settings::factory(['theme' => 42]))
|
|
|
|
->create();
|
|
|
|
->create();
|
|
|
|
$config = new Config(['theme' => 23, 'themes' => [42 => $theme, 23 => $theme2, 1337 => $theme3]]);
|
|
|
|
$config = new Config(['theme' => 23, 'themes' => [42 => $theme, 23 => $theme2, 1337 => $theme3]]);
|
|
|
|
|
|
|
|
|
|
|
|
$auth->expects($this->exactly(3))
|
|
|
|
$auth->expects($this->exactly(4))
|
|
|
|
->method('user')
|
|
|
|
->method('user')
|
|
|
|
->willReturnOnConsecutiveCalls(
|
|
|
|
->willReturnOnConsecutiveCalls(
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
$user,
|
|
|
|
$user,
|
|
|
|
|
|
|
|
$user,
|
|
|
|
null
|
|
|
|
null
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -46,17 +48,25 @@ class GlobalsTest extends ExtensionTest
|
|
|
|
|
|
|
|
|
|
|
|
$extension = new Globals($auth, $request);
|
|
|
|
$extension = new Globals($auth, $request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// No user
|
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
$this->assertGlobalsExists('user', [], $globals);
|
|
|
|
$this->assertGlobalsExists('user', [], $globals);
|
|
|
|
$this->assertGlobalsExists('request', $request, $globals);
|
|
|
|
$this->assertGlobalsExists('request', $request, $globals);
|
|
|
|
$this->assertGlobalsExists('themeId', 23, $globals);
|
|
|
|
$this->assertGlobalsExists('themeId', 23, $globals);
|
|
|
|
$this->assertGlobalsExists('theme', $theme2, $globals);
|
|
|
|
$this->assertGlobalsExists('theme', $theme2, $globals);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// User
|
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
$this->assertGlobalsExists('user', $user, $globals);
|
|
|
|
$this->assertGlobalsExists('user', $user, $globals);
|
|
|
|
$this->assertGlobalsExists('themeId', 42, $globals);
|
|
|
|
$this->assertGlobalsExists('themeId', 42, $globals);
|
|
|
|
$this->assertGlobalsExists('theme', $theme, $globals);
|
|
|
|
$this->assertGlobalsExists('theme', $theme, $globals);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// User with not available theme configured
|
|
|
|
|
|
|
|
$user->settings->theme = 9999;
|
|
|
|
|
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
|
|
|
|
$this->assertGlobalsExists('themeId', 42, $globals);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Request query parameter
|
|
|
|
$request->query->set('theme', 1337);
|
|
|
|
$request->query->set('theme', 1337);
|
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
$globals = $extension->getGlobals();
|
|
|
|
$this->assertGlobalsExists('user', [], $globals);
|
|
|
|
$this->assertGlobalsExists('user', [], $globals);
|
|
|
|