paddle-logging verbessert

This commit is contained in:
Codex Agent
2025-12-23 08:53:00 +01:00
parent aa6f9b35d9
commit 8267b2bca3
6 changed files with 263 additions and 44 deletions

View File

@@ -0,0 +1,66 @@
<?php
namespace Tests\Unit;
use App\Services\Paddle\PaddleClient;
use App\Services\Paddle\PaddleTransactionService;
use Mockery;
use Tests\TestCase;
class PaddleTransactionServiceTest extends TestCase
{
public function test_list_for_customer_uses_expected_order_by_format(): void
{
$client = Mockery::mock(PaddleClient::class);
$client->shouldReceive('get')
->once()
->with('/transactions', Mockery::on(function (array $payload) {
return $payload['customer_id'] === 'ctm_123'
&& $payload['order_by'] === 'created_at[desc]';
}))
->andReturn(['data' => [], 'meta' => ['pagination' => []]]);
$this->app->instance(PaddleClient::class, $client);
$service = $this->app->make(PaddleTransactionService::class);
$service->listForCustomer('ctm_123');
$this->assertTrue(true);
}
public function test_find_by_checkout_id_uses_expected_order_by_format(): void
{
$client = Mockery::mock(PaddleClient::class);
$client->shouldReceive('get')
->once()
->with('/transactions', Mockery::on(function (array $payload) {
return $payload['checkout_id'] === 'chk_123'
&& $payload['order_by'] === 'created_at[desc]';
}))
->andReturn(['data' => []]);
$this->app->instance(PaddleClient::class, $client);
$service = $this->app->make(PaddleTransactionService::class);
$this->assertNull($service->findByCheckoutId('chk_123'));
}
public function test_find_by_custom_data_uses_expected_order_by_format(): void
{
$client = Mockery::mock(PaddleClient::class);
$client->shouldReceive('get')
->once()
->with('/transactions', Mockery::on(function (array $payload) {
return $payload['order_by'] === 'created_at[desc]'
&& $payload['per_page'] === 20;
}))
->andReturn(['data' => []]);
$this->app->instance(PaddleClient::class, $client);
$service = $this->app->make(PaddleTransactionService::class);
$this->assertNull($service->findByCustomData([
'checkout_session_id' => 'sess_123',
]));
}
}