Documentation

GitModifiedTest extends AbstractFilterTestCase
in package

FinalYes

Tests for the \PHP_CodeSniffer\Filters\GitModified class.

Tags
covers

Table of Contents

Properties

$config  : Config
The Config object.
$ruleset  : Ruleset
The Ruleset object.

Methods

dataAcceptOnlyGitModified()  : array<string, array<string, array<string|int, string>>>
Data provider.
dataExecAlwaysReturnsArray()  : array<string, array<string, string|array<string|int, string>>>
Data provider.
initializeConfigAndRuleset()  : void
Initialize the config and ruleset objects.
testAcceptOnlyGitModified()  : void
Test filtering a file list for excluded paths.
testExecAlwaysReturnsArray()  : void
Test filtering a file list for excluded paths.
testFileNamePassesAsBasePathWillTranslateToDirname()  : void
Test filtering a file list for excluded paths.
getBaseDir()  : string
Retrieve the basedir to use for tests using the `getFakeFileList()` method.
getFakeFileList()  : array<string|int, string>
Retrieve a file list containing a range of paths for testing purposes.
getFilteredResultsAsArray()  : array<string|int, string>
Retrieve an array of files which were accepted by a filter.
getMockedClass()  : MockObject
Helper method to retrieve a mock object for a Filter class.
mapPathsToRuntimeOs()  : array<string|int, string|array<string|int, mixed>>
Translate Linux paths to Windows paths, when necessary.

Properties

Methods

dataAcceptOnlyGitModified()

Data provider.

public static dataAcceptOnlyGitModified() : array<string, array<string, array<string|int, string>>>
Tags
see
testAcceptOnlyGitModified
Return values
array<string, array<string, array<string|int, string>>>

dataExecAlwaysReturnsArray()

Data provider.

public static dataExecAlwaysReturnsArray() : array<string, array<string, string|array<string|int, string>>>
Tags
see
testExecAlwaysReturnsArray
Return values
array<string, array<string, string|array<string|int, string>>>

initializeConfigAndRuleset()

Initialize the config and ruleset objects.

public static initializeConfigAndRuleset() : void
Tags
beforeClass

testAcceptOnlyGitModified()

Test filtering a file list for excluded paths.

public testAcceptOnlyGitModified(array<string|int, string> $inputPaths, array<string|int, string> $outputGitModified, array<string|int, string> $expectedOutput) : void
Parameters
$inputPaths : array<string|int, string>

List of file paths to be filtered.

$outputGitModified : array<string|int, string>

Simulated "git modified" output.

$expectedOutput : array<string|int, string>

Expected filtering result.

Tags
dataProvider

dataAcceptOnlyGitModified

testExecAlwaysReturnsArray()

Test filtering a file list for excluded paths.

public testExecAlwaysReturnsArray(string $cmd, array<string|int, string> $expected) : void
Parameters
$cmd : string

Command to run.

$expected : array<string|int, string>

Expected return value.

Tags
dataProvider

dataExecAlwaysReturnsArray

testFileNamePassesAsBasePathWillTranslateToDirname()

Test filtering a file list for excluded paths.

public testFileNamePassesAsBasePathWillTranslateToDirname() : void

getBaseDir()

Retrieve the basedir to use for tests using the `getFakeFileList()` method.

protected static getBaseDir() : string
Return values
string

getFakeFileList()

Retrieve a file list containing a range of paths for testing purposes.

protected static getFakeFileList() : array<string|int, string>

This list must contain files which exist in this project (well, except for some which don't exist purely for testing purposes), as realpath() is used in the logic under test and realpath() will return false for any non-existent files, which will automatically filter them out before we get to the code under test.

Note this list does not include . and .. as \PHP_CodeSniffer\Files\FileList uses SKIP_DOTS.

Return values
array<string|int, string>

getFilteredResultsAsArray()

Retrieve an array of files which were accepted by a filter.

protected getFilteredResultsAsArray(Filter $filter) : array<string|int, string>
Parameters
$filter : Filter

The Filter object under test.

Return values
array<string|int, string>

getMockedClass()

Helper method to retrieve a mock object for a Filter class.

protected getMockedClass(string $className[, array<string|int, mixed> $constructorArgs = [] ][, array<string|int, string>|null $methodsToMock = null ]) : MockObject

The setMethods() method was silently deprecated in PHPUnit 9 and removed in PHPUnit 10.

Note: direct access to the getMockBuilder() method is soft deprecated as of PHPUnit 10, and expected to be hard deprecated in PHPUnit 11 and removed in PHPUnit 12. Dealing with that is something for a later iteration of the test suite.

Parameters
$className : string

Fully qualified name of the class under test.

$constructorArgs : array<string|int, mixed> = []

Optional. Array of parameters to pass to the class constructor.

$methodsToMock : array<string|int, string>|null = null

Optional. The methods to mock in the class under test. Needed for PHPUnit cross-version support as PHPUnit 4.x does not have a setMethodsExcept() method yet. If not passed, no methods will be replaced.

Return values
MockObject

mapPathsToRuntimeOs()

Translate Linux paths to Windows paths, when necessary.

protected static mapPathsToRuntimeOs(array<string|int, string|array<string|int, mixed>> $paths) : array<string|int, string|array<string|int, mixed>>

These type of tests should be able to run and pass on both *nix as well as Windows based dev systems. This method is a helper to allow for this.

Parameters
$paths : array<string|int, string|array<string|int, mixed>>

A single or multi-dimensional array containing file paths.

Return values
array<string|int, string|array<string|int, mixed>>

        
On this page

Search results