Skip to content

Commit

Permalink
Add tests for switching the default increments() method
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlap committed Nov 9, 2018
1 parent fd6002f commit 22e1f7c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Database/DatabaseMySqlSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Builder;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Grammars\MySqlGrammar;
Expand Down Expand Up @@ -380,6 +381,16 @@ public function testAddingIncrementingID()

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

Builder::useIntegerIncrements();
$blueprint = new Blueprint('users');
$blueprint->increments('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]);

Builder::$defaultIncrementsType = 'unsignedBigInteger';
}

public function testAddingSmallIncrementingID()
Expand Down
11 changes: 11 additions & 0 deletions tests/Database/DatabasePostgresSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Builder;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Grammars\PostgresGrammar;

Expand Down Expand Up @@ -274,6 +275,16 @@ public function testAddingIncrementingID()

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

Builder::useIntegerIncrements();
$blueprint = new Blueprint('users');
$blueprint->increments('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]);

Builder::$defaultIncrementsType = 'unsignedBigInteger';
}

public function testAddingSmallIncrementingID()
Expand Down
11 changes: 11 additions & 0 deletions tests/Database/DatabaseSqlServerSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Builder;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Grammars\SqlServerGrammar;

Expand Down Expand Up @@ -274,6 +275,16 @@ public function testAddingIncrementingID()

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

Builder::useIntegerIncrements();
$blueprint = new Blueprint('users');
$blueprint->increments('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]);

Builder::$defaultIncrementsType = 'unsignedBigInteger';
}

public function testAddingSmallIncrementingID()
Expand Down

0 comments on commit 22e1f7c

Please sign in to comment.