Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4792988
ConfigValidateTest.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
ConfigValidateTest.php
View Options
<?php
namespace
Nasqueron\Notifications\Tests\Console\Commands
;
use
Storage
;
class
ConfigValidateTest
extends
TestCase
{
/**
* @var string
*/
protected
$class
=
'Nasqueron
\N
otifications
\C
onsole
\C
ommands
\C
onfigValidate'
;
const
TEST_FILE
=
'bug.json'
;
public
function
testRegularExecute
()
{
$this
->
tester
->
execute
([
'command'
=>
$this
->
command
->
getName
()]);
// When all files are valid, nothing is displayed
$this
->
assertEquals
(
''
,
$this
->
tester
->
getDisplay
());
}
/**
* @dataProvider provideErrors
*/
public
function
testSyntaxErrorExecute
(
string
$content
,
string
$error
)
{
$this
->
populateTestFile
(
$content
);
// Not JSON
$this
->
tester
->
execute
([
'command'
=>
$this
->
command
->
getName
()]);
// When all files are valid, nothing is displayed
$this
->
assertRegexp
(
"/$error/"
,
$this
->
tester
->
getDisplay
());
}
/**
* Provides invalid JSON strings and associated error
*/
public
function
provideErrors
()
:
array
{
return
[
[
"lorem ipsum dolor"
,
"Syntax error"
],
[
'{"}'
,
"Control character error"
]
];
}
private
function
populateTestFile
(
string
$content
)
:
void
{
Storage
::
disk
(
'local'
)->
put
(
self
::
TEST_FILE
,
$content
);
}
private
function
deleteTestFile
()
:
void
{
$fs
=
Storage
::
disk
(
'local'
);
if
(
$fs
->
exists
(
self
::
TEST_FILE
))
{
$fs
->
delete
(
self
::
TEST_FILE
);
}
}
public
function
tearDown
()
{
$this
->
deleteTestFile
();
parent
::
tearDown
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 21:39 (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2437487
Default Alt Text
ConfigValidateTest.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment