mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Added PHPCS fixes and better array diff handling on fixture data count difference
This commit is contained in:
parent
b0d0143b82
commit
9ecdaf7965
1 changed files with 5 additions and 16 deletions
|
@ -291,23 +291,12 @@ class CakeTestFixture {
|
||||||
$merge = array_values($mergeData);
|
$merge = array_values($mergeData);
|
||||||
if (count($fields) !== count($merge)) {
|
if (count($fields) !== count($merge)) {
|
||||||
|
|
||||||
$mergeFields = array_keys( $mergeData );
|
$mergeFields = array_diff_key(array_keys($mergeData), $fields);
|
||||||
$remove = array();
|
|
||||||
|
|
||||||
foreach ($fields as $k => $f) {
|
|
||||||
if (in_array( $f, $mergeFields )) {
|
|
||||||
$remove[] = $f;
|
|
||||||
unset( $fields[$k] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$mergeFields = array_diff( $mergeFields, $remove );
|
|
||||||
$message = 'Fixture invalid: Count of fields does not match count of values in ' . get_class($this)."\n";
|
$message = 'Fixture invalid: Count of fields does not match count of values in ' . get_class($this)."\n";
|
||||||
foreach ($mergeFields as $field) {
|
foreach ($mergeFields as $field) {
|
||||||
$message .= "The field '".$field."' is in the data fixture but not in the schema."."\n";
|
$message .= "The field '".$field."' is in the data fixture but not in the schema."."\n";
|
||||||
}
|
}
|
||||||
foreach ($fields as $field) {
|
|
||||||
$message .= "The field '" . $field . "' is in the fixture but not in the data." . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new CakeException( $message );
|
throw new CakeException( $message );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue