FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpbench/tests/Unit/Config/ConfigLoaderTest.php at program-executor · phpbench/phpbench · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
phpbench
/
phpbench
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
133
Star
2k
Code
Issues
28
Pull requests
10
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
phpbench
/
tests
/
Unit
/
Config
/
ConfigLoaderTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (70 loc) · 2.5 KB
Breadcrumbs
phpbench
/
tests
/
Unit
/
Config
/
ConfigLoaderTest.php
Copy path
File metadata and controls
85 lines (70 loc) · 2.5 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
<?php
namespace
PhpBench
\
Tests
\
Unit
\
Config
;
use
PhpBench
\
Config
\
ConfigLoader
;
use
PhpBench
\
Config
\
Exception
\
ConfigFileNotFound
;
use
PhpBench
\
Config
\
Linter
\
SeldLinter
;
use
PhpBench
\
Config
\
Processor
\
CallbackProcessor
;
use
PhpBench
\
Tests
\
IntegrationTestCase
;
use
PhpBench
\
Tests
\
ProphecyTrait
;
class
ConfigLoaderTest
extends
IntegrationTestCase
{
use
ProphecyTrait;
protected
function
setUp
():
void
{
$
this
->
workspace
()->
reset
();
}
public
function
testLoadsConfig
():
void
{
$
this
->
workspace
()->
put
(
'
test.json
'
,
'
{"foobar": "barfoo"}
'
);
self
::
assertEquals
(
[
'
foobar
'
=>
'
barfoo
'
],
$
this
->
createLoader
()->
load
(
$
this
->
workspace
()->
path
(
'
test.json
'
))
);
}
public
function
testExceptionOnFileNotFound
():
void
{
$
this
->
expectException
(ConfigFileNotFound::class);
self
::
assertEquals
(
[
'
foobar
'
=>
'
barfoo
'
],
$
this
->
createLoader
()->
load
(
$
this
->
workspace
()->
path
(
'
test.json
'
))
);
}
public
function
testAppliesProcessors
():
void
{
$
this
->
workspace
()->
put
(
'
test.json
'
,
'
{"foobar": "barfoo"}
'
);
$
result
=
$
this
->
createLoader
([
new
CallbackProcessor
(
function
(
ConfigLoader
$
loader
,
string
$
path
,
array
$
config
) {
$
config
[
'
barfoo
'
] =
'
foobar
'
;
return
$
config
;
}),
])->
load
(
$
this
->
workspace
()->
path
(
'
test.json
'
));
self
::
assertEquals
([
'
foobar
'
=>
'
barfoo
'
,
'
barfoo
'
=>
'
foobar
'
,
],
$
result
);
}
public
function
testAppliesProcessorsThatApplyProcessors
():
void
{
$
this
->
workspace
()->
put
(
'
test.json
'
,
'
{"foobar": "barfoo", "include": "extra.json"}
'
);
$
this
->
workspace
()->
put
(
'
extra.json
'
,
'
{"bar": "baz"}
'
);
$
result
=
$
this
->
createLoader
([
new
CallbackProcessor
(
function
(
ConfigLoader
$
loader
,
string
$
path
,
array
$
config
) {
if
(
isset
(
$
config
[
'
include
'
])) {
$
config
[
'
extra
'
] =
$
loader
->
load
(
dirname
(
$
path
) .
'
/
'
.
$
config
[
'
include
'
]);
}
unset(
$
config
[
'
include
'
]);
return
$
config
;
}),
])->
load
(
$
this
->
workspace
()->
path
(
'
test.json
'
));
self
::
assertEquals
([
'
foobar
'
=>
'
barfoo
'
,
'
extra
'
=> [
'
bar
'
=>
'
baz
'
,
],
],
$
result
);
}
private
function
createLoader
(
array
$
processors
= []):
ConfigLoader
{
return
new
ConfigLoader
(
new
SeldLinter
(),
$
processors
);
}
}
Back
|
FazBrowse Home
|
New Git URL