Improve randomness in test data to prevent key collisions.

This commit is contained in:
James Cole
2018-07-14 16:41:07 +02:00
parent ff403dfa2e
commit 3d1523a060
50 changed files with 283 additions and 283 deletions

View File

@@ -96,7 +96,7 @@ class TransactionControllerTest extends TestCase
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -142,7 +142,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -240,7 +240,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$data = [
'description' => 'Split journal #' . random_int(1, 1000),
'description' => 'Split journal #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -298,7 +298,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -345,7 +345,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('findByName')->andReturn(null);
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -390,7 +390,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -434,7 +434,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [],
@@ -474,7 +474,7 @@ class TransactionControllerTest extends TestCase
$data = [
'description' => 'Split journal #' . random_int(1, 1000),
'description' => 'Split journal #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -524,7 +524,7 @@ class TransactionControllerTest extends TestCase
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -580,7 +580,7 @@ class TransactionControllerTest extends TestCase
// submit with another account.
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'bill_id' => $bill->id,
@@ -638,7 +638,7 @@ class TransactionControllerTest extends TestCase
// submit with another account.
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'bill_name' => $bill->name,
@@ -696,7 +696,7 @@ class TransactionControllerTest extends TestCase
// submit with another account.
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -754,7 +754,7 @@ class TransactionControllerTest extends TestCase
// submit with another account.
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -812,7 +812,7 @@ class TransactionControllerTest extends TestCase
// submit with another account.
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -876,7 +876,7 @@ class TransactionControllerTest extends TestCase
// submit with another account.
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'piggy_bank_id' => $piggyBank->id,
@@ -942,7 +942,7 @@ class TransactionControllerTest extends TestCase
// submit with another account.
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'piggy_bank_name' => $piggyBank->name,
@@ -996,7 +996,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'deposit',
'transactions' => [
@@ -1045,7 +1045,7 @@ class TransactionControllerTest extends TestCase
$data = [
'description' => 'Some deposit #' . random_int(1, 1000),
'description' => 'Some deposit #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'deposit',
'transactions' => [
@@ -1101,7 +1101,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]), new Collection([$second]));
$data = [
'description' => 'Some transfer #' . random_int(1, 1000),
'description' => 'Some transfer #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'transfer',
'transactions' => [
@@ -1165,7 +1165,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]), new Collection([$second]));
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1479,7 +1479,7 @@ class TransactionControllerTest extends TestCase
$bill = $this->user()->bills()->first();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'bill_id' => $bill->id,
@@ -1520,7 +1520,7 @@ class TransactionControllerTest extends TestCase
$bill = $this->user()->bills()->first();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'bill_name' => $bill->name,
@@ -1559,7 +1559,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1567,7 +1567,7 @@ class TransactionControllerTest extends TestCase
'amount' => '10',
'currency_id' => 1,
'source_id' => $account->id,
'destination_name' => 'New expense account #' . random_int(1, 1000),
'destination_name' => 'New expense account #' . random_int(1, 10000),
],
@@ -1600,7 +1600,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1639,7 +1639,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1680,7 +1680,7 @@ class TransactionControllerTest extends TestCase
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1719,7 +1719,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'deposit',
'transactions' => [
@@ -1757,7 +1757,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1797,7 +1797,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1836,7 +1836,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1875,7 +1875,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1915,7 +1915,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -1954,7 +1954,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
// store date meta fields (if present):
@@ -1999,9 +1999,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$name = 'Some new category #' . random_int(1, 1000);
$name = 'Some new category #' . random_int(1, 10000);
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -2041,7 +2041,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$name = 'New opposing account #' . random_int(1, 10000);
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -2080,7 +2080,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'notes' => 'I am a note',
@@ -2119,7 +2119,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]), new Collection([$opposing]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -2159,7 +2159,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -2199,7 +2199,7 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$piggy = $this->user()->piggyBanks()->first();
$data = [
'description' => 'Some deposit #' . random_int(1, 1000),
'description' => 'Some deposit #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'deposit',
'piggy_bank_name' => $piggy->name,
@@ -2240,7 +2240,7 @@ class TransactionControllerTest extends TestCase
$piggy = $this->user()->piggyBanks()->first();
$data = [
'description' => 'Some transfer #' . random_int(1, 1000),
'description' => 'Some transfer #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'transfer',
'piggy_bank_id' => $piggy->id,
@@ -2280,7 +2280,7 @@ class TransactionControllerTest extends TestCase
$piggy = $this->user()->piggyBanks()->first();
$data = [
'description' => 'Some transfer #' . random_int(1, 1000),
'description' => 'Some transfer #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'transfer',
'piggy_bank_name' => $piggy->name,
@@ -2316,7 +2316,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -2354,7 +2354,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'transactions' => [
@@ -2392,9 +2392,9 @@ class TransactionControllerTest extends TestCase
public function testSuccessStoreTags(): void
{
$tags = [
'TagOne' . random_int(1, 1000),
'TagTwoBlarg' . random_int(1, 1000),
'SomeThreeTag' . random_int(1, 1000),
'TagOne' . random_int(1, 10000),
'TagTwoBlarg' . random_int(1, 10000),
'SomeThreeTag' . random_int(1, 10000),
];
$journal = $this->user()->transactionJournals()->first();
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
@@ -2406,7 +2406,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'type' => 'withdrawal',
'tags' => implode(',', $tags),
@@ -2442,7 +2442,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$account->id]])->andReturn(new Collection([$account]));
$data = [
'description' => 'Some deposit #' . random_int(1, 1000),
'description' => 'Some deposit #' . random_int(1, 10000),
'date' => '2018-01-01',
'transactions' => [
[
@@ -2484,7 +2484,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$account->id]])->andReturn(new Collection([$account]));
$data = [
'description' => 'Some transaction #' . random_int(1, 1000),
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
'transactions' => [
[