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