File tree 6 files changed +41
-10
lines changed
tests/ORM/Functional/Driver/Common/Integration/Case428
6 files changed +41
-10
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,23 @@ public function testSave(): void
62
62
$ this ->save ($ purchaseOrder , ...$ orderItems );
63
63
}
64
64
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
+
65
82
public function setUp (): void
66
83
{
67
84
// Init DB
Original file line number Diff line number Diff line change @@ -16,5 +16,4 @@ public function __construct(string $number)
16
16
{
17
17
$ this ->number = $ number ;
18
18
}
19
-
20
19
}
Original file line number Diff line number Diff line change 6
6
7
7
class OrderItem
8
8
{
9
-
10
9
public ?int $ id = null ;
11
- public int $ order_id ;
10
+
12
11
public string $ sku ;
13
12
public int $ quantity = 1 ;
13
+ public int $ status = 0 ;
14
+
14
15
public ?int $ purchase_order_id = null ;
15
16
public ?PurchaseOrder $ purchaseOrder = null ;
16
- public int $ status = 0 ;
17
+
18
+ public int $ order_id ;
19
+ public Order $ order ;
17
20
18
21
public function __construct (string $ sku , int $ quantity = 1 )
19
22
{
20
23
$ this ->sku = $ sku ;
21
24
$ this ->quantity = $ quantity ;
22
25
}
23
-
24
26
}
Original file line number Diff line number Diff line change 6
6
7
7
class PurchaseOrder
8
8
{
9
-
10
9
public ?int $ id = null ;
11
10
public string $ number ;
11
+
12
12
/** @var iterable<PurchaseOrderItem> */
13
13
public iterable $ items = [];
14
14
15
15
public function __construct (string $ number )
16
16
{
17
17
$ this ->number = $ number ;
18
18
}
19
-
20
19
}
Original file line number Diff line number Diff line change 6
6
7
7
class PurchaseOrderItem
8
8
{
9
-
10
9
public ?int $ id = null ;
10
+ public int $ quantity = 1 ;
11
+
11
12
public int $ purchase_order_id ;
13
+ public PurchaseOrder $ purchaseOrder ;
14
+
12
15
public ?int $ order_item_id = null ;
13
16
public ?OrderItem $ orderItem = null ;
14
- public int $ quantity = 1 ;
15
17
16
18
public function __construct (int $ quantity = 1 )
17
19
{
18
20
$ this ->quantity = $ quantity ;
19
21
}
20
-
21
22
}
Original file line number Diff line number Diff line change 4
4
5
5
use Cycle \ORM \Mapper \Mapper ;
6
6
use Cycle \ORM \Relation ;
7
+ use Cycle \ORM \Schema \GeneratedField ;
7
8
use Cycle \ORM \SchemaInterface as Schema ;
8
9
use Cycle \ORM \Select \Repository ;
9
10
use Cycle \ORM \Select \Source ;
46
47
'number ' => 'string ' ,
47
48
],
48
49
Schema::SCHEMA => [],
50
+ Schema::GENERATED_FIELDS => [
51
+ 'id ' => GeneratedField::ON_INSERT , // autoincrement
52
+ ],
49
53
],
50
54
'order_item ' => [
51
55
Schema::ENTITY => OrderItem::class,
96
100
'status ' => 'int ' ,
97
101
],
98
102
Schema::SCHEMA => [],
103
+ Schema::GENERATED_FIELDS => [
104
+ 'id ' => GeneratedField::ON_INSERT , // autoincrement
105
+ ],
99
106
],
100
107
'purchase_order ' => [
101
108
Schema::ENTITY => PurchaseOrder::class,
132
139
'number ' => 'string ' ,
133
140
],
134
141
Schema::SCHEMA => [],
142
+ Schema::GENERATED_FIELDS => [
143
+ 'id ' => GeneratedField::ON_INSERT , // autoincrement
144
+ ],
135
145
],
136
146
'purchase_order_item ' => [
137
147
Schema::ENTITY => PurchaseOrderItem::class,
169
179
'quantity ' => 'int ' ,
170
180
],
171
181
Schema::SCHEMA => [],
182
+ Schema::GENERATED_FIELDS => [
183
+ 'id ' => GeneratedField::ON_INSERT , // autoincrement
184
+ ],
172
185
],
173
186
];
You can’t perform that action at this time.
0 commit comments