FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Queue/QueueSyncQueueTest.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
/
QueueSyncQueueTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
112 lines (95 loc) · 3.71 KB
Breadcrumbs
framework
/
tests
/
Queue
/
QueueSyncQueueTest.php
Copy path
File metadata and controls
executable file
·
112 lines (95 loc) · 3.71 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
use
Mockery
as
m
;
class
QueueSyncQueueTest
extends
PHPUnit_Framework_TestCase
{
public
function
tearDown
()
{
m::
close
();
}
public
function
testPushShouldFireJobInstantly
()
{
unset(
$
_SERVER
[
'
__sync.test
'
]);
/*
* Test Synced Closure
*/
$
sync
=
new
Illuminate
\
Queue
\
SyncQueue
;
$
container
=
new
Illuminate
\
Container
\
Container
;
$
encrypter
=
new
Illuminate
\
Encryption
\
Encrypter
(
str_repeat
(
'
b
'
,
16
));
$
container
->
instance
(
'
Illuminate\Contracts\Encryption\Encrypter
'
,
$
encrypter
);
$
sync
->
setContainer
(
$
container
);
$
sync
->
setEncrypter
(
$
encrypter
);
$
sync
->
push
(
function
(
$
job
) {
$
_SERVER
[
'
__sync.test
'
] =
true
;
$
job
->
delete
();
});
$
this
->
assertTrue
(
$
_SERVER
[
'
__sync.test
'
]);
unset(
$
_SERVER
[
'
__sync.test
'
]);
/*
* Test Synced Class Handler
*/
$
sync
->
push
(
'
SyncQueueTestHandler
'
, [
'
foo
'
=>
'
bar
'
]);
$
this
->
assertInstanceOf
(
'
Illuminate\Queue\Jobs\SyncJob
'
,
$
_SERVER
[
'
__sync.test
'
][
0
]);
$
this
->
assertEquals
([
'
foo
'
=>
'
bar
'
],
$
_SERVER
[
'
__sync.test
'
][
1
]);
}
public
function
testQueueableEntitiesAreSerializedAndResolved
()
{
$
sync
=
new
Illuminate
\
Queue
\
SyncQueue
;
$
sync
->
setContainer
(
$
container
=
new
Illuminate
\
Container
\
Container
);
$
container
->
instance
(
'
Illuminate\Contracts\Queue\EntityResolver
'
,
$
resolver
= m::
mock
(
'
Illuminate\Contracts\Queue\EntityResolver
'
));
$
resolver
->
shouldReceive
(
'
resolve
'
)->
once
()->
with
(
'
SyncQueueTestEntity
'
,
1
)->
andReturn
(
new
SyncQueueTestEntity
);
$
sync
->
push
(
'
SyncQueueTestHandler
'
, [
'
entity
'
=>
new
SyncQueueTestEntity
]);
$
this
->
assertInstanceOf
(
'
SyncQueueTestEntity
'
,
$
_SERVER
[
'
__sync.test
'
][
1
][
'
entity
'
]);
}
public
function
testQueueableEntitiesAreSerializedAndResolvedWhenPassedAsSingleEntities
()
{
$
sync
=
new
Illuminate
\
Queue
\
SyncQueue
;
$
sync
->
setContainer
(
$
container
=
new
Illuminate
\
Container
\
Container
);
$
container
->
instance
(
'
Illuminate\Contracts\Queue\EntityResolver
'
,
$
resolver
= m::
mock
(
'
Illuminate\Contracts\Queue\EntityResolver
'
));
$
resolver
->
shouldReceive
(
'
resolve
'
)->
once
()->
with
(
'
SyncQueueTestEntity
'
,
1
)->
andReturn
(
new
SyncQueueTestEntity
);
$
sync
->
push
(
'
SyncQueueTestHandler
'
,
new
SyncQueueTestEntity
);
$
this
->
assertInstanceOf
(
'
SyncQueueTestEntity
'
,
$
_SERVER
[
'
__sync.test
'
][
1
]);
}
public
function
testFailedJobGetsHandledWhenAnExceptionIsThrown
()
{
unset(
$
_SERVER
[
'
__sync.failed
'
]);
$
sync
=
new
Illuminate
\
Queue
\
SyncQueue
;
$
container
=
new
Illuminate
\
Container
\
Container
;
$
encrypter
=
new
Illuminate
\
Encryption
\
Encrypter
(
str_repeat
(
'
c
'
,
16
));
$
container
->
instance
(
'
Illuminate\Contracts\Encryption\Encrypter
'
,
$
encrypter
);
$
events
= m::
mock
(
'
Illuminate\Contracts\Events\Dispatcher
'
);
$
events
->
shouldReceive
(
'
fire
'
)->
once
();
$
container
->
instance
(
'
events
'
,
$
events
);
$
sync
->
setContainer
(
$
container
);
$
sync
->
setEncrypter
(
$
encrypter
);
try
{
$
sync
->
push
(
'
FailingSyncQueueTestHandler
'
, [
'
foo
'
=>
'
bar
'
]);
}
catch
(
Exception
$
e
) {
$
this
->
assertTrue
(
$
_SERVER
[
'
__sync.failed
'
]);
}
}
}
class
SyncQueueTestEntity
implements
Illuminate
\
Contracts
\
Queue
\QueueableEntity
{
public
function
getQueueableId
()
{
return
1
;
}
}
class
SyncQueueTestHandler
{
public
function
fire
(
$
job
,
$
data
)
{
$
_SERVER
[
'
__sync.test
'
] =
func_get_args
();
}
}
class
FailingSyncQueueTestHandler
{
public
function
fire
(
$
job
,
$
data
)
{
throw
new
Exception
();
}
public
function
failed
()
{
$
_SERVER
[
'
__sync.failed
'
] =
true
;
}
}
Back
|
FazBrowse Home
|
New Git URL