Skip to content

Commit 94ebac3

Browse files
authored
Merge pull request #41 from octalmage/clean_report_tests
clean_report tests.
2 parents 7d05014 + 36f8a28 commit 94ebac3

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/wpephpcompat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public function generate_directory_list() {
373373
* @param string $report The full report.
374374
* @return string The cleaned report.
375375
*/
376-
private function clean_report( $report ) {
376+
public function clean_report( $report ) {
377377
// Remove unnecessary overview.
378378
$report = preg_replace ( '/Time:.+\n/si', '', $report );
379379

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
class TestCleanReport extends WP_UnitTestCase {
3+
4+
private $wpephpc;
5+
6+
public function setUp() {
7+
$root_dir = realpath( __DIR__ . '/../../' );
8+
9+
$this->wpephpc = new \WPEPHPCompat( $root_dir );
10+
}
11+
12+
public function test_clean_report_time() {
13+
$report = "Time: 323\n";
14+
15+
$output = $this->wpephpc->clean_report( $report );
16+
$this->assertEquals( '', $output );
17+
}
18+
19+
public function test_clean_report_newlines() {
20+
$report = "\n\n\n\n";
21+
22+
$output = $this->wpephpc->clean_report( $report );
23+
$this->assertEquals( '', $output );
24+
}
25+
26+
public function test_clean_report_time_and_newlines() {
27+
$report = "\n\n\nhello\nTime: 323\n\n\n\n\n";
28+
29+
$output = $this->wpephpc->clean_report( $report );
30+
$this->assertEquals( 'hello', $output );
31+
}
32+
}

0 commit comments

Comments
 (0)