diff --git a/src/Illuminate/Database/Schema/Blueprint.php b/src/Illuminate/Database/Schema/Blueprint.php index 36dfbb7597b6..f8c273fbcbc6 100755 --- a/src/Illuminate/Database/Schema/Blueprint.php +++ b/src/Illuminate/Database/Schema/Blueprint.php @@ -1201,7 +1201,7 @@ public function foreignUuid($column) * @param string $column * @return \Illuminate\Database\Schema\ColumnDefinition */ - public function ipAddress($column) + public function ipAddress($column = 'ip_address') { return $this->addColumn('ipAddress', $column); } @@ -1212,7 +1212,7 @@ public function ipAddress($column) * @param string $column * @return \Illuminate\Database\Schema\ColumnDefinition */ - public function macAddress($column) + public function macAddress($column = 'mac_address') { return $this->addColumn('macAddress', $column); } diff --git a/tests/Database/DatabaseMySqlSchemaGrammarTest.php b/tests/Database/DatabaseMySqlSchemaGrammarTest.php index c89af64847ad..3e81cdca0950 100755 --- a/tests/Database/DatabaseMySqlSchemaGrammarTest.php +++ b/tests/Database/DatabaseMySqlSchemaGrammarTest.php @@ -1009,6 +1009,16 @@ public function testAddingIpAddress() $this->assertSame('alter table `users` add `foo` varchar(45) not null', $statements[0]); } + public function testAddingIpAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->ipAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table `users` add `ip_address` varchar(45) not null', $statements[0]); + } + public function testAddingMacAddress() { $blueprint = new Blueprint('users'); @@ -1019,6 +1029,16 @@ public function testAddingMacAddress() $this->assertSame('alter table `users` add `foo` varchar(17) not null', $statements[0]); } + public function testAddingMacAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->macAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table `users` add `mac_address` varchar(17) not null', $statements[0]); + } + public function testAddingGeometry() { $blueprint = new Blueprint('geo'); diff --git a/tests/Database/DatabasePostgresSchemaGrammarTest.php b/tests/Database/DatabasePostgresSchemaGrammarTest.php index 052197fd08c4..ce8514e4901f 100755 --- a/tests/Database/DatabasePostgresSchemaGrammarTest.php +++ b/tests/Database/DatabasePostgresSchemaGrammarTest.php @@ -856,6 +856,16 @@ public function testAddingIpAddress() $this->assertSame('alter table "users" add column "foo" inet not null', $statements[0]); } + public function testAddingIpAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->ipAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table "users" add column "ip_address" inet not null', $statements[0]); + } + public function testAddingMacAddress() { $blueprint = new Blueprint('users'); @@ -866,6 +876,16 @@ public function testAddingMacAddress() $this->assertSame('alter table "users" add column "foo" macaddr not null', $statements[0]); } + public function testAddingMacAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->macAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table "users" add column "mac_address" macaddr not null', $statements[0]); + } + public function testCompileForeign() { $blueprint = new Blueprint('users'); diff --git a/tests/Database/DatabaseSQLiteSchemaGrammarTest.php b/tests/Database/DatabaseSQLiteSchemaGrammarTest.php index 41e53cc725e7..442d0f137d58 100755 --- a/tests/Database/DatabaseSQLiteSchemaGrammarTest.php +++ b/tests/Database/DatabaseSQLiteSchemaGrammarTest.php @@ -741,6 +741,16 @@ public function testAddingIpAddress() $this->assertSame('alter table "users" add column "foo" varchar not null', $statements[0]); } + public function testAddingIpAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->ipAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table "users" add column "ip_address" varchar not null', $statements[0]); + } + public function testAddingMacAddress() { $blueprint = new Blueprint('users'); @@ -751,6 +761,16 @@ public function testAddingMacAddress() $this->assertSame('alter table "users" add column "foo" varchar not null', $statements[0]); } + public function testAddingMacAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->macAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table "users" add column "mac_address" varchar not null', $statements[0]); + } + public function testAddingGeometry() { $blueprint = new Blueprint('geo'); diff --git a/tests/Database/DatabaseSqlServerSchemaGrammarTest.php b/tests/Database/DatabaseSqlServerSchemaGrammarTest.php index 5ca3790522ab..acb2ed68367e 100755 --- a/tests/Database/DatabaseSqlServerSchemaGrammarTest.php +++ b/tests/Database/DatabaseSqlServerSchemaGrammarTest.php @@ -771,6 +771,16 @@ public function testAddingIpAddress() $this->assertSame('alter table "users" add "foo" nvarchar(45) not null', $statements[0]); } + public function testAddingIpAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->ipAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table "users" add "ip_address" nvarchar(45) not null', $statements[0]); + } + public function testAddingMacAddress() { $blueprint = new Blueprint('users'); @@ -781,6 +791,16 @@ public function testAddingMacAddress() $this->assertSame('alter table "users" add "foo" nvarchar(17) not null', $statements[0]); } + public function testAddingMacAddressDefaultsColumnName() + { + $blueprint = new Blueprint('users'); + $blueprint->macAddress(); + $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); + + $this->assertCount(1, $statements); + $this->assertSame('alter table "users" add "mac_address" nvarchar(17) not null', $statements[0]); + } + public function testAddingGeometry() { $blueprint = new Blueprint('geo');