1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Cache\QueryCacheProfile; |
8
|
|
|
use Doctrine\DBAL\Connection; |
9
|
|
|
use Doctrine\ORM\Annotation as ORM; |
10
|
|
|
use Doctrine\ORM\EntityManager; |
11
|
|
|
use Doctrine\ORM\Tools\ToolsException; |
12
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @group DDC-3634 |
16
|
|
|
*/ |
17
|
|
|
class DDC3634Test extends OrmFunctionalTestCase |
18
|
|
|
{ |
19
|
|
|
protected function setUp() |
20
|
|
|
{ |
21
|
|
|
parent::setUp(); |
22
|
|
|
|
23
|
|
|
$metadata = $this->em->getClassMetadata(DDC3634Entity::class); |
24
|
|
|
|
25
|
|
|
if ( ! $metadata->getValueGenerationPlan()->containsDeferred()) { |
|
|
|
|
26
|
|
|
$this->markTestSkipped('Need a post-insert ID generator in order to make this test work correctly'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
try { |
30
|
|
|
$this->schemaTool->createSchema([ |
31
|
|
|
$metadata, |
32
|
|
|
$this->em->getClassMetadata(DDC3634JTIBaseEntity::class), |
33
|
|
|
$this->em->getClassMetadata(DDC3634JTIChildEntity::class), |
34
|
|
|
]); |
35
|
|
|
} catch (ToolsException $e) { |
36
|
|
|
// schema already in place |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testSavesVeryLargeIntegerAutoGeneratedValue() |
41
|
|
|
{ |
42
|
|
|
$veryLargeId = PHP_INT_MAX . PHP_INT_MAX; |
43
|
|
|
|
44
|
|
|
$entityManager = EntityManager::create( |
45
|
|
|
new DDC3634LastInsertIdMockingConnection($veryLargeId, $this->em->getConnection()), |
|
|
|
|
46
|
|
|
$this->em->getConfiguration() |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
$entity = new DDC3634Entity(); |
50
|
|
|
|
51
|
|
|
$entityManager->persist($entity); |
52
|
|
|
$entityManager->flush(); |
53
|
|
|
|
54
|
|
|
self::assertSame($veryLargeId, $entity->id); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testSavesIntegerAutoGeneratedValueAsString() |
58
|
|
|
{ |
59
|
|
|
$entity = new DDC3634Entity(); |
60
|
|
|
|
61
|
|
|
$this->em->persist($entity); |
62
|
|
|
$this->em->flush(); |
63
|
|
|
|
64
|
|
|
self::assertInternalType('string', $entity->id); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testSavesIntegerAutoGeneratedValueAsStringWithJoinedInheritance() |
68
|
|
|
{ |
69
|
|
|
$entity = new DDC3634JTIChildEntity(); |
70
|
|
|
|
71
|
|
|
$this->em->persist($entity); |
72
|
|
|
$this->em->flush(); |
73
|
|
|
|
74
|
|
|
self::assertInternalType('string', $entity->id); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** @ORM\Entity */ |
79
|
|
|
class DDC3634Entity |
80
|
|
|
{ |
81
|
|
|
/** @ORM\Id @ORM\Column(type="bigint") @ORM\GeneratedValue(strategy="AUTO") */ |
82
|
|
|
public $id; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @ORM\Entity |
87
|
|
|
* @ORM\InheritanceType("JOINED") |
88
|
|
|
* @ORM\DiscriminatorMap({ |
89
|
|
|
* DDC3634JTIBaseEntity::class = DDC3634JTIBaseEntity::class, |
90
|
|
|
* DDC3634JTIChildEntity::class = DDC3634JTIChildEntity::class, |
91
|
|
|
* }) |
92
|
|
|
*/ |
93
|
|
|
class DDC3634JTIBaseEntity |
94
|
|
|
{ |
95
|
|
|
/** @ORM\Id @ORM\Column(type="bigint") @ORM\GeneratedValue(strategy="AUTO") */ |
96
|
|
|
public $id; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** @ORM\Entity */ |
100
|
|
|
class DDC3634JTIChildEntity extends DDC3634JTIBaseEntity |
101
|
|
|
{ |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
class DDC3634LastInsertIdMockingConnection extends Connection |
105
|
|
|
{ |
106
|
|
|
/** |
107
|
|
|
* @var Connection |
108
|
|
|
*/ |
109
|
|
|
private $realConnection; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @var int |
113
|
|
|
*/ |
114
|
|
|
private $identifier; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @param int $identifier |
118
|
|
|
* @param Connection $realConnection |
119
|
|
|
*/ |
120
|
|
|
public function __construct($identifier, Connection $realConnection) |
121
|
|
|
{ |
122
|
|
|
$this->realConnection = $realConnection; |
123
|
|
|
$this->identifier = $identifier; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
private function forwardCall() |
127
|
|
|
{ |
128
|
|
|
$trace = debug_backtrace(0, 2)[1]; |
129
|
|
|
|
130
|
|
|
return call_user_func_array([$this->realConnection, $trace['function']], $trace['args']); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function getParams() |
134
|
|
|
{ |
135
|
|
|
return $this->forwardCall(); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function getDatabase() |
139
|
|
|
{ |
140
|
|
|
return $this->forwardCall(); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function getHost() |
144
|
|
|
{ |
145
|
|
|
return $this->forwardCall(); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function getPort() |
149
|
|
|
{ |
150
|
|
|
return $this->forwardCall(); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function getUsername() |
154
|
|
|
{ |
155
|
|
|
return $this->forwardCall(); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function getPassword() |
159
|
|
|
{ |
160
|
|
|
return $this->forwardCall(); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function getDriver() |
164
|
|
|
{ |
165
|
|
|
return $this->forwardCall(); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getConfiguration() |
169
|
|
|
{ |
170
|
|
|
return $this->forwardCall(); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function getEventManager() |
174
|
|
|
{ |
175
|
|
|
return $this->forwardCall(); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function getDatabasePlatform() |
179
|
|
|
{ |
180
|
|
|
return $this->forwardCall(); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
public function getExpressionBuilder() |
184
|
|
|
{ |
185
|
|
|
return $this->forwardCall(); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
public function connect() |
189
|
|
|
{ |
190
|
|
|
return $this->forwardCall(); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
public function isAutoCommit() |
194
|
|
|
{ |
195
|
|
|
return $this->forwardCall(); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
public function setAutoCommit($autoCommit) |
199
|
|
|
{ |
200
|
|
|
return $this->forwardCall(); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
public function setFetchMode($fetchMode) |
204
|
|
|
{ |
205
|
|
|
return $this->forwardCall(); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
public function fetchAssoc($statement, array $params = [], array $types = []) |
209
|
|
|
{ |
210
|
|
|
return $this->forwardCall(); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
public function fetchArray($statement, array $params = [], array $types = []) |
214
|
|
|
{ |
215
|
|
|
return $this->forwardCall(); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
public function fetchColumn($statement, array $params = [], $column = 0, array $types = []) |
219
|
|
|
{ |
220
|
|
|
return $this->forwardCall(); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public function isConnected() |
224
|
|
|
{ |
225
|
|
|
return $this->forwardCall(); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function isTransactionActive() |
229
|
|
|
{ |
230
|
|
|
return $this->forwardCall(); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
public function delete($tableExpression, array $identifier, array $types = []) |
234
|
|
|
{ |
235
|
|
|
return $this->forwardCall(); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
public function close() |
239
|
|
|
{ |
240
|
|
|
return $this->forwardCall(); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
public function setTransactionIsolation($level) |
244
|
|
|
{ |
245
|
|
|
return $this->forwardCall(); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
public function getTransactionIsolation() |
249
|
|
|
{ |
250
|
|
|
return $this->forwardCall(); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
public function update($tableExpression, array $data, array $identifier, array $types = []) |
254
|
|
|
{ |
255
|
|
|
return $this->forwardCall(); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
public function insert($tableExpression, array $data, array $types = []) |
259
|
|
|
{ |
260
|
|
|
return $this->forwardCall(); |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
public function quoteIdentifier($str) |
264
|
|
|
{ |
265
|
|
|
return $this->forwardCall(); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
public function quote($input, $type = null) |
269
|
|
|
{ |
270
|
|
|
return $this->forwardCall(); |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
public function fetchAll($sql, array $params = [], $types = []) |
274
|
|
|
{ |
275
|
|
|
return $this->forwardCall(); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
public function prepare($statement) |
279
|
|
|
{ |
280
|
|
|
return $this->forwardCall(); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null) |
284
|
|
|
{ |
285
|
|
|
return $this->forwardCall(); |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp) |
289
|
|
|
{ |
290
|
|
|
return $this->forwardCall(); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
public function project($query, array $params, \Closure $function) |
294
|
|
|
{ |
295
|
|
|
return $this->forwardCall(); |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
public function query() |
299
|
|
|
{ |
300
|
|
|
return $this->forwardCall(); |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
public function executeUpdate($query, array $params = [], array $types = []) |
304
|
|
|
{ |
305
|
|
|
return $this->forwardCall(); |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
public function exec($statement) |
309
|
|
|
{ |
310
|
|
|
return $this->forwardCall(); |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
public function getTransactionNestingLevel() |
314
|
|
|
{ |
315
|
|
|
return $this->forwardCall(); |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
public function errorCode() |
319
|
|
|
{ |
320
|
|
|
return $this->forwardCall(); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
public function errorInfo() |
324
|
|
|
{ |
325
|
|
|
return $this->forwardCall(); |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
public function lastInsertId($seqName = null) |
329
|
|
|
{ |
330
|
|
|
return $this->identifier; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
public function transactional(\Closure $func) |
334
|
|
|
{ |
335
|
|
|
return $this->forwardCall(); |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints) |
339
|
|
|
{ |
340
|
|
|
return $this->forwardCall(); |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
public function getNestTransactionsWithSavepoints() |
344
|
|
|
{ |
345
|
|
|
return $this->forwardCall(); |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
protected function getNestedTransactionSavePointName() |
349
|
|
|
{ |
350
|
|
|
return $this->forwardCall(); |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
public function beginTransaction() |
354
|
|
|
{ |
355
|
|
|
return $this->forwardCall(); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
public function commit() |
359
|
|
|
{ |
360
|
|
|
return $this->forwardCall(); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
public function rollBack() |
364
|
|
|
{ |
365
|
|
|
return $this->forwardCall(); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
public function createSavepoint($savepoint) |
369
|
|
|
{ |
370
|
|
|
return $this->forwardCall(); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
public function releaseSavepoint($savepoint) |
374
|
|
|
{ |
375
|
|
|
return $this->forwardCall(); |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
public function rollbackSavepoint($savepoint) |
379
|
|
|
{ |
380
|
|
|
return $this->forwardCall(); |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
public function getWrappedConnection() |
384
|
|
|
{ |
385
|
|
|
return $this->forwardCall(); |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
public function getSchemaManager() |
389
|
|
|
{ |
390
|
|
|
return $this->forwardCall(); |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
public function setRollbackOnly() |
394
|
|
|
{ |
395
|
|
|
return $this->forwardCall(); |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
public function isRollbackOnly() |
399
|
|
|
{ |
400
|
|
|
return $this->forwardCall(); |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
public function convertToDatabaseValue($value, $type) |
404
|
|
|
{ |
405
|
|
|
return $this->forwardCall(); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
public function convertToPHPValue($value, $type) |
409
|
|
|
{ |
410
|
|
|
return $this->forwardCall(); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
public function resolveParams(array $params, array $types) |
414
|
|
|
{ |
415
|
|
|
return $this->forwardCall(); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
public function createQueryBuilder() |
419
|
|
|
{ |
420
|
|
|
return $this->forwardCall(); |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
public function ping() |
424
|
|
|
{ |
425
|
|
|
return $this->forwardCall(); |
426
|
|
|
} |
427
|
|
|
} |
428
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.