Download the PHP package sanmai/phpunit-legacy-adapter without Composer

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

PHPUnit Legacy Versions Adapter

As you're here, you are probably well aware that PHPUnit 8+ requires common template methods like setUp() or tearDown() to have a void return type declaration, which methods naturally break anything below PHP 7.1.

Although it is not a big deal to automatically update your code to use these return type declaration with help from the likes of PHP-CS-Fixer or Rector, it might become a problem if, for whatever unfortunate (but, hopefully, lucrative) reasons, you have to ensure your code is working under PHP 7.0 or PHP 5.6, all the while wanting using the best world can give you in the more-less recent versions of PHPUnit.

In this case, you'll have two problems. One, newer versions of PHPUnit do not have old assertions, but you can find a way around this, and another, as mentioned, newer versions of PHPUnit require void return type declarations for the convenient template methods, and then you're stuck because rewriting tests to work without these template methods is a major pain and might be impossible even. And then this small library comes to save your day!

How to use

First, update your tests to extend from \LegacyPHPUnit\TestCase instead of \PHPUnit\Framework\TestCase:

Then, where you had to use setUp(): void template method, use doSetUp() method, omitting all any any return types in a fully backward-compatible way.

There are similar replacements for most other template method:

Reference

Method Replacement
setUpBeforeClass(): void doSetUpBeforeClass()
tearDownAfterClass(): void doTearDownAfterClass()
setUp(): void doSetUp()
tearDown(): void doTearDown()
assertPreConditions(): void doAssertPreConditions()
assertPostConditions(): void doAssertPostConditions()

Supported versions

Future versions will likely follow the same pattern.

What this library does not do

Although this library solves the most annoying part of the problem, there are other parts the library was not designed to cover. For example:

There are polyfills for these changed methods (see below), but it should not be a big deal to write an ad hoc polyfill just for the methods you need. E.g.:

If there are several modular (and not) multi-version polyfills for these, and other methods:


All versions of phpunit-legacy-adapter with dependencies

PHP Build Version
Package Version
Requires phpunit/phpunit Version ^7 || ^8 || ^9 || ^10
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 sanmai/phpunit-legacy-adapter contains the following files

Loading the files please wait ....