Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F10813481
NotifyNewCommitsToDiffusionTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
NotifyNewCommitsToDiffusionTest.php
View Options
<?php
namespace
Nasqueron\Notifications\Tests\Jobs
;
use
Nasqueron\Notifications\Jobs\Job
;
use
Nasqueron\Notifications\Jobs\NotifyNewCommitsToDiffusion
;
use
Nasqueron\Notifications\Tests\TestCase
;
class
NotifyNewCommitsToDiffusionTest
extends
TestCase
{
///
/// Tests
///
/**
* @dataProvider apiRepositoryReplyProvider
*/
public
function
testHandle
(
$apiRepositoryReply
,
int
$apiCallCounts
)
{
$this
->
mockPhabricatorAPI
()
->
shouldReceive
(
'getForProject->call'
)
->
andReturn
(
// First API call: repository.query
$apiRepositoryReply
,
// Second API call: diffusion.looksoon
null
)
->
times
(
$apiCallCounts
);
// 2 when repository.query is valid
// 1 otherwise
$job
=
$this
->
mockJob
();
$job
->
handle
();
}
public
function
testJobWhenThereIsNoPhabricatorInstanceForTheProject
()
{
$job
=
$this
->
mockJob
(
"not-existing-project"
);
$job
->
handle
();
}
///
/// Helper methods
///
/**
* Mocks a job
*/
protected
function
mockJob
(
string
$project
=
"acme"
)
:
Job
{
return
new
NotifyNewCommitsToDiffusion
(
$project
,
"ssh://acme/k2.git"
);
}
/**
* Provides API repository reply and associated API calls count
*/
public
function
apiRepositoryReplyProvider
()
:
array
{
return
[
// Regular behavior
[[
new
class
{
public
$callsign
=
"K2"
;
}],
2
],
// Phabricator doesn't know this repo
[[],
1
],
// Some error occurs and the API reply is null
[
null
,
1
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jul 29, 13:54 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2755551
Default Alt Text
NotifyNewCommitsToDiffusionTest.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment