New tests and new configuration for tests.

This commit is contained in:
James Cole 2015-01-01 12:33:07 +01:00
parent 8e892e7ea5
commit 584f7ced84
11 changed files with 118 additions and 19 deletions

View File

@ -0,0 +1,2 @@
<?php
return ['log_level' => 'debug',];

View File

@ -0,0 +1,8 @@
<?php
return [
'verify_mail' => false,
'verify_reset' => true,
'allow_register' => true
];

View File

@ -0,0 +1,3 @@
<?php
return ['driver' => 'array',];

View File

@ -0,0 +1,12 @@
<?php
return [
'default' => 'sqlite',
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
]
]
];

View File

@ -0,0 +1,13 @@
<?php
return [
'driver' => 'smtp',
'host' => '',
'port' => 587,
'from' => ['address' => '', 'name' => 'Firefly III'],
'encryption' => 'tls',
'username' => '',
'password' => '',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => true,
];

View File

@ -0,0 +1,3 @@
<?php
return ['driver' => 'array',];

View File

@ -16,7 +16,8 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
public function createApplication()
{
$unitTesting = true;
$testEnvironment = 'testing';
$testEnvironment = 'testingInMemory';
return require __DIR__ . '/../../bootstrap/start.php';
@ -25,6 +26,9 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
public function setUp()
{
parent::setUp();
// reset database?
$this->prepareForTests();
}
static public function setupBeforeClass()
@ -37,4 +41,15 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
{
//m::close();
}
/**
* Migrates the database and set the mailer to 'pretend'.
* This will cause the tests to run quickly.
*
*/
private function prepareForTests()
{
Artisan::call('migrate');
Mail::pretend(true);
}
}

View File

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

View File

@ -0,0 +1,27 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class AccountTypeTest
*/
class AccountTypeTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
// tests
public function testAccounts()
{
$account = f::create('Account');
$this->assertCount(1, $account->accountType()->first()->accounts()->get());
}
}

26
tests/unit/BudgetTest.php Normal file
View File

@ -0,0 +1,26 @@
<?php
use League\FactoryMuffin\Facade as f;
/**
* Class AccountTypeTest
*/
class BudgetTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testUser()
{
$budget = f::create('Budget');
$this->assertInstanceOf('User', $budget->user);
}
}

View File

@ -1,18 +0,0 @@
<?php
class ExamplATest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
}
protected function tearDown()
{
}
// tests
public function testMe()
{
}
}