Skip to content

Commit b29744d

Browse files
committed
Fix failing test + test for overflow
1 parent 40f6b36 commit b29744d

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

src/Generators/FactoryGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function buildDefinition(Model $model)
9595

9696
$definition = str_replace(
9797
"/** {$column->dataType()}_attributes **/",
98-
implode(', ', [$precision, 0, (intval(str_repeat(9, $precision)) / pow(10, $scale))]),
98+
implode(', ', [$scale, 0, (str_repeat(9, $precision - $scale) . '.' . str_repeat(9, $scale))]),
9999
$definition
100100
);
101101
} else {

tests/fixtures/definitions/model-modifiers.bp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ models:
55
content: string default:''
66
amount: float:9,3
77
total: decimal:10,2
8+
overflow: decimal:99,99
89
ssn: char:11
910
role: enum:user,admin,owner

tests/fixtures/factories/model-modifiers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'content' => $faker->paragraphs(3, true),
1313
'amount' => $faker->randomFloat(3, 0, 999999.999),
1414
'total' => $faker->randomFloat(2, 0, 99999999.99),
15+
'overflow' => $faker->randomFloat(30, 0, 99999999999999999999999999999999999.999999999999999999999999999999),
1516
'ssn' => $faker->ssn,
1617
'role' => $faker->randomElement(["user","admin","owner"]),
1718
];

tests/fixtures/migrations/modifiers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function up()
2020
$table->string('content')->default('');
2121
$table->float('amount', 9, 3);
2222
$table->decimal('total', 10, 2);
23+
$table->decimal('overflow', 99, 99);
2324
$table->char('ssn', 11);
2425
$table->enum('role', ["user","admin","owner"]);
2526
$table->timestamps();

0 commit comments

Comments
 (0)