jenkins-bot has submitted this change and it was merged.
Change subject: Put PropertyNotFoundException into its own file and added
PropertyId field
......................................................................
Put PropertyNotFoundException into its own file and added PropertyId field
Change-Id: Ie6dd4aa884aaf9be6c5ff7a4c721b9ec5d880e1a
---
M lib/WikibaseLib.classes.php
M lib/WikibaseLib.hooks.php
M lib/includes/EntityRetrievingDataTypeLookup.php
A lib/includes/PropertyNotFoundException.php
A lib/tests/phpunit/PropertyNotFoundExceptionTest.php
5 files changed, 100 insertions(+), 9 deletions(-)
Approvals:
Daniel Kinzler: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/WikibaseLib.classes.php b/lib/WikibaseLib.classes.php
index 6dd483d..6262c0c 100644
--- a/lib/WikibaseLib.classes.php
+++ b/lib/WikibaseLib.classes.php
@@ -51,6 +51,7 @@
'Wikibase\ReferencedEntitiesFinder' =>
'includes/ReferencedEntitiesFinder.php',
'Wikibase\ObjectComparer' => 'includes/ObjectComparer.php',
'Wikibase\Lib\PropertyDataTypeLookup' =>
'includes/PropertyDataTypeLookup.php',
+ 'Wikibase\Lib\PropertyNotFoundException' =>
'includes/PropertyNotFoundException.php',
'Wikibase\Settings' => 'includes/Settings.php',
'Wikibase\SettingsArray' => 'includes/SettingsArray.php',
'Wikibase\Lib\SnakFormatter' => 'includes/SnakFormatter.php',
diff --git a/lib/WikibaseLib.hooks.php b/lib/WikibaseLib.hooks.php
index dafd214..968e91e 100644
--- a/lib/WikibaseLib.hooks.php
+++ b/lib/WikibaseLib.hooks.php
@@ -77,6 +77,7 @@
'TemplateRegistry',
'LibHooks',
'MockRepository',
+ 'PropertyNotFoundException',
'SettingsArray',
'SnakFormatter',
diff --git a/lib/includes/EntityRetrievingDataTypeLookup.php
b/lib/includes/EntityRetrievingDataTypeLookup.php
index bff63d3..bab6eaf 100644
--- a/lib/includes/EntityRetrievingDataTypeLookup.php
+++ b/lib/includes/EntityRetrievingDataTypeLookup.php
@@ -2,7 +2,6 @@
namespace Wikibase\Lib;
-use DataTypes\DataType;
use InvalidArgumentException;
use Wikibase\EntityId;
use Wikibase\EntityLookup;
@@ -67,13 +66,13 @@
* @param EntityId $propertyId
*
* @return Property
- * @throws PropertyNotFoundExtension
+ * @throws PropertyNotFoundException
*/
private function getProperty( EntityId $propertyId ) {
$property = $this->entityLookup->getEntity( $propertyId );
if ( $property === null ) {
- throw new PropertyNotFoundExtension();
+ throw new PropertyNotFoundException( $propertyId );
}
assert( $property instanceof Property );
@@ -81,9 +80,3 @@
}
}
-
-class PropertyNotFoundExtension extends \RuntimeException {
-
-
-
-}
\ No newline at end of file
diff --git a/lib/includes/PropertyNotFoundException.php
b/lib/includes/PropertyNotFoundException.php
new file mode 100644
index 0000000..2386f57
--- /dev/null
+++ b/lib/includes/PropertyNotFoundException.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Wikibase\Lib;
+
+use Wikibase\EntityId;
+use Wikibase\Property;
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 0.4
+ *
+ * @file
+ * @ingroup WikibaseLib
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class PropertyNotFoundException extends \RuntimeException {
+
+ protected $propertyId;
+
+ public function __construct( EntityId $propertyId, $message = '',
\Exception $previous = null ) {
+ $this->propertyId = $propertyId;
+
+ parent::__construct( $message, 0, $previous );
+ }
+
+ /**
+ * @return EntityId
+ */
+ public function getPropertyId() {
+ return $this->propertyId;
+ }
+
+}
diff --git a/lib/tests/phpunit/PropertyNotFoundExceptionTest.php
b/lib/tests/phpunit/PropertyNotFoundExceptionTest.php
new file mode 100644
index 0000000..38aa72c
--- /dev/null
+++ b/lib/tests/phpunit/PropertyNotFoundExceptionTest.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Wikibase\Lib\Test;
+
+use Wikibase\EntityId;
+use Wikibase\Lib\PropertyNotFoundException;
+
+/**
+ * @covers Wikibase\Lib\PropertyNotFoundException class.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @since 0.1
+ *
+ * @ingroup WikibaseDatabaseTest
+ *
+ * @group Wikibase
+ * @group WikibaseLib
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class PropertyNotFoundExceptionTest extends \PHPUnit_Framework_TestCase {
+
+ public function testConstructorWithJustATable() {
+ $propertyId = new EntityId( 'item', 42 );
+
+ $exception = new PropertyNotFoundException( $propertyId );
+
+ $this->assertEquals( $propertyId, $exception->getPropertyId() );
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/64054
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie6dd4aa884aaf9be6c5ff7a4c721b9ec5d880e1a
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Anja Jentzsch <[email protected]>
Gerrit-Reviewer: Ataherivand <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Jens Ohlig <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: John Erling Blad <[email protected]>
Gerrit-Reviewer: Lydia Pintscher <[email protected]>
Gerrit-Reviewer: Markus Kroetzsch <[email protected]>
Gerrit-Reviewer: Nikola Smolenski <[email protected]>
Gerrit-Reviewer: Silke Meyer <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits