Skip to content

Commit

Permalink
Use method expectDeprecation from Symfony Bridge instead of annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Apr 18, 2021
1 parent c990a13 commit c9ec8a6
Show file tree
Hide file tree
Showing 41 changed files with 75 additions and 87 deletions.
1 change: 1 addition & 0 deletions .composer-require-checker.json
Expand Up @@ -16,6 +16,7 @@
"PHPUnitGoodPractices\\Traits\\ProphesizeOnlyInterfaceTrait",
"Prophecy\\Argument",
"Prophecy\\PhpUnit\\ProphecyTrait",
"Symfony\\Bridge\\PhpUnit\\ExpectDeprecationTrait",
"Symfony\\Component\\EventDispatcher\\Event",
"Symfony\\Contracts\\EventDispatcher\\Event",
"Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface",
Expand Down
1 change: 1 addition & 0 deletions .php_cs.dist
Expand Up @@ -27,6 +27,7 @@ $config
'@PHPUnit75Migration:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']],
'header_comment' => ['header' => $header],
'list_syntax' => ['syntax' => 'long'],
])
Expand Down
2 changes: 1 addition & 1 deletion tests/ConfigTest.php
Expand Up @@ -289,10 +289,10 @@ public function testConfigConstructorWithName()

/**
* @group legacy
* @expectedDeprecation PhpCsFixer\Config::create is deprecated since 2.17 and will be removed in 3.0.
*/
public function testDeprecatedConstructor()
{
$this->expectDeprecation('PhpCsFixer\\Config::create is deprecated since 2.17 and will be removed in 3.0.');
Config::create();
}
}
2 changes: 1 addition & 1 deletion tests/Console/Command/FixCommandTest.php
Expand Up @@ -42,10 +42,10 @@ public function testEmptyRulesValue()

/**
* @group legacy
* @expectedDeprecation Expected "yes" or "no" for option "using-cache", other values are deprecated and support will be removed in 3.0. Got "not today", this implicitly set the option to "false".
*/
public function testEmptyFormatValue()
{
$this->expectDeprecation('Expected "yes" or "no" for option "using-cache", other values are deprecated and support will be removed in 3.0. Got "not today", this implicitly set the option to "false".');
$cmdTester = $this->doTestExecute(
[
'--using-cache' => 'not today',
Expand Down
8 changes: 4 additions & 4 deletions tests/Console/ConfigurationResolverTest.php
Expand Up @@ -120,10 +120,10 @@ public function testResolveProgressWithPositiveConfigAndExplicitProgress($progre
* @dataProvider provideProgressTypeLegacyCases
*
* @group legacy
* @expectedDeprecation Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead.
*/
public function testResolveProgressWithPositiveConfigAndExplicitProgressLegacy($progressType)
{
$this->expectDeprecation('Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead.');
$this->testResolveProgressWithPositiveConfigAndExplicitProgress($progressType);
}

Expand Down Expand Up @@ -152,10 +152,10 @@ public function testResolveProgressWithNegativeConfigAndExplicitProgress($progre
* @dataProvider provideProgressTypeLegacyCases
*
* @group legacy
* @expectedDeprecation Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead.
*/
public function testResolveProgressWithNegativeConfigAndExplicitProgressLegacy($progressType)
{
$this->expectDeprecation('Passing `estimating`, `estimating-max` or `run-in` is deprecated and will not be supported in 3.0, use `none` or `dots` instead.');
$this->testResolveProgressWithNegativeConfigAndExplicitProgress($progressType);
}

Expand Down Expand Up @@ -1201,10 +1201,10 @@ public function testResolveConfigFileOverridesDefault()

/**
* @group legacy
* @expectedDeprecation Expected "yes" or "no" for option "allow-risky", other values are deprecated and support will be removed in 3.0. Got "yes please", this implicitly set the option to "false".
*/
public function testDeprecationOfPassingOtherThanNoOrYes()
{
$this->expectDeprecation('Expected "yes" or "no" for option "allow-risky", other values are deprecated and support will be removed in 3.0. Got "yes please", this implicitly set the option to "false".');
$resolver = $this->createConfigurationResolver(['allow-risky' => 'yes please']);

static::assertFalse($resolver->getRiskyAllowed());
Expand Down Expand Up @@ -1242,10 +1242,10 @@ public function testWithEmptyRules()
* @dataProvider provideDeprecatedFixerConfiguredCases
*
* @group legacy
* @expectedDeprecation Rule "Vendor4/foo" is deprecated. Use "testA" and "testB" instead.
*/
public function testDeprecatedFixerConfigured($ruleConfig)
{
$this->expectDeprecation('Rule "Vendor4/foo" is deprecated. Use "testA" and "testB" instead.');
$fixer = new DeprecatedFixer();
$config = new Config();
$config->registerCustomFixers([$fixer]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php
Expand Up @@ -290,10 +290,10 @@ public static function providePrintToEchoFixNewCases()

/**
* @group legacy
* @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.
*/
public function testLegacyDefaultConfig()
{
$this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.');
$this->fixer->configure(null);

static::assertCandidateTokenType(T_PRINT, $this->fixer);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Alias/RandomApiMigrationFixerTest.php
Expand Up @@ -42,10 +42,10 @@ public function testConfigureCheckReplacementType()

/**
* @group legacy
* @expectedDeprecation Passing "replacements" at the root of the configuration for rule "random_api_migration" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead.
*/
public function testLegacyConfigure()
{
$this->expectDeprecation('Passing "replacements" at the root of the configuration for rule "random_api_migration" is deprecated and will not be supported in 3.0, use "replacements" => array(...) option instead.');
$this->fixer->configure(['rand' => 'random_int']);

$reflectionProperty = new \ReflectionProperty($this->fixer, 'configuration');
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php
Expand Up @@ -35,10 +35,10 @@ public function testInvalidConfiguration()

/**
* @group legacy
* @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.
*/
public function testLegacyFixWithDefaultConfiguration()
{
$this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.');
$this->fixer->configure(null);
$this->doTest(
'<?php $a = array(); $b = array();',
Expand Down
3 changes: 0 additions & 3 deletions tests/Fixer/CastNotation/LowercaseCastFixerTest.php
Expand Up @@ -13,7 +13,6 @@
namespace PhpCsFixer\Tests\Fixer\CastNotation;

use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @author SpacePossum
Expand All @@ -24,8 +23,6 @@
*/
final class LowercaseCastFixerTest extends AbstractFixerTestCase
{
use ExpectDeprecationTrait;

/**
* @param string $expected
* @param null|string $input
Expand Down
3 changes: 0 additions & 3 deletions tests/Fixer/CastNotation/ShortScalarCastFixerTest.php
Expand Up @@ -13,7 +13,6 @@
namespace PhpCsFixer\Tests\Fixer\CastNotation;

use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

/**
* @author SpacePossum
Expand All @@ -24,8 +23,6 @@
*/
final class ShortScalarCastFixerTest extends AbstractFixerTestCase
{
use ExpectDeprecationTrait;

/**
* @param string $expected
* @param null|string $input
Expand Down
Expand Up @@ -1153,10 +1153,10 @@ public function f2() {}
*
* @dataProvider provideDeprecatedConfigCases
* @group legacy
* @expectedDeprecation A list of elements is deprecated, use a dictionary of `const|method|property` => `none|one` instead.
*/
public function testWithDeprecatedConfig($expected, $input = null, array $config = [])
{
$this->expectDeprecation('A list of elements is deprecated, use a dictionary of `const|method|property` => `none|one` instead.');
$this->fixer->configure($config);
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php
Expand Up @@ -28,10 +28,10 @@ final class ClassDefinitionFixerTest extends AbstractFixerWithAliasedOptionsTest
{
/**
* @group legacy
* @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.
*/
public function testLegacyConfigureDefaultToNull()
{
$this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.');
$defaultConfig = [
'multi_line_extends_each_single_line' => false,
'single_item_single_line' => false,
Expand Down
Expand Up @@ -451,10 +451,10 @@ class Foo
*
* @group legacy
* @dataProvider provideConfigurationCases
* @expectedDeprecation Passing "order" at the root of the configuration for rule "ordered_class_elements" is deprecated and will not be supported in 3.0, use "order" => array(...) option instead.
*/
public function testLegacyFixWithConfiguration(array $configuration, $expected, $input)
{
$this->expectDeprecation('Passing "order" at the root of the configuration for rule "ordered_class_elements" is deprecated and will not be supported in 3.0, use "order" => array(...) option instead.');
$this->fixer->configure($configuration);
$this->doTest($expected, $input);
}
Expand Down
Expand Up @@ -622,10 +622,10 @@ class Foo
*
* @group legacy
* @dataProvider provideConfigurationCases
* @expectedDeprecation Passing "elements" at the root of the configuration for rule "single_class_element_per_statement" is deprecated and will not be supported in 3.0, use "elements" => array(...) option instead.
*/
public function testLegacyFixWithConfiguration(array $configuration, $expected)
{
$this->expectDeprecation('Passing "elements" at the root of the configuration for rule "single_class_element_per_statement" is deprecated and will not be supported in 3.0, use "elements" => array(...) option instead.');
static $input = <<<'EOT'
<?php
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php
Expand Up @@ -558,10 +558,10 @@ public function testInvalidConfigurationValue()
* @group legacy
* @requires PHP 7.1
* @dataProvider provideFixClassConstCases
* @expectedDeprecation Passing "elements" at the root of the configuration for rule "visibility_required" is deprecated and will not be supported in 3.0, use "elements" => array(...) option instead.
*/
public function testLegacyFixClassConst($expected, $input)
{
$this->expectDeprecation('Passing "elements" at the root of the configuration for rule "visibility_required" is deprecated and will not be supported in 3.0, use "elements" => array(...) option instead.');
$this->fixer->configure(['const']);
$this->doTest($expected, $input);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixer/Comment/HeaderCommentFixerTest.php
Expand Up @@ -568,10 +568,10 @@ public function testDefaultConfiguration()

/**
* @group legacy
* @expectedDeprecation Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.
*/
public function testLegacyMisconfiguration()
{
$this->expectDeprecation('Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.');
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
$this->expectExceptionMessage('[header_comment] Missing required configuration: The required option "header" is missing.');

Expand Down
Expand Up @@ -60,10 +60,10 @@ public function testFix($expected, $input = null, $fixStatement = null)
*
* @group legacy
* @dataProvider provideFixCases
* @expectedDeprecation Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead.
*/
public function testLegacyFix($expected, $input = null, $fixStatement = null)
{
$this->expectDeprecation('Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead.');
$this->fixerTest($expected, $input, $fixStatement, true);
}

Expand All @@ -87,11 +87,11 @@ public function testFix70($expected, $input = null, $fixStatement = null)
*
* @group legacy
* @dataProvider provideFix70Cases
* @expectedDeprecation Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead.
* @requires PHP 7.0
*/
public function testLegacyFix70($expected, $input = null, $fixStatement = null)
{
$this->expectDeprecation('Passing "statements" at the root of the configuration for rule "no_unneeded_control_parentheses" is deprecated and will not be supported in 3.0, use "statements" => array(...) option instead.');
$this->fixerTest($expected, $input, $fixStatement, true);
}

Expand Down

0 comments on commit c9ec8a6

Please sign in to comment.