Fixed tests.

This commit is contained in:
James Cole 2015-06-02 17:58:30 +02:00
parent 71947c097f
commit 616c849b1f
7 changed files with 16 additions and 18 deletions

View File

@ -12,7 +12,7 @@ use Session;
use Steam; use Steam;
use URL; use URL;
use View; use View;
use Preferences;
/** /**
* Class AccountController * Class AccountController
* *

View File

@ -363,11 +363,11 @@ class AccountRepository implements AccountRepositoryInterface
if ($data['openingBalance'] != 0) { if ($data['openingBalance'] != 0) {
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue'; $type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
$opposingData = [ $opposingData = [
'user' => $data['user'], 'user' => $data['user'],
'accountType' => $type, 'accountType' => $type,
'virtualBalance' => 0, 'virtualBalance' => 0,
'name' => $data['name'] . ' initial balance', 'name' => $data['name'] . ' initial balance',
'active' => false, 'active' => false,
]; ];
$opposing = $this->storeAccount($opposingData); $opposing = $this->storeAccount($opposingData);
$this->storeInitialBalance($newAccount, $opposing, $data); $this->storeInitialBalance($newAccount, $opposing, $data);
@ -414,10 +414,11 @@ class AccountRepository implements AccountRepositoryInterface
// create new opening balance. // create new opening balance.
$type = $data['openingBalance'] < 0 ? 'expense' : 'revenue'; $type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
$opposingData = [ $opposingData = [
'user' => $data['user'], 'user' => $data['user'],
'accountType' => $type, 'accountType' => $type,
'name' => $data['name'] . ' initial balance', 'name' => $data['name'] . ' initial balance',
'active' => false, 'active' => false,
'virtualBalance' => 0,
]; ];
$opposing = $this->storeAccount($opposingData); $opposing = $this->storeAccount($opposingData);
$this->storeInitialBalance($account, $opposing, $data); $this->storeInitialBalance($account, $opposing, $data);

View File

@ -7,7 +7,7 @@ use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Preferences; use Preferences as Prefs;
/** /**
* Class ChartProperties * Class ChartProperties
@ -27,7 +27,7 @@ class ChartProperties
{ {
$this->properties = new Collection; $this->properties = new Collection;
$this->addProperty(Auth::user()->id); $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) { if ($property instanceof Collection || $property instanceof EloquentCollection) {
$string .= print_r($property->toArray(), true); $string .= print_r($property->toArray(), true);
// Log::debug('added collection (size=' . $property->count() . ')');
continue; continue;
} }
if ($property instanceof Carbon) { if ($property instanceof Carbon) {
$string .= $property->toRfc3339String(); $string .= $property->toRfc3339String();
// Log::debug('Added time: ' . $property->toRfc3339String());
continue; continue;
} }
if (is_object($property)) { if (is_object($property)) {
$string .= $property->__toString(); $string .= $property->__toString();
// Log::debug('Added object of class ' . get_class($property));
} }
if (is_array($property)) { if (is_array($property)) {
$string .= print_r($property, true); $string .= print_r($property, true);
// Log::debug('Added array (size=' . count($property) . ')');
} }
$string .= (string)$property; $string .= (string)$property;
// Log::debug('Added cast to string: ' . $property);
} }
// Log::debug('--- done building string ---');
return md5($string); return md5($string);
} }
} }

View File

@ -69,6 +69,7 @@ class AccountControllerTest extends TestCase
Preferences::shouldReceive('get')->withArgs(['viewRange', '1M'])->andReturn($pref); Preferences::shouldReceive('get')->withArgs(['viewRange', '1M'])->andReturn($pref);
$language = FactoryMuffin::create('FireflyIII\Models\Preference'); $language = FactoryMuffin::create('FireflyIII\Models\Preference');
$language->data = 'en'; $language->data = 'en';
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($language); Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($language);

View File

@ -188,6 +188,7 @@ class BillControllerTest extends TestCase
$repository->shouldReceive('nextExpectedMatch')->once()->andReturn(new Carbon); $repository->shouldReceive('nextExpectedMatch')->once()->andReturn(new Carbon);
Amount::shouldReceive('format')->andReturn('XX'); Amount::shouldReceive('format')->andReturn('XX');
Amount::shouldReceive('formatJournal')->andReturn('XX');
Amount::shouldReceive('getCurrencyCode')->andReturn('XX'); Amount::shouldReceive('getCurrencyCode')->andReturn('XX');

View File

@ -193,6 +193,7 @@ class BudgetControllerTest extends TestCase
$this->be($budget->user); $this->be($budget->user);
$date = Carbon::now()->startOfMonth()->format('FY'); $date = Carbon::now()->startOfMonth()->format('FY');
Preferences::shouldReceive('set')->once()->withArgs(['budgetIncomeTotal' . $date, 1001]); Preferences::shouldReceive('set')->once()->withArgs(['budgetIncomeTotal' . $date, 1001]);
Preferences::shouldReceive('mark')->once()->andReturn(true);
// language preference: // language preference:
$language = FactoryMuffin::create('FireflyIII\Models\Preference'); $language = FactoryMuffin::create('FireflyIII\Models\Preference');

View File

@ -97,6 +97,7 @@ class PreferencesControllerTest extends TestCase
Preferences::shouldReceive('set')->once()->withArgs(['viewRange', '1M']); Preferences::shouldReceive('set')->once()->withArgs(['viewRange', '1M']);
Preferences::shouldReceive('set')->once()->withArgs(['budgetMaximum', 0]); Preferences::shouldReceive('set')->once()->withArgs(['budgetMaximum', 0]);
Preferences::shouldReceive('set')->once()->withArgs(['language', 'en']); Preferences::shouldReceive('set')->once()->withArgs(['language', 'en']);
Preferences::shouldReceive('mark')->once()->andReturn(true);
// language preference: // language preference:
$language = FactoryMuffin::create('FireflyIII\Models\Preference'); $language = FactoryMuffin::create('FireflyIII\Models\Preference');