More tests!

This commit is contained in:
James Cole 2015-01-01 13:43:34 +01:00
parent 402e8588cf
commit 74c9feb53f
5 changed files with 89 additions and 9 deletions

View File

@ -98,12 +98,5 @@ class User extends Eloquent implements UserInterface, RemindableInterface
return $this->hasMany('TransactionJournal');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
*/
public function transactions()
{
return $this->hasManyThrough('TransactionJournal', 'Transaction');
}
}

View File

@ -0,0 +1,9 @@
<?php
League\FactoryMuffin\Facade::define(
'Preference', [
'user_id' => 'factory|User',
'name' => 'word',
'data' => 'sentence',
]
);

View File

@ -10,7 +10,21 @@ League\FactoryMuffin\Facade::define(
return $code;
},
'name' => 'word',
'symbol' => '$'
'name' => function () {
$code = '';
for ($i = 0; $i < 8; $i++) {
$code .= chr(rand(65, 90));
}
return $code;
},
'symbol' => function () {
$code = '';
for ($i = 0; $i < 2; $i++) {
$code .= chr(rand(65, 90));
}
return $code;
}
]
);

View File

@ -0,0 +1,30 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class TransactionTypeTest
*/
class TransactionTypeTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
// tests
public function testJournals()
{
$journal = f::create('TransactionJournal');
$type = $journal->transactionType;
$this->assertCount(1, $type->transactionJournals()->get());
}
}

34
tests/unit/UserTest.php Normal file
View File

@ -0,0 +1,34 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class AccountTest
*/
class UserTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
// tests
public function testPreference()
{
$pref = f::create('Preference');
$this->assertEquals($pref->user_id, $pref->user->id);
}
public function testReminder()
{
$reminder = f::create('Reminder');
$this->assertEquals($reminder->user_id, $reminder->user->id);
}
}