Download the PHP package wondernetwork/slim-kernel-testing-harness without Composer

On this page you can find all versions of the php package wondernetwork/slim-kernel-testing-harness. 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 slim-kernel-testing-harness

Test harness for SlimKernel

Overview

The goal of this package is to make writing high-level tests exciting by building sufficient architecture around them, that would make it easy and expressive to build your test cases.

Installation

Core concepts

SlimKernelHttpClient

This class acts as a HttpClient directing the requests at the provided Slim App, which is at it’s core a Request Handler. The most basic usage is to use one of the convenience methods modeled after HTTP verbs:

Or a more advanced, by crafting the request manually (or using the provided RequestBuilder) and passing it to the request() method.

Each request is by default expected to succeed, as determined by returning a HTTP status code in the 1xx-3xx range. You can change the behaviour by calling the withResponseExpectation method:

Hint: when building test cases outside the happy path, such as making sure your authorization mechanism works correctly, you will want to use the ResponseExpectation::Failure mode.

HttpResponseAssertion

Each SlimKernelHttpClient returns a HttpResponseAssertion, which helps you make common assertions about the response and access its contents. Example helper methods:

The PSR-7 Response object is available as a public $response field. For convenience, the calling SlimKernelHttpClient is also attached as $httpClient.

Use Cases (KernelHttpUseCase trait)

To organize your test cases, and make reusable actions, it’s good to organize your sources into use cases. These use cases are an SDK of sorts for your app. They represent an abstraction over your application’s API. Look at the examples:

The trait is here to provide a couple of convenience methods. Since most of your use cases will only use the SlimKernelHttpClient as the entrypoint into your app, this is the only dependency for your use cases. The trait provides the factory method of($httpClient) to create an instance, the constructor to store the client in a protected field, and two helper methods to control the response expectation: expectFailure() and noResponseExpectation()

Assertions (JsonListResponseAssertion and others)

To build a robust test suite, most of your API endpoints will need a custom assertion class (responsible for holding the response data and making assertions on it). One particularly interesting instance of this are assertions about endpoints listing multiple records. Their handling can be made easier by using the JsonListResponseAssertion:

It automatically provides the ofJsonResponse factory method, which can directly take the result of a $httpClient->request() call. An advanced usage of the assertions and use cases is presented in the examples folder.

Middlewares

Inputs for a high-level e2e test are such complex and diverse. Different clients craft different payloads, which include:

It’s challenging to fit all this complexity and provide keep the simple interface such as the SlimKernelHttpClient has. The package solves this problem by allowing adding a PSR-15 middlewares to the client. Two basic ones are built in:

Custom middlewares in combination with different use cases for different clients of your app can be very powerful. You can look at the (example middlewares)[examples/middlewares] to a glimpse of how they can be used.


All versions of slim-kernel-testing-harness with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
wondernetwork/slim-kernel Version ^2.0
slim/http Version ^1.2
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 wondernetwork/slim-kernel-testing-harness contains the following files

Loading the files please wait ...