Skip to content

Commit

Permalink
add SqliteSchemaState test
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Dec 21, 2022
1 parent f2c51fd commit 561f629
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/Database/DatabaseSqliteSchemaStateTest.php
@@ -0,0 +1,39 @@
<?php

namespace Illuminate\Tests\Database;

use Illuminate\Database\Schema\SqliteSchemaState;
use Illuminate\Database\SQLiteConnection;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;

class DatabaseSqliteSchemaStateTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();
m::close();
}

public function testLoadSchemaToDatabase(): void
{
$config = ['driver' => 'sqlite', 'database' => 'database/database.sqlite', 'prefix' => '', 'foreign_key_constraints' => true, 'name' => 'sqlite'];
$connection = m::mock(SQLiteConnection::class);
$connection->shouldReceive('getConfig')->andReturn($config);

$process = m::spy(Process::class);
$processFactory = function () use ($process) {
return $process;
};

$schemaState = new SqliteSchemaState($connection, null, $processFactory);
$schemaState->load('database/schema/sqlite-schema.dump');

$process->shouldHaveReceived('mustRun')->with(null, [
'LARAVEL_LOAD_DATABASE' => 'database/database.sqlite',
'LARAVEL_LOAD_PATH' => 'database/schema/sqlite-schema.dump',
]);
}

}

0 comments on commit 561f629

Please sign in to comment.