FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Queue/QueueDatabaseQueueTest.php at master · JavaDevl/framework · GitHub
JavaDevl
/
framework
Public
forked from
laravel/framework
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
framework
/
tests
/
Queue
/
QueueDatabaseQueueTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (71 loc) · 3.47 KB
Breadcrumbs
framework
/
tests
/
Queue
/
QueueDatabaseQueueTest.php
Copy path
File metadata and controls
79 lines (71 loc) · 3.47 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
<?php
use
Mockery
as
m
;
class
QueueDatabaseQueueTest
extends
PHPUnit_Framework_TestCase
{
public
function
tearDown
()
{
m::
close
();
}
public
function
testPushProperlyPushesJobOntoDatabase
()
{
$
queue
=
$
this
->
getMock
(
'
Illuminate\Queue\DatabaseQueue
'
, [
'
getTime
'
], [
$
database
= m::
mock
(
'
Illuminate\Database\Connection
'
),
'
table
'
,
'
default
'
]);
$
queue
->
expects
(
$
this
->
any
())->
method
(
'
getTime
'
)->
will
(
$
this
->
returnValue
(
'
time
'
));
$
database
->
shouldReceive
(
'
table
'
)->
with
(
'
table
'
)->
andReturn
(
$
query
= m::
mock
(
'
StdClass
'
));
$
query
->
shouldReceive
(
'
insertGetId
'
)->
once
()->
andReturnUsing
(
function
(
$
array
) {
$
this
->
assertEquals
(
'
default
'
,
$
array
[
'
queue
'
]);
$
this
->
assertEquals
(
json_encode
([
'
job
'
=>
'
foo
'
,
'
data
'
=> [
'
data
'
]]),
$
array
[
'
payload
'
]);
$
this
->
assertEquals
(
0
,
$
array
[
'
attempts
'
]);
$
this
->
assertEquals
(
0
,
$
array
[
'
reserved
'
]);
$
this
->
assertNull
(
$
array
[
'
reserved_at
'
]);
$
this
->
assertInternalType
(
'
int
'
,
$
array
[
'
available_at
'
]);
});
$
queue
->
push
(
'
foo
'
, [
'
data
'
]);
}
public
function
testDelayedPushProperlyPushesJobOntoDatabase
()
{
$
queue
=
$
this
->
getMock
(
'
Illuminate\Queue\DatabaseQueue
'
,
[
'
getTime
'
],
[
$
database
= m::
mock
(
'
Illuminate\Database\Connection
'
),
'
table
'
,
'
default
'
]
);
$
queue
->
expects
(
$
this
->
any
())->
method
(
'
getTime
'
)->
will
(
$
this
->
returnValue
(
'
time
'
));
$
database
->
shouldReceive
(
'
table
'
)->
with
(
'
table
'
)->
andReturn
(
$
query
= m::
mock
(
'
StdClass
'
));
$
query
->
shouldReceive
(
'
insertGetId
'
)->
once
()->
andReturnUsing
(
function
(
$
array
) {
$
this
->
assertEquals
(
'
default
'
,
$
array
[
'
queue
'
]);
$
this
->
assertEquals
(
json_encode
([
'
job
'
=>
'
foo
'
,
'
data
'
=> [
'
data
'
]]),
$
array
[
'
payload
'
]);
$
this
->
assertEquals
(
0
,
$
array
[
'
attempts
'
]);
$
this
->
assertEquals
(
0
,
$
array
[
'
reserved
'
]);
$
this
->
assertNull
(
$
array
[
'
reserved_at
'
]);
$
this
->
assertInternalType
(
'
int
'
,
$
array
[
'
available_at
'
]);
});
$
queue
->
later
(
10
,
'
foo
'
, [
'
data
'
]);
}
public
function
testBulkBatchPushesOntoDatabase
()
{
$
database
= m::
mock
(
'
Illuminate\Database\Connection
'
);
$
queue
=
$
this
->
getMock
(
'
Illuminate\Queue\DatabaseQueue
'
, [
'
getTime
'
,
'
getAvailableAt
'
], [
$
database
,
'
table
'
,
'
default
'
]);
$
queue
->
expects
(
$
this
->
any
())->
method
(
'
getTime
'
)->
will
(
$
this
->
returnValue
(
'
created
'
));
$
queue
->
expects
(
$
this
->
any
())->
method
(
'
getAvailableAt
'
)->
will
(
$
this
->
returnValue
(
'
available
'
));
$
database
->
shouldReceive
(
'
table
'
)->
with
(
'
table
'
)->
andReturn
(
$
query
= m::
mock
(
'
StdClass
'
));
$
query
->
shouldReceive
(
'
insert
'
)->
once
()->
andReturnUsing
(
function
(
$
records
) {
$
this
->
assertEquals
([[
'
queue
'
=>
'
queue
'
,
'
payload
'
=>
json_encode
([
'
job
'
=>
'
foo
'
,
'
data
'
=> [
'
data
'
]]),
'
attempts
'
=>
0
,
'
reserved
'
=>
0
,
'
reserved_at
'
=>
null
,
'
available_at
'
=>
'
available
'
,
'
created_at
'
=>
'
created
'
,
], [
'
queue
'
=>
'
queue
'
,
'
payload
'
=>
json_encode
([
'
job
'
=>
'
bar
'
,
'
data
'
=> [
'
data
'
]]),
'
attempts
'
=>
0
,
'
reserved
'
=>
0
,
'
reserved_at
'
=>
null
,
'
available_at
'
=>
'
available
'
,
'
created_at
'
=>
'
created
'
,
]],
$
records
);
});
$
queue
->
bulk
([
'
foo
'
,
'
bar
'
], [
'
data
'
],
'
queue
'
);
}
}
Back
|
FazBrowse Home
|
New Git URL