From ea0dc99e14c2991091e4b0187b829f11ccc743fa Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 2 May 2017 15:05:01 +0200 Subject: [PATCH] TASK: Use test class for each sniff. * Allow executing tests for single sniff through phpunit '--filter'. * Provide structure to add further tests for a single sniff. * Make output more clear, which sniff was tested. --- .../Typo3Update/Sniffs/Classname.php | 28 +++++++++++++++++++ .../Sniffs/Classname/InheritanceSniffTest.php | 28 +++++++++++++++++++ .../Classname/InlineCommentSniffTest.php | 28 +++++++++++++++++++ .../Sniffs/Classname/InstanceofSniffTest.php | 28 +++++++++++++++++++ ...InstantiationWithMakeInstanceSniffTest.php | 28 +++++++++++++++++++ .../InstantiationWithNewSniffTest.php | 28 +++++++++++++++++++ ...nstantiationWithObjectManagerSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Classname/IsACallSniffTest.php | 28 +++++++++++++++++++ .../Classname/PhpDocCommentSniffTest.php | 28 +++++++++++++++++++ .../Sniffs/Classname/StaticCallSniffTest.php | 28 +++++++++++++++++++ .../TypeHintCatchExceptionSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Classname/TypeHintSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Classname/UseSniffTest.php | 28 +++++++++++++++++++ .../Deprecated/AjaxRegistrationTest.php | 28 +++++++++++++++++++ .../MissingNamespaceSniffTest.php | 28 +++++++++++++++++++ ...ingVendorForPluginsAndModulesSniffTest.php | 28 +++++++++++++++++++ .../Removed/GenericConstantUsageSniffTest.php | 28 +++++++++++++++++++ .../Removed/GenericFunctionCallSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Removed/TypoScriptSniffTest.php | 28 +++++++++++++++++++ tests/SniffsTest.php | 24 +++++++++------- 20 files changed, 546 insertions(+), 10 deletions(-) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php create mode 100644 tests/Sniffs/Classname/InheritanceSniffTest.php create mode 100644 tests/Sniffs/Classname/InlineCommentSniffTest.php create mode 100644 tests/Sniffs/Classname/InstanceofSniffTest.php create mode 100644 tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php create mode 100644 tests/Sniffs/Classname/InstantiationWithNewSniffTest.php create mode 100644 tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php create mode 100644 tests/Sniffs/Classname/IsACallSniffTest.php create mode 100644 tests/Sniffs/Classname/PhpDocCommentSniffTest.php create mode 100644 tests/Sniffs/Classname/StaticCallSniffTest.php create mode 100644 tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php create mode 100644 tests/Sniffs/Classname/TypeHintSniffTest.php create mode 100644 tests/Sniffs/Classname/UseSniffTest.php create mode 100644 tests/Sniffs/Deprecated/AjaxRegistrationTest.php create mode 100644 tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php create mode 100644 tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php create mode 100644 tests/Sniffs/Removed/GenericConstantUsageSniffTest.php create mode 100644 tests/Sniffs/Removed/GenericFunctionCallSniffTest.php create mode 100644 tests/Sniffs/Removed/TypoScriptSniffTest.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php new file mode 100644 index 0000000..ca3784e --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InlineCommentSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InheritanceSniffTest.php b/tests/Sniffs/Classname/InheritanceSniffTest.php new file mode 100644 index 0000000..56c8bcb --- /dev/null +++ b/tests/Sniffs/Classname/InheritanceSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InheritanceSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InlineCommentSniffTest.php b/tests/Sniffs/Classname/InlineCommentSniffTest.php new file mode 100644 index 0000000..ca3784e --- /dev/null +++ b/tests/Sniffs/Classname/InlineCommentSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InlineCommentSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstanceofSniffTest.php b/tests/Sniffs/Classname/InstanceofSniffTest.php new file mode 100644 index 0000000..49f9210 --- /dev/null +++ b/tests/Sniffs/Classname/InstanceofSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstanceofSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php b/tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php new file mode 100644 index 0000000..a54ab8f --- /dev/null +++ b/tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstantiationWithMakeInstanceSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstantiationWithNewSniffTest.php b/tests/Sniffs/Classname/InstantiationWithNewSniffTest.php new file mode 100644 index 0000000..3c07834 --- /dev/null +++ b/tests/Sniffs/Classname/InstantiationWithNewSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstantiationWithNewSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php b/tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php new file mode 100644 index 0000000..c2348bf --- /dev/null +++ b/tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstantiationWithObjectManagerSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/IsACallSniffTest.php b/tests/Sniffs/Classname/IsACallSniffTest.php new file mode 100644 index 0000000..6930ddf --- /dev/null +++ b/tests/Sniffs/Classname/IsACallSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class IsACallSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/PhpDocCommentSniffTest.php b/tests/Sniffs/Classname/PhpDocCommentSniffTest.php new file mode 100644 index 0000000..fb7fa8c --- /dev/null +++ b/tests/Sniffs/Classname/PhpDocCommentSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class PhpDocCommentSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/StaticCallSniffTest.php b/tests/Sniffs/Classname/StaticCallSniffTest.php new file mode 100644 index 0000000..e3b5faa --- /dev/null +++ b/tests/Sniffs/Classname/StaticCallSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class StaticCallSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php b/tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php new file mode 100644 index 0000000..a7d14b9 --- /dev/null +++ b/tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class TypeHintCatchExceptionSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/TypeHintSniffTest.php b/tests/Sniffs/Classname/TypeHintSniffTest.php new file mode 100644 index 0000000..e8c1637 --- /dev/null +++ b/tests/Sniffs/Classname/TypeHintSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class TypeHintSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/UseSniffTest.php b/tests/Sniffs/Classname/UseSniffTest.php new file mode 100644 index 0000000..ee03896 --- /dev/null +++ b/tests/Sniffs/Classname/UseSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class UseSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Deprecated/AjaxRegistrationTest.php b/tests/Sniffs/Deprecated/AjaxRegistrationTest.php new file mode 100644 index 0000000..b67c1ec --- /dev/null +++ b/tests/Sniffs/Deprecated/AjaxRegistrationTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class AjaxRegistrationSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php b/tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php new file mode 100644 index 0000000..07239dc --- /dev/null +++ b/tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class MissingNamespaceSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php b/tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php new file mode 100644 index 0000000..d73ca67 --- /dev/null +++ b/tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class MissingVendorForPluginsAndModulesSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Removed/GenericConstantUsageSniffTest.php b/tests/Sniffs/Removed/GenericConstantUsageSniffTest.php new file mode 100644 index 0000000..c955042 --- /dev/null +++ b/tests/Sniffs/Removed/GenericConstantUsageSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class GenericConstantUsageSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Removed/GenericFunctionCallSniffTest.php b/tests/Sniffs/Removed/GenericFunctionCallSniffTest.php new file mode 100644 index 0000000..a0176b8 --- /dev/null +++ b/tests/Sniffs/Removed/GenericFunctionCallSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class GenericFunctionCallSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Removed/TypoScriptSniffTest.php b/tests/Sniffs/Removed/TypoScriptSniffTest.php new file mode 100644 index 0000000..f7f91cc --- /dev/null +++ b/tests/Sniffs/Removed/TypoScriptSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class TypoScriptSniffTest extends SniffsTest +{ +} diff --git a/tests/SniffsTest.php b/tests/SniffsTest.php index 9f7a3b9..39f5ac4 100644 --- a/tests/SniffsTest.php +++ b/tests/SniffsTest.php @@ -29,7 +29,7 @@ use Symfony\Component\Finder\Finder; * * To add a test, just create the necessary fixture folder structure with files. */ -class SniffsTest extends TestCase +abstract class SniffsTest extends TestCase { /** * Get all fixtures for sniffs. @@ -61,16 +61,20 @@ class SniffsTest extends TestCase public function getSniffs() { $sniffs = []; - $finder = new Finder(); - $finder->in( - __DIR__ - . DIRECTORY_SEPARATOR . 'Fixtures' - . DIRECTORY_SEPARATOR . 'Standards' - . DIRECTORY_SEPARATOR . 'Typo3Update' - . DIRECTORY_SEPARATOR . 'Sniffs' - ); - foreach ($finder->directories()->name('*Sniff') as $folder) { + $classnameParts = array_slice(explode('\\', get_class($this)), 3); + $lastIndex = count($classnameParts) - 1; + $classnameParts[$lastIndex] = substr($classnameParts[$lastIndex], 0, -4); + $folderName = array_pop($classnameParts); + $folder = array_merge([ + __DIR__, + 'Fixtures', 'Standards', 'Typo3Update', 'Sniffs', + ], $classnameParts); + + $finder = new Finder(); + $finder->in(implode(DIRECTORY_SEPARATOR, $folder)); + + foreach ($finder->directories()->name($folderName) as $folder) { $sniff = [ $folder, [],