Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/StatsTest.php
<?php | <?php | ||||
namespace Tests\Feature\Controller\Admin; | namespace Tests\Feature\Controller\Admin; | ||||
use App\Http\Controllers\API\V4\Admin\StatsController; | use App\Http\Controllers\API\V4\Admin\StatsController; | ||||
use App\Payment; | use App\Payment; | ||||
use App\Providers\PaymentProvider; | |||||
use Illuminate\Support\Facades\DB; | use Illuminate\Support\Facades\DB; | ||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class StatsTest extends TestCase | class StatsTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | public function testChartIncomeCurrency(): void | ||||
$wallet->currency = 'EUR'; | $wallet->currency = 'EUR'; | ||||
$wallet->save(); | $wallet->save(); | ||||
$johns_wallet = $john->wallets()->first(); | $johns_wallet = $john->wallets()->first(); | ||||
// Create some test payments | // Create some test payments | ||||
Payment::create([ | Payment::create([ | ||||
'id' => 'test1', | 'id' => 'test1', | ||||
'description' => '', | 'description' => '', | ||||
'status' => PaymentProvider::STATUS_PAID, | 'status' => Payment::STATUS_PAID, | ||||
'amount' => 1000, | 'amount' => 1000, | ||||
'credit_amount' => 1000, | 'credit_amount' => 1000, | ||||
'type' => PaymentProvider::TYPE_ONEOFF, | 'type' => Payment::TYPE_ONEOFF, | ||||
'wallet_id' => $wallet->id, | 'wallet_id' => $wallet->id, | ||||
'provider' => 'mollie', | 'provider' => 'mollie', | ||||
'currency' => 'EUR', | 'currency' => 'EUR', | ||||
'currency_amount' => 1000, | 'currency_amount' => 1000, | ||||
]); | ]); | ||||
Payment::create([ | Payment::create([ | ||||
'id' => 'test2', | 'id' => 'test2', | ||||
'description' => '', | 'description' => '', | ||||
'status' => PaymentProvider::STATUS_PAID, | 'status' => Payment::STATUS_PAID, | ||||
'amount' => 2000, | 'amount' => 2000, | ||||
'credit_amount' => 2000, | 'credit_amount' => 2000, | ||||
'type' => PaymentProvider::TYPE_RECURRING, | 'type' => Payment::TYPE_RECURRING, | ||||
'wallet_id' => $wallet->id, | 'wallet_id' => $wallet->id, | ||||
'provider' => 'mollie', | 'provider' => 'mollie', | ||||
'currency' => 'EUR', | 'currency' => 'EUR', | ||||
'currency_amount' => 2000, | 'currency_amount' => 2000, | ||||
]); | ]); | ||||
Payment::create([ | Payment::create([ | ||||
'id' => 'test3', | 'id' => 'test3', | ||||
'description' => '', | 'description' => '', | ||||
'status' => PaymentProvider::STATUS_PAID, | 'status' => Payment::STATUS_PAID, | ||||
'amount' => 3000, | 'amount' => 3000, | ||||
'credit_amount' => 3000, | 'credit_amount' => 3000, | ||||
'type' => PaymentProvider::TYPE_ONEOFF, | 'type' => Payment::TYPE_ONEOFF, | ||||
'wallet_id' => $johns_wallet->id, | 'wallet_id' => $johns_wallet->id, | ||||
'provider' => 'mollie', | 'provider' => 'mollie', | ||||
'currency' => 'EUR', | 'currency' => 'EUR', | ||||
'currency_amount' => 2800, | 'currency_amount' => 2800, | ||||
]); | ]); | ||||
Payment::create([ | Payment::create([ | ||||
'id' => 'test4', | 'id' => 'test4', | ||||
'description' => '', | 'description' => '', | ||||
'status' => PaymentProvider::STATUS_PAID, | 'status' => Payment::STATUS_PAID, | ||||
'amount' => 4000, | 'amount' => 4000, | ||||
'credit_amount' => 4000, | 'credit_amount' => 4000, | ||||
'type' => PaymentProvider::TYPE_RECURRING, | 'type' => Payment::TYPE_RECURRING, | ||||
'wallet_id' => $johns_wallet->id, | 'wallet_id' => $johns_wallet->id, | ||||
'provider' => 'mollie', | 'provider' => 'mollie', | ||||
'currency' => 'CHF', | 'currency' => 'CHF', | ||||
'currency_amount' => 4000, | 'currency_amount' => 4000, | ||||
]); | ]); | ||||
Payment::create([ | Payment::create([ | ||||
'id' => 'test5', | 'id' => 'test5', | ||||
'description' => '', | 'description' => '', | ||||
'status' => PaymentProvider::STATUS_OPEN, | 'status' => Payment::STATUS_OPEN, | ||||
'amount' => 5000, | 'amount' => 5000, | ||||
'credit_amount' => 5000, | 'credit_amount' => 5000, | ||||
'type' => PaymentProvider::TYPE_ONEOFF, | 'type' => Payment::TYPE_ONEOFF, | ||||
'wallet_id' => $johns_wallet->id, | 'wallet_id' => $johns_wallet->id, | ||||
'provider' => 'mollie', | 'provider' => 'mollie', | ||||
'currency' => 'CHF', | 'currency' => 'CHF', | ||||
'currency_amount' => 5000, | 'currency_amount' => 5000, | ||||
]); | ]); | ||||
Payment::create([ | Payment::create([ | ||||
'id' => 'test6', | 'id' => 'test6', | ||||
'description' => '', | 'description' => '', | ||||
'status' => PaymentProvider::STATUS_FAILED, | 'status' => Payment::STATUS_FAILED, | ||||
'amount' => 6000, | 'amount' => 6000, | ||||
'credit_amount' => 6000, | 'credit_amount' => 6000, | ||||
'type' => PaymentProvider::TYPE_ONEOFF, | 'type' => Payment::TYPE_ONEOFF, | ||||
'wallet_id' => $johns_wallet->id, | 'wallet_id' => $johns_wallet->id, | ||||
'provider' => 'mollie', | 'provider' => 'mollie', | ||||
'currency' => 'CHF', | 'currency' => 'CHF', | ||||
'currency_amount' => 6000, | 'currency_amount' => 6000, | ||||
]); | ]); | ||||
// 'income' chart | // 'income' chart | ||||
$response = $this->actingAs($admin)->get("api/v4/stats/chart/income"); | $response = $this->actingAs($admin)->get("api/v4/stats/chart/income"); | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |