1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
6
|
|
|
|
7
|
|
|
use Doctrine\Tests\Models\Quote\User as QuotedUser; |
8
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
9
|
|
|
|
10
|
|
|
final class GH7012Test extends OrmFunctionalTestCase |
11
|
|
|
{ |
12
|
|
|
protected function setUp() : void |
13
|
|
|
{ |
14
|
|
|
$this->useModelSet('quote'); |
15
|
|
|
|
16
|
|
|
parent::setUp(); |
17
|
|
|
|
18
|
|
|
$this->setUpEntitySchema([GH7012UserData::class]); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @group 7012 |
23
|
|
|
*/ |
24
|
|
|
public function testUpdateEntityWithIdentifierAssociationWithQuotedJoinColumn() : void |
25
|
|
|
{ |
26
|
|
|
$user = new QuotedUser(); |
27
|
|
|
$user->name = 'John Doe'; |
28
|
|
|
|
29
|
|
|
$this->_em->persist($user); |
30
|
|
|
$this->_em->flush(); |
31
|
|
|
|
32
|
|
|
$userData = new GH7012UserData($user, '123456789'); |
33
|
|
|
|
34
|
|
|
$this->_em->persist($userData); |
35
|
|
|
$this->_em->flush(); |
36
|
|
|
|
37
|
|
|
$userData->name = '4321'; |
38
|
|
|
$this->_em->flush(); |
39
|
|
|
|
40
|
|
|
$platform = $this->_em->getConnection()->getDatabasePlatform(); |
41
|
|
|
$quotedTableName = $platform->quoteIdentifier('quote-user-data'); |
42
|
|
|
$quotedColumn = $platform->quoteIdentifier('name'); |
43
|
|
|
$quotedIdentifier = $platform->quoteIdentifier('user-id'); |
44
|
|
|
|
45
|
|
|
self::assertNotEquals('quote-user-data', $quotedTableName); |
46
|
|
|
self::assertNotEquals('name', $quotedColumn); |
47
|
|
|
self::assertNotEquals('user-id', $quotedIdentifier); |
48
|
|
|
|
49
|
|
|
$queries = $this->_sqlLoggerStack->queries; |
50
|
|
|
|
51
|
|
|
$this->assertSQLEquals( |
52
|
|
|
sprintf('UPDATE %s SET %s = ? WHERE %s = ?', $quotedTableName, $quotedColumn, $quotedIdentifier), |
53
|
|
|
$queries[$this->_sqlLoggerStack->currentQuery - 1]['sql'] |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @Entity |
61
|
|
|
* @Table(name="`quote-user-data`") |
62
|
|
|
*/ |
63
|
|
|
class GH7012UserData |
64
|
|
|
{ |
65
|
|
|
/** |
66
|
|
|
* @Id |
67
|
|
|
* @OneToOne(targetEntity=Doctrine\Tests\Models\Quote\User::class) |
68
|
|
|
* @JoinColumn(name="`user-id`", referencedColumnName="`user-id`", onDelete="CASCADE") |
69
|
|
|
*/ |
70
|
|
|
public $user; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @Column(type="string", name="`name`") |
74
|
|
|
*/ |
75
|
|
|
public $name; |
76
|
|
|
|
77
|
|
|
public function __construct(QuotedUser $user, string $name) |
78
|
|
|
{ |
79
|
|
|
$this->user = $user; |
80
|
|
|
$this->name = $name; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|