HelpTest
extends TestCase
in package
Test the Help class.
Tags
Table of Contents
Methods
- dataColorizeVariableInput() : array<string, array<string, string|array<string|int, string>>>
- Data provider.
- dataDisplayUsage() : array<string, array<string, string|array<string|int, string>>>
- Data provider.
- dataOptionFiltering() : array<string, array<string, string|array<string|int, string>|array<string, int>>>
- Data provider.
- dataOptionFilteringSpacerHandling() : array<string, array<string, string|array<string|int, string>>>
- Data provider.
- dataPrintCategoryOptions() : array<string, array<string, array<string, array<string, string>>|array<string, string>>>
- Data provider.
- dataReportWidthCalculations() : array<string, array<string, int|string|array<string|int, string>>>
- Data provider.
- testColorizeVariableInput() : void
- Verify that variable elements in an argument specification get colorized correctly.
- testConstructorInvalidArgumentException() : void
- Test receiving an expected exception when the shortOptions parameter is not passed a string value.
- testDisplayUsage() : void
- Test that if no short/long options are passed, only usage information is displayed (and displayed correctly).
- testOptionFiltering() : void
- Test filtering of the options by requested options.
- testOptionFilteringSpacerHandling() : void
- Test filtering of the options by requested options does not leave stray spacers at the start or end of a category and that a category does not contain two consecutive spacers.
- testPrintCategoryOptionsColor() : void
- Test the various option types within a category get displayed correctly.
- testPrintCategoryOptionsNoColor() : void
- Test the various option types within a category get displayed correctly.
- testQaArgumentNamesAreWithinAcceptableBounds() : void
- QA check: verify that the category names are at most the minimum screen width and that option argument names are always at most half the length of the minimum screen width.
- testQaValidCategoryOptionDefinitions() : void
- QA check: verify that each option only contains a spacer, text or argument + description combo.
- testReportWidthCalculations() : void
- Test the column width calculations.
Methods
dataColorizeVariableInput()
Data provider.
public
static dataColorizeVariableInput() : array<string, array<string, string|array<string|int, string>>>
Return values
array<string, array<string, string|array<string|int, string>>>dataDisplayUsage()
Data provider.
public
static dataDisplayUsage() : array<string, array<string, string|array<string|int, string>>>
Return values
array<string, array<string, string|array<string|int, string>>>dataOptionFiltering()
Data provider.
public
static dataOptionFiltering() : array<string, array<string, string|array<string|int, string>|array<string, int>>>
Return values
array<string, array<string, string|array<string|int, string>|array<string, int>>>dataOptionFilteringSpacerHandling()
Data provider.
public
static dataOptionFilteringSpacerHandling() : array<string, array<string, string|array<string|int, string>>>
Return values
array<string, array<string, string|array<string|int, string>>>dataPrintCategoryOptions()
Data provider.
public
static dataPrintCategoryOptions() : array<string, array<string, array<string, array<string, string>>|array<string, string>>>
Return values
array<string, array<string, array<string, array<string, string>>|array<string, string>>>dataReportWidthCalculations()
Data provider.
public
static dataReportWidthCalculations() : array<string, array<string, int|string|array<string|int, string>>>
Return values
array<string, array<string, int|string|array<string|int, string>>>testColorizeVariableInput()
Verify that variable elements in an argument specification get colorized correctly.
public
testColorizeVariableInput(string $input, string $expected) : void
Parameters
- $input : string
-
String to colorize.
- $expected : string
-
Expected function output.
Tags
testConstructorInvalidArgumentException()
Test receiving an expected exception when the shortOptions parameter is not passed a string value.
public
testConstructorInvalidArgumentException() : void
testDisplayUsage()
Test that if no short/long options are passed, only usage information is displayed (and displayed correctly).
public
testDisplayUsage(array<string|int, string> $cliArgs, string $expectedRegex) : void
Parameters
- $cliArgs : array<string|int, string>
-
Command line arguments.
- $expectedRegex : string
-
Regex to validate expected output.
Tags
testOptionFiltering()
Test filtering of the options by requested options.
public
testOptionFiltering(array<string|int, string> $longOptions, string $shortOptions, array<string, int> $expected) : void
Tests that:
- Options not explicitly requested are removed.
- Short options passed via the longOptions array are still respected.
- A category gets removed if all options are removed, even if the category still has spacers.
Parameters
- $longOptions : array<string|int, string>
-
The long options which should be displayed.
- $shortOptions : string
-
The short options which should be displayed.
- $expected : array<string, int>
-
The categories expected after filtering with the number of expected help items per category.
Tags
testOptionFilteringSpacerHandling()
Test filtering of the options by requested options does not leave stray spacers at the start or end of a category and that a category does not contain two consecutive spacers.
public
testOptionFilteringSpacerHandling(array<string|int, string> $longOptions, string $shortOptions) : void
Parameters
- $longOptions : array<string|int, string>
-
The long options which should be displayed.
- $shortOptions : string
-
The short options which should be displayed.
Tags
testPrintCategoryOptionsColor()
Test the various option types within a category get displayed correctly.
public
testPrintCategoryOptionsColor(array<string, array<string, string>> $input, array<string, string> $expectedRegex) : void
Parameters
- $input : array<string, array<string, string>>
-
The options to print.
- $expectedRegex : array<string, string>
-
Regexes to validate expected output.
Tags
testPrintCategoryOptionsNoColor()
Test the various option types within a category get displayed correctly.
public
testPrintCategoryOptionsNoColor(array<string, array<string, string>> $input, array<string, string> $expectedRegex) : void
Parameters
- $input : array<string, array<string, string>>
-
The options to print.
- $expectedRegex : array<string, string>
-
Regexes to validate expected output.
Tags
testQaArgumentNamesAreWithinAcceptableBounds()
QA check: verify that the category names are at most the minimum screen width and that option argument names are always at most half the length of the minimum screen width.
public
testQaArgumentNamesAreWithinAcceptableBounds() : void
If this test would start failing, either wrapping of argument info would need to be implemented or the minimum screen width needs to be upped.
Tags
testQaValidCategoryOptionDefinitions()
QA check: verify that each option only contains a spacer, text or argument + description combo.
public
testQaValidCategoryOptionDefinitions() : void
Tags
testReportWidthCalculations()
Test the column width calculations.
public
testReportWidthCalculations(int $reportWidth, array<string|int, string> $longOptions, string $expectedOutput) : void
This tests the following aspects:
- That the report width is never less than Help::MIN_WIDTH, even when a smaller width is passed.
- That the first column width is calculated correctly and is based on the longest argument.
- That the word wrapping of the description respects the maximum report width.
- That if the description is being wrapped, the indent for the second line is calculated correctly.
Parameters
- $reportWidth : int
-
Report width for the test.
- $longOptions : array<string|int, string>
-
The long options which should be displayed.
- $expectedOutput : string
-
Expected output.