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