mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Fixes --version and --help
This commit is contained in:
@ -1,5 +1,103 @@
|
||||
Pest Options:
|
||||
--init Initialise a standard Pest configuration
|
||||
--coverage Enable coverage and output to standard output
|
||||
--min=<N> Set the minimum required coverage percentage (<N>), and fail if not met
|
||||
--group=<name> Only runs tests from the specified group(s)
|
||||
|
||||
Pest Testing Framework 2.x-dev.
|
||||
|
||||
USAGE: pest <file> [options]
|
||||
|
||||
CONFIGURATION:
|
||||
--init ............................ Initialise a standard Pest configuration
|
||||
-c|--configuration <file> ....................... Read configuration from XML file
|
||||
--no-configuration ......... Ignore default configuration file (phpunit.xml)
|
||||
--no-extensions ............................. Do not load PHPUnit extensions
|
||||
--include-path <path(s)> ..... Prepend PHP's include_path with given path(s)
|
||||
-d <key[=value]> ...................................... Sets a php.ini value
|
||||
--cache-directory <dir> ................................. Specify cache directory
|
||||
--generate-configuration Generate configuration file with suggested settings
|
||||
--migrate-configuration ....... Migrate configuration file to current format
|
||||
|
||||
SELECTION:
|
||||
--list-suites ................................... List available test suites
|
||||
--testsuite <name> ............... Only run tests from the specified test suite(s)
|
||||
--exclude-testsuite <name> ........ Exclude tests from the specified test suite(s)
|
||||
--list-groups ................................... List available test groups
|
||||
--group <name> ........................ Only run tests from the specified group(s)
|
||||
--exclude-group <name> ................. Exclude tests from the specified group(s)
|
||||
--covers <name> ......................... Only run tests annotated with "@covers <name>"
|
||||
--uses <name> ............................. Only run tests annotated with "@uses <name>"
|
||||
--list-tests .......................................... List available tests
|
||||
--list-tests-xml <file> ....................... List available tests in XML format
|
||||
--filter <pattern> ........................................ Filter which tests to run
|
||||
--test-suffix <suffixes> Only search for test in files with specified suffix(es). Default: Test.php,.phpt
|
||||
|
||||
EXECUTION:
|
||||
--process-isolation ................ Run each test in a separate PHP process
|
||||
--globals-backup ................. Backup and restore $GLOBALS for each test
|
||||
--static-backup ......... Backup and restore static properties for each test
|
||||
--strict-coverage . Be strict about code coverage attributes and annotations
|
||||
--strict-global-state .............. Be strict about changes to global state
|
||||
--disallow-test-output ................. Be strict about output during tests
|
||||
--enforce-time-limit ................. Enforce time limit based on test size
|
||||
--default-time-limit <sec> Timeout in seconds for tests that have no declared size
|
||||
--dont-report-useless-tests .. Do not report tests that do not test anything
|
||||
--stop-on-defect ................. Stop execution upon first not-passed test
|
||||
--stop-on-error ............................ Stop execution upon first error
|
||||
--stop-on-failure ............... Stop execution upon first error or failure
|
||||
--stop-on-warning ........................ Stop execution upon first warning
|
||||
--stop-on-risky ....................... Stop execution upon first risky test
|
||||
--stop-on-skipped ................... Stop execution upon first skipped test
|
||||
--stop-on-incomplete ............. Stop execution upon first incomplete test
|
||||
--fail-on-incomplete .................... Treat incomplete tests as failures
|
||||
--fail-on-risky .............................. Treat risky tests as failures
|
||||
--fail-on-skipped .......................... Treat skipped tests as failures
|
||||
--fail-on-warning .................... Treat tests with warnings as failures
|
||||
--repeat <times> ...................................... Runs the test(s) repeatedly
|
||||
--cache-result ............................ Write test results to cache file
|
||||
--do-not-cache-result .............. Do not write test results to cache file
|
||||
--order-by <order> Run tests in order: default|defects|duration|no-depends|random|reverse|size
|
||||
--random-order-seed <N> .......... Use a specific random seed <N> for random order
|
||||
|
||||
REPORTING:
|
||||
--colors <flag> ............... Use colors in output ("never", "auto" or "always")
|
||||
--columns <n> .................... Number of columns to use for progress output
|
||||
--columns max ............ Use maximum number of columns for progress output
|
||||
--stderr ................................. Write to STDERR instead of STDOUT
|
||||
--display-incomplete .................. Display details for incomplete tests
|
||||
--display-skipped ........................ Display details for skipped tests
|
||||
--display-deprecations . Display details for deprecations triggered by tests
|
||||
--display-errors ............. Display details for errors triggered by tests
|
||||
--display-notices ........... Display details for notices triggered by tests
|
||||
--display-warnings ......... Display details for warnings triggered by tests
|
||||
--reverse-list .............................. Print defects in reverse order
|
||||
--teamcity ............... Report test execution progress in TeamCity format
|
||||
--testdox ................. Report test execution progress in TestDox format
|
||||
--no-interaction ........................ Disable TestDox progress animation
|
||||
|
||||
LOGGING:
|
||||
--log-junit <file> ................ Log test execution in JUnit XML format to file
|
||||
--log-teamcity <file> .............. Log test execution in TeamCity format to file
|
||||
--testdox-html <file> ........... Write agile documentation in HTML format to file
|
||||
--testdox-text <file> ........... Write agile documentation in Text format to file
|
||||
--testdox-xml <file> ............. Write agile documentation in XML format to file
|
||||
--log-events-text <file> ..................... Stream events as plain text to file
|
||||
--log-events-verbose-text <file> Stream events as plain text to file (with telemetry information)
|
||||
--no-logging .................................. Ignore logging configuration
|
||||
|
||||
CODE COVERAGE:
|
||||
--coverage ..... Generate code coverage report and output to standard output
|
||||
--coverage --min Set the minimum required coverage percentage, and fail if not met
|
||||
--coverage-crap4j <file> ...... Generate code coverage report in Crap4J XML format
|
||||
--coverage-html <dir> .............. Generate code coverage report in HTML format
|
||||
--coverage-php <file> ..................... Export PHP_CodeCoverage object to file
|
||||
--coverage-text=<file> Generate code coverage report in text format [default: standard output]
|
||||
--coverage-xml <dir> ........ Generate code coverage report in PHPUnit XML format
|
||||
--warm-coverage-cache ........................... Warm static analysis cache
|
||||
--coverage-filter <dir> ...................... Include <dir> in code coverage analysis
|
||||
--path-coverage ............................. Perform path coverage analysis
|
||||
--disable-coverage-ignore Disable attributes and annotations for ignoring code coverage
|
||||
--no-coverage ........................... Ignore code coverage configuration
|
||||
|
||||
MISCELLANEOUS:
|
||||
-h|--help .................................... Prints this usage information
|
||||
--version ..................................... Prints the version and exits
|
||||
--atleast-version <min> ....... Checks that version is greater than min and exits
|
||||
--check-version ................ Check whether PHPUnit is the latest version
|
||||
|
||||
|
||||
@ -729,10 +729,6 @@
|
||||
PASS Tests\Unit\Plugins\Retry
|
||||
✓ it retries if --retry argument is used
|
||||
|
||||
PASS Tests\Unit\Plugins\Version
|
||||
✓ it outputs the version when --version is used
|
||||
✓ it do not outputs version when --version is not used
|
||||
|
||||
PASS Tests\Unit\Support\Backtrace
|
||||
✓ it gets file name from called file
|
||||
|
||||
@ -756,8 +752,8 @@
|
||||
✓ it can filter the test suite filenames to those with the only method
|
||||
✓ it does not filter the test suite filenames to those with the only method when working in CI pipeline
|
||||
|
||||
WARN Tests\Visual\Help
|
||||
- visual snapshot of help command output → Not supported yet.
|
||||
PASS Tests\Visual\Help
|
||||
✓ visual snapshot of help command output
|
||||
|
||||
WARN Tests\Visual\JUnit
|
||||
- it is can successfully call all public methods → Not supported yet.
|
||||
@ -773,4 +769,7 @@
|
||||
WARN Tests\Visual\TeamCity
|
||||
- it is can successfully call all public methods → Not supported yet.
|
||||
|
||||
Tests: 4 incomplete, 1 todo, 19 skipped, 514 passed (1289 assertions)
|
||||
PASS Tests\Visual\Version
|
||||
✓ visual snapshot of help command output
|
||||
|
||||
Tests: 4 incomplete, 1 todo, 18 skipped, 514 passed (1289 assertions)
|
||||
|
||||
3
tests/.snapshots/version-command.txt
Normal file
3
tests/.snapshots/version-command.txt
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
Pest Testing Framework 2.x-dev.
|
||||
|
||||
@ -11,19 +11,19 @@ it('adds coverage if --coverage exist', function () {
|
||||
|
||||
expect($plugin->coverage)->toBeFalse();
|
||||
$arguments = $plugin->handleArguments([]);
|
||||
expect($arguments)->toEqual([]);
|
||||
expect($plugin->coverage)->toBeFalse();
|
||||
expect($arguments)->toEqual([])
|
||||
->and($plugin->coverage)->toBeFalse();
|
||||
|
||||
$arguments = $plugin->handleArguments(['--coverage']);
|
||||
expect($arguments)->toEqual(['--coverage-php', Coverage::getPath()]);
|
||||
expect($plugin->coverage)->toBeTrue();
|
||||
expect($arguments)->toEqual(['--coverage-php', Coverage::getPath()])
|
||||
->and($plugin->coverage)->toBeTrue();
|
||||
})->skip(! \Pest\Support\Coverage::isAvailable() || ! in_array('coverage', xdebug_info('mode'), true), 'Coverage is not available');
|
||||
|
||||
it('adds coverage if --min exist', function () {
|
||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
||||
expect($plugin->coverageMin)->toEqual(0.0);
|
||||
expect($plugin->coverageMin)->toEqual(0.0)
|
||||
->and($plugin->coverage)->toBeFalse();
|
||||
|
||||
expect($plugin->coverage)->toBeFalse();
|
||||
$plugin->handleArguments([]);
|
||||
expect($plugin->coverageMin)->toEqual(0.0);
|
||||
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Pest\Plugins\Version;
|
||||
use function Pest\version;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
it('outputs the version when --version is used', function () {
|
||||
$output = new BufferedOutput();
|
||||
$plugin = new Version($output);
|
||||
|
||||
$plugin->handleArguments(['foo', '--version']);
|
||||
expect($output->fetch())->toContain('Pest '.version());
|
||||
});
|
||||
|
||||
it('do not outputs version when --version is not used', function () {
|
||||
$output = new BufferedOutput();
|
||||
$plugin = new Version($output);
|
||||
|
||||
$plugin->handleArguments(['foo', 'bar']);
|
||||
expect($output->fetch())->toBe('');
|
||||
});
|
||||
@ -1,20 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Pest\Console\Help;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
test('visual snapshot of help command output', function () {
|
||||
$snapshot = __DIR__.'/../.snapshots/help-command.txt';
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
$outputBuffer = new BufferedOutput();
|
||||
$plugin = new Help($outputBuffer);
|
||||
|
||||
$plugin();
|
||||
|
||||
file_put_contents($snapshot, $outputBuffer->fetch());
|
||||
}
|
||||
|
||||
$output = function () {
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
|
||||
|
||||
@ -23,5 +11,11 @@ test('visual snapshot of help command output', function () {
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
file_put_contents($snapshot, $output());
|
||||
|
||||
$this->markTestSkipped('Snapshot rebuilt.');
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows')->skip('Not supported yet.');
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
|
||||
21
tests/Visual/Version.php
Normal file
21
tests/Visual/Version.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
test('visual snapshot of help command output', function () {
|
||||
$snapshot = __DIR__.'/../.snapshots/version-command.txt';
|
||||
|
||||
$output = function () {
|
||||
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--version'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']));
|
||||
|
||||
$process->run();
|
||||
|
||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
|
||||
};
|
||||
|
||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||
file_put_contents($snapshot, $output());
|
||||
|
||||
$this->markTestSkipped('Snapshot rebuilt.');
|
||||
}
|
||||
|
||||
expect($output())->toContain(file_get_contents($snapshot));
|
||||
})->skip(PHP_OS_FAMILY === 'Windows');
|
||||
Reference in New Issue
Block a user