1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\ApprovedRevs\Tests\PropertyAnnotators; |
4
|
|
|
|
5
|
|
|
use SMW\ApprovedRevs\PropertyAnnotators\ApprovedByPropertyAnnotator; |
6
|
|
|
use SMW\DIProperty; |
7
|
|
|
use SMW\DIWikiPage; |
8
|
|
|
use User; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @covers \SMW\ApprovedRevs\PropertyAnnotators\ApprovedByPropertyAnnotator |
12
|
|
|
* @group semantic-approved-revs |
13
|
|
|
* |
14
|
|
|
* @license GNU GPL v2+ |
15
|
|
|
* @since 1.0 |
16
|
|
|
*/ |
17
|
|
|
class ApprovedByPropertyAnnotatorTest extends \PHPUnit_Framework_TestCase { |
18
|
|
|
|
19
|
|
|
private $databaseLogReader; |
20
|
|
|
|
21
|
|
|
protected function setUp() { |
22
|
|
|
parent::setUp(); |
23
|
|
|
|
24
|
|
|
$this->databaseLogReader = $this->getMockBuilder( '\SMW\ApprovedRevs\DatabaseLogReader' ) |
25
|
|
|
->disableOriginalConstructor() |
26
|
|
|
->getMock(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testCanConstruct() { |
30
|
|
|
|
31
|
|
|
$this->assertInstanceOf( |
32
|
|
|
ApprovedByPropertyAnnotator::class, |
33
|
|
|
new ApprovedByPropertyAnnotator( $this->databaseLogReader ) |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testAddAnnotation() { |
38
|
|
|
|
39
|
|
|
$user = User::newFromName( "UnitTest" ); |
40
|
|
|
|
41
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
42
|
|
|
->disableOriginalConstructor() |
43
|
|
|
->getMock(); |
44
|
|
|
|
45
|
|
|
$semanticData->expects( $this->once() ) |
46
|
|
|
->method( 'addPropertyObjectValue' ) |
47
|
|
|
->with( |
48
|
|
|
$this->anyThing(), |
49
|
|
|
$this->equalTo( DIWikiPage::newFromTitle( $user->getUserPage() ) ) ); |
50
|
|
|
|
51
|
|
|
$annotator = new ApprovedByPropertyAnnotator( |
52
|
|
|
$this->databaseLogReader |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$annotator->setApprovedBy( $user ); |
56
|
|
|
$annotator->addAnnotation( $semanticData ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testRemoval() { |
60
|
|
|
|
61
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
62
|
|
|
->disableOriginalConstructor() |
63
|
|
|
->getMock(); |
64
|
|
|
|
65
|
|
|
$semanticData->expects( $this->once() ) |
66
|
|
|
->method( 'removeProperty' ); |
67
|
|
|
|
68
|
|
|
$annotator = new ApprovedByPropertyAnnotator( |
69
|
|
|
$this->databaseLogReader |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
$annotator->setApprovedBy( false ); |
|
|
|
|
73
|
|
|
$annotator->addAnnotation( $semanticData ); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: