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\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() { |
||
| 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 ); |
||
|
0 ignored issues
–
show
|
|||
| 70 | $annotator->addAnnotation( $semanticData ); |
||
| 71 | } |
||
| 72 | |||
| 73 | } |
||
| 74 |
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: