From 31eb80fb64a2ce0a7ae41121b51f94d74af90d3f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 3 Mar 2019 19:52:55 +0100 Subject: [PATCH] Unit tests: add @covers annotation to all utility method tests --- .../Autoloader/DetermineLoadedClassTest.php | 5 ++++ tests/Core/Config/ReportWidthTest.php | 28 +++++++++++++++++++ tests/Core/ErrorSuppressionTest.php | 5 ++++ tests/Core/File/FindEndOfStatementTest.php | 7 ++++- tests/Core/File/FindExtendedClassNameTest.php | 7 ++++- .../FindImplementedInterfaceNamesTest.php | 7 ++++- tests/Core/File/FindStartOfStatementTest.php | 5 ++++ tests/Core/File/GetClassPropertiesTest.php | 5 ++++ tests/Core/File/GetMemberPropertiesTest.php | 5 ++++ tests/Core/File/GetMethodParametersTest.php | 7 ++++- tests/Core/File/GetMethodPropertiesTest.php | 7 ++++- tests/Core/File/IsReferenceTest.php | 7 ++++- tests/Core/Filters/Filter/AcceptTest.php | 5 ++++ tests/Core/IsCamelCapsTest.php | 5 ++++ .../RuleInclusionAbsoluteLinuxTest.php | 5 ++++ .../RuleInclusionAbsoluteWindowsTest.php | 5 ++++ tests/Core/Ruleset/RuleInclusionTest.php | 5 ++++ tests/Core/Sniffs/AbstractArraySniffTest.php | 5 ++++ tests/Core/Tokenizer/DefaultKeywordTest.php | 3 ++ 19 files changed, 122 insertions(+), 6 deletions(-) diff --git a/tests/Core/Autoloader/DetermineLoadedClassTest.php b/tests/Core/Autoloader/DetermineLoadedClassTest.php index e4a27258a5..44a4cef079 100644 --- a/tests/Core/Autoloader/DetermineLoadedClassTest.php +++ b/tests/Core/Autoloader/DetermineLoadedClassTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Autoload; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Autoload::determineLoadedClass method. + * + * @covers \PHP_CodeSniffer\Autoload::determineLoadedClass + */ class DetermineLoadedClassTest extends TestCase { diff --git a/tests/Core/Config/ReportWidthTest.php b/tests/Core/Config/ReportWidthTest.php index 275a70cab1..c46dc22e6b 100644 --- a/tests/Core/Config/ReportWidthTest.php +++ b/tests/Core/Config/ReportWidthTest.php @@ -13,6 +13,11 @@ use PHPUnit\Framework\TestCase; use ReflectionProperty; +/** + * Tests for the \PHP_CodeSniffer\Config reportWidth value. + * + * @covers \PHP_CodeSniffer\Config::__get + */ class ReportWidthTest extends TestCase { @@ -76,6 +81,9 @@ public static function resetConfigToDefaults() /** * Test that report width without overrules will always be set to a non-0 positive integer. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::restoreDefaults + * * @return void */ public function testReportWidthDefault() @@ -92,6 +100,9 @@ public function testReportWidthDefault() /** * Test that the report width will be set to a non-0 positive integer when not found in the CodeSniffer.conf file. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::restoreDefaults + * * @return void */ public function testReportWidthWillBeSetFromAutoWhenNotFoundInConfFile() @@ -115,6 +126,10 @@ public function testReportWidthWillBeSetFromAutoWhenNotFoundInConfFile() /** * Test that the report width will be set correctly when found in the CodeSniffer.conf file. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::getConfigData + * @covers \PHP_CodeSniffer\Config::restoreDefaults + * * @return void */ public function testReportWidthCanBeSetFromConfFile() @@ -135,6 +150,9 @@ public function testReportWidthCanBeSetFromConfFile() /** * Test that the report width will be set correctly when passed as a CLI argument. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::processLongArgument + * * @return void */ public function testReportWidthCanBeSetFromCLI() @@ -153,6 +171,9 @@ public function testReportWidthCanBeSetFromCLI() /** * Test that the report width will be set correctly when multiple report widths are passed on the CLI. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::processLongArgument + * * @return void */ public function testReportWidthWhenSetFromCLIFirstValuePrevails() @@ -172,6 +193,10 @@ public function testReportWidthWhenSetFromCLIFirstValuePrevails() /** * Test that a report width passed as a CLI argument will overrule a report width set in a CodeSniffer.conf file. * + * @covers \PHP_CodeSniffer\Config::__set + * @covers \PHP_CodeSniffer\Config::processLongArgument + * @covers \PHP_CodeSniffer\Config::getConfigData + * * @return void */ public function testReportWidthSetFromCLIOverrulesConfFile() @@ -200,6 +225,8 @@ public function testReportWidthSetFromCLIOverrulesConfFile() /** * Test that the report width will be set to a non-0 positive integer when set to "auto". * + * @covers \PHP_CodeSniffer\Config::__set + * * @return void */ public function testReportWidthInputHandlingForAuto() @@ -221,6 +248,7 @@ public function testReportWidthInputHandlingForAuto() * @param int $expected Expected report width. * * @dataProvider dataReportWidthInputHandling + * @covers \PHP_CodeSniffer\Config::__set * * @return void */ diff --git a/tests/Core/ErrorSuppressionTest.php b/tests/Core/ErrorSuppressionTest.php index 3c99f5f999..7fc28d0e2e 100644 --- a/tests/Core/ErrorSuppressionTest.php +++ b/tests/Core/ErrorSuppressionTest.php @@ -14,6 +14,11 @@ use PHP_CodeSniffer\Files\DummyFile; use PHPUnit\Framework\TestCase; +/** + * Tests for PHP_CodeSniffer error suppression tags. + * + * @coversNothing + */ class ErrorSuppressionTest extends TestCase { diff --git a/tests/Core/File/FindEndOfStatementTest.php b/tests/Core/File/FindEndOfStatementTest.php index 4f9b3b0604..6296db6756 100644 --- a/tests/Core/File/FindEndOfStatementTest.php +++ b/tests/Core/File/FindEndOfStatementTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::findEndOfStatement method. + * + * @covers \PHP_CodeSniffer\Files\File::findEndOfStatement + */ class FindEndOfStatementTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindExtendedClassNameTest.php b/tests/Core/File/FindExtendedClassNameTest.php index a82e1e590e..c54b9cc120 100644 --- a/tests/Core/File/FindExtendedClassNameTest.php +++ b/tests/Core/File/FindExtendedClassNameTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::findExtendedClassName method. + * + * @covers \PHP_CodeSniffer\Files\File::findExtendedClassName + */ class FindExtendedClassNameTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindImplementedInterfaceNamesTest.php b/tests/Core/File/FindImplementedInterfaceNamesTest.php index 4e2885f1ca..6e04805efb 100644 --- a/tests/Core/File/FindImplementedInterfaceNamesTest.php +++ b/tests/Core/File/FindImplementedInterfaceNamesTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames method. + * + * @covers \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames + */ class FindImplementedInterfaceNamesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/FindStartOfStatementTest.php b/tests/Core/File/FindStartOfStatementTest.php index dabb706c78..25b7f6aa73 100644 --- a/tests/Core/File/FindStartOfStatementTest.php +++ b/tests/Core/File/FindStartOfStatementTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File:findStartOfStatement method. + * + * @covers \PHP_CodeSniffer\Files\File::findStartOfStatement + */ class FindStartOfStatementTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetClassPropertiesTest.php b/tests/Core/File/GetClassPropertiesTest.php index c5fe70b690..d7dfce8585 100644 --- a/tests/Core/File/GetClassPropertiesTest.php +++ b/tests/Core/File/GetClassPropertiesTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File:getClassProperties method. + * + * @covers \PHP_CodeSniffer\Files\File::getClassProperties + */ class GetClassPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMemberPropertiesTest.php b/tests/Core/File/GetMemberPropertiesTest.php index 272f3b2ef1..4ef08b168b 100644 --- a/tests/Core/File/GetMemberPropertiesTest.php +++ b/tests/Core/File/GetMemberPropertiesTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMemberProperties method. + * + * @covers \PHP_CodeSniffer\Files\File::getMemberProperties + */ class GetMemberPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodParametersTest.php b/tests/Core/File/GetMethodParametersTest.php index fd4742aea7..6f9b2adf9e 100644 --- a/tests/Core/File/GetMethodParametersTest.php +++ b/tests/Core/File/GetMethodParametersTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMethodParameters method. + * + * @covers \PHP_CodeSniffer\Files\File::getMethodParameters + */ class GetMethodParametersTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/GetMethodPropertiesTest.php b/tests/Core/File/GetMethodPropertiesTest.php index ab8fe66f78..e971611ea4 100644 --- a/tests/Core/File/GetMethodPropertiesTest.php +++ b/tests/Core/File/GetMethodPropertiesTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::getMethodProperties method. + * + * @covers \PHP_CodeSniffer\Files\File::getMethodProperties + */ class GetMethodPropertiesTest extends AbstractMethodUnitTest { diff --git a/tests/Core/File/IsReferenceTest.php b/tests/Core/File/IsReferenceTest.php index d40bee98ef..5372bf163c 100644 --- a/tests/Core/File/IsReferenceTest.php +++ b/tests/Core/File/IsReferenceTest.php @@ -1,6 +1,6 @@ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Files\File::isReference method. + * + * @covers \PHP_CodeSniffer\Files\File::isReference + */ class IsReferenceTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 26e589e010..53d4ba6441 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -15,6 +15,11 @@ use PHP_CodeSniffer\Ruleset; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Filters\Filter::accept method. + * + * @covers \PHP_CodeSniffer\Filters\Filter + */ class AcceptTest extends TestCase { diff --git a/tests/Core/IsCamelCapsTest.php b/tests/Core/IsCamelCapsTest.php index 94766260ff..9a1a737384 100644 --- a/tests/Core/IsCamelCapsTest.php +++ b/tests/Core/IsCamelCapsTest.php @@ -12,6 +12,11 @@ use PHP_CodeSniffer\Util\Common; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Util\Common::isCamelCaps method. + * + * @covers \PHP_CodeSniffer\Util\Common::isCamelCaps + */ class IsCamelCapsTest extends TestCase { diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php index 6e9e739a83..786cbe745a 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php @@ -13,6 +13,11 @@ use PHP_CodeSniffer\Ruleset; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Ruleset class using a Linux-style absolute path to include a sniff. + * + * @covers \PHP_CodeSniffer\Ruleset + */ class RuleInclusionAbsoluteLinuxTest extends TestCase { diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index d838e01fbc..629668c9af 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -13,6 +13,11 @@ use PHP_CodeSniffer\Ruleset; use PHPUnit\Framework\TestCase; +/** + * Tests for the \PHP_CodeSniffer\Ruleset class using a Windows-style absolute path to include a sniff. + * + * @covers \PHP_CodeSniffer\Ruleset + */ class RuleInclusionAbsoluteWindowsTest extends TestCase { diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index cab58778e5..df4a022636 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -14,6 +14,11 @@ use PHPUnit\Framework\TestCase; use ReflectionObject; +/** + * Tests for the \PHP_CodeSniffer\Ruleset class. + * + * @covers \PHP_CodeSniffer\Ruleset + */ class RuleInclusionTest extends TestCase { diff --git a/tests/Core/Sniffs/AbstractArraySniffTest.php b/tests/Core/Sniffs/AbstractArraySniffTest.php index c74513cac9..cf8a231bc0 100644 --- a/tests/Core/Sniffs/AbstractArraySniffTest.php +++ b/tests/Core/Sniffs/AbstractArraySniffTest.php @@ -11,6 +11,11 @@ use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest; +/** + * Tests for the \PHP_CodeSniffer\Sniffs\AbstractArraySniff. + * + * @covers \PHP_CodeSniffer\Sniffs\AbstractArraySniff + */ class AbstractArraySniffTest extends AbstractMethodUnitTest { diff --git a/tests/Core/Tokenizer/DefaultKeywordTest.php b/tests/Core/Tokenizer/DefaultKeywordTest.php index 9f89ce5948..c4d216dda0 100644 --- a/tests/Core/Tokenizer/DefaultKeywordTest.php +++ b/tests/Core/Tokenizer/DefaultKeywordTest.php @@ -283,6 +283,9 @@ public function dataNotDefaultKeyword() * * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/3326 * + * @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize + * @covers PHP_CodeSniffer\Tokenizers\Tokenizer::recurseScopeMap + * * @return void */ public function testIssue3326()