Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/PlanTest.php
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | public function testHasDomain(): void | ||||
$this->assertTrue($plan->hasDomain() === true); | $this->assertTrue($plan->hasDomain() === true); | ||||
} | } | ||||
/** | /** | ||||
* Test for a plan's cost. | * Test for a plan's cost. | ||||
*/ | */ | ||||
public function testCost(): void | public function testCost(): void | ||||
{ | { | ||||
$plan = Plan::where('title', 'individual')->first(); | $orig_plan = Plan::withEnvTenantContext()->where('title', 'individual')->first(); | ||||
$plan = Plan::create([ | |||||
$package_costs = 0; | 'title' => 'test-plan', | ||||
'description' => 'Test', | |||||
'name' => 'Test', | |||||
]); | |||||
foreach ($plan->packages as $package) { | $plan->packages()->saveMany($orig_plan->packages); | ||||
$package_costs += $package->cost(); | $plan->refresh(); | ||||
} | |||||
$this->assertTrue( | $this->assertSame(990, $plan->cost()); | ||||
$package_costs == 990, | |||||
"The total costs of all packages for this plan is not 9.90" | |||||
); | |||||
$this->assertTrue( | // Test plan months != 1 | ||||
$plan->cost() == 990, | $plan->months = 12; | ||||
"The total costs for this plan is not 9.90" | $plan->save(); | ||||
); | |||||
$this->assertTrue($plan->cost() == $package_costs); | $this->assertSame(990 * 12, $plan->cost()); | ||||
} | } | ||||
/** | /** | ||||
* Tests for Plan::tenant() | * Tests for Plan::tenant() | ||||
*/ | */ | ||||
public function testTenant(): void | public function testTenant(): void | ||||
{ | { | ||||
$plan = Plan::withEnvTenantContext()->where('title', 'individual')->first(); | $plan = Plan::withEnvTenantContext()->where('title', 'individual')->first(); | ||||
Show All 12 Lines |