FEATURE: Add tests for MissingVendorForPluginsAndModulesSniff
* With custom vendor and default vendor. Relates: #46
This commit is contained in:
parent
0703167315
commit
958086da24
8 changed files with 273 additions and 5 deletions
|
@ -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',
|
||||
],
|
||||
];
|
|
@ -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'
|
||||
'',
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
|
@ -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',
|
||||
]
|
||||
);
|
|
@ -135,10 +135,12 @@ class SniffsTest extends TestCase
|
|||
*/
|
||||
protected function getExpectedJsonOutput(SplFileInfo $folder)
|
||||
{
|
||||
return json_decode(
|
||||
file_get_contents($folder->getRealPath() . DIRECTORY_SEPARATOR . 'Expected.json'),
|
||||
true
|
||||
);
|
||||
$file = $folder->getPathname() . DIRECTORY_SEPARATOR . 'Expected.json';
|
||||
if (!is_file($file)) {
|
||||
throw new \Exception('Could not load file: ' . $file, 1491486050);
|
||||
}
|
||||
|
||||
return json_decode(file_get_contents($file), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue