classFileFixtureProvider
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
$faker | Generator | |
$ddlPath | string | |
$typeMapper | ?TypeMapperInterface | |
$hydrator | ?HydratorInterface | |
$dialect | string | SQL dialect: 'mysql', 'pgsql' or 'sqlite' |
$version | string|null | Version tag such as 'mysql-8.4.7', or null for the default of the dialect |
Throws
UnsupportedDriverException If the dialect is not supportedUnsupportedVersionException If the version tag is not a supported release of the dialectCalls 8
- class-const PlatformFactory::DRIVER_MYSQL() line 46
- static-call
Base::__construct()line 49 - static-call PlatformFactory::resolveVersion() line 51
- static-call PlatformFactory::createTypeMapper() line 53
- static-call PlatformFactory::createSchemaParser() line 54
- new FixtureGenerator line 56
- method-call DdlDirectory::loadSchemas() line 57
- new DdlDirectory line 57
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
$tableName | string | Table name (e.g., "users") |
$overrides | array<string, mixed> | Override values |
$className | class-string<T>|null | Deserialization target class |
Returns
($className is null ? array<string, mixed> : T)Throws
RuntimeExceptionTest cases 8
FileFixtureProviderTest::testFixtureGeneratesDataForLoadedTablecallsFileFixtureProviderTest::testFixtureWithHydrationcallsFileFixtureProviderTest::testFixtureWithMixedCaseTableNamecallsFileFixtureProviderTest::testFixtureWithOverridescallsFileFixtureProviderTest::testGetDialectAndGetVersionNameTheSelectedReleasecallsFileFixtureProviderTest::testRegisterSchemacallsFileFixtureProviderTest::testRegisterSchemaWithMixedCaseFixturecallsFileFixtureProviderTest::testThrowsExceptionForNonExistentTablecalls
Calls 3
- function-call
strtolowerline 75 - new
RuntimeExceptionline 78 - method-call FixtureGenerator::generate() line 81
public function hasTable(string $tableName): boolCheck if a table schema is loaded.
Parameters
$tableName | string |
Returns
boolTest cases 8
FileFixtureProviderTest::testHandlesCommentOnlySqlFilecallsFileFixtureProviderTest::testHandlesCommentsInSqlFilescallsFileFixtureProviderTest::testHandlesEmptySqlFilecallsFileFixtureProviderTest::testHasTableReturnsFalseForNonExistentcallsFileFixtureProviderTest::testLoadsSchemasFromDirectorycallsFileFixtureProviderTest::testRegisterSchemacallsFileFixtureProviderTest::testSkipsInvalidSqlFilescallsFileFixtureProviderTest::testTableNameIsCaseInsensitivecalls
Calls 1
- function-call
strtolowerline 89
public function getTableNames(): list<string>Get list of available table names.
Returns
list<string>Test cases 1
Calls 1
- function-call
array_keysline 99
public function registerSchema(string $createTableSql): voidManually register a schema.
Parameters
$createTableSql | string |
Test cases 2
Calls 2
- method-call FixtureGenerator::getSchemaParser() line 107
- function-call
strtolowerline 108
public function getFixtureGenerator(): FixtureGeneratorGet the underlying fixture generator.
Returns
Test cases 1
public function getDialect(): stringGet the dialect the DDL files are read for.
Returns
stringpublic function getVersion(): stringGet the version tag of the release the DDL files are read for.
Returns
stringPrivate surface 4§
Implementation details, listed for orientation only.
private FixtureGenerator $fixtureGeneratorprivate string $dialectprivate ServerVersion $versionprivate 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
FileFixtureProviderTest::testFixtureGeneratesDataForLoadedTablecallsFileFixtureProviderTest::testFixtureWithHydrationcallsFileFixtureProviderTest::testFixtureWithMixedCaseTableNamecallsFileFixtureProviderTest::testFixtureWithOverridescallsFileFixtureProviderTest::testGetDialectAndGetVersionNameTheSelectedReleasecallsFileFixtureProviderTest::testGetFixtureGeneratorcallsFileFixtureProviderTest::testGetTableNamescallsFileFixtureProviderTest::testGetVersionRejectsAnUnsupportedTagcallsFileFixtureProviderTest::testHandlesCommentOnlySqlFilecallsFileFixtureProviderTest::testHandlesCommentsInSqlFilescallsFileFixtureProviderTest::testHandlesEmptySqlFilecallsFileFixtureProviderTest::testHasTableReturnsFalseForNonExistentcallsFileFixtureProviderTest::testLoadsSchemasFromDirectorycallsFileFixtureProviderTest::testRegisterSchemacallsFileFixtureProviderTest::testRegisterSchemaWithMixedCaseFixturecallsFileFixtureProviderTest::testSkipsInvalidSqlFilescallsFileFixtureProviderTest::testTableNameIsCaseInsensitivecallsFileFixtureProviderTest::testThrowsExceptionForNonExistentDirectorycallsFileFixtureProviderTest::testThrowsExceptionForNonExistentTablecalls