PHPackages                             adrhumphreys/silverstripe-fixtures - 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. adrhumphreys/silverstripe-fixtures

ActiveSilverstripe-vendormodule[Testing &amp; Quality](/categories/testing)

adrhumphreys/silverstripe-fixtures
==================================

Fixtures for Silverstripe.

2.0.0(11mo ago)215.4k↑133.3%5[3 issues](https://github.com/adrhumphreys/silverstripe-fixtures/issues)BSD-3-ClausePHPPHP ^8.3CI failing

Since Aug 7Pushed 11mo ago3 watchersCompare

[ Source](https://github.com/adrhumphreys/silverstripe-fixtures)[ Packagist](https://packagist.org/packages/adrhumphreys/silverstripe-fixtures)[ RSS](/packages/adrhumphreys-silverstripe-fixtures/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (4)Versions (8)Used By (0)

Fixtures for Silverstripe
=========================

[](#fixtures-for-silverstripe)

Fixtures for all mixtures 👋

Requirements
------------

[](#requirements)

- SilverStripe ^6
- PHP ^8.3

Dev requirements
----------------

[](#dev-requirements)

- `phpunit/phpunit` ^11.5
- `squizlabs/php_codesniffer` ^3.0

Installation
------------

[](#installation)

```
composer require adrhumphreys/silverstripe-fixtures dev-master

```

### Installing as a dev only module:

[](#installing-as-a-dev-only-module)

When running `dev/build` Silverstripe framework will try to load all classes into it's ClassManifest to cache them and allow for functionality such as dependency injection. During that process it will try to load your Fixture class which will then try to load `AdrHumphreys\Fixtures\AbstractFixture` which doesn't exist. This will throw and exception and stop the `dev/build` process.

You have some options to remedy this, ranked from best to worst:

**Option 1: Place your fixtures in the `tests` directory for your project**: These are designed to be run on a test/dev environment only and the code is more reference than implementation specific. It therefore makes sense to move these files into this directory. Why? It's explicitly ignored when finding files via `ManifestFileFinder`

**Option 2: Add `_manifest_exclude` to the fixture directory**: This will ensure that `ManifestFileFinder` will ignore files in the directory. This is option 2 because it makes it easier for code that is test only to end up being relied upon by production code which should never be the case

**Option 3: Add `implements TestOnly` to all fixtures**If you are installing this as a dev dependency then **all** your fixtures will need to implement `\SilverStripe\Dev\TestOnly` this is specifically excluded from Silverstripes class manifest loader

How to use
----------

[](#how-to-use)

The default setup is to run this as a task like so:

```
vendor/bin/sake tasks:load-fixtures --directory=app/fixtures

```

You'll need to create your fixtures in the directory specified. Or you can implement your own task, look at the task `LoadFixtures` as an example. You can change `->loadFromDirectory` to multiple calls of `->loadFixture($fixtureClassName)`

A basic fixture looks like the following:

```
