mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 293913662e1372aae24a5069a753e38475116b8e
293913662e
[Performance] Only set Attribute on context inside ArrayDimFetch and ArrayItem on specific node used (#4493)
This commit is contained in:
parent
d4bf4ea4ff
commit
50d0f997c6
@ -12,6 +12,9 @@ use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Isset_;
|
||||
use PhpParser\Node\Expr\Match_;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
@ -43,6 +46,18 @@ final class ContextNodeVisitor extends NodeVisitorAbstract implements ScopeResol
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
}
|
||||
private function processInsideArrayDimFetch(ArrayDimFetch $arrayDimFetch) : void
|
||||
{
|
||||
if ($arrayDimFetch->var instanceof PropertyFetch || $arrayDimFetch->var instanceof StaticPropertyFetch) {
|
||||
$arrayDimFetch->var->setAttribute(AttributeKey::INSIDE_ARRAY_DIM_FETCH, \true);
|
||||
}
|
||||
}
|
||||
private function processInsideArrayItem(ArrayItem $arrayItem) : void
|
||||
{
|
||||
if ($arrayItem->value instanceof Match_) {
|
||||
$arrayItem->value->setAttribute(AttributeKey::INSIDE_ARRAY_ITEM, \true);
|
||||
}
|
||||
}
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if ($node instanceof For_ || $node instanceof Foreach_ || $node instanceof While_ || $node instanceof Do_) {
|
||||
@ -50,10 +65,12 @@ final class ContextNodeVisitor extends NodeVisitorAbstract implements ScopeResol
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof ArrayDimFetch) {
|
||||
$node->var->setAttribute(AttributeKey::INSIDE_ARRAY_DIM_FETCH, \true);
|
||||
$this->processInsideArrayDimFetch($node);
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof ArrayItem) {
|
||||
$node->value->setAttribute(AttributeKey::INSIDE_ARRAY_ITEM, \true);
|
||||
if ($node instanceof ArrayItem && $node->value instanceof Match_) {
|
||||
$this->processInsideArrayItem($node);
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof Isset_ || $node instanceof Unset_) {
|
||||
$this->processContextInIssetOrUnset($node);
|
||||
@ -69,12 +86,15 @@ final class ContextNodeVisitor extends NodeVisitorAbstract implements ScopeResol
|
||||
}
|
||||
if ($node instanceof Return_ && $node->expr instanceof Expr) {
|
||||
$node->expr->setAttribute(AttributeKey::IS_RETURN_EXPR, \true);
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof Arg) {
|
||||
$node->value->setAttribute(AttributeKey::IS_ARG_VALUE, \true);
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof Param) {
|
||||
$node->var->setAttribute(AttributeKey::IS_PARAM_VAR, \true);
|
||||
return null;
|
||||
}
|
||||
$this->processContextInClass($node);
|
||||
return null;
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '706be908c5d96381785128ad94cc608814aa0f35';
|
||||
public const PACKAGE_VERSION = '293913662e1372aae24a5069a753e38475116b8e';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-07-12 12:40:44';
|
||||
public const RELEASE_DATE = '2023-07-12 21:16:11';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c::getLoader();
|
||||
return ComposerAutoloaderInite107dc494ece1872275e224229f3a009::getLoader();
|
||||
|
10
vendor/composer/autoload_classmap.php
vendored
10
vendor/composer/autoload_classmap.php
vendored
@ -2108,13 +2108,16 @@ return array(
|
||||
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMethodCallFactory' => $vendorDir . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php',
|
||||
'Rector\\PHPUnit\\NodeFinder\\DataProviderClassMethodFinder' => $vendorDir . '/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php',
|
||||
'Rector\\PHPUnit\\PHPUnit50\\Rector\\StaticCall\\GetMockRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit50/Rector/StaticCall/GetMockRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\ClassMethod\\AddDoesNotPerformAssertionToNonAssertingTestRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\ClassMethod\\ExceptionAnnotationRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit60/Rector/ClassMethod/ExceptionAnnotationRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\MethodCall\\DelegateExceptionArgumentsRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\MethodCall\\GetMockBuilderGetMockToCreateMockRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit60/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit70\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => $vendorDir . '/rector/rector-phpunit/rules/PHPUnit70/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
|
||||
'Rector\\PHPUnit\\PhpDoc\\DataProviderMethodRenamer' => $vendorDir . '/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php',
|
||||
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => $vendorDir . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\AddDoesNotPerformAssertionToNonAssertingTestRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\DataProviderAnnotationToAttributeRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\DependsAnnotationWithValueToAttributeRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\ExceptionAnnotationRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/ExceptionAnnotationRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\TryCatchToExpectExceptionRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php',
|
||||
@ -2127,7 +2130,6 @@ return array(
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitSelfCallRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitSelfCallRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitThisCallRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitThisCallRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\StaticDataProviderClassMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/StaticDataProviderClassMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\TestListenerToHooksRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\YieldDataProviderRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/YieldDataProviderRector.php',
|
||||
@ -2147,9 +2149,7 @@ return array(
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertSameTrueFalseToAssertTrueFalseRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertTrueFalseInternalTypeToSpecificMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertTrueFalseToSpecificMethodRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\DelegateExceptionArgumentsRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/DelegateExceptionArgumentsRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\ExplicitPhpErrorApiRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/ExplicitPhpErrorApiRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\GetMockBuilderGetMockToCreateMockRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\PropertyExistsWithoutAssertRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/PropertyExistsWithoutAssertRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\RemoveExpectAnyFromMockRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/RemoveExpectAnyFromMockRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\RemoveSetMethodsMethodCallRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c
|
||||
class ComposerAutoloaderInite107dc494ece1872275e224229f3a009
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInite107dc494ece1872275e224229f3a009', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit403e9b3e175b446d3efee98eeb37d45c', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite107dc494ece1872275e224229f3a009', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite107dc494ece1872275e224229f3a009::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInite107dc494ece1872275e224229f3a009::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
18
vendor/composer/autoload_static.php
vendored
18
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c
|
||||
class ComposerStaticInite107dc494ece1872275e224229f3a009
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2361,13 +2361,16 @@ class ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c
|
||||
'Rector\\PHPUnit\\NodeFactory\\ExpectExceptionMethodCallFactory' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFactory/ExpectExceptionMethodCallFactory.php',
|
||||
'Rector\\PHPUnit\\NodeFinder\\DataProviderClassMethodFinder' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeFinder/DataProviderClassMethodFinder.php',
|
||||
'Rector\\PHPUnit\\PHPUnit50\\Rector\\StaticCall\\GetMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit50/Rector/StaticCall/GetMockRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\ClassMethod\\AddDoesNotPerformAssertionToNonAssertingTestRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit60/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\ClassMethod\\ExceptionAnnotationRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit60/Rector/ClassMethod/ExceptionAnnotationRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\MethodCall\\DelegateExceptionArgumentsRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit60\\Rector\\MethodCall\\GetMockBuilderGetMockToCreateMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit60/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php',
|
||||
'Rector\\PHPUnit\\PHPUnit70\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/PHPUnit70/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
|
||||
'Rector\\PHPUnit\\PhpDoc\\DataProviderMethodRenamer' => __DIR__ . '/..' . '/rector/rector-phpunit/src/PhpDoc/DataProviderMethodRenamer.php',
|
||||
'Rector\\PHPUnit\\PhpDoc\\PhpDocValueToNodeMapper' => __DIR__ . '/..' . '/rector/rector-phpunit/src/PhpDoc/PhpDocValueToNodeMapper.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\AddDoesNotPerformAssertionToNonAssertingTestRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/AddDoesNotPerformAssertionToNonAssertingTestRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\CreateMockToAnonymousClassRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/CreateMockToAnonymousClassRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\DataProviderAnnotationToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/DataProviderAnnotationToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\DependsAnnotationWithValueToAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/DependsAnnotationWithValueToAttributeRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\ExceptionAnnotationRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/ExceptionAnnotationRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\ClassMethod\\TryCatchToExpectExceptionRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/ClassMethod/TryCatchToExpectExceptionRector.php',
|
||||
@ -2380,7 +2383,6 @@ class ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitSelfCallRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitSelfCallRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\PreferPHPUnitThisCallRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/PreferPHPUnitThisCallRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\StaticDataProviderClassMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/StaticDataProviderClassMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\TestListenerToHooksRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\Class_\\YieldDataProviderRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/YieldDataProviderRector.php',
|
||||
@ -2400,9 +2402,7 @@ class ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertSameTrueFalseToAssertTrueFalseRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/AssertSameTrueFalseToAssertTrueFalseRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertTrueFalseInternalTypeToSpecificMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseInternalTypeToSpecificMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\AssertTrueFalseToSpecificMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/AssertTrueFalseToSpecificMethodRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\DelegateExceptionArgumentsRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/DelegateExceptionArgumentsRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\ExplicitPhpErrorApiRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/ExplicitPhpErrorApiRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\GetMockBuilderGetMockToCreateMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/GetMockBuilderGetMockToCreateMockRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\PropertyExistsWithoutAssertRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/PropertyExistsWithoutAssertRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\RemoveExpectAnyFromMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/RemoveExpectAnyFromMockRector.php',
|
||||
'Rector\\PHPUnit\\Rector\\MethodCall\\RemoveSetMethodsMethodCallRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/MethodCall/RemoveSetMethodsMethodCallRector.php',
|
||||
@ -3068,9 +3068,9 @@ class ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit403e9b3e175b446d3efee98eeb37d45c::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite107dc494ece1872275e224229f3a009::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite107dc494ece1872275e224229f3a009::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite107dc494ece1872275e224229f3a009::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
16
vendor/composer/installed.json
vendored
16
vendor/composer/installed.json
vendored
@ -1917,12 +1917,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||
"reference": "8afdccb30c1ab88b2d159470fa9ac8d56dee6362"
|
||||
"reference": "3482059826588c2d07ed00a3c7b0ded3e3d3faa2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/8afdccb30c1ab88b2d159470fa9ac8d56dee6362",
|
||||
"reference": "8afdccb30c1ab88b2d159470fa9ac8d56dee6362",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/3482059826588c2d07ed00a3c7b0ded3e3d3faa2",
|
||||
"reference": "3482059826588c2d07ed00a3c7b0ded3e3d3faa2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1947,7 +1947,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-07-06T20:12:24+00:00",
|
||||
"time": "2023-07-12T13:21:58+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
@ -2049,12 +2049,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "120e7ee1d392e5b87b1470c9267dee87acb03037"
|
||||
"reference": "3ed719e167f26fd02f7d25d77ac6e42ca4137b67"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/120e7ee1d392e5b87b1470c9267dee87acb03037",
|
||||
"reference": "120e7ee1d392e5b87b1470c9267dee87acb03037",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/3ed719e167f26fd02f7d25d77ac6e42ca4137b67",
|
||||
"reference": "3ed719e167f26fd02f7d25d77ac6e42ca4137b67",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2082,7 +2082,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.1",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-07-12T13:05:58+00:00",
|
||||
"time": "2023-07-12T14:01:43+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8afdccb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 410d05f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 120e7ee'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e788554'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3482059'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 410d05f'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3ed719e'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e788554'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace Rector\Doctrine\NodeManipulator;
|
||||
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockClassRenamer;
|
||||
use Rector\NodeTypeResolver\ValueObject\OldToNewType;
|
||||
|
@ -5,7 +5,6 @@ namespace Rector\Doctrine\Rector\Class_;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
|
@ -8,11 +8,56 @@ use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector;
|
||||
use Rector\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector;
|
||||
use Rector\PHPUnit\Rector\Class_\PreferPHPUnitThisCallRector;
|
||||
use Rector\PHPUnit\Rector\Class_\YieldDataProviderRector;
|
||||
use Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertInstanceOfComparisonRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertNotOperatorRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertRegExpRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseInternalTypeToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\RemoveSetMethodsMethodCallRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([RemoveExpectAnyFromMockRector::class, AddSeeTestAnnotationRector::class, ConstructClassMethodToSetUpTestCaseRector::class, AssertSameTrueFalseToAssertTrueFalseRector::class, AssertEqualsToSameRector::class, AssertCompareToSpecificMethodRector::class, AssertComparisonToSpecificMethodRector::class, PreferPHPUnitThisCallRector::class, YieldDataProviderRector::class]);
|
||||
$rectorConfig->rules([
|
||||
AddSeeTestAnnotationRector::class,
|
||||
ConstructClassMethodToSetUpTestCaseRector::class,
|
||||
AssertSameTrueFalseToAssertTrueFalseRector::class,
|
||||
AssertEqualsToSameRector::class,
|
||||
PreferPHPUnitThisCallRector::class,
|
||||
YieldDataProviderRector::class,
|
||||
// sepcific asserts
|
||||
AssertCompareToSpecificMethodRector::class,
|
||||
AssertComparisonToSpecificMethodRector::class,
|
||||
AssertNotOperatorRector::class,
|
||||
AssertTrueFalseToSpecificMethodRector::class,
|
||||
AssertSameBoolNullToSpecificMethodRector::class,
|
||||
AssertFalseStrposToContainsRector::class,
|
||||
AssertTrueFalseInternalTypeToSpecificMethodRector::class,
|
||||
AssertIssetToSpecificMethodRector::class,
|
||||
AssertInstanceOfComparisonRector::class,
|
||||
AssertPropertyExistsRector::class,
|
||||
AssertRegExpRector::class,
|
||||
SimplifyForeachInstanceOfRector::class,
|
||||
UseSpecificWillMethodRector::class,
|
||||
/**
|
||||
* Improve direct testing of your code, without mock creep. Make it simple, clear and easy to maintain:
|
||||
*
|
||||
* @see https://blog.frankdejonge.nl/testing-without-mocking-frameworks/
|
||||
* @see https://maksimivanov.com/posts/dont-mock-what-you-dont-own/
|
||||
* @see https://dev.to/mguinea/stop-using-mocking-libraries-2f2k
|
||||
* @see https://mnapoli.fr/anonymous-classes-in-tests/
|
||||
* @see https://steemit.com/php/@crell/don-t-use-mocking-libraries
|
||||
* @see https://davegebler.com/post/php/better-php-unit-testing-avoiding-mocks
|
||||
*/
|
||||
RemoveSetMethodsMethodCallRector::class,
|
||||
RemoveExpectAnyFromMockRector::class,
|
||||
]);
|
||||
};
|
||||
|
@ -4,13 +4,6 @@ declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\DelegateExceptionArgumentsRector;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
/** @deprecated Use PHPUnit 6.0 set instead, as related to the version */
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
# handles 2nd and 3rd argument of setExpectedException
|
||||
$rectorConfig->rule(DelegateExceptionArgumentsRector::class);
|
||||
$rectorConfig->rule(ExceptionAnnotationRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedException', 'expectedException'), new MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedExceptionRegExp', 'expectedException')]);
|
||||
};
|
||||
|
@ -4,18 +4,6 @@ declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertInstanceOfComparisonRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertNotOperatorRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertRegExpRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseInternalTypeToSpecificMethodRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector;
|
||||
/** @deprecated Use PHPUnit CodeQuality set instead, as related to the code quality */
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rules([AssertNotOperatorRector::class, AssertComparisonToSpecificMethodRector::class, AssertTrueFalseToSpecificMethodRector::class, AssertSameBoolNullToSpecificMethodRector::class, AssertFalseStrposToContainsRector::class, AssertTrueFalseInternalTypeToSpecificMethodRector::class, AssertCompareToSpecificMethodRector::class, AssertIssetToSpecificMethodRector::class, AssertInstanceOfComparisonRector::class, AssertPropertyExistsRector::class, AssertRegExpRector::class, SimplifyForeachInstanceOfRector::class]);
|
||||
};
|
||||
|
@ -4,21 +4,22 @@ declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
|
||||
use Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector;
|
||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/phpunit-exception.php');
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('PHPUnit\\Framework\\TestCase', 'createMockBuilder', 'getMockBuilder')]);
|
||||
// handles 2nd and 3rd argument of setExpectedException
|
||||
$rectorConfig->rules([DelegateExceptionArgumentsRector::class, ExceptionAnnotationRector::class, AddDoesNotPerformAssertionToNonAssertingTestRector::class, GetMockBuilderGetMockToCreateMockRector::class]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedException', 'expectedException'), new MethodCallRename('PHPUnit\\Framework\\TestClass', 'setExpectedExceptionRegExp', 'expectedException'), new MethodCallRename('PHPUnit\\Framework\\TestCase', 'createMockBuilder', 'getMockBuilder')]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, ['PHPUnit_Framework_MockObject_Stub' => 'PHPUnit\\Framework\\MockObject\\Stub', 'PHPUnit_Framework_MockObject_Stub_Return' => 'PHPUnit\\Framework\\MockObject\\Stub\\ReturnStub', 'PHPUnit_Framework_MockObject_Matcher_Parameters' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Parameters', 'PHPUnit_Framework_MockObject_Matcher_Invocation' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Invocation', 'PHPUnit_Framework_MockObject_MockObject' => 'PHPUnit\\Framework\\MockObject\\MockObject', 'PHPUnit_Framework_MockObject_Invocation_Object' => 'PHPUnit\\Framework\\MockObject\\Invocation\\ObjectInvocation']);
|
||||
$rectorConfig->ruleWithConfiguration(PseudoNamespaceToNamespaceRector::class, [
|
||||
// ref. https://github.com/sebastianbergmann/phpunit/compare/5.7.9...6.0.0
|
||||
new PseudoNamespaceToNamespace('PHPUnit_', ['PHPUnit_Framework_MockObject_MockObject', 'PHPUnit_Framework_MockObject_Invocation_Object', 'PHPUnit_Framework_MockObject_Matcher_Invocation', 'PHPUnit_Framework_MockObject_Matcher_Parameters', 'PHPUnit_Framework_MockObject_Stub_Return', 'PHPUnit_Framework_MockObject_Stub']),
|
||||
]);
|
||||
$rectorConfig->rule(AddDoesNotPerformAssertionToNonAssertingTestRector::class);
|
||||
$rectorConfig->rule(GetMockBuilderGetMockToCreateMockRector::class);
|
||||
};
|
||||
|
@ -4,11 +4,10 @@ declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector;
|
||||
use Rector\PHPUnit\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector;
|
||||
use Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector;
|
||||
use Rector\Renaming\ValueObject\RenameAnnotationByType;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/phpunit-exception.php');
|
||||
$rectorConfig->ruleWithConfiguration(RenameAnnotationRector::class, [new RenameAnnotationByType('PHPUnit\\Framework\\TestCase', 'scenario', 'test')]);
|
||||
$rectorConfig->rule(RemoveDataProviderTestPrefixRector::class);
|
||||
};
|
||||
|
@ -16,7 +16,6 @@ use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/phpunit-exception.php');
|
||||
$rectorConfig->rules([SpecificAssertInternalTypeRector::class, AssertEqualsParameterToSpecificMethodsTypeRector::class, SpecificAssertContainsRector::class]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, [
|
||||
# https://github.com/sebastianbergmann/phpunit/issues/3123
|
||||
|
@ -4,24 +4,6 @@ declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\RemoveSetMethodsMethodCallRector;
|
||||
use Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector;
|
||||
/**
|
||||
* Set to improve direct testing of your code, without mock overgrown weed everywhere. Make it simple and clear, easy to
|
||||
* maintain and swift to read.
|
||||
*
|
||||
* @see https://blog.frankdejonge.nl/testing-without-mocking-frameworks/
|
||||
* @see https://maksimivanov.com/posts/dont-mock-what-you-dont-own/
|
||||
* @see https://dev.to/mguinea/stop-using-mocking-libraries-2f2k
|
||||
* @see https://mnapoli.fr/anonymous-classes-in-tests/
|
||||
* @see https://steemit.com/php/@crell/don-t-use-mocking-libraries
|
||||
* @see https://davegebler.com/post/php/better-php-unit-testing-avoiding-mocks
|
||||
*/
|
||||
/** @deprecated Use CodeQuality set instead, as related to code-quality */
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(RemoveSetMethodsMethodCallRector::class);
|
||||
$rectorConfig->rule(GetMockBuilderGetMockToCreateMockRector::class);
|
||||
$rectorConfig->rule(RemoveExpectAnyFromMockRector::class);
|
||||
$rectorConfig->rule(UseSpecificWillMethodRector::class);
|
||||
};
|
||||
|
2
vendor/rector/rector-phpunit/easy-ci.php
vendored
2
vendor/rector/rector-phpunit/easy-ci.php
vendored
@ -7,6 +7,6 @@ use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Set\Contract\SetListInterface;
|
||||
use RectorPrefix202307\Symplify\EasyCI\Config\EasyCIConfig;
|
||||
return static function (EasyCIConfig $easyCIConfig) : void {
|
||||
$easyCIConfig->paths([__DIR__ . '/config', __DIR__ . '/src']);
|
||||
$easyCIConfig->paths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/rules']);
|
||||
$easyCIConfig->typesToSkip([RectorInterface::class, SetListInterface::class]);
|
||||
};
|
||||
|
9
vendor/rector/rector-phpunit/rector.php
vendored
9
vendor/rector/rector-phpunit/rector.php
vendored
@ -10,21 +10,16 @@ use Rector\Set\ValueObject\LevelSetList;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->importNames();
|
||||
$rectorConfig->disableParallel();
|
||||
$rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/rules', __DIR__ . '/rules-tests']);
|
||||
$rectorConfig->skip([
|
||||
// for tests
|
||||
'*/Source/*',
|
||||
'*/Fixture/*',
|
||||
'*/Expected/*',
|
||||
// buggy here
|
||||
\Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class,
|
||||
// object types
|
||||
StringClassNameToClassConstantRector::class => [__DIR__ . '/src/Rector/MethodCall/UseSpecificWillMethodRector.php', __DIR__ . '/src/Rector/Class_/TestListenerToHooksRector.php', __DIR__ . '/src/NodeFactory/ConsecutiveAssertionFactory.php', __DIR__ . '/src/NodeAnalyzer/TestsNodeAnalyzer.php', __DIR__ . '/src/NodeFactory/DataProviderClassMethodFactory.php', __DIR__ . '/config'],
|
||||
StringClassNameToClassConstantRector::class => [__DIR__ . '/src/Rector/Class_/TestListenerToHooksRector.php', __DIR__ . '/src/NodeAnalyzer/TestsNodeAnalyzer.php', __DIR__ . '/config'],
|
||||
]);
|
||||
$rectorConfig->sets([
|
||||
// needed for DEAD_CODE list, just in split package like this
|
||||
__DIR__ . '/config/config.php',
|
||||
LevelSetList::UP_TO_PHP_81,
|
||||
SetList::DEAD_CODE,
|
||||
PHPUnitSetList::PHPUNIT_100,
|
||||
@ -35,6 +30,8 @@ return static function (RectorConfig $rectorConfig) : void {
|
||||
SetList::NAMING,
|
||||
SetList::TYPE_DECLARATION,
|
||||
SetList::PRIVATIZATION,
|
||||
// needed for DEAD_CODE list, just in split package like this
|
||||
__DIR__ . '/config/config.php',
|
||||
]);
|
||||
$rectorConfig->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [
|
||||
// keep unprefixed to protected from downgrade
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
|
||||
|
||||
use Iterator;
|
||||
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
final class AddDoesNotPerformAssertionToNonAssertingTestRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(string $filePath) : void
|
||||
{
|
||||
$this->doTestFile($filePath);
|
||||
}
|
||||
public static function provideData() : Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
public function provideConfigFilePath() : string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class SomeClass extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class SomeClass extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class KeepAssert extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
$this->assertNotNull(5);
|
||||
}
|
||||
|
||||
public function testStatic()
|
||||
{
|
||||
$nothing = 5;
|
||||
self::assertNotNull(5);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class KeepAssertInCall extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->doElsewhere(5);
|
||||
}
|
||||
|
||||
private function doElsewhere($value)
|
||||
{
|
||||
$this->assertNotNull($value);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class KeepAssertInStaticCall extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
self::doElsewhere(5);
|
||||
}
|
||||
|
||||
private static function doElsewhere($value)
|
||||
{
|
||||
if ($value) {
|
||||
self::assertNotNull($value);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class KeepExpectedException extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
|
||||
public function testExpectException()
|
||||
{
|
||||
$this->expectException('Throwable');
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
|
||||
public function testSetExpectedException()
|
||||
{
|
||||
$this->setExpectedException('Throwable');
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class KeepNonPublic extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function testDelegated()
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class KeepNonTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function provideData()
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class KeepWithMultipleFunctionCalls extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider trueProvider
|
||||
*/
|
||||
public function testTrue(bool $bool): void
|
||||
{
|
||||
$this->refreshFixtures();
|
||||
$this->doSomeOtherStuff();
|
||||
|
||||
$this->handleAssert($bool);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool[]
|
||||
*/
|
||||
public function trueProvider(): array
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
];
|
||||
}
|
||||
|
||||
private function handleAssert(bool $bool): void
|
||||
{
|
||||
// some generic function that can be used for multiple test to do the same assertions.
|
||||
self::assertTrue($bool);
|
||||
}
|
||||
|
||||
protected function refreshFixtures(): void
|
||||
{
|
||||
// TODO: Implement refreshFixtures() method.
|
||||
}
|
||||
|
||||
protected function doSomeOtherStuff(): void
|
||||
{
|
||||
// TODO: Implement doSomeOtherStuff() method.
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\AbstractClassWithAssert;
|
||||
|
||||
final class KeepWithParentMethodAssert extends AbstractClassWithAssert
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->doAssertThis();
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\AbstractClassWithStaticAssert;
|
||||
|
||||
class KeepWithParentMethodStaticAssert extends AbstractClassWithStaticAssert
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->doAssertThis();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\Denormalizer;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\DenormalizerInterface;
|
||||
|
||||
class ProphecyAssertions extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDenormalize(): void
|
||||
{
|
||||
$badData = ['42'];
|
||||
$fixedData = [42];
|
||||
|
||||
$type = 'anything';
|
||||
|
||||
/** @var DenormalizerInterface $denormalizer */
|
||||
$denormalizer = $this->prophesize(DenormalizerInterface::class);
|
||||
$denormalizer
|
||||
->denormalize($fixedData, $type)
|
||||
->shouldBeCalled();
|
||||
|
||||
(new Denormalizer($denormalizer))->handle($badData, $type);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SkipMockeryTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$mockNetteUser = Mockery::mock(User::class);
|
||||
$mockNetteUser->expects()->isAllowed('yes', 'vote');
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class SkipAbstractMethod extends TestCase
|
||||
{
|
||||
abstract public function testSomeThing(): void;
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class SkipAlreadyAttributedDoesnotPerformAssertion extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\SomeUser;
|
||||
|
||||
final class SkipCallAfterMock extends TestCase
|
||||
{
|
||||
private \PHPUnit\Framework\MockObject\MockObject|SomeUser $mockNetteUser;
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->mockNetteUser = $this->getMockBuilder(SomeUser::class)
|
||||
->getMock();
|
||||
|
||||
$this->runSomething();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\Factory;
|
||||
|
||||
final class SkipCallExpectNotToPerformAssertionMethodCall extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testCreate(): void
|
||||
{
|
||||
$this->expectNotToPerformAssertions();
|
||||
|
||||
$factory = new Factory();
|
||||
|
||||
$factory->create();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\SomeUser;
|
||||
|
||||
final class SkipCallOnMock extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$mockNetteUser = $this->getMockBuilder(SomeUser::class)
|
||||
->getMock();
|
||||
|
||||
$this->runSomething($mockNetteUser);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\SomeUser;
|
||||
|
||||
final class SkipCallOnMockProperty extends TestCase
|
||||
{
|
||||
private MockObject|SomeUser $mockNetteUser;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->mockNetteUser = $this->getMockBuilder(SomeUser::class)
|
||||
->getMock();
|
||||
}
|
||||
|
||||
public function test(): void
|
||||
{
|
||||
$this->runSomething($this->mockNetteUser);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class SkipDoTestFileInfoTest extends \Rector\Testing\PHPUnit\AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<\Symplify\SmartFileSystem\SmartFileInfo>
|
||||
*/
|
||||
public function provideData(): \Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
public function provideConfigFilePath(): string
|
||||
{
|
||||
return __DIR__ . '/config/symfony-26.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class SkipExistingAnnotation extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testSomething(): void
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class SkipExpectOutputTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testExpectOutputString()
|
||||
{
|
||||
$this->expectOutputString('Hello world!');
|
||||
|
||||
print 'Hello world!';
|
||||
}
|
||||
|
||||
public function testExpectOutputRegex()
|
||||
{
|
||||
$this->expectOutputRegex('#^Hello world!$#');
|
||||
|
||||
print 'Hello world!';
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Blah {}
|
||||
class Other {}
|
||||
|
||||
class TestSomething extends TestCase
|
||||
{
|
||||
public function test_blah()
|
||||
{
|
||||
$a = $this->createMock(Blah::class);
|
||||
|
||||
$a->expects($this->once())->method('something');
|
||||
|
||||
(new Other())->whatever($a);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SkipMethodCallWithPropertyMock extends TestCase
|
||||
{
|
||||
private \PHPUnit\Framework\MockObject\MockObject $mock;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->mock = $this->createMock('SomeClass');
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->callMockedProperty();
|
||||
}
|
||||
|
||||
private function callMockedProperty()
|
||||
{
|
||||
$this->mock->expects('something');
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\CachedAdapter;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\CacheInterface;
|
||||
|
||||
final class CachedAdapterTest extends TestCase
|
||||
{
|
||||
/** @var CacheInterface&MockObject */
|
||||
private MockObject $cache;
|
||||
private CachedAdapter $cachedAdapter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->cache = $this->createMock(CacheInterface::class);
|
||||
$this->cachedAdapter = new CachedAdapter($this->cache);
|
||||
}
|
||||
|
||||
public function testDelete(): void
|
||||
{
|
||||
$this->cache
|
||||
->expects(self::never())
|
||||
->method('has');
|
||||
|
||||
$this->cachedAdapter->delete('test');
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
|
||||
class Repository {
|
||||
/**
|
||||
* @var object[]
|
||||
*/
|
||||
public array $items = [];
|
||||
|
||||
public function add(object $test) {
|
||||
$this->items[] = $test;
|
||||
}
|
||||
}
|
||||
|
||||
class Hello {
|
||||
public function __construct(private Repository $repository)
|
||||
{}
|
||||
|
||||
public function test(object $test) {
|
||||
$this->repository->add($test);
|
||||
}
|
||||
}
|
||||
|
||||
class HelloTest extends TestCase
|
||||
{
|
||||
use ObjectProphecy;
|
||||
|
||||
private Hello $hello;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$service = $this->prophesize(Service::class);
|
||||
$this->hello = new Hello($service->reveal());
|
||||
}
|
||||
|
||||
public function testSomething()
|
||||
{
|
||||
$test = new \stdClass();
|
||||
$this->service->add($test)
|
||||
->shouldBeCalled();
|
||||
|
||||
$this->hello->test($test);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class TestInAnnotatoin extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function thisIsTest()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
|
||||
|
||||
class TestInAnnotatoin extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function thisIsTest()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
abstract class AbstractClassWithAssert extends TestCase
|
||||
{
|
||||
public function doAssertThis()
|
||||
{
|
||||
$this->anotherMethod();
|
||||
}
|
||||
private function anotherMethod()
|
||||
{
|
||||
$this->assertTrue(\true);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
abstract class AbstractClassWithStaticAssert extends TestCase
|
||||
{
|
||||
public function doAssertThis()
|
||||
{
|
||||
self::anotherMethod();
|
||||
}
|
||||
private static function anotherMethod()
|
||||
{
|
||||
self::assertTrue(\true);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
final class CachedAdapter
|
||||
{
|
||||
/**
|
||||
* @var \Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\CacheInterface
|
||||
*/
|
||||
private $cache;
|
||||
public function __construct(\Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\CacheInterface $cache)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
}
|
||||
public function delete($key) : bool
|
||||
{
|
||||
return $this->cache->delete($key);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
interface CacheInterface
|
||||
{
|
||||
public function has() : bool;
|
||||
public function delete($key) : bool;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
final class Denormalizer
|
||||
{
|
||||
/**
|
||||
* @var \Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\DenormalizerInterface
|
||||
*/
|
||||
private $denormalizer;
|
||||
public function __construct(\Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\DenormalizerInterface $denormalizer)
|
||||
{
|
||||
$this->denormalizer = $denormalizer;
|
||||
}
|
||||
public function handle(array $data, string $type) : ?array
|
||||
{
|
||||
try {
|
||||
return $this->denormalizer->denormalize($data, $type);
|
||||
} catch (\Throwable $throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
interface DenormalizerInterface
|
||||
{
|
||||
/**
|
||||
* Denormalizes data back into an object of the given class.
|
||||
*
|
||||
* @param mixed $data Data to restore
|
||||
* @param string $type The expected class to instantiate
|
||||
* @param string $format Format the given data was extracted from
|
||||
* @param array $context Options available to the denormalizer
|
||||
*
|
||||
* @return object|array
|
||||
*/
|
||||
public function denormalize($data, $type, $format = null, array $context = []);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
class Factory
|
||||
{
|
||||
public function create() : \stdClass
|
||||
{
|
||||
return new \stdClass();
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
|
||||
|
||||
class SomeUser
|
||||
{
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/../../../../../config/config.php');
|
||||
$rectorConfig->rule(AddDoesNotPerformAssertionToNonAssertingTestRector::class);
|
||||
};
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector;
|
||||
|
||||
use Iterator;
|
||||
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
final class ExceptionAnnotationRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(string $filePath) : void
|
||||
{
|
||||
$this->doTestFile($filePath);
|
||||
}
|
||||
public static function provideData() : Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
public function provideConfigFilePath() : string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Source\SomeConstant;
|
||||
|
||||
final class ConstantCode extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedExceptionCode SomeConstant::ERROR_CODE
|
||||
*/
|
||||
public function testThrowExceptionWhenOperatorIsInvalid(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Source\SomeConstant;
|
||||
|
||||
final class ConstantCode extends TestCase
|
||||
{
|
||||
public function testThrowExceptionWhenOperatorIsInvalid(): void
|
||||
{
|
||||
$this->expectExceptionCode(SomeConstant::ERROR_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
final class MyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \FooException
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
// some code
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
final class MyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->expectException('FooException');
|
||||
// some code
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
final class MyTest2 extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Phpml\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessage Invalid operator "~=" provided
|
||||
*/
|
||||
public function testThrowExceptionWhenOperatorIsInvalid(): void
|
||||
{
|
||||
Comparison::compare(1, 1, '~=');
|
||||
|
||||
// extra line
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
final class MyTest2 extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testThrowExceptionWhenOperatorIsInvalid(): void
|
||||
{
|
||||
$this->expectException('Phpml\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Invalid operator "~=" provided');
|
||||
Comparison::compare(1, 1, '~=');
|
||||
|
||||
// extra line
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
final class MyTest3 extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testThrowExceptionWhenOperatorIsInvalid(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
final class MyTest3 extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testThrowExceptionWhenOperatorIsInvalid(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionMessageTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
throw new \Exception('A literal exception message');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testPartialMessageBegin(): void
|
||||
{
|
||||
throw new \Exception('A partial exception message');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExceptionMessageTest extends TestCase
|
||||
{
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
throw new \Exception('A literal exception message');
|
||||
}
|
||||
|
||||
public function testPartialMessageBegin(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
throw new \Exception('A partial exception message');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Fixture5Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage Message referencing a method, SomeClass::someMethod
|
||||
*/
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
throw new \Exception('Message referencing a method, SomeClass::someMethod');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Fixture5Test extends TestCase
|
||||
{
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('Message referencing a method, SomeClass::someMethod');
|
||||
throw new \Exception('Message referencing a method, SomeClass::someMethod');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Fixture6Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage SomeClass::someMethod
|
||||
*/
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
throw new \Exception('Message referencing a method, SomeClass::someMethod');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Fixture6Test extends TestCase
|
||||
{
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('SomeClass::someMethod');
|
||||
throw new \Exception('Message referencing a method, SomeClass::someMethod');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SkipMethodWithNullPhpDoc extends TestCase
|
||||
{
|
||||
public function testLiteralMessage(): void
|
||||
{
|
||||
$this->expectException('Exception');
|
||||
throw new \Exception('A literal exception message');
|
||||
}
|
||||
|
||||
// test
|
||||
|
||||
public function testPartialMessageBegin(): void
|
||||
{
|
||||
throw new \Exception('A partial exception message');
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\Source;
|
||||
|
||||
final class SomeConstant
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public const ERROR_CODE = 1000004;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/../../../../../config/config.php');
|
||||
$rectorConfig->rule(ExceptionAnnotationRector::class);
|
||||
};
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector;
|
||||
|
||||
use Iterator;
|
||||
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
final class DelegateExceptionArgumentsRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(string $filePath) : void
|
||||
{
|
||||
$this->doTestFile($filePath);
|
||||
}
|
||||
public static function provideData() : Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
public function provideConfigFilePath() : string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\Fixture;
|
||||
|
||||
final class BareMethodRenameTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->setExpectedException('FirstException');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\Fixture;
|
||||
|
||||
final class BareMethodRenameTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->expectException('FirstException');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\Fixture;
|
||||
|
||||
final class MyMessageTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->setExpectedException('SecondException', $message);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\Fixture;
|
||||
|
||||
final class MyMessageTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$this->expectException('SecondException');
|
||||
$this->expectExceptionMessage($message);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\Fixture;
|
||||
|
||||
final class MessageWithCodeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
self::setExpectedException('ThirdException', $message, 101);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\Fixture;
|
||||
|
||||
final class MessageWithCodeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
self::expectException('ThirdException');
|
||||
self::expectExceptionMessage($message);
|
||||
self::expectExceptionCode(101);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
final class MyRegexpTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
self::setExpectedExceptionRegExp('SomeException', 'SomREGEPX');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
final class MyRegexpTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
self::expectException('SomeException');
|
||||
self::expectExceptionMessageRegExp('SomREGEPX');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ArrayInputTest extends TestCase
|
||||
{
|
||||
public function testParseInvalidInput($expectedExceptionMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->setExpectedException('SomeException', $message);
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ArrayInputTest extends TestCase
|
||||
{
|
||||
public function testParseInvalidInput($expectedExceptionMessage)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('SomeException');
|
||||
$this->expectExceptionMessage($message);
|
||||
} else {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/../../../../../../config/config.php');
|
||||
$rectorConfig->rule(DelegateExceptionArgumentsRector::class);
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\Fixture;
|
||||
|
||||
class SomeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$applicationMock = $this->getMockBuilder('SomeClass')
|
||||
->disableOriginalConstructor()
|
||||
->disableOriginalClone()
|
||||
->disableArgumentCloning()
|
||||
->disallowMockingUnknownTypes()
|
||||
->getMock();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\Fixture;
|
||||
|
||||
class SomeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$applicationMock = $this->createMock('SomeClass');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\Fixture;
|
||||
|
||||
class GetMockOnly extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$applicationMock = $this->getMockBuilder('SomeClass')
|
||||
->getMock();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\Fixture;
|
||||
|
||||
class GetMockOnly extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$applicationMock = $this->createMock('SomeClass');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\Fixture;
|
||||
|
||||
final class SkipSetMethods extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
$applicationMock = $this->getMockBuilder('SomeClass')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['addViolation'])
|
||||
->getMock();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
|
||||
|
||||
use Iterator;
|
||||
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
final class GetMockBuilderGetMockToCreateMockRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(string $filePath) : void
|
||||
{
|
||||
$this->doTestFile($filePath);
|
||||
}
|
||||
public static function provideData() : Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
public function provideConfigFilePath() : string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/../../../../../config/config.php');
|
||||
$rectorConfig->rule(GetMockBuilderGetMockToCreateMockRector::class);
|
||||
};
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
|
||||
|
||||
class SomeClass extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider testProvideData()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
|
||||
public function testProvideData()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
|
||||
|
||||
class SomeClass extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
|
||||
public function provideData()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
|
||||
|
||||
class MultipleDataProviders extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider testProvideData()
|
||||
* @dataProvider testNextProvideData2()
|
||||
* @dataProvider testNextProvideData()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
|
||||
public function testProvideData()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
|
||||
public function testNextProvideData2()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
|
||||
public function testNextProvideData()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
|
||||
|
||||
class MultipleDataProviders extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
* @dataProvider nextProvideData2()
|
||||
* @dataProvider nextProvideData()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
|
||||
public function provideData()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
|
||||
public function nextProvideData2()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
|
||||
public function nextProvideData()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
|
||||
|
||||
class WithTestAnnotation extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider testProvideDataForWithATestAnnotation()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
|
||||
public function testProvideDataForWithATestAnnotation()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
|
||||
|
||||
class WithTestAnnotation extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideDataForWithATestAnnotation()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
$nothing = 5;
|
||||
}
|
||||
|
||||
public function provideDataForWithATestAnnotation()
|
||||
{
|
||||
return ['123'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector;
|
||||
|
||||
use Iterator;
|
||||
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
final class RemoveDataProviderTestPrefixRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(string $filePath) : void
|
||||
{
|
||||
$this->doTestFile($filePath);
|
||||
}
|
||||
public static function provideData() : Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
public function provideConfigFilePath() : string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace RectorPrefix202307;
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\PHPUnit\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->import(__DIR__ . '/../../../../../../config/config.php');
|
||||
$rectorConfig->rule(RemoveDataProviderTestPrefixRector::class);
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\ClassMethod;
|
||||
namespace Rector\PHPUnit\PHPUnit60\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
@ -18,7 +18,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
* @changelog https://phpunit.readthedocs.io/en/9.5/annotations.html#doesnotperformassertions
|
||||
* @changelog https://github.com/sebastianbergmann/phpunit/issues/2484
|
||||
*
|
||||
* @see \Rector\PHPUnit\Tests\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\AddDoesNotPerformAssertionToNonAssertingTestRectorTest
|
||||
* @see \Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\AddDoesNotPerformAssertionToNonAssertingTestRectorTest
|
||||
*/
|
||||
final class AddDoesNotPerformAssertionToNonAssertingTestRector extends AbstractRector
|
||||
{
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\ClassMethod;
|
||||
namespace Rector\PHPUnit\PHPUnit60\Rector\ClassMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
@ -15,7 +16,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
* @changelog https://thephp.cc/news/2016/02/questioning-phpunit-best-practices
|
||||
* @changelog https://github.com/sebastianbergmann/phpunit/commit/17c09b33ac5d9cad1459ace0ae7b1f942d1e9afd
|
||||
*
|
||||
* @see \Rector\PHPUnit\Tests\Rector\ClassMethod\ExceptionAnnotationRector\ExceptionAnnotationRectorTest
|
||||
* @see \Rector\PHPUnit\Tests\PHPUnit60\Rector\ClassMethod\ExceptionAnnotationRector\ExceptionAnnotationRectorTest
|
||||
*/
|
||||
final class ExceptionAnnotationRector extends AbstractRector
|
||||
{
|
||||
@ -83,7 +84,10 @@ CODE_SAMPLE
|
||||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
foreach (self::ANNOTATION_TO_METHOD as $annotationName => $methodName) {
|
||||
if (!$phpDocInfo->hasByName($annotationName)) {
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\MethodCall;
|
||||
namespace Rector\PHPUnit\PHPUnit60\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
@ -15,7 +15,7 @@ use Rector\PHPUnit\NodeFactory\AssertCallFactory;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\PHPUnit\Tests\Rector\MethodCall\DelegateExceptionArgumentsRector\DelegateExceptionArgumentsRectorTest
|
||||
* @see \Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\DelegateExceptionArgumentsRector\DelegateExceptionArgumentsRectorTest
|
||||
*/
|
||||
final class DelegateExceptionArgumentsRector extends AbstractRector
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\MethodCall;
|
||||
namespace Rector\PHPUnit\PHPUnit60\Rector\MethodCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
@ -11,7 +11,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://github.com/lmc-eu/steward/pull/187/files#diff-c7e8c65e59b8b4ff8b54325814d4ba55L80
|
||||
*
|
||||
* @see \Rector\PHPUnit\Tests\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\GetMockBuilderGetMockToCreateMockRectorTest
|
||||
* @see \Rector\PHPUnit\Tests\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector\GetMockBuilderGetMockToCreateMockRectorTest
|
||||
*/
|
||||
final class GetMockBuilderGetMockToCreateMockRector extends AbstractRector
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPUnit\Rector\Class_;
|
||||
namespace Rector\PHPUnit\PHPUnit70\Rector\Class_;
|
||||
|
||||
use RectorPrefix202307\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
@ -16,7 +16,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://stackoverflow.com/a/46693675/1348344
|
||||
*
|
||||
* @see \Rector\PHPUnit\Tests\Rector\Class_\RemoveDataProviderTestPrefixRector\RemoveDataProviderTestPrefixRectorTest
|
||||
* @see \Rector\PHPUnit\Tests\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector\RemoveDataProviderTestPrefixRectorTest
|
||||
*/
|
||||
final class RemoveDataProviderTestPrefixRector extends AbstractRector
|
||||
{
|
@ -51,14 +51,17 @@ final class PHPUnitSetList implements SetListInterface
|
||||
*/
|
||||
public const PHPUNIT_CODE_QUALITY = __DIR__ . '/../../config/sets/phpunit-code-quality.php';
|
||||
/**
|
||||
* @deprecated Use PHPUnit 6.0 set instead, as related to the version
|
||||
* @var string
|
||||
*/
|
||||
public const PHPUNIT_EXCEPTION = __DIR__ . '/../../config/sets/phpunit-exception.php';
|
||||
/**
|
||||
* @deprecated Use CodeQuality set instead, as related to code-quality
|
||||
* @var string
|
||||
*/
|
||||
public const REMOVE_MOCKS = __DIR__ . '/../../config/sets/remove-mocks.php';
|
||||
/**
|
||||
* @deprecated Use PHPUnit CodeQuality set instead, as related to the code quality
|
||||
* @var string
|
||||
*/
|
||||
public const PHPUNIT_SPECIFIC_METHOD = __DIR__ . '/../../config/sets/phpunit-specific-method.php';
|
||||
|
Loading…
x
Reference in New Issue
Block a user