Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
20 changes: 20 additions & 0 deletions tests/Database/DatabaseMySqlSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
20 changes: 20 additions & 0 deletions tests/Database/DatabasePostgresSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
20 changes: 20 additions & 0 deletions tests/Database/DatabaseSQLiteSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
20 changes: 20 additions & 0 deletions tests/Database/DatabaseSqlServerSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down