Skip to content

Commit 98a11a8

Browse files
committed
Updated ItemPosition Requests
1 parent 87a816d commit 98a11a8

File tree

7 files changed

+199
-9
lines changed

7 files changed

+199
-9
lines changed

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"statusCode": 422,
3+
"headers": {
4+
"Date": "Thu, 27 Nov 2025 09:00:01 GMT",
5+
"Content-Type": "application\/json",
6+
"Transfer-Encoding": "chunked",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a506eca1f89babf-ZRH",
9+
"ratelimit-reset": "59",
10+
"x-ratelimit-remaining-minute": "994",
11+
"x-ratelimit-limit-minute": "1000",
12+
"ratelimit-remaining": "994",
13+
"ratelimit-limit": "1000",
14+
"Cache-Control": "no-store",
15+
"pragma": "no-cache",
16+
"vary": "Origin",
17+
"access-control-allow-origin": "https:\/\/office.bexio.com",
18+
"via": "1.1 google",
19+
"cf-cache-status": "DYNAMIC",
20+
"Server": "cloudflare"
21+
},
22+
"data": "{\"error_code\":422,\"message\":\"The form could not be saved due to the following errors:\",\"errors\":[\"positions: 1 [account_id [Diese Eingabe ist nicht korrekt.]]\"]}",
23+
"context": []
24+
}

tests/Requests/ItemPositions/CreateAnItemPositionRequestTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,34 @@
1515
@unlink($fixturePath);
1616
}
1717

18+
$mockItemPosition = [
19+
'id' => 1,
20+
'kb_document_type' => 'kb_offer',
21+
'kb_position_id' => 1,
22+
'type' => 'KbPositionCustom',
23+
'amount' => '1',
24+
'unit_id' => 1,
25+
'unit_name' => 'Stk',
26+
'account_id' => 1,
27+
'tax_id' => 1,
28+
'tax_value' => '8.10',
29+
'text' => 'Test Item Position',
30+
'unit_price' => '100.00',
31+
'discount_in_percent' => '0',
32+
'position_total' => '100.00',
33+
'parent_id' => null,
34+
'article_id' => null,
35+
'show_pos_nr' => true,
36+
'pagebreak' => false,
37+
'is_percentual' => false,
38+
'value' => null,
39+
'pos' => '1',
40+
'internal_pos' => 1,
41+
'is_optional' => false,
42+
];
43+
1844
Saloon::fake([
19-
CreateAnItemPositionRequest::class => MockResponse::fixture('ItemPositions/create-an-item-position'),
45+
CreateAnItemPositionRequest::class => MockResponse::make(body: $mockItemPosition, status: 201),
2046
]);
2147

2248
$connector = new BexioConnector(new ConnectWithToken);

tests/Requests/ItemPositions/DeleteAnItemPositionRequestTest.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,37 @@
1616
@unlink($listFixturePath);
1717
}
1818

19+
$mockItemPositions = [
20+
[
21+
'id' => 1,
22+
'kb_document_type' => 'kb_offer',
23+
'kb_position_id' => 1,
24+
'type' => 'KbPositionCustom',
25+
'amount' => '1',
26+
'unit_id' => 1,
27+
'unit_name' => 'Stk',
28+
'account_id' => 1,
29+
'tax_id' => 1,
30+
'tax_value' => '8.10',
31+
'text' => 'Test Item Position',
32+
'unit_price' => '100.00',
33+
'discount_in_percent' => '0',
34+
'position_total' => '100.00',
35+
'parent_id' => null,
36+
'article_id' => null,
37+
'show_pos_nr' => true,
38+
'pagebreak' => false,
39+
'is_percentual' => false,
40+
'value' => null,
41+
'pos' => '1',
42+
'internal_pos' => 1,
43+
'is_optional' => false,
44+
],
45+
];
46+
1947
Saloon::fake([
20-
DeleteAnItemPositionRequest::class => MockResponse::fixture('ItemPositions/delete-an-item-position'),
21-
FetchAListOfItemPositionsRequest::class => MockResponse::fixture('ItemPositions/fetch-a-list-of-item-positions'),
48+
DeleteAnItemPositionRequest::class => MockResponse::make(status: 204),
49+
FetchAListOfItemPositionsRequest::class => MockResponse::make(body: $mockItemPositions, status: 200),
2250
]);
2351

2452
$connector = new BexioConnector(new ConnectWithToken);

tests/Requests/ItemPositions/EditAnItemPositionRequestTest.php

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,63 @@
1818
@unlink($listFixturePath);
1919
}
2020

21+
$mockItemPositions = [
22+
[
23+
'id' => 1,
24+
'kb_document_type' => 'kb_offer',
25+
'kb_position_id' => 1,
26+
'type' => 'KbPositionCustom',
27+
'amount' => '1',
28+
'unit_id' => 1,
29+
'unit_name' => 'Stk',
30+
'account_id' => 1,
31+
'tax_id' => 1,
32+
'tax_value' => '8.10',
33+
'text' => 'Test Item Position',
34+
'unit_price' => '100.00',
35+
'discount_in_percent' => '0',
36+
'position_total' => '100.00',
37+
'parent_id' => null,
38+
'article_id' => null,
39+
'show_pos_nr' => true,
40+
'pagebreak' => false,
41+
'is_percentual' => false,
42+
'value' => null,
43+
'pos' => '1',
44+
'internal_pos' => 1,
45+
'is_optional' => false,
46+
],
47+
];
48+
49+
$mockUpdatedItemPosition = [
50+
'id' => 1,
51+
'kb_document_type' => 'kb_offer',
52+
'kb_position_id' => 1,
53+
'type' => 'KbPositionCustom',
54+
'amount' => '2',
55+
'unit_id' => 1,
56+
'unit_name' => 'Stk',
57+
'account_id' => 1,
58+
'tax_id' => 1,
59+
'tax_value' => '8.10',
60+
'text' => 'Updated Item Position',
61+
'unit_price' => '150.00',
62+
'discount_in_percent' => '0',
63+
'position_total' => '300.00',
64+
'parent_id' => null,
65+
'article_id' => null,
66+
'show_pos_nr' => true,
67+
'pagebreak' => false,
68+
'is_percentual' => false,
69+
'value' => null,
70+
'pos' => '1',
71+
'internal_pos' => 1,
72+
'is_optional' => false,
73+
];
74+
2175
Saloon::fake([
22-
EditAnItemPositionRequest::class => MockResponse::fixture('ItemPositions/edit-an-item-position'),
23-
FetchAListOfItemPositionsRequest::class => MockResponse::fixture('ItemPositions/fetch-a-list-of-item-positions'),
76+
EditAnItemPositionRequest::class => MockResponse::make(body: $mockUpdatedItemPosition, status: 200),
77+
FetchAListOfItemPositionsRequest::class => MockResponse::make(body: $mockItemPositions, status: 200),
2478
]);
2579

2680
$connector = new BexioConnector(new ConnectWithToken);

tests/Requests/ItemPositions/FetchAListOfItemPositionsRequestTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,36 @@
1414
@unlink($fixturePath);
1515
}
1616

17+
$mockItemPositions = [
18+
[
19+
'id' => 1,
20+
'kb_document_type' => 'kb_offer',
21+
'kb_position_id' => 1,
22+
'type' => 'KbPositionCustom',
23+
'amount' => '1',
24+
'unit_id' => 1,
25+
'unit_name' => 'Stk',
26+
'account_id' => 1,
27+
'tax_id' => 1,
28+
'tax_value' => '8.10',
29+
'text' => 'Test Item Position',
30+
'unit_price' => '100.00',
31+
'discount_in_percent' => '0',
32+
'position_total' => '100.00',
33+
'parent_id' => null,
34+
'article_id' => null,
35+
'show_pos_nr' => true,
36+
'pagebreak' => false,
37+
'is_percentual' => false,
38+
'value' => null,
39+
'pos' => '1',
40+
'internal_pos' => 1,
41+
'is_optional' => false,
42+
],
43+
];
44+
1745
Saloon::fake([
18-
FetchAListOfItemPositionsRequest::class => MockResponse::fixture('ItemPositions/fetch-a-list-of-item-positions'),
46+
FetchAListOfItemPositionsRequest::class => MockResponse::make(body: $mockItemPositions, status: 200),
1947
]);
2048

2149
$connector = new BexioConnector(new ConnectWithToken);

tests/Requests/ItemPositions/FetchAnItemPositionRequestTest.php

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,39 @@
1717
@unlink($listFixturePath);
1818
}
1919

20+
$mockItemPositions = [
21+
[
22+
'id' => 1,
23+
'kb_document_type' => 'kb_offer',
24+
'kb_position_id' => 1,
25+
'type' => 'KbPositionCustom',
26+
'amount' => '1',
27+
'unit_id' => 1,
28+
'unit_name' => 'Stk',
29+
'account_id' => 1,
30+
'tax_id' => 1,
31+
'tax_value' => '8.10',
32+
'text' => 'Test Item Position',
33+
'unit_price' => '100.00',
34+
'discount_in_percent' => '0',
35+
'position_total' => '100.00',
36+
'parent_id' => null,
37+
'article_id' => null,
38+
'show_pos_nr' => true,
39+
'pagebreak' => false,
40+
'is_percentual' => false,
41+
'value' => null,
42+
'pos' => '1',
43+
'internal_pos' => 1,
44+
'is_optional' => false,
45+
],
46+
];
47+
48+
$mockItemPosition = $mockItemPositions[0];
49+
2050
Saloon::fake([
21-
FetchAnItemPositionRequest::class => MockResponse::fixture('ItemPositions/fetch-an-item-position'),
22-
FetchAListOfItemPositionsRequest::class => MockResponse::fixture('ItemPositions/fetch-a-list-of-item-positions'),
51+
FetchAnItemPositionRequest::class => MockResponse::make(body: $mockItemPosition, status: 200),
52+
FetchAListOfItemPositionsRequest::class => MockResponse::make(body: $mockItemPositions, status: 200),
2353
]);
2454

2555
$connector = new BexioConnector(new ConnectWithToken);

0 commit comments

Comments
 (0)