@@ -35,21 +35,15 @@ public function testNoExtraUpdateWithApplicationGeneratedId(): void
35
35
}
36
36
37
37
$ this ->_em ->flush ();
38
- if ($ this ->isQueryLogAvailable ()) {
39
- if ($ this ->getQueryLog ()->queries [0 ]['sql ' ] === '"START TRANSACTION" ' ) {
40
- self ::assertQueryCount (3 );
41
- } else {
42
- self ::assertQueryCount (1 );
43
- }
44
- }
38
+ $ this ->checkQueryCount (false );
45
39
46
40
$ this ->_em ->clear ();
47
41
48
42
$ child = $ this ->_em ->find (GH7877ApplicationGenerated::class, $ entityId );
49
43
$ this ->assertSame ($ entityId , $ child ->parent ->id );
50
44
}
51
45
52
- public function textExtraUpdateWithDatabaseGeneratedId (): void
46
+ public function testExtraUpdateWithDatabaseGeneratedId (): void
53
47
{
54
48
$ entity = new GH7877DatabaseGenerated ();
55
49
$ entity ->parent = $ entity ;
@@ -60,20 +54,27 @@ public function textExtraUpdateWithDatabaseGeneratedId(): void
60
54
}
61
55
62
56
$ this ->_em ->flush ();
63
- if ($ this ->isQueryLogAvailable ()) {
64
- if ($ this ->getQueryLog ()->queries [0 ]['sql ' ] === '"START TRANSACTION" ' ) {
65
- self ::assertQueryCount (4 );
66
- } else {
67
- self ::assertQueryCount (2 );
68
- }
69
- }
57
+ $ this ->checkQueryCount (
58
+ $ this ->_em ->getClassMetadata (GH7877DatabaseGenerated::class)->idGenerator ->isPostInsertGenerator ()
59
+ );
70
60
71
61
$ entityId = $ entity ->id ;
72
62
$ this ->_em ->clear ();
73
63
74
64
$ child = $ this ->_em ->find (GH7877DatabaseGenerated::class, $ entityId );
75
65
$ this ->assertSame ($ entityId , $ child ->parent ->id );
76
66
}
67
+
68
+ private function checkQueryCount (bool $ extra ): void
69
+ {
70
+ if ($ this ->isQueryLogAvailable ()) {
71
+ if ($ this ->getQueryLog ()->queries [0 ]['sql ' ] === '"START TRANSACTION" ' ) {
72
+ self ::assertQueryCount ($ extra ? 4 : 3 );
73
+ } else {
74
+ self ::assertQueryCount ($ extra ? 2 : 1 );
75
+ }
76
+ }
77
+ }
77
78
}
78
79
79
80
/**
0 commit comments