[ [ 'key' ], '', ], 'withParam' => [ [ 'key', [ 'a' ] ], 'a' ], 'withCode' => [ [ 'key', [], 'code' ], '' ], 'withData' => [ [ 'key', [ new ScalarParam( ParamType::NUM, 1 ) ], 'code', [ 'value' => 1 ] ], '' . '1' . '{"value":1}' . '' ], ]; } /** @dataProvider provideConstruct */ public function testSerialize( $args, $_ ) { $codec = new JsonCodec; $obj = new DataMessageValue( ...$args ); $serialized = $codec->serialize( $obj ); $newObj = $codec->deserialize( $serialized ); // XXX: would be nice to have a proper ::equals() method. $this->assertEquals( $obj->dump(), $newObj->dump() ); } /** @dataProvider provideConstruct */ public function testConstruct( $args, $expected ) { $mv = new DataMessageValue( ...$args ); $this->assertSame( $expected, $mv->dump() ); } /** @dataProvider provideConstruct */ public function testNew( $args, $expected ) { $mv = DataMessageValue::new( ...$args ); $this->assertSame( $expected, $mv->dump() ); } public function testGetCode() { $mv = new DataMessageValue( 'key', [], 'code' ); $this->assertSame( 'code', $mv->getCode() ); } public function testGetData() { $mv = new DataMessageValue( 'key', [], 'code', [ 'data' => 'foobar' ] ); $this->assertSame( [ 'data' => 'foobar' ], $mv->getData() ); } }