PHP code example of ergebnis / factory-muffin-definition
1. Go to this page and download the library: Download ergebnis/factory-muffin-definition library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ergebnis / factory-muffin-definition example snippets
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([
// ...
]);
}
}
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;
}
}