Download the PHP package jolicode/asynit without Composer

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

asynit

Asynchronous (if library use fiber) testing library runner for HTTP / API and more...

Install

Usage

Writing a test

Asynit will read PHP's classes to find available Test using the Asynit\Attribute\TestCase attribute. You need to create a test class in some directory, which will have the TestCase attribute of Asynit:

Then you can add some tests that will use the API of the TestCase class:

Note: All test methods should be prefixed by the test keyword or use the Asynit\Attribute\Test anotation. All others methods will not be executed automatically.

A test fail when an exception occurs during the test

Using assertion

Asynit provide trait to ease the writing of test. You can use the Asynit\AssertCaseTrait trait to use the assertion.

All assertions supported by PHPUnit are also supported by Asynit thanks to the bovigo-assert library. But you can use your own as long as it's throw an exception on failure.

Running the test

For running this test you will only need to use the PHP file provided by this project:

If you have many test files, you can run Asynit with a directory

Using HTTP Client

Asynit provide an optional Asynit\HttpClient\HttpClientWebCaseTrait trait that you can use to make HTTP request. You will need to install amphp/http-client and nyholm/psr7 to use it.

You can also use a more oriented API trait Asynit\HttpClient\HttpClientApiCaseTrait that will allow you to write test like this:

Dependency between tests

Sometime a test may need a value from the result of another test, like an authentication token that need to be available for some requests (or a cookie defining the session).

Asynit provides a Depend attribute which allows you to specify that a test is dependent from another one.

So if you have 3 tests, A, B and C and you say that C depend on A; Test A and B will be run in parallel and once A is completed and successful, C will be run with the result from A.

Let's see an example:

Here testAuthenticatedRequest will only be run after testLogin has been completed. You can also use dependency between different test case. The previous test case is under the Application\ApiTest namespace and thus we can write another test case like this:

Test Organization

It's really common to reuse this token in a lot of test, and maybe you don't need test when fetching the token. Asynit allow you to depend on any method of any class.

So you could write a TokenFetcherClass that will fetch the token and then use it in your test.

Then in your test class you will be able to call this method:

As you may notice, the fetchUserToken method does not start with test. Thus by default this method will not be included in the test suite. But as it is a dependency of a test, it will be included as a regular test in the global test suite and will leverage the cache system.


All versions of asynit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
amphp/amp Version ^3.0
amphp/http-client Version ^v5.0.1
amphp/sync Version ^2.0
bovigo/assert Version ^7.0
symfony/console Version ^4.4 || ^5.0 || ^6.0 || ^7.0
symfony/finder Version ^4.4 || ^5.0 || ^6.0 || ^7.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 jolicode/asynit contains the following files

Loading the files please wait ....