Skip to content

Firefly III: a personal finances manager

Fixed tests.

James Cole616c849b1f25
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index ffe7354574..dbef12d1e4 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -12,7 +12,7 @@ use Session;
use Steam;
use URL;
use View;
-
+use Preferences;
/**
* Class AccountController
*
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index a6ec7f81bd..dc9939aeab 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -363,11 +363,11 @@ class AccountRepository implements AccountRepositoryInterface
if ($data['openingBalance'] != 0) {
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
$opposingData = [
- 'user' => $data['user'],
- 'accountType' => $type,
+ 'user' => $data['user'],
+ 'accountType' => $type,
'virtualBalance' => 0,
- 'name' => $data['name'] . ' initial balance',
- 'active' => false,
+ 'name' => $data['name'] . ' initial balance',
+ 'active' => false,
];
$opposing = $this->storeAccount($opposingData);
$this->storeInitialBalance($newAccount, $opposing, $data);
@@ -414,10 +414,11 @@ class AccountRepository implements AccountRepositoryInterface
// create new opening balance.
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
$opposingData = [
- 'user' => $data['user'],
- 'accountType' => $type,
- 'name' => $data['name'] . ' initial balance',
- 'active' => false,
+ 'user' => $data['user'],
+ 'accountType' => $type,
+ 'name' => $data['name'] . ' initial balance',
+ 'active' => false,
+ 'virtualBalance' => 0,
];
$opposing = $this->storeAccount($opposingData);
$this->storeInitialBalance($account, $opposing, $data);
diff --git a/app/Support/ChartProperties.php b/app/Support/ChartProperties.php
index e12d864808..3bff338446 100644
--- a/app/Support/ChartProperties.php
+++ b/app/Support/ChartProperties.php
@@ -7,7 +7,7 @@ use Auth;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Collection;
-use Preferences;
+use Preferences as Prefs;
/**
* Class ChartProperties
@@ -27,7 +27,7 @@ class ChartProperties
{
$this->properties = new Collection;
$this->addProperty(Auth::user()->id);
- $this->addProperty(Preferences::lastActivity());
+ $this->addProperty(Prefs::lastActivity());
}
/**
@@ -50,28 +50,21 @@ class ChartProperties
if ($property instanceof Collection || $property instanceof EloquentCollection) {
$string .= print_r($property->toArray(), true);
- // Log::debug('added collection (size=' . $property->count() . ')');
continue;
}
if ($property instanceof Carbon) {
$string .= $property->toRfc3339String();
- // Log::debug('Added time: ' . $property->toRfc3339String());
continue;
}
if (is_object($property)) {
$string .= $property->__toString();
- // Log::debug('Added object of class ' . get_class($property));
}
if (is_array($property)) {
$string .= print_r($property, true);
- // Log::debug('Added array (size=' . count($property) . ')');
}
$string .= (string)$property;
- // Log::debug('Added cast to string: ' . $property);
}
- // Log::debug('--- done building string ---');
-
return md5($string);
}
}
\ No newline at end of file
diff --git a/tests/controllers/AccountControllerTest.php b/tests/controllers/AccountControllerTest.php
index 5913d750c7..0ff00f50ba 100644
--- a/tests/controllers/AccountControllerTest.php
+++ b/tests/controllers/AccountControllerTest.php
@@ -69,6 +69,7 @@ class AccountControllerTest extends TestCase
Preferences::shouldReceive('get')->withArgs(['viewRange', '1M'])->andReturn($pref);
+
$language = FactoryMuffin::create('FireflyIII\Models\Preference');
$language->data = 'en';
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($language);
diff --git a/tests/controllers/BillControllerTest.php b/tests/controllers/BillControllerTest.php
index 7ae7e26760..7242424df2 100644
--- a/tests/controllers/BillControllerTest.php
+++ b/tests/controllers/BillControllerTest.php
@@ -188,6 +188,7 @@ class BillControllerTest extends TestCase
$repository->shouldReceive('nextExpectedMatch')->once()->andReturn(new Carbon);
Amount::shouldReceive('format')->andReturn('XX');
+ Amount::shouldReceive('formatJournal')->andReturn('XX');
Amount::shouldReceive('getCurrencyCode')->andReturn('XX');
diff --git a/tests/controllers/BudgetControllerTest.php b/tests/controllers/BudgetControllerTest.php
index df08b1502a..01f8b7c9d4 100644
--- a/tests/controllers/BudgetControllerTest.php
+++ b/tests/controllers/BudgetControllerTest.php
@@ -193,6 +193,7 @@ class BudgetControllerTest extends TestCase
$this->be($budget->user);
$date = Carbon::now()->startOfMonth()->format('FY');
Preferences::shouldReceive('set')->once()->withArgs(['budgetIncomeTotal' . $date, 1001]);
+ Preferences::shouldReceive('mark')->once()->andReturn(true);
// language preference:
$language = FactoryMuffin::create('FireflyIII\Models\Preference');
diff --git a/tests/controllers/PreferencesControllerTest.php b/tests/controllers/PreferencesControllerTest.php
index 7a6a5b3b87..af3b9d1ab9 100644
--- a/tests/controllers/PreferencesControllerTest.php
+++ b/tests/controllers/PreferencesControllerTest.php
@@ -97,6 +97,7 @@ class PreferencesControllerTest extends TestCase
Preferences::shouldReceive('set')->once()->withArgs(['viewRange', '1M']);
Preferences::shouldReceive('set')->once()->withArgs(['budgetMaximum', 0]);
Preferences::shouldReceive('set')->once()->withArgs(['language', 'en']);
+ Preferences::shouldReceive('mark')->once()->andReturn(true);
// language preference:
$language = FactoryMuffin::create('FireflyIII\Models\Preference');