mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
With a little luck this will cover a lot.
This commit is contained in:
@@ -35,15 +35,8 @@ class Amount
|
|||||||
*/
|
*/
|
||||||
public function getCurrencySymbol()
|
public function getCurrencySymbol()
|
||||||
{
|
{
|
||||||
if (defined('FFCURRENCYSYMBOL')) {
|
|
||||||
return FFCURRENCYSYMBOL; // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
|
|
||||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||||
|
|
||||||
define('FFCURRENCYSYMBOL', $currency->symbol);
|
|
||||||
|
|
||||||
return $currency->symbol;
|
return $currency->symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,18 +141,12 @@ class Amount
|
|||||||
*/
|
*/
|
||||||
public function getCurrencyCode()
|
public function getCurrencyCode()
|
||||||
{
|
{
|
||||||
if (defined('FFCURRENCYCODE')) {
|
|
||||||
return FFCURRENCYCODE; // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
|
||||||
|
|
||||||
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
|
||||||
if ($currency) {
|
if ($currency) {
|
||||||
|
|
||||||
define('FFCURRENCYCODE', $currency->code);
|
|
||||||
|
|
||||||
return $currency->code;
|
return $currency->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ use Eloquent;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use Input;
|
use Input;
|
||||||
|
use RuntimeException;
|
||||||
use Session;
|
use Session;
|
||||||
use View;
|
use View;
|
||||||
|
|
||||||
@@ -109,10 +110,17 @@ class ExpandedForm
|
|||||||
$preFilled = Session::get('preFilled');
|
$preFilled = Session::get('preFilled');
|
||||||
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
|
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
|
||||||
}
|
}
|
||||||
if (!is_null(Input::old($name))) {
|
// @codeCoverageIgnoreStart
|
||||||
$value = Input::old($name);
|
try {
|
||||||
|
if (!is_null(Input::old($name))) {
|
||||||
|
$value = Input::old($name);
|
||||||
|
}
|
||||||
|
} catch (RuntimeException $e) {
|
||||||
|
// don't care about session errors.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,24 +257,6 @@ class ExpandedForm
|
|||||||
return $selectList;
|
return $selectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $name
|
|
||||||
* @param null $value
|
|
||||||
* @param array $options
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function month($name, $value = null, array $options = [])
|
|
||||||
{
|
|
||||||
$label = $this->label($name, $options);
|
|
||||||
$options = $this->expandOptionArray($name, $label, $options);
|
|
||||||
$classes = $this->getHolderClasses($name);
|
|
||||||
$value = $this->fillFieldValue($name, $value);
|
|
||||||
$html = View::make('form.month', compact('classes', 'name', 'label', 'value', 'options'))->render();
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param array $list
|
* @param array $list
|
||||||
@@ -274,7 +264,6 @@ class ExpandedForm
|
|||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @internal param null $value
|
|
||||||
*/
|
*/
|
||||||
public function multiRadio($name, array $list = [], $selected = null, array $options = [])
|
public function multiRadio($name, array $list = [], $selected = null, array $options = [])
|
||||||
{
|
{
|
||||||
@@ -297,7 +286,16 @@ class ExpandedForm
|
|||||||
*/
|
*/
|
||||||
public function optionsList($type, $name)
|
public function optionsList($type, $name)
|
||||||
{
|
{
|
||||||
$previousValue = Input::old('post_submit_action');
|
$previousValue = null;
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
try {
|
||||||
|
$previousValue = Input::old('post_submit_action');
|
||||||
|
} catch (RuntimeException $e) {
|
||||||
|
// don't care
|
||||||
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
$previousValue = is_null($previousValue) ? 'store' : $previousValue;
|
$previousValue = is_null($previousValue) ? 'store' : $previousValue;
|
||||||
$html = View::make('form.options', compact('type', 'name', 'previousValue'))->render();
|
$html = View::make('form.options', compact('type', 'name', 'previousValue'))->render();
|
||||||
|
|
||||||
|
@@ -10,4 +10,10 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px
|
padding: 0px
|
||||||
}
|
}
|
||||||
|
.medium {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.panel-link {color:#fff;text-decoration: none;}
|
||||||
|
a.panel-link:hover {color:#fff;text-decoration: none;}
|
@@ -233,6 +233,7 @@ return [
|
|||||||
'balanceFor' => 'Balance for :name',
|
'balanceFor' => 'Balance for :name',
|
||||||
|
|
||||||
// piggy banks:
|
// piggy banks:
|
||||||
|
'piggy_bank' => 'Piggy bank',
|
||||||
'new_piggy_bank' => 'Create new piggy bank',
|
'new_piggy_bank' => 'Create new piggy bank',
|
||||||
'account_status' => 'Account status',
|
'account_status' => 'Account status',
|
||||||
'left_for_piggy_banks' => 'Left for piggy banks',
|
'left_for_piggy_banks' => 'Left for piggy banks',
|
||||||
|
@@ -170,7 +170,7 @@ return [
|
|||||||
'Withdrawal' => 'Uitgave',
|
'Withdrawal' => 'Uitgave',
|
||||||
'Deposit' => 'Inkomsten',
|
'Deposit' => 'Inkomsten',
|
||||||
'Transfer' => 'Overschrijving',
|
'Transfer' => 'Overschrijving',
|
||||||
'bill' => 'Contracten',
|
'bill' => 'Contract',
|
||||||
'yes' => 'Ja',
|
'yes' => 'Ja',
|
||||||
'no' => 'Nee',
|
'no' => 'Nee',
|
||||||
'amount' => 'Bedrag',
|
'amount' => 'Bedrag',
|
||||||
@@ -242,6 +242,7 @@ return [
|
|||||||
'balanceFor' => 'Saldo op :name',
|
'balanceFor' => 'Saldo op :name',
|
||||||
|
|
||||||
// piggy banks:
|
// piggy banks:
|
||||||
|
'piggy_bank' => 'Spaarpotje',
|
||||||
'new_piggy_bank' => 'Nieuw spaarpotje',
|
'new_piggy_bank' => 'Nieuw spaarpotje',
|
||||||
'account_status' => 'Rekeningoverzicht',
|
'account_status' => 'Rekeningoverzicht',
|
||||||
'left_for_piggy_banks' => 'Over voor spaarpotjes',
|
'left_for_piggy_banks' => 'Over voor spaarpotjes',
|
||||||
|
@@ -25,6 +25,8 @@ class AmountSupportTest extends TestCase
|
|||||||
$this->object = new Amount;
|
$this->object = new Amount;
|
||||||
$user = FactoryMuffin::create('FireflyIII\User');
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
$this->be($user);
|
$this->be($user);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
202
tests/support/ExpandedFormTest.php
Normal file
202
tests/support/ExpandedFormTest.php
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
<?php
|
||||||
|
use FireflyIII\Support\ExpandedForm;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ExpandedFormTest
|
||||||
|
*/
|
||||||
|
class ExpandedFormTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ExpandedForm
|
||||||
|
*/
|
||||||
|
protected $object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->object = new ExpandedForm;
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::amount
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::label
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::expandOptionArray
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::getHolderClasses
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::fillFieldValue
|
||||||
|
*/
|
||||||
|
public function testAmount()
|
||||||
|
{
|
||||||
|
$result = $this->object->amount('abcde', '12.23', ['label' => 'Some Label']);
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($result, '23'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::balance
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::label
|
||||||
|
*/
|
||||||
|
public function testBalance()
|
||||||
|
{
|
||||||
|
$result = $this->object->balance('abcde', '12.23', []);
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($result, '23'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::checkbox
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::getHolderClasses
|
||||||
|
*/
|
||||||
|
public function testCheckbox()
|
||||||
|
{
|
||||||
|
// add error to session for this thing:
|
||||||
|
$errors = new MessageBag;
|
||||||
|
$errors->add('abcde', 'Some error here.');
|
||||||
|
$this->session(['errors' => $errors]);
|
||||||
|
|
||||||
|
$result = $this->object->checkbox('abcde', 1, true);
|
||||||
|
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($result, 'checked="checked"'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::date
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::fillFieldValue
|
||||||
|
*/
|
||||||
|
public function testDate()
|
||||||
|
{
|
||||||
|
$preFilled = [
|
||||||
|
'abcde' => '1998-01-01'
|
||||||
|
];
|
||||||
|
$this->session(['preFilled' => $preFilled]);
|
||||||
|
|
||||||
|
$result = $this->object->date('abcde');
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($result, '1998'));
|
||||||
|
$this->assertTrue(str_contains($result, 'type="date"'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::integer
|
||||||
|
*/
|
||||||
|
public function testInteger()
|
||||||
|
{
|
||||||
|
$result = $this->object->integer('abcde', 12345);
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($result, '12345'));
|
||||||
|
$this->assertTrue(str_contains($result, 'type="number"'));
|
||||||
|
$this->assertTrue(str_contains($result, 'step="1"'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::location
|
||||||
|
*/
|
||||||
|
public function testLocation()
|
||||||
|
{
|
||||||
|
$result = $this->object->location('abcde');
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($result, 'id="clearLocation"'));
|
||||||
|
$this->assertTrue(str_contains($result, 'id="map-canvas"'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::makeSelectList
|
||||||
|
*/
|
||||||
|
public function testMakeSelectList()
|
||||||
|
{
|
||||||
|
$collection = new Collection;
|
||||||
|
for ($i = 0; $i < 5; $i++) {
|
||||||
|
$collection->push(FactoryMuffin::create('FireflyIII\Models\Account'));
|
||||||
|
}
|
||||||
|
$result = $this->object->makeSelectList($collection, true);
|
||||||
|
|
||||||
|
$this->assertCount(6, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::multiRadio
|
||||||
|
*/
|
||||||
|
public function testMultiRadio()
|
||||||
|
{
|
||||||
|
$list = [
|
||||||
|
'some' => 'BlaBla',
|
||||||
|
'other' => 'ThisIsCool'
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = $this->object->multiRadio('abcde', $list);
|
||||||
|
|
||||||
|
$this->assertTrue(str_contains($result, 'ThisIsCool'));
|
||||||
|
$this->assertTrue(str_contains($result, 'other'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::optionsList
|
||||||
|
*/
|
||||||
|
public function testOptionsList()
|
||||||
|
{
|
||||||
|
$result = $this->object->optionsList('update', 'MotorCycle');
|
||||||
|
$this->assertTrue(str_contains($result, 'MotorCycle'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::select
|
||||||
|
*/
|
||||||
|
public function testSelect()
|
||||||
|
{
|
||||||
|
$list = [
|
||||||
|
'some' => 'BlaBla',
|
||||||
|
'other' => 'ThisIsCool'
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = $this->object->select('abcde', $list);
|
||||||
|
$this->assertTrue(str_contains($result, 'ThisIsCool'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::tags
|
||||||
|
*/
|
||||||
|
public function testTags()
|
||||||
|
{
|
||||||
|
$result = $this->object->tags('abcde', 'some,tags');
|
||||||
|
$this->assertTrue(str_contains($result, 'data-role="tagsinput"'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::text
|
||||||
|
*/
|
||||||
|
public function testText()
|
||||||
|
{
|
||||||
|
$result = $this->object->text('abcde', 'MotorBike!');
|
||||||
|
$this->assertTrue(str_contains($result, 'MotorBike!'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers FireflyIII\Support\ExpandedForm::textarea
|
||||||
|
*/
|
||||||
|
public function testTextarea()
|
||||||
|
{
|
||||||
|
$result = $this->object->textarea('abcde', 'Pillow fight!');
|
||||||
|
$this->assertTrue(str_contains($result, 'Pillow fight!'));
|
||||||
|
$this->assertTrue(str_contains($result, 'abcde_holder'));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user