diff --git a/src/PropertyAnnotators/LinksToPropertyAnnotator.php b/src/PropertyAnnotators/LinksToPropertyAnnotator.php index 0f3b87e..2c4820e 100644 --- a/src/PropertyAnnotators/LinksToPropertyAnnotator.php +++ b/src/PropertyAnnotators/LinksToPropertyAnnotator.php @@ -14,7 +14,7 @@ * @private * @ingroup SESP * - * @license GNU GPL v2+ + * @license GPL-2.0-or-later * @since 3.0.4 */ class LinksToPropertyAnnotator implements PropertyAnnotator { @@ -22,7 +22,7 @@ class LinksToPropertyAnnotator implements PropertyAnnotator { /** * Predefined property ID */ - const PROP_ID = '___LINKSTO'; + public const PROP_ID = '___LINKSTO'; /** * @var AppFactory @@ -53,7 +53,7 @@ public function setEnabledNamespaces( array $namespaces ) { * {@inheritDoc} */ public function isAnnotatorFor( DIProperty $property ) { - return $property->getKey() === self::PROP_ID ; + return $property->getKey() === self::PROP_ID; } /** @@ -64,7 +64,11 @@ public function isAnnotatorFor( DIProperty $property ) { public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { $page = $semanticData->getSubject()->getTitle(); - if ( $page === null || ( !empty( $this->enabledNamespaces ) && !$page->inNamespaces( $this->enabledNamespaces ) ) ) { + if ( + $page === null || + ( !empty( $this->enabledNamespaces ) && + !$page->inNamespaces( $this->enabledNamespaces ) ) + ) { return; } @@ -89,7 +93,7 @@ public function addAnnotation( DIProperty $property, SemanticData $semanticData [ 'page' => [ 'JOIN', 'page_id=pl_from' ] ] ); - foreach( $res as $row ) { + foreach ( $res as $row ) { $title = Title::newFromText( $row->sel_title, $row->sel_ns ); if ( $title !== null && $title->exists() ) { $semanticData->addPropertyObjectValue( $property, DIWikiPage::newFromTitle( $title ) ); diff --git a/tests/phpunit/Unit/PropertyAnnotators/LinksToPropertyAnnotatorTest.php b/tests/phpunit/Unit/PropertyAnnotators/LinksToPropertyAnnotatorTest.php index aebf903..4201739 100644 --- a/tests/phpunit/Unit/PropertyAnnotators/LinksToPropertyAnnotatorTest.php +++ b/tests/phpunit/Unit/PropertyAnnotators/LinksToPropertyAnnotatorTest.php @@ -2,7 +2,6 @@ namespace SESP\Tests\PropertyAnnotators; -use PHPUnit_Framework_TestCase; use SESP\AppFactory; use SESP\PropertyAnnotators\LinksToPropertyAnnotator; use SMW\DIProperty; @@ -14,10 +13,10 @@ * @covers \SESP\PropertyAnnotators\LinksToPropertyAnnotator * @group semantic-extra-special-properties * - * @license GNU GPL v2+ + * @license GPL-2.0-or-later * @since 2.0 */ -class LinksToPropertyAnnotatorTest extends PHPUnit_Framework_TestCase { +class LinksToPropertyAnnotatorTest extends \PHPUnit\Framework\TestCase { private $property; private $appFactory; @@ -33,7 +32,6 @@ protected function setUp(): void { } public function testCanConstruct() { - $this->assertInstanceOf( LinksToPropertyAnnotator::class, new LinksToPropertyAnnotator( $this->appFactory ) @@ -41,7 +39,6 @@ public function testCanConstruct() { } public function testIsAnnotatorFor() { - $instance = new LinksToPropertyAnnotator( $this->appFactory ); @@ -56,7 +53,7 @@ public function testAddAnnotation() { ->disableOriginalConstructor() ->getMock(); - $factory->expects( $this->once() )->method('getConnection'); + $factory->expects( $this->once() )->method( 'getConnection' ); $subject = $this->getMockBuilder( DIWikiPage::class ) ->disableOriginalConstructor() @@ -90,7 +87,7 @@ public function testNotAddAnnotation() { ->getMock(); $factory->expects( $this->never() ) - ->method('getConnection'); + ->method( 'getConnection' ); $subject = $this->getMockBuilder( DIWikiPage::class ) ->disableOriginalConstructor()