jenkins-bot has submitted this change and it was merged.
Change subject: more testcases for ByPropertyListSerializer
......................................................................
more testcases for ByPropertyListSerializer
Having the testcases like this is clearer!
We can also see exactly what is happening
Change-Id: I8b4abbb3ac65520ab4b78432adbc06a73e087e05
---
M lib/tests/phpunit/serializers/ByPropertyListSerializerTest.php
1 file changed, 97 insertions(+), 22 deletions(-)
Approvals:
Aude: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/tests/phpunit/serializers/ByPropertyListSerializerTest.php
b/lib/tests/phpunit/serializers/ByPropertyListSerializerTest.php
index b59baac..0753015 100644
--- a/lib/tests/phpunit/serializers/ByPropertyListSerializerTest.php
+++ b/lib/tests/phpunit/serializers/ByPropertyListSerializerTest.php
@@ -71,12 +71,12 @@
$validArgs = $this->arrayWrap( $validArgs );
- $validArgs[] = array(
+ $validArgs[ 'Empty' ] = array(
new SnakList(),
array(),
);
- $validArgs[] = array(
+ $validArgs[ 'Default' ] = array(
new SnakList( array( $snak0, $snak1, $snak2 ) ),
array(
'P42' => array(
@@ -99,30 +99,105 @@
),
);
- return $validArgs;
- }
+ $options = new SerializationOptions();
+ $options->setIdKeyMode( SerializationOptions::ID_KEYS_LOWER );
- /**
- * @dataProvider provideIdKeyMode
- */
- public function testIdKeyMode( $mode ) {
- $snakSerializer = new SnakSerializer();
- $snak = new PropertyNoValueSnak( new PropertyId( "P123" ) );
+ $validArgs[ 'ID_KEYS_LOWER' ] = array(
+ new SnakList( array( $snak0, $snak1, $snak2 ) ),
+ array(
+ 'p42' => array(
+ 0 => array(
+ 'snaktype' => 'novalue',
+ 'property' => 'P42',
+ ),
+ ),
+ 'p2' => array(
+ 0 => array(
+ 'snaktype' => 'somevalue',
+ 'property' => 'P2',
+ ),
+ 1 => array(
+ 'snaktype' => 'value',
+ 'property' => 'P2',
+ 'datavalue' =>
$dataValue0->toArray(),
+ ),
+ ),
+ ),
+ $options
+ );
$options = new SerializationOptions();
- $options->setIdKeyMode( $mode );
- $serializer = new ByPropertyListSerializer( 'test',
$snakSerializer, $options );
+ $options->setIdKeyMode( SerializationOptions::ID_KEYS_UPPER );
- $data = $serializer->getSerialized( new ArrayObject( array(
$snak ) ) );
- $this->assertEquals( ( $mode &
SerializationOptions::ID_KEYS_UPPER ) > 0, array_key_exists( 'P123', $data ),
'upper case key' );
- $this->assertEquals( ( $mode &
SerializationOptions::ID_KEYS_LOWER ) > 0, array_key_exists( 'p123', $data ),
'lower case key' );
- }
-
- public function provideIdKeyMode() {
- return array(
- 'lower' => array( SerializationOptions::ID_KEYS_LOWER ),
- 'upper' => array( SerializationOptions::ID_KEYS_UPPER ),
- 'both' => array( SerializationOptions::ID_KEYS_BOTH ),
+ $validArgs[ 'ID_KEYS_UPPER' ] = array(
+ new SnakList( array( $snak0, $snak1, $snak2 ) ),
+ array(
+ 'P42' => array(
+ 0 => array(
+ 'snaktype' => 'novalue',
+ 'property' => 'P42',
+ ),
+ ),
+ 'P2' => array(
+ 0 => array(
+ 'snaktype' => 'somevalue',
+ 'property' => 'P2',
+ ),
+ 1 => array(
+ 'snaktype' => 'value',
+ 'property' => 'P2',
+ 'datavalue' =>
$dataValue0->toArray(),
+ ),
+ ),
+ ),
+ $options
);
+
+
+ $options = new SerializationOptions();
+ $options->setIdKeyMode( SerializationOptions::ID_KEYS_BOTH );
+
+ $validArgs[ 'ID_KEYS_BOTH' ] = array(
+ new SnakList( array( $snak0, $snak1, $snak2 ) ),
+ array(
+ 'P42' => array(
+ 0 => array(
+ 'snaktype' => 'novalue',
+ 'property' => 'P42',
+ ),
+ ),
+ 'P2' => array(
+ 0 => array(
+ 'snaktype' => 'somevalue',
+ 'property' => 'P2',
+ ),
+ 1 => array(
+ 'snaktype' => 'value',
+ 'property' => 'P2',
+ 'datavalue' =>
$dataValue0->toArray(),
+ ),
+ ),
+ 'p42' => array(
+ 0 => array(
+ 'snaktype' => 'novalue',
+ 'property' => 'P42',
+ ),
+ ),
+ 'p2' => array(
+ 0 => array(
+ 'snaktype' => 'somevalue',
+ 'property' => 'P2',
+ ),
+ 1 => array(
+ 'snaktype' => 'value',
+ 'property' => 'P2',
+ 'datavalue' =>
$dataValue0->toArray(),
+ ),
+ ),
+ ),
+ $options
+ );
+
+ return $validArgs;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/92865
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8b4abbb3ac65520ab4b78432adbc06a73e087e05
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits