Download the PHP package automattic/patchwork-redefine-exit without Composer

On this page you can find all versions of the php package automattic/patchwork-redefine-exit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package patchwork-redefine-exit

automattic/patchwork-redefine-exit

This package uses antecedent/patchwork to redefine exit and die for more robust PHPUnit testing.

Installation

Require using composer require --dev automattic/patchwork-redefine-exit.

Configuration

You'll need to configure Patchwork to allow redefining of exit() and die() by setting redefinable-internals in your patchwork.json. At minimum that would look like this:

(you can place patchwork.json in the same directory as your PHPUnit boostrap file).

You'll also need to configure PHPUnit to load Patchwork and this package, which is normally done by including something like this in your PHPUnit boostrap file.

Use with other testing frameworks

For other testing frameworks, you'll need to use a bootstrap file or similar mechanism to load Patchwork before any code under test is loaded, and call Automattic\RedefineExit::setup() before any tests are run.

If the testing framework itself calls exit or die in a manner that gets caught incorrectly (e.g. to terminate with an appropriate exit code at the end of the test run), you may subclass Automattic\RedefineExit and implement the ignoreExitCall() method to identify and ignore such calls.

Usage

If everything is set up correctly, calls to exit or die outside of PHPUnit itself will throw an instance of Automattic\RedefineExit\ExitException instead of exiting. If not caught or expected (using PHPUnit's expectException() and related methods), this will cause the test to gracefully fail with a message about the uncaught exception.

The message on the exception will describe how exit or die was called, and the code will match the code the process would have exited with.

If you catch the exception in your test, you can determine whether it was exit or die by checking $ex->getFunction(), and you can access the actual argument passed with $ex->getArgument().

Caveats

In addition to the limitations of Patchwork itself around redefining builtin functions, note that Patchwork's restoreAll() function should be avoided as it would also restore the exit handlers. To avoid the problems that causes, we normally set up our exit and die redefinitions with "expiration" handlers that will kill the process (with a helpful message) if Patchwork\restoreAll() is called. If you want to restore all other handlers except ours, a replacement function Automattic\RedefineExit::restoreAll() is provided. Or, if you'd rather avoid the expiration handlers entirely, call Automattic\RedefineExit::setupDangerously() instead of ::setup(). In this case you may want to call ::setupDangerously() again every time you call Patchwork\restoreAll().

Security

Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.

License

patchwork-redefine-exit is licensed under GNU General Public License v2 (or later)


All versions of patchwork-redefine-exit with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
antecedent/patchwork Version ^2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package automattic/patchwork-redefine-exit contains the following files

Loading the files please wait ....