FEATURE: Add further tests

Relates: #46
This commit is contained in:
Daniel Siepmann 2017-04-06 12:11:31 +02:00
parent d7911cccee
commit af74a5db21
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
12 changed files with 360 additions and 0 deletions

View file

@ -0,0 +1,10 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -19,6 +19,6 @@
* 02110-1301, USA.
*/
-if ($a instanceof t3lib_Singleton) {
+if ($a instanceof \TYPO3\CMS\Core\SingletonInterface) {
// do something
}

View file

@ -0,0 +1,24 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 1,
"messages": [
{
"column": 19,
"fixable": true,
"line": 22,
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.Instanceof.legacyClassname",
"type": "ERROR"
}
],
"warnings": 0
}
},
"totals": {
"errors": 1,
"fixable": 1,
"warnings": 0
}
}

View file

@ -0,0 +1,24 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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.
*/
if ($a instanceof t3lib_Singleton) {
// do something
}

View file

@ -0,0 +1,10 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -19,6 +19,6 @@
* 02110-1301, USA.
*/
-t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController');
+t3lib_div::makeInstance('\TYPO3\CMS\Extbase\Command\HelpCommandController');
// Not handled by this sniff, but StaticCallSniff, as this uses double colon.
t3lib_div::makeInstance(Tx_Extbase_Command_HelpCommandController::class);

View file

@ -0,0 +1,24 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 1,
"messages": [
{
"column": 25,
"fixable": true,
"line": 22,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithMakeInstance.legacyClassname",
"type": "ERROR"
}
],
"warnings": 0
}
},
"totals": {
"errors": 1,
"fixable": 1,
"warnings": 0
}
}

View file

@ -0,0 +1,24 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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.
*/
t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController');
// Not handled by this sniff, but StaticCallSniff, as this uses double colon.
t3lib_div::makeInstance(Tx_Extbase_Command_HelpCommandController::class);

View file

@ -0,0 +1,22 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -19,13 +19,13 @@
* 02110-1301, USA.
*/
-new \Tx_Extbase_Command_HelpCommandController();
-new \Tx_Extbase_Command_HelpCommandController;
-(new \Tx_Extbase_Command_HelpCommandController)
+new \TYPO3\CMS\Extbase\Command\HelpCommandController();
+new \TYPO3\CMS\Extbase\Command\HelpCommandController;
+(new \TYPO3\CMS\Extbase\Command\HelpCommandController)
->doSomething()
;
-new Tx_Extbase_Command_HelpCommandController();
-new Tx_Extbase_Command_HelpCommandController;
-(new Tx_Extbase_Command_HelpCommandController)
+new \TYPO3\CMS\Extbase\Command\HelpCommandController();
+new \TYPO3\CMS\Extbase\Command\HelpCommandController;
+(new \TYPO3\CMS\Extbase\Command\HelpCommandController)
->doSomething()
;

View file

@ -0,0 +1,69 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 6,
"messages": [
{
"column": 6,
"fixable": true,
"line": 22,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
"type": "ERROR"
},
{
"column": 6,
"fixable": true,
"line": 23,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
"type": "ERROR"
},
{
"column": 7,
"fixable": true,
"line": 24,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
"type": "ERROR"
},
{
"column": 5,
"fixable": true,
"line": 27,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
"type": "ERROR"
},
{
"column": 5,
"fixable": true,
"line": 28,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
"type": "ERROR"
},
{
"column": 6,
"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.InstantiationWithNew.legacyClassname",
"type": "ERROR"
}
],
"warnings": 0
}
},
"totals": {
"errors": 6,
"fixable": 6,
"warnings": 0
}
}

View file

@ -0,0 +1,31 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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.
*/
new \Tx_Extbase_Command_HelpCommandController();
new \Tx_Extbase_Command_HelpCommandController;
(new \Tx_Extbase_Command_HelpCommandController)
->doSomething()
;
new Tx_Extbase_Command_HelpCommandController();
new Tx_Extbase_Command_HelpCommandController;
(new Tx_Extbase_Command_HelpCommandController)
->doSomething()
;

View file

@ -0,0 +1,20 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -21,13 +21,13 @@
// Not handled by this sniff, but StaticCallSniff, as this uses double colon.
$this->objectManager->get(\Tx_Extbase_Command_HelpCommandController::class);
-$this->objectManager->get('\Tx_Extbase_Command_HelpCommandController');
-$this->objectManager->get('Tx_Extbase_Command_HelpCommandController');
+$this->objectManager->get('\TYPO3\CMS\Extbase\Command\HelpCommandController');
+$this->objectManager->get('\TYPO3\CMS\Extbase\Command\HelpCommandController');
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
// Not handled by this sniff, but StaticCallSniff, as this uses double colon.
->get(\Tx_Extbase_Command_HelpCommandController::class);
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
- ->get('\Tx_Extbase_Command_HelpCommandController');
+ ->get('\TYPO3\CMS\Extbase\Command\HelpCommandController');
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
- ->get('Tx_Extbase_Command_HelpCommandController');
+ ->get('\TYPO3\CMS\Extbase\Command\HelpCommandController');

View file

@ -0,0 +1,69 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 6,
"messages": [
{
"column": 27,
"fixable": true,
"line": 24,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
"type": "ERROR"
},
{
"column": 27,
"fixable": true,
"line": 24,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
"type": "ERROR"
},
{
"column": 27,
"fixable": true,
"line": 25,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
"type": "ERROR"
},
{
"column": 11,
"fixable": true,
"line": 31,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
"type": "ERROR"
},
{
"column": 11,
"fixable": true,
"line": 31,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
"type": "ERROR"
},
{
"column": 11,
"fixable": true,
"line": 33,
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
"type": "ERROR"
}
],
"warnings": 0
}
},
"totals": {
"errors": 6,
"fixable": 6,
"warnings": 0
}
}

View file

@ -0,0 +1,33 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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.
*/
// Not handled by this sniff, but StaticCallSniff, as this uses double colon.
$this->objectManager->get(\Tx_Extbase_Command_HelpCommandController::class);
$this->objectManager->get('\Tx_Extbase_Command_HelpCommandController');
$this->objectManager->get('Tx_Extbase_Command_HelpCommandController');
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
// Not handled by this sniff, but StaticCallSniff, as this uses double colon.
->get(\Tx_Extbase_Command_HelpCommandController::class);
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
->get('\Tx_Extbase_Command_HelpCommandController');
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager)
->get('Tx_Extbase_Command_HelpCommandController');