Skip to content

Commit

Permalink
Merge pull request #91 from thephpleague/facade-tests
Browse files Browse the repository at this point in the history
Facade Tests
  • Loading branch information
scottrobertson committed Jul 21, 2014
2 parents b19e04e + 2c23ccb commit cd031c0
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/Facade/FactoryMuffinTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace League\FactoryMuffin\Test\Facade;

use League\FactoryMuffin\Facade\FactoryMuffin;

class FactoryMuffinTest extends \PHPUnit_Framework_TestCase
{
public function testDefine()
{
FactoryMuffin::define('\League\FactoryMuffin\Test\Facade\User', array(
'name' => '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);
}

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);
}

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
{
public function save()
{
return true;
}
}

0 comments on commit cd031c0

Please sign in to comment.