FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-framework/tests/Simplex/FrameworkTest.php at main · jprivet-dev/php-framework · GitHub
jprivet-dev
/
php-framework
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
php-framework
/
tests
/
Simplex
/
FrameworkTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (42 loc) · 1.81 KB
Breadcrumbs
php-framework
/
tests
/
Simplex
/
FrameworkTest.php
Copy path
File metadata and controls
49 lines (42 loc) · 1.81 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
<?php
use
PHPUnit
\
Framework
\
TestCase
;
use
Simplex
\
Framework
;
use
Symfony
\
Component
\
EventDispatcher
\
EventDispatcher
;
use
Symfony
\
Component
\
HttpFoundation
\
Request
;
use
Symfony
\
Component
\
HttpKernel
\
Controller
\
ArgumentResolverInterface
;
use
Symfony
\
Component
\
HttpKernel
\
Controller
\
ControllerResolverInterface
;
use
Symfony
\
Component
\
Routing
\
Exception
\
ResourceNotFoundException
;
use
Symfony
\
Component
\
Routing
\
Matcher
\
UrlMatcherInterface
;
use
Symfony
\
Component
\
Routing
\
RequestContext
;
class
FrameworkTest
extends
TestCase
{
public
function
testNotFoundHandling
()
{
$
framework
=
$
this
->
getFrameworkForException
(
new
ResourceNotFoundException
());
$
response
=
$
framework
->
handle
(
new
Request
());
$
this
->
assertEquals
(
404
,
$
response
->
getStatusCode
());
}
public
function
testErrorHandling
()
{
$
framework
=
$
this
->
getFrameworkForException
(
new
RuntimeException
());
$
response
=
$
framework
->
handle
(
new
Request
());
$
this
->
assertEquals
(
500
,
$
response
->
getStatusCode
());
}
private
function
getFrameworkForException
(
Exception
$
exception
):
Framework
{
$
dispatcher
=
$
this
->
createMock
(EventDispatcher::class);
$
context
=
$
this
->
createMock
(RequestContext::class);
$
matcher
=
$
this
->
createMock
(UrlMatcherInterface::class);
$
matcher
->
expects
(
$
this
->
once
())
->
method
(
'
match
'
)
->
will
(
$
this
->
throwException
(
$
exception
));
$
matcher
->
expects
(
$
this
->
once
())
->
method
(
'
getContext
'
)
->
will
(
$
this
->
returnValue
(
$
context
));
$
controllerResolver
=
$
this
->
createMock
(ControllerResolverInterface::class);
$
argumentResolver
=
$
this
->
createMock
(ArgumentResolverInterface::class);
return
new
Framework
(
$
dispatcher
,
$
matcher
,
$
controllerResolver
,
$
argumentResolver
);
}
}
Back
|
FazBrowse Home
|
New Git URL