classFixturePlan
class FixturePlan
implements Stringable
@visibility public.The parsed form of a fixture plan: which tables take part, and how their columns line up.
This type is the plan. The DBML relation string is one way to write it down and from() reads it; toString() writes it back. Building it up method by method, or declaring one as a class, produce the same value by other routes:
FixturePlan::from('order.id < order_detail.order_id');
(new FixturePlan())->withOneToMany('order.id', 'order_detail.order_id');
final class OrderWithDetails extends FixturePlan { public function __construct() { parent::__construct( Relation::oneToMany('order.id', 'order_detail.order_id'), Relation::manyToOne('order.customer_id', 'customer.id'), ); } }
A subclass names a plan without adding a kind of plan, so the builders below return a plain FixturePlan rather than the subclass: once a declared plan is altered it is no longer the plan that class stands for.
$plan = \SqlFixture\Plan\FixturePlan::from('users.id < posts.user_id');
$plan->tables // => ['users', 'posts']
$plan->toString() // => 'users.id < posts.user_id'Properties§
public list<Relation> $relationspublic list<string> $tablespublic list<string> $generationOrderMethods§
public function __construct(Relation|string ...$parts)Parameters
$parts | Relation|string | Relations, and the names of tables that stand alone |
Throws
EmptyPlanException If a table declaration is emptyCalls 8
- method-call TableName::assertTableName() line 87
- new TableName line 87
- function-call
array_valuesline 90 - function-call
array_uniqueline 92 - method-call PlanValidation::rejectColumnsBoundTwice() line 94
- new PlanValidation line 94
- method-call PlanValidation::rejectUnboundedSelfReferences() line 95
- method-call PlanValidation::sortByDependency() line 96
public static function from(string|self $plan): selfRead a plan written in the DBML relation syntax.
Parameters
$plan | string|self |
Returns
selfThrows
Test cases 66
FixtureGenerationBench::setUpcallsConnectedTablesTest::testConnectedToFollowsBothDirectionsAndSkipsOtherComponentscallsOverrideSpecsTest::testSpecsPreservesNamedAndPositionalRequestscallsRelationProjectionTest::testReferencedColumnsDeduplicatesParentKeyscallsRowMaterializerTest::testMaterializeLinksEveryChildToTheGeneratedParentcallsRowMaterializerTest::testMaterializeParentDoesNotWalkBackAlongTheArrivalRelationcallsRowMaterializerTest::testMaterializeRowPreservesExplicitKeyscallsRowMaterializerTest::testToChildrenCopiesTheExistingParentKeycallsRowMaterializerTest::testToParentProjectsGeneratedKeyscallsPlanGeneratorTest::testACompositeRelationCarriesEveryColumncallsPlanGeneratorTest::testACountOfZeroGeneratesNoRowscallsPlanGeneratorTest::testAListGivesOneRowPerEntrycallsPlanGeneratorTest::testAnOptionalChildMayGenerateNoneAtAllcallsPlanGeneratorTest::testAnOptionalOneToOneAskedForNoneIsNullcallsPlanGeneratorTest::testAnOptionalParentIsGeneratedWhenTheCallerAsksForItcallsPlanGeneratorTest::testAnOptionalParentNobodyAskedForIsLeftOutcallsPlanGeneratorTest::testAnUnboundedChildCountCanExceedItsMinimumcallsPlanGeneratorTest::testAnUnknownTableIsReportedcallsPlanGeneratorTest::testAnUnmentionedChildIsStillGeneratedcallsPlanGeneratorTest::testAOneToOneChildIsASingleRowcallsPlanGeneratorTest::testAOneToOneChildIsGeneratedExactlyOncecallsPlanGeneratorTest::testAOneToOneChildIsNeverGeneratedMoreThanOncecallsPlanGeneratorTest::testAParentIsGeneratedAndLinkedTocallsPlanGeneratorTest::testAPlanNamingAColumnTheTableLacksIsRejectedBeforeGeneratingcallsPlanGeneratorTest::testARequiredChildNeverGeneratesNonecallsPlanGeneratorTest::testARequiredParentIsGeneratedWhetherOrNotItWasAskedForcallsPlanGeneratorTest::testARowCarriesBothItsInheritedKeyAndItsOwnParentKeycallsPlanGeneratorTest::testATableReachableOnlyBackwardsAlongARelationIsStillPartOfTheWalkcallsPlanGeneratorTest::testChildRowsCarryTheParentKeycallsPlanGeneratorTest::testEntriesComeBackInTheOrderThePlanNamesThemcallsPlanGeneratorTest::testEveryChildOfAListGetsItsOwnParentcallsPlanGeneratorTest::testEveryOtherRelationOfAParentIsStillFollowedcallsPlanGeneratorTest::testFixingTheLinkingColumnLeavesTheParentAlonecallsPlanGeneratorTest::testGenerateTheTableThePlanIsAboutGetsOneRowcallsPlanGeneratorTest::testKeysAreStoodInForEveryColumnARelationReadscallsPlanGeneratorTest::testOneSetOfValuesAppliesToEveryGeneratedRowcallsPlanGeneratorTest::testOverridesMayBeGivenAsTableOverridescallsPlanGeneratorTest::testTablesThatStandAloneAreGeneratedToocallsPlanGeneratorTest::testTheSubjectHonoursACountItWasGivencallsPlanGeneratorTest::testTheSubjectIsOneRowEvenWhenSomethingReferencesItcallsPlanSchemaValidatorTest::aColumnTheTableDoesNotHaveIsRejectedcallsPlanSchemaValidatorTest::testAGeneratedColumnCannotBeLinkedcallsPlanSchemaValidatorTest::testAGeneratedColumnCannotBeWrittenIntoEithercallsPlanSchemaValidatorTest::testATableNamedWithoutAnyRelationIsCheckedToocallsPlanSchemaValidatorTest::testATableTheResolverDoesNotKnowIsRejectedcallsPlanSchemaValidatorTest::testValidateAPlanMatchingTheSchemaPassescallsFixturePlanTest::testADeclaredPlanEqualsTheParsedStringcallsFixturePlanTest::testAnOptionalSelfReferenceIsAllowedcallsFixturePlanTest::testCastingToStringWritesThePlanBackcallsFixturePlanTest::testDependenciesOfReturnsAListEvenWhenTheMatchIsNotFirstcallsFixturePlanTest::testDependenciesOfSelectsRelationsWhereTheTableIsTheChildcallsFixturePlanTest::testDependentsOfReturnsAListEvenWhenTheMatchIsNotFirstcallsFixturePlanTest::testDependentsOfSelectsRelationsWhereTheTableIsTheParentcallsFixturePlanTest::testFromAcceptsAPlanAndCopiesItcallsFixturePlanTest::testFromReadsTheRelationStringcallsFixturePlanTest::testGenerationOrderCoversTablesThatStandAlonecallsFixturePlanTest::testGenerationOrderHandlesSeveralIndependentComponentscallsFixturePlanTest::testGenerationOrderPutsEveryParentBeforeItsChildrencallsFixturePlanTest::testRootsAreTheTablesNothingHasToPrecedecallsFixturePlanTest::testRootsReturnsAListEvenWhenTheFirstTableIsNotOnecallsFixturePlanTest::testSubjectTableTheSubjectIsTheFirstTableNamedcallsFixturePlanTest::testTheStringAndTheObjectDescribeTheSamePlancallsFixturePlanTest::testTheSubjectIsNotNecessarilyGeneratedFirstcallsFixturePlanTest::testToStringWritesThePlanBackcallsFixturePlanTest::testTwoForeignKeysBetweenTheSameTablesAreAllowedcallsPlanTablesTest::testStandaloneTablesExcludesRelationEndpointscalls
Called from 1
Calls 3
- new
selfline 114 - method-call PlanParser::parse() line 117
- new PlanParser line 117
public static function table(string $table): selfStart a plan from the table its fixtures are rooted at.
Parameters
$table | string |
Returns
selfTest cases 18
GenerationRunTest::testAClaimedTableThatWasNeverReachedIsNotAListcallsGenerationRunTest::testATableThatGeneratedNothingReadsBackAsNullcallsGenerationRunTest::testClaimingDoesNotUndoWhatTheWalkAlreadyLearntcallsGenerationRunTest::testReachedReachingATableAsAListStickscallsGenerationRunTest::testToSetATableReachedOnlyAsASingleRowReadsBackAsOnecallsFixturePlanTest::testEveryBuilderMethodReturnsANewInstancecallsFixturePlanTest::testTablesAreNotRepeatedcallsFixturePlanTest::testTableStartsAPlanWithNoRelationscallsFixturePlanTest::testTheStringAndTheObjectDescribeTheSamePlancallsFixturePlanTest::testWithManyToOneAddsARelationcallsFixturePlanTest::testWithManyToOneCanMarkTheParentOptionalcallsFixturePlanTest::testWithOneToManyAddsARelationcallsFixturePlanTest::testWithOneToOneAddsARelationcallsFixturePlanTest::testWithRelationAcceptsAColumnRefForCompositeKeyscallsFixturePlanTest::testWithRelationAddsARelationDirectlycallsFixturePlanTest::testWithTableNamesATableThatHasNoRelationYetcallsPlanPrinterTest::testPrintsATableOnlyPlanAsItsTableNamecallsTableNameTest::testAssertTableNameAcceptsUnderscoresAndDollarSignscalls
Calls 1
- new
selfline 125
public function withRelation(Relation $relation): selfReturns with relation.
Parameters
$relation | Relation |
Returns
selfCalled from 3
- method-call SqlFixture\Plan\FixturePlan::withOneToMany() packages/sql-fixture/src/Plan/FixturePlan.php:144
- method-call SqlFixture\Plan\FixturePlan::withManyToOne() packages/sql-fixture/src/Plan/FixturePlan.php:155
- method-call SqlFixture\Plan\FixturePlan::withOneToOne() packages/sql-fixture/src/Plan/FixturePlan.php:166
Calls 1
- new
selfline 133
public function withOneToMany(
string|ColumnRef $parent,
string|ColumnRef $child,
bool $childOptional = false,
): selfAdd parent.column < child.column.
Returns
selfCalls 2
- method-call FixturePlan::withRelation() line 144
- static-call Relation::oneToMany() line 144
public function withManyToOne(
string|ColumnRef $child,
string|ColumnRef $parent,
bool $parentOptional = false,
): selfAdd child.column > parent.column.
Returns
selfCalls 2
- method-call FixturePlan::withRelation() line 155
- static-call Relation::manyToOne() line 155
public function withOneToOne(
string|ColumnRef $parent,
string|ColumnRef $child,
bool $childOptional = false,
): selfAdd parent.column - child.column.
Returns
selfCalls 2
- method-call FixturePlan::withRelation() line 166
- static-call Relation::oneToOne() line 166
public function withTable(string $table): selfName a table that takes part without being related to anything.
Parameters
$table | string |
Returns
selfTest cases 1
Calls 1
- new
selfline 174
public function subjectTable(): ?stringThe table the fixtures are about, which is the first one named.
This is where the plan reads from, not where generation starts: written order_detail.order_id > order.id the subject is order_detail, but order has to exist first. Use generationOrder for that.
Returns
?stringTest cases 1
public function roots(): list<string>Tables nothing else has to be generated before.
Returns
list<string>Calls 1
- method-call FixturePlan::dependenciesOf() line 199
public function dependenciesOf(string $table): list<Relation>Relations that must be satisfied before this table can be generated, that is, those in which it is the child.
Parameters
$table | string |
Returns
list<Relation>Called from 2
Calls 3
- function-call
array_valuesline 215 - function-call
array_filterline 215 - method-call Relation::child() line 217
public function dependentsOf(string $table): list<Relation>Relations hanging off this table, that is, those in which it is the parent.
Parameters
$table | string |
Returns
list<Relation>Called from 2
Calls 3
- function-call
array_valuesline 228 - function-call
array_filterline 228 - method-call Relation::parent() line 230
public function toString(): stringReturns to string.
Returns
stringTest cases 2
Called from 1
Calls 2
- method-call PlanPrinter::print() line 239
- new PlanPrinter line 239
public function __toString(): stringReturns the canonical textual representation.
Returns
stringCalls 1
- method-call FixturePlan::toString() line 247
Private surface 1§
Implementation details, listed for orientation only.
private list<Relation|string> $partsTest cases 110§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 36
FixturePlanTest::testADeclaredPlanEqualsTheParsedStringcallsFixturePlanTest::testAnEmptyPlanHasNoSubjectcallsFixturePlanTest::testAnOptionalSelfReferenceIsAllowedcallsFixturePlanTest::testAPlanBuiltFromAKeyedSpreadCanStillBeExtendedcallsFixturePlanTest::testAQuotedTableNameLosesItsQuotescallsFixturePlanTest::testAStringPartNamesAStandaloneTablecallsFixturePlanTest::testATableNameIsTakenWithoutSurroundingSpacecallsFixturePlanTest::testCastingToStringWritesThePlanBackcallsFixturePlanTest::testDependenciesOfReturnsAListEvenWhenTheMatchIsNotFirstcallsFixturePlanTest::testDependenciesOfSelectsRelationsWhereTheTableIsTheChildcallsFixturePlanTest::testDependentsOfReturnsAListEvenWhenTheMatchIsNotFirstcallsFixturePlanTest::testDependentsOfSelectsRelationsWhereTheTableIsTheParentcallsFixturePlanTest::testEveryBuilderMethodReturnsANewInstancecallsFixturePlanTest::testFromAcceptsAPlanAndCopiesItcallsFixturePlanTest::testFromReadsTheRelationStringcallsFixturePlanTest::testGenerationOrderCoversTablesThatStandAlonecallsFixturePlanTest::testGenerationOrderHandlesSeveralIndependentComponentscallsFixturePlanTest::testGenerationOrderPutsEveryParentBeforeItsChildrencallsFixturePlanTest::testOfAcceptsRelationsWithoutAStringcallsFixturePlanTest::testPartsSpreadFromAKeyedArrayAreStillReadInOrdercallsFixturePlanTest::testRootsAreTheTablesNothingHasToPrecedecallsFixturePlanTest::testRootsReturnsAListEvenWhenTheFirstTableIsNotOnecallsFixturePlanTest::testSubjectTableTheSubjectIsTheFirstTableNamedcallsFixturePlanTest::testTablesAreNotRepeatedcallsFixturePlanTest::testTableStartsAPlanWithNoRelationscallsFixturePlanTest::testTheStringAndTheObjectDescribeTheSamePlancallsFixturePlanTest::testTheSubjectIsNotNecessarilyGeneratedFirstcallsFixturePlanTest::testToStringWritesThePlanBackcallsFixturePlanTest::testTwoForeignKeysBetweenTheSameTablesAreAllowedcallsFixturePlanTest::testWithManyToOneAddsARelationcallsFixturePlanTest::testWithManyToOneCanMarkTheParentOptionalcallsFixturePlanTest::testWithOneToManyAddsARelationcallsFixturePlanTest::testWithOneToOneAddsARelationcallsFixturePlanTest::testWithRelationAcceptsAColumnRefForCompositeKeyscallsFixturePlanTest::testWithRelationAddsARelationDirectlycallsFixturePlanTest::testWithTableNamesATableThatHasNoRelationYetcalls
Other tests reaching this symbol 74
FixtureGenerationBench::setUpcallsPostgreSqlEndToEndTestcallsSqliteIntegrationTestcallsConnectedTablesTest::testConnectedToFollowsBothDirectionsAndSkipsOtherComponentscallsOverrideSpecsTest::testSpecsPreservesNamedAndPositionalRequestscallsRelationCountsTestcallsRelationProjectionTest::testReferencedColumnsDeduplicatesParentKeyscallsRowMaterializerTest::testMaterializeLinksEveryChildToTheGeneratedParentcallsRowMaterializerTest::testMaterializeParentDoesNotWalkBackAlongTheArrivalRelationcallsRowMaterializerTest::testMaterializeRowPreservesExplicitKeyscallsRowMaterializerTest::testToChildrenCopiesTheExistingParentKeycallsRowMaterializerTest::testToParentProjectsGeneratedKeyscallsGenerationRunTest::testAClaimedTableThatWasNeverReachedIsNotAListcallsGenerationRunTest::testATableThatGeneratedNothingReadsBackAsNullcallsGenerationRunTest::testClaimingDoesNotUndoWhatTheWalkAlreadyLearntcallsGenerationRunTest::testReachedReachingATableAsAListStickscallsGenerationRunTest::testToSetATableReachedOnlyAsASingleRowReadsBackAsOnecallsPlanGeneratorTest::testACompositeRelationCarriesEveryColumncallsPlanGeneratorTest::testACountOfZeroGeneratesNoRowscallsPlanGeneratorTest::testAListGivesOneRowPerEntrycallsPlanGeneratorTest::testAnOptionalChildMayGenerateNoneAtAllcallsPlanGeneratorTest::testAnOptionalOneToOneAskedForNoneIsNullcallsPlanGeneratorTest::testAnOptionalParentIsGeneratedWhenTheCallerAsksForItcallsPlanGeneratorTest::testAnOptionalParentNobodyAskedForIsLeftOutcallsPlanGeneratorTest::testAnUnboundedChildCountCanExceedItsMinimumcallsPlanGeneratorTest::testAnUnknownTableIsReportedcallsPlanGeneratorTest::testAnUnmentionedChildIsStillGeneratedcallsPlanGeneratorTest::testAOneToOneChildIsASingleRowcallsPlanGeneratorTest::testAOneToOneChildIsGeneratedExactlyOncecallsPlanGeneratorTest::testAOneToOneChildIsNeverGeneratedMoreThanOncecallsPlanGeneratorTest::testAParentIsGeneratedAndLinkedTocallsPlanGeneratorTest::testAPlanNamingAColumnTheTableLacksIsRejectedBeforeGeneratingcallsPlanGeneratorTest::testARequiredChildNeverGeneratesNonecallsPlanGeneratorTest::testARequiredParentIsGeneratedWhetherOrNotItWasAskedForcallsPlanGeneratorTest::testARowCarriesBothItsInheritedKeyAndItsOwnParentKeycallsPlanGeneratorTest::testATableReachableOnlyBackwardsAlongARelationIsStillPartOfTheWalkcallsPlanGeneratorTest::testChildRowsCarryTheParentKeycallsPlanGeneratorTest::testEntriesComeBackInTheOrderThePlanNamesThemcallsPlanGeneratorTest::testEveryChildOfAListGetsItsOwnParentcallsPlanGeneratorTest::testEveryOtherRelationOfAParentIsStillFollowedcallsPlanGeneratorTest::testFixingTheLinkingColumnLeavesTheParentAlonecallsPlanGeneratorTest::testGenerateTheTableThePlanIsAboutGetsOneRowcallsPlanGeneratorTest::testKeysAreStoodInForEveryColumnARelationReadscallsPlanGeneratorTest::testOneSetOfValuesAppliesToEveryGeneratedRowcallsPlanGeneratorTest::testOverridesMayBeGivenAsTableOverridescallsPlanGeneratorTest::testTablesThatStandAloneAreGeneratedToocallsPlanGeneratorTest::testTheSubjectHonoursACountItWasGivencallsPlanGeneratorTest::testTheSubjectIsOneRowEvenWhenSomethingReferencesItcallsPlanSchemaExceptionTestcallsPlanSchemaValidatorTest::aColumnTheTableDoesNotHaveIsRejectedcallsPlanSchemaValidatorTest::testAGeneratedColumnCannotBeLinkedcallsPlanSchemaValidatorTest::testAGeneratedColumnCannotBeWrittenIntoEithercallsPlanSchemaValidatorTest::testATableNamedWithoutAnyRelationIsCheckedToocallsPlanSchemaValidatorTest::testATableTheResolverDoesNotKnowIsRejectedcallsPlanSchemaValidatorTest::testValidateAPlanMatchingTheSchemaPassescallsEndpointValidatorTestcallsFixtureProviderTestcallsConstructorHydrationTestcallsPropertyHydrationTestcallsColumnRefTestcallsPlanStatementsTestcallsRelationCursorTestcallsRelationReaderTestcallsPlanParserTestcallsPlanPrinterTest::testPrintsATableOnlyPlanAsItsTableNamecallsPlanStructureExceptionTestcallsPlanSyntaxExceptionTestcallsPlanTablesTest::testStandaloneTablesExcludesRelationEndpointscallsRelationGroupsTestcallsStatementPrinterTestcallsRelationTestcallsPlanValidationTestcallsTableNameTest::testAssertTableNameAcceptsUnderscoresAndDollarSignscallsSqlSchemaProviderTestcalls
Relations§
Instantiated in 1
Static calls 1
Method calls 3
- method-call SqlFixture\Fixture\Generation\RelationProjection::referencedColumns() packages/sql-fixture/src/Fixture/Generation/RelationProjection.php:25
- method-call SqlFixture\Fixture\Generation\RowMaterializer::materializeRow() packages/sql-fixture/src/Fixture/Generation/RowMaterializer.php:87
- method-call SqlFixture\Fixture\Generation\RowMaterializer::materializeRow() packages/sql-fixture/src/Fixture/Generation/RowMaterializer.php:103
Type declarations 14
- type SqlFixture\Fixture\Generation\ConnectedTables packages/sql-fixture/src/Fixture/Generation/ConnectedTables.php:21
- type SqlFixture\Fixture\Generation\RelationProjection packages/sql-fixture/src/Fixture/Generation/RelationProjection.php:21
- type SqlFixture\Fixture\Generation\RowMaterializer packages/sql-fixture/src/Fixture/Generation/RowMaterializer.php:36
- type SqlFixture\Fixture\Generation\RowMaterializer packages/sql-fixture/src/Fixture/Generation/RowMaterializer.php:60
- type SqlFixture\Fixture\Generation\RowMaterializer packages/sql-fixture/src/Fixture/Generation/RowMaterializer.php:75
- type SqlFixture\Fixture\Generation\RowMaterializer packages/sql-fixture/src/Fixture/Generation/RowMaterializer.php:123
- type SqlFixture\Fixture\Generation\RowMaterializer packages/sql-fixture/src/Fixture/Generation/RowMaterializer.php:146
- type SqlFixture\Fixture\GenerationRun packages/sql-fixture/src/Fixture/GenerationRun.php:128
- type SqlFixture\Fixture\PlanGenerator packages/sql-fixture/src/Fixture/PlanGenerator.php:44
- type SqlFixture\Fixture\PlanSchemaValidator packages/sql-fixture/src/Fixture/PlanSchemaValidator.php:33
- type SqlFixture\FixtureProvider packages/sql-fixture/src/FixtureProvider.php:91
- type SqlFixture\Plan\PlanParser packages/sql-fixture/src/Plan/PlanParser.php:33
- type SqlFixture\Plan\PlanPrinter packages/sql-fixture/src/Plan/PlanPrinter.php:19
- type SqlFixture\Plan\Printing\PlanTables packages/sql-fixture/src/Plan/Printing/PlanTables.php:24