Skip to content

Commit 103b91d

Browse files
committed
tests added.
1 parent 9f148c6 commit 103b91d

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

src/Service/Generator/Compiler/Mapper/FieldMapper.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function generateField(FieldEntity $fieldEntity): string
2525
$argumentString = $this->renderArguments($fieldEntity->getArguments());
2626

2727
$methods = [
28-
$fieldEntity->getType() . "('" . $fieldEntity->getColumnName() . "'" . $argumentString . ")",
28+
$fieldEntity->getType()."('".$fieldEntity->getColumnName()."'".$argumentString.")",
2929
...$this->getFluentOptions($fieldEntity->getOptions()),
3030
];
3131

@@ -37,20 +37,18 @@ private function renderArguments(array $arguments): string
3737
$args = [];
3838

3939
foreach ($arguments as $arg) {
40-
if ($arg === null) {
41-
continue;
42-
}
43-
44-
if (is_bool($arg)) {
45-
$args[] = $arg ? 'true' : 'false';
46-
} elseif (is_int($arg)) {
47-
$args[] = $arg;
48-
} else {
49-
$args[] = "'" . $arg . "'";
40+
if (null !== $arg) {
41+
if (is_bool($arg)) {
42+
$args[] = $arg ? 'true' : 'false';
43+
} elseif (is_int($arg)) {
44+
$args[] = $arg;
45+
} else {
46+
$args[] = "'".$arg."'";
47+
}
5048
}
5149
}
5250

53-
return count($args) > 0 ? ', ' . implode(', ', $args) : '';
51+
return count($args) > 0 ? ', '.implode(', ', $args) : '';
5452
}
5553

5654
private function getFluentOptions(array $options): array
@@ -60,7 +58,7 @@ private function getFluentOptions(array $options): array
6058
if (!empty($options['default'])) {
6159
$methods[] = $options['default'] === 'CURRENT_TIMESTAMP'
6260
? "default(DB::raw('CURRENT_TIMESTAMP'))"
63-
: "default('" . $options['default'] . "')";
61+
: "default('".$options['default']."')";
6462
}
6563

6664
if (!empty($options['unsigned'])) {
@@ -72,7 +70,7 @@ private function getFluentOptions(array $options): array
7270
}
7371

7472
if (!empty($options['comment'])) {
75-
$methods[] = "comment('" . addcslashes($options['comment'], "\\'") . "')";
73+
$methods[] = "comment('".addcslashes($options['comment'], "\\'")."')";
7674
}
7775

7876
return $methods;

tests/Unit/Generator/Compiler/Mapper/FieldMapperTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,6 @@ public function testMapWorksWithArgumentsAndWithoutOptions(array $arguments, str
9696
$this->assertStringContainsString(sprintf("\$table->bigInteger(%s);", "'id'".$expectedResult), $result[0]);
9797
}
9898

99-
public function testMapWorkWithoutArgumentsAndWithoutOptions(): void
100-
{
101-
$field = new FieldEntity();
102-
$field->setType('bigInteger');
103-
$field->setColumnName('id');
104-
$data = [$field];
105-
$result = $this->mapper->map($data);
106-
$this->assertCount(1, $result);
107-
$this->assertStringContainsString("\$table->bigInteger('id');", $result[0]);
108-
}
109-
11099
public static function optionProvider(): array
111100
{
112101
return [

0 commit comments

Comments
 (0)