|
4 | 4 |
|
5 | 5 | use Illuminate\Database\Connection; |
6 | 6 | use Illuminate\Database\Schema\Blueprint; |
| 7 | +use Illuminate\Database\Schema\Builder; |
7 | 8 | use Illuminate\Database\Schema\ForeignIdColumnDefinition; |
8 | 9 | use Illuminate\Database\Schema\Grammars\PostgresGrammar; |
9 | 10 | use Mockery as m; |
@@ -434,6 +435,52 @@ public function testAddingString() |
434 | 435 | $this->assertSame('alter table "users" add column "foo" varchar(100) null default \'bar\'', $statements[0]); |
435 | 436 | } |
436 | 437 |
|
| 438 | + public function testAddingStringWithoutLengthLimit() |
| 439 | + { |
| 440 | + $blueprint = new Blueprint('users'); |
| 441 | + $blueprint->string('foo'); |
| 442 | + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); |
| 443 | + |
| 444 | + $this->assertCount(1, $statements); |
| 445 | + $this->assertSame('alter table "users" add column "foo" varchar(255) not null', $statements[0]); |
| 446 | + |
| 447 | + Builder::$defaultStringLength = null; |
| 448 | + |
| 449 | + $blueprint = new Blueprint('users'); |
| 450 | + $blueprint->string('foo'); |
| 451 | + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); |
| 452 | + |
| 453 | + try { |
| 454 | + $this->assertCount(1, $statements); |
| 455 | + $this->assertSame('alter table "users" add column "foo" varchar not null', $statements[0]); |
| 456 | + } finally { |
| 457 | + Builder::$defaultStringLength = 255; |
| 458 | + } |
| 459 | + } |
| 460 | + |
| 461 | + public function testAddingCharWithoutLengthLimit() |
| 462 | + { |
| 463 | + $blueprint = new Blueprint('users'); |
| 464 | + $blueprint->char('foo'); |
| 465 | + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); |
| 466 | + |
| 467 | + $this->assertCount(1, $statements); |
| 468 | + $this->assertSame('alter table "users" add column "foo" char(255) not null', $statements[0]); |
| 469 | + |
| 470 | + Builder::$defaultStringLength = null; |
| 471 | + |
| 472 | + $blueprint = new Blueprint('users'); |
| 473 | + $blueprint->char('foo'); |
| 474 | + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); |
| 475 | + |
| 476 | + try { |
| 477 | + $this->assertCount(1, $statements); |
| 478 | + $this->assertSame('alter table "users" add column "foo" char not null', $statements[0]); |
| 479 | + } finally { |
| 480 | + Builder::$defaultStringLength = 255; |
| 481 | + } |
| 482 | + } |
| 483 | + |
437 | 484 | public function testAddingText() |
438 | 485 | { |
439 | 486 | $blueprint = new Blueprint('users'); |
|
0 commit comments