Skip to content

Commit

Permalink
Merge branch '2.2' into 2.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/AutoReview/ProjectCodeTest.php
#	tests/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixerTest.php
#	tests/Fixer/ArrayNotation/TrimArraySpacesFixerTest.php
#	tests/Fixer/Basic/BracesFixerTest.php
#	tests/Fixer/Casing/LowercaseConstantsFixerTest.php
#	tests/Fixer/Casing/MagicConstantCasingFixerTest.php
#	tests/Fixer/CastNotation/CastSpacesFixerTest.php
#	tests/Fixer/ClassNotation/NoBlankLinesAfterClassOpeningFixerTest.php
#	tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php
#	tests/Fixer/ControlStructure/NoUnneededControlParenthesesFixerTest.php
#	tests/Fixer/DoctrineAnnotation/DoctrineAnnotationBracesFixerTest.php
#	tests/Fixer/DoctrineAnnotation/DoctrineAnnotationSpacesFixerTest.php
#	tests/Fixer/FunctionNotation/FunctionDeclarationFixerTest.php
#	tests/Fixer/FunctionNotation/FunctionTypehintSpaceFixerTest.php
#	tests/Fixer/FunctionNotation/MethodArgumentSpaceFixerTest.php
#	tests/Fixer/FunctionNotation/NoSpacesAfterFunctionNameFixerTest.php
#	tests/Fixer/FunctionNotation/NoUnreachableDefaultArgumentValueFixerTest.php
#	tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php
#	tests/Fixer/Operator/NewWithBracesFixerTest.php
#	tests/Fixer/Operator/UnaryOperatorSpacesFixerTest.php
#	tests/Fixer/PhpTag/BlankLineAfterOpeningTagFixerTest.php
#	tests/Fixer/PhpTag/LinebreakAfterOpeningTagFixerTest.php
#	tests/Fixer/Phpdoc/PhpdocNoUselessInheritdocFixerTest.php
#	tests/Fixer/Phpdoc/PhpdocToCommentFixerTest.php
#	tests/Fixer/Semicolon/NoEmptyStatementFixerTest.php
#	tests/Fixer/Whitespace/NoExtraConsecutiveBlankLinesFixerTest.php
#	tests/Tokenizer/TokensAnalyzerTest.php
  • Loading branch information
keradus committed Sep 6, 2017
2 parents 81e2cb9 + 10c9393 commit c660329
Show file tree
Hide file tree
Showing 122 changed files with 527 additions and 473 deletions.
4 changes: 2 additions & 2 deletions tests/AbstractDoctrineAnnotationFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class AbstractDoctrineAnnotationFixerTestCase extends AbstractFixerTest
/**
* @param array $configuration
*
* @dataProvider getInvalidConfigurationCases
* @dataProvider provideInvalidConfigurationCases
*/
public function testConfigureWithInvalidConfiguration(array $configuration)
{
Expand All @@ -34,7 +34,7 @@ public function testConfigureWithInvalidConfiguration(array $configuration)
/**
* @return array
*/
public function getInvalidConfigurationCases()
public function provideInvalidConfigurationCases()
{
return [
[['foo' => 'bar']],
Expand Down
4 changes: 2 additions & 2 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public function testFixersPriorityEdgeFixers()
}

/**
* @dataProvider getFixersPriorityCases
* @dataProvider provideFixersPriorityCases
*/
public function testFixersPriority(FixerInterface $first, FixerInterface $second)
{
$this->assertLessThan($first->getPriority(), $second->getPriority());
}

public function getFixersPriorityCases()
public function provideFixersPriorityCases()
{
$factory = new FixerFactory();
$factory->registerBuiltInFixers();
Expand Down
72 changes: 63 additions & 9 deletions tests/AutoReview/ProjectCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace PhpCsFixer\Tests\AutoReview;

use PhpCsFixer\DocBlock\DocBlock;
use PhpCsFixer\Tokenizer\Tokens;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
Expand Down Expand Up @@ -73,7 +74,7 @@ function ($class) { return !class_exists($class) && !trait_exists($class); }
/**
* @param string $className
*
* @dataProvider provideSrcConcreteClasses
* @dataProvider provideSrcConcreteClassCases
*/
public function testThatSrcClassHaveTestClass($className)
{
Expand All @@ -91,7 +92,7 @@ public function testThatSrcClassHaveTestClass($className)
/**
* @param string $className
*
* @dataProvider provideSrcClassesNotAbuseInterfaces
* @dataProvider provideSrcClassesNotAbuseInterfacesCases
*/
public function testThatSrcClassesNotAbuseInterfaces($className)
{
Expand Down Expand Up @@ -151,7 +152,7 @@ function (\ReflectionClass $interface) {
/**
* @param string $className
*
* @dataProvider provideSrcClasses
* @dataProvider provideSrcClassCases
*/
public function testThatSrcClassesNotExposeProperties($className)
{
Expand Down Expand Up @@ -219,7 +220,7 @@ public function testThatSrcClassesNotExposeProperties($className)
/**
* @param string $className
*
* @dataProvider provideTestClasses
* @dataProvider provideTestClassCases
*/
public function testThatTestClassesAreTraitOrAbstractOrFinal($className)
{
Expand All @@ -234,7 +235,7 @@ public function testThatTestClassesAreTraitOrAbstractOrFinal($className)
/**
* @param string $className
*
* @dataProvider provideTestClasses
* @dataProvider provideTestClassCases
*/
public function testThatTestClassesAreInternal($className)
{
Expand All @@ -247,7 +248,22 @@ public function testThatTestClassesAreInternal($className)
);
}

public function provideSrcClasses()
/**
* @dataProvider provideDataProviderMethodNameCases
*
* @param string $testClassName
* @param string $dataProviderMethodName
*/
public function testThatDataProvidersAreCorrectlyNamed($testClassName, $dataProviderMethodName)
{
$this->assertRegExp('/^provide[A-Z]\S+Cases$/', $dataProviderMethodName, sprintf(
'Data provider in "%s" with name "%s" is not correctly named.',
$testClassName,
$dataProviderMethodName
));
}

public function provideSrcClassCases()
{
return array_map(
function ($item) {
Expand All @@ -257,7 +273,7 @@ function ($item) {
);
}

public function provideSrcClassesNotAbuseInterfaces()
public function provideSrcClassesNotAbuseInterfacesCases()
{
return array_map(
function ($item) {
Expand Down Expand Up @@ -291,7 +307,7 @@ function ($item) {
);
}

public function provideSrcConcreteClasses()
public function provideSrcConcreteClassCases()
{
return array_map(
function ($item) { return [$item]; },
Expand All @@ -306,7 +322,7 @@ function ($className) {
);
}

public function provideTestClasses()
public function provideTestClassCases()
{
return array_map(
function ($item) {
Expand All @@ -316,6 +332,44 @@ function ($item) {
);
}

public function provideDataProviderMethodNameCases()
{
$data = [];

$testClassNames = $this->getTestClasses();

foreach ($testClassNames as $testClassName) {
$dataProviderMethodNames = [];
$tokens = Tokens::fromCode(file_get_contents(
str_replace('\\', DIRECTORY_SEPARATOR, preg_replace('#^PhpCsFixer\\\Tests#', 'tests', $testClassName)).'.php'
));

foreach ($tokens as $token) {
if ($token->isGivenKind(T_DOC_COMMENT)) {
$docBlock = new DocBlock($token->getContent());
$dataProviderAnnotations = $docBlock->getAnnotationsOfType('dataProvider');

foreach ($dataProviderAnnotations as $dataProviderAnnotation) {
if (1 === preg_match('/@dataProvider\s+(?P<methodName>\w+)/', $dataProviderAnnotation->getContent(), $matches)) {
$dataProviderMethodNames[] = $matches['methodName'];
}
}
}
}

$dataProviderMethodNames = array_unique($dataProviderMethodNames);

foreach ($dataProviderMethodNames as $dataProviderMethodName) {
$data[] = [
$testClassName,
$dataProviderMethodName,
];
}
}

return $data;
}

private function getSrcClasses()
{
static $files;
Expand Down
4 changes: 2 additions & 2 deletions tests/AutoReview/TransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class TransformerTest extends TestCase
/**
* @param TransformerInterface $transformer
*
* @dataProvider provideTransformers
* @dataProvider provideTransformerCases
*/
public function testTransformersAreFinal(TransformerInterface $transformer)
{
Expand All @@ -44,7 +44,7 @@ public function testTransformersAreFinal(TransformerInterface $transformer)
/**
* @return TransformerInterface[]
*/
public function provideTransformers()
public function provideTransformerCases()
{
static $transformersArray = null;

Expand Down
4 changes: 2 additions & 2 deletions tests/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function testFromJsonThrowsInvalidArgumentExceptionIfJsonIsInvalid()
}

/**
* @dataProvider providerMissingData
* @dataProvider provideMissingDataCases
*
* @param array $data
*/
Expand All @@ -131,7 +131,7 @@ public function testFromJsonThrowsInvalidArgumentExceptionIfJsonIsMissingKey(arr
/**
* @return array
*/
public function providerMissingData()
public function provideMissingDataCases()
{
$data = [
'php' => '7.1.2',
Expand Down
4 changes: 2 additions & 2 deletions tests/CiIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function tearDown()
* @param string[] $expectedResult2Lines
* @param string $expectedResult3Files
*
* @dataProvider getIntegrationCases
* @dataProvider provideIntegrationCases
*/
public function testIntegration(
$branchName,
Expand Down Expand Up @@ -168,7 +168,7 @@ public function testIntegration(
$this->assertSame(0, $result3['code']);
}

public function getIntegrationCases()
public function provideIntegrationCases()
{
return [
[
Expand Down
12 changes: 6 additions & 6 deletions tests/Console/ConfigurationResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function testResolveProgressWithNegativeConfigAndNegativeOption()
/**
* @param string $progressType
*
* @dataProvider getProgressTypeCases
* @dataProvider provideProgressTypeCases
*/
public function testResolveProgressWithPositiveConfigAndExplicitProgress($progressType)
{
Expand All @@ -147,7 +147,7 @@ public function testResolveProgressWithPositiveConfigAndExplicitProgress($progre
/**
* @param string $progressType
*
* @dataProvider getProgressTypeCases
* @dataProvider provideProgressTypeCases
*/
public function testResolveProgressWithNegativeConfigAndExplicitProgress($progressType)
{
Expand All @@ -166,7 +166,7 @@ public function testResolveProgressWithNegativeConfigAndExplicitProgress($progre
$this->assertSame($progressType, $resolver->getProgress());
}

public function getProgressTypeCases()
public function provideProgressTypeCases()
{
return [
['none'],
Expand Down Expand Up @@ -699,7 +699,7 @@ public function testResolveIsDryRunViaPositiveOption()
* @param bool $configValue
* @param null|bool|string $passed
*
* @dataProvider getResolveBooleanOptions
* @dataProvider provideResolveBooleanOptionCases
*/
public function testResolveUsingCacheWithConfigOption($expected, $configValue, $passed)
{
Expand Down Expand Up @@ -804,7 +804,7 @@ public function testResolveCacheFileWithConfigAndOption()
* @param bool $configValue
* @param null|bool|string $passed
*
* @dataProvider getResolveBooleanOptions
* @dataProvider provideResolveBooleanOptionCases
*/
public function testResolveAllowRiskyWithConfigOption($expected, $configValue, $passed)
{
Expand Down Expand Up @@ -1049,7 +1049,7 @@ public function testDeprecationOfPassingOtherThanNoOrYes()
$this->assertFalse($resolver->getRiskyAllowed());
}

public function getResolveBooleanOptions()
public function provideResolveBooleanOptionCases()
{
return [
[true, true, 'yes'],
Expand Down
8 changes: 4 additions & 4 deletions tests/Console/Output/ProcessOutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class ProcessOutputTest extends TestCase
* @param array $statuses
* @param string $expectedOutput
*
* @dataProvider getProcessProgressOutputCases
* @dataProvider provideProcessProgressOutputCases
*/
public function testProcessProgressOutput(array $statuses, $expectedOutput)
{
Expand All @@ -45,7 +45,7 @@ public function testProcessProgressOutput(array $statuses, $expectedOutput)
$this->assertSame($expectedOutput, $output->fetch());
}

public function getProcessProgressOutputCases()
public function provideProcessProgressOutputCases()
{
return [
[
Expand Down Expand Up @@ -100,7 +100,7 @@ public function getProcessProgressOutputCases()
* @param array $statuses
* @param string $expectedOutput
*
* @dataProvider getProcessProgressOutputWithNumbersCases
* @dataProvider provideProcessProgressOutputWithNumbersCases
*/
public function testProcessProgressOutputWithNumbers(array $statuses, $expectedOutput)
{
Expand All @@ -122,7 +122,7 @@ public function testProcessProgressOutputWithNumbers(array $statuses, $expectedO
$this->assertSame($expectedOutput, $output->fetch());
}

public function getProcessProgressOutputWithNumbersCases()
public function provideProcessProgressOutputWithNumbersCases()
{
return [
[
Expand Down
8 changes: 4 additions & 4 deletions tests/DocBlock/AnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ final class AnnotationTest extends TestCase
* @param int $index
* @param string $content
*
* @dataProvider provideContent
* @dataProvider provideGetContentCases
*/
public function testGetContent($index, $content)
{
Expand All @@ -98,7 +98,7 @@ public function testGetContent($index, $content)
$this->assertSame($content, (string) $annotation);
}

public function provideContent()
public function provideGetContentCases()
{
$cases = [];

Expand Down Expand Up @@ -163,7 +163,7 @@ public function provideEndCases()
* @param int $index
* @param string $tag
*
* @dataProvider provideTags
* @dataProvider provideGetTagCases
*/
public function testGetTag($index, $tag)
{
Expand All @@ -173,7 +173,7 @@ public function testGetTag($index, $tag)
$this->assertSame($tag, $annotation->getTag()->getName());
}

public function provideTags()
public function provideGetTagCases()
{
$cases = [];

Expand Down
Loading

0 comments on commit c660329

Please sign in to comment.