diff --git a/WordPress/Tests/Files/FileNameUnitTest.php b/WordPress/Tests/Files/FileNameUnitTest.php index 905147956d..c56d3661f2 100644 --- a/WordPress/Tests/Files/FileNameUnitTest.php +++ b/WordPress/Tests/Files/FileNameUnitTest.php @@ -9,7 +9,11 @@ namespace WordPressCS\WordPress\Tests\Files; +use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +use PHPCSUtils\BackCompat\Helper; +use PHPCSUtils\TestUtils\ConfigDouble; /** * Unit test class for the FileName sniff. @@ -172,4 +176,26 @@ public function getErrorList( $testFile = '' ) { public function getWarningList() { return array(); } + + /** + * Test the sniff bails early when handling STDIN. + * + * @return void + */ + public function testStdIn() { + $config = new ConfigDouble(); + Helper::setConfigData( 'installed_paths', dirname( dirname( __DIR__ ) ), true, $config ); + $config->standards = array( 'WordPress' ); + $config->sniffs = array( 'WordPress.Files.FileName' ); + + $ruleset = new Ruleset( $config ); + + $content = 'process(); + + $this->assertSame( 0, $file->getErrorCount() ); + $this->assertSame( 0, $file->getWarningCount() ); + $this->assertCount( 0, $file->getErrors() ); + } } diff --git a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php index cac3a5983c..a8c7c95e84 100644 --- a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php +++ b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php @@ -9,8 +9,11 @@ namespace WordPressCS\WordPress\Tests\Utils; +use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Ruleset; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHPCSUtils\BackCompat\Helper; +use PHPCSUtils\TestUtils\ConfigDouble; /** * Unit test class for the I18nTextDomainFixer sniff. @@ -200,4 +203,32 @@ public function getWarningList( $testFile = '' ) { return array(); } } + + /** + * Test the sniff bails early when handling a plugin header passed via STDIN. + * + * @return void + */ + public function testStdIn() { + $config = new ConfigDouble(); + Helper::setConfigData( 'installed_paths', dirname( dirname( __DIR__ ) ), true, $config ); + $config->standards = array( 'WordPress' ); + $config->sniffs = array( 'WordPress.Utils.I18nTextDomainFixer' ); + + $ruleset = new Ruleset( $config ); + + $content = 'process(); + + $this->assertSame( 0, $file->getErrorCount() ); + $this->assertSame( 0, $file->getWarningCount() ); + $this->assertCount( 0, $file->getErrors() ); + } }