Skip to content

Commit e3efb12

Browse files
committed
Tests for Text Report
1 parent afa0dfb commit e3efb12

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/*
3+
* This file is part of the PHP_CodeCoverage package.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestCase.php';
12+
13+
/**
14+
* Tests for the PHP_CodeCoverage_Report_Text class.
15+
*
16+
* @since Class available since Release 3.0.2
17+
*/
18+
class PHP_CodeCoverage_Report_TextTest extends PHP_CodeCoverage_TestCase
19+
{
20+
/**
21+
* @covers PHP_CodeCoverage_Report_Text
22+
*/
23+
public function testTextForBankAccountTest()
24+
{
25+
$text = new PHP_CodeCoverage_Report_Text(50, 90, false, false);
26+
27+
$this->assertStringMatchesFormatFile(
28+
TEST_FILES_PATH . 'BankAccount-text.txt',
29+
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount()))
30+
);
31+
}
32+
33+
/**
34+
* @covers PHP_CodeCoverage_Report_Text
35+
*/
36+
public function testTextForFileWithIgnoredLines()
37+
{
38+
$text = new PHP_CodeCoverage_Report_Text(50, 90, false, false);
39+
40+
$this->assertStringMatchesFormatFile(
41+
TEST_FILES_PATH . 'ignored-lines-text.txt',
42+
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines()))
43+
);
44+
}
45+
46+
/**
47+
* @covers PHP_CodeCoverage_Report_Text
48+
*/
49+
public function testTextForClassWithAnonymousFunction()
50+
{
51+
$text = new PHP_CodeCoverage_Report_Text(50, 90, false, false);
52+
53+
$this->assertStringMatchesFormatFile(
54+
TEST_FILES_PATH . 'class-with-anonymous-function-text.txt',
55+
str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction()))
56+
);
57+
}
58+
}

tests/_files/BankAccount-text.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
3+
Code Coverage Report:
4+
%s
5+
6+
Summary:
7+
Classes: 0.00% (0/1)
8+
Methods: 75.00% (3/4)
9+
Lines: 50.00% (5/10)
10+
11+
BankAccount
12+
Methods: 75.00% ( 3/ 4) Lines: 50.00% ( 5/ 10)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
3+
Code Coverage Report:
4+
%s
5+
6+
Summary:
7+
Classes: 0.00% (0/1)
8+
Methods: 50.00% (1/2)
9+
Lines: 87.50% (7/8)
10+
11+
CoveredClassWithAnonymousFunctionInStaticMethod
12+
Methods: 50.00% ( 1/ 2) Lines: 80.00% ( 4/ 5)

tests/_files/ignored-lines-text.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
3+
Code Coverage Report:
4+
%s
5+
6+
Summary:
7+
Classes: 100.00% (2/2)
8+
Methods: (0/0)
9+
Lines: 50.00% (1/2)
10+

0 commit comments

Comments
 (0)