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. |
Calls 2
- static-call SimulationException::__construct() line 81
- function-call
sprintfline 81
public function getSql(): stringGet the SQL statement.
Returns
stringTest cases 1
public function getTableName(): stringGet the name of the table.
Returns
stringTest cases 1
public function getConstraintName(): stringGet the name of the foreign key constraint.
Returns
stringpublic function getReferencedTable(): stringGet the name of the referenced table.
Returns
stringpublic 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 16§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
ForeignKeyViolationExceptionTest::testGetConstraintNameReturnsConstraintNamecallsForeignKeyViolationExceptionTest::testGetMessageReturnsFormattedMessagecallsForeignKeyViolationExceptionTest::testGetReferencedColumnReturnsReferencedColumncallsForeignKeyViolationExceptionTest::testGetReferencedTableReturnsReferencedTablecallsForeignKeyViolationExceptionTest::testGetSqlReturnsOriginalSqlcallsForeignKeyViolationExceptionTest::testGetTableNameReturnsTableNamecallsForeignKeyViolationExceptionTest::testOfNamesNoColumnWhereTheKeyPointsAtNonecallsForeignKeyViolationExceptionTest::testOfNamesTheFirstColumnTheKeyPointsAtcalls
Other tests reaching this symbol 8
ExecutionCheck::verifycallsSessionTest::testForeignKeyFailureRestoresShadowStatecallsForeignKeyCascadeTest::testApplyActionRefusesTheStatementWhereTheActionForbidsItcallsForeignKeyIntegrityTest::testAssertHoldsRefusesAShadowInWhichAChildReferencesNothingcallsReferentialIntegrityEnforcerTest::testDeleteRestrictRejectsParentRemovalcallsReferentialIntegrityEnforcerTest::testFallbackReferencedPrimaryKeyAppearsInUpdateViolationcallsReferentialIntegrityEnforcerTest::testRejectsInsertWhoseParentDoesNotExistcallsReferentialIntegrityEnforcerTest::testValidationContinuesPastMissingAndNullForeignKeyscalls