Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/BillingTest.php
Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | public function testSecondMonth(): void | ||||
] | ] | ||||
); | ); | ||||
$this->backdateEntitlements([$entitlement], Carbon::now()->subMonthsWithoutOverflow(1)); | $this->backdateEntitlements([$entitlement], Carbon::now()->subMonthsWithoutOverflow(1)); | ||||
$this->assertEquals(2023, $this->wallet->expectedCharges()); | $this->assertEquals(2023, $this->wallet->expectedCharges()); | ||||
} | } | ||||
public function testWithDiscount(): void | public function testWithDiscountRate(): void | ||||
{ | { | ||||
$package = \App\Package::create( | $package = \App\Package::create( | ||||
[ | [ | ||||
'title' => 'kolab-kube', | 'title' => 'kolab-kube', | ||||
'name' => 'Kolab for Kuba Fans', | 'name' => 'Kolab for Kuba Fans', | ||||
'description' => 'Kolab for Kube fans', | 'description' => 'Kolab for Kube fans', | ||||
'discount_rate' => 50 | 'discount_rate' => 50 | ||||
] | ] | ||||
Show All 20 Lines | public function testWithDiscountRate(): void | ||||
$wallet = $user->wallets->first(); | $wallet = $user->wallets->first(); | ||||
$wallet_id = $wallet->id; | $wallet_id = $wallet->id; | ||||
$this->backdateEntitlements($wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1)); | $this->backdateEntitlements($wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1)); | ||||
$this->assertEquals(500, $wallet->expectedCharges()); | $this->assertEquals(500, $wallet->expectedCharges()); | ||||
} | } | ||||
/** | |||||
* Test cost calculation with a wallet discount | |||||
*/ | |||||
public function testWithWalletDiscount(): void | |||||
{ | |||||
$discount = \App\Discount::where('code', 'TEST')->first(); | |||||
$wallet = $this->user->wallets()->first(); | |||||
$wallet->discount()->associate($discount); | |||||
$this->backdateEntitlements($wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1)); | |||||
$this->assertEquals(898, $wallet->expectedCharges()); | |||||
} | |||||
} | } |