From 26e87c45aef073206237f28f53f699dd5f1ba969 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 27 Jul 2019 14:28:16 +0200 Subject: [PATCH] Test refactoring (#1112) * Merge branch 'master' of C:\Projects\PHPOffice\PHPSpreadsheet\develop with conflicts. * Argument fix * Text Test functions refactored into individual test files * Codestyle (line at eof) * docblocks --- .../Functions/DateTime/DateTest.php | 2 +- .../Functions/DateTime/DateValueTest.php | 2 +- .../Functions/DateTime/EDateTest.php | 2 +- .../Functions/DateTime/EoMonthTest.php | 2 +- .../Functions/DateTime/TimeTest.php | 2 +- .../Functions/DateTime/TimeValueTest.php | 2 +- .../Functions/Statistical/GammaLnTest.php | 5 +- .../Functions/TextData/CharTest.php | 44 ++ .../Functions/TextData/CleanTest.php | 44 ++ .../Functions/TextData/CodeTest.php | 44 ++ .../Functions/TextData/ConcatenateTest.php | 43 ++ .../Functions/TextData/DollarTest.php | 43 ++ .../Functions/TextData/ExactTest.php | 51 +++ .../Functions/TextData/FindTest.php | 43 ++ .../Functions/TextData/FixedTest.php | 43 ++ .../Functions/TextData/LeftTest.php | 43 ++ .../Functions/TextData/LenTest.php | 44 ++ .../Functions/TextData/LowerTest.php | 44 ++ .../Functions/TextData/MidTest.php | 43 ++ .../Functions/TextData/NumberValueTest.php | 44 ++ .../Functions/TextData/ProperTest.php | 44 ++ .../Functions/TextData/ReplaceTest.php | 43 ++ .../Functions/TextData/RightTest.php | 43 ++ .../Functions/TextData/SearchTest.php | 43 ++ .../Functions/TextData/SubstituteTest.php | 43 ++ .../Calculation/Functions/TextData/TTest.php | 44 ++ .../Functions/TextData/TextJoinTest.php | 44 ++ .../Functions/TextData/TextTest.php | 48 ++ .../Functions/TextData/TrimTest.php | 44 ++ .../Functions/TextData/UpperTest.php | 44 ++ .../Functions/TextData/ValueTest.php | 48 ++ .../Calculation/TextDataTest.php | 430 ------------------ 32 files changed, 1070 insertions(+), 438 deletions(-) create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php create mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/TextDataTest.php diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index 6628322a..447e504e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -49,7 +49,7 @@ class DateTest extends TestCase $result = DateTime::DATE(2012, 1, 31); // Must return an object... - self::assertIsObject($result); + $this->assertIsObject($result); // ... of the correct type $this->assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index 2c4e96eb..236da6c7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -48,7 +48,7 @@ class DateValueTest extends TestCase $result = DateTime::DATEVALUE('2012-1-31'); // Must return an object... - self::assertIsObject($result); + $this->assertIsObject($result); // ... of the correct type $this->assertTrue(is_a($result, DateTimeInterface::class)); // ... with the correct value diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php index 7f885096..eead7441 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -48,7 +48,7 @@ class EDateTest extends TestCase $result = DateTime::EDATE('2012-1-26', -1); // Must return an object... - self::assertIsObject($result); + $this->assertIsObject($result); // ... of the correct type $this->assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php index 6092151a..5e1c52a1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -48,7 +48,7 @@ class EoMonthTest extends TestCase $result = DateTime::EOMONTH('2012-1-26', -1); // Must return an object... - self::assertIsObject($result); + $this->assertIsObject($result); // ... of the correct type $this->assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index 61406f5a..8debe7a1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -46,7 +46,7 @@ class TimeTest extends TestCase $result = DateTime::TIME(7, 30, 20); // Must return an object... - self::assertIsObject($result); + $this->assertIsObject($result); // ... of the correct type $this->assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index d1adfc62..52fe18f6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -47,7 +47,7 @@ class TimeValueTest extends TestCase $result = DateTime::TIMEVALUE('7:30:20'); // Must return an object... - self::assertIsObject($result); + $this->assertIsObject($result); // ... of the correct type $this->assertTrue(is_a($result, 'DateTimeInterface')); // ... with the correct value diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php index 02b11af3..436996ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -17,10 +17,11 @@ class GammaLnTest extends TestCase * @dataProvider providerGAMMALN * * @param mixed $expectedResult + * @param $value */ - public function testGAMMALN($expectedResult, ...$args) + public function testGAMMALN($expectedResult, $value) { - $result = Statistical::GAMMALN(...$args); + $result = Statistical::GAMMALN($value); $this->assertEquals($expectedResult, $result, '', 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php new file mode 100644 index 00000000..7ae50fa7 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerCHAR() + { + return require 'data/Calculation/TextData/CHAR.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php new file mode 100644 index 00000000..3286e6fd --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerCLEAN() + { + return require 'data/Calculation/TextData/CLEAN.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php new file mode 100644 index 00000000..a22c1401 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerCODE() + { + return require 'data/Calculation/TextData/CODE.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php new file mode 100644 index 00000000..46ea0cb7 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerCONCATENATE() + { + return require 'data/Calculation/TextData/CONCATENATE.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php new file mode 100644 index 00000000..af49a7d0 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerDOLLAR() + { + return require 'data/Calculation/TextData/DOLLAR.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php new file mode 100644 index 00000000..8c47be47 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -0,0 +1,51 @@ +assertSame($expectedResult, $result); + } + + /** + * @return array + */ + public function providerEXACT() + { + return require 'data/Calculation/TextData/EXACT.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php new file mode 100644 index 00000000..86ae5e77 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerFIND() + { + return require 'data/Calculation/TextData/FIND.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php new file mode 100644 index 00000000..d46f0e48 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerFIXED() + { + return require 'data/Calculation/TextData/FIXED.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php new file mode 100644 index 00000000..18d6c258 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerLEFT() + { + return require 'data/Calculation/TextData/LEFT.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php new file mode 100644 index 00000000..ad3dc00c --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerLEN() + { + return require 'data/Calculation/TextData/LEN.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php new file mode 100644 index 00000000..52fd3afe --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerLOWER() + { + return require 'data/Calculation/TextData/LOWER.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php new file mode 100644 index 00000000..d0db50e0 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerMID() + { + return require 'data/Calculation/TextData/MID.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php new file mode 100644 index 00000000..9de91f7e --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerNUMBERVALUE() + { + return require 'data/Calculation/TextData/NUMBERVALUE.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php new file mode 100644 index 00000000..4e1b0b76 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerPROPER() + { + return require 'data/Calculation/TextData/PROPER.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php new file mode 100644 index 00000000..dd4411a0 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerREPLACE() + { + return require 'data/Calculation/TextData/REPLACE.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php new file mode 100644 index 00000000..64fb0e5b --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerRIGHT() + { + return require 'data/Calculation/TextData/RIGHT.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php new file mode 100644 index 00000000..c77742b6 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerSEARCH() + { + return require 'data/Calculation/TextData/SEARCH.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php new file mode 100644 index 00000000..2fdb1091 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -0,0 +1,43 @@ +assertEquals($expectedResult, $result); + } + + public function providerSUBSTITUTE() + { + return require 'data/Calculation/TextData/SUBSTITUTE.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php new file mode 100644 index 00000000..90104a17 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerT() + { + return require 'data/Calculation/TextData/T.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php new file mode 100644 index 00000000..690db346 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerTEXTJOIN() + { + return require 'data/Calculation/TextData/TEXTJOIN.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php new file mode 100644 index 00000000..dbcd0900 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -0,0 +1,48 @@ +assertEquals($expectedResult, $result); + } + + public function providerTEXT() + { + return require 'data/Calculation/TextData/TEXT.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php new file mode 100644 index 00000000..2a9fe94e --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerTRIM() + { + return require 'data/Calculation/TextData/TRIM.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php new file mode 100644 index 00000000..60c894d6 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -0,0 +1,44 @@ +assertEquals($expectedResult, $result); + } + + public function providerUPPER() + { + return require 'data/Calculation/TextData/UPPER.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php new file mode 100644 index 00000000..b6c29f3d --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -0,0 +1,48 @@ +assertEquals($expectedResult, $result, '', 1E-8); + } + + public function providerVALUE() + { + return require 'data/Calculation/TextData/VALUE.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php b/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php deleted file mode 100644 index 32d7605f..00000000 --- a/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php +++ /dev/null @@ -1,430 +0,0 @@ -