Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruleset::populateTokenListeners(): add tests #757

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/Core/Ruleset/ExplainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public function testExplainWithDeprecatedSniffs()
$ruleset = new Ruleset($config);

$expected = PHP_EOL;
$expected .= 'The ShowSniffDeprecationsTest standard contains 10 sniffs'.PHP_EOL.PHP_EOL;
$expected .= 'The ShowSniffDeprecationsTest standard contains 11 sniffs'.PHP_EOL.PHP_EOL;

$expected .= 'TestStandard (10 sniffs)'.PHP_EOL;
$expected .= 'TestStandard (11 sniffs)'.PHP_EOL;
$expected .= '------------------------'.PHP_EOL;
$expected .= ' TestStandard.Deprecated.WithLongReplacement *'.PHP_EOL;
$expected .= ' TestStandard.Deprecated.WithoutReplacement *'.PHP_EOL;
Expand All @@ -198,7 +198,8 @@ public function testExplainWithDeprecatedSniffs()
$expected .= ' TestStandard.SetProperty.AllowedViaMagicMethod'.PHP_EOL;
$expected .= ' TestStandard.SetProperty.AllowedViaStdClass'.PHP_EOL;
$expected .= ' TestStandard.SetProperty.NotAllowedViaAttribute'.PHP_EOL;
$expected .= ' TestStandard.SetProperty.PropertyTypeHandling'.PHP_EOL.PHP_EOL;
$expected .= ' TestStandard.SetProperty.PropertyTypeHandling'.PHP_EOL;
$expected .= ' TestStandard.ValidSniffs.RegisterEmptyArray'.PHP_EOL.PHP_EOL;

$expected .= '* Sniffs marked with an asterix are deprecated.'.PHP_EOL;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Test fixture.
*
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersTest
*/

namespace Fixtures\TestStandard\Sniffs\InvalidSniffs;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;

class RegisterNoArraySniff implements Sniff
{

public function register()
{
return false;
}

public function process(File $phpcsFile, $stackPtr)
{
// Do something.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Test fixture.
*
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\PopulateTokenListenersTest
*/

namespace Fixtures\TestStandard\Sniffs\ValidSniffs;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;

class RegisterEmptyArraySniff implements Sniff
{

public function register()
{
return [];
}

public function process(File $phpcsFile, $stackPtr)
{
// Do something.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PopulateTokenListenersTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
jrfnl marked this conversation as resolved.
Show resolved Hide resolved

<config name="installed_paths" value="./tests/Core/Ruleset/Fixtures/TestStandard/"/>

<rule ref="TestStandard.InvalidSniffs.RegisterNoArray"/>

</ruleset>
Loading
Loading