Completed
Pull Request — 3.x (#807)
by
unknown
01:48
created

AuditReaderTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\DoctrineORMAdminBundle\Tests\Model;
13
14
use PHPUnit\Framework\TestCase;
15
use SimpleThings\EntityAudit\AuditReader as SimpleThingsAuditReader;
16
use Sonata\DoctrineORMAdminBundle\Model\AuditReader;
17
18
/**
19
 * @author Marko Kunic <[email protected]>
20
 */
21
class AuditReaderTest extends TestCase
22
{
23
    /**
24
     * @var SimpleThingsAuditReader
25
     */
26
    private $simpleThingsAuditReader;
27
28
    /**
29
     * @var AuditReader
30
     */
31
    private $auditReader;
32
33
    public function setUp()
34
    {
35
        $this->simpleThingsAuditReader = $this->prophesize(SimpleThingsAuditReader::class);
36
        $this->auditReader = new AuditReader($this->simpleThingsAuditReader->reveal());
37
    }
38
39
    public function testFind()
40
    {
41
        $this->simpleThingsAuditReader
42
            ->find($className = 'fakeClass', $id = 1, $revision = 2)
43
            ->shouldBeCalledTimes(1);
44
45
        $this->auditReader->find($className, $id, $revision);
46
    }
47
48
    public function testFindRevisionHistory()
49
    {
50
        $this->simpleThingsAuditReader
0 ignored issues
show
Bug introduced by
The method shouldBeCalledTimes cannot be called on $this->simpleThingsAudit...imit = 20, $offset = 0) (of type array<integer,object<Sim...\EntityAudit\Revision>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
51
            ->findRevisionHistory($limit = 20, $offset = 0)
52
            ->shouldBeCalledTimes(1);
53
54
        $this->auditReader->findRevisionHistory(null, $limit, $offset);
55
    }
56
57
    public function testFindRevision()
58
    {
59
        $this->simpleThingsAuditReader
0 ignored issues
show
Bug introduced by
The method shouldBeCalledTimes() does not seem to exist on object<SimpleThings\EntityAudit\Revision>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
            ->findRevision($revision = 2)
61
            ->shouldBeCalledTimes(1);
62
63
        $this->auditReader->findRevision(null, $revision);
64
    }
65
66
    public function testFindRevisions()
67
    {
68
        $this->simpleThingsAuditReader
0 ignored issues
show
Bug introduced by
The method shouldBeCalledTimes cannot be called on $this->simpleThingsAudit...= 'fakeClass', $id = 2) (of type array<integer,object<Sim...\EntityAudit\Revision>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
69
            ->findRevisions($className = 'fakeClass', $id = 2)
70
            ->shouldBeCalledTimes(1);
71
72
        $this->auditReader->findRevisions($className, $id);
73
    }
74
75
    public function testDiff()
76
    {
77
        $this->simpleThingsAuditReader
0 ignored issues
show
Bug introduced by
The method shouldBeCalledTimes cannot be called on $this->simpleThingsAudit... = 1, $newRevision = 2) (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
78
            ->diff($className = 'fakeClass', $id = 1, $oldRevision = 1, $newRevision = 2)
79
            ->shouldBeCalledTimes(1);
80
81
        $this->auditReader->diff($className, $id, $oldRevision, $newRevision);
82
    }
83
}
84