From 9ecdaf79655db798bfd48886cc3d3bd7a6792aa8 Mon Sep 17 00:00:00 2001 From: tranfuga25s Date: Tue, 9 Dec 2014 08:56:34 -0300 Subject: [PATCH] Added PHPCS fixes and better array diff handling on fixture data count difference --- .../TestSuite/Fixture/CakeTestFixture.php | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index e31f38986..c8b2a0182 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -287,26 +287,15 @@ class CakeTestFixture { $fields = array_unique($fields); $default = array_fill_keys($fields, null); foreach ($this->records as $record) { - $mergeData = array_merge( $default, $record ); - $merge = array_values( $mergeData ); + $mergeData = array_merge($default, $record); + $merge = array_values($mergeData); if (count($fields) !== count($merge)) { - $mergeFields = array_keys( $mergeData ); - $remove = array(); + $mergeFields = array_diff_key(array_keys($mergeData), $fields); - 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) { - $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"; + $message .= "The field '".$field."' is in the data fixture but not in the schema."."\n"; } throw new CakeException( $message );