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
|
|
|
private $simpleThingsAuditReader; |
24
|
|
|
private $auditReader; |
25
|
|
|
|
26
|
|
|
public function setUp() |
27
|
|
|
{ |
28
|
|
|
$this->simpleThingsAuditReader = $this->prophesize(SimpleThingsAuditReader::class); |
29
|
|
|
$this->auditReader = new AuditReader($this->simpleThingsAuditReader->reveal()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testFind() |
33
|
|
|
{ |
34
|
|
|
$this->simpleThingsAuditReader |
35
|
|
|
->find($className = 'fakeClass', $id = 1, $revision = 2) |
36
|
|
|
->shouldBeCalledTimes(1); |
37
|
|
|
|
38
|
|
|
$this->auditReader->find($className, $id, $revision); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testFindRevisionHistory() |
42
|
|
|
{ |
43
|
|
|
$this->simpleThingsAuditReader |
44
|
|
|
->findRevisionHistory($limit = 20, $offset = 0) |
45
|
|
|
->shouldBeCalledTimes(1); |
46
|
|
|
|
47
|
|
|
$this->auditReader->findRevisionHistory(null, $limit, $offset); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testFindRevision() |
51
|
|
|
{ |
52
|
|
|
$this->simpleThingsAuditReader |
53
|
|
|
->findRevision($revision = 2) |
54
|
|
|
->shouldBeCalledTimes(1); |
55
|
|
|
|
56
|
|
|
$this->auditReader->findRevision(null, $revision); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testFindRevisions() |
60
|
|
|
{ |
61
|
|
|
$this->simpleThingsAuditReader |
62
|
|
|
->findRevisions($className = 'fakeClass', $id = 2) |
63
|
|
|
->shouldBeCalledTimes(1); |
64
|
|
|
|
65
|
|
|
$this->auditReader->findRevisions($className, $id); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function testDiff() |
69
|
|
|
{ |
70
|
|
|
$this->simpleThingsAuditReader |
71
|
|
|
->diff($className = 'fakeClass', $id = 1, $oldRevision = 1, $newRevision = 2); |
72
|
|
|
|
73
|
|
|
$this->auditReader->diff($className, $id, $oldRevision, $newRevision); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|