mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-03 20:20:37 -06:00
The tests now reflect that not all category-related views support all date ranges, see issue #170
This commit is contained in:
parent
ee8c83bbd8
commit
be74fbd677
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,6 +15,25 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
*/
|
*/
|
||||||
protected $baseUrl = 'http://localhost';
|
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,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the application.
|
* Creates the application.
|
||||||
*
|
*
|
||||||
@ -29,19 +49,27 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return User
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function emptyUser()
|
public function dateRangeProvider()
|
||||||
{
|
{
|
||||||
return User::find(2);
|
return [
|
||||||
|
'one day' => ['1D'],
|
||||||
|
'one week' => ['1W'],
|
||||||
|
'one month' => ['1M'],
|
||||||
|
'three months' => ['3M'],
|
||||||
|
'six months' => ['6M'],
|
||||||
|
'one year' => ['1Y'],
|
||||||
|
'custom range' => ['custom'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function toBeDeletedUser()
|
public function emptyUser()
|
||||||
{
|
{
|
||||||
return User::find(3);
|
return User::find(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,6 +101,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
}
|
}
|
||||||
// if the database copy does exists, copy back as original.
|
// if the database copy does exists, copy back as original.
|
||||||
|
|
||||||
|
|
||||||
$this->session(
|
$this->session(
|
||||||
[
|
[
|
||||||
'start' => Carbon::now()->startOfMonth(),
|
'start' => Carbon::now()->startOfMonth(),
|
||||||
@ -98,12 +127,22 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public function toBeDeletedUser()
|
||||||
|
{
|
||||||
|
return User::find(3);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return User::find(1);
|
$user = User::find(1);
|
||||||
|
|
||||||
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,12 +13,14 @@
|
|||||||
class AccountControllerTest extends TestCase
|
class AccountControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Http\Controllers\AccountController::create
|
* @covers FireflyIII\Http\Controllers\AccountController::create
|
||||||
* @covers FireflyIII\Http\Controllers\AccountController::__construct
|
* @covers FireflyIII\Http\Controllers\AccountController::__construct
|
||||||
|
* @dataProvider dateRangeProvider
|
||||||
*/
|
*/
|
||||||
public function testCreate()
|
public function testCreate($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/accounts/create/asset');
|
$this->call('GET', '/accounts/create/asset');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
}
|
}
|
||||||
@ -58,20 +60,24 @@ class AccountControllerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Http\Controllers\AccountController::index
|
* @covers FireflyIII\Http\Controllers\AccountController::index
|
||||||
* @covers FireflyIII\Http\Controllers\AccountController::isInArray
|
* @covers FireflyIII\Http\Controllers\AccountController::isInArray
|
||||||
|
* @dataProvider dateRangeProvider
|
||||||
*/
|
*/
|
||||||
public function testIndex()
|
public function testIndex($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/accounts/asset');
|
$this->call('GET', '/accounts/asset');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Http\Controllers\AccountController::show
|
* @covers FireflyIII\Http\Controllers\AccountController::show
|
||||||
|
* @dataProvider dateRangeProvider
|
||||||
*/
|
*/
|
||||||
public function testShow()
|
public function testShow($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/accounts/show/1');
|
$this->call('GET', '/accounts/show/1');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
}
|
}
|
||||||
|
@ -61,20 +61,24 @@ class CategoryControllerTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Http\Controllers\CategoryController::index
|
* @covers FireflyIII\Http\Controllers\CategoryController::index
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function testIndex()
|
public function testIndex($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/categories');
|
$this->call('GET', '/categories');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Http\Controllers\CategoryController::noCategory
|
* @covers FireflyIII\Http\Controllers\CategoryController::noCategory
|
||||||
|
* @dataProvider dateRangeProvider
|
||||||
*/
|
*/
|
||||||
public function testNoCategory()
|
public function testNoCategory($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/categories/list/noCategory');
|
$this->call('GET', '/categories/list/noCategory');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
}
|
}
|
||||||
@ -82,10 +86,12 @@ class CategoryControllerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Http\Controllers\CategoryController::show
|
* @covers FireflyIII\Http\Controllers\CategoryController::show
|
||||||
* @covers FireflyIII\Http\Controllers\Controller::getSumOfRange
|
* @covers FireflyIII\Http\Controllers\Controller::getSumOfRange
|
||||||
|
* @dataProvider dateRangeProvider
|
||||||
*/
|
*/
|
||||||
public function testShow()
|
public function testShow($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/categories/show/1');
|
$this->call('GET', '/categories/show/1');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
|
|
||||||
@ -93,10 +99,12 @@ class CategoryControllerTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Http\Controllers\CategoryController::showWithDate
|
* @covers FireflyIII\Http\Controllers\CategoryController::showWithDate
|
||||||
|
* @dataProvider dateRangeProvider
|
||||||
*/
|
*/
|
||||||
public function testShowWithDate()
|
public function testShowWithDate($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/categories/show/1/20150101');
|
$this->call('GET', '/categories/show/1/20150101');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user