Download the PHP package datto/phpunit-entropy without Composer

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

Datto PHPUnit Entropy

Entropy is a library to provide tools for working with randomized testing in PHPUnit as well as for testing systems that make use of PHP's random functions such as rand and shuffle.

Use cases

Detect dependent tests

Sometimes unit tests require changes to global state, or cover functionality that alters that state. While this is never an ideal situation, this can often result in the creation of inadvertent dependencies on other tests.

Enabling Entropy's test shuffling functionality randomizes the order of your tests, helping to highlight these dependencies.

Entropy's test-shuffling also avoids changing the order of tests using the @depends functionality of PHPUnit; future work will work to ensure that shuffling can still occur for these tests when appropriate.

Randomized testing

Sometimes you can find yourself in a situation where the range of inputs for a function is so large that taking a cross-section of those inputs is a more efficient use of your resources. But what happens if that cross-section has holes where your tests might fail?

One way to get around this is to use randomized inputs, where input is generated in such a way as to get a random cross-section of the ranges. In other words, using rand or another such non-deterministic approach.

An extension of this, property-based testing is the practice of applying random input to your application or function, and observing that the output adheres to certain rules or has certain properties relative to the input, rather than precise testing of equality to a known result set.

By managing the random seed for your tests, Entropy allows not only the use of these approaches, but also to make them repeatable, either by accepting a fixed seed or recovering it from the last failed run until your test suite passed.

Including in your project

You can add this library to your project using Composer:

Running

Once configured, you can run your test suite as normal; the listener will look after itself. On test error or failure, the seed used will be stored in a temporary file, so that on the next run it will be reused, rather than a new seed generated.

Defining the seed

The seed for the random number generator is provided from up to four locations, presented here in priority order.

Environment variable

If set, the SEED environment variable will be used to override any other settings. It can be set via export, but recommended use is to set it for the current run only:

Configuration

The seed may be fixed by configuration; see the Configuration section below.

Last run

If a test run fails, the seed used is stored in a temporary file. This is then loaded on a subsequent test, and will persist until the suite succeeds again.

rand()

If no seed is set via the above methods, the final method is to use PHP's rand function.

Configuration

Entropy Test Listener

Once installed via composer, configuring the test listener is simply a matter of altering your PHPUnit configuration file (often phpunit.xml):

Arguments

seeding
enabled - boolean

If set to true, the random number generator will be seeded by the listener.

seed - integer

If you set the seed via this argument, only this value will be used to seed the random number generator. See the section on seed priority below.

file - string

If set, this file will be used to store the last failed random seed; it defaults to [TMPDIR LOCATION]/phpunit-entropy-seed.

shuffle - boolean

If set to true, the order in which unit tests are executed will be randomized (except for suites where @depends is in use). This is useful in determining and identifying inter-test dependencies.

Future work

Developer contact

Christopher Hoult [[email protected]](mailto://[email protected])


All versions of phpunit-entropy with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 datto/phpunit-entropy contains the following files

Loading the files please wait ....