Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4793067
ConfigShowTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
ConfigShowTest.php
View Options
<?php
namespace
Nasqueron\Notifications\Tests\Console\Commands
;
use
Nasqueron\Notifications\Config\Features
;
use
Nasqueron\Notifications\Config\Services\Service
;
use
Mockery
;
class
ConfigShowTest
extends
TestCase
{
/**
* @var string
*/
protected
$class
=
'Nasqueron
\N
otifications
\C
onsole
\C
ommands
\C
onfigShow'
;
/**
* Nasqueron\Notifications\Config\Services\Services
*/
private
$servicesMock
;
public
function
setUp
()
{
parent
::
setUp
();
$this
->
servicesMock
=
$this
->
mockServices
();
}
public
function
testRegularExecute
()
{
//Our command calls Services::get()
$this
->
servicesMock
->
shouldReceive
(
'get'
)->
once
()->
andReturn
([]);
$this
->
tester
->
execute
([
'command'
=>
$this
->
command
->
getName
()]);
$this
->
assertRegexp
(
'/Gates/'
,
$this
->
tester
->
getDisplay
());
$this
->
assertRegexp
(
'/Features/'
,
$this
->
tester
->
getDisplay
());
$this
->
assertRegexp
(
'/Services declared/'
,
$this
->
tester
->
getDisplay
());
}
public
function
testRegularExecuteWithService
()
{
$service
=
$this
->
mockService
();
$this
->
servicesMock
->
shouldReceive
(
'get'
)
->
once
()
->
andReturn
([
$service
]);
$this
->
tester
->
execute
([
'command'
=>
$this
->
command
->
getName
()]);
$this
->
assertRegexp
(
'/Storm/'
,
$this
->
tester
->
getDisplay
());
}
public
function
testRegularExecuteWithPhabricatorService
()
{
$this
->
mockPhabricatorAPIForProjectsMap
();
$service
=
$this
->
mockService
(
'Phabricator'
);
$this
->
servicesMock
->
shouldReceive
(
'get'
)
->
once
()
->
andReturn
([
$service
]);
$this
->
servicesMock
->
shouldReceive
(
'findServiceByProperty'
);
$this
->
tester
->
execute
([
'command'
=>
$this
->
command
->
getName
()]);
$this
->
assertRegexp
(
'/Phabricator.*Projects map not cached./'
,
$this
->
tester
->
getDisplay
());
}
protected
function
mockProjectsMap
()
{
$mock
=
Mockery
::
mock
(
'Nasqueron
\N
otifications
\P
habricator
\P
rojectsMap'
);
$this
->
app
->
instance
(
'phabricator-projectsmap'
,
$mock
);
return
$mock
;
}
public
function
testRegularExecuteWithPhabricatorServiceWhenTheProjectsMapIsCached
()
{
// The services list will return only one, for the Phabricator gate.
$service
=
$this
->
mockService
(
'Phabricator'
);
$this
->
servicesMock
->
shouldReceive
(
'get'
)->
once
()->
andReturn
([
$service
]);
// The project map (built by the factory) will say it's cached.
$this
->
mockProjectsMap
()
->
shouldReceive
(
'fetch->isCached'
)->
once
()->
andReturn
(
true
);
$this
->
tester
->
execute
([
'command'
=>
$this
->
command
->
getName
()]);
$this
->
assertRegexp
(
'/Phabricator.*✓/'
,
$this
->
tester
->
getDisplay
());
}
public
function
testExecuteWhenSomeFeatureIsDisabled
()
{
Features
::
disable
(
'ActionsReport'
);
$this
->
servicesMock
->
shouldReceive
(
'get'
)->
once
()->
andReturn
([]);
$this
->
tester
->
execute
([
'command'
=>
$this
->
command
->
getName
()]);
$this
->
assertRegexp
(
'/Gate *
\|
*✓ *
\|
/'
,
$this
->
tester
->
getDisplay
());
$this
->
assertRegexp
(
'/ActionsReport *
\|
*
\|
/'
,
$this
->
tester
->
getDisplay
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 21:39 (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2441556
Default Alt Text
ConfigShowTest.php (3 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment