8
8
use Cycle \ORM \Entity \Behavior \Exception \OptimisticLock \RecordIsLockedException ;
9
9
use Cycle \ORM \Entity \Behavior \Listener \OptimisticLock ;
10
10
use Cycle \ORM \Entity \Behavior \Tests \Fixtures \OptimisticLock \Comment ;
11
+ use Cycle \ORM \Entity \Behavior \Tests \Fixtures \OptimisticLock \Author ;
11
12
use Cycle \ORM \Entity \Behavior \Tests \Functional \Driver \Common \BaseListenerTest ;
12
13
use Cycle \ORM \Entity \Behavior \Tests \Traits \TableTrait ;
13
14
use Cycle \ORM \Heap \Heap ;
14
15
use Cycle \ORM \Schema ;
15
16
use Cycle \ORM \SchemaInterface ;
17
+ use Cycle \ORM \Relation ;
16
18
use Cycle \ORM \Select ;
17
19
use Cycle \ORM \Transaction ;
18
20
@@ -34,6 +36,8 @@ public function setUp(): void
34
36
'version_microtime ' => 'string ' ,
35
37
'version_custom ' => 'int,nullable ' ,
36
38
'content ' => 'string,nullable ' ,
39
+ 'author_first_name ' => 'string ' ,
40
+ 'author_last_name ' => 'string ' ,
37
41
]
38
42
);
39
43
@@ -81,8 +85,25 @@ public function setUp(): void
81
85
'versionDatetime ' => 'datetime '
82
86
],
83
87
SchemaInterface::SCHEMA => [],
84
- SchemaInterface::RELATIONS => [],
88
+ SchemaInterface::RELATIONS => [
89
+ 'author ' => [
90
+ Relation::TYPE => Relation::EMBEDDED ,
91
+ Relation::TARGET => Author::class,
92
+ Relation::LOAD => Relation::LOAD_EAGER ,
93
+ Relation::SCHEMA => [],
94
+ ]
95
+ ],
85
96
],
97
+ Author::class => [
98
+ SchemaInterface::ENTITY => Author::class,
99
+ SchemaInterface::DATABASE => 'default ' ,
100
+ SchemaInterface::TABLE => 'comments ' ,
101
+ SchemaInterface::PRIMARY_KEY => ['id ' ],
102
+ SchemaInterface::COLUMNS => [
103
+ 'first_name ' => 'author_first_name ' ,
104
+ 'last_name ' => 'author_last_name ' ,
105
+ ],
106
+ ]
86
107
]));
87
108
}
88
109
@@ -95,7 +116,7 @@ public function testAddVersionOnCreate()
95
116
96
117
$ this ->orm = $ this ->orm ->with (heap: new Heap ());
97
118
$ select = new Select ($ this ->orm , Comment::class);
98
-
119
+
99
120
$ comment = $ select ->fetchOne ();
100
121
101
122
$ this ->assertSame (1 , $ comment ->versionInt );
0 commit comments