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

ApprovedStatusPropertyAnnotatorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
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\ApprovedStatusPropertyAnnotator;
6
use SMW\DIProperty;
7
use SMWDIString as DIString;
8
9
/**
10
 * @covers \SMW\ApprovedRevs\PropertyAnnotators\ApprovedStatusPropertyAnnotator
11
 * @group semantic-approved-revs
12
 *
13
 * @license GNU GPL v2+
14
 * @since 1.0
15
 */
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