From 28dcd74b89f53456792c878c37d08b55bdcf13b5 Mon Sep 17 00:00:00 2001 From: Scott Robertson Date: Mon, 21 Jul 2014 19:08:10 +0100 Subject: [PATCH 1/3] Test Facade::define method --- tests/Facade/FactoryMuffinTest.php | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/Facade/FactoryMuffinTest.php diff --git a/tests/Facade/FactoryMuffinTest.php b/tests/Facade/FactoryMuffinTest.php new file mode 100644 index 0000000..f37a6dd --- /dev/null +++ b/tests/Facade/FactoryMuffinTest.php @@ -0,0 +1,31 @@ + 'string', + 'active' => 'boolean', + 'email' => 'email' + )); + + $user = FactoryMuffin::create('\League\FactoryMuffin\Test\Facade\User'); + + $this->assertInternalType('string', $user->name); + $this->assertInternalType('boolean', $user->active); + $this->assertContains('@', $user->email); + } +} + +class User +{ + public function save() + { + return true; + } +} From dc1ed6278ccc47c2c33a39174f160c323c756cd6 Mon Sep 17 00:00:00 2001 From: Scott Robertson Date: Mon, 21 Jul 2014 19:13:51 +0100 Subject: [PATCH 2/3] test facade::instance() --- tests/Facade/FactoryMuffinTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Facade/FactoryMuffinTest.php b/tests/Facade/FactoryMuffinTest.php index f37a6dd..8edc20d 100644 --- a/tests/Facade/FactoryMuffinTest.php +++ b/tests/Facade/FactoryMuffinTest.php @@ -20,6 +20,22 @@ public function testDefine() $this->assertInternalType('boolean', $user->active); $this->assertContains('@', $user->email); } + + public function testInstance() + { + FactoryMuffin::define('\League\FactoryMuffin\Test\Facade\User', array( + 'name' => 'string', + 'active' => 'boolean', + 'email' => 'email' + )); + + $user = FactoryMuffin::instance('\League\FactoryMuffin\Test\Facade\User'); + + $this->assertInternalType('string', $user->name); + $this->assertInternalType('boolean', $user->active); + $this->assertContains('@', $user->email); + } + } class User From 2c23ccbdd1d2789beab5cdbdc7cd0c0529760c89 Mon Sep 17 00:00:00 2001 From: Scott Robertson Date: Mon, 21 Jul 2014 19:14:02 +0100 Subject: [PATCH 3/3] test facade::attributesFor() --- tests/Facade/FactoryMuffinTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Facade/FactoryMuffinTest.php b/tests/Facade/FactoryMuffinTest.php index 8edc20d..7b90e3c 100644 --- a/tests/Facade/FactoryMuffinTest.php +++ b/tests/Facade/FactoryMuffinTest.php @@ -36,6 +36,20 @@ public function testInstance() $this->assertContains('@', $user->email); } + public function testAttributesFor() + { + FactoryMuffin::define('\League\FactoryMuffin\Test\Facade\User', array( + 'name' => 'string', + 'active' => 'boolean', + 'email' => 'email' + )); + + $attributes = FactoryMuffin::attributesFor('\League\FactoryMuffin\Test\Facade\User'); + + $this->assertInternalType('string', $attributes['name']); + $this->assertInternalType('boolean', $attributes['active']); + $this->assertContains('@', $attributes['email']); + } } class User