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 URL;
use View;
use Preferences;
/**
* Class AccountController
*

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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');

View File

@ -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');

View File

@ -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');