my
$obj
= Wikibase::Datatype::MediainfoSnak->new(
'datavalue'
=> Wikibase::Datatype::Value::String->new(
'value'
=>
'1.1'
,
),
'property'
=>
'P11'
,
);
my
$ret_hr
= Wikibase::Datatype::Struct::MediainfoSnak::obj2struct(
$obj
,
is_deeply(
$ret_hr
,
{
'datavalue'
=> {
'type'
=>
'string'
,
'value'
=>
'1.1'
,
},
'property'
=>
'P11'
,
'snaktype'
=>
'value'
,
},
'Output of obj2struct() subroutine.'
,
);
eval
{
Wikibase::Datatype::Struct::MediainfoSnak::obj2struct(
'bad'
);
};
is(
$EVAL_ERROR
,
"Object isn't 'Wikibase::Datatype::MediainfoSnak'.\n"
,
"Object isn't 'Wikibase::Datatype::MediainfoSnak'."
);
clean();
$obj
= Wikibase::Datatype::MediainfoSnak->new(
'datavalue'
=> Wikibase::Datatype::Value::String->new(
'value'
=>
'1.1'
,
),
'property'
=>
'P11'
,
);
eval
{
Wikibase::Datatype::Struct::MediainfoSnak::obj2struct(
$obj
);
};
is(
$EVAL_ERROR
,
"Base URI is required.\n"
,
'Base URI is required.'
);
clean();
eval
{
Wikibase::Datatype::Struct::MediainfoSnak::obj2struct();
};
is(
$EVAL_ERROR
,
"Object doesn't exist.\n"
,
"Object doesn't exist."
);
clean();
$obj
= Wikibase::Datatype::MediainfoSnak->new(
'property'
=>
'P11'
,
'snaktype'
=>
'novalue'
,
);
$ret_hr
= Wikibase::Datatype::Struct::MediainfoSnak::obj2struct(
$obj
,
is_deeply(
$ret_hr
,
{
'property'
=>
'P11'
,
'snaktype'
=>
'novalue'
,
},
'Output of obj2struct() subroutine with snaktype novalue.'
,
);
$obj
= Wikibase::Datatype::MediainfoSnak->new(
'property'
=>
'P11'
,
'snaktype'
=>
'somevalue'
,
);
$ret_hr
= Wikibase::Datatype::Struct::MediainfoSnak::obj2struct(
$obj
,
is_deeply(
$ret_hr
,
{
'property'
=>
'P11'
,
'snaktype'
=>
'somevalue'
,
},
'Output of obj2struct() subroutine with snaktype somevalue.'
,
);