2017 © Pedro PelĂĄez
 

library factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

image

localheinz/factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  • Sunday, June 3, 2018
  • by localheinz
  • Repository
  • 1 Watchers
  • 4 Stars
  • 8,643 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 35 % Grown

The README.md

factory-girl-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 breerly/factory-girl-php., (*4)

Installation

Run, (*5)

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

Usage

Create Definitions

Implement one of the, (*6)

  • Ergebnis\FactoryGirl\Definition\Definition
  • Ergebnis\FactoryGirl\Definition\FakerAwareDefinition

interfaces and use the instance of FactoryGirl\Provider\Doctrine\FixtureFactory that is passed into accept() to define entities:, (*7)

<?php

namespace Foo\Bar\Test\Fixture\Entity;

use Ergebnis\FactoryGirl\Definition\Definition;
use FactoryGirl\Provider\Doctrine\FixtureFactory;
use Foo\Bar\Entity;

final class UserDefinition implements Definition
{
    public function accept(FixtureFactory $fixtureFactory): void
    {
        $fixtureFactory->defineEntity(Entity\User::class, [
            // ...
        ]);
    }
}

: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., (*8)

Register Definitions

Lazily instantiate an instance of FactoryGirl\Provider\Doctrine\FixtureFactory and use Definitions to find definitions, register definitions with the fixture factory, and optionally provide definitions with an instance of Faker\Generator:, (*9)

<?php

namespace Foo\Bar\Test\Integration;

use Doctrine\ORM;
use Ergebnis\FactoryGirl\Definition\Definitions;
use FactoryGirl\Provider\Doctrine\FixtureFactory;
use Faker\Generator;
use PHPUnit\Framework;

abstract class AbstractIntegrationTestCase extends Framework\TestCase
{
    /**
     * @var FixtureFactory
     */
    private $fixtureFactory;

    final protected function entityManager(): ORM\EntityManager
    {
        // ...
    }

    final protected function faker(): Generator
    {
        // ...
    }

    final protected function fixtureFactory(): FixtureFactory
    {
        if (null === $this->fixtureFactory) {
            $fixtureFactory = new FixtureFactory($this->entityManager());
            $fixtureFactory->persistOnGet(true);

            Definitions::in(__DIR__ . '/../Fixture')
                ->registerWith($fixtureFactory)
                ->provideWith($this->faker());

            $this->fixtureFactory = $fixtureFactory;
        }

        return $this->fixtureFactory;
    }
}

Contributing

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

Code of Conduct

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

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

License

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

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

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., (*15)

The Versions

03/06 2018

dev-master

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

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/02 2018

1.3.0

1.3.0.0 https://github.com/localheinz/factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/02 2018

dev-feature/abstract-definition

dev-feature/abstract-definition https://github.com/localheinz/factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/02 2018

dev-feature/faker-aware-definition

dev-feature/faker-aware-definition https://github.com/localheinz/factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/02 2018

dev-fix/prophecy

dev-fix/prophecy https://github.com/localheinz/factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

14/02 2018

dev-fix/example

dev-fix/example https://github.com/localheinz/factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

27/01 2018

1.2.0

1.2.0.0 https://github.com/localheinz/factory-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  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-girl-definition

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

24/01 2018

dev-fix/prerequisite

dev-fix/prerequisite

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  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 breerly/factory-girl-php.

  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 breerly/factory-girl-php.

  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 breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

30/08 2017

dev-feature/php-cs-fixer-config

dev-feature/php-cs-fixer-config

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

21/08 2017

dev-feature/php72

dev-feature/php72

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

24/06 2017

0.2.0

0.2.0.0

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

31/05 2017

0.1.1

0.1.1.0

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

25/05 2017

0.1.0

0.1.0.0

Provides an interface for, and an easy way to find and register entity definitions for breerly/factory-girl-php.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller