Failed Conditions
Push — 2.7 ( aeef8f...195140 )
by Michael
08:10
created

GH7068Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5
use Doctrine\DBAL\LockMode;
6
use Doctrine\ORM\TransactionRequiredException;
7
use Doctrine\Tests\OrmFunctionalTestCase;
8
9
final class GH7068Test extends OrmFunctionalTestCase
10
{
11
    /**
12
     * {@inheritDoc}
13
     */
14
    protected function setUp()
15
    {
16
        parent::setUp();
17
18
        $this->setUpEntitySchema(
19
            [
20
                SomeEntity::class,
21
            ]
22
        );
23
    }
24
25
    public function testLockModeIsRespected()
26
    {
27
        $entity = new SomeEntity();
28
        $this->_em->persist($entity);
29
        $this->_em->flush();
30
        $this->_em->clear();
31
32
        $this->_em->find(SomeEntity::class, 1);
33
34
        $this->expectException(TransactionRequiredException::class);
35
        $this->_em->find(SomeEntity::class, 1, LockMode::PESSIMISTIC_WRITE);
36
    }
37
}
38
39
/** @Entity */
40
final class SomeEntity {
41
    /** @Id @Column(type="integer") @GeneratedValue */
42
    public $id;
43
}
44