Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/WalletTest.php
Show All 35 Lines | public function setUp(): void | ||||
parent::setUp(); | parent::setUp(); | ||||
Carbon::setTestNow(Carbon::createFromDate(2022, 02, 02)); | Carbon::setTestNow(Carbon::createFromDate(2022, 02, 02)); | ||||
foreach ($this->users as $user) { | foreach ($this->users as $user) { | ||||
$this->deleteTestUser($user); | $this->deleteTestUser($user); | ||||
} | } | ||||
Sku::select()->update(['fee' => 0]); | Sku::select()->update(['fee' => 0]); | ||||
\App\TaxRate::truncate(); | |||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
foreach ($this->users as $user) { | foreach ($this->users as $user) { | ||||
$this->deleteTestUser($user); | $this->deleteTestUser($user); | ||||
} | } | ||||
Sku::select()->update(['fee' => 0]); | Sku::select()->update(['fee' => 0]); | ||||
\App\TaxRate::truncate(); | |||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test that turning wallet balance from negative to positive | * Test that turning wallet balance from negative to positive | ||||
* unsuspends and undegrades the account | * unsuspends and undegrades the account | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 489 Lines • ▼ Show 20 Lines | public function testChargeAndDeleteEntitlementsTrial(): void | ||||
$trans = $etransactions[0]; | $trans = $etransactions[0]; | ||||
$this->assertSame(null, $trans->description); | $this->assertSame(null, $trans->description); | ||||
$this->assertSame(15, $trans->amount); | $this->assertSame(15, $trans->amount); | ||||
$this->assertSame(Transaction::ENTITLEMENT_BILLED, $trans->type); | $this->assertSame(Transaction::ENTITLEMENT_BILLED, $trans->type); | ||||
*/ | */ | ||||
} | } | ||||
/** | /** | ||||
* Tests for award() and penalty() | |||||
*/ | |||||
public function testAwardAndPenalty(): void | |||||
{ | |||||
$this->markTestIncomplete(); | |||||
} | |||||
/** | |||||
* Tests for chargeback() and refund() | |||||
*/ | |||||
public function testChargebackAndRefund(): void | |||||
{ | |||||
$this->markTestIncomplete(); | |||||
} | |||||
/** | |||||
* Tests for chargeEntitlement() | |||||
*/ | |||||
public function testChargeEntitlement(): void | |||||
{ | |||||
$this->markTestIncomplete(); | |||||
} | |||||
/** | |||||
* Tests for taxRate() | |||||
*/ | |||||
public function testTaxRate(): void | |||||
{ | |||||
\config(['app.vat.countries' => null]); | |||||
\App\TaxRate::create([ | |||||
'start' => now(), | |||||
'country' => 'US', | |||||
'rate' => 7.5, | |||||
]); | |||||
\App\TaxRate::create([ | |||||
'start' => now(), | |||||
'country' => 'DE', | |||||
'rate' => 10.0, | |||||
]); | |||||
$user = $this->getTestUser('UserWallet1@UserWallet.com'); | |||||
$wallet = $user->wallets()->first(); | |||||
$user->setSetting('country', null); | |||||
$this->assertSame(0.0, $wallet->taxRate()); | |||||
$user->setSetting('country', 'DE'); | |||||
$this->assertSame(10.0, $wallet->taxRate()); | |||||
$user->setSetting('country', 'US'); | |||||
$this->assertSame(7.5, $wallet->taxRate()); | |||||
$user->setSetting('country', 'PL'); | |||||
$this->assertSame(0.0, $wallet->taxRate()); | |||||
// Test $start argument | |||||
\App\TaxRate::create([ | |||||
'start' => now()->subYear(), | |||||
'country' => 'DE', | |||||
'rate' => 5.0, | |||||
]); | |||||
$user->setSetting('country', 'DE'); | |||||
$this->assertSame(10.0, $wallet->taxRate(now())); | |||||
$this->assertSame(5.0, $wallet->taxRate(now()->subMonth())); | |||||
$this->assertSame(0.0, $wallet->taxRate(now()->subYears(2))); | |||||
// Test app.vat.rate/app.vat.countries settings | |||||
\config(['app.vat.rate' => 5.0]); | |||||
\config(['app.vat.countries' => 'DE']); | |||||
$this->assertSame(5.0, $wallet->taxRate()); | |||||
} | |||||
/** | |||||
* Tests for updateEntitlements() | * Tests for updateEntitlements() | ||||
*/ | */ | ||||
public function testUpdateEntitlements(): void | public function testUpdateEntitlements(): void | ||||
{ | { | ||||
$this->markTestIncomplete(); | $this->markTestIncomplete(); | ||||
} | } | ||||
} | } |