mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 19:01:39 +00:00
Improve test coverage and quality
This commit is contained in:
@@ -67,7 +67,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||
'type' => 'asset',
|
||||
'account_role' => 'defaultAsset',
|
||||
'opening_balance' => '123.45',
|
||||
@@ -146,7 +146,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new liability account #' . random_int(1, 10000),
|
||||
'name' => 'Some new liability account #' . $this->randomInt(),
|
||||
'type' => 'liability',
|
||||
'liability_amount' => '10000',
|
||||
'liability_start_date' => '2016-01-01',
|
||||
@@ -185,7 +185,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||
'type' => 'asset',
|
||||
'account_role' => 'ccAsset',
|
||||
];
|
||||
@@ -233,7 +233,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||
'type' => 'asset',
|
||||
'account_role' => 'defaultAsset',
|
||||
'include_net_worth' => false,
|
||||
@@ -314,7 +314,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||
'type' => 'asset',
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
@@ -355,7 +355,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
||||
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||
'currency_code' => 'EUR',
|
||||
'type' => 'asset',
|
||||
'account_role' => 'defaultAsset',
|
||||
|
@@ -115,7 +115,7 @@ class AttachmentControllerTest extends TestCase
|
||||
// data to submit
|
||||
$data = [
|
||||
'filename' => 'Some new att',
|
||||
'description' => sprintf('Attempt #%d', random_int(1, 10000)),
|
||||
'description' => sprintf('Attempt #%d', $this->randomInt()),
|
||||
'model' => 'TransactionJournal',
|
||||
'model_id' => $journal->id,
|
||||
];
|
||||
@@ -159,7 +159,7 @@ class AttachmentControllerTest extends TestCase
|
||||
// data to submit
|
||||
$data = [
|
||||
'filename' => $attachment->filename,
|
||||
'description' => sprintf('Attempt #%d', random_int(1, 10000)),
|
||||
'description' => sprintf('Attempt #%d', $this->randomInt()),
|
||||
'model' => 'TransactionJournal',
|
||||
'model_id' => 1,
|
||||
];
|
||||
|
@@ -68,8 +68,8 @@ class BillControllerTest extends TestCase
|
||||
|
||||
// data to submit:
|
||||
$data = [
|
||||
'name' => 'New bill #' . random_int(1, 10000),
|
||||
'match' => 'some,words,' . random_int(1, 10000),
|
||||
'name' => 'New bill #' . $this->randomInt(),
|
||||
'match' => 'some,words,' . $this->randomInt(),
|
||||
'amount_min' => '66.34',
|
||||
'amount_max' => '45.67',
|
||||
'date' => '2018-01-01',
|
||||
@@ -121,8 +121,8 @@ class BillControllerTest extends TestCase
|
||||
|
||||
// data to submit:
|
||||
$data = [
|
||||
'name' => 'New bill #' . random_int(1, 10000),
|
||||
'match' => 'some,words,' . random_int(1, 10000),
|
||||
'name' => 'New bill #' . $this->randomInt(),
|
||||
'match' => 'some,words,' . $this->randomInt(),
|
||||
'amount_min' => '12.34',
|
||||
'amount_max' => '45.67',
|
||||
'date' => '2018-01-01',
|
||||
@@ -160,8 +160,8 @@ class BillControllerTest extends TestCase
|
||||
$repository->shouldReceive('update')->andReturn($bill);
|
||||
// data to submit:
|
||||
$data = [
|
||||
'name' => 'New bill #' . random_int(1, 10000),
|
||||
'match' => 'some,words,' . random_int(1, 10000),
|
||||
'name' => 'New bill #' . $this->randomInt(),
|
||||
'match' => 'some,words,' . $this->randomInt(),
|
||||
'amount_min' => '12.34',
|
||||
'amount_max' => '45.67',
|
||||
'date' => '2018-01-01',
|
||||
|
@@ -80,9 +80,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => true,
|
||||
|
||||
];
|
||||
@@ -110,9 +110,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => true,
|
||||
|
||||
];
|
||||
@@ -146,9 +146,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
// create editable link type:
|
||||
$linkType = LinkType::create(
|
||||
[
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => true,
|
||||
|
||||
]
|
||||
@@ -160,9 +160,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => true,
|
||||
|
||||
];
|
||||
@@ -186,9 +186,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
// create editable link type:
|
||||
$linkType = LinkType::create(
|
||||
[
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => false,
|
||||
|
||||
]
|
||||
@@ -199,9 +199,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => true,
|
||||
|
||||
];
|
||||
@@ -227,9 +227,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
// create editable link type:
|
||||
$linkType = LinkType::create(
|
||||
[
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => true,
|
||||
|
||||
]
|
||||
@@ -240,9 +240,9 @@ class LinkTypeControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'name' => 'random' . random_int(1, 100000),
|
||||
'outward' => 'outward' . random_int(1, 100000),
|
||||
'inward' => 'inward ' . random_int(1, 100000),
|
||||
'name' => 'random' . $this->randomInt(),
|
||||
'outward' => 'outward' . $this->randomInt(),
|
||||
'inward' => 'inward ' . $this->randomInt(),
|
||||
'editable' => true,
|
||||
|
||||
];
|
||||
|
@@ -78,7 +78,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
$repository->shouldReceive('store')->once()->andReturn($piggy);
|
||||
|
||||
$data = [
|
||||
'name' => 'New piggy #' . random_int(1, 100000),
|
||||
'name' => 'New piggy #' . $this->randomInt(),
|
||||
'account_id' => 1,
|
||||
'target_amount' => '100',
|
||||
];
|
||||
@@ -106,7 +106,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
|
||||
|
||||
$data = [
|
||||
'name' => 'New piggy #' . random_int(1, 100000),
|
||||
'name' => 'New piggy #' . $this->randomInt(),
|
||||
'account_id' => 1,
|
||||
'target_amount' => '100',
|
||||
];
|
||||
@@ -157,7 +157,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first());
|
||||
|
||||
$data = [
|
||||
'name' => 'new pigy bank ' . random_int(1, 10000),
|
||||
'name' => 'new pigy bank ' . $this->randomInt(),
|
||||
'account_id' => 1,
|
||||
'target_amount' => '100',
|
||||
];
|
||||
|
@@ -80,7 +80,7 @@ class RuleGroupControllerTest extends TestCase
|
||||
$ruleGroupRepos->shouldReceive('setUser')->once();
|
||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule group ' . random_int(1, 100000),
|
||||
'title' => 'Store new rule group ' . $this->randomInt(),
|
||||
'active' => 1,
|
||||
'description' => 'Hello',
|
||||
];
|
||||
@@ -214,7 +214,7 @@ class RuleGroupControllerTest extends TestCase
|
||||
$ruleGroupRepos->shouldReceive('setUser')->once();
|
||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule ' . random_int(1, 100000),
|
||||
'title' => 'Store new rule ' . $this->randomInt(),
|
||||
'active' => 1,
|
||||
'description' => 'Hello',
|
||||
];
|
||||
|
@@ -57,7 +57,7 @@ class TagControllerTest extends TestCase
|
||||
{
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->inRandomOrder()->first();
|
||||
$data = ['tag' => 'Some tag' . random_int(1, 10000),];
|
||||
$data = ['tag' => 'Some tag' . $this->randomInt(),];
|
||||
$transformer = $this->mock(TagTransformer::class);
|
||||
|
||||
// mock transformer
|
||||
@@ -126,7 +126,7 @@ class TagControllerTest extends TestCase
|
||||
{
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->inRandomOrder()->first();
|
||||
$data = ['tag' => 'Some tag' . random_int(1, 10000),];
|
||||
$data = ['tag' => 'Some tag' . $this->randomInt(),];
|
||||
$transformer = $this->mock(TagTransformer::class);
|
||||
|
||||
// mock transformer
|
||||
|
@@ -61,7 +61,7 @@ class UserControllerTest extends TestCase
|
||||
public function testStoreBasic(): void
|
||||
{
|
||||
$data = [
|
||||
'email' => 'some_new@user' . random_int(1, 10000) . '.com',
|
||||
'email' => 'some_new@user' . $this->randomInt() . '.com',
|
||||
];
|
||||
|
||||
// mock
|
||||
@@ -91,7 +91,7 @@ class UserControllerTest extends TestCase
|
||||
public function testStoreBasicJson(): void
|
||||
{
|
||||
$data = [
|
||||
'email' => 'some_new@user' . random_int(1, 10000) . '.com',
|
||||
'email' => 'some_new@user' . $this->randomInt() . '.com',
|
||||
'blocked' => true,
|
||||
'blocked_code' => 'email_changed',
|
||||
];
|
||||
@@ -185,11 +185,11 @@ class UserControllerTest extends TestCase
|
||||
public function testUpdate(): void
|
||||
{
|
||||
// create a user first:
|
||||
$user = User::create(['email' => 'some@newu' . random_int(1, 10000) . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
||||
$user = User::create(['email' => 'some@newu' . $this->randomInt() . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
||||
|
||||
// data:
|
||||
$data = [
|
||||
'email' => 'some-new@email' . random_int(1, 10000) . '.com',
|
||||
'email' => 'some-new@email' . $this->randomInt() . '.com',
|
||||
'blocked' => 0,
|
||||
];
|
||||
|
||||
@@ -220,11 +220,11 @@ class UserControllerTest extends TestCase
|
||||
public function testUpdateJson(): void
|
||||
{
|
||||
// create a user first:
|
||||
$user = User::create(['email' => 'some@newu' . random_int(1, 10000) . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
||||
$user = User::create(['email' => 'some@newu' . $this->randomInt() . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
||||
|
||||
// data:
|
||||
$data = [
|
||||
'email' => 'some-new@email' . random_int(1, 10000) . '.com',
|
||||
'email' => 'some-new@email' . $this->randomInt() . '.com',
|
||||
'blocked' => 0,
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user