2017 © Pedro PelĂĄez
 

library factory-muffin-definition

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin.

image

localheinz/factory-muffin-definition

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin.

  • Saturday, January 27, 2018
  • by localheinz
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

factory-muffin-definition

Integrate Prune Release Renew, (*1)

Code Coverage Type Coverage, (*2)

Latest Stable Version Total Downloads, (*3)

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin, inspired by ergebnis/factory-girl-definition., (*4)

Installation

Run, (*5)

$ composer require --dev ergebnis/factory-muffin-definition

Usage

Create Definitions

Implement the Definition interface and use the instance of League\FactoryMuffin\FactoryMuffin that is passed in into accept() to define entities:, (*6)

<?php

namespace Foo\Bar\Test\Fixture\Entity;

use Ergebnis\FactoryMuffin\Definition\Definition;
use Foo\Bar\Entity;
use League\FactoryMuffin\FactoryMuffin;

final class UserDefinition implements Definition
{
    public function accept(FactoryMuffin $factoryMuffin): void
    {
        $factoryMuffin->define(Entity\User::class)->setDefinitions([
            // ...
        ]);
    }
}

:bulb: Any number of entities can be defined within a definition. However, it's probably a good idea to create a definition for each entity., (*7)

Register Definitions

Lazily instantiate an instance of League\FactoryMuffin\FactoryMuffin and use Definitions to find definitions and register them with the factory:, (*8)

<?php

namespace Foo\Bar\Test\Integration;

use Ergebnis\FactoryMuffin\Definition\Definitions;
use League\FactoryMuffin\FactoryMuffin;
use League\FactoryMuffin\Stores;
use PHPUnit\Framework;

abstract class AbstractIntegrationTestCase extends Framework\TestCase
{
    final protected function factoryMuffin(): FactoryMuffin
    {
        static $factoryMuffin = null;

        if (null === $factoryMuffin) {
            $factoryMuffin = new FactoryMuffin(new Stores\ModelStore('save'));

            Definitions::in(__DIR__ . '/../Fixture')->registerWith($factoryMuffin);
        }

        return $factoryMuffin;
    }
}

Contributing

Please have a look at CONTRIBUTING.md., (*9)

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md., (*10)

License

This package is licensed using the MIT License., (*11)

Please have a look at LICENSE.md., (*12)

Curious what I am building?

:mailbox_with_mail: Subscribe to my list, and I will occasionally send you an email to let you know what I am working on., (*13)

The Versions

27/01 2018

dev-master

9999999-dev https://github.com/localheinz/factory-muffin-definition

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

27/01 2018

dev-feature/urls

dev-feature/urls https://github.com/localheinz/factory-muffin-definition

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

24/01 2018

dev-feature/make-rule-syntax

dev-feature/make-rule-syntax

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

11/10 2017

1.1.0

1.1.0.0

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

19/09 2017

1.0.0

1.0.0.0

Provides an interface for, and an easy way to find and register entity definitions for league/factory-muffin.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Andreas Möller