Skip to content

Commit 9cb3a01

Browse files
committed
Fix tests
1 parent 562fde4 commit 9cb3a01

File tree

3 files changed

+19
-43
lines changed

3 files changed

+19
-43
lines changed

tests/Feature/DatabaseTestCase.php

+11-17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Auth\EloquentUserProvider;
66
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Foundation\Testing\RefreshDatabase;
78
use Illuminate\Support\Facades\Schema;
89
use LdapRecord\Laravel\Auth\DatabaseUserProvider;
910
use LdapRecord\Laravel\Import\UserSynchronizer;
@@ -13,33 +14,26 @@
1314
use LdapRecord\Models\ActiveDirectory\User;
1415
use LdapRecord\Models\Model;
1516
use Mockery as m;
17+
use Orchestra\Testbench\Attributes\WithMigration;
1618

19+
#[WithMigration]
1720
class DatabaseTestCase extends TestCase
1821
{
22+
use RefreshDatabase;
23+
1924
protected function setUp(): void
2025
{
2126
parent::setUp();
2227

23-
$this->createUsersTable();
28+
Schema::table('users', function (Blueprint $table) {
29+
$table->softDeletes();
30+
});
2431
}
2532

26-
protected function createUsersTable()
33+
protected function defineDatabaseMigrations()
2734
{
28-
// Setup the users database table.
29-
Schema::create('users', function (Blueprint $table) {
30-
$table->bigIncrements('id');
31-
$table->string('name');
32-
$table->string('email')->unique();
33-
$table->timestamp('email_verified_at')->nullable();
34-
$table->string('password');
35-
$table->rememberToken();
36-
$table->timestamps();
37-
$table->softDeletes();
38-
39-
// Additional fields for LdapRecord.
40-
$table->string('guid')->unique()->nullable();
41-
$table->string('domain')->nullable();
42-
});
35+
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
36+
$this->loadMigrationsFrom(__DIR__.'/../../vendor/laravel/sanctum/database/migrations');
4337
}
4438

4539
protected function getMockLdapModel(array $attributes = [])

tests/Feature/SanctumTest.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace LdapRecord\Laravel\Tests\Feature;
44

5-
use Illuminate\Foundation\Testing\DatabaseMigrations;
65
use Illuminate\Http\Request;
76
use Illuminate\Support\Facades\Auth;
87
use Illuminate\Support\Facades\Route;
@@ -14,7 +13,6 @@
1413
class SanctumTest extends DatabaseTestCase
1514
{
1615
use CreatesTestUsers;
17-
use DatabaseMigrations;
1816

1917
protected function setUp(): void
2018
{
@@ -36,10 +34,16 @@ protected function setUp(): void
3634

3735
Route::post('api/sanctum/token', function (Request $request) {
3836
if (Auth::validate($request->only('mail', 'password'))) {
39-
return ['token' => Auth::getLastAttempted()->createToken($request->device_name)->plainTextToken];
37+
return [
38+
'token' => Auth::getLastAttempted()
39+
->createToken($request->device_name)
40+
->plainTextToken,
41+
];
4042
}
4143

42-
throw ValidationException::withMessages(['email' => 'The provided credentials are incorrect.']);
44+
throw ValidationException::withMessages([
45+
'email' => 'The provided credentials are incorrect.',
46+
]);
4347
});
4448
}
4549

tests/Unit/LdapAuthServiceProviderTest.php

-22
This file was deleted.

0 commit comments

Comments
 (0)