summaryrefslogtreecommitdiffstats
path: root/extensions/PhabBugz/t
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/PhabBugz/t')
-rw-r--r--extensions/PhabBugz/t/basic.t252
-rw-r--r--extensions/PhabBugz/t/feed-daemon-guts.t191
-rw-r--r--extensions/PhabBugz/t/review-flags.t246
3 files changed, 318 insertions, 371 deletions
diff --git a/extensions/PhabBugz/t/basic.t b/extensions/PhabBugz/t/basic.t
index af92dc64f..d0083c275 100644
--- a/extensions/PhabBugz/t/basic.t
+++ b/extensions/PhabBugz/t/basic.t
@@ -11,7 +11,7 @@ use 5.10.1;
use lib qw( . lib local/lib/perl5 );
use Bugzilla;
-BEGIN { Bugzilla->extensions };
+BEGIN { Bugzilla->extensions }
use Test::More;
use Test2::Tools::Mock;
@@ -30,68 +30,65 @@ our @project_members;
my $User = mock 'Bugzilla::Extension::PhabBugz::User' => (
- add_constructor => [
- 'fake_new' => 'hash',
- ],
- override => [
- 'match' => sub { [ mock() ] },
- ],
+ add_constructor => ['fake_new' => 'hash',],
+ override => ['match' => sub { [mock()] },],
);
my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' => (
- override => [
- get_group_members => sub {
- return [ map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } @group_members ];
- }
- ]
+ override => [
+ get_group_members => sub {
+ return [map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) }
+ @group_members];
+ }
+ ]
);
my $Project = mock 'Bugzilla::Extension::PhabBugz::Project' => (
- override_constructor => [
- new_from_query => 'ref_copy',
- ],
- override => [
- 'members' => sub {
- return [ map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) } @project_members ];
- }
- ]
+ override_constructor => [new_from_query => 'ref_copy',],
+ override => [
+ 'members' => sub {
+ return [map { Bugzilla::Extension::PhabBugz::User->fake_new(%$_) }
+ @project_members];
+ }
+ ]
);
-local Bugzilla->params->{phabricator_enabled} = 1;
-local Bugzilla->params->{phabricator_api_key} = 'FAKE-API-KEY';
+local Bugzilla->params->{phabricator_enabled} = 1;
+local Bugzilla->params->{phabricator_api_key} = 'FAKE-API-KEY';
local Bugzilla->params->{phabricator_base_uri} = 'http://fake.fabricator.tld';
my $Bugzilla = mock 'Bugzilla' => (
- override => [
- 'dbh' => sub { mock() },
- 'user' => sub { Bugzilla::User->new({ name => 'phab-bot@bmo.tld' }) },
- ],
+ override => [
+ 'dbh' => sub { mock() },
+ 'user' => sub { Bugzilla::User->new({name => 'phab-bot@bmo.tld'}) },
+ ],
);
my $BugzillaGroup = mock 'Bugzilla::Group' => (
- add_constructor => [
- 'fake_new' => 'hash',
- ],
- override => [
- 'match' => sub { [ Bugzilla::Group->fake_new(id => 1, name => 'firefox-security' ) ] },
- ],
+ add_constructor => ['fake_new' => 'hash',],
+ override => [
+ 'match' =>
+ sub { [Bugzilla::Group->fake_new(id => 1, name => 'firefox-security')] },
+ ],
);
my $BugzillaUser = mock 'Bugzilla::User' => (
- add_constructor => [
- 'fake_new' => 'hash',
- ],
- override => [
- 'new' => sub {
- my ($class, $hash) = @_;
- if ($hash->{name} eq 'phab-bot@bmo.tld') {
- return $class->fake_new( id => 8_675_309, login_name => 'phab-bot@bmo.tld', realname => 'Fake PhabBot' );
- }
- else {
- }
- },
- 'match' => sub { [ mock() ] },
- ],
+ add_constructor => ['fake_new' => 'hash',],
+ override => [
+ 'new' => sub {
+ my ($class, $hash) = @_;
+ if ($hash->{name} eq 'phab-bot@bmo.tld') {
+ return $class->fake_new(
+ id => 8_675_309,
+ login_name => 'phab-bot@bmo.tld',
+ realname => 'Fake PhabBot'
+ );
+ }
+ else {
+ }
+ },
+ 'match' => sub { [mock()] },
+ ],
);
@@ -99,78 +96,66 @@ my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
# Same members in both
do {
- my $UserAgent = mock 'Mojo::UserAgent' => (
- override => [
- 'post' => sub {
- my ($self, $url, undef, $params) = @_;
- my $data = decode_json($params->{params});
- is_deeply($data->{transactions}, [], 'no-op');
- return mock_useragent_tx('{}');
- },
- ],
- );
- local @group_members = (
- { phid => 'foo' },
- );
- local @project_members = (
- { phid => 'foo' },
- );
- $feed->group_query;
+ my $UserAgent = mock 'Mojo::UserAgent' => (
+ override => [
+ 'post' => sub {
+ my ($self, $url, undef, $params) = @_;
+ my $data = decode_json($params->{params});
+ is_deeply($data->{transactions}, [], 'no-op');
+ return mock_useragent_tx('{}');
+ },
+ ],
+ );
+ local @group_members = ({phid => 'foo'},);
+ local @project_members = ({phid => 'foo'},);
+ $feed->group_query;
};
# Project has members not in group
do {
- my $UserAgent = mock 'Mojo::UserAgent' => (
- override => [
- 'post' => sub {
- 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_useragent_tx('{}');
- },
- ]
- );
- local @group_members = ();
- local @project_members = (
- { phid => 'foo' },
- );
- $feed->group_query;
+ my $UserAgent = mock 'Mojo::UserAgent' => (
+ override => [
+ 'post' => sub {
+ 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_useragent_tx('{}');
+ },
+ ]
+ );
+ local @group_members = ();
+ local @project_members = ({phid => 'foo'},);
+ $feed->group_query;
};
# Group has members not in project
do {
- my $UserAgent = mock 'Mojo::UserAgent' => (
- override => [
- 'post' => sub {
- 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_useragent_tx('{}');
- },
- ]
- );
- local @group_members = (
- { phid => 'foo' },
- );
- local @project_members = (
- );
- $feed->group_query;
+ my $UserAgent = mock 'Mojo::UserAgent' => (
+ override => [
+ 'post' => sub {
+ 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_useragent_tx('{}');
+ },
+ ]
+ );
+ local @group_members = ({phid => 'foo'},);
+ local @project_members = ();
+ $feed->group_query;
};
do {
- my $Revision = mock 'Bugzilla::Extension::PhabBugz::Revision' => (
- override => [
- 'update' => sub { 1 },
- ],
- );
- my $UserAgent = mock 'Mojo::UserAgent' => (
- override => [
- 'post' => sub {
- my ($self, $url, undef, $params) = @_;
- if ($url =~ /differential\.revision\.search/) {
- my $content = <<JSON;
+ my $Revision = mock 'Bugzilla::Extension::PhabBugz::Revision' =>
+ (override => ['update' => sub {1},],);
+ my $UserAgent = mock 'Mojo::UserAgent' => (
+ override => [
+ 'post' => sub {
+ my ($self, $url, undef, $params) = @_;
+ if ($url =~ /differential\.revision\.search/) {
+ my $content = <<JSON;
{
"error_info": null,
"error_code": null,
@@ -216,35 +201,32 @@ do {
}
}
JSON
- return mock_useragent_tx($content);
- }
- else {
- return mock_useragent_tx("bad request");
- }
- },
- ],
- );
- my $Attachment = mock 'Bugzilla::Attachment' => (
- add_constructor => [ fake_new => 'hash' ],
- );
- my $Bug = mock 'Bugzilla::Bug' => (
- add_constructor => [ fake_new => 'hash' ],
- );
- my $bug = Bugzilla::Bug->fake_new(
- bug_id => 23,
- attachments => [
- Bugzilla::Attachment->fake_new(
- mimetype => 'text/x-phabricator-request',
- filename => 'phabricator-D9999-url.txt',
- ),
- ]
- );
+ return mock_useragent_tx($content);
+ }
+ else {
+ return mock_useragent_tx("bad request");
+ }
+ },
+ ],
+ );
+ my $Attachment
+ = mock 'Bugzilla::Attachment' => (add_constructor => [fake_new => 'hash'],);
+ my $Bug = mock 'Bugzilla::Bug' => (add_constructor => [fake_new => 'hash'],);
+ my $bug = Bugzilla::Bug->fake_new(
+ bug_id => 23,
+ attachments => [
+ Bugzilla::Attachment->fake_new(
+ mimetype => 'text/x-phabricator-request',
+ filename => 'phabricator-D9999-url.txt',
+ ),
+ ]
+ );
- my $revisions = get_attachment_revisions($bug);
- is(ref($revisions), 'ARRAY', 'it is an array ref');
- isa_ok($revisions->[0], 'Bugzilla::Extension::PhabBugz::Revision');
- is($revisions->[0]->bug_id, 23, 'Bugzila ID is 23');
- ok( try { $revisions->[0]->update }, 'update revision');
+ my $revisions = get_attachment_revisions($bug);
+ is(ref($revisions), 'ARRAY', 'it is an array ref');
+ isa_ok($revisions->[0], 'Bugzilla::Extension::PhabBugz::Revision');
+ is($revisions->[0]->bug_id, 23, 'Bugzila ID is 23');
+ ok(try { $revisions->[0]->update }, 'update revision');
};
diff --git a/extensions/PhabBugz/t/feed-daemon-guts.t b/extensions/PhabBugz/t/feed-daemon-guts.t
index 0c508be98..44d65eab4 100644
--- a/extensions/PhabBugz/t/feed-daemon-guts.t
+++ b/extensions/PhabBugz/t/feed-daemon-guts.t
@@ -24,8 +24,11 @@ use Digest::SHA qw(sha1_hex);
use ok 'Bugzilla::Extension::PhabBugz::Feed';
use ok 'Bugzilla::Extension::PhabBugz::Constants', 'PHAB_AUTOMATION_USER';
-use ok 'Bugzilla::Config', 'SetParam';
-can_ok('Bugzilla::Extension::PhabBugz::Feed', qw( group_query feed_query user_query ));
+use ok 'Bugzilla::Config', 'SetParam';
+can_ok(
+ 'Bugzilla::Extension::PhabBugz::Feed',
+ qw( group_query feed_query user_query )
+);
Bugzilla->error_mode(ERROR_MODE_TEST);
@@ -34,127 +37,117 @@ my $phab_bot = create_user(PHAB_AUTOMATION_USER, '*');
my $UserAgent = mock 'Mojo::UserAgent' => ();
{
- SetParam('phabricator_enabled', 0);
- my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
- my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' => (
- override => [
- get_last_id => sub { die "get_last_id" },
- ],
- );
-
- foreach my $method (qw( feed_query user_query group_query )) {
- try {
- $feed->$method;
- pass "disabling the phabricator sync: $method";
- }
- catch {
- fail "disabling the phabricator sync: $method";
- }
+ SetParam('phabricator_enabled', 0);
+ my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
+ my $Feed = mock 'Bugzilla::Extension::PhabBugz::Feed' =>
+ (override => [get_last_id => sub { die "get_last_id" },],);
+
+ foreach my $method (qw( feed_query user_query group_query )) {
+ try {
+ $feed->$method;
+ pass "disabling the phabricator sync: $method";
+ }
+ catch {
+ fail "disabling the phabricator sync: $method";
}
+ }
}
my @bad_response = (
- ['http error', mock_useragent_tx("doesn't matter", sub { $_->code(500) }) ],
- ['invalid json', mock_useragent_tx('<xml>foo</xml>') ],
- ['json containing error code', mock_useragent_tx(encode_json({error_code => 1234 }))],
+ ['http error', mock_useragent_tx("doesn't matter", sub { $_->code(500) })],
+ ['invalid json', mock_useragent_tx('<xml>foo</xml>')],
+ [
+ 'json containing error code',
+ mock_useragent_tx(encode_json({error_code => 1234}))
+ ],
);
-SetParam(phabricator_enabled => 1);
-SetParam(phabricator_api_key => 'FAKE-API-KEY');
+SetParam(phabricator_enabled => 1);
+SetParam(phabricator_api_key => 'FAKE-API-KEY');
SetParam(phabricator_base_uri => 'http://fake.fabricator.tld/');
foreach my $bad_response (@bad_response) {
- my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
- $UserAgent->override(
- post => sub {
- my ( $self, $url, undef, $params ) = @_;
- return $bad_response->[1];
- }
- );
-
- foreach my $method (qw( feed_query user_query group_query )) {
- try {
- # This is a hack to get reasonable exception objects.
- local $Bugzilla::Template::is_processing = 1;
- $feed->$method;
- fail "$method - $bad_response->[0]";
- }
- catch {
- is( $_->type, 'bugzilla.code.phabricator_api_error', "$method - $bad_response->[0]" );
- };
+ my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
+ $UserAgent->override(
+ post => sub {
+ my ($self, $url, undef, $params) = @_;
+ return $bad_response->[1];
}
- $UserAgent->reset('post');
+ );
+
+ foreach my $method (qw( feed_query user_query group_query )) {
+ try {
+ # This is a hack to get reasonable exception objects.
+ local $Bugzilla::Template::is_processing = 1;
+ $feed->$method;
+ fail "$method - $bad_response->[0]";
+ }
+ catch {
+ is(
+ $_->type,
+ 'bugzilla.code.phabricator_api_error',
+ "$method - $bad_response->[0]"
+ );
+ };
+ }
+ $UserAgent->reset('post');
}
-my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
-my $json = JSON::MaybeXS->new( canonical => 1, pretty => 1 );
-my $dylan = create_user( 'dylan@mozilla.com', '*', realname => 'Dylan Hardison :dylan' );
-my $evildylan = create_user( 'dylan@gmail.com', '*', realname => 'Evil Dylan :dylan' );
-my $myk = create_user( 'myk@mozilla.com', '*', realname => 'Myk Melez :myk' );
+my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
+my $json = JSON::MaybeXS->new(canonical => 1, pretty => 1);
+my $dylan
+ = create_user('dylan@mozilla.com', '*', realname => 'Dylan Hardison :dylan');
+my $evildylan
+ = create_user('dylan@gmail.com', '*', realname => 'Evil Dylan :dylan');
+my $myk = create_user('myk@mozilla.com', '*', realname => 'Myk Melez :myk');
my $phab_bot_phid = next_phid('PHID-USER');
done_testing;
sub user_search {
- my (%conf) = @_;
-
- return {
- error_info => undef,
- error_code => undef,
- result => {
- cursor => {
- after => $conf{after},
- order => undef,
- limit => 100,
- before => undef
+ my (%conf) = @_;
+
+ return {
+ error_info => undef,
+ error_code => undef,
+ result => {
+ cursor =>
+ {after => $conf{after}, order => undef, limit => 100, before => undef},
+ query => {queryKey => undef},
+ maps => {},
+ data => [
+ map {
+ +{
+ attachments => {
+ $_->{bmo_id}
+ ? ("external-accounts" =>
+ {"external-accounts" => [{type => 'bmo', id => $_->{bmo_id},}]})
+ : (),
},
- query => {
- queryKey => undef
+ fields => {
+ roles => ["verified", "approved", "activated"],
+ realName => $_->{realname},
+ dateModified => time,
+ policy => {view => "public", edit => "no-one"},
+ dateCreated => time,
+ username => $_->{username},
},
- maps => {},
- data => [
- map {
- +{
- attachments => {
- $_->{bmo_id}
- ? ( "external-accounts" => {
- "external-accounts" => [
- {
- type => 'bmo',
- id => $_->{bmo_id},
- }
- ]
- }
- )
- : (),
- },
- fields => {
- roles => [ "verified", "approved", "activated" ],
- realName => $_->{realname},
- dateModified => time,
- policy => {
- view => "public",
- edit => "no-one"
- },
- dateCreated => time,
- username => $_->{username},
- },
- phid => next_phid("PHID-USER"),
- type => "USER",
- id => $_->{phab_id},
- },
- } @{ $conf{users} },
- ]
- }
- };
+ phid => next_phid("PHID-USER"),
+ type => "USER",
+ id => $_->{phab_id},
+ },
+ } @{$conf{users}},
+ ]
+ }
+ };
}
sub next_phid {
- my ($prefix) = @_;
- state $number = 'a' x 20;
- return $prefix . '-' . ($number++);
+ my ($prefix) = @_;
+ state $number = 'a' x 20;
+ return $prefix . '-' . ($number++);
}
diff --git a/extensions/PhabBugz/t/review-flags.t b/extensions/PhabBugz/t/review-flags.t
index 610c46dca..b23a55eec 100644
--- a/extensions/PhabBugz/t/review-flags.t
+++ b/extensions/PhabBugz/t/review-flags.t
@@ -15,11 +15,11 @@ use Test2::V0;
our @EMAILS;
BEGIN {
- require Bugzilla::Mailer;
- no warnings 'redefine';
- *Bugzilla::Mailer::MessageToMTA = sub {
- push @EMAILS, [@_];
- };
+ require Bugzilla::Mailer;
+ no warnings 'redefine';
+ *Bugzilla::Mailer::MessageToMTA = sub {
+ push @EMAILS, [@_];
+ };
}
use Bugzilla::Test::MockDB;
use Bugzilla::Test::MockParams;
@@ -35,138 +35,121 @@ use Data::Dumper;
use ok 'Bugzilla::Extension::PhabBugz::Feed';
use ok 'Bugzilla::Extension::PhabBugz::Constants', 'PHAB_AUTOMATION_USER';
-use ok 'Bugzilla::Config', 'SetParam';
-can_ok('Bugzilla::Extension::PhabBugz::Feed', qw( group_query feed_query user_query ));
+use ok 'Bugzilla::Config', 'SetParam';
+can_ok(
+ 'Bugzilla::Extension::PhabBugz::Feed',
+ qw( group_query feed_query user_query )
+);
SetParam(phabricator_base_uri => 'http://fake.phabricator.tld/');
-SetParam(mailfrom => 'bugzilla-daemon');
+SetParam(mailfrom => 'bugzilla-daemon');
Bugzilla->error_mode(ERROR_MODE_TEST);
-my $nobody = create_user('nobody@mozilla.org', '*');
+my $nobody = create_user('nobody@mozilla.org', '*');
my $phab_bot = create_user(PHAB_AUTOMATION_USER, '*');
# Steve Rogers is the revision author
-my $steve = create_user('steverogers@avengers.org', '*', realname => 'Steve Rogers :steve');
+my $steve = create_user('steverogers@avengers.org', '*',
+ realname => 'Steve Rogers :steve');
# Bucky Barns is the reviewer
-my $bucky = create_user('bucky@avengers.org', '*', realname => 'Bucky Barns :bucky');
+my $bucky
+ = create_user('bucky@avengers.org', '*', realname => 'Bucky Barns :bucky');
my $firefox = Bugzilla::Product->create(
- {
- name => 'Firefox',
- description => 'Fake firefox product',
- version => 'Unspecified',
- },
+ {
+ name => 'Firefox',
+ description => 'Fake firefox product',
+ version => 'Unspecified',
+ },
);
-my $general = Bugzilla::Component->create(
- {
- product =>$firefox,
- name => 'General',
- description => 'The most general description',
- initialowner => { id => $nobody->id },
- }
-);
+my $general = Bugzilla::Component->create({
+ product => $firefox,
+ name => 'General',
+ description => 'The most general description',
+ initialowner => {id => $nobody->id},
+});
Bugzilla->set_user($steve);
-my $bug = Bugzilla::Bug->create(
- {
- short_desc => 'test bug',
- product => $firefox,
- component => $general->name,
- bug_severity => 'normal',
- op_sys => 'Unspecified',
- rep_platform => 'Unspecified',
- version => 'Unspecified',
- comment => 'first post',
- priority => 'P1',
- }
-);
-
-my $recipients = { changer => $steve };
+my $bug = Bugzilla::Bug->create({
+ short_desc => 'test bug',
+ product => $firefox,
+ component => $general->name,
+ bug_severity => 'normal',
+ op_sys => 'Unspecified',
+ rep_platform => 'Unspecified',
+ version => 'Unspecified',
+ comment => 'first post',
+ priority => 'P1',
+});
+
+my $recipients = {changer => $steve};
Bugzilla::BugMail::Send($bug->bug_id, $recipients);
@EMAILS = ();
-my $revision = Bugzilla::Extension::PhabBugz::Revision->new(
- {
- id => 1,
- phid => 'PHID-DREV-uozm3ggfp7e7uoqegmc3',
- type => 'DREV',
- fields => {
- title => "title",
- summary => "the summary of the revision",
- status => { value => "not sure" },
- dateCreated => time() - (60 * 60),
- dateModified => time() - (60 * 5),
- authorPHID => 'authorPHID',
- policy => {
- view => 'policy.view',
- edit => 'policy.edit',
- },
- 'bugzilla.bug-id' => $bug->id,
- },
- attachments => {
- projects => { projectPHIDs => [] },
- reviewers => {
- reviewers => [ ],
- },
- subscribers => {
- subscriberPHIDs => [],
- subscriberCount => 1,
- viewerIsSubscribed => 1,
- }
- },
- reviews => [
- {
- user => new_phab_user($bucky),
- status => 'accepted',
- }
- ]
- }
-);
-my $PhabRevisionMock = mock 'Bugzilla::Extension::PhabBugz::Revision' => (
- override => [
- make_public => sub { },
- update => sub { },
- ]
-);
+my $revision = Bugzilla::Extension::PhabBugz::Revision->new({
+ id => 1,
+ phid => 'PHID-DREV-uozm3ggfp7e7uoqegmc3',
+ type => 'DREV',
+ fields => {
+ title => "title",
+ summary => "the summary of the revision",
+ status => {value => "not sure"},
+ dateCreated => time() - (60 * 60),
+ dateModified => time() - (60 * 5),
+ authorPHID => 'authorPHID',
+ policy => {view => 'policy.view', edit => 'policy.edit',},
+ 'bugzilla.bug-id' => $bug->id,
+ },
+ attachments => {
+ projects => {projectPHIDs => []},
+ reviewers => {reviewers => [],},
+ subscribers =>
+ {subscriberPHIDs => [], subscriberCount => 1, viewerIsSubscribed => 1,}
+ },
+ reviews => [{user => new_phab_user($bucky), status => 'accepted',}]
+});
+my $PhabRevisionMock = mock 'Bugzilla::Extension::PhabBugz::Revision' =>
+ (override => [make_public => sub { }, update => sub { },]);
my $PhabUserMock = mock 'Bugzilla::Extension::PhabBugz::User' => (
- override => [
- match => sub {
- my ($class, $query) = @_;
- if ($query && $query->{phids} && $query->{phids}[0]) {
- my $phid = $query->{phids}[0];
- if ($phid eq 'authorPHID') {
- return [ new_phab_user($steve, $phid) ];
- }
- }
- },
- ]
+ override => [
+ match => sub {
+ my ($class, $query) = @_;
+ if ($query && $query->{phids} && $query->{phids}[0]) {
+ my $phid = $query->{phids}[0];
+ if ($phid eq 'authorPHID') {
+ return [new_phab_user($steve, $phid)];
+ }
+ }
+ },
+ ]
);
my $feed = Bugzilla::Extension::PhabBugz::Feed->new;
my $changer = new_phab_user($bucky);
@EMAILS = ();
-$feed->process_revision_change(
- $revision, $changer, "story text"
-);
+$feed->process_revision_change($revision, $changer, "story text");
# The first comment, and the comment made when the attachment is attached
# are made by Steve.
# The review comment is made by Bucky.
-my $sth = Bugzilla->dbh->prepare("select profiles.login_name, thetext from longdescs join profiles on who = userid");
+my $sth
+ = Bugzilla->dbh->prepare(
+ "select profiles.login_name, thetext from longdescs join profiles on who = userid"
+ );
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
- if ($row->{thetext} =~ /first post/i) {
- is($row->{login_name}, $steve->login, 'first post author');
- }
- elsif ($row->{thetext} =~ /the summary of the revision/i) {
- is($row->{login_name}, $steve->login, 'the first attachment comment');
- }
- elsif ($row->{thetext} =~ /has approved the revision/i) {
- is($row->{login_name}, $bucky->login);
- }
+ if ($row->{thetext} =~ /first post/i) {
+ is($row->{login_name}, $steve->login, 'first post author');
+ }
+ elsif ($row->{thetext} =~ /the summary of the revision/i) {
+ is($row->{login_name}, $steve->login, 'the first attachment comment');
+ }
+ elsif ($row->{thetext} =~ /has approved the revision/i) {
+ is($row->{login_name}, $bucky->login);
+ }
}
diag Dumper(\@EMAILS);
@@ -174,36 +157,25 @@ diag Dumper(\@EMAILS);
done_testing;
sub new_phab_user {
- my ($bug_user, $phid) = @_;
-
- return Bugzilla::Extension::PhabBugz::User->new(
- {
- id => $bug_user->id * 1000,
- type => "USER",
- phid => $phid // "PHID-USER-" . ( $bug_user->id * 1000 ),
- fields => {
- username => $bug_user->nick,
- realName => $bug_user->name,
- dateCreated => time() - 60 * 60 * 24,
- dateModified => time(),
- roles => [],
- policy => {
- view => 'view',
- edit => 'edit',
- },
- },
- attachments => {
- 'external-accounts' => {
- 'external-accounts' => [
- {
- type => 'bmo',
- id => $bug_user->id,
- }
- ]
- }
- }
- }
- );
+ my ($bug_user, $phid) = @_;
+
+ return Bugzilla::Extension::PhabBugz::User->new({
+ id => $bug_user->id * 1000,
+ type => "USER",
+ phid => $phid // "PHID-USER-" . ($bug_user->id * 1000),
+ fields => {
+ username => $bug_user->nick,
+ realName => $bug_user->name,
+ dateCreated => time() - 60 * 60 * 24,
+ dateModified => time(),
+ roles => [],
+ policy => {view => 'view', edit => 'edit',},
+ },
+ attachments => {
+ 'external-accounts' =>
+ {'external-accounts' => [{type => 'bmo', id => $bug_user->id,}]}
+ }
+ });
-} \ No newline at end of file
+}