['order_created', 'subscription_created'], 'lemonsqueezy.store_id' => 'store_123', 'lemonsqueezy.webhook_secret' => 'secret_123', ]); $client = Mockery::mock(LemonSqueezyClient::class); $client->shouldReceive('post') ->once() ->with('/webhooks', Mockery::on(function (array $payload): bool { $attributes = $payload['data']['attributes'] ?? []; $store = $payload['data']['relationships']['store']['data']['id'] ?? null; return ($attributes['url'] ?? null) === 'https://example.test/lemonsqueezy/webhook' && ($attributes['events'] ?? []) === ['order_created', 'subscription_created'] && ($attributes['secret'] ?? null) === 'secret_123' && $store === 'store_123'; })) ->andReturn(['data' => ['id' => 'wh_123']]); $this->app->instance(LemonSqueezyClient::class, $client); $this->artisan('lemonsqueezy:webhooks:register', [ '--url' => 'https://example.test/lemonsqueezy/webhook', ])->assertExitCode(0); } }