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
2 changes: 2 additions & 0 deletions src/Generators/FactoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public static function fakerDataType(string $type)
'unsignedsmallinteger' => 'randomDigitNotNull',
'biginteger' => 'randomNumber()',
'smallint' => 'randomNumber()',
'tinyinteger' => 'randomNumber()',
'smallinteger' => 'randomNumber()',
'decimal' => 'randomFloat(/** decimal_attributes **/)',
'float' => 'randomFloat(/** float_attributes **/)',
'longtext' => 'text',
Expand Down
1 change: 1 addition & 0 deletions tests/Feature/Generator/FactoryGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function modelTreeDataProvider()
['drafts/unconventional-foreign-key.yaml', 'database/factories/StateFactory.php', 'factories/unconventional-foreign-key.php'],
['drafts/foreign-key-shorthand.yaml', 'database/factories/CommentFactory.php', 'factories/foreign-key-shorthand.php'],
['drafts/resource-statements.yaml', 'database/factories/UserFactory.php', 'factories/resource-statements.php'],
['drafts/factory-smallint-and-tinyint.yaml', 'database/factories/ModelFactory.php', 'factories/factory-smallint-and-tinyint.php'],
];
}
}
4 changes: 4 additions & 0 deletions tests/fixtures/drafts/factory-smallint-and-tinyint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
models:
Model:
market_type: tinyInteger
deposit: smallInteger unsigned
13 changes: 13 additions & 0 deletions tests/fixtures/factories/factory-smallint-and-tinyint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Model;
use Faker\Generator as Faker;

$factory->define(Model::class, function (Faker $faker) {
return [
'market_type' => $faker->randomNumber(),
'deposit' => $faker->randomNumber(),
];
});