1 | <?php |
||
17 | class ApprovedRevPropertyAnnotatorTest extends \PHPUnit_Framework_TestCase { |
||
18 | |||
19 | private $approvedRevsFacade; |
||
20 | |||
21 | protected function setUp(): void { |
||
22 | parent::setUp(); |
||
23 | |||
24 | $this->approvedRevsFacade = $this->getMockBuilder( '\SMW\ApprovedRevs\ApprovedRevsFacade' ) |
||
25 | ->disableOriginalConstructor() |
||
26 | ->getMock(); |
||
27 | } |
||
28 | |||
29 | public function testCanConstruct() { |
||
30 | |||
31 | $this->assertInstanceOf( |
||
32 | ApprovedRevPropertyAnnotator::class, |
||
33 | new ApprovedRevPropertyAnnotator( $this->approvedRevsFacade ) |
||
34 | ); |
||
35 | } |
||
36 | |||
37 | public function testAddAnnotation() { |
||
38 | |||
39 | $semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
||
40 | ->disableOriginalConstructor() |
||
41 | ->getMock(); |
||
42 | |||
43 | $semanticData->expects( $this->once() ) |
||
44 | ->method( 'addPropertyObjectValue' ) |
||
45 | ->with( |
||
46 | $this->anyThing(), |
||
47 | $this->equalTo( new DINumber( 42 ) ) ); |
||
48 | |||
49 | $annotator = new ApprovedRevPropertyAnnotator( |
||
50 | $this->approvedRevsFacade |
||
51 | ); |
||
52 | |||
53 | $annotator->setApprovedRev( 42 ); |
||
54 | $annotator->addAnnotation( $semanticData ); |
||
55 | } |
||
56 | |||
57 | public function testRemoval() { |
||
58 | |||
59 | $semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
||
60 | ->disableOriginalConstructor() |
||
61 | ->getMock(); |
||
62 | |||
63 | $semanticData->expects( $this->once() ) |
||
64 | ->method( 'removeProperty' ); |
||
65 | |||
66 | $annotator = new ApprovedRevPropertyAnnotator( |
||
67 | $this->approvedRevsFacade |
||
68 | ); |
||
69 | |||
70 | $annotator->setApprovedRev( false ); |
||
71 | $annotator->addAnnotation( $semanticData ); |
||
72 | } |
||
73 | |||
74 | } |
||
75 |