Remove tests.

This commit is contained in:
James Cole 2016-05-15 15:01:29 +02:00
parent ec2027b8db
commit f373c72679
31 changed files with 86 additions and 3142 deletions

View File

@ -30,6 +30,9 @@ class TestData
/** @var Carbon */
private $start;
/** @var string */
private $time;
/**
* TestData constructor.
*
@ -45,6 +48,7 @@ class TestData
$this->start = $start;
$this->end = $end;
$this->time = $end->format('Y-m-d H:i:s');
}
/**
@ -64,8 +68,8 @@ class TestData
$insert = [];
foreach ($this->data['accounts'] as $account) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $account['user_id'],
'account_type_id' => $account['account_type_id'],
'name' => Crypt::encrypt($account['name']),
@ -79,8 +83,8 @@ class TestData
$insert = [];
foreach ($this->data['account-meta'] as $meta) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $meta['account_id'],
'name' => $meta['name'],
'data' => $meta['data'],
@ -100,8 +104,8 @@ class TestData
$data = Crypt::encrypt($attachment['content']);
$attachmentId = DB::table('attachments')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'attachable_id' => $attachment['attachable_id'],
'attachable_type' => $attachment['attachable_type'],
'user_id' => $attachment['user_id'],
@ -128,8 +132,8 @@ class TestData
$insert = [];
foreach ($this->data['bills'] as $bill) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $bill['user_id'],
'name' => Crypt::encrypt($bill['name']),
'match' => Crypt::encrypt($bill['match']),
@ -155,8 +159,8 @@ class TestData
$insert = [];
foreach ($this->data['budgets'] as $budget) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $budget['user_id'],
'name' => Crypt::encrypt($budget['name']),
'encrypted' => 1,
@ -168,8 +172,8 @@ class TestData
$amount = rand($limit['amount_min'], $limit['amount_max']);
$limitId = DB::table('budget_limits')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'budget_id' => $limit['budget_id'],
'startdate' => $limit['startdate'],
'amount' => $amount,
@ -180,8 +184,8 @@ class TestData
DB::table('limit_repetitions')->insert(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'budget_limit_id' => $limitId,
'startdate' => $limit['startdate'],
'enddate' => Navigation::endOfPeriod(new Carbon($limit['startdate']), $limit['repeat_freq'])->format('Y-m-d'),
@ -195,8 +199,8 @@ class TestData
$amount = rand($limit['amount_min'], $limit['amount_max']);
$limitId = DB::table('budget_limits')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'budget_id' => $limit['budget_id'],
'startdate' => $current->format('Y-m-d'),
'amount' => $amount,
@ -207,8 +211,8 @@ class TestData
DB::table('limit_repetitions')->insert(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'budget_limit_id' => $limitId,
'startdate' => $current->format('Y-m-d'),
'enddate' => Navigation::endOfPeriod($current, 'monthly')->format('Y-m-d'),
@ -230,8 +234,8 @@ class TestData
$insert = [];
foreach ($this->data['categories'] as $category) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $category['user_id'],
'name' => Crypt::encrypt($category['name']),
'encrypted' => 1,
@ -256,8 +260,8 @@ class TestData
$description = str_replace(':month', $month, $withdrawal['description']);
$journalId = DB::table('transaction_journals')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $withdrawal['user_id'],
'transaction_type_id' => 1,
'bill_id' => $withdrawal['bill_id'] ?? null,
@ -275,15 +279,15 @@ class TestData
);
$amount = (rand($withdrawal['min_amount'] * 100, $withdrawal['max_amount'] * 100)) / 100;
$transactions[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'transaction_journal_id' => $journalId,
'account_id' => $withdrawal['source_id'],
'amount' => $amount * -1,
];
$transactions[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'transaction_journal_id' => $journalId,
'account_id' => $withdrawal['destination_id'],
'amount' => $amount,
@ -316,8 +320,8 @@ class TestData
$description = str_replace(':month', $month, $deposit['description']);
$journalId = DB::table('transaction_journals')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $deposit['user_id'],
'transaction_type_id' => 2,
'bill_id' => $deposit['bill_id'] ?? null,
@ -335,15 +339,15 @@ class TestData
);
$amount = (rand($deposit['min_amount'] * 100, $deposit['max_amount'] * 100)) / 100;
$transactions[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'transaction_journal_id' => $journalId,
'account_id' => $deposit['source_id'],
'amount' => $amount * -1,
];
$transactions[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'transaction_journal_id' => $journalId,
'account_id' => $deposit['destination_id'],
'amount' => $amount,
@ -365,8 +369,8 @@ class TestData
$description = str_replace(':month', $month, $transfer['description']);
$journalId = DB::table('transaction_journals')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $transfer['user_id'],
'transaction_type_id' => 3,
'bill_id' => $transfer['bill_id'] ?? null,
@ -384,15 +388,15 @@ class TestData
);
$amount = (rand($transfer['min_amount'] * 100, $transfer['max_amount'] * 100)) / 100;
$transactions[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'transaction_journal_id' => $journalId,
'account_id' => $transfer['source_id'],
'amount' => $amount * -1,
];
$transactions[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'transaction_journal_id' => $journalId,
'account_id' => $transfer['destination_id'],
'amount' => $amount,
@ -408,11 +412,12 @@ class TestData
);
}
}
DB::table('transactions')->insert($transactions);
$transactions = [];
$current->addMonth();
}
DB::table('transactions')->insert($transactions);
}
/**
@ -423,8 +428,8 @@ class TestData
foreach ($this->data['multi-deposits'] as $deposit) {
$journalId = DB::table('transaction_journals')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $deposit['user_id'],
'transaction_type_id' => 2,
'transaction_currency_id' => 1,
@ -444,8 +449,8 @@ class TestData
$amount = $deposit['amounts'][$index];
$first = DB::table('transactions')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $deposit['destination_id'],
'transaction_journal_id' => $journalId,
'description' => $description,
@ -454,8 +459,8 @@ class TestData
);
$second = DB::table('transactions')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $source,
'transaction_journal_id' => $journalId,
'description' => $description,
@ -487,8 +492,8 @@ class TestData
foreach ($this->data['multi-transfers'] as $transfer) {
$journalId = DB::table('transaction_journals')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $transfer['user_id'],
'transaction_type_id' => 3,
'transaction_currency_id' => 1,
@ -509,8 +514,8 @@ class TestData
$source = $transfer['source_ids'][$index];
$first = DB::table('transactions')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $source,
'transaction_journal_id' => $journalId,
'description' => $description,
@ -519,8 +524,8 @@ class TestData
);
$second = DB::table('transactions')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $destination,
'transaction_journal_id' => $journalId,
'description' => $description,
@ -554,8 +559,8 @@ class TestData
foreach ($this->data['multi-withdrawals'] as $withdrawal) {
$journalId = DB::table('transaction_journals')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $withdrawal['user_id'],
'transaction_type_id' => 1,
'transaction_currency_id' => 1,
@ -575,8 +580,8 @@ class TestData
$amount = $withdrawal['amounts'][$index];
$first = DB::table('transactions')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $withdrawal['source_id'],
'transaction_journal_id' => $journalId,
'description' => $description,
@ -585,8 +590,8 @@ class TestData
);
$second = DB::table('transactions')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $destination,
'transaction_journal_id' => $journalId,
'description' => $description,
@ -635,8 +640,8 @@ class TestData
foreach ($this->data['piggy-banks'] as $piggyBank) {
$piggyId = DB::table('piggy_banks')->insertGetId(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'account_id' => $piggyBank['account_id'],
'name' => Crypt::encrypt($piggyBank['name']),
'targetamount' => $piggyBank['targetamount'],
@ -650,8 +655,8 @@ class TestData
if (isset($piggyBank['currentamount'])) {
DB::table('piggy_bank_repetitions')->insert(
[
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'piggy_bank_id' => $piggyId,
'startdate' => $piggyBank['startdate'],
'currentamount' => $piggyBank['currentamount'],
@ -669,8 +674,8 @@ class TestData
$insert = [];
foreach ($this->data['rule-groups'] as $group) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $group['user_id'],
'order' => $group['order'],
'title' => $group['title'],
@ -682,8 +687,8 @@ class TestData
$insert = [];
foreach ($this->data['rules'] as $rule) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $rule['user_id'],
'rule_group_id' => $rule['rule_group_id'],
'order' => $rule['order'],
@ -698,8 +703,8 @@ class TestData
$insert = [];
foreach ($this->data['rule-triggers'] as $trigger) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'rule_id' => $trigger['rule_id'],
'order' => $trigger['order'],
'active' => $trigger['active'],
@ -713,8 +718,8 @@ class TestData
$insert = [];
foreach ($this->data['rule-actions'] as $action) {
$insert[] = [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'rule_id' => $action['rule_id'],
'order' => $action['order'],
'active' => $action['active'],
@ -735,8 +740,8 @@ class TestData
foreach ($this->data['tags'] as $tag) {
$insert[]
= [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'user_id' => $tag['user_id'],
'tag' => Crypt::encrypt($tag['tag']),
'tagMode' => $tag['tagMode'],
@ -756,8 +761,8 @@ class TestData
foreach ($this->data['users'] as $user) {
$insert[]
= [
'created_at' => DB::raw('NOW()'),
'updated_at' => DB::raw('NOW()'),
'created_at' => $this->time,
'updated_at' => $this->time,
'email' => $user['email'],
'password' => bcrypt($user['password']),
];

View File

@ -8,7 +8,6 @@ declare(strict_types = 1);
* of the MIT license. See the LICENSE file for details.
*/
use Carbon\Carbon;
use FireflyIII\Support\Migration\TestData;
use Illuminate\Database\Seeder;
@ -31,13 +30,18 @@ class TestDataSeeder extends Seeder
*/
public function run()
{
$disk = Storage::disk('database');
$env = App::environment();
$disk = Storage::disk('database');
$env = App::environment();
Log::debug('Environment is ' . $env);
$fileName = 'seed.' . $env . '.json';
if ($disk->exists($fileName)) {
Log::debug('Now seeding ' . $fileName);
$file = json_decode($disk->get($fileName), true);
// run the file:
TestData::run($file);
return;
}
Log::info('No seed file (' . $fileName . ') for environment ' . $env);
}
}

View File

@ -15,34 +15,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
*/
protected $baseUrl = 'http://localhost';
/**
* @param User $user
* @param string $range
*/
public function changeDateRange(User $user, $range)
{
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'];
if (in_array($range, $valid)) {
Preference::where('user_id', $user->id)->where('name', 'viewRange')->delete();
Preference::create(
[
'user_id' => $user->id,
'name' => 'viewRange',
'data' => $range,
]
);
// set period to match?
}
if ($range === 'custom') {
$this->session(
[
'start' => Carbon::now()->subDays(20),
'end' => Carbon::now(),
]
);
}
}
/**
* Creates the application.
@ -58,30 +30,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
return $app;
}
/**
* @return array
*/
public function dateRangeProvider()
{
return [
'one day' => ['1D'],
'one week' => ['1W'],
'one month' => ['1M'],
'three months' => ['3M'],
'six months' => ['6M'],
'one year' => ['1Y'],
'custom range' => ['custom'],
];
}
/**
* @return User
*/
public function emptyUser()
{
return User::find(2);
}
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@ -111,16 +59,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
}
// if the database copy does exists, copy back as original.
$this->session(
[
'start' => Carbon::now()->startOfMonth(),
'end' => Carbon::now()->endOfMonth(),
'first' => Carbon::now()->startOfYear(),
]
);
}
/**
@ -132,23 +70,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
parent::tearDown();
}
/**
* @return User
*/
public function toBeDeletedUser()
{
return User::find(3);
}
/**
* @return User
*/
public function user()
{
$user = User::find(1);
return $user;
}
/**
* @param string $class

View File

@ -1,139 +0,0 @@
<?php
/**
* AccountControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Illuminate\Pagination\LengthAwarePaginator;
/**
* Class AccountControllerTest
*/
class AccountControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\AccountController::create
* @covers FireflyIII\Http\Controllers\AccountController::__construct
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testCreate($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/accounts/create/asset');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/accounts/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::destroy
*/
public function testDestroy()
{
$this->be($this->user());
$this->session(['accounts.delete.url' => 'http://localhost']);
$this->call('POST', '/accounts/destroy/6');
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/accounts/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::index
* @covers FireflyIII\Http\Controllers\AccountController::isInArray
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/accounts/asset');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::show
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testShow($range)
{
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('getJournals')->once()->andReturn(new LengthAwarePaginator([], 0, 50));
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/accounts/show/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::store
* @covers FireflyIII\Http\Requests\AccountFormRequest::authorize
* @covers FireflyIII\Http\Requests\AccountFormRequest::rules
*
*/
public function testStore()
{
$this->be($this->user());
$this->session(['accounts.create.url' => 'http://localhost']);
$args = [
'name' => 'Some kind of test account.',
'what' => 'asset',
'amount_currency_id_virtualBalance' => 1,
'amount_currency_id_openingBalance' => 1,
];
$this->call('POST', '/accounts/store', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::update
* @covers FireflyIII\Http\Requests\AccountFormRequest::authorize
* @covers FireflyIII\Http\Requests\AccountFormRequest::rules
*/
public function testUpdate()
{
$this->session(['accounts.edit.url' => 'http://localhost']);
$args = [
'id' => 1,
'name' => 'TestData new name',
'active' => 1,
];
$this->be($this->user());
$this->call('POST', '/accounts/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,90 +0,0 @@
<?php
/**
* AttachmentControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:27.
*/
class AttachmentControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\AttachmentController::delete
* @covers FireflyIII\Http\Controllers\AttachmentController::__construct
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/attachment/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AttachmentController::destroy
*/
public function testDestroy()
{
$this->be($this->user());
$this->session(['attachments.delete.url' => 'http://localhost']);
$this->call('POST', '/attachment/destroy/2');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\AttachmentController::download
*/
public function testDownload()
{
$this->be($this->user());
$this->call('GET', '/attachment/download/1');
$this->assertResponseStatus(200);
// must have certain headers
}
/**
* @covers FireflyIII\Http\Controllers\AttachmentController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/attachment/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AttachmentController::preview
*/
public function testPreview()
{
$this->be($this->user());
$this->call('GET', '/attachment/preview/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\AttachmentController::update
* @covers FireflyIII\Http\Requests\AttachmentFormRequest::authorize
* @covers FireflyIII\Http\Requests\AttachmentFormRequest::rules
*/
public function testUpdate()
{
$this->session(['attachments.edit.url' => 'http://localhost']);
$args = [
'title' => 'New title',
'description' => 'New descr',
'notes' => 'New notes',
];
$this->be($this->user());
$this->call('POST', '/attachment/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,81 +0,0 @@
<?php
/**
* AuthControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:40:28.
*/
class AuthControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::logout
*/
public function testLogout()
{
$this->be($this->user());
$this->call('GET', '/logout');
$this->assertResponseStatus(302);
// index should now redirect:
$this->call('GET', '/');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::login
* @covers FireflyIII\Http\Controllers\Auth\AuthController::__construct
* @covers FireflyIII\Http\Controllers\Auth\AuthController::sendFailedLoginResponse
* @covers FireflyIII\Http\Controllers\Auth\AuthController::getFailedLoginMessage
*
*/
public function testLogin()
{
$args = [
'email' => 'thegrumpydictator@gmail.com',
'password' => 'james',
'remember' => 1,
];
$this->call('POST', '/login', $args);
$this->assertResponseStatus(302);
$this->call('GET', '/');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::register
* @covers FireflyIII\Http\Controllers\Auth\AuthController::create
* @covers FireflyIII\Http\Controllers\Auth\AuthController::isBlockedDomain
* @covers FireflyIII\Http\Controllers\Auth\AuthController::getBlockedDomains
* @covers FireflyIII\Http\Controllers\Auth\AuthController::validator
*/
public function testRegister()
{
$args = [
'email' => 'thegrumpydictator+test@gmail.com',
'password' => 'james123',
'password_confirmation' => 'james123',
];
$this->call('POST', '/register', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('start');
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::showRegistrationForm
*/
public function testShowRegistrationForm()
{
$this->call('GET', '/register');
$this->assertResponseStatus(200);
}
}

View File

@ -1,27 +0,0 @@
<?php
/**
* PasswordControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:40:28.
*/
class PasswordControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::sendResetLinkEmail
*/
public function testSendResetLinkEmail()
{
$args = [
'email' => 'thegrumpydictator@gmail.com',
];
$this->call('POST', '/password/email', $args);
$this->assertResponseStatus(302);
}
}

View File

@ -1,165 +0,0 @@
<?php
/**
* BillControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Carbon\Carbon;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:27.
*/
class BillControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\BillController::create
* @covers FireflyIII\Http\Controllers\BillController::__construct
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/bills/create');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/bills/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::destroy
*/
public function testDestroy()
{
$this->session(['bills.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('POST', '/bills/destroy/2');
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/bills/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::index
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/bills');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::rescan
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testRescan($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/bills/rescan/1');
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::show
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testShow($range)
{
$repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
$repository->shouldReceive('getJournals')->once()->andReturn(new LengthAwarePaginator([], 0, 50));
$repository->shouldReceive('nextExpectedMatch')->once()->andReturn(new Carbon);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/bills/show/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::store
* @covers FireflyIII\Http\Requests\BillFormRequest::authorize
* @covers FireflyIII\Http\Requests\BillFormRequest::getBillData
* @covers FireflyIII\Http\Requests\BillFormRequest::rules
*/
public function testStore()
{
$this->session(['bills.create.url' => 'http://localhost']);
$args = [
'name' => 'Some test',
'match' => 'words',
'amount_min' => 10,
'amount_max' => 100,
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'date' => '20160101',
'repeat_freq' => 'monthly',
'skip' => 0,
];
$this->be($this->user());
$this->call('POST', '/bills/store', $args);
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\BillController::update
* @covers FireflyIII\Http\Requests\BillFormRequest::authorize
* @covers FireflyIII\Http\Requests\BillFormRequest::getBillData
* @covers FireflyIII\Http\Requests\BillFormRequest::rules
*/
public function testUpdate()
{
$this->session(['bills.edit.url' => 'http://localhost']);
$args = [
'id' => 1,
'name' => 'Some test',
'match' => 'words',
'amount_min' => 10,
'amount_max' => 100,
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'date' => '20160101',
'repeat_freq' => 'monthly',
'skip' => 0,
];
$this->be($this->user());
$this->call('POST', '/bills/update/1', $args);
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
}

View File

@ -1,196 +0,0 @@
<?php
/**
* BudgetControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Carbon\Carbon;
use Illuminate\Pagination\LengthAwarePaginator;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:27.
*/
class BudgetControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\BudgetController::amount
* @covers FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testAmount($range)
{
$args = [
'amount' => 1200,
];
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('POST', '/budgets/amount/1', $args);
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::create
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/budgets/create');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/budgets/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::destroy
*/
public function testDestroy()
{
$this->be($this->user());
$this->session(['budgets.delete.url' => 'http://localhost']);
$this->call('POST', '/budgets/destroy/2');
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/budgets/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::index
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/budgets');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::noBudget
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testNoBudget($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/budgets/list/noBudget');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testPostUpdateIncome($range)
{
$args = [
'amount' => 1200,
];
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('POST', '/budgets/income', $args);
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::show
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testShow($range)
{
// mock some stuff:
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$repository->shouldReceive('getJournals')->once()->andReturn(new LengthAwarePaginator([], 0, 50));
$repository->shouldReceive('firstActivity')->once()->andReturn(new Carbon);
$repository->shouldReceive('spentPerDay')->once()->andReturn([]);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/budgets/show/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::store
* @covers FireflyIII\Http\Requests\BudgetFormRequest::authorize
* @covers FireflyIII\Http\Requests\BudgetFormRequest::rules
*/
public function testStore()
{
$this->be($this->user());
$this->session(['budgets.create.url' => 'http://localhost']);
$args = [
'name' => 'Some kind of test budget.',
];
$this->call('POST', '/budgets/store', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::update
* @covers FireflyIII\Http\Requests\BudgetFormRequest::authorize
* @covers FireflyIII\Http\Requests\BudgetFormRequest::rules
*/
public function testUpdate()
{
$this->be($this->user());
$this->session(['budgets.edit.url' => 'http://localhost']);
$args = [
'name' => 'Some kind of test budget.',
'id' => 1,
];
$this->call('POST', '/budgets/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::updateIncome
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testUpdateIncome($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/budgets/income');
$this->assertResponseStatus(200);
}
}

View File

@ -1,156 +0,0 @@
<?php
/**
* CategoryControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:27.
*/
class CategoryControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\CategoryController::create
* @covers FireflyIII\Http\Controllers\CategoryController::__construct
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/categories/create');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/categories/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::destroy
*/
public function testDestroy()
{
$this->be($this->user());
$this->session(['categories.delete.url' => 'http://localhost']);
$this->call('POST', '/categories/destroy/2');
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/categories/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::index
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/categories');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::noCategory
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testNoCategory($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/categories/list/noCategory');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::show
* @covers FireflyIII\Http\Controllers\Controller::getSumOfRange
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testShow($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/categories/show/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::showWithDate
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testShowWithDate($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/categories/show/1/20150101');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::store
* @covers FireflyIII\Http\Requests\CategoryFormRequest::authorize
* @covers FireflyIII\Http\Requests\CategoryFormRequest::rules
*/
public function testStore()
{
$this->be($this->user());
$this->session(['categories.create.url' => 'http://localhost']);
$args = [
'name' => 'Some kind of test cat.',
];
$this->call('POST', '/categories/store', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\CategoryController::update
* @covers FireflyIII\Http\Requests\CategoryFormRequest::authorize
* @covers FireflyIII\Http\Requests\CategoryFormRequest::rules
*/
public function testUpdate()
{
$this->be($this->user());
$this->session(['categories.edit.url' => 'http://localhost']);
$args = [
'name' => 'Some kind of test category.',
'id' => 1,
];
$this->call('POST', '/categories/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,59 +0,0 @@
<?php
/**
* ChartAccountControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:57.
*/
class ChartAccountControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts
* @covers FireflyIII\Http\Controllers\Chart\AccountController::__construct
*/
public function testExpenseAccounts()
{
$this->be($this->user());
$this->call('GET', '/chart/account/expense');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::frontpage
*/
public function testFrontpage()
{
$this->be($this->user());
$this->call('GET', '/chart/account/frontpage');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::report
*/
public function testReport()
{
$this->be($this->user());
$this->call('GET', '/chart/account/report/default/20160101/20160131/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::single
*/
public function testSingle()
{
$this->be($this->user());
$this->call('GET', '/chart/account/1');
$this->assertResponseStatus(200);
}
}

View File

@ -1,38 +0,0 @@
<?php
/**
* ChartBillControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:57.
*/
class ChartBillControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Chart\BillController::frontpage
* @covers FireflyIII\Http\Controllers\Chart\BillController::__construct
*/
public function testFrontpage()
{
$this->be($this->user());
$this->call('GET', '/chart/bill/frontpage');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BillController::single
*/
public function testSingle()
{
$this->be($this->user());
$this->call('GET', '/chart/bill/1');
$this->assertResponseStatus(200);
}
}

View File

@ -1,77 +0,0 @@
<?php
/**
* ChartBudgetControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Carbon\Carbon;
use FireflyIII\Models\Budget;
use Illuminate\Support\Collection;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:57.
*/
class ChartBudgetControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budget
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::__construct
*/
public function testBudget()
{
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$repository->shouldReceive('spentPerDay')->once()->andReturn([]);
$repository->shouldReceive('getFirstBudgetLimitDate')->once()->andReturn(new Carbon);
$this->be($this->user());
$this->call('GET', '/chart/budget/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit
*/
public function testBudgetLimit()
{
$this->be($this->user());
$this->call('GET', '/chart/budget/1/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::frontpage
*/
public function testFrontpage()
{
$this->be($this->user());
$this->call('GET', '/chart/budget/frontpage');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::multiYear
*/
public function testMultiYear()
{
$budget = new Budget;
$budget->id = 1;
$budget->dateFormatted = '2015';
$budget->budgeted = 120;
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$repository->shouldReceive('getBudgetedPerYear')->once()->andReturn(new Collection([$budget]));
$repository->shouldReceive('getBudgetsAndExpensesPerYear')->once()->andReturn([]);
$this->be($this->user());
$this->call('GET', '/chart/budget/multi-year/default/20150101/20160101/1/1');
$this->assertResponseStatus(200);
}
}

View File

@ -1,106 +0,0 @@
<?php
/**
* ChartCategoryControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Illuminate\Support\Collection;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:57.
*/
class ChartCategoryControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::all
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::__construct
*/
public function testAll()
{
$this->be($this->user());
$this->call('GET', '/chart/category/1/all');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::currentPeriod
*/
public function testCurrentPeriod()
{
$this->be($this->user());
$this->call('GET', '/chart/category/1/period');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::earnedInPeriod
*/
public function testEarnedInPeriod()
{
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$repository->shouldReceive('earnedForAccountsPerMonth')->once()->andReturn(new Collection);
$this->be($this->user());
$this->call('GET', '/chart/category/earned-in-period/default/20150101/20151231/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::frontpage
*/
public function testFrontpage()
{
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$repository->shouldReceive('spentForAccountsPerMonth')->once()->andReturn(new Collection);
$repository->shouldReceive('sumSpentNoCategory')->once()->andReturn('120');
$this->be($this->user());
$this->call('GET', '/chart/category/frontpage');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::multiYear
*/
public function testMultiYear()
{
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$repository->shouldReceive('listMultiYear')->once()->andReturn(new Collection);
$this->be($this->user());
$this->call('GET', '/chart/category/multi-year/default/20150101/20151231/1/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod
*/
public function testSpecificPeriod()
{
$this->be($this->user());
$this->call('GET', '/chart/category/1/period/20150101');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::spentInPeriod
*/
public function testSpentInPeriod()
{
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$repository->shouldReceive('spentForAccountsPerMonth')->once()->andReturn(new Collection);
$this->be($this->user());
$this->call('GET', '/chart/category/spent-in-period/default/20150101/20151231/1');
$this->assertResponseStatus(200);
}
}

View File

@ -1,26 +0,0 @@
<?php
/**
* ChartPiggyBankControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:57.
*/
class ChartPiggyBankControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Chart\PiggyBankController::history
* @covers FireflyIII\Http\Controllers\Chart\PiggyBankController::__construct
*/
public function testHistory()
{
$this->be($this->user());
$this->call('GET', '/chart/piggy-bank/1');
$this->assertResponseStatus(200);
}
}

View File

@ -1,43 +0,0 @@
<?php
/**
* ChartReportControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:57.
*/
class ChartReportControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOut
* @covers FireflyIII\Http\Controllers\Chart\ReportController::__construct
*/
public function testYearInOut()
{
$repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
$repository->shouldReceive('spentPerMonth')->once()->andReturn([]);
$repository->shouldReceive('earnedPerMonth')->once()->andReturn([]);
$this->be($this->user());
$this->call('GET', '/chart/report/in-out/default/20150101/20151231/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\Chart\ReportController::yearInOutSummarized
*/
public function testYearInOutSummarized()
{
$repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
$repository->shouldReceive('spentPerMonth')->once()->andReturn([]);
$repository->shouldReceive('earnedPerMonth')->once()->andReturn([]);
$this->be($this->user());
$this->call('GET', '/chart/report/in-out-sum/default/20150101/20151231/1');
$this->assertResponseStatus(200);
}
}

View File

@ -1,239 +0,0 @@
<?php
/**
* CsvControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Illuminate\Support\Collection;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class CsvControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\CsvController::columnRoles
* @covers FireflyIII\Http\Controllers\CsvController::__construct
*/
public function testColumnRoles()
{
$this->be($this->user());
// mock wizard
$fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-import-account', 'csv-specifix', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
// mock Data and Reader
$reader = $this->mock('League\Csv\Reader');
$data = $this->mock('FireflyIII\Helpers\Csv\Data');
$data->shouldReceive('getReader')->times(2)->andReturn($reader);
$reader->shouldReceive('fetchOne')->withNoArgs()->once()->andReturn([1, 2, 3, 4]);
$reader->shouldReceive('fetchOne')->with(1)->once()->andReturn([1, 2, 3, 4]);
$data->shouldReceive('getRoles')->once()->andReturn([]);
$data->shouldReceive('getMap')->once()->andReturn([]);
$data->shouldReceive('hasHeaders')->once()->andReturn(false);
$this->call('GET', '/csv/column_roles');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::downloadConfig
*/
public function testDownloadConfig()
{
$this->be($this->user());
$fields = ['csv-date-format', 'csv-has-headers', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
$this->call('GET', '/csv/download-config');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::downloadConfigPage
*/
public function testDownloadConfigPage()
{
$this->be($this->user());
$fields = ['csv-date-format', 'csv-has-headers', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
$this->call('GET', '/csv/download');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::index
*/
public function testIndex()
{
$this->be($this->user());
$this->call('GET', '/csv');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::initialParse
*/
public function testInitialParse()
{
$this->be($this->user());
$fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
$wizard->shouldReceive('processSelectedRoles')->once()->with([])->andReturn([1, 2, 3]);
$wizard->shouldReceive('processSelectedMapping')->once()->with([1, 2, 3], [])->andReturn([1, 2, 3]);
$this->call('POST', '/csv/initial_parse');
// should be redirect
$this->assertResponseStatus(302);
// should be redirected to mapping:
$this->assertRedirectedToRoute('csv.map');
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::initialParse
*/
public function testInitialParseNoMap()
{
$this->be($this->user());
$fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
$wizard->shouldReceive('processSelectedRoles')->once()->with([])->andReturn([1, 2, 3]);
$wizard->shouldReceive('processSelectedMapping')->once()->with([1, 2, 3], [])->andReturn([]);
$this->call('POST', '/csv/initial_parse');
// should be redirect
$this->assertResponseStatus(302);
// should be redirected to download config:
$this->assertRedirectedToRoute('csv.download-config-page');
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::map
*/
public function testMap()
{
$this->be($this->user());
$fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
$wizard->shouldReceive('showOptions')->once()->with([])->andReturn([]);
// mock Data and Reader
$reader = $this->mock('League\Csv\Reader');
$data = $this->mock('FireflyIII\Helpers\Csv\Data');
$data->shouldReceive('getReader')->once()->andReturn($reader);
$data->shouldReceive('getMap')->times(3)->andReturn([]);
$data->shouldReceive('hasHeaders')->once()->andReturn(true);
$wizard->shouldReceive('getMappableValues')->with($reader, [], true)->andReturn([]);
$data->shouldReceive('getMapped')->once()->andReturn([]);
$this->call('GET', '/csv/map');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::process
*/
public function testProcess()
{
$this->be($this->user());
$fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles', 'csv-mapped', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
// mock
$data = $this->mock('FireflyIII\Helpers\Csv\Data');
// mock
$importer = $this->mock('FireflyIII\Helpers\Csv\Importer');
$importer->shouldReceive('setData')->once()->with($data);
$importer->shouldReceive('run')->once()->withNoArgs();
$importer->shouldReceive('getRows')->once()->withNoArgs()->andReturn(0);
$importer->shouldReceive('getErrors')->once()->withNoArgs()->andReturn([]);
$importer->shouldReceive('getImported')->once()->withNoArgs()->andReturn(0);
$importer->shouldReceive('getJournals')->once()->withNoArgs()->andReturn(new Collection);
$this->call('GET', '/csv/process');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::saveMapping
*/
public function testSaveMapping()
{
$this->be($this->user());
$fields = ['csv-file', 'csv-date-format', 'csv-has-headers', 'csv-map', 'csv-roles', 'csv-delimiter'];
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('sessionHasValues')->once()->with($fields)->andReturn(true);
$this->call('POST', '/csv/save_mapping', ['mapping' => []]);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('csv.download-config-page');
}
/**
* @covers FireflyIII\Http\Controllers\CsvController::upload
*/
public function testUpload()
{
$this->be($this->user());
$wizard = $this->mock('FireflyIII\Helpers\Csv\WizardInterface');
$wizard->shouldReceive('storeCsvFile')->andReturn('');
// mock Data and Reader
$data = $this->mock('FireflyIII\Helpers\Csv\Data');
$data->shouldReceive('setCsvFileLocation')->once()->with('');
$data->shouldReceive('setDateFormat')->once()->with('Ymd');
$data->shouldReceive('setHasHeaders')->once()->with('');
$data->shouldReceive('setMap')->once()->with([]);
$data->shouldReceive('setMapped')->once()->with([]);
$data->shouldReceive('setRoles')->once()->with([]);
$data->shouldReceive('setSpecifix')->once()->with([]);
$data->shouldReceive('setImportAccount')->once()->with(0);
$data->shouldReceive('setDelimiter')->once()->with(',');
$file = new UploadedFile(storage_path('build/test-upload.csv'), 'test-file.csv', 'text/plain', 446);
$this->call('POST', '/csv/upload', ['date_format' => 'Ymd'], [], ['csv' => $file]);
// csv data set:
$this->assertResponseStatus(302);
}
}

View File

@ -1,134 +0,0 @@
<?php
/**
* CurrencyControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class CurrencyControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::create
* @covers FireflyIII\Http\Controllers\CurrencyController::__construct
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/currency/create');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::defaultCurrency
*/
public function testDefaultCurrency()
{
$this->be($this->user());
$this->call('GET', '/currency/default/2');
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('currency.index');
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/currency/delete/2');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::destroy
*/
public function testDestroy()
{
$this->session(['currency.delete.url' => 'http://localhost/currency']);
$this->be($this->user());
$this->call('POST', '/currency/destroy/3');
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('currency.index');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/currency/edit/2');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::index
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/currency');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::store
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::authorize
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::rules
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::getCurrencyData
*/
public function testStore()
{
$this->be($this->user());
$this->session(['currency.create.url' => 'http://localhost/currency']);
$args = [
'name' => 'New Euro.',
'symbol' => 'Y',
'code' => 'IUY',
];
$this->call('POST', '/currency/store', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('currency.index');
}
/**
* @covers FireflyIII\Http\Controllers\CurrencyController::update
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::authorize
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::rules
* @covers FireflyIII\Http\Requests\CurrencyFormRequest::getCurrencyData
*/
public function testUpdate()
{
$this->session(['currency.edit.url' => 'http://localhost/currency']);
$args = [
'id' => 1,
'name' => 'New Euro.',
'symbol' => 'Y',
'code' => 'IUY',
];
$this->be($this->user());
$this->call('POST', '/currency/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('currency.index');
}
}

View File

@ -1,39 +0,0 @@
<?php
/**
* HelpControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class HelpControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\HelpController::show
* @covers FireflyIII\Http\Controllers\HelpController::__construct
*/
public function testShow()
{
$this->be($this->user());
$this->call('GET', '/help/index');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\HelpController::show
*/
public function testShowNoRoute()
{
$this->be($this->user());
$this->call('GET', '/help/indxxex');
$this->assertResponseStatus(200);
}
}

View File

@ -1,57 +0,0 @@
<?php
/**
* HomeControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
class HomeControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\HomeController::dateRange
* @covers FireflyIII\Http\Controllers\HomeController::__construct
*/
public function testDateRange()
{
$this->be($this->user());
$args = [
'start' => '2012-01-01',
'end' => '2012-04-01',
];
// if date range is > 50, should have flash.
$this->call('POST', '/daterange', $args);
$this->assertResponseStatus(200);
$this->assertSessionHas('warning', '91 days of data may take a while to load.');
}
/**
* @covers FireflyIII\Http\Controllers\HomeController::flush
*/
public function testFlush()
{
$this->be($this->user());
$this->call('GET', '/flush');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\HomeController::index
* @covers FireflyIII\Http\Controllers\Controller::__construct
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/');
$this->assertResponseStatus(200);
}
}

View File

@ -1,177 +0,0 @@
<?php
/**
* JsonControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Illuminate\Support\Collection;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class JsonControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\JsonController::action
* @covers FireflyIII\Http\Controllers\JsonController::__construct
*/
public function testAction()
{
$this->be($this->user());
$this->call('GET', '/json/action');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxBillsPaid
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testBoxBillsPaid($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/json/box/bills-paid');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testBoxBillsUnpaid($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/json/box/bills-unpaid');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxIn
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testBoxIn($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/json/box/in');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::boxOut
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testBoxOut($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/json/box/out');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::categories
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testCategories($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/json/categories');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::endTour
*/
public function testEndTour()
{
$this->be($this->user());
$response = $this->call('POST', '/json/end-tour');
$this->assertResponseStatus(200);
$this->assertEquals('"true"', $response->content());
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::expenseAccounts
*/
public function testExpenseAccounts()
{
$this->be($this->user());
$this->call('GET', '/json/expense-accounts');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::revenueAccounts
*/
public function testRevenueAccounts()
{
$this->be($this->user());
$this->call('GET', '/json/revenue-accounts');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::tags
*/
public function testTags()
{
$this->be($this->user());
$this->call('GET', '/json/tags');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::tour
*/
public function testTour()
{
$this->be($this->user());
$this->call('GET', '/json/tour');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::transactionJournals
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testTransactionJournals($range)
{
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
$paginator = new \Illuminate\Pagination\LengthAwarePaginator(new Collection, 0, 40);
$repository->shouldReceive('getJournals')->withAnyArgs()->once()->andReturn($paginator);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/json/transaction-journals/deposit');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\JsonController::trigger
*/
public function testTrigger()
{
$this->be($this->user());
$this->call('GET', '/json/trigger');
$this->assertResponseStatus(200);
}
}

View File

@ -1,59 +0,0 @@
<?php
/**
* NewUserControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class NewUserControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\NewUserController::index
* @covers FireflyIII\Http\Controllers\NewUserController::__construct
*/
public function testIndex()
{
$this->be($this->emptyUser());
$this->call('GET', '/');
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('new-user.index');
}
/**
* @covers FireflyIII\Http\Controllers\NewUserController::index
*/
public function testIndexGo()
{
$this->be($this->emptyUser());
$this->call('GET', '/new-user');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\NewUserController::submit
* @covers FireflyIII\Http\Requests\NewUserFormRequest::authorize
* @covers FireflyIII\Http\Requests\NewUserFormRequest::rules
*/
public function testSubmit()
{
$this->be($this->emptyUser());
$args = [
'bank_name' => 'New bank',
'bank_balance' => 100,
'savings_balance' => 200,
'credit_card_limit' => 1000,
];
$this->call('POST', '/new-user/submit', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,198 +0,0 @@
<?php
/**
* PiggyBankControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class PiggyBankControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::add
* @covers FireflyIII\Http\Controllers\PiggyBankController::__construct
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testAdd($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/piggy-banks/add/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::create
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/piggy-banks/create');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/piggy-banks/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::destroy
*/
public function testDestroy()
{
$this->be($this->user());
$this->session(['piggy-banks.delete.url' => 'http://localhost']);
$this->call('POST', '/piggy-banks/destroy/2');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/piggy-banks/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::index
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/piggy-banks');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::order
*/
public function testOrder()
{
$args = [
1 => 1,
2 => 2,
];
$this->be($this->user());
$this->call('POST', '/piggy-banks/sort', $args);
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::postAdd
*/
public function testPostAdd()
{
$args = [
'amount' => 100,
];
$this->be($this->user());
$this->call('POST', '/piggy-banks/add/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::postRemove
*/
public function testPostRemove()
{
$args = [
'amount' => 100,
];
$this->be($this->user());
$this->call('POST', '/piggy-banks/remove/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::remove
*/
public function testRemove()
{
$this->be($this->user());
$this->call('GET', '/piggy-banks/remove/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::show
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testShow($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/piggy-banks/show/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::store
* @covers FireflyIII\Http\Requests\PiggyBankFormRequest::authorize
* @covers FireflyIII\Http\Requests\PiggyBankFormRequest::rules
*/
public function testStore()
{
$this->be($this->user());
$this->session(['piggy-banks.create.url' => 'http://localhost/']);
$args = [
'name' => 'New',
'targetamount' => 100,
'account_id' => 2,
];
$this->call('POST', '/piggy-banks/store', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\PiggyBankController::update
* @covers FireflyIII\Http\Requests\PiggyBankFormRequest::authorize
* @covers FireflyIII\Http\Requests\PiggyBankFormRequest::rules
*/
public function testUpdate()
{
$this->be($this->user());
$this->session(['piggy-banks.edit.url' => 'http://localhost/']);
$args = [
'name' => 'Updated',
'targetamount' => 100,
'account_id' => 2,
'id' => 1,
];
$this->call('POST', '/piggy-banks/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,50 +0,0 @@
<?php
/**
* PreferencesControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class PreferencesControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\PreferencesController::index
* @covers FireflyIII\Http\Controllers\PreferencesController::__construct
*/
public function testIndex()
{
$this->be($this->user());
$this->call('GET', '/preferences');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\PreferencesController::postIndex
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testPostIndex($range)
{
$args = [
'frontPageAccounts' => [1],
'viewRange' => $range,
'budgetMaximum' => 100,
'customFiscalYear' => 1,
'fiscalYearStart' => '01-01',
'language' => 'en_US',
];
$this->be($this->user());
$this->call('POST', '/preferences', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,83 +0,0 @@
<?php
/**
* ProfileControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class ProfileControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\ProfileController::changePassword
* @covers FireflyIII\Http\Controllers\ProfileController::__construct
*/
public function testChangePassword()
{
$this->be($this->user());
$this->call('GET', '/profile/change-password');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\ProfileController::deleteAccount
*/
public function testDeleteAccount()
{
$this->be($this->user());
$this->call('GET', '/profile/delete-account');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\ProfileController::index
*/
public function testIndex()
{
$this->be($this->user());
$this->call('GET', '/profile');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword
* @covers FireflyIII\Http\Requests\ProfileFormRequest::authorize
* @covers FireflyIII\Http\Requests\ProfileFormRequest::rules
*/
public function testPostChangePassword()
{
$args = [
'current_password' => 'james',
'new_password' => 'sander',
'new_password_confirmation' => 'sander',
];
$this->be($this->user());
$this->call('POST', '/profile/change-password', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount
* @covers FireflyIII\Http\Requests\DeleteAccountFormRequest::authorize
* @covers FireflyIII\Http\Requests\DeleteAccountFormRequest::rules
*/
public function testPostDeleteAccount()
{
$args = [
'password' => 'james',
];
$this->be($this->toBeDeletedUser());
$this->call('POST', '/profile/delete-account', $args);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('index');
$this->assertNull(DB::table('users')->find(3));
}
}

View File

@ -1,130 +0,0 @@
<?php
/**
* ReportControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use FireflyIII\Helpers\Collection\Account as AccountCollection;
use FireflyIII\Helpers\Collection\Balance;
use FireflyIII\Helpers\Collection\Bill as BillCollection;
use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
use Illuminate\Support\Collection;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class ReportControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\ReportController::index
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/reports');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\ReportController::__construct
* @covers FireflyIII\Http\Controllers\ReportController::report
* @covers FireflyIII\Http\Controllers\ReportController::defaultMonth
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testReportDefaultMonth($range)
{
// mock some stuff.
$accountHelper = $this->mock('FireflyIII\Helpers\Report\AccountReportHelperInterface');
$budgetHelper = $this->mock('FireflyIII\Helpers\Report\BudgetReportHelperInterface');
$balanceHelper = $this->mock('FireflyIII\Helpers\Report\BalanceReportHelperInterface');
$defaultHelper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
$accountHelper->shouldReceive('getAccountReport')->once()->andReturn(new AccountCollection);
$defaultHelper->shouldReceive('getIncomeReport')->once()->andReturn(new Income);
$defaultHelper->shouldReceive('getExpenseReport')->once()->andReturn(new Expense);
$budgetHelper->shouldReceive('getBudgetReport')->once()->andReturn(new BudgetCollection);
$defaultHelper->shouldReceive('getCategoryReport')->once()->andReturn(new CategoryCollection);
$balanceHelper->shouldReceive('getBalanceReport')->once()->andReturn(new Balance);
$defaultHelper->shouldReceive('getBillReport')->once()->andReturn(new BillCollection);
$defaultHelper->shouldReceive('tagReport')->once()->andReturn([]);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/reports/report/default/20160101/20160131/1,2');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\ReportController::report
* @covers FireflyIII\Http\Controllers\ReportController::defaultMultiYear
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testReportDefaultMultiYear($range)
{
$this->be($this->user());
// mock some stuff.
$accountHelper = $this->mock('FireflyIII\Helpers\Report\AccountReportHelperInterface');
$defaultHelper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
$budgetRepos = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$categoryRepos = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$budgetRepos->shouldReceive('getActiveBudgets')->once()->andReturn(new Collection);
$categoryRepos->shouldReceive('getCategories')->once()->andReturn(new Collection);
$accountHelper->shouldReceive('getAccountReport')->once()->andReturn(new AccountCollection);
$defaultHelper->shouldReceive('getIncomeReport')->once()->andReturn(new Income);
$defaultHelper->shouldReceive('getExpenseReport')->once()->andReturn(new Expense);
$defaultHelper->shouldReceive('tagReport')->once()->andReturn([]);
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/reports/report/default/20160101/20171231/1,2');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\ReportController::report
* @covers FireflyIII\Http\Controllers\ReportController::defaultYear
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testReportDefaultYear($range)
{
// mock some stuff.
$accountHelper = $this->mock('FireflyIII\Helpers\Report\AccountReportHelperInterface');
$defaultHelper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
$accountHelper->shouldReceive('getAccountReport')->once()->andReturn(new AccountCollection);
$defaultHelper->shouldReceive('getIncomeReport')->once()->andReturn(new Income);
$defaultHelper->shouldReceive('getCategoriesWithExpenses')->andReturn(new Collection);
$defaultHelper->shouldReceive('getExpenseReport')->once()->andReturn(new Expense);
$defaultHelper->shouldReceive('tagReport')->once()->andReturn([]);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/reports/report/default/20160101/20161231/1,2');
$this->assertResponseStatus(200);
}
}

View File

@ -1,177 +0,0 @@
<?php
/**
* RuleControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
*/
class RuleControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\RuleController::__construct
* @covers FireflyIII\Http\Controllers\RuleController::create
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/rules/create/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/rules/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::destroy
*/
public function testDestroy()
{
$this->session(['rules.rule.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('POST', '/rules/destroy/1');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::down
*/
public function testDown()
{
$this->be($this->user());
$this->call('GET', '/rules/down/1');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::edit
* @covers FireflyIII\Http\Controllers\RuleController::getCurrentTriggers
* @covers FireflyIII\Http\Controllers\RuleController::getCurrentActions
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/rules/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::index
* @covers FireflyIII\Http\Controllers\RuleController::createDefaultRuleGroup
* @covers FireflyIII\Http\Controllers\RuleController::createDefaultRule
*/
public function testIndex()
{
$this->be($this->user());
$this->call('GET', '/rules');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::reorderRuleActions
*/
public function testReorderRuleActions()
{
$this->be($this->user());
$args = ['actions' => [1, 2, 3]];
$this->call('POST', '/rules/action/order/1', $args);
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::reorderRuleTriggers
*/
public function testReorderRuleTriggers()
{
$this->be($this->user());
$args = ['actions' => [1, 2]];
$this->call('POST', '/rules/trigger/order/1', $args);
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::store
* @covers FireflyIII\Http\Requests\RuleFormRequest::authorize
* @covers FireflyIII\Http\Requests\RuleFormRequest::rules
*/
public function testStore()
{
$this->session(['rules.rule.create.url' => 'http://localhost']);
$this->be($this->user());
$args = [
'rule_group_id' => 1,
'title' => 'Some new rule',
'user_id' => 1,
'trigger' => 'store-journal',
'description' => 'Some new rule',
'rule-trigger' => ['description_is'],
'rule-trigger-value' => ['something'],
'rule-trigger-stop' => [],
'rule-action' => ['set_category'],
'rule-action-value' => ['something'],
'rule-action-stop' => [],
'stop_processing' => 0,
];
$this->call('POST', '/rules/store/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::up
*/
public function testUp()
{
$this->be($this->user());
$this->call('GET', '/rules/up/1');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\RuleController::update
* @covers FireflyIII\Http\Requests\RuleFormRequest::authorize
* @covers FireflyIII\Http\Requests\RuleFormRequest::rules
*/
public function testUpdate()
{
$this->session(['rules.rule.edit.url' => 'http://localhost']);
$this->be($this->user());
$args = [
'title' => 'Some new rule update',
'rule_group_id' => 1,
'id' => 1,
'active' => 1,
'trigger' => 'store-journal',
'description' => 'Some new rule',
'rule-trigger' => ['description_is'],
'rule-trigger-value' => ['something'],
'rule-trigger-stop' => [],
'rule-action' => ['set_category'],
'rule-action-value' => ['something'],
'rule-action-stop' => [],
'stop_processing' => 0,
];
$this->call('POST', '/rules/update/1', $args);
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
}

View File

@ -1,120 +0,0 @@
<?php
/**
* RuleGroupControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:29.
*/
class RuleGroupControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::create
* @covers FireflyIII\Http\Controllers\RuleGroupController::__construct
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/rule-groups/create');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/rule-groups/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::destroy
*/
public function testDestroy()
{
$this->session(['rules.rule-group.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('POST', '/rule-groups/destroy/1');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::down
*/
public function testDown()
{
$this->be($this->user());
$this->call('GET', '/rule-groups/down/1');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/rule-groups/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::store
* @covers FireflyIII\Http\Requests\RuleGroupFormRequest::authorize
* @covers FireflyIII\Http\Requests\RuleGroupFormRequest::rules
*/
public function testStore()
{
$this->session(['rules.rule-group.create.url' => 'http://localhost']);
$args = [
'title' => 'Some new rule group',
'description' => 'New rules',
];
$this->be($this->user());
$this->call('POST', '/rule-groups/store', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::up
*/
public function testUp()
{
$this->be($this->user());
$this->call('GET', '/rule-groups/up/1');
$this->assertResponseStatus(302);
}
/**
* @covers FireflyIII\Http\Controllers\RuleGroupController::update
* @covers FireflyIII\Http\Requests\RuleGroupFormRequest::authorize
* @covers FireflyIII\Http\Requests\RuleGroupFormRequest::rules
*/
public function testUpdate()
{
$this->session(['rules.rule-group.edit.url' => 'http://localhost']);
$args = [
'id' => 1,
'title' => 'Some new rule group X',
'description' => 'New rules',
'active' => 1,
];
$this->be($this->user());
$this->call('POST', '/rule-groups/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,34 +0,0 @@
<?php
/**
* SearchControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Illuminate\Support\Collection;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:29.
*/
class SearchControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\SearchController::__construct
* @covers FireflyIII\Http\Controllers\SearchController::index
*/
public function testIndex()
{
$searcher = $this->mock('FireflyIII\Support\Search\SearchInterface');
$searcher->shouldReceive('searchTransactions')->once()->with(['test'])->andReturn(new Collection);
$searcher->shouldReceive('searchAccounts')->once()->with(['test'])->andReturn(new Collection);
$searcher->shouldReceive('searchCategories')->once()->with(['test'])->andReturn(new Collection);
$searcher->shouldReceive('searchBudgets')->once()->with(['test'])->andReturn(new Collection);
$searcher->shouldReceive('searchTags')->once()->with(['test'])->andReturn(new Collection);
$this->be($this->user());
$this->call('GET', '/search?q=test&search=');
$this->assertResponseStatus(200);
}
}

View File

@ -1,129 +0,0 @@
<?php
/**
* TagControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:29.
*/
class TagControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\TagController::__construct
* @covers FireflyIII\Http\Controllers\TagController::create
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/tags/create');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TagController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/tags/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TagController::destroy
*/
public function testDestroy()
{
$this->be($this->user());
$this->call('POST', '/tags/destroy/1');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\TagController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/tags/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TagController::hideTagHelp
*/
public function testHideTagHelp()
{
$this->be($this->user());
$this->call('POST', '/tags/hideTagHelp/true');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TagController::index
*/
public function testIndex()
{
$this->be($this->user());
$this->call('GET', '/tags');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TagController::show
*/
public function testShow()
{
$this->be($this->user());
$this->call('GET', '/tags/show/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TagController::store
* @covers FireflyIII\Http\Requests\TagFormRequest::authorize
* @covers FireflyIII\Http\Requests\TagFormRequest::rules
*/
public function testStore()
{
$args = [
'tag' => 'Some new tag',
'tagMode' => 'nothing',
];
$this->session(['tags.create.url' => 'http://localhost']);
$this->be($this->user());
$this->call('POST', '/tags/store', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\TagController::update
* @covers FireflyIII\Http\Requests\TagFormRequest::authorize
* @covers FireflyIII\Http\Requests\TagFormRequest::rules
*/
public function testUpdate()
{
$args = [
'tag' => 'Some new tag yay',
'id' => 1,
'tagMode' => 'nothing',
];
$this->session(['tags.edit.url' => 'http://localhost']);
$this->be($this->user());
$this->call('POST', '/tags/update/1', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@ -1,157 +0,0 @@
<?php
/**
* TransactionControllerTest.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
use Illuminate\Pagination\LengthAwarePaginator;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:29.
*/
class TransactionControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\TransactionController::create
* @covers FireflyIII\Http\Controllers\TransactionController::__construct
*/
public function testCreate()
{
$this->be($this->user());
$this->call('GET', '/transactions/create/withdrawal');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', '/transaction/delete/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::destroy
*/
public function testDestroy()
{
$this->session(['transactions.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('POST', '/transaction/destroy/1');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', '/transaction/edit/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::index
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testIndex($range)
{
$journals = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
$journals->shouldReceive('getJournals')->once()->andReturn(new LengthAwarePaginator([], 0, 50));
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/transactions/deposit');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::reorder
*/
public function testReorder()
{
$args = [
'ids' => [1],
'date' => '2015-01-01',
];
$this->be($this->user());
$this->call('POST', '/transaction/reorder', $args);
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::show
* @dataProvider dateRangeProvider
*
* @param $range
*/
public function testShow($range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', '/transaction/show/1');
$this->assertResponseStatus(200);
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::store
* @covers FireflyIII\Http\Requests\JournalFormRequest::authorize
* @covers FireflyIII\Http\Requests\JournalFormRequest::rules
* @covers FireflyIII\Http\Requests\JournalFormRequest::getJournalData
*/
public function testStore()
{
$this->session(['transactions.create.url' => 'http://localhost']);
$args = [
'what' => 'withdrawal',
'description' => 'Something',
'source_account_id' => '1',
'destination_account_name' => 'Some expense',
'amount' => 100,
'amount_currency_id_amount' => 1,
'date' => '2015-01-01',
];
$this->be($this->user());
$this->call('POST', '/transactions/store/withdrawal', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\TransactionController::update
* @covers FireflyIII\Http\Requests\JournalFormRequest::authorize
* @covers FireflyIII\Http\Requests\JournalFormRequest::rules
* @covers FireflyIII\Http\Requests\JournalFormRequest::getJournalData
*/
public function testUpdate()
{
$this->session(['transactions.edit.url' => 'http://localhost']);
$args = [
'what' => 'withdrawal',
'id' => 4,
'description' => 'Something new',
'source_account_id' => '1',
'destination_account_name' => 'Some expense account',
'amount' => 100,
'amount_currency_id_amount' => 1,
'date' => '2015-01-01',
];
$this->be($this->user());
$this->call('POST', '/transaction/update/4', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}