Skip to content

Commit 72e279d

Browse files
committed
WordPress-Core/FileName: add a test for code handling STDIN
The sniff bails early when handling STDIN. This commit adds a test to cover that part of the sniff code.
1 parent 48e59e9 commit 72e279d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

WordPress/Tests/Files/FileNameUnitTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
namespace WordPressCS\WordPress\Tests\Files;
1111

12+
use PHP_CodeSniffer\Files\DummyFile;
13+
use PHP_CodeSniffer\Ruleset;
1214
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
15+
use PHPCSUtils\BackCompat\Helper;
16+
use PHPCSUtils\TestUtils\ConfigDouble;
1317

1418
/**
1519
* Unit test class for the FileName sniff.
@@ -172,4 +176,26 @@ public function getErrorList( $testFile = '' ) {
172176
public function getWarningList() {
173177
return array();
174178
}
179+
180+
/**
181+
* Test the sniff bails early when handling STDIN.
182+
*
183+
* @return void
184+
*/
185+
public function testStdIn() {
186+
$config = new ConfigDouble();
187+
Helper::setConfigData( 'installed_paths', dirname( dirname( __DIR__ ) ), true, $config );
188+
$config->standards = array( 'WordPress' );
189+
$config->sniffs = array( 'WordPress.Files.FileName' );
190+
191+
$ruleset = new Ruleset( $config );
192+
193+
$content = '<?php ';
194+
$file = new DummyFile( $content, $ruleset, $config );
195+
$file->process();
196+
197+
$this->assertSame( 0, $file->getErrorCount() );
198+
$this->assertSame( 0, $file->getWarningCount() );
199+
$this->assertCount( 0, $file->getErrors() );
200+
}
175201
}

0 commit comments

Comments
 (0)