-
-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathReportTest.php
More file actions
90 lines (82 loc) · 2.8 KB
/
Copy pathReportTest.php
File metadata and controls
90 lines (82 loc) · 2.8 KB
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
<?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\System;
class ReportTest extends SystemTestCase
{
/**
* It should generate a report.
*/
public function testGenerateReport(): void
{
$this->getBenchResult();
$process = $this->phpbench(
'report --file=' . $this->fname . ' --report=default'
);
$this->assertEquals(0, $process->getExitCode());
$output = $process->getOutput();
$this->assertStringContainsString('benchNothing', $output);
}
/**
* It should generate a report when given the --ref option.
*/
public function testGenerateReportFromUuid(): void
{
$document = $this->getBenchResult(null, ' --store');
$ref = $document->evaluate('string(./suite/@uuid)');
$process = $this->phpbench(
'report --ref=' . $ref . ' --report=default'
);
$this->assertEquals(0, $process->getExitCode());
$output = $process->getOutput();
$this->assertStringContainsString('benchNothing', $output);
}
public function testGenerateFilteredReport(): void
{
$document = $this->getBenchResult(null, ' --store');
$ref = $document->evaluate('string(./suite/@uuid)');
$process = $this->phpbench(
'report --ref=' . $ref . ' --report=default --filter=Anything --variant=nothing'
);
$this->assertEquals(0, $process->getExitCode());
$output = $process->getOutput();
$this->assertEmpty($output);
}
/**
* It should allow the mode, precision and time-unit to be specified.
*/
public function testTimeUnitOverride(): void
{
$this->getBenchResult();
$process = $this->phpbench(
'report --file=' . $this->fname . ' --report=default --time-unit=seconds --mode=throughput --precision=6'
);
$output = $process->getOutput();
$this->assertExitCode(0, $process);
$this->assertStringContainsString('100,000.000000ops/s', $output);
}
/**
* It should throw an exception if no reports are specified.
*/
public function testNoReports(): void
{
$process = $this->phpbench('report --file=results/report1.xml');
$this->assertExitCode(1, $process);
$this->assertStringContainsString('You must specify or con', $process->getErrorOutput());
}
/**
* It should throw an exception if the report file does not exist.
*/
public function testNonExistingFile(): void
{
$process = $this->phpbench('report tests/Systemist.xml');
$this->assertExitCode(1, $process);
}
}