Passed
Pull Request — master (#21)
by GIT
08:43 queued 44s
created

ApprovedRevPropertyAnnotatorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 58
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SMW\ApprovedRevs\Tests\PropertyAnnotators;
4
5
use SMW\ApprovedRevs\PropertyAnnotators\ApprovedRevPropertyAnnotator;
6
use SMW\DIProperty;
7
use SMW\DIWikiPage;
8
use SMWDINumber as DINumber;
9
10
/**
11
 * @covers \SMW\ApprovedRevs\PropertyAnnotators\ApprovedRevPropertyAnnotator
12
 * @group semantic-approved-revs
13
 *
14
 * @license GNU GPL v2+
15
 * @since 1.0
16
 */
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