Skip to content

Commit

Permalink
Unit tests: add @Covers annotation to all utility method tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Dec 9, 2023
1 parent 40a4bd9 commit 31eb80f
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 6 deletions.
5 changes: 5 additions & 0 deletions tests/Core/Autoloader/DetermineLoadedClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
28 changes: 28 additions & 0 deletions tests/Core/Config/ReportWidthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -221,6 +248,7 @@ public function testReportWidthInputHandlingForAuto()
* @param int $expected Expected report width.
*
* @dataProvider dataReportWidthInputHandling
* @covers \PHP_CodeSniffer\Config::__set
*
* @return void
*/
Expand Down
5 changes: 5 additions & 0 deletions tests/Core/ErrorSuppressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
7 changes: 6 additions & 1 deletion tests/Core/File/FindEndOfStatementTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Tests for the \PHP_CodeSniffer\Files\File:findEndOfStatement method.
* Tests for the \PHP_CodeSniffer\Files\File::findEndOfStatement method.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
Expand All @@ -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
{

Expand Down
7 changes: 6 additions & 1 deletion tests/Core/File/FindExtendedClassNameTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Tests for the \PHP_CodeSniffer\Files\File:findExtendedClassName method.
* Tests for the \PHP_CodeSniffer\Files\File::findExtendedClassName method.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
Expand All @@ -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
{

Expand Down
7 changes: 6 additions & 1 deletion tests/Core/File/FindImplementedInterfaceNamesTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Tests for the \PHP_CodeSniffer\Files\File:findImplementedInterfaceNames method.
* Tests for the \PHP_CodeSniffer\Files\File::findImplementedInterfaceNames method.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
Expand All @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/File/FindStartOfStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/File/GetClassPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/File/GetMemberPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
7 changes: 6 additions & 1 deletion tests/Core/File/GetMethodParametersTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Tests for the \PHP_CodeSniffer\Files\File:getMethodParameters method.
* Tests for the \PHP_CodeSniffer\Files\File::getMethodParameters method.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
Expand All @@ -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
{

Expand Down
7 changes: 6 additions & 1 deletion tests/Core/File/GetMethodPropertiesTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Tests for the \PHP_CodeSniffer\Files\File:getMethodProperties method.
* Tests for the \PHP_CodeSniffer\Files\File::getMethodProperties method.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
Expand All @@ -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
{

Expand Down
7 changes: 6 additions & 1 deletion tests/Core/File/IsReferenceTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Tests for the \PHP_CodeSniffer\Files\File:isReference method.
* Tests for the \PHP_CodeSniffer\Files\File::isReference method.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
Expand All @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/Filters/Filter/AcceptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/IsCamelCapsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/Ruleset/RuleInclusionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
5 changes: 5 additions & 0 deletions tests/Core/Sniffs/AbstractArraySniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down
3 changes: 3 additions & 0 deletions tests/Core/Tokenizer/DefaultKeywordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 31eb80f

Please sign in to comment.