|
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
|
|
|
class GH5804Generator extends AbstractIdGenerator |
|
48
|
|
|
{ |
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
|
|
public function generate(EntityManager $em, $entity) |
|
53
|
|
|
{ |
|
54
|
|
|
return 'test5804'; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
class GH5804Type extends \Doctrine\DBAL\Types\Type |
|
59
|
|
|
{ |
|
60
|
|
|
public function getName() |
|
61
|
|
|
{ |
|
62
|
|
|
return 'GH5804Type'; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritdoc} |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) |
|
69
|
|
|
{ |
|
70
|
|
|
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
77
|
|
|
{ |
|
78
|
|
|
if (empty($value)) { |
|
79
|
|
|
return null; |
|
80
|
|
|
} |
|
81
|
|
|
return 'testGh5804DbValue'; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|