1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\DoctrineORMAdminBundle\Tests\Model; |
15
|
|
|
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
17
|
|
|
use SimpleThings\EntityAudit\AuditReader as SimpleThingsAuditReader; |
18
|
|
|
use Sonata\DoctrineORMAdminBundle\Model\AuditReader; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Marko Kunic <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class AuditReaderTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
private $simpleThingsAuditReader; |
26
|
|
|
private $auditReader; |
27
|
|
|
|
28
|
|
|
public function setUp(): void |
29
|
|
|
{ |
30
|
|
|
$this->simpleThingsAuditReader = $this->prophesize(SimpleThingsAuditReader::class); |
31
|
|
|
$this->auditReader = new AuditReader($this->simpleThingsAuditReader->reveal()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testFind(): void |
35
|
|
|
{ |
36
|
|
|
$this->simpleThingsAuditReader |
37
|
|
|
->find($className = 'fakeClass', $id = 1, $revision = 2) |
38
|
|
|
->shouldBeCalledTimes(1); |
39
|
|
|
|
40
|
|
|
$this->auditReader->find($className, $id, $revision); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testFindRevisionHistory(): void |
44
|
|
|
{ |
45
|
|
|
$this->simpleThingsAuditReader |
46
|
|
|
->findRevisionHistory($limit = 20, $offset = 0) |
47
|
|
|
->shouldBeCalledTimes(1); |
48
|
|
|
|
49
|
|
|
$this->auditReader->findRevisionHistory(null, $limit, $offset); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testFindRevision(): void |
53
|
|
|
{ |
54
|
|
|
$this->simpleThingsAuditReader |
55
|
|
|
->findRevision($revision = 2) |
56
|
|
|
->shouldBeCalledTimes(1); |
57
|
|
|
|
58
|
|
|
$this->auditReader->findRevision(null, $revision); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function testFindRevisions(): void |
62
|
|
|
{ |
63
|
|
|
$this->simpleThingsAuditReader |
64
|
|
|
->findRevisions($className = 'fakeClass', $id = 2) |
65
|
|
|
->shouldBeCalledTimes(1); |
66
|
|
|
|
67
|
|
|
$this->auditReader->findRevisions($className, $id); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function testDiff(): void |
71
|
|
|
{ |
72
|
|
|
$this->simpleThingsAuditReader |
73
|
|
|
->diff($className = 'fakeClass', $id = 1, $oldRevision = 1, $newRevision = 2); |
74
|
|
|
|
75
|
|
|
$this->auditReader->diff($className, $id, $oldRevision, $newRevision); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|