PHPackages                             golossus/php-test-fixture-loading - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. golossus/php-test-fixture-loading

ActiveLibrary[Testing &amp; Quality](/categories/testing)

golossus/php-test-fixture-loading
=================================

A package which provides an improved way of loading fixtures in tests

v1.0.0(5y ago)22.2kMITPHPPHP &gt;=7.1

Since Jan 13Pushed 5y ago2 watchersCompare

[ Source](https://github.com/golossus/php-test-fixture-loading)[ Packagist](https://packagist.org/packages/golossus/php-test-fixture-loading)[ RSS](/packages/golossus-php-test-fixture-loading/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/dfb16041866ee2944612cb08fcb76430f4bada0ac4e334b406a5d05e5a2322bf/68747470733a2f2f7472617669732d63692e636f6d2f676f6c6f737375732f7068702d746573742d666978747572652d6c6f6164696e672e7376673f6272616e63683d6d61696e)](https://travis-ci.com/golossus/php-test-fixture-loading)[![codecov](https://camo.githubusercontent.com/eaa1faed32dd70917863c9655fb2bbeb699f55f633b941c03090baae4d1443ac/68747470733a2f2f636f6465636f762e696f2f67682f676f6c6f737375732f7068702d746573742d666978747572652d6c6f6164696e672f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d3856574d33464d355355)](https://codecov.io/gh/golossus/php-test-fixture-loading)[![Version](https://camo.githubusercontent.com/cc144a39bac7af5fa7a2a583cc09a5387383c7cc49ee320134310833546809eb/68747470733a2f2f706f7365722e707567782e6f72672f676f6c6f737375732f7068702d746573742d666978747572652d6c6f6164696e672f76657273696f6e)](//packagist.org/packages/golossus/php-test-fixture-loading)[![Total Downloads](https://camo.githubusercontent.com/dd1627278fdf7eb8530d21621512f3be8ab70ef45193216dc275dc643dbc8934/68747470733a2f2f706f7365722e707567782e6f72672f676f6c6f737375732f7068702d746573742d666978747572652d6c6f6164696e672f646f776e6c6f616473)](//packagist.org/packages/golossus/php-test-fixture-loading)[![License](https://camo.githubusercontent.com/c5714b66f725a3d80d7e942e05234cc3a4ce55ca75da9b8f9f8690c9ad88a759/68747470733a2f2f706f7365722e707567782e6f72672f676f6c6f737375732f7068702d746573742d666978747572652d6c6f6164696e672f6c6963656e7365)](//packagist.org/packages/golossus/php-test-fixture-loading)

 [ ![](https://avatars2.githubusercontent.com/u/58183018) ](https://www.golossus.com)

[php-test-fixture-loading](https://github.com/golossus/php-lazy-proxy-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
------------

[](#installation)

```
composer require --dev golossus/php-test-fixture-loading
```

Usage
-----

[](#usage)

Configuration
-------------

[](#configuration)

Use the trait [FixtureLoaderTrait](./lib/FixtureLoaderTrait.php) 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:

```
