Download the PHP package golossus/php-test-fixture-loading without Composer

On this page you can find all versions of the php package golossus/php-test-fixture-loading. 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 php-test-fixture-loading

Build Status codecov

php-test-fixture-loading is a package which tries to ease in the process of loading testing fixtures to have a better maintainability and code reuse. With this package, (data) fixtures can be created as simple classes that can be joined to compose more complex testing scenarios.

Installation

Usage

Configuration

Use the trait FixtureLoaderTrait on a base test class or TestCase. Those will typically inherit from a PHPUnit test class, like the Symfony WebTestCase or similar.

Additionally, this trait has an abstract method buildFixture which should be implemented as well. This method is responsible to adapt the way data fixtures are instantiated, because different projects might follow different approaches. This is specially true when a Dependency Injection container is needed to build a fixture.

As an example take the following TestCase class which uses a Symfony 4 WebTestCase. Take a look at the trait and the method:

Your case might be more complex (or maybe simpler), so implement this method to cover your needs.

For Symfony applications like in the example above don't forget to declare the fixtures folder as services, or you won't be able to build the fixtures.

Although the example uses the testing container to build the data fixtures, so in practice you're allowed to build private services (which is the default behaviour), actually it's possible that you need to make the fixtures public. Look at the following example:

Creating a fixture class

To create a fixture is so easy as creating a new class which implement the Fixture interface. This interface only provides two methods: load and depends. The first one defines the logic to create the data and provides a FixtureRepository parameter to store a reference on memory of any object created (and maybe stored in the database) which can be retrieved afterwards on the test function. The second method is useful to define which other data fixtures should be loaded before the current one.

All dependencies of a loaded fixture will be also loaded even if they are not specified directly in the list of fixtures to load.

If any fixture declares a dependency graph which produces a cycle, will throw an exception during the loading phase.

Even if some dependency is used more than once it will actually load just one time.

As an example of fixture:

Loading fixtures

Once the configuration above has been completed, the usage is quite straightforward, just use the method loadFixtures provided in the previous trait to load any desired fixture. This method returns a special fixture repository which is used during loading to store object references on demand.

Community

Contributing

This is an Open Source project. The Golossus team wants to enable it to be community-driven and open to contributing documentation.

Security Issues

If you discover a security vulnerability, please follow our disclosure procedure.

About Us

This package development is led by the Golossus Team contributors.


All versions of php-test-fixture-loading with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
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 golossus/php-test-fixture-loading contains the following files

Loading the files please wait ....