/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Database/Sqlite/SchemaStateTest.php
94 строки
3 KB
Jack Bayliss
[13.x] Add `without-migration-data` flag to DumpCommand (#60570)
23 июн 2026, 21:46
Не верифицирован
23 июн 2026, 21:46
c0f7532
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Database\Sqlite; use Illuminate\Support\Facades\DB; use Orchestra\Testbench\Attributes\RequiresDatabase; use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use function Orchestra\Testbench\remote; #[RequiresDatabase('sqlite')] class SchemaStateTest extends TestCase { use InteractsWithPublishedFiles; protected $files = [ 'database/schema', ]; protected function setUp(): void { parent::setUp(); remote('migrate:install'); } protected function tearDown(): void { remote('db:wipe')->mustRun(); parent::tearDown(); } #[RequiresOperatingSystem('Linux|Darwin')] public function testSchemaDumpOnSqlite() { if ($this->usesSqliteInMemoryDatabaseConnection()) { $this->markTestSkipped('Test cannot be run using :in-memory: database connection'); } $connection = DB::connection(); $connection->getSchemaBuilder()->createDatabase($connection->getConfig('database')); $connection->statement('CREATE TABLE IF NOT EXISTS migrations (id integer primary key autoincrement not null, migration varchar not null, batch integer not null);'); $connection->statement('CREATE TABLE users (id integer primary key autoincrement not null, email varchar not null, name varchar not null);'); $connection->statement('INSERT INTO users (email, name) VALUES ("taylor@laravel.com", "Taylor Otwell");'); $this->assertTrue($connection->table('sqlite_sequence')->exists()); $this->app['files']->ensureDirectoryExists(database_path('schema')); $connection->getSchemaState()->dump($connection, database_path('schema/sqlite-schema.sql')); $this->assertFileContains([ 'CREATE TABLE migrations', 'CREATE TABLE users', ], 'database/schema/sqlite-schema.sql'); $this->assertFileNotContains([ 'sqlite_sequence', ], 'database/schema/sqlite-schema.sql'); } #[RequiresOperatingSystem('Linux|Darwin')] public function testSchemaDumpWithoutMigrationDataOnSqlite() { if ($this->usesSqliteInMemoryDatabaseConnection()) { $this->markTestSkipped('Test cannot be run using :in-memory: database connection'); } $connection = DB::connection(); $connection->getSchemaBuilder()->createDatabase($connection->getConfig('database')); $connection->statement('CREATE TABLE IF NOT EXISTS migrations (id integer primary key autoincrement not null, migration varchar not null, batch integer not null);'); $connection->statement('CREATE TABLE users (id integer primary key autoincrement not null, email varchar not null, name varchar not null);'); $connection->statement('INSERT INTO migrations (migration, batch) VALUES ("2014_10_12_000000_create_users_table", 1);'); $this->app['files']->ensureDirectoryExists(database_path('schema')); $connection->getSchemaState() ->withMigrationTable(null) ->dump($connection, database_path('schema/sqlite-schema.sql')); $this->assertFileContains([ 'CREATE TABLE migrations', 'CREATE TABLE users', ], 'database/schema/sqlite-schema.sql'); $this->assertFileNotContains([ 'INSERT INTO "migrations"', ], 'database/schema/sqlite-schema.sql'); } }