FEATURE: Add tests for MissingVendorForPluginsAndModulesSniff

* With custom vendor and default vendor.

Relates: #46
This commit is contained in:
Daniel Siepmann 2017-04-06 15:48:37 +02:00
parent 0703167315
commit 958086da24
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
8 changed files with 273 additions and 5 deletions

View file

@ -0,0 +1,27 @@
<?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.
*/
return [
'defaultVendor' => [],
'customVendor' => [
'runtime-set' => 'vendor MyCustomVendor',
],
];

View file

@ -0,0 +1,52 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -20,7 +20,7 @@
*/
TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
- $_EXTKEY,
+ 'MyCustomVendor.' . $_EXTKEY,
'name',
[
'Controller' => 'action',
@@ -28,7 +28,7 @@
);
Tx_Extbase_Utility_Extension::configurePlugin(
- $_EXTKEY,
+ 'MyCustomVendor.' . $_EXTKEY,
'name',
[
'Controller' => 'action',
@@ -36,19 +36,19 @@
);
Tx_Extbase_Utility_Extension::registerPlugin(
- $_EXTKEY,
+ 'MyCustomVendor.' . $_EXTKEY,
'name',
'title'
);
TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
- $_EXTKEY,
+ 'MyCustomVendor.' . $_EXTKEY,
'name',
'title'
);
Tx_Extbase_Utility_Extension::registerModule(
- $_EXTKEY,
+ 'MyCustomVendor.' . $_EXTKEY,
'subpart',
'key'
'',
@@ -58,7 +58,7 @@
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
- $_EXTKEY,
+ 'MyCustomVendor.' . $_EXTKEY,
'subpart',
'key'
'',

View file

@ -0,0 +1,69 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 6,
"messages": [
{
"column": 5,
"fixable": true,
"line": 23,
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
"type": "ERROR"
},
{
"column": 5,
"fixable": true,
"line": 31,
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
"type": "ERROR"
},
{
"column": 5,
"fixable": true,
"line": 39,
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
"type": "ERROR"
},
{
"column": 5,
"fixable": true,
"line": 45,
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
"type": "ERROR"
},
{
"column": 5,
"fixable": true,
"line": 51,
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
"type": "ERROR"
},
{
"column": 5,
"fixable": true,
"line": 61,
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
"severity": 5,
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
"type": "ERROR"
}
],
"warnings": 0
}
},
"totals": {
"errors": 6,
"fixable": 6,
"warnings": 0
}
}

View file

@ -1,4 +1,4 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/InputFileForIssues.php --- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php
+++ PHP_CodeSniffer +++ PHP_CodeSniffer
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
*/ */

View file

@ -0,0 +1,118 @@
<?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.
*/
TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
$_EXTKEY,
'name',
[
'Controller' => 'action',
]
);
Tx_Extbase_Utility_Extension::configurePlugin(
$_EXTKEY,
'name',
[
'Controller' => 'action',
]
);
Tx_Extbase_Utility_Extension::registerPlugin(
$_EXTKEY,
'name',
'title'
);
TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'name',
'title'
);
Tx_Extbase_Utility_Extension::registerModule(
$_EXTKEY,
'subpart',
'key'
'',
[
'Controller' => 'action',
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
$_EXTKEY,
'subpart',
'key'
'',
[
'Controller' => 'action',
]
);
// Already vendor exists
TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Vendor.' . $_EXTKEY,
'name',
[
'Controller' => 'action',
]
);
Tx_Extbase_Utility_Extension::configurePlugin(
'Vendor.' . $_EXTKEY,
'name',
[
'Controller' => 'action',
]
);
Tx_Extbase_Utility_Extension::registerPlugin(
'Vendor.' . $_EXTKEY,
'name',
'title'
);
TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Vendor.' . $_EXTKEY,
'name',
'title'
);
Tx_Extbase_Utility_Extension::registerModule(
'Vendor.' . $_EXTKEY,
'subpart',
'key'
'',
[
'Controller' => 'action',
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'Vendor.' . $_EXTKEY,
'subpart',
'key'
'',
[
'Controller' => 'action',
]
);

View file

@ -135,10 +135,12 @@ class SniffsTest extends TestCase
*/ */
protected function getExpectedJsonOutput(SplFileInfo $folder) protected function getExpectedJsonOutput(SplFileInfo $folder)
{ {
return json_decode( $file = $folder->getPathname() . DIRECTORY_SEPARATOR . 'Expected.json';
file_get_contents($folder->getRealPath() . DIRECTORY_SEPARATOR . 'Expected.json'), if (!is_file($file)) {
true throw new \Exception('Could not load file: ' . $file, 1491486050);
); }
return json_decode(file_get_contents($file), true);
} }
/** /**