PHP Class PhpCsFixer\Test\AbstractFixerTestCase

Author: Dariusz Rumiński ([email protected])
Inheritance: extends PHPUnit_Framework_TestCase
Exibir arquivo Open project: friendsofphp/php-cs-fixer Class Usage Examples

Protected Properties

Property Type Description
$fixer null | PhpCsFixer\Fixer\FixerInterface
$linter PhpCsFixer\Linter\LinterInterface

Protected Methods

Method Description
createFixer ( ) : PhpCsFixer\Fixer\FixerInterface
createFixerFactory ( ) : FixerFactory Create fixer factory with all needed fixers registered.
doTest ( string $expected, string | null $input = null, SplFileInfo $file = null ) Tests if a fixer fixes a given string to match the expected result.
getFixerName ( ) : string
getTestFile ( string $filename = __FILE__ ) : SplFileInfo
lintSource ( string $source ) : string | null
setUp ( )

Private Methods

Method Description
assertTokens ( Tokens $expectedTokens, Tokens $inputTokens )
getFixerClassName ( ) : string
getLinter ( ) : PhpCsFixer\Linter\LinterInterface

Method Details

createFixer() protected method

protected createFixer ( ) : PhpCsFixer\Fixer\FixerInterface
return PhpCsFixer\Fixer\FixerInterface

createFixerFactory() protected method

Create fixer factory with all needed fixers registered.
protected createFixerFactory ( ) : FixerFactory
return PhpCsFixer\FixerFactory

doTest() protected method

It is used both if you want to test if something is fixed or if it is not touched by the fixer. It also makes sure that the expected output does not change when run through the fixer. That means that you do not need two test cases like [$expected] and [$expected, $input] (where $expected is the same in both cases) as the latter covers both of them. This method throws an exception if $expected and $input are equal to prevent test cases that accidentally do not test anything.
protected doTest ( string $expected, string | null $input = null, SplFileInfo $file = null )
$expected string The expected fixer output
$input string | null The fixer input, or null if it should intentionally be equal to the output
$file SplFileInfo The file to fix, or null if unneeded

getFixerName() protected method

protected getFixerName ( ) : string
return string

getTestFile() protected method

protected getTestFile ( string $filename = __FILE__ ) : SplFileInfo
$filename string
return SplFileInfo

lintSource() protected method

protected lintSource ( string $source ) : string | null
$source string
return string | null

setUp() protected method

protected setUp ( )

Property Details

$fixer protected_oe property

protected null|FixerInterface,PhpCsFixer\Fixer $fixer
return null | PhpCsFixer\Fixer\FixerInterface

$linter protected_oe property

protected LinterInterface,PhpCsFixer\Linter $linter
return PhpCsFixer\Linter\LinterInterface