Jeroen De Dauw has uploaded a new change for review. https://gerrit.wikimedia.org/r/64933
Change subject: Added UpdateFailedException ...................................................................... Added UpdateFailedException Change-Id: Ifd963ef53a0c18566c502e08b58a3888b7e1a6e8 --- A Database/includes/UpdateFailedException.php M Database/tests/phpunit/SelectFailedExceptionTest.php M Database/tests/phpunit/TableCreationFailedExceptionTest.php A Database/tests/phpunit/UpdateFailedExceptionTest.php 4 files changed, 132 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/33/64933/1 diff --git a/Database/includes/UpdateFailedException.php b/Database/includes/UpdateFailedException.php new file mode 100644 index 0000000..efd1e38 --- /dev/null +++ b/Database/includes/UpdateFailedException.php @@ -0,0 +1,64 @@ +<?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 < jeroended...@gmail.com > + */ +class UpdateFailedException extends QueryInterfaceException { + + protected $tableName; + protected $values; + protected $conditions; + + public function __construct( $tableName, array $values, array $conditions, $message = '', \Exception $previous = null ) { + parent::__construct( $message, 0, $previous ); + + $this->tableName = $tableName; + $this->conditions = $conditions; + $this->values = $values; + } + + /** + * @return string + */ + public function getTableName() { + return $this->tableName; + } + + /** + * @return array + */ + public function getConditions() { + return $this->conditions; + } + + /** + * @return array + */ + public function getValues() { + return $this->values; + } + +} \ No newline at end of file diff --git a/Database/tests/phpunit/SelectFailedExceptionTest.php b/Database/tests/phpunit/SelectFailedExceptionTest.php index 52a1462..7496190 100644 --- a/Database/tests/phpunit/SelectFailedExceptionTest.php +++ b/Database/tests/phpunit/SelectFailedExceptionTest.php @@ -5,7 +5,7 @@ use Wikibase\Database\SelectFailedException; /** - * @covers Wikibase\Database\SelectFailedException class. + * @covers Wikibase\Database\SelectFailedException * * 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 diff --git a/Database/tests/phpunit/TableCreationFailedExceptionTest.php b/Database/tests/phpunit/TableCreationFailedExceptionTest.php index 3b6a719..2570293 100644 --- a/Database/tests/phpunit/TableCreationFailedExceptionTest.php +++ b/Database/tests/phpunit/TableCreationFailedExceptionTest.php @@ -5,7 +5,7 @@ use Wikibase\Database\TableCreationFailedException; /** - * @covers Wikibase\Database\TableCreationFailedException class. + * @covers Wikibase\Database\TableCreationFailedException * * 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 diff --git a/Database/tests/phpunit/UpdateFailedExceptionTest.php b/Database/tests/phpunit/UpdateFailedExceptionTest.php new file mode 100644 index 0000000..46627a7 --- /dev/null +++ b/Database/tests/phpunit/UpdateFailedExceptionTest.php @@ -0,0 +1,66 @@ +<?php + +namespace Wikibase\Database\Tests; + +use Wikibase\Database\UpdateFailedException; + +/** + * @covers Wikibase\Database\UpdateFailedException + * + * 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 < jeroended...@gmail.com > + */ +class UpdateFailedExceptionTest extends \PHPUnit_Framework_TestCase { + + public function testConstructorWithOnlyRequiredArguments() { + $tableName = 'nyancats'; + $values = array( 'bar', 'baz', 'bah' ); + $conditions = array( 'foo' => 42, 'awesome > 9000' ); + + $exception = new UpdateFailedException( $tableName, $values, $conditions ); + + $this->assertEquals( $tableName, $exception->getTableName() ); + $this->assertEquals( $values, $exception->getValues() ); + $this->assertEquals( $conditions, $exception->getConditions() ); + } + + public function testConstructorWithAllArguments() { + $tableName = 'users'; + $fields = array( 'bar' ); + $conditions = array( 'foo' => 42 ); + $message = 'NyanData all the way accross the sky!'; + $previous = new \Exception( 'Onoez!' ); + + $exception = new UpdateFailedException( $tableName, $fields, $conditions, $message, $previous ); + + $this->assertEquals( $tableName, $exception->getTableName() ); + $this->assertEquals( $fields, $exception->getValues() ); + $this->assertEquals( $conditions, $exception->getConditions() ); + $this->assertEquals( $message, $exception->getMessage() ); + $this->assertEquals( $previous, $exception->getPrevious() ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/64933 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifd963ef53a0c18566c502e08b58a3888b7e1a6e8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits