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