Download the PHP package jasny/phpunit-extension without Composer

On this page you can find all versions of the php package jasny/phpunit-extension. 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 phpunit-extension

Jasny PHPUnit extension

Build status Scrutinizer Code Quality Code Coverage Packagist Stable Version Packagist License

Additional functionality for PHPUnit.

Installation

composer require jasny/phpunit-extension

Usage

Callback mock

MockObject createCallbackMock(InvocationOrder $matcher, array|Closure $assert = null, $return = null)

The method takes either the expected arguments as array and the return value or a Closure. If a Closure is given, it will be called with an InvocationMocker, which can be used for more advanced matching.

Safe Mocks

The SafeMocksTrait overwrites the createMock method to disable auto-return value generation. This means that the test will fail if any method is called that isn't configured.

In the example above, the method bye() isn't configured for $foo. Normally the test would succeed, but with SafeMocksTrait this test will result in the failure

Return value inference disabled and no expectation set up for Foo::bye()

Expected warning

ExpectedWarningTrait overwrites the following methods;

Take the following example function;

PHPUnit converts notices and warning to exceptions. While you can catch these exceptions through methods like expectDeprecation, any code after the the notice/warning isn't run and therefor untestable.

The following test succeeds, while it should fail.

ExpectedWarningTrait sets a custom error handler, that catches expected warnings and notices, without converting them to exceptions. Code will continue to run.

After all other assertions succeed, the code will check if there are any expected warnings/notices that haven't been triggered.

In context of

mixed inContextOf(object $object, \Closure $function)

The function is called in context of the given object. This allows to call private and protected methods and get or set private and protected properties.

Beware: You should only test via public methods and properties. When you're required to access private methods or properties to perform tests, something is likely wrong in the architecture of your code.

Consecutive calls

ConsecutiveTrait is a replacement for PHPUnit's withConsecutive method which was removed in PHPUnit 10.


All versions of phpunit-extension with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
phpunit/phpunit Version >= 10.1, < 12.0
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 jasny/phpunit-extension contains the following files

Loading the files please wait ....