Skip to content

Commit b82c3cb

Browse files
committed
fix runtime
1 parent 41d6d7f commit b82c3cb

1 file changed

Lines changed: 46 additions & 4 deletions

File tree

tests/Feature/Checkout/CheckoutFlowTest.php

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ protected function setUp(): void
3232
$this->cashier = User::factory()->create(['name' => 'Test Cashier']);
3333
$this->customer = User::factory()->create(['name' => 'Test Customer']);
3434
$this->tseClient = TseClient::create([
35-
'machine_id' => $this->machine->id,
3635
'remote_id' => 'client-test-123',
37-
'state' => 'ACTIVE'
36+
'serial_number' => 'tse-serial-456',
37+
'state' => 'REGISTERED'
38+
]);
39+
$this->machine = Machine::factory()->create([
40+
'name' => 'POS-01',
41+
'tse_client_id' => $this->tseClient->id
3842
]);
3943
}
4044

@@ -76,8 +80,12 @@ public function it_adds_checkout_items_correctly()
7680
$badge = \App\Models\Badge\Badge::factory()->create();
7781
$item = CheckoutItem::create([
7882
'checkout_id' => $checkout->id,
83+
'payable_type' => Badge::class,
84+
'payable_id' => $badge->id,
7985
'name' => 'Fursuit Badge Registration',
8086
'description' => ['Premium Badge', 'Double-sided print'],
87+
'subtotal' => 1681,
88+
'tax' => 319,
8189
'total' => 2000, // €20.00
8290
]);
8391

@@ -255,9 +263,24 @@ public function it_validates_required_checkout_fields()
255263
/** @test */
256264
public function it_handles_fiskaly_api_errors_gracefully()
257265
{
266+
// Set up Fiskaly config for this test
267+
config([
268+
'services.fiskaly.api_key' => 'test-key',
269+
'services.fiskaly.api_secret' => 'test-secret',
270+
'services.fiskaly.tss_id' => 'f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0',
271+
]);
272+
273+
// Pre-cache auth data to avoid auth flow
274+
cache()->put('fiskaly_auth_data', encrypt([
275+
'access_token' => 'test-access-token',
276+
'refresh_token' => 'test-refresh-token',
277+
'access_token_expires_at' => now()->addHour()->toISOString(),
278+
'refresh_token_expires_in' => 86400,
279+
]), 86400);
280+
258281
// Mock Fiskaly API error response
259282
Http::fake([
260-
'kassensichv.fiskaly.com/api/v2/tss/*/tx/*' => Http::response([
283+
'https://kassensichv-middleware.fiskaly.com/api/v2/tss/*/tx/*' => Http::response([
261284
'error' => 'TSE_NOT_AVAILABLE',
262285
'message' => 'TSE device is not available'
263286
], 500)
@@ -316,6 +339,21 @@ public function it_tracks_remote_revision_count()
316339
*/
317340
public function it_stores_complete_fiskaly_response_data()
318341
{
342+
// Set up Fiskaly config for this test
343+
config([
344+
'services.fiskaly.api_key' => 'test-key',
345+
'services.fiskaly.api_secret' => 'test-secret',
346+
'services.fiskaly.tss_id' => 'f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0',
347+
]);
348+
349+
// Pre-cache auth data to avoid auth flow
350+
cache()->put('fiskaly_auth_data', encrypt([
351+
'access_token' => 'test-access-token',
352+
'refresh_token' => 'test-refresh-token',
353+
'access_token_expires_at' => now()->addHour()->toISOString(),
354+
'refresh_token_expires_in' => 86400,
355+
]), 86400);
356+
319357
$mockResponse = [
320358
'_id' => 'fiskaly-tx-123',
321359
'number' => 42,
@@ -330,7 +368,7 @@ public function it_stores_complete_fiskaly_response_data()
330368
];
331369

332370
Http::fake([
333-
'kassensichv.fiskaly.com/api/v2/tss/*/tx/*' => Http::response($mockResponse, 200)
371+
'https://kassensichv-middleware.fiskaly.com/api/v2/tss/*/tx/*' => Http::response($mockResponse, 200)
334372
]);
335373

336374
$checkout = $this->createBasicCheckout(['remote_id' => 'f1f1f105-f1f1-f1f1-f1f1-f1f1f1f1f005', 'remote_rev_count' => 0]);
@@ -364,8 +402,12 @@ private function addCheckoutItem(Checkout $checkout): CheckoutItem
364402
$badge = \App\Models\Badge\Badge::factory()->create();
365403
return CheckoutItem::create([
366404
'checkout_id' => $checkout->id,
405+
'payable_type' => Badge::class,
406+
'payable_id' => $badge->id,
367407
'name' => 'Fursuit Badge Registration',
368408
'description' => ['Premium Badge'],
409+
'subtotal' => $checkout->subtotal,
410+
'tax' => $checkout->tax,
369411
'total' => $checkout->total,
370412
]);
371413
}

0 commit comments

Comments
 (0)