FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Foundation/FoundationApplicationTest.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
/
Foundation
/
FoundationApplicationTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
214 lines (183 loc) · 7.44 KB
Breadcrumbs
framework
/
tests
/
Foundation
/
FoundationApplicationTest.php
Copy path
File metadata and controls
executable file
·
214 lines (183 loc) · 7.44 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
use
Mockery
as
m
;
use
Illuminate
\
Foundation
\
Application
;
class
FoundationApplicationTest
extends
PHPUnit_Framework_TestCase
{
public
function
tearDown
()
{
m::
close
();
}
public
function
testSetLocaleSetsLocaleAndFiresLocaleChangedEvent
()
{
$
app
=
new
Application
;
$
app
[
'
config
'
] =
$
config
= m::
mock
(
'
StdClass
'
);
$
config
->
shouldReceive
(
'
set
'
)->
once
()->
with
(
'
app.locale
'
,
'
foo
'
);
$
app
[
'
translator
'
] =
$
trans
= m::
mock
(
'
StdClass
'
);
$
trans
->
shouldReceive
(
'
setLocale
'
)->
once
()->
with
(
'
foo
'
);
$
app
[
'
events
'
] =
$
events
= m::
mock
(
'
StdClass
'
);
$
events
->
shouldReceive
(
'
fire
'
)->
once
()->
with
(
'
locale.changed
'
, [
'
foo
'
]);
$
app
->
setLocale
(
'
foo
'
);
}
public
function
testServiceProvidersAreCorrectlyRegistered
()
{
$
provider
= m::
mock
(
'
Illuminate\Support\ServiceProvider
'
);
$
class
=
get_class
(
$
provider
);
$
provider
->
shouldReceive
(
'
register
'
)->
once
();
$
app
=
new
Application
;
$
app
->
register
(
$
provider
);
$
this
->
assertTrue
(
in_array
(
$
class
,
$
app
->
getLoadedProviders
()));
}
public
function
testDeferredServicesMarkedAsBound
()
{
$
app
=
new
Application
;
$
app
->
setDeferredServices
([
'
foo
'
=>
'
ApplicationDeferredServiceProviderStub
'
]);
$
this
->
assertTrue
(
$
app
->
bound
(
'
foo
'
));
$
this
->
assertEquals
(
'
foo
'
,
$
app
->
make
(
'
foo
'
));
}
public
function
testDeferredServicesAreSharedProperly
()
{
$
app
=
new
Application
;
$
app
->
setDeferredServices
([
'
foo
'
=>
'
ApplicationDeferredSharedServiceProviderStub
'
]);
$
this
->
assertTrue
(
$
app
->
bound
(
'
foo
'
));
$
one
=
$
app
->
make
(
'
foo
'
);
$
two
=
$
app
->
make
(
'
foo
'
);
$
this
->
assertInstanceOf
(
'
StdClass
'
,
$
one
);
$
this
->
assertInstanceOf
(
'
StdClass
'
,
$
two
);
$
this
->
assertSame
(
$
one
,
$
two
);
}
public
function
testDeferredServicesCanBeExtended
()
{
$
app
=
new
Application
;
$
app
->
setDeferredServices
([
'
foo
'
=>
'
ApplicationDeferredServiceProviderStub
'
]);
$
app
->
extend
(
'
foo
'
,
function
(
$
instance
,
$
container
) {
return
$
instance
.
'
bar
'
; });
$
this
->
assertEquals
(
'
foobar
'
,
$
app
->
make
(
'
foo
'
));
}
public
function
testDeferredServiceProviderIsRegisteredOnlyOnce
()
{
$
app
=
new
Application
;
$
app
->
setDeferredServices
([
'
foo
'
=>
'
ApplicationDeferredServiceProviderCountStub
'
]);
$
obj
=
$
app
->
make
(
'
foo
'
);
$
this
->
assertInstanceOf
(
'
StdClass
'
,
$
obj
);
$
this
->
assertSame
(
$
obj
,
$
app
->
make
(
'
foo
'
));
$
this
->
assertEquals
(
1
, ApplicationDeferredServiceProviderCountStub::
$
count
);
}
public
function
testDeferredServicesAreLazilyInitialized
()
{
ApplicationDeferredServiceProviderStub::
$
initialized
=
false
;
$
app
=
new
Application
;
$
app
->
setDeferredServices
([
'
foo
'
=>
'
ApplicationDeferredServiceProviderStub
'
]);
$
this
->
assertTrue
(
$
app
->
bound
(
'
foo
'
));
$
this
->
assertFalse
(ApplicationDeferredServiceProviderStub::
$
initialized
);
$
app
->
extend
(
'
foo
'
,
function
(
$
instance
,
$
container
) {
return
$
instance
.
'
bar
'
; });
$
this
->
assertFalse
(ApplicationDeferredServiceProviderStub::
$
initialized
);
$
this
->
assertEquals
(
'
foobar
'
,
$
app
->
make
(
'
foo
'
));
$
this
->
assertTrue
(ApplicationDeferredServiceProviderStub::
$
initialized
);
}
public
function
testDeferredServicesCanRegisterFactories
()
{
$
app
=
new
Application
;
$
app
->
setDeferredServices
([
'
foo
'
=>
'
ApplicationFactoryProviderStub
'
]);
$
this
->
assertTrue
(
$
app
->
bound
(
'
foo
'
));
$
this
->
assertEquals
(
1
,
$
app
->
make
(
'
foo
'
));
$
this
->
assertEquals
(
2
,
$
app
->
make
(
'
foo
'
));
$
this
->
assertEquals
(
3
,
$
app
->
make
(
'
foo
'
));
}
public
function
testSingleProviderCanProvideMultipleDeferredServices
()
{
$
app
=
new
Application
;
$
app
->
setDeferredServices
([
'
foo
'
=>
'
ApplicationMultiProviderStub
'
,
'
bar
'
=>
'
ApplicationMultiProviderStub
'
,
]);
$
this
->
assertEquals
(
'
foo
'
,
$
app
->
make
(
'
foo
'
));
$
this
->
assertEquals
(
'
foobar
'
,
$
app
->
make
(
'
bar
'
));
}
public
function
testEnvironment
()
{
$
app
=
new
Application
;
$
app
[
'
env
'
] =
'
foo
'
;
$
this
->
assertEquals
(
'
foo
'
,
$
app
->
environment
());
$
this
->
assertTrue
(
$
app
->
environment
(
'
foo
'
));
$
this
->
assertTrue
(
$
app
->
environment
(
'
f*
'
));
$
this
->
assertTrue
(
$
app
->
environment
(
'
foo
'
,
'
bar
'
));
$
this
->
assertTrue
(
$
app
->
environment
([
'
foo
'
,
'
bar
'
]));
$
this
->
assertFalse
(
$
app
->
environment
(
'
qux
'
));
$
this
->
assertFalse
(
$
app
->
environment
(
'
q*
'
));
$
this
->
assertFalse
(
$
app
->
environment
(
'
qux
'
,
'
bar
'
));
$
this
->
assertFalse
(
$
app
->
environment
([
'
qux
'
,
'
bar
'
]));
}
public
function
testMethodAfterLoadingEnvironmentAddsClosure
()
{
$
app
=
new
Application
;
$
closure
=
function
() {};
$
app
->
afterLoadingEnvironment
(
$
closure
);
$
this
->
assertArrayHasKey
(
0
,
$
app
[
'
events
'
]->
getListeners
(
'
bootstrapped: Illuminate\Foundation\Bootstrap\DetectEnvironment
'
));
$
this
->
assertSame
(
$
closure
,
$
app
[
'
events
'
]->
getListeners
(
'
bootstrapped: Illuminate\Foundation\Bootstrap\DetectEnvironment
'
)[
0
]);
}
public
function
testBeforeBootstrappingAddsClosure
()
{
$
app
=
new
Application
;
$
closure
=
function
() {};
$
app
->
beforeBootstrapping
(
'
Illuminate\Foundation\Bootstrap\RegisterFacades
'
,
$
closure
);
$
this
->
assertArrayHasKey
(
0
,
$
app
[
'
events
'
]->
getListeners
(
'
bootstrapping: Illuminate\Foundation\Bootstrap\RegisterFacades
'
));
$
this
->
assertSame
(
$
closure
,
$
app
[
'
events
'
]->
getListeners
(
'
bootstrapping: Illuminate\Foundation\Bootstrap\RegisterFacades
'
)[
0
]);
}
public
function
testAfterBootstrappingAddsClosure
()
{
$
app
=
new
Application
;
$
closure
=
function
() {};
$
app
->
afterBootstrapping
(
'
Illuminate\Foundation\Bootstrap\RegisterFacades
'
,
$
closure
);
$
this
->
assertArrayHasKey
(
0
,
$
app
[
'
events
'
]->
getListeners
(
'
bootstrapped: Illuminate\Foundation\Bootstrap\RegisterFacades
'
));
$
this
->
assertSame
(
$
closure
,
$
app
[
'
events
'
]->
getListeners
(
'
bootstrapped: Illuminate\Foundation\Bootstrap\RegisterFacades
'
)[
0
]);
}
}
class
ApplicationDeferredSharedServiceProviderStub
extends
Illuminate
\
Support
\ServiceProvider
{
protected
$
defer
=
true
;
public
function
register
()
{
$
this
->
app
->
singleton
(
'
foo
'
,
function
() {
return
new
StdClass
;
});
}
}
class
ApplicationDeferredServiceProviderCountStub
extends
Illuminate
\
Support
\ServiceProvider
{
public
static
$
count
=
0
;
protected
$
defer
=
true
;
public
function
register
()
{
static
::
$
count
++;
$
this
->
app
[
'
foo
'
] =
new
StdClass
;
}
}
class
ApplicationDeferredServiceProviderStub
extends
Illuminate
\
Support
\ServiceProvider
{
public
static
$
initialized
=
false
;
protected
$
defer
=
true
;
public
function
register
()
{
static
::
$
initialized
=
true
;
$
this
->
app
[
'
foo
'
] =
'
foo
'
;
}
}
class
ApplicationFactoryProviderStub
extends
Illuminate
\
Support
\ServiceProvider
{
protected
$
defer
=
true
;
public
function
register
()
{
$
this
->
app
->
bind
(
'
foo
'
,
function
() {
static
$
count
=
0
;
return
++
$
count
;
});
}
}
class
ApplicationMultiProviderStub
extends
Illuminate
\
Support
\ServiceProvider
{
protected
$
defer
=
true
;
public
function
register
()
{
$
this
->
app
->
singleton
(
'
foo
'
,
function
() {
return
'
foo
'
; });
$
this
->
app
->
singleton
(
'
bar
'
,
function
(
$
app
) {
return
$
app
[
'
foo
'
].
'
bar
'
; });
}
}
Back
|
FazBrowse Home
|
New Git URL