Skip to content

Commit

Permalink
Tests/Ruleset/fixtures: move existing fixtures to subdirectory
Browse files Browse the repository at this point in the history
For some new tests, some test fixtures outside a standard directory structure and/or in a seperate standard directory structure are needed.

This commit moves the pre-existing sniff test fixtures to a subdirectory to allow for the upcoming additional test fixtures.

Includes updating the standard/ruleset to have a namespace prefix ("Fixtures"), so that aspect of things can now also be tested.
  • Loading branch information
jrfnl committed Nov 21, 2024
1 parent 9f81294 commit 80b5656
Show file tree
Hide file tree
Showing 31 changed files with 84 additions and 84 deletions.
22 changes: 11 additions & 11 deletions tests/Core/Ruleset/ExplainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,17 @@ public function testExplainWithDeprecatedSniffs()
$expected = PHP_EOL;
$expected .= 'The ShowSniffDeprecationsTest standard contains 9 sniffs'.PHP_EOL.PHP_EOL;

$expected .= 'Fixtures (9 sniffs)'.PHP_EOL;
$expected .= '-------------------'.PHP_EOL;
$expected .= ' Fixtures.Deprecated.WithLongReplacement *'.PHP_EOL;
$expected .= ' Fixtures.Deprecated.WithoutReplacement *'.PHP_EOL;
$expected .= ' Fixtures.Deprecated.WithReplacement *'.PHP_EOL;
$expected .= ' Fixtures.Deprecated.WithReplacementContainingLinuxNewlines *'.PHP_EOL;
$expected .= ' Fixtures.Deprecated.WithReplacementContainingNewlines *'.PHP_EOL;
$expected .= ' Fixtures.SetProperty.AllowedAsDeclared'.PHP_EOL;
$expected .= ' Fixtures.SetProperty.AllowedViaMagicMethod'.PHP_EOL;
$expected .= ' Fixtures.SetProperty.AllowedViaStdClass'.PHP_EOL;
$expected .= ' Fixtures.SetProperty.NotAllowedViaAttribute'.PHP_EOL.PHP_EOL;
$expected .= 'TestStandard (9 sniffs)'.PHP_EOL;
$expected .= '-----------------------'.PHP_EOL;
$expected .= ' TestStandard.Deprecated.WithLongReplacement *'.PHP_EOL;
$expected .= ' TestStandard.Deprecated.WithoutReplacement *'.PHP_EOL;
$expected .= ' TestStandard.Deprecated.WithReplacement *'.PHP_EOL;
$expected .= ' TestStandard.Deprecated.WithReplacementContainingLinuxNewlines *'.PHP_EOL;
$expected .= ' TestStandard.Deprecated.WithReplacementContainingNewlines *'.PHP_EOL;
$expected .= ' TestStandard.SetProperty.AllowedAsDeclared'.PHP_EOL;
$expected .= ' TestStandard.SetProperty.AllowedViaMagicMethod'.PHP_EOL;
$expected .= ' TestStandard.SetProperty.AllowedViaStdClass'.PHP_EOL;
$expected .= ' TestStandard.SetProperty.NotAllowedViaAttribute'.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
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\Deprecated;
namespace Fixtures\TestStandard\Sniffs\Deprecated;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\Deprecated;
namespace Fixtures\TestStandard\Sniffs\Deprecated;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\Deprecated;
namespace Fixtures\TestStandard\Sniffs\Deprecated;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\Deprecated;
namespace Fixtures\TestStandard\Sniffs\Deprecated;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\Deprecated;
namespace Fixtures\TestStandard\Sniffs\Deprecated;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\DeprecatedInvalid;
namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\DeprecatedInvalid;
namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\DeprecatedInvalid;
namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\DeprecatedInvalid;
namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SniffDeprecationTest
*/

namespace Fixtures\Sniffs\DeprecatedInvalid;
namespace Fixtures\TestStandard\Sniffs\DeprecatedInvalid;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest
*/

namespace Fixtures\Sniffs\SetProperty;
namespace Fixtures\TestStandard\Sniffs\SetProperty;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest
*/

namespace Fixtures\Sniffs\SetProperty;
namespace Fixtures\TestStandard\Sniffs\SetProperty;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest
*/

namespace Fixtures\Sniffs\SetProperty;
namespace Fixtures\TestStandard\Sniffs\SetProperty;

use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @see \PHP_CodeSniffer\Tests\Core\Ruleset\SetSniffPropertyTest
*/

namespace Fixtures\Sniffs\SetProperty;
namespace Fixtures\TestStandard\Sniffs\SetProperty;

use AllowDynamicProperties;
use PHP_CodeSniffer\Files\File;
Expand Down
4 changes: 4 additions & 0 deletions tests/Core/Ruleset/Fixtures/TestStandard/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="TestStandard" namespace="Fixtures\TestStandard" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

</ruleset>
4 changes: 0 additions & 4 deletions tests/Core/Ruleset/Fixtures/ruleset.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Core/Ruleset/SetPropertyAllowedAsDeclaredTest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SetSniffPropertyTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

<rule ref="./tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedAsDeclaredSniff.php">
<rule ref="./tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php">
<properties>
<property name="arbitrarystring" value="arbitraryvalue"/>
<property name="arbitraryarray" type="array">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SetSniffPropertyTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

<rule ref="./tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php">
<rule ref="./tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php">
<properties>
<property name="arbitrarystring" value="arbitraryvalue"/>
<property name="arbitraryarray" type="array">
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Ruleset/SetPropertyAllowedViaStdClassTest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SetSniffPropertyTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

<rule ref="./tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/AllowedViaStdClassSniff.php">
<rule ref="./tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php">
<properties>
<property name="arbitrarystring" value="arbitraryvalue"/>
<property name="arbitraryarray" type="array">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SetSniffPropertyTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

<rule ref="./tests/Core/Ruleset/Fixtures/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php">
<rule ref="./tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php">
<properties>
<property name="arbitrarystring" value="arbitraryvalue"/>
</properties>
Expand Down
16 changes: 8 additions & 8 deletions tests/Core/Ruleset/SetSniffPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ final class SetSniffPropertyTest extends TestCase
*/
public function testSniffPropertiesGetSetWhenAllowed($name)
{
$sniffCode = "Fixtures.SetProperty.{$name}";
$sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff';
$sniffCode = "TestStandard.SetProperty.{$name}";
$sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff';
$properties = [
'arbitrarystring' => 'arbitraryvalue',
'arbitraryarray' => [
Expand Down Expand Up @@ -163,7 +163,7 @@ public function testSetPropertyThrowsErrorOnInvalidProperty()
public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute()
{
$exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException';
$exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff Fixtures.SetProperty.NotAllowedViaAttribute';
$exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff TestStandard.SetProperty.NotAllowedViaAttribute';
if (method_exists($this, 'expectException') === true) {
$this->expectException($exceptionClass);
$this->expectExceptionMessage($exceptionMsg);
Expand Down Expand Up @@ -225,8 +225,8 @@ public function testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCateg
public function testDirectCallWithNewArrayFormatSetsProperty()
{
$name = 'AllowedAsDeclared';
$sniffCode = "Fixtures.SetProperty.{$name}";
$sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff';
$sniffCode = "TestStandard.SetProperty.{$name}";
$sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff';

// Set up the ruleset.
$standard = __DIR__."/SetProperty{$name}Test.xml";
Expand Down Expand Up @@ -276,8 +276,8 @@ public function testDirectCallWithNewArrayFormatSetsProperty()
public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue)
{
$name = 'AllowedAsDeclared';
$sniffCode = "Fixtures.SetProperty.{$name}";
$sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff';
$sniffCode = "TestStandard.SetProperty.{$name}";
$sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff';

// Set up the ruleset.
$standard = __DIR__."/SetProperty{$name}Test.xml";
Expand Down Expand Up @@ -383,7 +383,7 @@ public function testDirectCallWithOldArrayFormatThrowsDeprecationNotice()
}

$name = 'AllowedAsDeclared';
$sniffClass = 'Fixtures\Sniffs\SetProperty\\'.$name.'Sniff';
$sniffClass = 'Fixtures\TestStandard\Sniffs\SetProperty\\'.$name.'Sniff';

// Set up the ruleset.
$standard = __DIR__."/SetProperty{$name}Test.xml";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ShowSniffDeprecationsTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

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

<rule ref="Fixtures.DeprecatedInvalid.EmptyDeprecationVersion"/>
<rule ref="TestStandard.DeprecatedInvalid.EmptyDeprecationVersion"/>

</ruleset>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ShowSniffDeprecationsTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

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

<rule ref="Fixtures.DeprecatedInvalid.EmptyRemovalVersion"/>
<rule ref="TestStandard.DeprecatedInvalid.EmptyRemovalVersion"/>

</ruleset>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ShowSniffDeprecationsTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

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

<rule ref="Fixtures.DeprecatedInvalid.InvalidDeprecationMessage"/>
<rule ref="TestStandard.DeprecatedInvalid.InvalidDeprecationMessage"/>

</ruleset>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ShowSniffDeprecationsTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

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

<rule ref="Fixtures.DeprecatedInvalid.InvalidDeprecationVersion"/>
<rule ref="TestStandard.DeprecatedInvalid.InvalidDeprecationVersion"/>

</ruleset>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ShowSniffDeprecationsTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

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

<rule ref="Fixtures.DeprecatedInvalid.InvalidRemovalVersion"/>
<rule ref="TestStandard.DeprecatedInvalid.InvalidRemovalVersion"/>

</ruleset>
6 changes: 3 additions & 3 deletions tests/Core/Ruleset/ShowSniffDeprecationsOrderTest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ShowSniffDeprecationsTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

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

<!-- This list is non-alphabetic on purpose. The display order is what is being tested. -->
<rule ref="Fixtures.Deprecated.WithReplacement"/>
<rule ref="Fixtures.Deprecated.WithoutReplacement"/>
<rule ref="TestStandard.Deprecated.WithReplacement"/>
<rule ref="TestStandard.Deprecated.WithoutReplacement"/>

</ruleset>
4 changes: 2 additions & 2 deletions tests/Core/Ruleset/ShowSniffDeprecationsReportWidthTest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ShowSniffDeprecationsTest" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

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

<rule ref="Fixtures.Deprecated.WithLongReplacement"/>
<rule ref="TestStandard.Deprecated.WithLongReplacement"/>

</ruleset>
Loading

0 comments on commit 80b5656

Please sign in to comment.