mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Restored some tests.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
* Class TestCase
|
||||
*/
|
||||
@@ -12,6 +16,35 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
*/
|
||||
protected $baseUrl = 'http://localhost';
|
||||
|
||||
/**
|
||||
* @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(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
@@ -19,10 +52,62 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$user = User::find(1);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return \Mockery\MockInterface
|
||||
*/
|
||||
protected function mock($class)
|
||||
{
|
||||
$object = Mockery::mock($class);
|
||||
|
||||
|
||||
$this->app->instance($class, $object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user