mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Laravel 5.3 upgrade (#189)
* Started move to laravel 5.3 * Started updating login & registration flows for laravel 5.3 update * Updated app emails to notification system * Fixed registations bugs and removed email confirmation model * Fixed large portion of laravel post-upgrade issues * Fixed and tested LDAP process
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use BookStack\EmailConfirmation;
|
||||
use BookStack\Notifications\ConfirmEmail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class AuthTest extends TestCase
|
||||
{
|
||||
@@ -57,15 +58,13 @@ class AuthTest extends TestCase
|
||||
|
||||
public function test_confirmed_registration()
|
||||
{
|
||||
// Fake notifications
|
||||
Notification::fake();
|
||||
|
||||
// Set settings and get user instance
|
||||
$this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true']);
|
||||
$user = factory(\BookStack\User::class)->make();
|
||||
|
||||
// Mock Mailer to ensure mail is being sent
|
||||
$mockMailer = Mockery::mock('Illuminate\Contracts\Mail\Mailer');
|
||||
$mockMailer->shouldReceive('send')->with('emails/email-confirmation', Mockery::type('array'), Mockery::type('callable'))->twice();
|
||||
$this->app->instance('mailer', $mockMailer);
|
||||
|
||||
// Go through registration process
|
||||
$this->visit('/register')
|
||||
->see('Sign Up')
|
||||
@@ -76,6 +75,10 @@ class AuthTest extends TestCase
|
||||
->seePageIs('/register/confirm')
|
||||
->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => false]);
|
||||
|
||||
// Ensure notification sent
|
||||
$dbUser = \BookStack\User::where('email', '=', $user->email)->first();
|
||||
Notification::assertSentTo($dbUser, ConfirmEmail::class);
|
||||
|
||||
// Test access and resend confirmation email
|
||||
$this->login($user->email, $user->password)
|
||||
->seePageIs('/register/confirm/awaiting')
|
||||
@@ -84,19 +87,18 @@ class AuthTest extends TestCase
|
||||
->seePageIs('/register/confirm/awaiting')
|
||||
->press('Resend Confirmation Email');
|
||||
|
||||
// Get confirmation
|
||||
$user = $user->where('email', '=', $user->email)->first();
|
||||
$emailConfirmation = EmailConfirmation::where('user_id', '=', $user->id)->first();
|
||||
|
||||
|
||||
// Check confirmation email button and confirmation activation.
|
||||
$this->visit('/register/confirm/' . $emailConfirmation->token . '/email')
|
||||
->see('Email Confirmation')
|
||||
->click('Confirm Email')
|
||||
// Get confirmation and confirm notification matches
|
||||
$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;
|
||||
});
|
||||
|
||||
// Check confirmation email confirmation activation.
|
||||
$this->visit('/register/confirm/' . $emailConfirmation->token)
|
||||
->seePageIs('/')
|
||||
->see($user->name)
|
||||
->notSeeInDatabase('email_confirmations', ['token' => $emailConfirmation->token])
|
||||
->seeInDatabase('users', ['name' => $user->name, 'email' => $user->email, 'email_confirmed' => true]);
|
||||
->seeInDatabase('users', ['name' => $dbUser->name, 'email' => $dbUser->email, 'email_confirmed' => true]);
|
||||
}
|
||||
|
||||
public function test_restricted_registration()
|
||||
|
@@ -236,8 +236,9 @@ class EntityTest extends TestCase
|
||||
->type('super test page', '#name')
|
||||
->press('Save Page')
|
||||
// Check redirect
|
||||
->seePageIs($newPageUrl)
|
||||
->visit($pageUrl)
|
||||
->seePageIs($newPageUrl);
|
||||
|
||||
$this->visit($pageUrl)
|
||||
->seePageIs($newPageUrl);
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,7 @@ class PageDraftTest extends TestCase
|
||||
->visit($chapter->getUrl() . '/create-page')
|
||||
->visit($book->getUrl())
|
||||
->seeInElement('.page-list', 'New Page');
|
||||
|
||||
|
||||
$this->asAdmin()
|
||||
->visit($book->getUrl())
|
||||
->dontSeeInElement('.page-list', 'New Page')
|
||||
|
@@ -59,8 +59,10 @@ class ImageTest extends TestCase
|
||||
|
||||
$this->assertTrue(file_exists(public_path($relPath)), 'Uploaded image exists');
|
||||
|
||||
$this->deleteImage($relPath);
|
||||
|
||||
$this->seeInDatabase('images', [
|
||||
'url' => $relPath,
|
||||
'url' => $this->baseUrl . $relPath,
|
||||
'type' => 'gallery',
|
||||
'uploaded_to' => $page->id,
|
||||
'path' => $relPath,
|
||||
@@ -69,7 +71,7 @@ class ImageTest extends TestCase
|
||||
'name' => $imageName
|
||||
]);
|
||||
|
||||
$this->deleteImage($relPath);
|
||||
|
||||
}
|
||||
|
||||
public function test_image_delete()
|
||||
@@ -85,7 +87,7 @@ class ImageTest extends TestCase
|
||||
$this->assertResponseOk();
|
||||
|
||||
$this->dontSeeInDatabase('images', [
|
||||
'url' => $relPath,
|
||||
'url' => $this->baseUrl . $relPath,
|
||||
'type' => 'gallery'
|
||||
]);
|
||||
|
||||
|
Reference in New Issue
Block a user