Skip to content

Commit

Permalink
Merge pull request #25 from scottrobertson/integer_typecast
Browse files Browse the repository at this point in the history
Integer typecast
  • Loading branch information
scottrobertson committed Apr 28, 2014
2 parents 06a674e + 614fc6c commit b7c9297
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Zizaco/FactoryMuff/FactoryMuff.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,13 @@ private function generateAttr( $kind, $model = NULL )
}

else if ( is_string($kind) && substr( $kind, 0, 8 ) === 'integer|' ) {
$numgen = substr( $kind, 8 );

$numgen = substr( $kind, 8 );
$result = null;
for ( $i=0; $i<$numgen; $i++ ) {
$result .= mt_rand(0,9);
}

return (int) $result;
}
else {

Expand Down
4 changes: 2 additions & 2 deletions tests/FactoryMuffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public function test_date_kind_with_date()
public function test_integer()
{
$this->factory->define('SampleModelA', array(
'number' => 'integer|100',
'number' => 'integer|10',
));

$obj = $this->factory->create('SampleModelA');
$this->assertEquals(100, strlen($obj->number));
$this->assertEquals(10, strlen($obj->number));
}

public function test_should_create()
Expand Down

0 comments on commit b7c9297

Please sign in to comment.