FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Pagination/PaginationEnvironmentTest.php at 4.1 · JavaDevl/framework · GitHub
JavaDevl
framework
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
tests
/
Pagination
/
PaginationEnvironmentTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
102 lines (72 loc) · 2.71 KB
Breadcrumbs
framework
/
tests
/
Pagination
/
PaginationEnvironmentTest.php
Copy path
File metadata and controls
executable file
·
102 lines (72 loc) · 2.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
<?php
use
Mockery
as
m
;
use
Illuminate
\
Pagination
\
Environment
;
class
PaginationEnvironmentTest
extends
PHPUnit_Framework_TestCase {
public
function
tearDown
()
{
m::
close
();
}
public
function
testCreationOfEnvironment
()
{
$
env
=
$
this
->
getEnvironment
();
}
public
function
testPaginatorCanBeCreated
()
{
$
env
=
$
this
->
getEnvironment
();
$
request
=
Illuminate
\
Http
\Request::
create
(
'
http://foo.com
'
,
'
GET
'
);
$
env
->
setRequest
(
$
request
);
$
this
->
assertInstanceOf
(
'
Illuminate\Pagination\Paginator
'
,
$
env
->
make
(
array
(
'
foo
'
,
'
bar
'
),
2
,
2
));
}
public
function
testPaginationViewCanBeCreated
()
{
$
env
=
$
this
->
getEnvironment
();
$
paginator
= m::
mock
(
'
Illuminate\Pagination\Paginator
'
);
$
env
->
getViewDriver
()->
shouldReceive
(
'
make
'
)->
once
()->
with
(
'
pagination::slider
'
,
array
(
'
environment
'
=>
$
env
,
'
paginator
'
=>
$
paginator
))->
andReturn
(
'
foo
'
);
$
this
->
assertEquals
(
'
foo
'
,
$
env
->
getPaginationView
(
$
paginator
));
}
public
function
testCurrentPageCanBeRetrieved
()
{
$
env
=
$
this
->
getEnvironment
();
$
request
=
Illuminate
\
Http
\Request::
create
(
'
http://foo.com?page=2
'
,
'
GET
'
);
$
env
->
setRequest
(
$
request
);
$
this
->
assertEquals
(
2
,
$
env
->
getCurrentPage
());
$
env
=
$
this
->
getEnvironment
();
$
request
=
Illuminate
\
Http
\Request::
create
(
'
http://foo.com?page=-1
'
,
'
GET
'
);
$
env
->
setRequest
(
$
request
);
$
this
->
assertEquals
(
1
,
$
env
->
getCurrentPage
());
}
public
function
testSettingCurrentUrlOverrulesRequest
()
{
$
env
=
$
this
->
getEnvironment
();
$
request
=
Illuminate
\
Http
\Request::
create
(
'
http://foo.com?page=2
'
,
'
GET
'
);
$
env
->
setRequest
(
$
request
);
$
env
->
setCurrentPage
(
3
);
$
this
->
assertEquals
(
3
,
$
env
->
getCurrentPage
());
}
public
function
testCurrentUrlCanBeRetrieved
()
{
$
env
=
$
this
->
getEnvironment
();
$
request
=
Illuminate
\
Http
\Request::
create
(
'
http://foo.com/bar?page=2
'
,
'
GET
'
);
$
env
->
setRequest
(
$
request
);
$
this
->
assertEquals
(
'
http://foo.com/bar
'
,
$
env
->
getCurrentUrl
());
$
env
=
$
this
->
getEnvironment
();
$
request
=
Illuminate
\
Http
\Request::
create
(
'
http://foo.com?page=2
'
,
'
GET
'
);
$
env
->
setRequest
(
$
request
);
$
this
->
assertEquals
(
'
http://foo.com
'
,
$
env
->
getCurrentUrl
());
}
public
function
testOverridingPageParam
()
{
$
env
=
$
this
->
getEnvironment
();
$
this
->
assertEquals
(
'
page
'
,
$
env
->
getPageName
());
$
env
->
setPageName
(
'
foo
'
);
$
this
->
assertEquals
(
'
foo
'
,
$
env
->
getPageName
());
}
protected
function
getEnvironment
()
{
$
request
= m::
mock
(
'
Illuminate\Http\Request
'
);
$
view
= m::
mock
(
'
Illuminate\View\Environment
'
);
$
trans
= m::
mock
(
'
Symfony\Component\Translation\TranslatorInterface
'
);
$
view
->
shouldReceive
(
'
addNamespace
'
)->
once
()->
with
(
'
pagination
'
,
realpath
(
__DIR__
.
'
/../../src/Illuminate/Pagination
'
).
'
/views
'
);
return
new
Environment
(
$
request
,
$
view
,
$
trans
,
'
page
'
);
}
}
Back
|
FazBrowse Home
|
New Git URL