Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/EntitlementTest.php
<?php | <?php | ||||
namespace Tests\Feature; | namespace Tests\Feature; | ||||
use App\Domain; | use App\Domain; | ||||
use App\Entitlement; | use App\Entitlement; | ||||
use App\Package; | use App\Package; | ||||
use App\Sku; | use App\Sku; | ||||
use App\User; | use App\User; | ||||
use Carbon\Carbon; | use Carbon\Carbon; | ||||
use Illuminate\Support\Facades\Queue; | |||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class EntitlementTest extends TestCase | class EntitlementTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | public function testEntitlementFunctions(): void | ||||
$this->assertNotNull($entitlement); | $this->assertNotNull($entitlement); | ||||
$this->assertSame($sku->id, $entitlement->sku->id); | $this->assertSame($sku->id, $entitlement->sku->id); | ||||
$this->assertSame($wallet->id, $entitlement->wallet->id); | $this->assertSame($wallet->id, $entitlement->wallet->id); | ||||
$this->assertEquals($user->id, $entitlement->entitleable->id); | $this->assertEquals($user->id, $entitlement->entitleable->id); | ||||
$this->assertTrue($entitlement->entitleable instanceof \App\User); | $this->assertTrue($entitlement->entitleable instanceof \App\User); | ||||
} | } | ||||
/** | /** | ||||
* Test Entitlement::entitlementTitle() | * Test Entitlement::entitleableTitle() | ||||
*/ | */ | ||||
public function testEntitlementTitle(): void | public function testEntitleableTitle(): void | ||||
{ | { | ||||
Queue::fake(); | |||||
$packageDomain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first(); | $packageDomain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first(); | ||||
$packageKolab = Package::withEnvTenantContext()->where('title', 'kolab')->first(); | $packageKolab = Package::withEnvTenantContext()->where('title', 'kolab')->first(); | ||||
$user = $this->getTestUser('entitled-user@custom-domain.com'); | $user = $this->getTestUser('entitled-user@custom-domain.com'); | ||||
$group = $this->getTestGroup('test-group@custom-domain.com'); | $group = $this->getTestGroup('test-group@custom-domain.com'); | ||||
$domain = $this->getTestDomain( | $domain = $this->getTestDomain( | ||||
'custom-domain.com', | 'custom-domain.com', | ||||
[ | [ | ||||
Show All 20 Lines | public function testEntitleableTitle(): void | ||||
->where('sku_id', $sku_group->id)->first(); | ->where('sku_id', $sku_group->id)->first(); | ||||
$this->assertSame($group->email, $entitlement->entitleableTitle()); | $this->assertSame($group->email, $entitlement->entitleableTitle()); | ||||
$entitlement = Entitlement::where('wallet_id', $wallet->id) | $entitlement = Entitlement::where('wallet_id', $wallet->id) | ||||
->where('sku_id', $sku_domain->id)->first(); | ->where('sku_id', $sku_domain->id)->first(); | ||||
$this->assertSame($domain->namespace, $entitlement->entitleableTitle()); | $this->assertSame($domain->namespace, $entitlement->entitleableTitle()); | ||||
// Make sure it still works if the entitleable is deleted | |||||
$domain->delete(); | |||||
$entitlement->refresh(); | |||||
$this->assertSame($domain->namespace, $entitlement->entitleableTitle()); | |||||
$this->assertNotNull($entitlement->entitleable); | |||||
} | } | ||||
} | } |