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
This commit is contained in:
Mark Baker 2019-07-27 14:28:16 +02:00 committed by GitHub
parent 1c6f0b8a9d
commit 26e87c45ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 1070 additions and 438 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class CharTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerCHAR
*
* @param mixed $expectedResult
* @param $character
*/
public function testCHAR($expectedResult, $character)
{
$result = TextData::CHARACTER($character);
$this->assertEquals($expectedResult, $result);
}
public function providerCHAR()
{
return require 'data/Calculation/TextData/CHAR.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class CleanTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerCLEAN
*
* @param mixed $expectedResult
* @param $value
*/
public function testCLEAN($expectedResult, $value)
{
$result = TextData::TRIMNONPRINTABLE($value);
$this->assertEquals($expectedResult, $result);
}
public function providerCLEAN()
{
return require 'data/Calculation/TextData/CLEAN.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class CodeTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerCODE
*
* @param mixed $expectedResult
* @param $character
*/
public function testCODE($expectedResult, $character)
{
$result = TextData::ASCIICODE($character);
$this->assertEquals($expectedResult, $result);
}
public function providerCODE()
{
return require 'data/Calculation/TextData/CODE.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class ConcatenateTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerCONCATENATE
*
* @param mixed $expectedResult
*/
public function testCONCATENATE($expectedResult, ...$args)
{
$result = TextData::CONCATENATE(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerCONCATENATE()
{
return require 'data/Calculation/TextData/CONCATENATE.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class DollarTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerDOLLAR
*
* @param mixed $expectedResult
*/
public function testDOLLAR($expectedResult, ...$args)
{
$result = TextData::DOLLAR(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerDOLLAR()
{
return require 'data/Calculation/TextData/DOLLAR.php';
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class ExactTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerEXACT
*
* @param mixed $expectedResult
* @param array $args
*/
public function testEXACT($expectedResult, ...$args)
{
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(' ');
StringHelper::setCurrencyCode('$');
$result = TextData::EXACT(...$args);
$this->assertSame($expectedResult, $result);
}
/**
* @return array
*/
public function providerEXACT()
{
return require 'data/Calculation/TextData/EXACT.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class FindTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerFIND
*
* @param mixed $expectedResult
*/
public function testFIND($expectedResult, ...$args)
{
$result = TextData::SEARCHSENSITIVE(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerFIND()
{
return require 'data/Calculation/TextData/FIND.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class FixedTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerFIXED
*
* @param mixed $expectedResult
*/
public function testFIXED($expectedResult, ...$args)
{
$result = TextData::FIXEDFORMAT(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerFIXED()
{
return require 'data/Calculation/TextData/FIXED.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class LeftTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerLEFT
*
* @param mixed $expectedResult
*/
public function testLEFT($expectedResult, ...$args)
{
$result = TextData::LEFT(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerLEFT()
{
return require 'data/Calculation/TextData/LEFT.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class LenTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerLEN
*
* @param mixed $expectedResult
* @param $value
*/
public function testLEN($expectedResult, $value)
{
$result = TextData::STRINGLENGTH($value);
$this->assertEquals($expectedResult, $result);
}
public function providerLEN()
{
return require 'data/Calculation/TextData/LEN.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class LowerTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerLOWER
*
* @param mixed $expectedResult
* @param $value
*/
public function testLOWER($expectedResult, $value)
{
$result = TextData::LOWERCASE($value);
$this->assertEquals($expectedResult, $result);
}
public function providerLOWER()
{
return require 'data/Calculation/TextData/LOWER.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class MidTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerMID
*
* @param mixed $expectedResult
*/
public function testMID($expectedResult, ...$args)
{
$result = TextData::MID(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerMID()
{
return require 'data/Calculation/TextData/MID.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class NumberValueTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerNUMBERVALUE
*
* @param mixed $expectedResult
* @param array $args
*/
public function testNUMBERVALUE($expectedResult, array $args)
{
$result = TextData::NUMBERVALUE(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerNUMBERVALUE()
{
return require 'data/Calculation/TextData/NUMBERVALUE.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class ProperTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerPROPER
*
* @param mixed $expectedResult
* @param $value
*/
public function testPROPER($expectedResult, $value)
{
$result = TextData::PROPERCASE($value);
$this->assertEquals($expectedResult, $result);
}
public function providerPROPER()
{
return require 'data/Calculation/TextData/PROPER.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class ReplaceTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerREPLACE
*
* @param mixed $expectedResult
*/
public function testREPLACE($expectedResult, ...$args)
{
$result = TextData::REPLACE(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerREPLACE()
{
return require 'data/Calculation/TextData/REPLACE.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class RightTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerRIGHT
*
* @param mixed $expectedResult
*/
public function testRIGHT($expectedResult, ...$args)
{
$result = TextData::RIGHT(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerRIGHT()
{
return require 'data/Calculation/TextData/RIGHT.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class SearchTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerSEARCH
*
* @param mixed $expectedResult
*/
public function testSEARCH($expectedResult, ...$args)
{
$result = TextData::SEARCHINSENSITIVE(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerSEARCH()
{
return require 'data/Calculation/TextData/SEARCH.php';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class SubstituteTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerSUBSTITUTE
*
* @param mixed $expectedResult
*/
public function testSUBSTITUTE($expectedResult, ...$args)
{
$result = TextData::SUBSTITUTE(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerSUBSTITUTE()
{
return require 'data/Calculation/TextData/SUBSTITUTE.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class TTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerT
*
* @param mixed $expectedResult
* @param $value
*/
public function testT($expectedResult, $value)
{
$result = TextData::RETURNSTRING($value);
$this->assertEquals($expectedResult, $result);
}
public function providerT()
{
return require 'data/Calculation/TextData/T.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class TextJoinTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerTEXTJOIN
*
* @param mixed $expectedResult
* @param array $args
*/
public function testTEXTJOIN($expectedResult, array $args)
{
$result = TextData::TEXTJOIN(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerTEXTJOIN()
{
return require 'data/Calculation/TextData/TEXTJOIN.php';
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class TextTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerTEXT
*
* @param mixed $expectedResult
*/
public function testTEXT($expectedResult, ...$args)
{
// Enforce decimal and thousands separator values to UK/US, and currency code to USD
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
$result = TextData::TEXTFORMAT(...$args);
$this->assertEquals($expectedResult, $result);
}
public function providerTEXT()
{
return require 'data/Calculation/TextData/TEXT.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class TrimTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerTRIM
*
* @param mixed $expectedResult
* @param $character
*/
public function testTRIM($expectedResult, $character)
{
$result = TextData::TRIMSPACES($character);
$this->assertEquals($expectedResult, $result);
}
public function providerTRIM()
{
return require 'data/Calculation/TextData/TRIM.php';
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class UpperTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerUPPER
*
* @param mixed $expectedResult
* @param $value
*/
public function testUPPER($expectedResult, $value)
{
$result = TextData::UPPERCASE($value);
$this->assertEquals($expectedResult, $result);
}
public function providerUPPER()
{
return require 'data/Calculation/TextData/UPPER.php';
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class ValueTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerVALUE
*
* @param mixed $expectedResult
* @param $value
*/
public function testVALUE($expectedResult, $value)
{
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(' ');
StringHelper::setCurrencyCode('$');
$result = TextData::VALUE($value);
$this->assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerVALUE()
{
return require 'data/Calculation/TextData/VALUE.php';
}
}

View File

@ -1,430 +0,0 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
use PHPUnit\Framework\TestCase;
class TextDataTest extends TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
public function tearDown()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
}
/**
* @dataProvider providerCHAR
*
* @param mixed $expectedResult
*/
public function testCHAR($expectedResult, ...$args)
{
$result = TextData::CHARACTER(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerCHAR()
{
return require 'data/Calculation/TextData/CHAR.php';
}
/**
* @dataProvider providerCODE
*
* @param mixed $expectedResult
*/
public function testCODE($expectedResult, ...$args)
{
$result = TextData::ASCIICODE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerCODE()
{
return require 'data/Calculation/TextData/CODE.php';
}
/**
* @dataProvider providerCONCATENATE
*
* @param mixed $expectedResult
*/
public function testCONCATENATE($expectedResult, ...$args)
{
$result = TextData::CONCATENATE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerCONCATENATE()
{
return require 'data/Calculation/TextData/CONCATENATE.php';
}
/**
* @dataProvider providerLEFT
*
* @param mixed $expectedResult
*/
public function testLEFT($expectedResult, ...$args)
{
$result = TextData::LEFT(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerLEFT()
{
return require 'data/Calculation/TextData/LEFT.php';
}
/**
* @dataProvider providerMID
*
* @param mixed $expectedResult
*/
public function testMID($expectedResult, ...$args)
{
$result = TextData::MID(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerMID()
{
return require 'data/Calculation/TextData/MID.php';
}
/**
* @dataProvider providerRIGHT
*
* @param mixed $expectedResult
*/
public function testRIGHT($expectedResult, ...$args)
{
$result = TextData::RIGHT(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerRIGHT()
{
return require 'data/Calculation/TextData/RIGHT.php';
}
/**
* @dataProvider providerLOWER
*
* @param mixed $expectedResult
*/
public function testLOWER($expectedResult, ...$args)
{
$result = TextData::LOWERCASE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerLOWER()
{
return require 'data/Calculation/TextData/LOWER.php';
}
/**
* @dataProvider providerUPPER
*
* @param mixed $expectedResult
*/
public function testUPPER($expectedResult, ...$args)
{
$result = TextData::UPPERCASE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerUPPER()
{
return require 'data/Calculation/TextData/UPPER.php';
}
/**
* @dataProvider providerPROPER
*
* @param mixed $expectedResult
*/
public function testPROPER($expectedResult, ...$args)
{
$result = TextData::PROPERCASE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerPROPER()
{
return require 'data/Calculation/TextData/PROPER.php';
}
/**
* @dataProvider providerLEN
*
* @param mixed $expectedResult
*/
public function testLEN($expectedResult, ...$args)
{
$result = TextData::STRINGLENGTH(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerLEN()
{
return require 'data/Calculation/TextData/LEN.php';
}
/**
* @dataProvider providerSEARCH
*
* @param mixed $expectedResult
*/
public function testSEARCH($expectedResult, ...$args)
{
$result = TextData::SEARCHINSENSITIVE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerSEARCH()
{
return require 'data/Calculation/TextData/SEARCH.php';
}
/**
* @dataProvider providerFIND
*
* @param mixed $expectedResult
*/
public function testFIND($expectedResult, ...$args)
{
$result = TextData::SEARCHSENSITIVE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerFIND()
{
return require 'data/Calculation/TextData/FIND.php';
}
/**
* @dataProvider providerREPLACE
*
* @param mixed $expectedResult
*/
public function testREPLACE($expectedResult, ...$args)
{
$result = TextData::REPLACE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerREPLACE()
{
return require 'data/Calculation/TextData/REPLACE.php';
}
/**
* @dataProvider providerSUBSTITUTE
*
* @param mixed $expectedResult
*/
public function testSUBSTITUTE($expectedResult, ...$args)
{
$result = TextData::SUBSTITUTE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerSUBSTITUTE()
{
return require 'data/Calculation/TextData/SUBSTITUTE.php';
}
/**
* @dataProvider providerTRIM
*
* @param mixed $expectedResult
*/
public function testTRIM($expectedResult, ...$args)
{
$result = TextData::TRIMSPACES(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerTRIM()
{
return require 'data/Calculation/TextData/TRIM.php';
}
/**
* @dataProvider providerCLEAN
*
* @param mixed $expectedResult
*/
public function testCLEAN($expectedResult, ...$args)
{
$result = TextData::TRIMNONPRINTABLE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerCLEAN()
{
return require 'data/Calculation/TextData/CLEAN.php';
}
/**
* @dataProvider providerDOLLAR
*
* @param mixed $expectedResult
*/
public function testDOLLAR($expectedResult, ...$args)
{
$result = TextData::DOLLAR(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerDOLLAR()
{
return require 'data/Calculation/TextData/DOLLAR.php';
}
/**
* @dataProvider providerFIXED
*
* @param mixed $expectedResult
*/
public function testFIXED($expectedResult, ...$args)
{
$result = TextData::FIXEDFORMAT(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerFIXED()
{
return require 'data/Calculation/TextData/FIXED.php';
}
/**
* @dataProvider providerT
*
* @param mixed $expectedResult
*/
public function testT($expectedResult, ...$args)
{
$result = TextData::RETURNSTRING(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerT()
{
return require 'data/Calculation/TextData/T.php';
}
/**
* @dataProvider providerTEXT
*
* @param mixed $expectedResult
*/
public function testTEXT($expectedResult, ...$args)
{
// Enforce decimal and thousands separator values to UK/US, and currency code to USD
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(',');
StringHelper::setCurrencyCode('$');
$result = TextData::TEXTFORMAT(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerTEXT()
{
return require 'data/Calculation/TextData/TEXT.php';
}
/**
* @dataProvider providerVALUE
*
* @param mixed $expectedResult
*/
public function testVALUE($expectedResult, ...$args)
{
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(' ');
StringHelper::setCurrencyCode('$');
$result = TextData::VALUE(...$args);
self::assertEquals($expectedResult, $result, '', 1E-8);
}
public function providerVALUE()
{
return require 'data/Calculation/TextData/VALUE.php';
}
/**
* @dataProvider providerEXACT
*
* @param mixed $expectedResult
* @param array $args
*/
public function testEXACT($expectedResult, ...$args)
{
StringHelper::setDecimalSeparator('.');
StringHelper::setThousandsSeparator(' ');
StringHelper::setCurrencyCode('$');
$result = TextData::EXACT(...$args);
self::assertSame($expectedResult, $result);
}
/**
* @return array
*/
public function providerEXACT()
{
return require 'data/Calculation/TextData/EXACT.php';
}
/**
* @dataProvider providerTEXTJOIN
*
* @param mixed $expectedResult
* @param array $args
*/
public function testTEXTJOIN($expectedResult, array $args)
{
$result = TextData::TEXTJOIN(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerTEXTJOIN()
{
return require 'data/Calculation/TextData/TEXTJOIN.php';
}
/**
* @dataProvider providerNUMBERVALUE
*
* @param mixed $expectedResult
* @param array $args
*/
public function testNUMBERVALUE($expectedResult, array $args)
{
$result = TextData::NUMBERVALUE(...$args);
self::assertEquals($expectedResult, $result);
}
public function providerNUMBERVALUE()
{
return require 'data/Calculation/TextData/NUMBERVALUE.php';
}
}