FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpbench/tests/Unit/Model/BenchmarkTest.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
/
Model
/
BenchmarkTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
100 lines (87 loc) · 3.17 KB
Breadcrumbs
phpbench
/
tests
/
Unit
/
Model
/
BenchmarkTest.php
Copy path
File metadata and controls
100 lines (87 loc) · 3.17 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
<?php
/*
* This file is part of the PHPBench package
*
* (c) Daniel Leech <daniel@dantleech.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace
PhpBench
\
Tests
\
Unit
\
Model
;
use
PhpBench
\
Benchmark
\
Metadata
\
SubjectMetadata
;
use
PhpBench
\
Model
\
Benchmark
;
use
PhpBench
\
Model
\
ResolvedExecutor
;
use
PhpBench
\
Model
\
Suite
;
use
PhpBench
\
Registry
\
Config
;
use
PhpBench
\
Tests
\
TestCase
;
class
BenchmarkTest
extends
TestCase
{
public
const
EXAMPLE_FORMAT
=
'
foobar
'
;
/**
* @var Benchmark
*/
private
$
benchmark
;
private
$
suite
;
protected
function
setUp
():
void
{
$
this
->
suite
=
$
this
->
prophesize
(Suite::class);
$
this
->
benchmark
=
new
Benchmark
(
$
this
->
suite
->
reveal
(),
'
Class
'
);
}
public
function
testGetSet
():
void
{
$
this
->
assertSame
(
$
this
->
suite
->
reveal
(),
$
this
->
benchmark
->
getSuite
());
$
this
->
assertEquals
(
'
Class
'
,
$
this
->
benchmark
->
getClass
());
}
/**
* @dataProvider provideName
*/
public
function
testGetName
(
string
$
class
,
string
$
expected
):
void
{
$
benchmark
=
new
Benchmark
(
$
this
->
suite
->
reveal
(),
$
class
);
self
::
assertEquals
(
$
expected
,
$
benchmark
->
getName
());
}
/**
* @return array<array<string>>
*/
public
function
provideName
():
array
{
return
[
[
''
,
''
],
[
'
A
'
,
'
A
'
],
[
'
A
\\
B
'
,
'
B
'
],
[
'
A
\\
B
\\
Code
'
,
'
Code
'
],
];
}
/**
* It should create and add a subject from some metadata.
*/
public
function
testCreateSubjectFromMetadata
():
void
{
$
metadata
=
$
this
->
prophesize
(SubjectMetadata::class);
$
metadata
->
getName
()->
willReturn
(
'
hello
'
);
$
metadata
->
getGroups
()->
willReturn
([
'
one
'
,
'
two
'
]);
$
metadata
->
getSleep
()->
willReturn
(
30
);
$
metadata
->
getFormat
()->
willReturn
(
self
::
EXAMPLE_FORMAT
);
$
metadata
->
getRetryThreshold
()->
willReturn
(
10
);
$
metadata
->
getOutputTimeUnit
()->
willReturn
(
50
);
$
metadata
->
getOutputMode
()->
willReturn
(
60
);
$
metadata
->
getOutputTimePrecision
()->
willReturn
(
3
);
$
executor
= ResolvedExecutor::
fromNameAndConfig
(
'
foo
'
,
new
Config
(
'
one
'
, [
'
foo
'
=>
'
bar
'
]));
$
subject
=
$
this
->
benchmark
->
createSubjectFromMetadataAndExecutor
(
$
metadata
->
reveal
(),
$
executor
);
$
this
->
assertInstanceOf
(
'
PhpBench\Model\Subject
'
,
$
subject
);
$
this
->
assertEquals
(
'
hello
'
,
$
subject
->
getName
());
$
this
->
assertEquals
([
'
one
'
,
'
two
'
],
$
subject
->
getGroups
());
$
this
->
assertEquals
(
30
,
$
subject
->
getSleep
());
$
this
->
assertEquals
(
self
::
EXAMPLE_FORMAT
,
$
subject
->
getFormat
());
$
this
->
assertEquals
(
10
,
$
subject
->
getRetryThreshold
());
$
this
->
assertEquals
(
50
,
$
subject
->
getOutputTimeUnit
());
$
this
->
assertEquals
(
60
,
$
subject
->
getOutputMode
());
$
this
->
assertEquals
(
3
,
$
subject
->
getOutputTimePrecision
());
$
subjects
=
$
this
->
benchmark
->
getSubjects
();
$
this
->
assertCount
(
1
,
$
subjects
);
$
bSubject
=
current
(
$
subjects
);
$
this
->
assertInstanceOf
(
'
PhpBench\Model\Subject
'
,
$
bSubject
);
$
this
->
assertSame
(
$
subject
,
$
bSubject
);
}
}
Back
|
FazBrowse Home
|
New Git URL