This should fix all twig tests. Let's find out!

This commit is contained in:
James Cole 2015-05-02 19:44:12 +02:00
parent efe6f59f79
commit c7ae15a41a
12 changed files with 123 additions and 10 deletions

View File

@ -8,6 +8,7 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Support\Collection;
use Input;
use Preferences;
use Redirect;
@ -190,7 +191,9 @@ class BudgetController extends Controller
$journals = $repository->getJournals($budget, $repetition);
$limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget);
$subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name);
$journals->setPath('/budgets/show/'.$budget->id);
if (!$journals instanceof Collection) {
$journals->setPath('/budgets/show/' . $budget->id);
}
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
}

View File

@ -160,12 +160,15 @@ class Amount
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
if ($currency) {
\Cache::forever('FFCURRENCYCODE', $currency->code);
Cache::forever('FFCURRENCYCODE', $currency->code);
define('FFCURRENCYCODE', $currency->code);
define('FFCURRENCYCODE', $currency->code);
return $currency->code;
}
return $currency->code;
return 'EUR';
}
public function getDefaultCurrency()

View File

@ -7,7 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">

View File

@ -0,0 +1,44 @@
{% extends "./layout/default.twig" %}
{% block content %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, category) }}
{{ Form.model(category, {'class' : 'form-horizontal','id' : 'update','url' : route('categories.update',category.id)}) }}
<input type="hidden" name="id" value="{{ category.id }}" />
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="panel panel-primary">
<div class="panel-heading">
<i class="fa fa-exclamation"></i> Mandatory fields
</div>
<div class="panel-body">
{{ ExpandedForm.text('name') }}
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<!-- panel for options -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bolt"></i> Options
</div>
<div class="panel-body">
{{ ExpandedForm.optionsList('update','category') }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<p>
<button type="submit" class="btn btn-lg btn-success">
Update category
</button>
</p>
</div>
</div>
</form>
{% endblock %}

18
resources/twig/error.twig Normal file
View File

@ -0,0 +1,18 @@
{% extends "./layout/guest.twig" %}
{% block content %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h1 class="text-danger">Firefly<br/>
<small>Error</small>
</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
{{ message |default('General unknown errror') }}
</div>
</div>
{% endblock %}

View File

@ -1,5 +1,7 @@
<?php
use Carbon\Carbon;
use FireflyIII\Models\TransactionCurrency;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
@ -31,13 +33,23 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
parent::setUp();
// if the database copy does not exist, call migrate.
$copy = __DIR__.'/../storage/database/testing-copy.db';
$original = __DIR__.'/../storage/database/testing.db';
$copy = __DIR__ . '/../storage/database/testing-copy.db';
$original = __DIR__ . '/../storage/database/testing.db';
FactoryMuffin::loadFactories(__DIR__ . '/factories');
if (!file_exists($copy)) {
Log::debug('Created new database.');
touch($original);
Artisan::call('migrate');
copy($original, $copy);
// create EUR currency
/** @var TransactionCurrency $currency */
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$currency->code = 'EUR';
$currency->save();
Log::debug('Created new EUR currency.');
} else {
if (file_exists($copy)) {
copy($copy, $original);
@ -45,7 +57,16 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
}
// if the database copy does exists, copy back as original.
FactoryMuffin::loadFactories(__DIR__ . '/factories');
$this->session(
[
'start' => Carbon::now()->startOfMonth(),
'end' => Carbon::now()->endOfMonth(),
'first' => Carbon::now()->startOfYear()
]
);
}

View File

@ -69,6 +69,7 @@ class AccountControllerTest extends TestCase
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/accounts/create/asset');
$this->assertResponseOk();
@ -127,6 +128,7 @@ class AccountControllerTest extends TestCase
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
// get edit page:
$this->call('GET', '/accounts/edit/' . $this->account->id);
@ -153,7 +155,7 @@ class AccountControllerTest extends TestCase
$repository->shouldReceive('getLastActivity')->andReturn(null);
Amount::shouldReceive('format')->andReturn('');
Amount::shouldReceive('getCurrencyCode')->once()->andReturn('A');
Amount::shouldReceive('getCurrencyCode')->andReturn('A');
// put stuff in session:
@ -172,7 +174,7 @@ class AccountControllerTest extends TestCase
$this->be($this->account->user);
// mock!
Amount::shouldReceive('getCurrencyCode')->once()->andReturn('A');
Amount::shouldReceive('getCurrencyCode')->andReturn('A');
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('getJournals')->andReturn(new LengthAwarePaginator([], 0, 10));

View File

@ -72,6 +72,7 @@ class BillControllerTest extends TestCase
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/bills/create');
$this->assertViewHas('subTitle', 'Create new');
@ -111,6 +112,7 @@ class BillControllerTest extends TestCase
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/bills/edit/' . $bill->id);
$this->assertViewHas('subTitle', 'Edit "' . e($bill->name) . '"');
@ -126,6 +128,7 @@ class BillControllerTest extends TestCase
$collection->push($bill);
Amount::shouldReceive('format')->andReturn('XX');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
$repository->shouldReceive('getBills')->once()->andReturn($collection);
@ -187,6 +190,8 @@ class BillControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('XX');
Amount::shouldReceive('getCurrencyCode')->andReturn('XX');
$this->call('GET', '/bills/show/' . $bill->id);
}

View File

@ -115,6 +115,7 @@ class BudgetControllerTest extends TestCase
$repository->shouldReceive('getCurrentRepetition')->once();
Amount::shouldReceive('getCurrencySymbol')->andReturn('x');
Amount::shouldReceive('format')->andReturn('x');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/budgets');
$this->assertResponseOk();
@ -304,6 +305,10 @@ class BudgetControllerTest extends TestCase
$pref = FactoryMuffin::create('FireflyIII\Models\Preference');
Preferences::shouldReceive('get')->withArgs(['budgetIncomeTotal' . $date, 1000])->andReturn($pref);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/budgets/income');
$this->assertResponseOk();

View File

@ -56,6 +56,7 @@ class JsonControllerTest extends TestCase
$accounts->shouldReceive('getCreditCards')->andReturn($ccs);
$accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Steam::shouldReceive('balance')->andReturn(0);
@ -83,6 +84,7 @@ class JsonControllerTest extends TestCase
$bills->shouldReceive('createFakeBill')->andReturn($bill);
$accounts->shouldReceive('getCreditCards')->andReturn($ccs);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Steam::shouldReceive('balance')->andReturn(-1);
$this->call('GET', '/json/box/bills-unpaid');
@ -97,6 +99,7 @@ class JsonControllerTest extends TestCase
$repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
$repository->shouldReceive('incomeByPeriod')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/json/box/in');
$this->assertResponseOk();
@ -110,6 +113,7 @@ class JsonControllerTest extends TestCase
$repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
$repository->shouldReceive('journalsByExpenseAccount')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/json/box/out');
$this->assertResponseOk();

View File

@ -50,6 +50,8 @@ class PiggyBankControllerTest extends TestCase
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('leftOnAccount')->withAnyArgs()->andReturn(12);
Amount::shouldReceive('format')->andReturn('XXxx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/piggy-banks/add/' . $piggyBank->id);
$this->assertResponseOk();
@ -179,6 +181,7 @@ class PiggyBankControllerTest extends TestCase
Steam::shouldReceive('balance')->andReturn(20);
$accounts->shouldReceive('leftOnAccount')->andReturn(12);
Amount::shouldReceive('format')->andReturn('123');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/piggy-banks');
@ -218,6 +221,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBanks->shouldReceive('createEvent')->once();
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe']);
$this->assertResponseStatus(302);
@ -235,6 +239,7 @@ class PiggyBankControllerTest extends TestCase
$piggyBanks->shouldReceive('createEvent')->once();
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']);
$this->assertResponseStatus(302);
@ -283,6 +288,8 @@ class PiggyBankControllerTest extends TestCase
$this->be($piggyBank->account->user);
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/piggy-banks/remove/' . $piggyBank->id);
$this->assertResponseOk();

View File

@ -55,6 +55,7 @@ class PreferencesControllerTest extends TestCase
Preferences::shouldReceive('get')->once()->withArgs(['budgetMaximum', 1000])->andReturn($pref);
Preferences::shouldReceive('get')->once()->withArgs(['currencyPreference', 'EUR'])->andReturn($pref);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection);
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);