FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
enqueue-dev/pkg/async-command/Tests/RunCommandTest.php at master · practice-code/enqueue-dev · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
practice-code
/
enqueue-dev
Public
forked from
php-enqueue/enqueue-dev
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
enqueue-dev
/
pkg
/
async-command
/
Tests
/
RunCommandTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (64 loc) · 2.51 KB
Breadcrumbs
enqueue-dev
/
pkg
/
async-command
/
Tests
/
RunCommandTest.php
Copy path
File metadata and controls
87 lines (64 loc) · 2.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace
Enqueue
\
AsyncCommand
\
Tests
;
use
Enqueue
\
AsyncCommand
\
RunCommand
;
use
PHPUnit
\
Framework
\
TestCase
;
class
RunCommandTest
extends
TestCase
{
public
function
testShouldImplementJsonSerializableInterface
()
{
$
rc
=
new
\
ReflectionClass
(RunCommand::class);
$
this
->
assertTrue
(
$
rc
->
implementsInterface
(\JsonSerializable::class));
}
public
function
testShouldBeFinal
()
{
$
rc
=
new
\
ReflectionClass
(RunCommand::class);
$
this
->
assertTrue
(
$
rc
->
isFinal
());
}
public
function
testShouldAllowGetCommandSetInConstructor
()
{
$
command
=
new
RunCommand
(
'
theCommand
'
);
$
this
->
assertSame
(
'
theCommand
'
,
$
command
->
getCommand
());
}
public
function
testShouldReturnEmptyArrayByDefaultOnGetArguments
()
{
$
command
=
new
RunCommand
(
'
aCommand
'
);
$
this
->
assertSame
([],
$
command
->
getArguments
());
}
public
function
testShouldReturnEmptyArrayByDefaultOnGetOptions
()
{
$
command
=
new
RunCommand
(
'
aCommand
'
);
$
this
->
assertSame
([],
$
command
->
getOptions
());
}
public
function
testShouldReturnArgumentsSetInConstructor
()
{
$
command
=
new
RunCommand
(
'
aCommand
'
, [
'
theArgument
'
=>
'
theValue
'
]);
$
this
->
assertSame
([
'
theArgument
'
=>
'
theValue
'
],
$
command
->
getArguments
());
}
public
function
testShouldReturnOptionsSetInConstructor
()
{
$
command
=
new
RunCommand
(
'
aCommand
'
, [], [
'
theOption
'
=>
'
theValue
'
]);
$
this
->
assertSame
([
'
theOption
'
=>
'
theValue
'
],
$
command
->
getOptions
());
}
public
function
testShouldSerializeAndUnserialzeCommand
()
{
$
command
=
new
RunCommand
(
'
theCommand
'
,
[
'
theArgument
'
=>
'
theValue
'
],
[
'
theOption
'
=>
'
theValue
'
]
);
$
jsonCommand
=
json_encode
(
$
command
);
// guard
$
this
->
assertNotEmpty
(
$
jsonCommand
);
$
unserializedCommand
= RunCommand::
jsonUnserialize
(
$
jsonCommand
);
$
this
->
assertInstanceOf
(RunCommand::class,
$
unserializedCommand
);
$
this
->
assertSame
(
'
theCommand
'
,
$
unserializedCommand
->
getCommand
());
$
this
->
assertSame
([
'
theArgument
'
=>
'
theValue
'
],
$
unserializedCommand
->
getArguments
());
$
this
->
assertSame
([
'
theOption
'
=>
'
theValue
'
],
$
unserializedCommand
->
getOptions
());
}
public
function
testThrowExceptionIfInvalidJsonGiven
()
{
$
this
->
expectException
(\InvalidArgumentException::class);
$
this
->
expectExceptionMessage
(
'
The malformed json given.
'
);
RunCommand::
jsonUnserialize
(
'
{]
'
);
}
}
Back
|
FazBrowse Home
|
New Git URL