Completed
Push — master ( ec265b...65ebad )
by Luís
14s
created

GH7067Test::testSLCWithVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Doctrine\Tests\ORM\Functional\Ticket;
5
6
use Doctrine\ORM\Annotation as ORM;
7
8
final class GH7067Test extends \Doctrine\Tests\OrmFunctionalTestCase
9
{
10
    public function setUp() : void
11
    {
12
        $this->enableSecondLevelCache();
13
        parent::setUp();
14
15
        $this->setUpEntitySchema([GH7067Entity::class]);
16
    }
17
18
    /**
19
     * @group 7067
20
     */
21
    public function testSLCWithVersion() : void
22
    {
23
        $entity             = new GH7067Entity();
24
        $entity->lastUpdate = new \DateTime();
25
26
        $this->em->persist($entity);
27
        $this->em->flush();
28
        $this->em->clear();
29
30
        /** @var GH7067Entity $notCached */
31
        $notCached = $this->em->find(GH7067Entity::class, $entity->id);
32
33
        self::assertNotNull($notCached->version, 'Version already cached by persister above, it must be not null');
34
35
        $notCached->lastUpdate = new \DateTime();
36
37
        $this->em->flush();
38
        $this->em->clear();
39
    }
40
}
41
42
/**
43
 * @ORM\Entity()
44
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE")
45
 */
46
class GH7067Entity
47
{
48
    /**
49
     * @ORM\Id
50
     * @ORM\GeneratedValue
51
     * @ORM\Column(type="integer")
52
     */
53
    public $id;
54
55
    /**
56
     * @ORM\Column(type="datetime")
57
     *
58
     * @var \DateTime
59
     */
60
    public $lastUpdate;
61
62
    /**
63
     * @ORM\Column(type="datetime")
64
     * @ORM\Version()
65
     *
66
     * @var \DateTime
67
     */
68
    public $version;
69
}
70