public function testAddingString() { $blueprint = new Blueprint('users'); $blueprint->string('foo'); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table "users" add "foo" nvarchar(255) not null', $statements[0]); $blueprint = new Blueprint('users'); $blueprint->string('foo', 100); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table "users" add "foo" nvarchar(100) not null', $statements[0]); $blueprint = new Blueprint('users'); $blueprint->string('foo', 100)->nullable()->default('bar'); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table "users" add "foo" nvarchar(100) null default \'bar\'', $statements[0]); }
public function testAddingString() { $blueprint = new Blueprint('users'); $blueprint->string('foo'); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table `users` add `foo` varchar(255) not null', $statements[0]); $blueprint = new Blueprint('users'); $blueprint->string('foo', 100); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table `users` add `foo` varchar(100) not null', $statements[0]); $blueprint = new Blueprint('users'); $blueprint->string('foo', 100)->nullable()->default('bar'); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table `users` add `foo` varchar(100) null default \'bar\'', $statements[0]); $blueprint = new Blueprint('users'); $blueprint->string('foo', 100)->nullable()->default(new Robbo\SchemaBuilder\Expression('CURRENT TIMESTAMP')); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertEquals(1, count($statements)); $this->assertEquals('alter table `users` add `foo` varchar(100) null default CURRENT TIMESTAMP', $statements[0]); }