mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Added login/register theme events
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Auth\Access\SocialAuthService;
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Entities\Tools\PageContent;
|
||||
use BookStack\Facades\Theme;
|
||||
@ -122,6 +124,38 @@ class ThemeTest extends TestCase
|
||||
$resp->assertStatus(443);
|
||||
}
|
||||
|
||||
public function test_event_auth_login_standard()
|
||||
{
|
||||
$args = [];
|
||||
$callback = function (...$eventArgs) use (&$args) {
|
||||
$args = $eventArgs;
|
||||
};
|
||||
|
||||
Theme::listen(ThemeEvents::AUTH_LOGIN, $callback);
|
||||
$this->post('/login', ['email' => 'admin@admin.com', 'password' => 'password']);
|
||||
|
||||
$this->assertCount(2, $args);
|
||||
$this->assertEquals('standard', $args[0]);
|
||||
$this->assertInstanceOf(User::class, $args[1]);
|
||||
}
|
||||
|
||||
public function test_event_auth_register_standard()
|
||||
{
|
||||
$args = [];
|
||||
$callback = function (...$eventArgs) use (&$args) {
|
||||
$args = $eventArgs;
|
||||
};
|
||||
Theme::listen(ThemeEvents::AUTH_REGISTER, $callback);
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$this->post('/register', ['email' => $user->email, 'name' => $user->name, 'password' => 'password']);
|
||||
|
||||
$this->assertCount(2, $args);
|
||||
$this->assertEquals('standard', $args[0]);
|
||||
$this->assertInstanceOf(User::class, $args[1]);
|
||||
}
|
||||
|
||||
public function test_add_social_driver()
|
||||
{
|
||||
Theme::addSocialDriver('catnet', [
|
||||
|
Reference in New Issue
Block a user