mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 10:16:49 +00:00
Re-implemented basic account controller tests.
This commit is contained in:
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
use Log;
|
||||
use Mockery;
|
||||
use FireflyIII\Models\Preference;
|
||||
use Carbon\Carbon;
|
||||
/**
|
||||
* Class TestCase
|
||||
*
|
||||
@@ -12,4 +16,75 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$user = User::find(1);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $range
|
||||
*/
|
||||
public function changeDateRange(User $user, $range)
|
||||
{
|
||||
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'];
|
||||
if (in_array($range, $valid)) {
|
||||
Preference::where('user_id', $user->id)->where('name', 'viewRange')->delete();
|
||||
Preference::create(
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
'name' => 'viewRange',
|
||||
'data' => $range,
|
||||
]
|
||||
);
|
||||
// set period to match?
|
||||
|
||||
}
|
||||
if ($range === 'custom') {
|
||||
$this->session(
|
||||
[
|
||||
'start' => Carbon::now()->subDays(20),
|
||||
'end' => Carbon::now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return \Mockery\MockInterface
|
||||
*/
|
||||
protected function mock($class)
|
||||
{
|
||||
Log::debug(sprintf('Will now mock %s', $class));
|
||||
$object = Mockery::mock($class);
|
||||
$this->app->instance($class, $object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dateRangeProvider()
|
||||
{
|
||||
return [
|
||||
'one day' => ['1D'],
|
||||
'one week' => ['1W'],
|
||||
'one month' => ['1M'],
|
||||
'three months' => ['3M'],
|
||||
'six months' => ['6M'],
|
||||
'one year' => ['1Y'],
|
||||
'custom range' => ['custom'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user