summaryrefslogtreecommitdiffstats
path: root/extensions/PhabBugz/t/basic.t
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/PhabBugz/t/basic.t')
-rw-r--r--extensions/PhabBugz/t/basic.t27
1 files changed, 14 insertions, 13 deletions
diff --git a/extensions/PhabBugz/t/basic.t b/extensions/PhabBugz/t/basic.t
index 9a6723ccb..af92dc64f 100644
--- a/extensions/PhabBugz/t/basic.t
+++ b/extensions/PhabBugz/t/basic.t
@@ -17,6 +17,7 @@ use Test::More;
use Test2::Tools::Mock;
use Data::Dumper;
use JSON::MaybeXS;
+use Bugzilla::Test::Util qw(mock_useragent_tx);
use Carp;
use Try::Tiny;
@@ -98,13 +99,13 @@ my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
# Same members in both
do {
- my $UserAgent = mock 'LWP::UserAgent' => (
+ my $UserAgent = mock 'Mojo::UserAgent' => (
override => [
'post' => sub {
- my ($self, $url, $params) = @_;
+ my ($self, $url, undef, $params) = @_;
my $data = decode_json($params->{params});
is_deeply($data->{transactions}, [], 'no-op');
- return mock({is_error => 0, content => '{}'});
+ return mock_useragent_tx('{}');
},
],
);
@@ -119,14 +120,14 @@ do {
# Project has members not in group
do {
- my $UserAgent = mock 'LWP::UserAgent' => (
+ my $UserAgent = mock 'Mojo::UserAgent' => (
override => [
'post' => sub {
- my ($self, $url, $params) = @_;
+ my ($self, $url, undef, $params) = @_;
my $data = decode_json($params->{params});
my $expected = [ { type => 'members.remove', value => ['foo'] } ];
is_deeply($data->{transactions}, $expected, 'remove foo');
- return mock({is_error => 0, content => '{}'});
+ return mock_useragent_tx('{}');
},
]
);
@@ -139,14 +140,14 @@ do {
# Group has members not in project
do {
- my $UserAgent = mock 'LWP::UserAgent' => (
+ my $UserAgent = mock 'Mojo::UserAgent' => (
override => [
'post' => sub {
- my ($self, $url, $params) = @_;
+ my ($self, $url, undef, $params) = @_;
my $data = decode_json($params->{params});
my $expected = [ { type => 'members.add', value => ['foo'] } ];
is_deeply($data->{transactions}, $expected, 'add foo');
- return mock({is_error => 0, content => '{}'});
+ return mock_useragent_tx('{}');
},
]
);
@@ -164,10 +165,10 @@ do {
'update' => sub { 1 },
],
);
- my $UserAgent = mock 'LWP::UserAgent' => (
+ my $UserAgent = mock 'Mojo::UserAgent' => (
override => [
'post' => sub {
- my ($self, $url, $params) = @_;
+ my ($self, $url, undef, $params) = @_;
if ($url =~ /differential\.revision\.search/) {
my $content = <<JSON;
{
@@ -215,10 +216,10 @@ do {
}
}
JSON
- return mock { is_error => 0, content => $content };
+ return mock_useragent_tx($content);
}
else {
- return mock { is_error => 1, message => "bad request" };
+ return mock_useragent_tx("bad request");
}
},
],