Download the PHP package adgoal/phpunit-entity-tester without Composer

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

phpunit-entity-tester : Quickly test your entities

You can write very quickly unit tests for the accessors, adders and removers of your entities.

Requirements

Installation

Quick example

This is an example of unit test file:

Documentation

Test the accessors

1. Add 'use' statement

2. Create the tester object

Where $entity is the entity to test and 'attribute' the base name of setter and getter methods.

In this case, the tester will test the methods 'setAttribute' and 'getAttribute'.

3. Configure the tester

Your can change the setter and getter methods like this :

You can remove the fluent constaint for the setter (set to true by default)

4. Run tests

Simply use the test method :

In this case the tester :

  1. calls the setter with 'the value'
  2. tests the fluent constraint
  3. tests that the getter return 'the value'

If the value returned by the getter have to be different to the value used with the setter use the second argument of the test method like this :

Test Setter

You can also only test the setter method like that :

This method calls the setter method and tests the fluent constraint

Test Getter

You can also only test the setter method like that :

This method calls the getter method and tests the return with value in parameter

Test the adders, removers and collection getters

1. Add 'use' statement

2. Create the tester object

Where $entity is the entity to test and 'items' the base name for adder, remover and getter methods. For the adder and remover methods, the final 's' of the base name will be removed.

In this case, ther tester will test the methods 'addItem', 'removeItem' and 'getItems'.

3. Configure the tester

You can change the adder, remover and getter methods like this :

You can remove the fluent constraint for the adder and remover methods (set to true by default)

By default, the tester considere that the collection respect the unicity of its items. You can force the tester to considere thaht the collection don't respect the unicity like that :

4. Run tests

Simply use the test method :

This method needs two arguments to work. In this case the tester :

  1. calls and tests the adder method with the first value
  2. try to remove the second value (that is not in collection yet)
  3. calls and tests the adder method with the second value
  4. try to add again the first value (to tetunique constraint)
  5. try to remove the first value
  6. add again the first value (to obtain a collection with the first and the second value in it)

This method uses the following three methods that you can also use separatly.

Test Adder

You can also only test the adder method like that :

This method calls the adder method and tests :

  1. the fluent constraint
  2. if the value is in collection (added)
  3. the unicity constraint
Test Remover

You can also only test the remover method like that :

This method calls the remover method and tests :

  1. the fluent constraint
  2. if the value is not in colleciton (removed)
  3. if the remover removed the good number of items (all that match value but not more)
Test Getter

You can also only test the getter method like that :

This method tests if the returned value of the getter method is :

  1. (if return is an object) implement Countable interface
  2. (if return is an object) implement Traversable interface
  3. (if return is not an object) is an array or null

Tricks

To test entity quicker, use dataProvider with tester.

  1. Create the test method

  2. Create the data provider

You can also use the process for AccessorCollectionTester by customize the test method.

Credits

Special thanks for gerg0ire who encourage me to do that library


All versions of phpunit-entity-tester with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
phpunit/phpunit Version >=6
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 adgoal/phpunit-entity-tester contains the following files

Loading the files please wait ....