class FileFixtureProvider
    extends Base

Faker provider that generates fixtures from local DDL files.

The dialect and, optionally, the version tag select the release the DDL files are read for; omitting the version tag uses the default of the dialect.

Methods§

public function __construct(
    Generator $faker,
    string $ddlPath,
    ?TypeMapperInterface $typeMapper = null,
    ?HydratorInterface $hydrator = null,
    string $dialect = PlatformFactory::DRIVER_MYSQL,
    string|null $version = null,
)

Parameters

$fakerGenerator
$ddlPathstring
$typeMapper?TypeMapperInterface
$hydrator?HydratorInterface
$dialectstringSQL dialect: 'mysql', 'pgsql' or 'sqlite'
$versionstring|nullVersion tag such as 'mysql-8.4.7', or null for the default of the dialect

Throws

UnsupportedDriverException If the dialect is not supported
UnsupportedVersionException If the version tag is not a supported release of the dialect
Calls 8
public function fixture<T of object>(
    string $tableName,
    array<string, mixed> $overrides = [],
    class-string<T>|null $className = null,
): ($className is null ? array<string, mixed> : T)

Generate a fixture from a DDL file.

Parameters

$tableNamestringTable name (e.g., "users")
$overridesarray<string, mixed>Override values
$classNameclass-string<T>|nullDeserialization target class

Returns

($className is null ? array<string, mixed> : T)

Throws

RuntimeException
Test cases 8
Calls 3
public function getTableNames(): list<string>

Get list of available table names.

Returns

list<string>
Test cases 1
Calls 1
public function registerSchema(string $createTableSql): void

Manually register a schema.

Parameters

$createTableSqlstring
Test cases 2
Calls 2
public function getFixtureGenerator(): FixtureGenerator

Get the underlying fixture generator.

Test cases 1
public function getDialect(): string

Get the dialect the DDL files are read for.

Returns

string
Test cases 1
public function getVersion(): string

Get the version tag of the release the DDL files are read for.

Returns

string
Test cases 1

Private surface 4§

Implementation details, listed for orientation only.

private FixtureGenerator $fixtureGenerator
private string $dialect
private ServerVersion $version
private array<string, TableSchema> $schemas = []

Test cases 19§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 19