Skip to content

Commit 14f8a99

Browse files
committed
Try to reproduce bug
1 parent ff5dcb6 commit 14f8a99

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

tests/ORM/Functional/Driver/Common/Integration/Case428/CaseTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ public function testSave(): void
6262
$this->save($purchaseOrder, ...$orderItems);
6363
}
6464

65+
public function testCreate(): void
66+
{
67+
$order = new Entity\Order('O0101');
68+
$purchaseOrder = new PurchaseOrder('PO101');
69+
70+
$orderItems = [];
71+
for ($i = 0; $i < 20; $i++) {
72+
$orderItem = new Entity\OrderItem('A' . $i, 1);
73+
$orderItem->order = $order;
74+
// $order->items[] = $orderItem;
75+
$orderItem->purchaseOrder = $purchaseOrder;
76+
$orderItems[] = $orderItem;
77+
}
78+
79+
$this->save($order, $purchaseOrder, ...$orderItems);
80+
}
81+
6582
public function setUp(): void
6683
{
6784
// Init DB

tests/ORM/Functional/Driver/Common/Integration/Case428/Entity/Order.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ public function __construct(string $number)
1616
{
1717
$this->number = $number;
1818
}
19-
2019
}

tests/ORM/Functional/Driver/Common/Integration/Case428/Entity/OrderItem.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66

77
class OrderItem
88
{
9-
109
public ?int $id = null;
11-
public int $order_id;
10+
1211
public string $sku;
1312
public int $quantity = 1;
13+
public int $status = 0;
14+
1415
public ?int $purchase_order_id = null;
1516
public ?PurchaseOrder $purchaseOrder = null;
16-
public int $status = 0;
17+
18+
public int $order_id;
19+
public Order $order;
1720

1821
public function __construct(string $sku, int $quantity = 1)
1922
{
2023
$this->sku = $sku;
2124
$this->quantity = $quantity;
2225
}
23-
2426
}

tests/ORM/Functional/Driver/Common/Integration/Case428/Entity/PurchaseOrder.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
class PurchaseOrder
88
{
9-
109
public ?int $id = null;
1110
public string $number;
11+
1212
/** @var iterable<PurchaseOrderItem> */
1313
public iterable $items = [];
1414

1515
public function __construct(string $number)
1616
{
1717
$this->number = $number;
1818
}
19-
2019
}

tests/ORM/Functional/Driver/Common/Integration/Case428/Entity/PurchaseOrderItem.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
class PurchaseOrderItem
88
{
9-
109
public ?int $id = null;
10+
public int $quantity = 1;
11+
1112
public int $purchase_order_id;
13+
public PurchaseOrder $purchaseOrder;
14+
1215
public ?int $order_item_id = null;
1316
public ?OrderItem $orderItem = null;
14-
public int $quantity = 1;
1517

1618
public function __construct(int $quantity = 1)
1719
{
1820
$this->quantity = $quantity;
1921
}
20-
2122
}

tests/ORM/Functional/Driver/Common/Integration/Case428/schema.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Cycle\ORM\Mapper\Mapper;
66
use Cycle\ORM\Relation;
7+
use Cycle\ORM\Schema\GeneratedField;
78
use Cycle\ORM\SchemaInterface as Schema;
89
use Cycle\ORM\Select\Repository;
910
use Cycle\ORM\Select\Source;
@@ -46,6 +47,9 @@
4647
'number' => 'string',
4748
],
4849
Schema::SCHEMA => [],
50+
Schema::GENERATED_FIELDS => [
51+
'id' => GeneratedField::ON_INSERT, // autoincrement
52+
],
4953
],
5054
'order_item' => [
5155
Schema::ENTITY => OrderItem::class,
@@ -96,6 +100,9 @@
96100
'status' => 'int',
97101
],
98102
Schema::SCHEMA => [],
103+
Schema::GENERATED_FIELDS => [
104+
'id' => GeneratedField::ON_INSERT, // autoincrement
105+
],
99106
],
100107
'purchase_order' => [
101108
Schema::ENTITY => PurchaseOrder::class,
@@ -132,6 +139,9 @@
132139
'number' => 'string',
133140
],
134141
Schema::SCHEMA => [],
142+
Schema::GENERATED_FIELDS => [
143+
'id' => GeneratedField::ON_INSERT, // autoincrement
144+
],
135145
],
136146
'purchase_order_item' => [
137147
Schema::ENTITY => PurchaseOrderItem::class,
@@ -169,5 +179,8 @@
169179
'quantity' => 'int',
170180
],
171181
Schema::SCHEMA => [],
182+
Schema::GENERATED_FIELDS => [
183+
'id' => GeneratedField::ON_INSERT, // autoincrement
184+
],
172185
],
173186
];

0 commit comments

Comments
 (0)