mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Added login/register theme events
This commit is contained in:
@ -17,8 +17,7 @@ class SocialAuthTest extends TestCase
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
config(['GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
|
||||
|
||||
$mockSocialite = Mockery::mock(Factory::class);
|
||||
$this->app[Factory::class] = $mockSocialite;
|
||||
$mockSocialite = $this->mock(Factory::class);
|
||||
$mockSocialDriver = Mockery::mock(Provider::class);
|
||||
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
|
||||
|
||||
@ -46,8 +45,7 @@ class SocialAuthTest extends TestCase
|
||||
'APP_URL' => 'http://localhost'
|
||||
]);
|
||||
|
||||
$mockSocialite = Mockery::mock(Factory::class);
|
||||
$this->app[Factory::class] = $mockSocialite;
|
||||
$mockSocialite = $this->mock(Factory::class);
|
||||
$mockSocialDriver = Mockery::mock(Provider::class);
|
||||
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
|
||||
|
||||
@ -93,8 +91,7 @@ class SocialAuthTest extends TestCase
|
||||
]);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$mockSocialite = Mockery::mock(Factory::class);
|
||||
$this->app[Factory::class] = $mockSocialite;
|
||||
$mockSocialite = $this->mock(Factory::class);
|
||||
$mockSocialDriver = Mockery::mock(Provider::class);
|
||||
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
|
||||
|
||||
@ -132,8 +129,7 @@ class SocialAuthTest extends TestCase
|
||||
]);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$mockSocialite = Mockery::mock(Factory::class);
|
||||
$this->app[Factory::class] = $mockSocialite;
|
||||
$mockSocialite = $this->mock(Factory::class);
|
||||
$mockSocialDriver = Mockery::mock(Provider::class);
|
||||
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
|
||||
|
||||
@ -169,8 +165,7 @@ class SocialAuthTest extends TestCase
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
config(['GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
|
||||
|
||||
$mockSocialite = Mockery::mock(Factory::class);
|
||||
$this->app[Factory::class] = $mockSocialite;
|
||||
$mockSocialite = $this->mock(Factory::class);
|
||||
$mockSocialDriver = Mockery::mock(Provider::class);
|
||||
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
|
||||
|
||||
|
@ -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