switched to paddle inline checkout, removed paypal and most of stripe. added product sync between app and paddle.
This commit is contained in:
55
tests/Feature/PaddleSyncPackagesCommandTest.php
Normal file
55
tests/Feature/PaddleSyncPackagesCommandTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\SyncPackageToPaddle;
|
||||
use App\Models\Package;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus as BusFacade;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PaddleSyncPackagesCommandTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_command_dispatches_jobs_for_packages(): void
|
||||
{
|
||||
Package::factory()->count(2)->create();
|
||||
|
||||
BusFacade::fake();
|
||||
|
||||
$this->artisan('paddle:sync-packages', [
|
||||
'--dry-run' => true,
|
||||
'--queue' => true,
|
||||
])->assertExitCode(0);
|
||||
|
||||
BusFacade::assertDispatched(SyncPackageToPaddle::class, 2);
|
||||
}
|
||||
|
||||
public function test_command_filters_packages_by_id(): void
|
||||
{
|
||||
$package = Package::factory()->create();
|
||||
Package::factory()->create();
|
||||
|
||||
BusFacade::fake();
|
||||
|
||||
$this->artisan('paddle:sync-packages', [
|
||||
'--dry-run' => true,
|
||||
'--queue' => true,
|
||||
'--package' => [$package->id],
|
||||
])->assertExitCode(0);
|
||||
|
||||
BusFacade::assertDispatched(SyncPackageToPaddle::class, function (SyncPackageToPaddle $job) use ($package) {
|
||||
return $this->getJobPackageId($job) === $package->id;
|
||||
});
|
||||
}
|
||||
|
||||
protected function getJobPackageId(SyncPackageToPaddle $job): int
|
||||
{
|
||||
$reflection = new \ReflectionClass($job);
|
||||
$property = $reflection->getProperty('packageId');
|
||||
$property->setAccessible(true);
|
||||
|
||||
return (int) $property->getValue($job);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user