-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathSubscriptionStripePriceIdTest.php
More file actions
70 lines (55 loc) · 2.08 KB
/
SubscriptionStripePriceIdTest.php
File metadata and controls
70 lines (55 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Tests\Unit;
use App\Enums\Subscription;
use Illuminate\Support\Facades\Config;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class SubscriptionStripePriceIdTest extends TestCase
{
private const YEARLY_PRICE = 'price_max_yearly';
private const MONTHLY_PRICE = 'price_max_monthly';
private const EAP_PRICE = 'price_max_eap';
private const DISCOUNTED_PRICE = 'price_max_discounted';
protected function setUp(): void
{
parent::setUp();
Config::set('subscriptions.plans.max.stripe_price_id', self::YEARLY_PRICE);
Config::set('subscriptions.plans.max.stripe_price_id_monthly', self::MONTHLY_PRICE);
Config::set('subscriptions.plans.max.stripe_price_id_eap', self::EAP_PRICE);
Config::set('subscriptions.plans.max.stripe_price_id_discounted', self::DISCOUNTED_PRICE);
}
#[Test]
public function yearly_returns_default_price(): void
{
$this->assertEquals(self::YEARLY_PRICE, Subscription::Max->stripePriceId());
}
#[Test]
public function monthly_returns_monthly_price(): void
{
$this->assertEquals(self::MONTHLY_PRICE, Subscription::Max->stripePriceId(interval: 'month'));
}
#[Test]
public function eap_yearly_returns_eap_price(): void
{
$this->assertEquals(self::EAP_PRICE, Subscription::Max->stripePriceId(forceEap: true));
}
#[Test]
public function eap_monthly_returns_monthly_price_not_eap(): void
{
$this->assertEquals(
self::MONTHLY_PRICE,
Subscription::Max->stripePriceId(forceEap: true, interval: 'month')
);
}
#[Test]
public function discounted_returns_discounted_price(): void
{
$this->assertEquals(self::DISCOUNTED_PRICE, Subscription::Max->stripePriceId(discounted: true));
}
#[Test]
public function monthly_falls_back_to_default_when_no_monthly_price(): void
{
Config::set('subscriptions.plans.max.stripe_price_id_monthly', null);
$this->assertEquals(self::YEARLY_PRICE, Subscription::Max->stripePriceId(interval: 'month'));
}
}