We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7242a0c + ae2dbd8 commit df04592Copy full SHA for df04592
2 files changed
tests/unit/Entity/ItemIdTest.php
@@ -84,10 +84,27 @@ public function testSerialize() {
84
$this->assertSame( '["item","Q1"]', $id->serialize() );
85
}
86
87
- public function testUnserialize() {
+ /**
88
+ * @dataProvider serializationProvider
89
+ */
90
+ public function testUnserialize( $json, $expected ) {
91
$id = new ItemId( 'Q1' );
- $id->unserialize( '["item","Q2"]' );
- $this->assertSame( 'Q2', $id->getSerialization() );
92
+ $id->unserialize( $json );
93
+ $this->assertSame( $expected, $id->getSerialization() );
94
+ }
95
+
96
+ public function serializationProvider() {
97
+ return array(
98
+ array( '["item","Q2"]', 'Q2' ),
99
100
+ // All these cases are kind of an injection vector and allow constructing invalid ids.
101
+ array( '["string","Q2"]', 'Q2' ),
102
+ array( '["","string"]', 'string' ),
103
+ array( '["",""]', '' ),
104
+ array( '["",2]', 2 ),
105
+ array( '["",null]', null ),
106
+ array( '', null ),
107
+ );
108
109
110
/**
tests/unit/Entity/PropertyIdTest.php
$this->assertSame( '["property","P1"]', $id->serialize() );
$id = new PropertyId( 'P1' );
- $id->unserialize( '["property","P2"]' );
- $this->assertSame( 'P2', $id->getSerialization() );
+ array( '["property","P2"]', 'P2' ),
+ array( '["string","P2"]', 'P2' ),
0 commit comments