classForeignKeyViolationException
final class ForeignKeyViolationException
extends SimulationException
Exception thrown when a FOREIGN KEY constraint is violated.
Methods§
public static function of(
string $sql,
string $tableName,
string $constraintName,
string $referencedTable,
list<string> $referencedColumns,
): selfReports a constraint a statement left broken, or was forbidden by.
A key may point at several columns; the message names the first, which is what a database says too.
Parameters
$sql | string | Statement being simulated |
$tableName | string | Table holding the key |
$constraintName | string | Constraint that was not honoured |
$referencedTable | string | Table the key points at |
$referencedColumns | list<string> | Columns it points at |
Returns
self Exception naming the constraint and what it points atTest cases 2
Called from 2
Calls 1
- new
selfline 58
public function __construct(
string $sql,
string $tableName,
string $constraintName,
string $referencedTable,
string $referencedColumn,
)Parameters
$sql | string | The SQL statement. |
$tableName | string | The name of the table. |
$constraintName | string | The name of the foreign key constraint. |
$referencedTable | string | The name of the referenced table. |
$referencedColumn | string | The name of the referenced column. |
Test cases 8
ForeignKeyViolationExceptionTest::testGetConstraintNameReturnsConstraintNamecoversForeignKeyViolationExceptionTest::testGetMessageReturnsFormattedMessagecoversForeignKeyViolationExceptionTest::testGetReferencedColumnReturnsReferencedColumncoversForeignKeyViolationExceptionTest::testGetReferencedTableReturnsReferencedTablecoversForeignKeyViolationExceptionTest::testGetSqlReturnsOriginalSqlcoversForeignKeyViolationExceptionTest::testGetTableNameReturnsTableNamecoversForeignKeyViolationExceptionTest::testOfNamesNoColumnWhereTheKeyPointsAtNonecoversForeignKeyViolationExceptionTest::testOfNamesTheFirstColumnTheKeyPointsAtcovers
Calls 2
- static-call SimulationException::__construct() line 81
- function-call
sprintfline 81
public function getSql(): stringGet the SQL statement.
Returns
stringTest cases 1
ForeignKeyViolationExceptionTest::testGetSqlReturnsOriginalSqlcovers and calls
public function getTableName(): stringGet the name of the table.
Returns
stringTest cases 2
public function getConstraintName(): stringGet the name of the foreign key constraint.
Returns
stringTest cases 1
public function getReferencedTable(): stringGet the name of the referenced table.
Returns
stringTest cases 1
public function getReferencedColumn(): stringGet the name of the referenced column.
Returns
stringPrivate surface 5§
Implementation details, listed for orientation only.
private string $sqlprivate string $tableNameprivate string $constraintNameprivate string $referencedTableprivate string $referencedColumnTest cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
ForeignKeyViolationExceptionTest::testGetConstraintNameReturnsConstraintNamecovers and callsForeignKeyViolationExceptionTest::testGetMessageReturnsFormattedMessagecovers and callsForeignKeyViolationExceptionTest::testGetReferencedColumnReturnsReferencedColumncovers and callsForeignKeyViolationExceptionTest::testGetReferencedTableReturnsReferencedTablecovers and callsForeignKeyViolationExceptionTest::testGetSqlReturnsOriginalSqlcovers and callsForeignKeyViolationExceptionTest::testGetTableNameReturnsTableNamecovers and callsForeignKeyViolationExceptionTest::testOfNamesNoColumnWhereTheKeyPointsAtNonecovers and callsForeignKeyViolationExceptionTest::testOfNamesTheFirstColumnTheKeyPointsAtcovers and calls
Other tests reaching this symbol 7
SessionTest::testForeignKeyFailureRestoresShadowStatecallsForeignKeyCascadeTest::testApplyActionRefusesTheStatementWhereTheActionForbidsItcallsForeignKeyIntegrityTest::testAssertHoldsRefusesAShadowInWhichAChildReferencesNothingcallsReferentialIntegrityEnforcerTest::testDeleteRestrictRejectsParentRemovalcallsReferentialIntegrityEnforcerTest::testFallbackReferencedPrimaryKeyAppearsInUpdateViolationcallsReferentialIntegrityEnforcerTest::testRejectsInsertWhoseParentDoesNotExistcallsReferentialIntegrityEnforcerTest::testValidationContinuesPastMissingAndNullForeignKeyscalls