1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Namespaced tests to align with new laravel default

This commit is contained in:
Dan Brown
2017-02-04 11:58:42 +00:00
parent 076693efc9
commit 33a2999a57
21 changed files with 71 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php namespace Tests;
use BookStack\Notifications\ConfirmEmail;
use Illuminate\Support\Facades\Notification;
@@ -88,7 +88,7 @@ class AuthTest extends BrowserKitTest
->press('Resend Confirmation Email');
// Get confirmation and confirm notification matches
$emailConfirmation = DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first();
$emailConfirmation = \DB::table('email_confirmations')->where('user_id', '=', $dbUser->id)->first();
Notification::assertSentTo($dbUser, ConfirmEmail::class, function($notification, $channels) use ($emailConfirmation) {
return $notification->token === $emailConfirmation->token;
});
@@ -177,7 +177,7 @@ class AuthTest extends BrowserKitTest
->seePageIs('/settings/users');
$userPassword = \BookStack\User::find($user->id)->password;
$this->assertTrue(Hash::check('newpassword', $userPassword));
$this->assertTrue(\Hash::check('newpassword', $userPassword));
}
public function test_user_deletion()
@@ -238,7 +238,6 @@ class AuthTest extends BrowserKitTest
Notification::assertSentTo($user, \BookStack\Notifications\ResetPassword::class);
$n = Notification::sent($user, \BookStack\Notifications\ResetPassword::class);
$reset = DB::table('password_resets')->where('email', '=', 'admin@admin.com')->first();
$this->visit('/password/reset/' . $n->first()->token)
->see('Reset Password')
->submitForm('Reset Password', [

View File

@@ -1,4 +1,4 @@
<?php
<?php namespace Tests;
use BookStack\User;
class LdapTest extends BrowserKitTest
@@ -12,7 +12,7 @@ class LdapTest extends BrowserKitTest
{
parent::setUp();
app('config')->set(['auth.method' => 'ldap', 'services.ldap.base_dn' => 'dc=ldap,dc=local', 'auth.providers.users.driver' => 'ldap']);
$this->mockLdap = Mockery::mock(BookStack\Services\Ldap::class);
$this->mockLdap = \Mockery::mock(\BookStack\Services\Ldap::class);
$this->app['BookStack\Services\Ldap'] = $this->mockLdap;
$this->mockUser = factory(User::class)->make();
}
@@ -22,7 +22,7 @@ class LdapTest extends BrowserKitTest
$this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId);
$this->mockLdap->shouldReceive('setVersion')->once();
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(4)
->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array'))
->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
->andReturn(['count' => 1, 0 => [
'uid' => [$this->mockUser->name],
'cn' => [$this->mockUser->name],
@@ -50,7 +50,7 @@ class LdapTest extends BrowserKitTest
$this->mockLdap->shouldReceive('setVersion')->once();
$ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn');
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array'))
->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
->andReturn(['count' => 1, 0 => [
'cn' => [$this->mockUser->name],
'dn' => $ldapDn,
@@ -73,7 +73,7 @@ class LdapTest extends BrowserKitTest
$this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId);
$this->mockLdap->shouldReceive('setVersion')->once();
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array'))
->with($this->resourceId, config('services.ldap.base_dn'), \Mockery::type('string'), \Mockery::type('array'))
->andReturn(['count' => 1, 0 => [
'uid' => [$this->mockUser->name],
'cn' => [$this->mockUser->name],

View File

@@ -1,4 +1,4 @@
<?php
<?php namespace Tests;
class SocialAuthTest extends BrowserKitTest
{
@@ -11,10 +11,10 @@ class SocialAuthTest extends BrowserKitTest
$this->setSettings(['registration-enabled' => 'true']);
config(['GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
$mockSocialite = Mockery::mock('Laravel\Socialite\Contracts\Factory');
$mockSocialite = \Mockery::mock('Laravel\Socialite\Contracts\Factory');
$this->app['Laravel\Socialite\Contracts\Factory'] = $mockSocialite;
$mockSocialDriver = Mockery::mock('Laravel\Socialite\Contracts\Provider');
$mockSocialUser = Mockery::mock('\Laravel\Socialite\Contracts\User');
$mockSocialDriver = \Mockery::mock('Laravel\Socialite\Contracts\Provider');
$mockSocialUser = \Mockery::mock('\Laravel\Socialite\Contracts\User');
$mockSocialite->shouldReceive('driver')->twice()->with('google')->andReturn($mockSocialDriver);
$mockSocialDriver->shouldReceive('redirect')->once()->andReturn(redirect('/'));
@@ -34,18 +34,16 @@ class SocialAuthTest extends BrowserKitTest
public function test_social_login()
{
$user = factory(\BookStack\User::class)->make();
config([
'GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc',
'GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc',
'APP_URL' => 'http://localhost'
]);
$mockSocialite = Mockery::mock('Laravel\Socialite\Contracts\Factory');
$mockSocialite = \Mockery::mock('Laravel\Socialite\Contracts\Factory');
$this->app['Laravel\Socialite\Contracts\Factory'] = $mockSocialite;
$mockSocialDriver = Mockery::mock('Laravel\Socialite\Contracts\Provider');
$mockSocialUser = Mockery::mock('\Laravel\Socialite\Contracts\User');
$mockSocialDriver = \Mockery::mock('Laravel\Socialite\Contracts\Provider');
$mockSocialUser = \Mockery::mock('\Laravel\Socialite\Contracts\User');
$mockSocialUser->shouldReceive('getId')->twice()->andReturn('logintest123');
@@ -68,7 +66,7 @@ class SocialAuthTest extends BrowserKitTest
->seePageIs('/login');
// Test social callback with matching social account
DB::table('social_accounts')->insert([
\DB::table('social_accounts')->insert([
'user_id' => $this->getAdmin()->id,
'driver' => 'github',
'driver_id' => 'logintest123'