Skip to content

Commit

Permalink
Merge pull request #136 from designmynight/string_type_fix_improved_t…
Browse files Browse the repository at this point in the history
…esting

string_type_fix_improved_testing
  • Loading branch information
MihailProcudin authored Mar 31, 2022
2 parents 2086b7d + 2ef65f9 commit 9e912ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,7 @@ public function routingRequired(): void
*/
public function string($column, $length = null): PropertyDefinition
{
$length = $length ?: Builder::$defaultStringLength;

return $this->text('string', $column, compact('length'));
return $this->text($column);
}

/**
Expand Down
21 changes: 13 additions & 8 deletions tests/Unit/Database/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public function it_performs_token_count()
$name = 'name';
$expected = compact('type', 'name');

$this->blueprint->tokenCount($expected['name']);

$this->assertColumn($expected);
}

Expand All @@ -142,6 +144,8 @@ public function it_adds_text()
$name = 'name';
$expected = compact('type', 'name');

$this->blueprint->text($name);

$this->assertColumn($expected);
}

Expand All @@ -150,10 +154,12 @@ public function it_adds_text()
*/
public function it_adds_string()
{
$type = 'string';
$type = 'text';
$name = 'name';
$expected = compact('type', 'name');

$this->blueprint->string($expected['name']);

$this->assertColumn($expected);
}

Expand All @@ -177,6 +183,8 @@ public function it_adds_a_range()
$name = 'name';
$expected = compact('type', 'name');

$this->blueprint->range($expected['type'], $expected['name']);

$this->assertColumn($expected);
}

Expand All @@ -191,10 +199,7 @@ public function it_adds_a_integer_range()

$this->blueprint->integerRange($expected['name']);

$columns = $this->blueprint->getColumns();
$attr = $columns[0]->getAttributes();

$this->assertEquals($expected, $attr);
$this->assertColumn($expected);
}

/**
Expand All @@ -206,13 +211,13 @@ public function it_adds_a_integer()
$name = 'name';
$expected = compact('type', 'name');

$this->blueprint->integer($name);

$this->assertColumn($expected);
}

public function assertColumn($expected)
{
$this->blueprint->addColumn($expected['type'], $expected['name']);

$columns = $this->blueprint->getColumns();
$attr = $columns[0]->getAttributes();

Expand All @@ -227,7 +232,7 @@ public function it_adds_a_column()
$type = 'string';
$name = 'name';
$expected = compact('type', 'name');

$this->blueprint->addColumn($type, $name);
$this->assertColumn($expected);
}

Expand Down

0 comments on commit 9e912ff

Please sign in to comment.