diff --git a/src/Generators/Base.php b/src/Generators/Base.php index a28fdff..4095260 100644 --- a/src/Generators/Base.php +++ b/src/Generators/Base.php @@ -81,10 +81,10 @@ public static function detect($kind, $object = null, $faker = null) return new Closure($kind, $object, $faker); } - $class = __NAMESPACE__ . '\\Generic'; + $class = __NAMESPACE__.'\\Generic'; foreach (self::$generators as $generator) { if (substr($kind, 0, strlen($generator)) === $generator) { - $class = __NAMESPACE__ . '\\' . ucfirst($generator); + $class = __NAMESPACE__.'\\'.ucfirst($generator); break; } } @@ -128,7 +128,7 @@ protected function getGenerator() protected function getGeneratorWithoutPrefix() { if ($prefix = $this->getPrefix()) { - return str_replace($prefix . ':', '', $this->getGenerator()); + return str_replace($prefix.':', '', $this->getGenerator()); } return $this->getGenerator(); diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index aa7d71d..a9045f7 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -6,7 +6,7 @@ abstract class AbstractTestCase extends PHPUnit_Framework_TestCase { public static function setupBeforeClass() { - FactoryMuffin::setFakerLocale('en_GB')->loadFactories(__DIR__ . '/factories'); + FactoryMuffin::setFakerLocale('en_GB')->loadFactories(__DIR__.'/factories'); } public static function tearDownAfterClass() diff --git a/tests/DefinitionTest.php b/tests/DefinitionTest.php index ed38d7a..fa9d3b7 100644 --- a/tests/DefinitionTest.php +++ b/tests/DefinitionTest.php @@ -1,7 +1,7 @@ assertSame(1, count(get_included_files()) - $count); $this->assertInstanceOf('League\FactoryMuffin\Factory', $return); @@ -92,7 +92,7 @@ public function testFactoryLoading() public function testShouldThrowExceptionWhenLoadingANonexistentDirectory() { try { - FactoryMuffin::loadFactories($path = __DIR__ . '/thisdirectorydoesntexist'); + FactoryMuffin::loadFactories($path = __DIR__.'/thisdirectorydoesntexist'); } catch (DirectoryNotFoundException $e) { $this->assertEquals("The directory '$path' was not found.", $e->getMessage()); $this->assertEquals($path, $e->getPath()); diff --git a/tests/EloquentTest.php b/tests/EloquentTest.php index 2da673a..3b76c12 100644 --- a/tests/EloquentTest.php +++ b/tests/EloquentTest.php @@ -1,116 +1,115 @@ -addConnection(array( - 'driver' => 'sqlite', - 'database' => ':memory:', - 'prefix' => '' - )); - - $db->setAsGlobal(); - $db->bootEloquent(); - - $db->schema()->create('users', function ($table) { - $table->increments('id'); - $table->string('name'); - $table->string('email'); - $table->timestamps(); - }); - - $db->schema()->create('cats', function ($table) { - $table->increments('id'); - $table->string('name'); - $table->integer('user_id'); - }); - - parent::setupBeforeClass(); - - FactoryMuffin::seed(5, 'User'); - FactoryMuffin::seed(50, 'Cat'); - } - - public function testNumberOfCats() - { - $cats = array(); - foreach (User::all() as $user) { - foreach ($user->cats as $cat) - { - $cats[] = $cat; - } - } - - $this->assertCount(50, $cats); - $this->assertInstanceOf('Cat', $cats[0]); - } - - public function testNumberOfCatOwners() - { - $users = array(); - foreach (Cat::all() as $cat) { - $users[] = $cat->user; - } - - $this->assertCount(50, $users); - $this->assertCount(5, array_unique($users)); - $this->assertInstanceOf('User', $users[0]); - } - - public function testUserProperties() - { - $user = User::first(); - - $this->assertGreaterThan(1, strlen($user->name)); - $this->assertGreaterThan(5, strlen($user->email)); - $this->assertContains('@', $user->email); - $this->assertContains('.', $user->email); - $this->assertInstanceOf('DateTime', $user->created_at); - $this->assertInstanceOf('DateTime', $user->updated_at); - $this->assertSame((string) $user->created_at, (string) $user->updated_at); - $this->assertFalse($user->xyz == true); - } - - public function testCatProperties() - { - $cat = Cat::first(); - - $this->assertGreaterThan(1, strlen($cat->name)); - $this->assertTrue($cat->user_id == true); - $this->assertFalse($cat->created_at == true); - $this->assertFalse($cat->updated_at == true); - $this->assertFalse($cat->xyz == true); - } -} - -class User extends Eloquent -{ - public $table = 'users'; - - public function cats() - { - return $this->hasMany('Cat'); - } -} - -class Cat extends Eloquent -{ - public $timestamps = false; - - public $table = 'cats'; - - public function user() - { - return $this->belongsTo('User'); - } +addConnection(array( + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '' + )); + + $db->setAsGlobal(); + $db->bootEloquent(); + + $db->schema()->create('users', function ($table) { + $table->increments('id'); + $table->string('name'); + $table->string('email'); + $table->timestamps(); + }); + + $db->schema()->create('cats', function ($table) { + $table->increments('id'); + $table->string('name'); + $table->integer('user_id'); + }); + + parent::setupBeforeClass(); + + FactoryMuffin::seed(5, 'User'); + FactoryMuffin::seed(50, 'Cat'); + } + + public function testNumberOfCats() + { + $cats = array(); + foreach (User::all() as $user) { + foreach ($user->cats as $cat) { + $cats[] = $cat; + } + } + + $this->assertCount(50, $cats); + $this->assertInstanceOf('Cat', $cats[0]); + } + + public function testNumberOfCatOwners() + { + $users = array(); + foreach (Cat::all() as $cat) { + $users[] = $cat->user; + } + + $this->assertCount(50, $users); + $this->assertCount(5, array_unique($users)); + $this->assertInstanceOf('User', $users[0]); + } + + public function testUserProperties() + { + $user = User::first(); + + $this->assertGreaterThan(1, strlen($user->name)); + $this->assertGreaterThan(5, strlen($user->email)); + $this->assertContains('@', $user->email); + $this->assertContains('.', $user->email); + $this->assertInstanceOf('DateTime', $user->created_at); + $this->assertInstanceOf('DateTime', $user->updated_at); + $this->assertSame((string) $user->created_at, (string) $user->updated_at); + $this->assertFalse($user->xyz == true); + } + + public function testCatProperties() + { + $cat = Cat::first(); + + $this->assertGreaterThan(1, strlen($cat->name)); + $this->assertTrue($cat->user_id == true); + $this->assertFalse($cat->created_at == true); + $this->assertFalse($cat->updated_at == true); + $this->assertFalse($cat->xyz == true); + } +} + +class User extends Eloquent +{ + public $table = 'users'; + + public function cats() + { + return $this->hasMany('Cat'); + } +} + +class Cat extends Eloquent +{ + public $timestamps = false; + + public $table = 'cats'; + + public function user() + { + return $this->belongsTo('User'); + } } diff --git a/tests/FactoryMuffinTest.php b/tests/FactoryMuffinTest.php index f52a7fd..c97a6a5 100644 --- a/tests/FactoryMuffinTest.php +++ b/tests/FactoryMuffinTest.php @@ -1,7 +1,7 @@