Skip to content

Commit

Permalink
Fix null length
Browse files Browse the repository at this point in the history
  • Loading branch information
jfilla committed Nov 7, 2019
1 parent 0771923 commit c0f93a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DoctrineEntityFaker/ConfigurationFactory.php
Expand Up @@ -32,11 +32,11 @@ public function create(): Configuration
return $faker->dateTime;
},
Types::STRING => function (Column $column) use ($faker) {
$length = $column->length;
$length = $column->length ?? 255;
if ($length <= 10) {
return substr(md5((string)mt_rand()), 0, $length);
}
return $faker->text($column->length ?? 255);
return $faker->text($length);
},
Types::TEXT => function () use ($faker) {
return $faker->text();
Expand Down
6 changes: 6 additions & 0 deletions tests/DoctrineEntityFakerTests/Entities/EntityB.php
Expand Up @@ -44,6 +44,12 @@ class EntityB
*/
public $string;

/**
* @var string
* @ORM\Column(type="string")
*/
public $stringDefaultLength;

/**
* @var string
* @ORM\Column(type="string", length=2)
Expand Down

0 comments on commit c0f93a7

Please sign in to comment.