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\ApprovedDatePropertyAnnotator; |
||
| 6 | use SMW\DIProperty; |
||
| 7 | use MWTimestamp; |
||
| 8 | use SMWDITime as DITime; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @covers \SMW\ApprovedRevs\PropertyAnnotators\ApprovedDatePropertyAnnotator |
||
| 12 | * @group semantic-approved-revs |
||
| 13 | * |
||
| 14 | * @license GNU GPL v2+ |
||
| 15 | * @since 1.0 |
||
| 16 | */ |
||
| 17 | class ApprovedDatePropertyAnnotatorTest 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 | ApprovedDatePropertyAnnotator::class, |
||
| 33 | new ApprovedDatePropertyAnnotator( $this->databaseLogReader ) |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | protected static function getDITime( MWTimestamp $time ) { |
||
| 38 | return new DITime( |
||
| 39 | DITime::CM_GREGORIAN, |
||
| 40 | $time->format( 'Y' ), |
||
| 41 | $time->format( 'm' ), |
||
| 42 | $time->format( 'd' ), |
||
| 43 | $time->format( 'H' ), |
||
| 44 | $time->format( 'i' ) |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function testAddAnnotation() { |
||
| 49 | |||
| 50 | $now = new MWTimestamp( wfTimestampNow() ); |
||
| 51 | $time = self::getDITime( $now ); |
||
| 52 | |||
| 53 | $semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
||
| 54 | ->disableOriginalConstructor() |
||
| 55 | ->getMock(); |
||
| 56 | |||
| 57 | $semanticData->expects( $this->once() ) |
||
| 58 | ->method( 'addPropertyObjectValue' ) |
||
| 59 | ->with( |
||
| 60 | $this->anyThing(), |
||
| 61 | $this->equalTo( $time ) |
||
| 62 | ); |
||
| 63 | |||
| 64 | $annotator = new ApprovedDatePropertyAnnotator( |
||
| 65 | $this->databaseLogReader |
||
| 66 | ); |
||
| 67 | |||
| 68 | $annotator->setApprovedDate( $now ); |
||
| 69 | $annotator->addAnnotation( $semanticData ); |
||
| 70 | } |
||
| 71 | |||
| 72 | public function testRemoval() { |
||
| 73 | $semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
||
| 74 | ->disableOriginalConstructor() |
||
| 75 | ->getMock(); |
||
| 76 | |||
| 77 | $semanticData->expects( $this->once() ) |
||
| 78 | ->method( 'removeProperty' ); |
||
| 79 | |||
| 80 | $annotator = new ApprovedDatePropertyAnnotator( |
||
| 81 | $this->databaseLogReader |
||
| 82 | ); |
||
| 83 | |||
| 84 | $annotator->setApprovedDate( false ); |
||
|
0 ignored issues
–
show
|
|||
| 85 | $annotator->addAnnotation( $semanticData ); |
||
| 86 | } |
||
| 87 | |||
| 88 | } |
||
| 89 |
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: