Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
With a little luck this will cover a lot.
James Cole596cd0948932
diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex c9a494f3f5..c823d7736a 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -35,15 +35,8 @@ class Amount*/public function getCurrencySymbol(){- if (defined('FFCURRENCYSYMBOL')) {- return FFCURRENCYSYMBOL; // @codeCoverageIgnore- }-$currencyPreference = Prefs::get('currencyPreference', 'EUR');$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();-- define('FFCURRENCYSYMBOL', $currency->symbol);-return $currency->symbol;}@@ -148,18 +141,12 @@ class Amount*/public function getCurrencyCode(){- if (defined('FFCURRENCYCODE')) {- return FFCURRENCYCODE; // @codeCoverageIgnore- }-$currencyPreference = Prefs::get('currencyPreference', 'EUR');$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();if ($currency) {- define('FFCURRENCYCODE', $currency->code);-return $currency->code;}diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.phpindex bac40078a4..1e65ebf1aa 100644--- a/app/Support/ExpandedForm.php+++ b/app/Support/ExpandedForm.php@@ -7,6 +7,7 @@ use Eloquent;use Illuminate\Support\Collection;use Illuminate\Support\MessageBag;use Input;+use RuntimeException;use Session;use View;@@ -109,10 +110,17 @@ class ExpandedForm$preFilled = Session::get('preFilled');$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;}- if (!is_null(Input::old($name))) {- $value = Input::old($name);+ // @codeCoverageIgnoreStart+ try {+ if (!is_null(Input::old($name))) {+ $value = Input::old($name);+ }+ } catch (RuntimeException $e) {+ // don't care about session errors.}+ // @codeCoverageIgnoreEnd+return $value;}@@ -249,24 +257,6 @@ class ExpandedFormreturn $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 array $list@@ -274,7 +264,6 @@ class ExpandedForm* @param array $options** @return string- * @internal param null $value*/public function multiRadio($name, array $list = [], $selected = null, array $options = []){@@ -297,7 +286,16 @@ class ExpandedForm*/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;$html = View::make('form.options', compact('type', 'name', 'previousValue'))->render();diff --git a/public/css/firefly.css b/public/css/firefly.cssindex 09359d29db..bb147ee849 100644--- a/public/css/firefly.css+++ b/public/css/firefly.css@@ -10,4 +10,10 @@height: 100%;margin: 0px;padding: 0px-}\ No newline at end of file+}+.medium {+ font-size: 16px;+}++a.panel-link {color:#fff;text-decoration: none;}+a.panel-link:hover {color:#fff;text-decoration: none;}\ No newline at end of filediff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.phpindex 48d6bb7359..28970efa4f 100644--- a/resources/lang/en/firefly.php+++ b/resources/lang/en/firefly.php@@ -233,6 +233,7 @@ return ['balanceFor' => 'Balance for :name',// piggy banks:+ 'piggy_bank' => 'Piggy bank','new_piggy_bank' => 'Create new piggy bank','account_status' => 'Account status','left_for_piggy_banks' => 'Left for piggy banks',diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.phpindex 7db9587382..9b36c7f94e 100644--- a/resources/lang/nl/firefly.php+++ b/resources/lang/nl/firefly.php@@ -170,7 +170,7 @@ return ['Withdrawal' => 'Uitgave','Deposit' => 'Inkomsten','Transfer' => 'Overschrijving',- 'bill' => 'Contracten',+ 'bill' => 'Contract','yes' => 'Ja','no' => 'Nee','amount' => 'Bedrag',@@ -242,6 +242,7 @@ return ['balanceFor' => 'Saldo op :name',// piggy banks:+ 'piggy_bank' => 'Spaarpotje','new_piggy_bank' => 'Nieuw spaarpotje','account_status' => 'Rekeningoverzicht','left_for_piggy_banks' => 'Over voor spaarpotjes',diff --git a/tests/support/AmountSupportTest.php b/tests/support/AmountSupportTest.phpindex e297291b19..63631e0578 100644--- a/tests/support/AmountSupportTest.php+++ b/tests/support/AmountSupportTest.php@@ -25,6 +25,8 @@ class AmountSupportTest extends TestCase$this->object = new Amount;$user = FactoryMuffin::create('FireflyIII\User');$this->be($user);++}/**diff --git a/tests/support/ExpandedFormTest.php b/tests/support/ExpandedFormTest.phpnew file mode 100644index 0000000000..c69a885d17--- /dev/null+++ b/tests/support/ExpandedFormTest.php@@ -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'));+ }+}\ No newline at end of file