Completed
Push — master ( 984641...035d9e )
by Marco
36:13 queued 25:30
created

GH7068Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\ORM\Functional\Ticket;
6
7
use Doctrine\DBAL\LockMode;
8
use Doctrine\ORM\Annotation as ORM;
9
use Doctrine\ORM\TransactionRequiredException;
10
use Doctrine\Tests\OrmFunctionalTestCase;
11
12
final class GH7068Test extends OrmFunctionalTestCase
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17
    protected function setUp() : void
18
    {
19
        parent::setUp();
20
21
        $this->setUpEntitySchema(
22
            [
23
                SomeEntity::class,
24
            ]
25
        );
26
    }
27
28
    public function testLockModeIsRespected() : void
29
    {
30
        $entity = new SomeEntity();
31
        $this->em->persist($entity);
32
        $this->em->flush();
33
        $this->em->clear();
34
35
        $this->em->find(SomeEntity::class, 1);
36
37
        $this->expectException(TransactionRequiredException::class);
38
        $this->em->find(SomeEntity::class, 1, LockMode::PESSIMISTIC_WRITE);
0 ignored issues
show
Unused Code introduced by
The call to Doctrine\Common\Persistence\ObjectManager::find() has too many arguments starting with Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        $this->em->/** @scrutinizer ignore-call */ 
39
                   find(SomeEntity::class, 1, LockMode::PESSIMISTIC_WRITE);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
39
    }
40
}
41
42
/** @ORM\Entity */
43
final class SomeEntity
44
{
45
    /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue */
46
    public $id;
47
}
48