From a2d04589a6d98179b2fa094cdbf065a0233526aa Mon Sep 17 00:00:00 2001 From: tranfuga25s Date: Fri, 5 Dec 2014 15:23:48 -0300 Subject: [PATCH] Change to output the difference between fixture data and fields --- .../TestSuite/Fixture/CakeTestFixture.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index 329eef27f..fc70aa519 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -287,9 +287,25 @@ class CakeTestFixture { $fields = array_unique($fields); $default = array_fill_keys($fields, null); foreach ($this->records as $record) { - $merge = array_values(array_merge($default, $record)); + $merge_data = array_merge( $default, $record ); + $merge = array_values( $temporal ); if (count($fields) !== count($merge)) { - throw new CakeException('Fixture invalid: Count of fields does not match count of values in ' . get_class($this)); + + $merge_fields = array_keys( $merge_data ); + $remove = array(); + + foreach( $fields as $f ) { + if( in_array( $f, $merge_fields ) ) { + $remove[] = $f; + } + } + $merge_fields = array_diff( $merge_fields, $remove ); + $message = 'Fixture invalid: Count of fields does not match count of values in ' . get_class($this)."\n"; + foreach( $merge_fields as $field ) { + $message .= "The field '".$field."' is not in the fixture used in the schema."."\n"; + } + + throw new CakeException( $message ); } $values[] = $merge; }