class Test

Supports unit test related console commands.

Constants

ALLOWED_OPTIONS

The array of options allowed as input for the test command.

FEATURE_PATH

The path for feature tests.

UNIT_PATH

The path for unit tests.

Properties

string $inputOptions

A string of input options provided as input when running the test command.

OutputInterface $output

The Symfony OutputInterface object.

Methods

__construct(InputInterface $input, OutputInterface $output)

Constructor

int
allTests()

Performs all tests.

static array
featureTests()

Returns array containing all filenames in Feature directory.

static string
makeFeatureTest(string $testName)

The template for a new Feature test class that extends ApplicationTestCase.

static int
makeTest(string $testName, InputInterface $input)

Creates a new test class. When --feature flag is provided a test feature class is created.

static string
makeUnitTest(string $testName)

The template for a new Unit Test class that extends TestCase.

static string
parseOptions(InputInterface $input)

Parses PHPUnit related arguments and ignore Symfony arguments.

void
runTest(string $tests)

Runs the unit test contained in the TestCase class.

int
selectTests(string $testArg)

Supports ability to run test by class name or function name within a class.

void
singleFileWithinSuite(string $testArg, string $suite = self::UNIT_PATH)

Performs testing against a single class within a test suite.

static bool
testIfExists(string $name)

Checks if file exists in either test suite.

static bool
testIfSame(string $name)

Enforces rule that classes/files across test suites should be unique.

int
testSuite(array $collection)

Run all test files in an individual test suite.

static bool
testSuiteStatus(int|null $featureStatus, int|null $unitStatus)

Determines if execution of a test suite(s) is successful.

static array
unitTests()

Returns array containing all filenames in Unit directory.

Details

at line 70
__construct(InputInterface $input, OutputInterface $output)

Constructor

Parameters

InputInterface $input

The Symfony InputInterface object.

OutputInterface $output

The Symfony OutputInterface object.

at line 80
int allTests()

Performs all tests.

Return Value

int

A value that indicates success, invalid, or failure.

at line 101
static array featureTests()

Returns array containing all filenames in Feature directory.

Return Value

array

The array of all filenames in the Feature directory.

at line 111
static string makeFeatureTest(string $testName)

The template for a new Feature test class that extends ApplicationTestCase.

Parameters

string $testName

The name of the TestCase class.

Return Value

string

The contents for the new TestCase class.

at line 143
static int makeTest(string $testName, InputInterface $input)

Creates a new test class. When --feature flag is provided a test feature class is created.

Parameters

string $testName

The name for the test.

InputInterface $input

The Symfony InputInterface object.

Return Value

int

A value that indicates success, invalid, or failure.

at line 171
static string makeUnitTest(string $testName)

The template for a new Unit Test class that extends TestCase.

Parameters

string $testName

The name of the TestCase class.

Return Value

string

The contents for the new TestCase class.

at line 201
static string parseOptions(InputInterface $input)

Parses PHPUnit related arguments and ignore Symfony arguments.

Parameters

InputInterface $input

Instance of InputInterface from command.

Return Value

string

A string containing the arguments to be provided to PHPUnit.

at line 274
void runTest(string $tests)

Runs the unit test contained in the TestCase class.

Parameters

string $tests

The test to be performed.

Return Value

void

at line 287
int selectTests(string $testArg)

Supports ability to run test by class name or function name within a class.

Parameters

string $testArg

The name of the class or class::test_name.

Return Value

int

A value that indicates success, invalid, or failure.

at line 334
void singleFileWithinSuite(string $testArg, string $suite = self::UNIT_PATH)

Performs testing against a single class within a test suite.

Parameters

string $testArg

The name of the test class.

string $suite

The name of the test suite.

Return Value

void

at line 350
static bool testIfExists(string $name)

Checks if file exists in either test suite.

Parameters

string $name

The name of the file to be created.

Return Value

bool

True if file exists in either test suite, otherwise we return false.

at line 366
static bool testIfSame(string $name)

Enforces rule that classes/files across test suites should be unique.

Parameters

string $name

The name of the test class to be executed.

Return Value

bool

True if class/file exists across both test suites, otherwise we return false.

at line 381
int testSuite(array $collection)

Run all test files in an individual test suite.

Parameters

array $collection

All classes in a particular test suite.

Return Value

int

A value that indicates success, invalid, or failure.

at line 401
static bool testSuiteStatus(int|null $featureStatus, int|null $unitStatus)

Determines if execution of a test suite(s) is successful.

Parameters

int|null $featureStatus

Tracks if feature test are successful.

int|null $unitStatus

Tracks if unit test are successful.

Return Value

bool

True if successful, otherwise we return false.

at line 411
static array unitTests()

Returns array containing all filenames in Unit directory.

Return Value

array

The array of all filenames in the Unit directory.