Addshore has uploaded a new change for review. https://gerrit.wikimedia.org/r/92859
Change subject: Fix ByPropertyListUnserializer tests ...................................................................... Fix ByPropertyListUnserializer tests Previous to this the dataprovider for valid data was not actually being used by any tests! This change removes the pointless base class which was only used by this test class as well as adding a test method that actually tests the data provided. We also fix the expected output as expecting a Snaks object is wrong Change-Id: Ifaf92d0d61b4c4f3be6b290ba72ed07799854013 --- M lib/tests/phpunit/serializers/ByPropertyListUnserializerTest.php D lib/tests/phpunit/serializers/UnserializerBaseTest.php 2 files changed, 35 insertions(+), 99 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/59/92859/1 diff --git a/lib/tests/phpunit/serializers/ByPropertyListUnserializerTest.php b/lib/tests/phpunit/serializers/ByPropertyListUnserializerTest.php index f4cac75..259e399 100644 --- a/lib/tests/phpunit/serializers/ByPropertyListUnserializerTest.php +++ b/lib/tests/phpunit/serializers/ByPropertyListUnserializerTest.php @@ -9,12 +9,9 @@ use Wikibase\PropertyNoValueSnak; use Wikibase\PropertySomeValueSnak; use Wikibase\PropertyValueSnak; -use Wikibase\SnakList; /** * @covers Wikibase\Lib\Serializers\ByPropertyListUnserializer - * - * @since 0.4 * * @group WikibaseLib * @group Wikibase @@ -22,14 +19,11 @@ * * @licence GNU GPL v2+ * @author Jeroen De Dauw < [email protected] > + * @author Adam Shorland */ -class ByPropertyListUnserializerTest extends UnserializerBaseTest { +class ByPropertyListUnserializerTest extends \MediaWikiTestCase { /** - * @see UnserializerBaseTest::getClass - * - * @since 0.4 - * * @return string */ protected function getClass() { @@ -37,24 +31,22 @@ } /** - * @see UnserializerBaseTest::getInstance - * - * @since 0.4 - * * @return ByPropertyListUnserializer */ protected function getInstance() { - $snakSetailizer = new SnakSerializer(); - return new ByPropertyListUnserializer( $snakSetailizer ); + $snakSerializer = new SnakSerializer(); + return new ByPropertyListUnserializer( $snakSerializer ); } /** - * @see UnserializerBaseTest::validProvider - * - * @since 0.4 - * - * @return array + * @dataProvider validProvider */ + public function testGetUnserializedValid( array $input, $expected ) { + $unserializer = $this->getInstance(); + $unserialized = $unserializer->newFromSerialization( $input ); + $this->assertEquals( $expected, $unserialized ); + } + public function validProvider() { $validArgs = array(); @@ -67,13 +59,9 @@ $snak1 = new PropertySomeValueSnak( $id2 ); $snak2 = new PropertyValueSnak( $id2, $dataValue0 ); - $validArgs[] = new SnakList( array( $snak0, $snak1, $snak2 ) ); - - $validArgs = $this->arrayWrap( $validArgs ); - $validArgs[] = array( array(), - new SnakList(), + array(), ); $validArgs[] = array( @@ -96,10 +84,32 @@ ), ), ), - new SnakList( array( $snak0, $snak1, $snak2 ) ), + array( $snak0, $snak1, $snak2 ), ); return $validArgs; } + public function invalidProvider() { + $invalid = array( + false, + true, + null, + 42, + 4.2, + '', + 'foo bar baz', + ); + + return $this->arrayWrap( $this->arrayWrap( $invalid ) ); + } + + /** + * @dataProvider invalidProvider + */ + public function testNewFromSerializationInvalid( $input ) { + $serializer = $this->getInstance(); + $this->assertException( function() use ( $serializer, $input ) { $serializer->newFromSerialization( $input ); } ); + } + } diff --git a/lib/tests/phpunit/serializers/UnserializerBaseTest.php b/lib/tests/phpunit/serializers/UnserializerBaseTest.php deleted file mode 100644 index fb67d6a..0000000 --- a/lib/tests/phpunit/serializers/UnserializerBaseTest.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -namespace Wikibase\Lib\Test\Serializers; - -use Wikibase\Lib\Serializers\Unserializer; - -/** - * Base class for tests that test classes deriving from Wikibase\SerializerObject. - * - * @since 0.4 - * - * @group WikibaseLib - * @group Wikibase - * @group WikibaseSerialization - * - * @licence GNU GPL v2+ - * @author Jeroen De Dauw < [email protected] > - */ -abstract class UnserializerBaseTest extends \MediaWikiTestCase { - - /** - * @since 0.4 - * - * @return string - */ - protected abstract function getClass(); - - /** - * @since 0.4 - * - * @return array - */ - public abstract function validProvider(); - - /** - * @since 0.4 - * - * @return Unserializer - */ - protected function getInstance() { - $class = $this->getClass(); - return new $class(); - } - - /** - * @since 0.4 - * - * @return array - */ - public function invalidProvider() { - $invalid = array( - false, - true, - null, - 42, - 4.2, - '', - 'foo bar baz', - ); - - return $this->arrayWrap( $this->arrayWrap( $invalid ) ); - } - - /** - * @dataProvider invalidProvider - * - * @since 0.4 - */ - public function testNewFromSerializationInvalid( $input ) { - $serializer = $this->getInstance(); - $this->assertException( function() use ( $serializer, $input ) { $serializer->newFromSerialization( $input ); } ); - } - -} -- To view, visit https://gerrit.wikimedia.org/r/92859 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifaf92d0d61b4c4f3be6b290ba72ed07799854013 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Addshore <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
