diff --git a/WordPress/Tests/Files/FileNameStdInTest.xml b/WordPress/Tests/Files/FileNameStdInTest.xml new file mode 100644 index 0000000000..8d837430f3 --- /dev/null +++ b/WordPress/Tests/Files/FileNameStdInTest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/WordPress/Tests/Files/FileNameUnitTest.php b/WordPress/Tests/Files/FileNameUnitTest.php index 905147956d..ee9a0bb128 100644 --- a/WordPress/Tests/Files/FileNameUnitTest.php +++ b/WordPress/Tests/Files/FileNameUnitTest.php @@ -9,6 +9,9 @@ namespace WordPressCS\WordPress\Tests\Files; +use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; /** @@ -172,4 +175,24 @@ 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(); + $config->standards = array( __DIR__ . '/FileNameStdInTest.xml' ); + + $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/I18nTextDomainFixerStdInTest.xml b/WordPress/Tests/Utils/I18nTextDomainFixerStdInTest.xml new file mode 100644 index 0000000000..f4b5513a46 --- /dev/null +++ b/WordPress/Tests/Utils/I18nTextDomainFixerStdInTest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php index 8da63235c1..078ffffe7f 100644 --- a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php +++ b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php @@ -9,6 +9,9 @@ namespace WordPressCS\WordPress\Tests\Utils; +use PHP_CodeSniffer\Files\DummyFile; +use PHP_CodeSniffer\Ruleset; +use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; use PHPCSUtils\BackCompat\Helper; @@ -197,4 +200,30 @@ 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(); + $config->standards = array( __DIR__ . '/I18nTextDomainFixerStdInTest.xml' ); + + $ruleset = new Ruleset( $config ); + + $content = 'process(); + + $this->assertSame( 0, $file->getErrorCount() ); + $this->assertSame( 0, $file->getWarningCount() ); + $this->assertCount( 0, $file->getErrors() ); + } }