new stage code
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Tests\Feature;
|
||||
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseProduct;
|
||||
use App\Models\User;
|
||||
use App\Services\Payments\PurchaseProvisioner;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
@@ -102,4 +103,30 @@ class PaddleSubscriptionProvisioningTest extends TestCase
|
||||
$this->assertNotNull($license->revoked_at);
|
||||
$this->assertFalse($license->is_usable);
|
||||
}
|
||||
|
||||
public function test_new_purchase_creates_a_portal_user_for_the_customer(): void
|
||||
{
|
||||
$this->product('pri_personal_monthly', 'Personal', 1);
|
||||
|
||||
app(PurchaseProvisioner::class)->provision('paddle', $this->subscription(
|
||||
'subscription.created', 'active', 'pri_personal_monthly', 'pro_personal'
|
||||
));
|
||||
|
||||
$user = User::where('email', 'mark@example.com')->firstOrFail();
|
||||
$this->assertSame('Mark', $user->name);
|
||||
$this->assertNotNull($user->email_verified_at);
|
||||
}
|
||||
|
||||
public function test_existing_customer_account_is_reused(): void
|
||||
{
|
||||
User::factory()->create(['name' => 'Existing Mark', 'email' => 'mark@example.com']);
|
||||
$this->product('pri_personal_monthly', 'Personal', 1);
|
||||
|
||||
app(PurchaseProvisioner::class)->provision('paddle', $this->subscription(
|
||||
'subscription.created', 'active', 'pri_personal_monthly', 'pro_personal'
|
||||
));
|
||||
|
||||
$this->assertSame(1, User::where('email', 'mark@example.com')->count());
|
||||
$this->assertSame('Existing Mark', User::where('email', 'mark@example.com')->firstOrFail()->name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user