1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
6
|
|
|
use Doctrine\ORM\EntityManager; |
7
|
|
|
use Doctrine\ORM\Id\AbstractIdGenerator; |
8
|
|
|
use Doctrine\Tests\Models\GH5804\GH5804Article; |
9
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @group 6402 |
13
|
|
|
*/ |
14
|
|
|
class GH5804Test extends OrmFunctionalTestCase |
15
|
|
|
{ |
16
|
|
|
protected function setUp() |
17
|
|
|
{ |
18
|
|
|
$this->useModelSet('gh5804'); |
19
|
|
|
parent::setUp(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public static function setUpBeforeClass() |
23
|
|
|
{ |
24
|
|
|
\Doctrine\DBAL\Types\Type::addType('GH5804Type', GH5804Type::class); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @group GH-5804 |
29
|
|
|
*/ |
30
|
|
|
public function testTextColumnSaveAndRetrieve2() |
31
|
|
|
{ |
32
|
|
|
$firstArticle = new GH5804Article; |
33
|
|
|
$firstArticle->text = 'Max'; |
34
|
|
|
$this->_em->persist($firstArticle); |
35
|
|
|
$this->_em->flush(); |
36
|
|
|
|
37
|
|
|
self::assertSame(1, $firstArticle->version); |
38
|
|
|
|
39
|
|
|
$firstArticle->text = 'Moritz'; |
40
|
|
|
$this->_em->persist($firstArticle); |
41
|
|
|
$this->_em->flush(); |
42
|
|
|
|
43
|
|
|
self::assertSame(2, $firstArticle->version); |
44
|
|
|
|
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
class GH5804Generator extends AbstractIdGenerator |
49
|
|
|
{ |
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
|
|
public function generate(EntityManager $em, $entity) |
54
|
|
|
{ |
55
|
|
|
return 'test5804'; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
class GH5804Type extends \Doctrine\DBAL\Types\Type |
60
|
|
|
{ |
61
|
|
|
public function getName() |
62
|
|
|
{ |
63
|
|
|
return 'GH5804Type'; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
*/ |
69
|
|
|
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) |
70
|
|
|
{ |
71
|
|
|
return $platform->getGuidTypeDeclarationSQL($fieldDeclaration); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
|
|
public function convertToDatabaseValue($value, AbstractPlatform $platform) |
78
|
|
|
{ |
79
|
|
|
if (empty($value)) { |
80
|
|
|
return null; |
81
|
|
|
} |
82
|
|
|
return 'testGh5804DbValue'; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
|