Skip to content

Commit

Permalink
Make tests use bigincrements as default
Browse files Browse the repository at this point in the history
Add test for 'integerIncrements'
  • Loading branch information
victorlap committed Nov 9, 2018
1 parent a406533 commit fd6002f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
28 changes: 19 additions & 9 deletions tests/Database/DatabaseMySqlSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate 'utf8_unicode_ci'", $statements[0]);
$this->assertEquals("create table `users` (`id` bigint unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate 'utf8_unicode_ci'", $statements[0]);

$blueprint = new Blueprint('users');
$blueprint->increments('id');
Expand All @@ -43,7 +43,7 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `id` int unsigned not null auto_increment primary key, add `email` varchar(255) not null', $statements[0]);
$this->assertEquals('alter table `users` add `id` bigint unsigned not null auto_increment primary key, add `email` varchar(255) not null', $statements[0]);
}

public function testEngineCreateTable()
Expand All @@ -61,7 +61,7 @@ public function testEngineCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate 'utf8_unicode_ci' engine = InnoDB", $statements[0]);
$this->assertEquals("create table `users` (`id` bigint unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate 'utf8_unicode_ci' engine = InnoDB", $statements[0]);

$blueprint = new Blueprint('users');
$blueprint->create();
Expand All @@ -76,7 +76,7 @@ public function testEngineCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate 'utf8_unicode_ci' engine = InnoDB", $statements[0]);
$this->assertEquals("create table `users` (`id` bigint unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8 collate 'utf8_unicode_ci' engine = InnoDB", $statements[0]);
}

public function testCharsetCollationCreateTable()
Expand All @@ -94,7 +94,7 @@ public function testCharsetCollationCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'", $statements[0]);
$this->assertEquals("create table `users` (`id` bigint unsigned not null auto_increment primary key, `email` varchar(255) not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'", $statements[0]);

$blueprint = new Blueprint('users');
$blueprint->create();
Expand All @@ -109,7 +109,7 @@ public function testCharsetCollationCreateTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals("create table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) character set utf8mb4 collate 'utf8mb4_unicode_ci' not null) default character set utf8 collate 'utf8_unicode_ci'", $statements[0]);
$this->assertEquals("create table `users` (`id` bigint unsigned not null auto_increment primary key, `email` varchar(255) character set utf8mb4 collate 'utf8mb4_unicode_ci' not null) default character set utf8 collate 'utf8_unicode_ci'", $statements[0]);
}

public function testBasicCreateTableWithPrefix()
Expand All @@ -127,7 +127,7 @@ public function testBasicCreateTableWithPrefix()
$statements = $blueprint->toSql($conn, $grammar);

$this->assertCount(1, $statements);
$this->assertEquals('create table `prefix_users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null)', $statements[0]);
$this->assertEquals('create table `prefix_users` (`id` bigint unsigned not null auto_increment primary key, `email` varchar(255) not null)', $statements[0]);
}

public function testCreateTemporaryTable()
Expand All @@ -144,7 +144,7 @@ public function testCreateTemporaryTable()
$statements = $blueprint->toSql($conn, $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('create temporary table `users` (`id` int unsigned not null auto_increment primary key, `email` varchar(255) not null)', $statements[0]);
$this->assertEquals('create temporary table `users` (`id` bigint unsigned not null auto_increment primary key, `email` varchar(255) not null)', $statements[0]);
}

public function testDropTable()
Expand Down Expand Up @@ -379,7 +379,7 @@ public function testAddingIncrementingID()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `id` int unsigned not null auto_increment primary key', $statements[0]);
$this->assertEquals('alter table `users` add `id` bigint unsigned not null auto_increment primary key', $statements[0]);
}

public function testAddingSmallIncrementingID()
Expand All @@ -392,6 +392,16 @@ public function testAddingSmallIncrementingID()
$this->assertEquals('alter table `users` add `id` smallint unsigned not null auto_increment primary key', $statements[0]);
}

public function testAddingIntegerIncrementingID()
{
$blueprint = new Blueprint('users');
$blueprint->integerIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table `users` add `id` int unsigned not null auto_increment primary key', $statements[0]);
}

public function testAddingBigIncrementingID()
{
$blueprint = new Blueprint('users');
Expand Down
26 changes: 18 additions & 8 deletions tests/Database/DatabasePostgresSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('create table "users" ("id" serial primary key not null, "email" varchar(255) not null)', $statements[0]);
$this->assertEquals('create table "users" ("id" bigserial primary key not null, "email" varchar(255) not null)', $statements[0]);

$blueprint = new Blueprint('users');
$blueprint->increments('id');
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" serial primary key not null, add column "email" varchar(255) not null', $statements[0]);
$this->assertEquals('alter table "users" add column "id" bigserial primary key not null, add column "email" varchar(255) not null', $statements[0]);
}

public function testCreateTableAndCommentColumn()
Expand All @@ -44,7 +44,7 @@ public function testCreateTableAndCommentColumn()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(2, $statements);
$this->assertEquals('create table "users" ("id" serial primary key not null, "email" varchar(255) not null)', $statements[0]);
$this->assertEquals('create table "users" ("id" bigserial primary key not null, "email" varchar(255) not null)', $statements[0]);
$this->assertEquals('comment on column "users"."email" is \'my first comment\'', $statements[1]);
}

Expand All @@ -58,7 +58,7 @@ public function testCreateTemporaryTable()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('create temporary table "users" ("id" serial primary key not null, "email" varchar(255) not null)', $statements[0]);
$this->assertEquals('create temporary table "users" ("id" bigserial primary key not null, "email" varchar(255) not null)', $statements[0]);
}

public function testDropTable()
Expand Down Expand Up @@ -273,7 +273,7 @@ public function testAddingIncrementingID()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" serial primary key not null', $statements[0]);
$this->assertEquals('alter table "users" add column "id" bigserial primary key not null', $statements[0]);
}

public function testAddingSmallIncrementingID()
Expand All @@ -296,6 +296,16 @@ public function testAddingMediumIncrementingID()
$this->assertEquals('alter table "users" add column "id" serial primary key not null', $statements[0]);
}

public function testAddingIntegerIncrementingID()
{
$blueprint = new Blueprint('users');
$blueprint->integerIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "id" serial primary key not null', $statements[0]);
}

public function testAddingBigIncrementingID()
{
$blueprint = new Blueprint('users');
Expand Down Expand Up @@ -666,19 +676,19 @@ public function testAddingGeneratedAs()
$blueprint->increments('foo')->generatedAs();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer generated by default as identity primary key not null', $statements[0]);
$this->assertEquals('alter table "users" add column "foo" bigint generated by default as identity primary key not null', $statements[0]);
// With always modifier
$blueprint = new Blueprint('users');
$blueprint->increments('foo')->generatedAs()->always();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer generated always as identity primary key not null', $statements[0]);
$this->assertEquals('alter table "users" add column "foo" bigint generated always as identity primary key not null', $statements[0]);
// With sequence options
$blueprint = new Blueprint('users');
$blueprint->increments('foo')->generatedAs('increment by 10 start with 100');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add column "foo" integer generated by default as identity (increment by 10 start with 100) primary key not null', $statements[0]);
$this->assertEquals('alter table "users" add column "foo" bigint generated by default as identity (increment by 10 start with 100) primary key not null', $statements[0]);
// Not a primary key
$blueprint = new Blueprint('users');
$blueprint->integer('foo')->generatedAs();
Expand Down
20 changes: 15 additions & 5 deletions tests/Database/DatabaseSqlServerSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('create table "users" ("id" int identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);
$this->assertEquals('create table "users" ("id" bigint identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);

$blueprint = new Blueprint('users');
$blueprint->increments('id');
$blueprint->string('email');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" int identity primary key not null, "email" nvarchar(255) not null', $statements[0]);
$this->assertEquals('alter table "users" add "id" bigint identity primary key not null, "email" nvarchar(255) not null', $statements[0]);

$blueprint = new Blueprint('users');
$blueprint->create();
Expand All @@ -41,7 +41,7 @@ public function testBasicCreateTable()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()->setTablePrefix('prefix_'));

$this->assertCount(1, $statements);
$this->assertEquals('create table "prefix_users" ("id" int identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);
$this->assertEquals('create table "prefix_users" ("id" bigint identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);
}

public function testCreateTemporaryTable()
Expand All @@ -54,7 +54,7 @@ public function testCreateTemporaryTable()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('create table "#users" ("id" int identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);
$this->assertEquals('create table "#users" ("id" bigint identity primary key not null, "email" nvarchar(255) not null)', $statements[0]);
}

public function testDropTable()
Expand Down Expand Up @@ -273,7 +273,7 @@ public function testAddingIncrementingID()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" int identity primary key not null', $statements[0]);
$this->assertEquals('alter table "users" add "id" bigint identity primary key not null', $statements[0]);
}

public function testAddingSmallIncrementingID()
Expand All @@ -296,6 +296,16 @@ public function testAddingMediumIncrementingID()
$this->assertEquals('alter table "users" add "id" int identity primary key not null', $statements[0]);
}

public function testAddingIntegerIncrementingID()
{
$blueprint = new Blueprint('users');
$blueprint->integerIncrements('id');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertEquals('alter table "users" add "id" int identity primary key not null', $statements[0]);
}

public function testAddingBigIncrementingID()
{
$blueprint = new Blueprint('users');
Expand Down

0 comments on commit fd6002f

Please sign in to comment.