Archive-Har
view release on metacpan or search on metacpan
t/mandatory_optional.t view on Meta::CPAN
(($har->entries())[0])->response()->content()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{response}->{content}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->response()->content()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->response()->content()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
ok($hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{comment} eq "test headers", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{_private} eq "headers", "_private is correct");
(((($har->entries())[0])->request()->headers())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{_private}, "new _private value is correct (2)");
(((($har->entries())[0])->request()->headers())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{headers}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((((($har->entries())[0])->request()->headers())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (((($har->entries())[0])->request()->headers())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{comment} eq "test postData", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{_private} eq "postData", "_private is correct");
(($har->entries())[0])->request()->post_data()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{postData}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->request()->post_data()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->request()->post_data()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->request()->post_data()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{comment} eq "test params", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{fileName} eq "example.pdf", "fileName is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{contentType} eq "application/pdf", "contentType is correct");
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{_private} eq "params", "_private is correct");
(((($har->entries())[0])->request()->post_data()->params())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{_private}, "new _private value is correct (2)");
(((($har->entries())[0])->request()->post_data()->params())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((((($har->entries())[0])->request()->post_data()->params())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (((($har->entries())[0])->request()->post_data()->params())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
ok($hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{comment} eq "test queryString", "comment is correct");
ok($hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{_private} eq "queryString", "_private is correct");
(((($har->entries())[0])->request()->query_string())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{_private}, "new _private value is correct (2)");
(((($har->entries())[0])->request()->query_string())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{queryString}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((((($har->entries())[0])->request()->query_string())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (((($har->entries())[0])->request()->query_string())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
ok($hash->{log}->{entries}->[0]->{timings}->{comment} eq "test timings", "comment is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{_private} eq "timings", "_private is correct");
(($har->entries())[0])->timings()->ssl(undef);
(($har->entries())[0])->timings()->blocked(undef);
(($har->entries())[0])->timings()->connect(undef);
(($har->entries())[0])->timings()->dns(undef);
(($har->entries())[0])->timings()->_private(undef);
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{timings}->{ssl} == -1, "timings ssl unavailable is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{blocked} == -1, "timings blocked unavailable is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{connect} == -1, "timings connect unavailable is correct");
ok($hash->{log}->{entries}->[0]->{timings}->{dns} == -1, "timings dns unavailable is correct");
ok(!exists $hash->{log}->{entries}->[0]->{timings}->{_private}, "new _private value is correct (2)");
(($har->entries())[0])->timings()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{timings}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->entries())[0])->timings()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->entries())[0])->timings()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
(($har->entries())[0])->request()->post_data()->text("foobar");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{entries}->[0]->{request}->{postData}->{text} eq "foobar", "postData text is correct");
ok(!exists $hash->{log}->{entries}->[0]->{request}->{postData}->{params}->[0], "postData params does not exist");
$checking = <<'_CHECK_';
{
"log": {
"pages": [ { "comment": "test pages", "_private": "pages", "pageTimings": { "comment": "test pageTimings", "_private": "pageTimings" } } ]
}
}
_CHECK_
$har->string($checking);
$hash = JSON::decode_json($har->string());
ok($hash, "Successfully read pages elements in har archive");
ok($hash->{log}->{pages}->[0]->{comment} eq "test pages", "comment is correct");
ok($hash->{log}->{pages}->[0]->{_private} eq "pages", "_private is correct");
(($har->pages())[0])->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{pages}->[0]->{_private}, "new _private value is correct (2)");
(($har->pages())[0])->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{pages}->[0]->{_private} eq "value", "new _private value is correct (3)");
ok((($har->pages())[0])->_private() eq "value", "new _private value is correct (4)");
eval { (($har->pages())[0])->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
(($har->pages())[0])->started_date_time(undef);
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{pages}->[0]->{startedDateTime} eq '0000-00-00T00:00:00.0+00:00', "started_date_time is not defined");
eval { (($har->pages())[0])->started_date_time("not_formatted") };
ok($@ =~ /^started_date_time is not formatted correctly/, "started_date_time throws an exception with invalid input");
ok($hash->{log}->{pages}->[0]->{pageTimings}->{comment} eq "test pageTimings", "comment is correct");
ok($hash->{log}->{pages}->[0]->{pageTimings}->{_private} eq "pageTimings", "_private is correct");
(($har->pages())[0])->page_timings()->_private(undef);
$hash = JSON::decode_json($har->string());
ok(!exists $hash->{log}->{pages}->[0]->{pageTimings}->{_private}, "new _private value is correct (2)");
(($har->pages())[0])->page_timings()->_private("value");
$hash = JSON::decode_json($har->string());
ok($hash->{log}->{pages}->[0]->{pageTimings}->{_private} eq "value", "new _private value is correct (3)");
ok((($har->pages())[0])->page_timings()->_private() eq "value", "new _private value is correct (4)");
eval { (($har->pages())[0])->page_timings()->does_not_exist() };
ok($@ =~ /^does_not_exist is not specified in the HAR 1.2 spec and does not start with an underscore/, "does_not_exist access throws an exception");
eval { (($har->pages())[0])->page_timings()->on_content_load('sdf') };
ok($@ =~ /^on_content_load must be a positive number or -1/, "setting on_content_load to a non numeric throws an exception");
eval { (($har->pages())[0])->page_timings()->on_load('sdf') };
ok($@ =~ /^on_load must be a positive number or -1/, "setting on_load to a non numeric throws an exception");
no warnings;
eval "sub IO::Uncompress::Gunzip::gunzip { return; }";
( run in 0.499 second using v1.01-cache-2.11-cpan-97f6503c9c8 )