Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/UsersTest.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public function setUp(): void | ||||
Sku::where('title', 'test')->delete(); | Sku::where('title', 'test')->delete(); | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->settings()->whereIn('key', ['mollie_id', 'stripe_id'])->delete(); | $wallet->settings()->whereIn('key', ['mollie_id', 'stripe_id'])->delete(); | ||||
$wallet->save(); | $wallet->save(); | ||||
$user->settings()->whereIn('key', ['greylist_enabled', 'guam_enabled'])->delete(); | $user->settings()->whereIn('key', ['greylist_enabled', 'guam_enabled'])->delete(); | ||||
$user->status |= User::STATUS_IMAP_READY | User::STATUS_LDAP_READY; | $user->status |= User::STATUS_IMAP_READY | User::STATUS_LDAP_READY | User::STATUS_ACTIVE; | ||||
$user->status &= ~User::STATUS_RESTRICTED; | |||||
$user->save(); | $user->save(); | ||||
Plan::withEnvTenantContext()->where('title', 'individual')->update(['mode' => 'email']); | Plan::withEnvTenantContext()->where('title', 'individual')->update(['mode' => 'email']); | ||||
$user->setSettings(['plan_id' => null]); | $user->setSettings(['plan_id' => null]); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
Show All 16 Lines | public function tearDown(): void | ||||
Sku::where('title', 'test')->delete(); | Sku::where('title', 'test')->delete(); | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
$wallet->discount()->dissociate(); | $wallet->discount()->dissociate(); | ||||
$wallet->settings()->whereIn('key', ['mollie_id', 'stripe_id'])->delete(); | $wallet->settings()->whereIn('key', ['mollie_id', 'stripe_id'])->delete(); | ||||
$wallet->save(); | $wallet->save(); | ||||
$user->settings()->whereIn('key', ['greylist_enabled', 'guam_enabled'])->delete(); | $user->settings()->whereIn('key', ['greylist_enabled', 'guam_enabled'])->delete(); | ||||
$user->status |= User::STATUS_IMAP_READY | User::STATUS_LDAP_READY; | $user->status |= User::STATUS_IMAP_READY | User::STATUS_LDAP_READY | User::STATUS_ACTIVE; | ||||
$user->status &= ~User::STATUS_RESTRICTED; | |||||
$user->save(); | $user->save(); | ||||
Plan::withEnvTenantContext()->where('title', 'individual')->update(['mode' => 'email']); | Plan::withEnvTenantContext()->where('title', 'individual')->update(['mode' => 'email']); | ||||
$user->setSettings(['plan_id' => null]); | $user->setSettings(['plan_id' => null]); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 1,312 Lines • ▼ Show 20 Lines | public function testUserResponse(): void | ||||
$this->assertTrue($result['statusInfo']['enableWallets']); | $this->assertTrue($result['statusInfo']['enableWallets']); | ||||
$this->assertTrue($result['statusInfo']['enableWalletMandates']); | $this->assertTrue($result['statusInfo']['enableWalletMandates']); | ||||
$this->assertTrue($result['statusInfo']['enableWalletPayments']); | $this->assertTrue($result['statusInfo']['enableWalletPayments']); | ||||
$this->assertTrue($result['statusInfo']['enableUsers']); | $this->assertTrue($result['statusInfo']['enableUsers']); | ||||
$this->assertTrue($result['statusInfo']['enableSettings']); | $this->assertTrue($result['statusInfo']['enableSettings']); | ||||
// Ned is John's wallet controller | // Ned is John's wallet controller | ||||
$plan = Plan::withEnvTenantContext()->where('title', 'individual')->first(); | $plan = Plan::withEnvTenantContext()->where('title', 'individual')->first(); | ||||
$plan->mode = 'mandate'; | $plan->mode = Plan::MODE_MANDATE; | ||||
$plan->save(); | $plan->save(); | ||||
$wallet->owner->setSettings(['plan_id' => $plan->id]); | $wallet->owner->setSettings(['plan_id' => $plan->id]); | ||||
$ned = $this->getTestUser('ned@kolab.org'); | $ned = $this->getTestUser('ned@kolab.org'); | ||||
$ned_wallet = $ned->wallets()->first(); | $ned_wallet = $ned->wallets()->first(); | ||||
$result = $this->invokeMethod(new UsersController(), 'userResponse', [$ned]); | $result = $this->invokeMethod(new UsersController(), 'userResponse', [$ned]); | ||||
$this->assertEquals($ned->id, $result['id']); | $this->assertEquals($ned->id, $result['id']); | ||||
$this->assertEquals($ned->email, $result['email']); | $this->assertEquals($ned->email, $result['email']); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public function testUserResponse(): void | ||||
$this->assertFalse($result['statusInfo']['enableWallets']); | $this->assertFalse($result['statusInfo']['enableWallets']); | ||||
$this->assertFalse($result['statusInfo']['enableWalletMandates']); | $this->assertFalse($result['statusInfo']['enableWalletMandates']); | ||||
$this->assertFalse($result['statusInfo']['enableWalletPayments']); | $this->assertFalse($result['statusInfo']['enableWalletPayments']); | ||||
$this->assertFalse($result['statusInfo']['enableUsers']); | $this->assertFalse($result['statusInfo']['enableUsers']); | ||||
$this->assertFalse($result['statusInfo']['enableSettings']); | $this->assertFalse($result['statusInfo']['enableSettings']); | ||||
$this->assertFalse($result['isLocked']); | $this->assertFalse($result['isLocked']); | ||||
// Test locked user | // Test locked user | ||||
$john->restrict(); | $john->status &= ~User::STATUS_ACTIVE; | ||||
$john->save(); | |||||
$result = $this->invokeMethod(new UsersController(), 'userResponse', [$john]); | $result = $this->invokeMethod(new UsersController(), 'userResponse', [$john]); | ||||
$this->assertTrue($result['isLocked']); | $this->assertTrue($result['isLocked']); | ||||
} | } | ||||
/** | /** | ||||
* User email address validation. | * User email address validation. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |