123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace Illuminate\Tests\Integration\Database;
- use Doctrine\DBAL\Types\Type;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Database\Schema\Grammars\SQLiteGrammar;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Tests\Integration\Database\Fixtures\TinyInteger;
- class SchemaBuilderTest extends DatabaseTestCase
- {
- protected function destroyDatabaseMigrations()
- {
- Schema::dropAllViews();
- }
- public function testDropAllTables()
- {
- $this->expectNotToPerformAssertions();
- Schema::create('table', function (Blueprint $table) {
- $table->increments('id');
- });
- Schema::dropAllTables();
- $this->artisan('migrate:install');
- Schema::create('table', function (Blueprint $table) {
- $table->increments('id');
- });
- }
- public function testDropAllViews()
- {
- $this->expectNotToPerformAssertions();
- DB::statement('create view foo (id) as select 1');
- Schema::dropAllViews();
- DB::statement('create view foo (id) as select 1');
- }
- public function testRegisterCustomDoctrineType()
- {
- if ($this->driver !== 'sqlite') {
- $this->markTestSkipped('Test requires a SQLite connection.');
- }
- Schema::registerCustomDoctrineType(TinyInteger::class, TinyInteger::NAME, 'TINYINT');
- Schema::create('test', function (Blueprint $table) {
- $table->string('test_column');
- });
- $blueprint = new Blueprint('test', function (Blueprint $table) {
- $table->tinyInteger('test_column')->change();
- });
- $blueprint->build($this->getConnection(), new SQLiteGrammar);
- $this->assertArrayHasKey(TinyInteger::NAME, Type::getTypesMap());
- $this->assertSame('tinyinteger', Schema::getColumnType('test', 'test_column'));
- }
- public function testRegisterCustomDoctrineTypeASecondTime()
- {
- if ($this->driver !== 'sqlite') {
- $this->markTestSkipped('Test requires a SQLite connection.');
- }
- Schema::registerCustomDoctrineType(TinyInteger::class, TinyInteger::NAME, 'TINYINT');
- Schema::create('test', function (Blueprint $table) {
- $table->string('test_column');
- });
- $blueprint = new Blueprint('test', function (Blueprint $table) {
- $table->tinyInteger('test_column')->change();
- });
- $blueprint->build($this->getConnection(), new SQLiteGrammar);
- $this->assertArrayHasKey(TinyInteger::NAME, Type::getTypesMap());
- $this->assertSame('tinyinteger', Schema::getColumnType('test', 'test_column'));
- }
- }
|