Denny Vrandecic has submitted this change and it was merged.
Change subject: Added InsertFailedException
......................................................................
Added InsertFailedException
Change-Id: I12a18822c4f4ee2e8ea3cf950edba33fa53e59dc
---
M Database/includes/DeleteFailedException.php
A Database/includes/InsertFailedException.php
A Database/tests/phpunit/InsertFailedExceptionTest.php
3 files changed, 119 insertions(+), 2 deletions(-)
Approvals:
Denny Vrandecic: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Database/includes/DeleteFailedException.php
b/Database/includes/DeleteFailedException.php
index e940cc0..41b135b 100644
--- a/Database/includes/DeleteFailedException.php
+++ b/Database/includes/DeleteFailedException.php
@@ -31,11 +31,11 @@
protected $tableName;
protected $conditions;
- public function __construct( $tableName, array $conditions, $message =
'', \Exception $previous = null ) {
+ public function __construct( $tableName, array $values, $message = '',
\Exception $previous = null ) {
parent::__construct( $message, 0, $previous );
$this->tableName = $tableName;
- $this->conditions = $conditions;
+ $this->conditions = $values;
}
/**
diff --git a/Database/includes/InsertFailedException.php
b/Database/includes/InsertFailedException.php
new file mode 100644
index 0000000..aa7cb19
--- /dev/null
+++ b/Database/includes/InsertFailedException.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace Wikibase\Database;
+
+/**
+ * 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.1
+ *
+ * @file
+ * @ingroup WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class InsertFailedException extends QueryInterfaceException {
+
+ protected $tableName;
+ protected $values;
+
+ public function __construct( $tableName, array $values, $message = '',
\Exception $previous = null ) {
+ parent::__construct( $message, 0, $previous );
+
+ $this->tableName = $tableName;
+ $this->values = $values;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTableName() {
+ return $this->tableName;
+ }
+
+ /**
+ * @return array
+ */
+ public function getValues() {
+ return $this->values;
+ }
+
+}
diff --git a/Database/tests/phpunit/InsertFailedExceptionTest.php
b/Database/tests/phpunit/InsertFailedExceptionTest.php
new file mode 100644
index 0000000..d3dc897
--- /dev/null
+++ b/Database/tests/phpunit/InsertFailedExceptionTest.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Wikibase\Database\Tests;
+
+use Wikibase\Database\InsertFailedException;
+
+/**
+ * @covers Wikibase\Database\InsertFailedException
+ *
+ * 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 WikibaseDatabase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class InsertFailedExceptionTest extends \PHPUnit_Framework_TestCase {
+
+ public function testConstructorWithOnlyRequiredArguments() {
+ $tableName = 'nyancats';
+ $values = array( 'foo' => 42, 'awesome > 9000' );
+
+ $exception = new InsertFailedException( $tableName, $values );
+
+ $this->assertEquals( $tableName, $exception->getTableName() );
+ $this->assertEquals( $values, $exception->getValues() );
+ }
+
+ public function testConstructorWithAllArguments() {
+ $tableName = 'users';
+ $values = array( 'foo' => 42 );
+ $message = 'NyanData all the way accross the sky!';
+ $previous = new \Exception( 'Onoez!' );
+
+ $exception = new InsertFailedException( $tableName, $values,
$message, $previous );
+
+ $this->assertEquals( $tableName, $exception->getTableName() );
+ $this->assertEquals( $values, $exception->getValues() );
+ $this->assertEquals( $message, $exception->getMessage() );
+ $this->assertEquals( $previous, $exception->getPrevious() );
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/64939
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I12a18822c4f4ee2e8ea3cf950edba33fa53e59dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits