From 36a9068b38f1df02f137617e2d5acbda78635e5a Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Fri, 20 May 2016 08:41:09 +0200 Subject: [PATCH] #401 : PHPUnit Fixes (Calculation > LookupRef) --- src/PhpSpreadsheet/Calculation/LookupRef.php | 3 +-- unitTests/Classes/src/Calculation/LookupRefTest.php | 4 ++++ unitTests/rawTestData/Calculation/LookupRef/VLOOKUP.data | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 359fa164..5e76633b 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -768,7 +768,7 @@ class LookupRef } else { $f = array_keys($lookup_array); $firstRow = array_pop($f); - if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) { + if ((!is_array($lookup_array[$firstRow])) || ($index_number - 1 > count($lookup_array[$firstRow]))) { return Functions::REF(); } else { $columnKeys = array_keys($lookup_array[$firstRow]); @@ -781,7 +781,6 @@ class LookupRef if (!$not_exact_match) { $firstRowH = asort($lookup_array[$firstColumn]); } - $rowNumber = $rowValue = false; foreach ($lookup_array[$firstColumn] as $rowKey => $rowData) { if ((is_numeric($lookup_value) && is_numeric($rowData) && ($rowData > $lookup_value)) || diff --git a/unitTests/Classes/src/Calculation/LookupRefTest.php b/unitTests/Classes/src/Calculation/LookupRefTest.php index fdf2ab43..43a71088 100644 --- a/unitTests/Classes/src/Calculation/LookupRefTest.php +++ b/unitTests/Classes/src/Calculation/LookupRefTest.php @@ -4,6 +4,10 @@ namespace PHPExcel\Calculation; require_once 'testDataFileIterator.php'; +/** + * Class LookupRefTest + * @package PHPExcel\Calculation + */ class LookupRefTest extends \PHPUnit_Framework_TestCase { diff --git a/unitTests/rawTestData/Calculation/LookupRef/VLOOKUP.data b/unitTests/rawTestData/Calculation/LookupRef/VLOOKUP.data index 8fefc6cc..8466d4f7 100644 --- a/unitTests/rawTestData/Calculation/LookupRef/VLOOKUP.data +++ b/unitTests/rawTestData/Calculation/LookupRef/VLOOKUP.data @@ -1,4 +1,4 @@ -1, {"Density"|"Viscosity"|"Temperature";0.457|3.55|500;0.525|3.25|400;0.616|2.93|300;0.675|2.75|250;0.746|2.57|200;0.835|2.38|150;0.946|2.17|100;1.09|1.95|50;1.29|1.71|0}, 2, FALSE, 2.17 +1, {"Density"|"Viscosity"|"Temperature";0.457|3.55|500;0.525|3.25|400;0.616|2.93|300;0.675|2.75|250;0.746|2.57|200;0.835|2.38|150;0.946|2.17|100;1.09|1.95|50;1.29|1.71|0}, 2, FALSE, "#N/A" 1, {"Density"|"Viscosity"|"Temperature";0.457|3.55|500;0.525|3.25|400;0.616|2.93|300;0.675|2.75|250;0.746|2.57|200;0.835|2.38|150;0.946|2.17|100;1.09|1.95|50;1.29|1.71|0}, 3, TRUE, 100 .7, {"Density"|"Viscosity"|"Temperature";0.457|3.55|500;0.525|3.25|400;0.616|2.93|300;0.675|2.75|250;0.746|2.57|200;0.835|2.38|150;0.946|2.17|100;1.09|1.95|50;1.29|1.71|0}, 3, FALSE, "#N/A" 0.1, {"Density"|"Viscosity"|"Temperature";0.457|3.55|500;0.525|3.25|400;0.616|2.93|300;0.675|2.75|250;0.746|2.57|200;0.835|2.38|150;0.946|2.17|100;1.09|1.95|50;1.29|1.71|0}, 2, TRUE, "#N/A"