FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Log/LogWriterTest.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
/
Log
/
LogWriterTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
83 lines (69 loc) · 2.8 KB
Breadcrumbs
framework
/
tests
/
Log
/
LogWriterTest.php
Copy path
File metadata and controls
executable file
·
83 lines (69 loc) · 2.8 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
<?php
use
Mockery
as
m
;
use
Illuminate
\
Log
\
Writer
;
class
LogWriterTest
extends
PHPUnit_Framework_TestCase
{
public
function
tearDown
()
{
m::
close
();
}
public
function
testFileHandlerCanBeAdded
()
{
$
writer
=
new
Writer
(
$
monolog
= m::
mock
(
'
Monolog\Logger
'
));
$
monolog
->
shouldReceive
(
'
pushHandler
'
)->
once
()->
with
(m::
type
(
'
Monolog\Handler\StreamHandler
'
));
$
writer
->
useFiles
(
__DIR__
);
}
public
function
testRotatingFileHandlerCanBeAdded
()
{
$
writer
=
new
Writer
(
$
monolog
= m::
mock
(
'
Monolog\Logger
'
));
$
monolog
->
shouldReceive
(
'
pushHandler
'
)->
once
()->
with
(m::
type
(
'
Monolog\Handler\RotatingFileHandler
'
));
$
writer
->
useDailyFiles
(
__DIR__
,
5
);
}
public
function
testErrorLogHandlerCanBeAdded
()
{
$
writer
=
new
Writer
(
$
monolog
= m::
mock
(
'
Monolog\Logger
'
));
$
monolog
->
shouldReceive
(
'
pushHandler
'
)->
once
()->
with
(m::
type
(
'
Monolog\Handler\ErrorLogHandler
'
));
$
writer
->
useErrorLog
();
}
public
function
testMethodsPassErrorAdditionsToMonolog
()
{
$
writer
=
new
Writer
(
$
monolog
= m::
mock
(
'
Monolog\Logger
'
));
$
monolog
->
shouldReceive
(
'
error
'
)->
once
()->
with
(
'
foo
'
, []);
$
writer
->
error
(
'
foo
'
);
}
public
function
testWriterFiresEventsDispatcher
()
{
$
writer
=
new
Writer
(
$
monolog
= m::
mock
(
'
Monolog\Logger
'
),
$
events
=
new
Illuminate
\
Events
\
Dispatcher
);
$
monolog
->
shouldReceive
(
'
error
'
)->
once
()->
with
(
'
foo
'
, []);
$
events
->
listen
(
'
illuminate.log
'
,
function
(
$
level
,
$
message
,
array
$
context
= []) {
$
_SERVER
[
'
__log.level
'
] =
$
level
;
$
_SERVER
[
'
__log.message
'
] =
$
message
;
$
_SERVER
[
'
__log.context
'
] =
$
context
;
});
$
writer
->
error
(
'
foo
'
);
$
this
->
assertTrue
(
isset
(
$
_SERVER
[
'
__log.level
'
]));
$
this
->
assertEquals
(
'
error
'
,
$
_SERVER
[
'
__log.level
'
]);
unset(
$
_SERVER
[
'
__log.level
'
]);
$
this
->
assertTrue
(
isset
(
$
_SERVER
[
'
__log.message
'
]));
$
this
->
assertEquals
(
'
foo
'
,
$
_SERVER
[
'
__log.message
'
]);
unset(
$
_SERVER
[
'
__log.message
'
]);
$
this
->
assertTrue
(
isset
(
$
_SERVER
[
'
__log.context
'
]));
$
this
->
assertEquals
([],
$
_SERVER
[
'
__log.context
'
]);
unset(
$
_SERVER
[
'
__log.context
'
]);
}
/**
* @expectedException RuntimeException
*/
public
function
testListenShortcutFailsWithNoDispatcher
()
{
$
writer
=
new
Writer
(
$
monolog
= m::
mock
(
'
Monolog\Logger
'
));
$
writer
->
listen
(
function
() {});
}
public
function
testListenShortcut
()
{
$
writer
=
new
Writer
(
$
monolog
= m::
mock
(
'
Monolog\Logger
'
),
$
events
= m::
mock
(
'
Illuminate\Contracts\Events\Dispatcher
'
));
$
callback
=
function
() {
return
'
success
'
; };
$
events
->
shouldReceive
(
'
listen
'
)->
with
(
'
illuminate.log
'
,
$
callback
)->
once
();
$
writer
->
listen
(
$
callback
);
}
}
Back
|
FazBrowse Home
|
New Git URL