Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tjardoo committed Feb 24, 2024
1 parent c6bba90 commit 7eecee7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
5 changes: 2 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon

parameters:

paths:
- src

# The level 9 is the highest level
level: 8

ignoreErrors:

excludePaths:

checkMissingIterableValueType: false
checkMissingIterableValueType: false
4 changes: 0 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<env name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
Expand Down
30 changes: 27 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Label84\AuthLog\Tests;

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Label84\AuthLog\AuthLogServiceProvider;
use Orchestra\Testbench\Factories\UserFactory;

Expand All @@ -13,7 +15,7 @@ public function setUp(): void
{
parent::setUp();

$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->setUpDatabase();

$this->user = (new UserFactory())->make([
'id' => 1000,
Expand All @@ -30,8 +32,30 @@ protected function getPackageProviders($app): array

protected function getEnvironmentSetUp($app): void
{
include_once __DIR__.'/../database/migrations/create_auth_logs_table.php.stub';
config()->set('authlog.database_connection', 'sqlite');
config()->set('database.default', 'sqlite');
config()->set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
]);
}

protected function setUpDatabase()
{
Schema::create(config('authlog.table_name'), function (Blueprint $table) {
$table->id();

$table->string('event_name');
$table->string('email')->nullable();

$table->unsignedBigInteger('user_id')->nullable();

$table->string('ip_address');
$table->text('user_agent')->nullable();

$table->text('context')->nullable();

(new \CreateAuthLogsTable())->up();
$table->datetime('created_at')->useCurrent();
});
}
}

0 comments on commit 7eecee7

Please sign in to comment.