Jeroen De Dauw has uploaded a new change for review. https://gerrit.wikimedia.org/r/50634
Change subject: Added TableDefinitionTest ...................................................................... Added TableDefinitionTest Change-Id: Ibdf324d85c3f3093aa46af2d4407a77936711322 --- M repo/Wikibase.hooks.php A repo/tests/phpunit/includes/Database/TableDefinitionTest.php 2 files changed, 98 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/34/50634/1 diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 002f238..5f3e700 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -186,6 +186,7 @@ 'content/PropertyHandler', 'Database/FieldDefinition', + 'Database/TableDefinition', 'specials/SpecialCreateItem', 'specials/SpecialItemDisambiguation', diff --git a/repo/tests/phpunit/includes/Database/TableDefinitionTest.php b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php new file mode 100644 index 0000000..aa7681e --- /dev/null +++ b/repo/tests/phpunit/includes/Database/TableDefinitionTest.php @@ -0,0 +1,97 @@ +<?php + +namespace Wikibase\Repo\Test\Database; + +use Wikibase\Repo\Database\FieldDefinition; +use Wikibase\Repo\Database\TableDefinition; + +/** + * Unit test Wikibase\Repo\Database\TableDefinitionTest 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.4 + * + * @ingroup WikibaseRepoTest + * + * @group Wikibase + * @group WikibaseRepo + * @group WikibaseDatabase + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < jeroended...@gmail.com > + */ +class TableDefinitionTest extends \MediaWikiTestCase { + + public function instanceProvider() { + $instances = array(); + + $instances[] = new TableDefinition( + 'snaks', + array( + new FieldDefinition( 'omnomnom', FieldDefinition::TYPE_TEXT ) + ) + ); + + $instances[] = new TableDefinition( + 'spam', + array( + new FieldDefinition( 'o', FieldDefinition::TYPE_TEXT ), + new FieldDefinition( 'h', FieldDefinition::TYPE_TEXT ), + new FieldDefinition( 'i', FieldDefinition::TYPE_INTEGER, 42 ), + ) + ); + + return $this->arrayWrap( $instances ); + } + + /** + * @dataProvider instanceProvider + * + * @param TableDefinition $table + */ + public function testReturnValueOfGetName( TableDefinition $table ) { + $this->assertInternalType( 'string', $table->getName() ); + + $newTable = new TableDefinition( $table->getName(), $table->getFields() ); + + $this->assertEquals( + $table->getName(), + $newTable->getName(), + 'The TableDefinition name is set and obtained correctly' + ); + } + + /** + * @dataProvider instanceProvider + * + * @param TableDefinition $table + */ + public function testReturnValueOfGetFields( TableDefinition $table ) { + $this->assertInternalType( 'array', $table->getFields() ); + $this->assertContainsOnlyInstancesOf( 'Wikibase\Repo\Database\FieldDefinition', $table->getFields() ); + + $newTable = new TableDefinition( $table->getName(), $table->getFields() ); + + $this->assertEquals( + $table->getFields(), + $newTable->getFields(), + 'The TableDefinition fields are set and obtained correctly' + ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/50634 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibdf324d85c3f3093aa46af2d4407a77936711322 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