From 9a905c492a3ef2c3ded055e96e274abd2728738f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 11:56:52 +0200 Subject: [PATCH] TASK: Add missing test for GenericFunctionCallSniff Resolves: #64 --- .../GenericFunctionCallSniff/Expected.json | 60 +++++++++++++++++++ .../InputFileForIssues.php | 35 +++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json new file mode 100644 index 0000000..f2e61ab --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json @@ -0,0 +1,60 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 0, + "messages": [ + { + "column": 41, + "fixable": false, + "line": 24, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "column": 17, + "fixable": false, + "line": 26, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "column": 44, + "fixable": false, + "line": 28, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "column": 8, + "fixable": false, + "line": 31, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", + "type": "WARNING" + }, + { + "column": 17, + "fixable": false, + "line": 35, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", + "type": "WARNING" + } + ], + "warnings": 5 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 5 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php new file mode 100644 index 0000000..5f65331 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php @@ -0,0 +1,35 @@ + + * + * 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 TYPO3\CMS\Core\Utility\GeneralUtility; + +\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('some_tca_table'); +// Both works, as we check last part of class name only. +GeneralUtility::loadTCA('some_tca_table'); +// Also matches, as we don't check whole name for now, to enable the above check with imported name. +\OwnVendor\ExtName\Utility\GeneralUtility::loadTCA('some_tca_table'); + +$test = new \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController(); +$test->includeTCA(); + +$someThingElse = new \DateTime(); +// Is also detected, as we do not check type of variable. +$someThingElse->includeTCA();