Download the PHP package kairos-project/tests without Composer

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

Tests

A test helper library

This library is a simple helper for tests of PHP application, it provide functions that aim to be involved in constructor testing, getters and setters, etc...

Basic usage

The test helper library is designed to automate the tests for basic logic elements. These basics elements will be the simple constructor testing, the getter/setter or more abstractly accessor tests, and finally the instance construction without requirements.

To be used, the test case has to extends the AbstractTestClass class, and define the tested class.

Constructor test

First of all is the constructor test. To validate the construction of an instance, its necessary to test multiples cases:

To do this, the assertConstructor() method allow two arguments as array. The first array will contain the name of the property expected to be assigned as key and the value to assign as value, representing the given arguments in the same order as the call. The second array will have the same structure and represent the default value of the properties.

To test the value assignment as reference (useful for object), the the property have to be prefixed by the same: keyword.

Since version 2.3

It is also possible to make more complex assertion by providing a user defined constraint using the KairosProject\Constrait\InjectionConstraint class.

Here an example of data that is injected in an array by the constructor before be stored in the property :

Access a protected or private method

To access a private or protected method, the getClassMethod('name') can be used. It will return an instance of ReflectionMethod configured to be accessible by default.

Test a simple getter or a simple setter

The simple getters and setters are a common practice to access private or protected properties in an object. To validate that a property is correctly assigned or returned, then the assertIsSimpleGetter('property', 'getterMethodName', 'value') or the assertIsSimpleSetter('property', 'getterMethodName', 'value') methods can be used.

If you want to test both at the same time, then it is possible to use the assertHasSimpleAccessor('property', 'value') method.

Get a fresh instance without calling the constructor

As we don't want to test the constructor for each tests, it is possible to get a fresh instance by calling the getInstance() method. The argument of this method is optional and can be used to set the dependencies directly inside the properties, using the ReflectionProperty instead of the constructor or the setters.

Get invocation builder to configure mock calls

To create a new InvocationBuilder instance, the getInvocationBuilder($mock, new Invocation(), 'methodName') can be used. This method is nothing more than a helper for $mock->expect($count)->method('methodName');

Bulk properties content validation

To validate the value stored by a set of property, use the assertPropertiesSame and assertPropertiesEqual methods.

Set up the tested class at runtime

In specific cases it is possible to see the need of defining the tested class at runtime. For this specific purpose, it is possible to use the runTestWithInstanceOf method.


All versions of tests with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 | ^8.0
phpunit/phpunit Version ^8 | ^9@stable
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 kairos-project/tests contains the following files

Loading the files please wait ....