Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/WalletsTest.php
Show All 31 Lines | class WalletsTest extends TestCase | ||||
} | } | ||||
/** | /** | ||||
* Test for getWalletNotice() method | * Test for getWalletNotice() method | ||||
*/ | */ | ||||
public function testGetWalletNotice(): void | public function testGetWalletNotice(): void | ||||
{ | { | ||||
$user = $this->getTestUser('wallets-controller@kolabnow.com'); | $user = $this->getTestUser('wallets-controller@kolabnow.com'); | ||||
$package = \App\Package::where('title', 'kolab')->first(); | $package = \App\Package::withObjectTenantContext($user)->where('title', 'kolab')->first(); | ||||
$user->assignPackage($package); | $user->assignPackage($package); | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
$controller = new WalletsController(); | $controller = new WalletsController(); | ||||
$method = new \ReflectionMethod($controller, 'getWalletNotice'); | $method = new \ReflectionMethod($controller, 'getWalletNotice'); | ||||
$method->setAccessible(true); | $method->setAccessible(true); | ||||
// User/entitlements created today, balance=0 | // User/entitlements created today, balance=0 | ||||
Show All 36 Lines | public function testGetWalletNotice(): void | ||||
// test "almost 2 years" | // test "almost 2 years" | ||||
$wallet->balance = 990 * 23.5; | $wallet->balance = 990 * 23.5; | ||||
$notice = $method->invoke($controller, $wallet); | $notice = $method->invoke($controller, $wallet); | ||||
$this->assertMatchesRegularExpression('/\(1 Jahr 11 Monate\)/', $notice); | $this->assertMatchesRegularExpression('/\(1 Jahr 11 Monate\)/', $notice); | ||||
// Old entitlements, 100% discount | // Old entitlements, 100% discount | ||||
$this->backdateEntitlements($wallet->entitlements, Carbon::now()->subDays(40)); | $this->backdateEntitlements($wallet->entitlements, Carbon::now()->subDays(40)); | ||||
$discount = \App\Discount::where('discount', 100)->first(); | $discount = \App\Discount::withObjectTenantContext($user)->where('discount', 100)->first(); | ||||
$wallet->discount()->associate($discount); | $wallet->discount()->associate($discount); | ||||
$notice = $method->invoke($controller, $wallet->refresh()); | $notice = $method->invoke($controller, $wallet->refresh()); | ||||
$this->assertSame(null, $notice); | $this->assertSame(null, $notice); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines |