Changeset View
Changeset View
Standalone View
Standalone View
src/tests/TestCaseTrait.php
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | protected function createTestTransactions($wallet) | ||||
} | } | ||||
} | } | ||||
$transaction = Transaction::create([ | $transaction = Transaction::create([ | ||||
'user_email' => 'jeroen@jeroen.jeroen', | 'user_email' => 'jeroen@jeroen.jeroen', | ||||
'object_id' => $wallet->id, | 'object_id' => $wallet->id, | ||||
'object_type' => \App\Wallet::class, | 'object_type' => \App\Wallet::class, | ||||
'type' => Transaction::WALLET_DEBIT, | 'type' => Transaction::WALLET_DEBIT, | ||||
'amount' => $debit, | 'amount' => $debit * -1, | ||||
'description' => 'Payment', | 'description' => 'Payment', | ||||
]); | ]); | ||||
$result[] = $transaction; | $result[] = $transaction; | ||||
Transaction::whereIn('id', $entitlementTransactions)->update(['transaction_id' => $transaction->id]); | Transaction::whereIn('id', $entitlementTransactions)->update(['transaction_id' => $transaction->id]); | ||||
$transaction = Transaction::create([ | $transaction = Transaction::create([ | ||||
'user_email' => null, | 'user_email' => null, | ||||
Show All 10 Lines | protected function createTestTransactions($wallet) | ||||
$types = [ | $types = [ | ||||
Transaction::WALLET_AWARD, | Transaction::WALLET_AWARD, | ||||
Transaction::WALLET_PENALTY, | Transaction::WALLET_PENALTY, | ||||
]; | ]; | ||||
// The page size is 10, so we generate so many to have at least two pages | // The page size is 10, so we generate so many to have at least two pages | ||||
$loops = 10; | $loops = 10; | ||||
while ($loops-- > 0) { | while ($loops-- > 0) { | ||||
$type = $types[count($result) % count($types)]; | |||||
$transaction = Transaction::create([ | $transaction = Transaction::create([ | ||||
'user_email' => 'jeroen.@jeroen.jeroen', | 'user_email' => 'jeroen.@jeroen.jeroen', | ||||
'object_id' => $wallet->id, | 'object_id' => $wallet->id, | ||||
'object_type' => \App\Wallet::class, | 'object_type' => \App\Wallet::class, | ||||
'type' => $types[count($result) % count($types)], | 'type' => $type, | ||||
'amount' => 11 * (count($result) + 1), | 'amount' => 11 * (count($result) + 1) * ($type == Transaction::WALLET_PENALTY ? -1 : 1), | ||||
'description' => 'TRANS' . $loops, | 'description' => 'TRANS' . $loops, | ||||
]); | ]); | ||||
$transaction->created_at = $date->next(Carbon::MONDAY); | $transaction->created_at = $date->next(Carbon::MONDAY); | ||||
$transaction->save(); | $transaction->save(); | ||||
$result[] = $transaction; | $result[] = $transaction; | ||||
} | } | ||||
return $result; | return $result; | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |