Documentation

ESLintUnitTest extends AbstractSniffUnitTest
in package

FinalYes

Unit test class for the ESLint sniff.

Tags
covers

Table of Contents

Constants

ESLINT_CONFIG  = '{ "parserOptions": { "ecmaVersion": 5, "sourceType": "script", "ecmaFeatures": {} }, "rules": { "no-undef": 2, "no-unused-vars": 2 } }'
Basic ESLint config to use for testing the sniff.

Properties

$standardsDir  : string
The path to the standard's main directory.
$testsDir  : string
The path to the standard's test directory.
$backupGlobals  : bool
Enable or disable the backup and restoration of the $GLOBALS array.

Methods

generateFailureMessages()  : array<string|int, mixed>
Generate a list of test failures for a given sniffed file.
getErrorList()  : array<int, int>
Returns the lines where errors should occur.
getWarningList()  : array<int, int>
Returns the lines where warnings should occur.
setCliValues()  : void
Get a list of CLI values to set before the file is tested.
testSniff()  : void
Tests the extending classes Sniff class.
getTestFiles()  : array<string|int, string>
Get a list of all test files to check.
resetProperties()  : void
Remove artifact.
setUpPrerequisites()  : void
Sets up this unit test.
shouldSkipTest()  : bool
Should this test be skipped for some reason.

Constants

ESLINT_CONFIG

Basic ESLint config to use for testing the sniff.

public string ESLINT_CONFIG = '{ "parserOptions": { "ecmaVersion": 5, "sourceType": "script", "ecmaFeatures": {} }, "rules": { "no-undef": 2, "no-unused-vars": 2 } }'

Properties

$backupGlobals

Enable or disable the backup and restoration of the $GLOBALS array.

protected bool $backupGlobals = false

Overwrite this attribute in a child class of TestCase. Setting this attribute in setUp() has no effect!

Methods

generateFailureMessages()

Generate a list of test failures for a given sniffed file.

public generateFailureMessages(LocalFile $file) : array<string|int, mixed>
Parameters
$file : LocalFile

The file being tested.

Tags
throws
RuntimeException
Return values
array<string|int, mixed>

getErrorList()

Returns the lines where errors should occur.

public getErrorList() : array<int, int>

The key of the array should represent the line number and the value should represent the number of errors that should occur on that line.

Return values
array<int, int>

getWarningList()

Returns the lines where warnings should occur.

public getWarningList() : array<int, int>

The key of the array should represent the line number and the value should represent the number of warnings that should occur on that line.

Return values
array<int, int>

setCliValues()

Get a list of CLI values to set before the file is tested.

public setCliValues(string $filename, Config $config) : void
Parameters
$filename : string

The name of the file being tested.

$config : Config

The config data for the run.

testSniff()

Tests the extending classes Sniff class.

public final testSniff() : void
Tags
throws
Exception

getTestFiles()

Get a list of all test files to check.

protected getTestFiles(string $testFileBase) : array<string|int, string>

These will have the same base as the sniff name but different extensions. We ignore the .php file as it is the class.

Parameters
$testFileBase : string

The base path that the unit tests files will have.

Return values
array<string|int, string>

resetProperties()

Remove artifact.

protected resetProperties() : void
Tags
after

setUpPrerequisites()

Sets up this unit test.

protected setUpPrerequisites() : void
Tags
before

shouldSkipTest()

Should this test be skipped for some reason.

protected shouldSkipTest() : bool
Return values
bool

        
On this page

Search results