SemanticMediaWiki /
SemanticApprovedRevs
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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() { |
||
| 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 ); |
||
|
0 ignored issues
–
show
|
|||
| 71 | $annotator->addAnnotation( $semanticData ); |
||
| 72 | } |
||
| 73 | |||
| 74 | } |
||
| 75 |
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: