From a78d94ab136bd190fdcf8563e5c65dbb05e35990 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 6 Apr 2017 11:44:15 +0200 Subject: [PATCH] WIP|FEATURE: Add further tests * Add new tests and improve existing Relates: #46 --- phpunit.xml.dist | 4 ++ .../DocCommentSniff/Expected.diff | 14 ++++- .../DocCommentSniff/Expected.json | 28 ++++++++-- .../DocCommentSniff/InputFileForIssues.php | 8 +++ .../InheritanceSniff/Expected.diff | 21 ++++++++ .../InlineCommentSniff/Expected.diff | 24 +++++++++ .../InlineCommentSniff/Expected.json | 51 +++++++++++++++++++ .../InlineCommentSniff/InputFileForIssues.php | 38 ++++++++++++++ 8 files changed, 182 insertions(+), 6 deletions(-) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.diff create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.diff create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c20385f..a507cf9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,7 +6,11 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" + stopOnError="false" stopOnFailure="false" + stopOnIncomplete="false" + stopOnSkipped="false" + stopOnRisky="false" syntaxCheck="false"> diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.diff index aa7add2..f6d97a5 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.diff @@ -1,8 +1,15 @@ --- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php +++ PHP_CodeSniffer -@@ -22,9 +22,9 @@ +@@ -22,19 +22,19 @@ class InputFileForIssues { + /** +- * @var Tx_Extbase_Domain_Repository_CategoryRepository ++ * @var \TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository + * @inject + */ + protected $someVar; + /** - * @param t3lib_div + * @param \TYPO3\CMS\Core\Utility\GeneralUtility @@ -12,3 +19,8 @@ */ public function doSomething($something) { +- /** @var t3lib_div $variable */ // This is supported as this is a phpdoc. ++ /** @var \TYPO3\CMS\Core\Utility\GeneralUtility $variable */ // This is supported as this is a phpdoc. + /** @var $variable t3lib_div */ // This is not supported! Use inline comments instead. + } + } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.json index b70120f..6df46f0 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.json @@ -1,12 +1,21 @@ { "files": { "InputFileForIssues.php": { - "errors": 2, + "errors": 4, "messages": [ + { + "column": 13, + "fixable": true, + "line": 25, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Repository_CategoryRepository\", use \"TYPO3\\CMS\\Extbase\\Domain\\Repository\\CategoryRepository\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", + "type": "ERROR" + }, { "column": 15, "fixable": true, - "line": 25, + "line": 31, "message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead", "severity": 5, "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", @@ -15,19 +24,28 @@ { "column": 16, "fixable": true, - "line": 27, + "line": 33, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead", "severity": 5, "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", "type": "ERROR" + }, + { + "column": 18, + "fixable": true, + "line": 37, + "message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", + "type": "ERROR" } ], "warnings": 0 } }, "totals": { - "errors": 2, - "fixable": 2, + "errors": 4, + "fixable": 4, "warnings": 0 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php index bcee6c5..92acefb 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php @@ -21,6 +21,12 @@ class InputFileForIssues { + /** + * @var Tx_Extbase_Domain_Repository_CategoryRepository + * @inject + */ + protected $someVar; + /** * @param t3lib_div * @@ -28,5 +34,7 @@ class InputFileForIssues */ public function doSomething($something) { + /** @var t3lib_div $variable */ // This is supported as this is a phpdoc. + /** @var $variable t3lib_div */ // This is not supported! Use inline comments instead. } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.diff new file mode 100644 index 0000000..410f7f9 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.diff @@ -0,0 +1,21 @@ +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/InputFileForIssues.php ++++ PHP_CodeSniffer +@@ -19,14 +19,14 @@ + * 02110-1301, USA. + */ + +-class InputFileForIssues extends Tx_Extbase_Configuration_Configurationmanager implements t3lib_Singleton, Tx_Extbase_Core_BootstrapInterface ++class InputFileForIssues extends \TYPO3\CMS\Extbase\Configuration\ConfigurationManager implements \TYPO3\CMS\Core\SingletonInterface, \TYPO3\CMS\Extbase\Core\BootstrapInterface + { + + } + +-class InputFileForIssues extends Tx_Extbase_Configuration_Configurationmanager implements +- t3lib_Singleton, +- Tx_Extbase_Core_BootstrapInterface ++class InputFileForIssues extends \TYPO3\CMS\Extbase\Configuration\ConfigurationManager implements ++ \TYPO3\CMS\Core\SingletonInterface, ++ \TYPO3\CMS\Extbase\Core\BootstrapInterface + { + + } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.diff new file mode 100644 index 0000000..09e3e30 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.diff @@ -0,0 +1,24 @@ +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php ++++ PHP_CodeSniffer +@@ -23,16 +23,14 @@ + { + public function something() + { +- /* @var $variable Tx_Extbase_Command_HelpCommandController */ ++ /* @var $variable \TYPO3\CMS\Extbase\Command\HelpCommandController */ + $variable; + +- // @var $variable Tx_Extbase_Command_HelpCommandController ++ // @var $variable \TYPO3\CMS\Extbase\Command\HelpCommandController + $variable; + +- /* @var Tx_Extbase_Command_HelpCommandController $variable */ ++ /* @var \TYPO3\CMS\Extbase\Command\HelpCommandController $variable */ + $variable; + +- // @var Tx_Extbase_Command_HelpCommandController $variable ++ // @var \TYPO3\CMS\Extbase\Command\HelpCommandController $variable + $variable; + } + } + diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.json new file mode 100644 index 0000000..b1c0d31 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.json @@ -0,0 +1,51 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 4, + "messages": [ + { + "column": 9, + "fixable": true, + "line": 26, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "type": "ERROR" + }, + { + "column": 9, + "fixable": true, + "line": 29, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "type": "ERROR" + }, + { + "column": 9, + "fixable": true, + "line": 32, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "type": "ERROR" + }, + { + "column": 9, + "fixable": true, + "line": 35, + "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "type": "ERROR" + } + ], + "warnings": 0 + } + }, + "totals": { + "errors": 4, + "fixable": 4, + "warnings": 0 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php new file mode 100644 index 0000000..eedd2f8 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php @@ -0,0 +1,38 @@ + + * + * 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. + */ + +class InputFileForIssues +{ + public function something() + { + /* @var $variable Tx_Extbase_Command_HelpCommandController */ + $variable; + + // @var $variable Tx_Extbase_Command_HelpCommandController + $variable; + + /* @var Tx_Extbase_Command_HelpCommandController $variable */ + $variable; + + // @var Tx_Extbase_Command_HelpCommandController $variable + $variable; + } +}