Completed
Push — 2.6 ( 496c6a...794c77 )
by Luís
13:47
created

GH7067Test   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

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