Updates to 3rd party libraries
Add Dockerfile and specific docker-php.ini
This commit is contained in:
120
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php
vendored
Normal file
120
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CalculationTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
$calculation->setLocale('en_us');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerBinaryComparisonOperation
|
||||
*
|
||||
* @param mixed $formula
|
||||
* @param mixed $expectedResultExcel
|
||||
* @param mixed $expectedResultOpenOffice
|
||||
*/
|
||||
public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice)
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
$resultExcel = Calculation::getInstance()->_calculateFormulaValue($formula);
|
||||
self::assertEquals($expectedResultExcel, $resultExcel, 'should be Excel compatible');
|
||||
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
|
||||
$resultOpenOffice = Calculation::getInstance()->_calculateFormulaValue($formula);
|
||||
self::assertEquals($expectedResultOpenOffice, $resultOpenOffice, 'should be OpenOffice compatible');
|
||||
}
|
||||
|
||||
public function providerBinaryComparisonOperation()
|
||||
{
|
||||
return require 'data/CalculationBinaryComparisonOperation.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGetFunctions
|
||||
*
|
||||
* @param string $category
|
||||
* @param array|string $functionCall
|
||||
* @param string $argumentCount
|
||||
*/
|
||||
public function testGetFunctions($category, $functionCall, $argumentCount)
|
||||
{
|
||||
self::assertInternalType('callable', $functionCall);
|
||||
}
|
||||
|
||||
public function providerGetFunctions()
|
||||
{
|
||||
return Calculation::getInstance()->getFunctions();
|
||||
}
|
||||
|
||||
public function testIsImplemented()
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
self::assertFalse($calculation->isImplemented('non-existing-function'));
|
||||
self::assertFalse($calculation->isImplemented('AREAS'));
|
||||
self::assertTrue($calculation->isImplemented('coUNt'));
|
||||
self::assertTrue($calculation->isImplemented('abs'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCanLoadAllSupportedLocales
|
||||
*
|
||||
* @param string $locale
|
||||
*/
|
||||
public function testCanLoadAllSupportedLocales($locale)
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
self::assertTrue($calculation->setLocale($locale));
|
||||
}
|
||||
|
||||
public function providerCanLoadAllSupportedLocales()
|
||||
{
|
||||
return [
|
||||
['bg'],
|
||||
['cs'],
|
||||
['da'],
|
||||
['de'],
|
||||
['en_us'],
|
||||
['es'],
|
||||
['fi'],
|
||||
['fr'],
|
||||
['hu'],
|
||||
['it'],
|
||||
['nl'],
|
||||
['no'],
|
||||
['pl'],
|
||||
['pt'],
|
||||
['pt_br'],
|
||||
['ru'],
|
||||
['sv'],
|
||||
['tr'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testDoesHandleXlfnFunctions()
|
||||
{
|
||||
$calculation = Calculation::getInstance();
|
||||
|
||||
$tree = $calculation->parseFormula('=_xlfn.ISFORMULA(A1)');
|
||||
self::assertCount(3, $tree);
|
||||
$function = $tree[2];
|
||||
self::assertEquals('Function', $function['type']);
|
||||
|
||||
$tree = $calculation->parseFormula('=_xlfn.STDEV.S(A1:B2)');
|
||||
self::assertCount(5, $tree);
|
||||
$function = $tree[4];
|
||||
self::assertEquals('Function', $function['type']);
|
||||
}
|
||||
}
|
487
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php
vendored
Normal file
487
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/DateTimeTest.php
vendored
Normal file
@ -0,0 +1,487 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class DateTimeTest.
|
||||
*/
|
||||
class DateTimeTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDATE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDATE($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::DATE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDATE()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/DATE.php';
|
||||
}
|
||||
|
||||
public function testDATEtoPHP()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
|
||||
$result = DateTime::DATE(2012, 1, 31);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
self::assertEquals(1327968000, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function testDATEtoPHPObject()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
|
||||
$result = DateTime::DATE(2012, 1, 31);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
// Must return an object...
|
||||
self::assertInternalType('object', $result);
|
||||
// ... of the correct type
|
||||
self::assertTrue(is_a($result, 'DateTime'));
|
||||
// ... with the correct value
|
||||
self::assertEquals($result->format('d-M-Y'), '31-Jan-2012');
|
||||
}
|
||||
|
||||
public function testDATEwith1904Calendar()
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
|
||||
$result = DateTime::DATE(1918, 11, 11);
|
||||
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
|
||||
self::assertEquals($result, 5428);
|
||||
}
|
||||
|
||||
public function testDATEwith1904CalendarError()
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
|
||||
$result = DateTime::DATE(1901, 1, 31);
|
||||
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
|
||||
self::assertEquals($result, '#NUM!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDATEVALUE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDATEVALUE($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::DATEVALUE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDATEVALUE()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/DATEVALUE.php';
|
||||
}
|
||||
|
||||
public function testDATEVALUEtoPHP()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
|
||||
$result = DateTime::DATEVALUE('2012-1-31');
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
self::assertEquals(1327968000, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function testDATEVALUEtoPHPObject()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
|
||||
$result = DateTime::DATEVALUE('2012-1-31');
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
// Must return an object...
|
||||
self::assertInternalType('object', $result);
|
||||
// ... of the correct type
|
||||
self::assertTrue(is_a($result, 'DateTime'));
|
||||
// ... with the correct value
|
||||
self::assertEquals($result->format('d-M-Y'), '31-Jan-2012');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerYEAR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testYEAR($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::YEAR(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerYEAR()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/YEAR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMONTH
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMONTH($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::MONTHOFYEAR(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerMONTH()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/MONTH.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerWEEKNUM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testWEEKNUM($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::WEEKNUM(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerWEEKNUM()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/WEEKNUM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerISOWEEKNUM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $dateValue
|
||||
*/
|
||||
public function testISOWEEKNUM($expectedResult, $dateValue)
|
||||
{
|
||||
$result = DateTime::ISOWEEKNUM($dateValue);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerISOWEEKNUM()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/ISOWEEKNUM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerWEEKDAY
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testWEEKDAY($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::WEEKDAY(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerWEEKDAY()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/WEEKDAY.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDAY
|
||||
*
|
||||
* @param mixed $expectedResultExcel
|
||||
* @param mixed $expectedResultOpenOffice
|
||||
*/
|
||||
public function testDAY($expectedResultExcel, $expectedResultOpenOffice, ...$args)
|
||||
{
|
||||
$resultExcel = DateTime::DAYOFMONTH(...$args);
|
||||
self::assertEquals($expectedResultExcel, $resultExcel, null, 1E-8);
|
||||
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
|
||||
$resultOpenOffice = DateTime::DAYOFMONTH(...$args);
|
||||
self::assertEquals($expectedResultOpenOffice, $resultOpenOffice, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDAY()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/DAY.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTIME
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testTIME($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::TIME(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerTIME()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/TIME.php';
|
||||
}
|
||||
|
||||
public function testTIMEtoPHP()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
|
||||
$result = DateTime::TIME(7, 30, 20);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
self::assertEquals(27020, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function testTIMEtoPHPObject()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
|
||||
$result = DateTime::TIME(7, 30, 20);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
// Must return an object...
|
||||
self::assertInternalType('object', $result);
|
||||
// ... of the correct type
|
||||
self::assertTrue(is_a($result, 'DateTime'));
|
||||
// ... with the correct value
|
||||
self::assertEquals($result->format('H:i:s'), '07:30:20');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTIMEVALUE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testTIMEVALUE($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::TIMEVALUE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerTIMEVALUE()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/TIMEVALUE.php';
|
||||
}
|
||||
|
||||
public function testTIMEVALUEtoPHP()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
|
||||
$result = DateTime::TIMEVALUE('7:30:20');
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
self::assertEquals(23420, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function testTIMEVALUEtoPHPObject()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
|
||||
$result = DateTime::TIMEVALUE('7:30:20');
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
// Must return an object...
|
||||
self::assertInternalType('object', $result);
|
||||
// ... of the correct type
|
||||
self::assertTrue(is_a($result, 'DateTime'));
|
||||
// ... with the correct value
|
||||
self::assertEquals($result->format('H:i:s'), '07:30:20');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerHOUR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testHOUR($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::HOUROFDAY(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerHOUR()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/HOUR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMINUTE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMINUTE($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::MINUTE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerMINUTE()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/MINUTE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSECOND
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSECOND($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::SECOND(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerSECOND()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/SECOND.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNETWORKDAYS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testNETWORKDAYS($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::NETWORKDAYS(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerNETWORKDAYS()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/NETWORKDAYS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerWORKDAY
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testWORKDAY($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::WORKDAY(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerWORKDAY()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/WORKDAY.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerEDATE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testEDATE($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::EDATE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerEDATE()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/EDATE.php';
|
||||
}
|
||||
|
||||
public function testEDATEtoPHP()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
|
||||
$result = DateTime::EDATE('2012-1-26', -1);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
self::assertEquals(1324857600, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function testEDATEtoPHPObject()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
|
||||
$result = DateTime::EDATE('2012-1-26', -1);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
// Must return an object...
|
||||
self::assertInternalType('object', $result);
|
||||
// ... of the correct type
|
||||
self::assertTrue(is_a($result, 'DateTime'));
|
||||
// ... with the correct value
|
||||
self::assertEquals($result->format('d-M-Y'), '26-Dec-2011');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerEOMONTH
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testEOMONTH($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::EOMONTH(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerEOMONTH()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/EOMONTH.php';
|
||||
}
|
||||
|
||||
public function testEOMONTHtoPHP()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_NUMERIC);
|
||||
$result = DateTime::EOMONTH('2012-1-26', -1);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
self::assertEquals(1325289600, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function testEOMONTHtoPHPObject()
|
||||
{
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
|
||||
$result = DateTime::EOMONTH('2012-1-26', -1);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
// Must return an object...
|
||||
self::assertInternalType('object', $result);
|
||||
// ... of the correct type
|
||||
self::assertTrue(is_a($result, 'DateTime'));
|
||||
// ... with the correct value
|
||||
self::assertEquals($result->format('d-M-Y'), '31-Dec-2011');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDATEDIF
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDATEDIF($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::DATEDIF(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDATEDIF()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/DATEDIF.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDAYS360
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDAYS360($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::DAYS360(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDAYS360()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/DAYS360.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerYEARFRAC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testYEARFRAC($expectedResult, ...$args)
|
||||
{
|
||||
$result = DateTime::YEARFRAC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerYEARFRAC()
|
||||
{
|
||||
return require 'data/Calculation/DateTime/YEARFRAC.php';
|
||||
}
|
||||
}
|
1009
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/EngineeringTest.php
vendored
Normal file
1009
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/EngineeringTest.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
613
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php
vendored
Normal file
613
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php
vendored
Normal file
@ -0,0 +1,613 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FinancialTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerACCRINT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testACCRINT($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::ACCRINT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerACCRINT()
|
||||
{
|
||||
return require 'data/Calculation/Financial/ACCRINT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerACCRINTM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testACCRINTM($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::ACCRINTM(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerACCRINTM()
|
||||
{
|
||||
return require 'data/Calculation/Financial/ACCRINTM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAMORDEGRC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAMORDEGRC($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::AMORDEGRC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerAMORDEGRC()
|
||||
{
|
||||
return require 'data/Calculation/Financial/AMORDEGRC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAMORLINC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAMORLINC($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::AMORLINC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerAMORLINC()
|
||||
{
|
||||
return require 'data/Calculation/Financial/AMORLINC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYBS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYBS($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::COUPDAYBS(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYBS()
|
||||
{
|
||||
return require 'data/Calculation/Financial/COUPDAYBS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYS($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::COUPDAYS(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYS()
|
||||
{
|
||||
return require 'data/Calculation/Financial/COUPDAYS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPDAYSNC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPDAYSNC($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::COUPDAYSNC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPDAYSNC()
|
||||
{
|
||||
return require 'data/Calculation/Financial/COUPDAYSNC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPNCD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPNCD($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::COUPNCD(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPNCD()
|
||||
{
|
||||
return require 'data/Calculation/Financial/COUPNCD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPNUM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPNUM($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::COUPNUM(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPNUM()
|
||||
{
|
||||
return require 'data/Calculation/Financial/COUPNUM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOUPPCD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOUPPCD($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::COUPPCD(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCOUPPCD()
|
||||
{
|
||||
return require 'data/Calculation/Financial/COUPPCD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCUMIPMT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCUMIPMT($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::CUMIPMT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCUMIPMT()
|
||||
{
|
||||
return require 'data/Calculation/Financial/CUMIPMT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCUMPRINC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCUMPRINC($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::CUMPRINC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerCUMPRINC()
|
||||
{
|
||||
return require 'data/Calculation/Financial/CUMPRINC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDB
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDB($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::DB(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDB()
|
||||
{
|
||||
return require 'data/Calculation/Financial/DB.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDDB
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDDB($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::DDB(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDDB()
|
||||
{
|
||||
return require 'data/Calculation/Financial/DDB.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDISC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDISC($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::DISC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDISC()
|
||||
{
|
||||
return require 'data/Calculation/Financial/DISC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDOLLARDE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDOLLARDE($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::DOLLARDE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDOLLARDE()
|
||||
{
|
||||
return require 'data/Calculation/Financial/DOLLARDE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDOLLARFR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDOLLARFR($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::DOLLARFR(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerDOLLARFR()
|
||||
{
|
||||
return require 'data/Calculation/Financial/DOLLARFR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerEFFECT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testEFFECT($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::EFFECT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerEFFECT()
|
||||
{
|
||||
return require 'data/Calculation/Financial/EFFECT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFV
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFV($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::FV(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerFV()
|
||||
{
|
||||
return require 'data/Calculation/Financial/FV.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFVSCHEDULE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFVSCHEDULE($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::FVSCHEDULE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerFVSCHEDULE()
|
||||
{
|
||||
return require 'data/Calculation/Financial/FVSCHEDULE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerINTRATE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testINTRATE($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::INTRATE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerINTRATE()
|
||||
{
|
||||
return require 'data/Calculation/Financial/INTRATE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIPMT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIPMT($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::IPMT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIPMT()
|
||||
{
|
||||
return require 'data/Calculation/Financial/IPMT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIRR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIRR($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::IRR(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIRR()
|
||||
{
|
||||
return require 'data/Calculation/Financial/IRR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerISPMT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testISPMT($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::ISPMT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerISPMT()
|
||||
{
|
||||
return require 'data/Calculation/Financial/ISPMT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMIRR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMIRR($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::MIRR(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerMIRR()
|
||||
{
|
||||
return require 'data/Calculation/Financial/MIRR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNOMINAL
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testNOMINAL($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::NOMINAL(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerNOMINAL()
|
||||
{
|
||||
return require 'data/Calculation/Financial/NOMINAL.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNPER
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testNPER($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::NPER(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerNPER()
|
||||
{
|
||||
return require 'data/Calculation/Financial/NPER.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNPV
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testNPV($expectedResult, ...$args)
|
||||
{
|
||||
$result = Financial::NPV(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerNPV()
|
||||
{
|
||||
return require 'data/Calculation/Financial/NPV.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerPRICE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testPRICE($expectedResult, ...$args)
|
||||
{
|
||||
$this->markTestIncomplete('TODO: This test should be fixed');
|
||||
|
||||
$result = Financial::PRICE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerPRICE()
|
||||
{
|
||||
return require 'data/Calculation/Financial/PRICE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerPRICEDISC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testPRICEDISC($expectedResult, array $args)
|
||||
{
|
||||
$result = Financial::PRICEDISC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerPRICEDISC()
|
||||
{
|
||||
return require 'data/Calculation/Financial/PRICEDISC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerPV
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testPV($expectedResult, array $args)
|
||||
{
|
||||
$result = Financial::PV(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerPV()
|
||||
{
|
||||
return require 'data/Calculation/Financial/PV.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerRATE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testRATE($expectedResult, ...$args)
|
||||
{
|
||||
$this->markTestIncomplete('TODO: This test should be fixed');
|
||||
|
||||
$result = Financial::RATE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerRATE()
|
||||
{
|
||||
return require 'data/Calculation/Financial/RATE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerXIRR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testXIRR($expectedResult, ...$args)
|
||||
{
|
||||
$this->markTestIncomplete('TODO: This test should be fixed');
|
||||
|
||||
$result = Financial::XIRR(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerXIRR()
|
||||
{
|
||||
return require 'data/Calculation/Financial/XIRR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerPDURATION
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testPDURATION($expectedResult, array $args)
|
||||
{
|
||||
$result = Financial::PDURATION(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerPDURATION()
|
||||
{
|
||||
return require 'data/Calculation/Financial/PDURATION.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerRRI
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testRRI($expectedResult, array $args)
|
||||
{
|
||||
$result = Financial::RRI(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerRRI()
|
||||
{
|
||||
return require 'data/Calculation/Financial/RRI.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSLN
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSLN($expectedResult, array $args)
|
||||
{
|
||||
$result = Financial::SLN(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerSLN()
|
||||
{
|
||||
return require 'data/Calculation/Financial/SLN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSYD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSYD($expectedResult, array $args)
|
||||
{
|
||||
$result = Financial::SYD(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerSYD()
|
||||
{
|
||||
return require 'data/Calculation/Financial/SYD.php';
|
||||
}
|
||||
}
|
385
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php
vendored
Normal file
385
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php
vendored
Normal file
@ -0,0 +1,385 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FunctionsTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
}
|
||||
|
||||
public function testCompatibilityMode()
|
||||
{
|
||||
$result = Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC);
|
||||
// Test for a true response for success
|
||||
$this->assertTrue($result);
|
||||
// Test that mode has been changed
|
||||
$this->assertEquals(Functions::COMPATIBILITY_GNUMERIC, Functions::getCompatibilityMode());
|
||||
}
|
||||
|
||||
public function testInvalidCompatibilityMode()
|
||||
{
|
||||
$result = Functions::setCompatibilityMode('INVALIDMODE');
|
||||
// Test for a false response for failure
|
||||
$this->assertFalse($result);
|
||||
// Test that mode has not been changed
|
||||
$this->assertEquals(Functions::COMPATIBILITY_EXCEL, Functions::getCompatibilityMode());
|
||||
}
|
||||
|
||||
public function testReturnDateType()
|
||||
{
|
||||
$result = Functions::setReturnDateType(Functions::RETURNDATE_PHP_OBJECT);
|
||||
// Test for a true response for success
|
||||
$this->assertTrue($result);
|
||||
// Test that mode has been changed
|
||||
$this->assertEquals(Functions::RETURNDATE_PHP_OBJECT, Functions::getReturnDateType());
|
||||
}
|
||||
|
||||
public function testInvalidReturnDateType()
|
||||
{
|
||||
$result = Functions::setReturnDateType('INVALIDTYPE');
|
||||
// Test for a false response for failure
|
||||
$this->assertFalse($result);
|
||||
// Test that mode has not been changed
|
||||
$this->assertEquals(Functions::RETURNDATE_EXCEL, Functions::getReturnDateType());
|
||||
}
|
||||
|
||||
public function testDUMMY()
|
||||
{
|
||||
$result = Functions::DUMMY();
|
||||
self::assertEquals('#Not Yet Implemented', $result);
|
||||
}
|
||||
|
||||
public function testDIV0()
|
||||
{
|
||||
$result = Functions::DIV0();
|
||||
self::assertEquals('#DIV/0!', $result);
|
||||
}
|
||||
|
||||
public function testNA()
|
||||
{
|
||||
$result = Functions::NA();
|
||||
self::assertEquals('#N/A', $result);
|
||||
}
|
||||
|
||||
public function testNAN()
|
||||
{
|
||||
$result = Functions::NAN();
|
||||
self::assertEquals('#NUM!', $result);
|
||||
}
|
||||
|
||||
public function testNAME()
|
||||
{
|
||||
$result = Functions::NAME();
|
||||
self::assertEquals('#NAME?', $result);
|
||||
}
|
||||
|
||||
public function testREF()
|
||||
{
|
||||
$result = Functions::REF();
|
||||
self::assertEquals('#REF!', $result);
|
||||
}
|
||||
|
||||
public function testNULL()
|
||||
{
|
||||
$result = Functions::null();
|
||||
self::assertEquals('#NULL!', $result);
|
||||
}
|
||||
|
||||
public function testVALUE()
|
||||
{
|
||||
$result = Functions::VALUE();
|
||||
self::assertEquals('#VALUE!', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsBlank
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsBlank($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isBlank(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsBlank()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_BLANK.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsErr
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsErr($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isErr(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsErr()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_ERR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsError
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsError($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isError(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsError()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_ERROR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerErrorType
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testErrorType($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::errorType(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerErrorType()
|
||||
{
|
||||
return require 'data/Calculation/Functions/ERROR_TYPE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsLogical
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsLogical($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isLogical(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsLogical()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_LOGICAL.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsNa
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsNa($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isNa(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsNa()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_NA.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsNumber
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsNumber($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isNumber(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsNumber()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_NUMBER.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsText
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsText($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isText(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsText()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_TEXT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsNonText
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsNonText($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isNonText(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsNonText()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_NONTEXT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsEven
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsEven($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isEven(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsEven()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_EVEN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsOdd
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsOdd($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::isOdd(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsOdd()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IS_ODD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTYPE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testTYPE($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::TYPE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerTYPE()
|
||||
{
|
||||
return require 'data/Calculation/Functions/TYPE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerN
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testN($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::n(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerN()
|
||||
{
|
||||
return require 'data/Calculation/Functions/N.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsFormula
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $reference Reference to the cell we wish to test
|
||||
* @param mixed $value Value of the cell we wish to test
|
||||
*/
|
||||
public function testIsFormula($expectedResult, $reference, $value = 'undefined')
|
||||
{
|
||||
$ourCell = null;
|
||||
if ($value !== 'undefined') {
|
||||
$remoteCell = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$remoteCell->method('isFormula')
|
||||
->will($this->returnValue(substr($value, 0, 1) == '='));
|
||||
|
||||
$remoteSheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$remoteSheet->method('getCell')
|
||||
->will($this->returnValue($remoteCell));
|
||||
|
||||
$workbook = $this->getMockBuilder(Spreadsheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$workbook->method('getSheetByName')
|
||||
->will($this->returnValue($remoteSheet));
|
||||
|
||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$sheet->method('getCell')
|
||||
->will($this->returnValue($remoteCell));
|
||||
$sheet->method('getParent')
|
||||
->will($this->returnValue($workbook));
|
||||
|
||||
$ourCell = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$ourCell->method('getWorksheet')
|
||||
->will($this->returnValue($sheet));
|
||||
}
|
||||
|
||||
$result = Functions::isFormula($reference, $ourCell);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerIsFormula()
|
||||
{
|
||||
return require 'data/Calculation/Functions/ISFORMULA.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIfCondition
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIfCondition($expectedResult, ...$args)
|
||||
{
|
||||
$result = Functions::ifCondition(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerIfCondition()
|
||||
{
|
||||
return require 'data/Calculation/Functions/IF_CONDITION.php';
|
||||
}
|
||||
}
|
123
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php
vendored
Normal file
123
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/LogicalTest.php
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Logical;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LogicalTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
public function testTRUE()
|
||||
{
|
||||
$result = Logical::TRUE();
|
||||
self::assertTrue($result);
|
||||
}
|
||||
|
||||
public function testFALSE()
|
||||
{
|
||||
$result = Logical::FALSE();
|
||||
self::assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAND
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAND($expectedResult, ...$args)
|
||||
{
|
||||
$result = Logical::logicalAnd(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerAND()
|
||||
{
|
||||
return require 'data/Calculation/Logical/AND.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerOR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testOR($expectedResult, ...$args)
|
||||
{
|
||||
$result = Logical::logicalOr(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerOR()
|
||||
{
|
||||
return require 'data/Calculation/Logical/OR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerXOR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testXOR($expectedResult, ...$args)
|
||||
{
|
||||
$result = Logical::logicalXor(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerXOR()
|
||||
{
|
||||
return require 'data/Calculation/Logical/XOR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNOT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testNOT($expectedResult, ...$args)
|
||||
{
|
||||
$result = Logical::NOT(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerNOT()
|
||||
{
|
||||
return require 'data/Calculation/Logical/NOT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIF
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIF($expectedResult, ...$args)
|
||||
{
|
||||
$result = Logical::statementIf(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerIF()
|
||||
{
|
||||
return require 'data/Calculation/Logical/IF.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIFERROR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIFERROR($expectedResult, ...$args)
|
||||
{
|
||||
$result = Logical::IFERROR(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerIFERROR()
|
||||
{
|
||||
return require 'data/Calculation/Logical/IFERROR.php';
|
||||
}
|
||||
}
|
172
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php
vendored
Normal file
172
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/LookupRefTest.php
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class LookupRefTest.
|
||||
*/
|
||||
class LookupRefTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerHLOOKUP
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testHLOOKUP($expectedResult, ...$args)
|
||||
{
|
||||
$result = LookupRef::HLOOKUP(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerHLOOKUP()
|
||||
{
|
||||
return require 'data/Calculation/LookupRef/HLOOKUP.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerVLOOKUP
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testVLOOKUP($expectedResult, ...$args)
|
||||
{
|
||||
$result = LookupRef::VLOOKUP(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerVLOOKUP()
|
||||
{
|
||||
return require 'data/Calculation/LookupRef/VLOOKUP.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMATCH
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMATCH($expectedResult, ...$args)
|
||||
{
|
||||
$result = LookupRef::MATCH(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerMATCH()
|
||||
{
|
||||
return require 'data/Calculation/LookupRef/MATCH.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerINDEX
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testINDEX($expectedResult, ...$args)
|
||||
{
|
||||
$result = LookupRef::INDEX(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerINDEX()
|
||||
{
|
||||
return require 'data/Calculation/LookupRef/INDEX.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOLUMNS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOLUMNS($expectedResult, ...$args)
|
||||
{
|
||||
$result = LookupRef::COLUMNS(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerCOLUMNS()
|
||||
{
|
||||
return require 'data/Calculation/LookupRef/COLUMNS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerROWS
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testROWS($expectedResult, ...$args)
|
||||
{
|
||||
$result = LookupRef::ROWS(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerROWS()
|
||||
{
|
||||
return require 'data/Calculation/LookupRef/ROWS.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormulaText
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $reference Reference to the cell we wish to test
|
||||
* @param mixed $value Value of the cell we wish to test
|
||||
*/
|
||||
public function testFormulaText($expectedResult, $reference, $value = 'undefined')
|
||||
{
|
||||
$ourCell = null;
|
||||
if ($value !== 'undefined') {
|
||||
$remoteCell = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$remoteCell->method('isFormula')
|
||||
->will($this->returnValue(substr($value, 0, 1) == '='));
|
||||
$remoteCell->method('getValue')
|
||||
->will($this->returnValue($value));
|
||||
|
||||
$remoteSheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$remoteSheet->method('getCell')
|
||||
->will($this->returnValue($remoteCell));
|
||||
|
||||
$workbook = $this->getMockBuilder(Spreadsheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$workbook->method('getSheetByName')
|
||||
->will($this->returnValue($remoteSheet));
|
||||
|
||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$sheet->method('getCell')
|
||||
->will($this->returnValue($remoteCell));
|
||||
$sheet->method('getParent')
|
||||
->will($this->returnValue($workbook));
|
||||
|
||||
$ourCell = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$ourCell->method('getWorksheet')
|
||||
->will($this->returnValue($sheet));
|
||||
}
|
||||
|
||||
$result = LookupRef::FORMULATEXT($reference, $ourCell);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-8);
|
||||
}
|
||||
|
||||
public function providerFormulaText()
|
||||
{
|
||||
return require 'data/Calculation/LookupRef/FORMULATEXT.php';
|
||||
}
|
||||
}
|
881
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php
vendored
Normal file
881
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php
vendored
Normal file
@ -0,0 +1,881 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\RowDimension;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MathTrigTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerATAN2
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testATAN2($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::ATAN2(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerATAN2()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/ATAN2.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCEILING
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCEILING($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::CEILING(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerCEILING()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/CEILING.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOMBIN
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCOMBIN($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::COMBIN(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerCOMBIN()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/COMBIN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerEVEN
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testEVEN($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::EVEN(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerEVEN()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/EVEN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerODD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testODD($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::ODD(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerODD()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/ODD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFACT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFACT($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::FACT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerFACT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/FACT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFACTDOUBLE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFACTDOUBLE($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::FACTDOUBLE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerFACTDOUBLE()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/FACTDOUBLE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFLOOR
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFLOOR($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::FLOOR(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerFLOOR()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/FLOOR.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGCD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testGCD($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::GCD(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerGCD()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/GCD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerLCM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testLCM($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::LCM(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerLCM()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/LCM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerINT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testINT($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::INT(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerINT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/INT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSIGN
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSIGN($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SIGN(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSIGN()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SIGN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerPOWER
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testPOWER($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::POWER(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerPOWER()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/POWER.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerLOG
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testLOG($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::logBase(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerLOG()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/LOG.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMOD
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMOD($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::MOD(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerMOD()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/MOD.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMDETERM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMDETERM($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::MDETERM(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerMDETERM()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/MDETERM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMINVERSE
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMINVERSE($expectedResult, ...$args)
|
||||
{
|
||||
$this->markTestIncomplete('TODO: This test should be fixed');
|
||||
|
||||
$result = MathTrig::MINVERSE(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerMINVERSE()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/MINVERSE.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMMULT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMMULT($expectedResult, ...$args)
|
||||
{
|
||||
$this->markTestIncomplete('TODO: This test should be fixed');
|
||||
|
||||
$result = MathTrig::MMULT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerMMULT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/MMULT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMULTINOMIAL
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMULTINOMIAL($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::MULTINOMIAL(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerMULTINOMIAL()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/MULTINOMIAL.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMROUND
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMROUND($expectedResult, ...$args)
|
||||
{
|
||||
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
|
||||
$result = MathTrig::MROUND(...$args);
|
||||
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerMROUND()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/MROUND.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerPRODUCT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testPRODUCT($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::PRODUCT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerPRODUCT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/PRODUCT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerQUOTIENT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testQUOTIENT($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::QUOTIENT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerQUOTIENT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/QUOTIENT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerROUNDUP
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testROUNDUP($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::ROUNDUP(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerROUNDUP()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/ROUNDUP.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerROUNDDOWN
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testROUNDDOWN($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::ROUNDDOWN(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerROUNDDOWN()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/ROUNDDOWN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSERIESSUM
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSERIESSUM($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SERIESSUM(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSERIESSUM()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SERIESSUM.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSUMSQ
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSUMSQ($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SUMSQ(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSUMSQ()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUMSQ.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSUMPRODUCT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSUMPRODUCT($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SUMPRODUCT(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSUMPRODUCT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUMPRODUCT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSUMX2MY2
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSUMX2MY2($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SUMX2MY2(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSUMX2MY2()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUMX2MY2.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSUMX2PY2
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSUMX2PY2($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SUMX2PY2(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSUMX2PY2()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUMX2PY2.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSUMXMY2
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSUMXMY2($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SUMXMY2(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSUMXMY2()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUMXMY2.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTRUNC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testTRUNC($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::TRUNC(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerTRUNC()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/TRUNC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerROMAN
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testROMAN($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::ROMAN(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerROMAN()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/ROMAN.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSQRTPI
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSQRTPI($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SQRTPI(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSQRTPI()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SQRTPI.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSUMIF
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSUMIF($expectedResult, ...$args)
|
||||
{
|
||||
$result = MathTrig::SUMIF(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSUMIF()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUMIF.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSUBTOTAL
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSUBTOTAL($expectedResult, ...$args)
|
||||
{
|
||||
$cell = $this->getMockBuilder(Cell::class)
|
||||
->setMethods(['getValue'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cell->method('getValue')
|
||||
->willReturn(null);
|
||||
$worksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->setMethods(['cellExists', 'getCell'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$worksheet->method('cellExists')
|
||||
->willReturn(true);
|
||||
$worksheet->method('getCell')
|
||||
->willReturn($cell);
|
||||
$cellReference = $this->getMockBuilder(Cell::class)
|
||||
->setMethods(['getWorksheet'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cellReference->method('getWorksheet')
|
||||
->willReturn($worksheet);
|
||||
|
||||
array_push($args, $cellReference);
|
||||
$result = MathTrig::SUBTOTAL(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSUBTOTAL()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUBTOTAL.php';
|
||||
}
|
||||
|
||||
protected function rowVisibility()
|
||||
{
|
||||
$data = [1 => false, 2 => true, 3 => false, 4 => true, 5 => false, 6 => false, 7 => false, 8 => true, 9 => false, 10 => true, 11 => true];
|
||||
foreach ($data as $k => $v) {
|
||||
yield $k => $v;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerHiddenSUBTOTAL
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testHiddenSUBTOTAL($expectedResult, ...$args)
|
||||
{
|
||||
$visibilityGenerator = $this->rowVisibility();
|
||||
|
||||
$rowDimension = $this->getMockBuilder(RowDimension::class)
|
||||
->setMethods(['getVisible'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$rowDimension->method('getVisible')
|
||||
->will($this->returnCallback(function () use ($visibilityGenerator) {
|
||||
$result = $visibilityGenerator->current();
|
||||
$visibilityGenerator->next();
|
||||
|
||||
return $result;
|
||||
}));
|
||||
$columnDimension = $this->getMockBuilder(ColumnDimension::class)
|
||||
->setMethods(['getVisible'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$columnDimension->method('getVisible')
|
||||
->willReturn(true);
|
||||
$cell = $this->getMockBuilder(Cell::class)
|
||||
->setMethods(['getValue'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cell->method('getValue')
|
||||
->willReturn('');
|
||||
$worksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->setMethods(['cellExists', 'getCell', 'getRowDimension', 'getColumnDimension'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$worksheet->method('cellExists')
|
||||
->willReturn(true);
|
||||
$worksheet->method('getCell')
|
||||
->willReturn($cell);
|
||||
$worksheet->method('getRowDimension')
|
||||
->willReturn($rowDimension);
|
||||
$worksheet->method('getColumnDimension')
|
||||
->willReturn($columnDimension);
|
||||
$cellReference = $this->getMockBuilder(Cell::class)
|
||||
->setMethods(['getWorksheet'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cellReference->method('getWorksheet')
|
||||
->willReturn($worksheet);
|
||||
|
||||
array_push($args, $cellReference);
|
||||
$result = MathTrig::SUBTOTAL(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerHiddenSUBTOTAL()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUBTOTALHIDDEN.php';
|
||||
}
|
||||
|
||||
protected function cellValues(array $cellValues)
|
||||
{
|
||||
foreach ($cellValues as $k => $v) {
|
||||
yield $k => $v;
|
||||
}
|
||||
}
|
||||
|
||||
protected function cellIsFormula(array $cellValues)
|
||||
{
|
||||
foreach ($cellValues as $cellValue) {
|
||||
yield $cellValue[0] === '=';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNestedSUBTOTAL
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testNestedSUBTOTAL($expectedResult, ...$args)
|
||||
{
|
||||
$cellValueGenerator = $this->cellValues(Functions::flattenArray(array_slice($args, 1)));
|
||||
$cellIsFormulaGenerator = $this->cellIsFormula(Functions::flattenArray(array_slice($args, 1)));
|
||||
|
||||
$cell = $this->getMockBuilder(Cell::class)
|
||||
->setMethods(['getValue', 'isFormula'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cell->method('getValue')
|
||||
->will($this->returnCallback(function () use ($cellValueGenerator) {
|
||||
$result = $cellValueGenerator->current();
|
||||
$cellValueGenerator->next();
|
||||
|
||||
return $result;
|
||||
}));
|
||||
$cell->method('isFormula')
|
||||
->will($this->returnCallback(function () use ($cellIsFormulaGenerator) {
|
||||
$result = $cellIsFormulaGenerator->current();
|
||||
$cellIsFormulaGenerator->next();
|
||||
|
||||
return $result;
|
||||
}));
|
||||
$worksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->setMethods(['cellExists', 'getCell'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$worksheet->method('cellExists')
|
||||
->willReturn(true);
|
||||
$worksheet->method('getCell')
|
||||
->willReturn($cell);
|
||||
$cellReference = $this->getMockBuilder(Cell::class)
|
||||
->setMethods(['getWorksheet'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cellReference->method('getWorksheet')
|
||||
->willReturn($worksheet);
|
||||
|
||||
array_push($args, $cellReference);
|
||||
|
||||
$result = MathTrig::SUBTOTAL(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerNestedSUBTOTAL()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SUBTOTALNESTED.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSEC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $angle
|
||||
*/
|
||||
public function testSEC($expectedResult, $angle)
|
||||
{
|
||||
$result = MathTrig::SEC($angle);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSEC()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SEC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSECH
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $angle
|
||||
*/
|
||||
public function testSECH($expectedResult, $angle)
|
||||
{
|
||||
$result = MathTrig::SECH($angle);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerSECH()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/SECH.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCSC
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $angle
|
||||
*/
|
||||
public function testCSC($expectedResult, $angle)
|
||||
{
|
||||
$result = MathTrig::CSC($angle);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerCSC()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/CSC.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCSCH
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $angle
|
||||
*/
|
||||
public function testCSCH($expectedResult, $angle)
|
||||
{
|
||||
$result = MathTrig::CSCH($angle);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerCSCH()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/CSCH.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $angle
|
||||
*/
|
||||
public function testCOT($expectedResult, $angle)
|
||||
{
|
||||
$result = MathTrig::COT($angle);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerCOT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/COT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCOTH
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $angle
|
||||
*/
|
||||
public function testCOTH($expectedResult, $angle)
|
||||
{
|
||||
$result = MathTrig::COTH($angle);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerCOTH()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/COTH.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerACOT
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $number
|
||||
*/
|
||||
public function testACOT($expectedResult, $number)
|
||||
{
|
||||
$result = MathTrig::ACOT($number);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerACOT()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/ACOT.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerACOTH
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $number
|
||||
*/
|
||||
public function testACOTH($expectedResult, $number)
|
||||
{
|
||||
$result = MathTrig::ACOTH($number);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-12);
|
||||
}
|
||||
|
||||
public function providerACOTH()
|
||||
{
|
||||
return require 'data/Calculation/MathTrig/ACOTH.php';
|
||||
}
|
||||
}
|
431
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php
vendored
Normal file
431
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Calculation/TextDataTest.php
vendored
Normal file
@ -0,0 +1,431 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\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, null, 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, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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';
|
||||
}
|
||||
}
|
79
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php
vendored
Normal file
79
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Collection\Cells;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AdvancedValueBinderTest extends TestCase
|
||||
{
|
||||
public function provider()
|
||||
{
|
||||
$currencyUSD = NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
|
||||
$currencyEURO = str_replace('$', '€', NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
|
||||
return [
|
||||
['10%', 0.1, NumberFormat::FORMAT_PERCENTAGE_00, ',', '.', '$'],
|
||||
['$10.11', 10.11, $currencyUSD, ',', '.', '$'],
|
||||
['$1,010.12', 1010.12, $currencyUSD, ',', '.', '$'],
|
||||
['$20,20', 20.2, $currencyUSD, '.', ',', '$'],
|
||||
['$2.020,20', 2020.2, $currencyUSD, '.', ',', '$'],
|
||||
['€2.020,20', 2020.2, $currencyEURO, '.', ',', '€'],
|
||||
['€ 2.020,20', 2020.2, $currencyEURO, '.', ',', '€'],
|
||||
['€2,020.22', 2020.22, $currencyEURO, ',', '.', '€'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $valueBinded
|
||||
* @param mixed $format
|
||||
* @param mixed $thousandsSeparator
|
||||
* @param mixed $decimalSeparator
|
||||
* @param mixed $currencyCode
|
||||
*/
|
||||
public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode)
|
||||
{
|
||||
$sheet = $this->getMockBuilder(Worksheet::class)
|
||||
->setMethods(['getStyle', 'getNumberFormat', 'setFormatCode', 'getCellCollection'])
|
||||
->getMock();
|
||||
$cellCollection = $this->getMockBuilder(Cells::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cellCollection->expects($this->any())
|
||||
->method('getParent')
|
||||
->will($this->returnValue($sheet));
|
||||
|
||||
$sheet->expects($this->once())
|
||||
->method('getStyle')
|
||||
->will($this->returnSelf());
|
||||
$sheet->expects($this->once())
|
||||
->method('getNumberFormat')
|
||||
->will($this->returnSelf());
|
||||
$sheet->expects($this->once())
|
||||
->method('setFormatCode')
|
||||
->with($format)
|
||||
->will($this->returnSelf());
|
||||
$sheet->expects($this->any())
|
||||
->method('getCellCollection')
|
||||
->will($this->returnValue($cellCollection));
|
||||
|
||||
StringHelper::setCurrencyCode($currencyCode);
|
||||
StringHelper::setDecimalSeparator($decimalSeparator);
|
||||
StringHelper::setThousandsSeparator($thousandsSeparator);
|
||||
|
||||
$cell = new Cell(null, DataType::TYPE_STRING, $sheet);
|
||||
|
||||
$binder = new AdvancedValueBinder();
|
||||
$binder->bindValue($cell, $value);
|
||||
self::assertEquals($valueBinded, $cell->getValue());
|
||||
}
|
||||
}
|
367
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php
vendored
Normal file
367
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php
vendored
Normal file
@ -0,0 +1,367 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoordinateTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerColumnString
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param mixed $string
|
||||
*/
|
||||
public function testColumnIndexFromString($expectedResult, $string)
|
||||
{
|
||||
$columnIndex = Coordinate::columnIndexFromString($string);
|
||||
self::assertEquals($expectedResult, $columnIndex);
|
||||
|
||||
$stringBack = Coordinate::stringFromColumnIndex($columnIndex);
|
||||
self::assertEquals($stringBack, $string, 'should be able to get the original input with opposite method');
|
||||
}
|
||||
|
||||
public function providerColumnString()
|
||||
{
|
||||
return require 'data/ColumnString.php';
|
||||
}
|
||||
|
||||
public function testColumnIndexFromStringTooLong()
|
||||
{
|
||||
$cellAddress = 'ABCD';
|
||||
|
||||
try {
|
||||
Coordinate::columnIndexFromString($cellAddress);
|
||||
} catch (\Exception $e) {
|
||||
self::assertInstanceOf(Exception::class, $e);
|
||||
self::assertEquals($e->getMessage(), 'Column string index can not be longer than 3 characters');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
public function testColumnIndexFromStringTooShort()
|
||||
{
|
||||
$cellAddress = '';
|
||||
|
||||
try {
|
||||
Coordinate::columnIndexFromString($cellAddress);
|
||||
} catch (\Exception $e) {
|
||||
self::assertInstanceOf(Exception::class, $e);
|
||||
self::assertEquals($e->getMessage(), 'Column string index can not be empty');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerColumnIndex
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
* @param int $columnIndex
|
||||
*/
|
||||
public function testStringFromColumnIndex($expectedResult, $columnIndex)
|
||||
{
|
||||
$string = Coordinate::stringFromColumnIndex($columnIndex);
|
||||
self::assertEquals($expectedResult, $string);
|
||||
|
||||
$columnIndexBack = Coordinate::columnIndexFromString($string);
|
||||
self::assertEquals($columnIndexBack, $columnIndex, 'should be able to get the original input with opposite method');
|
||||
}
|
||||
|
||||
public function providerColumnIndex()
|
||||
{
|
||||
return require 'data/ColumnIndex.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCoordinates
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCoordinateFromString($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::coordinateFromString(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerCoordinates()
|
||||
{
|
||||
return require 'data/CellCoordinates.php';
|
||||
}
|
||||
|
||||
public function testCoordinateFromStringWithRangeAddress()
|
||||
{
|
||||
$cellAddress = 'A1:AI2012';
|
||||
|
||||
try {
|
||||
Coordinate::coordinateFromString($cellAddress);
|
||||
} catch (\Exception $e) {
|
||||
self::assertInstanceOf(Exception::class, $e);
|
||||
self::assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
public function testCoordinateFromStringWithEmptyAddress()
|
||||
{
|
||||
$cellAddress = '';
|
||||
|
||||
try {
|
||||
Coordinate::coordinateFromString($cellAddress);
|
||||
} catch (\Exception $e) {
|
||||
self::assertInstanceOf(Exception::class, $e);
|
||||
self::assertEquals($e->getMessage(), 'Cell coordinate can not be zero-length string');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
public function testCoordinateFromStringWithInvalidAddress()
|
||||
{
|
||||
$cellAddress = 'AI';
|
||||
|
||||
try {
|
||||
Coordinate::coordinateFromString($cellAddress);
|
||||
} catch (\Exception $e) {
|
||||
self::assertInstanceOf(Exception::class, $e);
|
||||
self::assertEquals($e->getMessage(), 'Invalid cell coordinate ' . $cellAddress);
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAbsoluteCoordinates
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAbsoluteCoordinateFromString($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::absoluteCoordinate(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerAbsoluteCoordinates()
|
||||
{
|
||||
return require 'data/CellAbsoluteCoordinate.php';
|
||||
}
|
||||
|
||||
public function testAbsoluteCoordinateFromStringWithRangeAddress()
|
||||
{
|
||||
$cellAddress = 'A1:AI2012';
|
||||
|
||||
try {
|
||||
Coordinate::absoluteCoordinate($cellAddress);
|
||||
} catch (\Exception $e) {
|
||||
self::assertInstanceOf(Exception::class, $e);
|
||||
self::assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAbsoluteReferences
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testAbsoluteReferenceFromString($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::absoluteReference(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerAbsoluteReferences()
|
||||
{
|
||||
return require 'data/CellAbsoluteReference.php';
|
||||
}
|
||||
|
||||
public function testAbsoluteReferenceFromStringWithRangeAddress()
|
||||
{
|
||||
$cellAddress = 'A1:AI2012';
|
||||
|
||||
try {
|
||||
Coordinate::absoluteReference($cellAddress);
|
||||
} catch (\Exception $e) {
|
||||
self::assertInstanceOf(Exception::class, $e);
|
||||
self::assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSplitRange
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testSplitRange($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::splitRange(...$args);
|
||||
foreach ($result as $key => $split) {
|
||||
if (!is_array($expectedResult[$key])) {
|
||||
self::assertEquals($expectedResult[$key], $split[0]);
|
||||
} else {
|
||||
self::assertEquals($expectedResult[$key], $split);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function providerSplitRange()
|
||||
{
|
||||
return require 'data/CellSplitRange.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerBuildRange
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testBuildRange($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::buildRange(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerBuildRange()
|
||||
{
|
||||
return require 'data/CellBuildRange.php';
|
||||
}
|
||||
|
||||
public function testBuildRangeInvalid()
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
|
||||
if (PHP_MAJOR_VERSION < 7) {
|
||||
$this->markTestSkipped('Cannot catch type hinting error with PHP 5.6');
|
||||
}
|
||||
|
||||
$cellRange = '';
|
||||
Coordinate::buildRange($cellRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerRangeBoundaries
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testRangeBoundaries($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::rangeBoundaries(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerRangeBoundaries()
|
||||
{
|
||||
return require 'data/CellRangeBoundaries.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerRangeDimension
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testRangeDimension($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::rangeDimension(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerRangeDimension()
|
||||
{
|
||||
return require 'data/CellRangeDimension.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGetRangeBoundaries
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testGetRangeBoundaries($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::getRangeBoundaries(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerGetRangeBoundaries()
|
||||
{
|
||||
return require 'data/CellGetRangeBoundaries.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerExtractAllCellReferencesInRange
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testExtractAllCellReferencesInRange($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::extractAllCellReferencesInRange(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerExtractAllCellReferencesInRange()
|
||||
{
|
||||
return require 'data/CellExtractAllCellReferencesInRange.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerInvalidRange
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testExtractAllCellReferencesInRangeInvalidRange($range)
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('Invalid range: "' . $range . '"');
|
||||
|
||||
Coordinate::extractAllCellReferencesInRange($range);
|
||||
}
|
||||
|
||||
public function providerInvalidRange()
|
||||
{
|
||||
return [['Z1:A1'], ['A4:A1'], ['B1:A1'], ['AA1:Z1']];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerMergeRangesInCollection
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testMergeRangesInCollection($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::mergeRangesInCollection(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerMergeRangesInCollection()
|
||||
{
|
||||
return require 'data/CellMergeRangesInCollection.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCoordinateIsRange
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCoordinateIsRange($expectedResult, ...$args)
|
||||
{
|
||||
$result = Coordinate::coordinateIsRange(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerCoordinateIsRange()
|
||||
{
|
||||
return require 'data/CoordinateIsRange.php';
|
||||
}
|
||||
}
|
17
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php
vendored
Normal file
17
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataTypeTest extends TestCase
|
||||
{
|
||||
public function testGetErrorCodes()
|
||||
{
|
||||
$result = DataType::getErrorCodes();
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertGreaterThan(0, count($result));
|
||||
self::assertArrayHasKey('#NULL!', $result);
|
||||
}
|
||||
}
|
19
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php
vendored
Normal file
19
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DataValidationTest.php
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataValidationTest extends TestCase
|
||||
{
|
||||
public function testNoValidation()
|
||||
{
|
||||
$dataValidation = new DataValidation();
|
||||
self::assertSame('090624f04837265d79323c4a1b7e89d1', $dataValidation->getHashCode());
|
||||
$dataValidation->setType(DataValidation::TYPE_CUSTOM);
|
||||
|
||||
self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode());
|
||||
self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode(), 'getHashCode() should not have side effect');
|
||||
}
|
||||
}
|
73
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php
vendored
Normal file
73
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DataValidatorTest.php
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataValidatorTest extends TestCase
|
||||
{
|
||||
public function testNoValidation()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$testCell = $sheet->getCell('A1');
|
||||
|
||||
self::assertTrue($testCell->hasValidValue(), 'a cell without any validation data is always valid');
|
||||
}
|
||||
|
||||
public function testUnsupportedType()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$testCell = $sheet->getCell('A1');
|
||||
|
||||
$validation = $testCell->getDataValidation();
|
||||
$validation->setType(DataValidation::TYPE_CUSTOM);
|
||||
$validation->setAllowBlank(true);
|
||||
|
||||
self::assertFalse($testCell->hasValidValue(), 'cannot assert that value is valid when the validation type is not supported');
|
||||
}
|
||||
|
||||
public function testList()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$testCell = $sheet->getCell('A1');
|
||||
|
||||
$validation = $testCell->getDataValidation();
|
||||
$validation->setType(DataValidation::TYPE_LIST);
|
||||
|
||||
// blank value
|
||||
$testCell->setValue('');
|
||||
$validation->setAllowBlank(true);
|
||||
self::assertTrue($testCell->hasValidValue(), 'cell can be empty');
|
||||
$validation->setAllowBlank(false);
|
||||
self::assertFalse($testCell->hasValidValue(), 'cell can not be empty');
|
||||
|
||||
// inline list
|
||||
$validation->setFormula1('"yes,no"');
|
||||
$testCell->setValue('foo');
|
||||
self::assertFalse($testCell->hasValidValue(), "cell value ('foo') is not allowed");
|
||||
$testCell->setValue('yes');
|
||||
self::assertTrue($testCell->hasValidValue(), "cell value ('yes') has to be allowed");
|
||||
|
||||
// list from cells
|
||||
$sheet->getCell('B1')->setValue(5);
|
||||
$sheet->getCell('B2')->setValue(6);
|
||||
$sheet->getCell('B3')->setValue(7);
|
||||
$testCell = $sheet->getCell('A1'); // redefine $testCell, because it has broken coordinates after using other cells
|
||||
$validation->setFormula1('B1:B3');
|
||||
$testCell->setValue('10');
|
||||
self::assertFalse($testCell->hasValidValue(), "cell value ('10') is not allowed");
|
||||
$testCell = $sheet->getCell('A1'); // redefine $testCell, because it has broken coordinates after using other cells
|
||||
$testCell->setValue('5');
|
||||
self::assertTrue($testCell->hasValidValue(), "cell value ('5') has to be allowed");
|
||||
|
||||
$testCell = $sheet->getCell('A1'); // redefine $testCell, because it has broken coordinates after using other cells
|
||||
$validation->setFormula1('broken : cell : coordinates');
|
||||
|
||||
self::assertFalse($testCell->hasValidValue(), 'invalid formula should not throw exceptions');
|
||||
}
|
||||
}
|
86
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php
vendored
Normal file
86
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Cell;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DefaultValueBinderTest extends TestCase
|
||||
{
|
||||
private $cellStub;
|
||||
|
||||
private function createCellStub()
|
||||
{
|
||||
// Create a stub for the Cell class.
|
||||
$this->cellStub = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
// Configure the stub.
|
||||
$this->cellStub->expects($this->any())
|
||||
->method('setValueExplicit')
|
||||
->will($this->returnValue(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider binderProvider
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function testBindValue($value)
|
||||
{
|
||||
$this->createCellStub();
|
||||
$binder = new DefaultValueBinder();
|
||||
$result = $binder->bindValue($this->cellStub, $value);
|
||||
self::assertTrue($result);
|
||||
}
|
||||
|
||||
public function binderProvider()
|
||||
{
|
||||
return [
|
||||
[null],
|
||||
[''],
|
||||
['ABC'],
|
||||
['=SUM(A1:B2)'],
|
||||
[true],
|
||||
[false],
|
||||
[123],
|
||||
[-123.456],
|
||||
['123'],
|
||||
['-123.456'],
|
||||
['#REF!'],
|
||||
[new DateTime()],
|
||||
[new DateTimeImmutable()],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDataTypeForValue
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDataTypeForValue($expectedResult, ...$args)
|
||||
{
|
||||
$result = DefaultValueBinder::dataTypeForValue(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerDataTypeForValue()
|
||||
{
|
||||
return require 'data/Cell/DefaultValueBinder.php';
|
||||
}
|
||||
|
||||
public function testDataTypeForRichTextObject()
|
||||
{
|
||||
$objRichText = new RichText();
|
||||
$objRichText->createText('Hello World');
|
||||
|
||||
$expectedResult = DataType::TYPE_INLINE;
|
||||
$result = DefaultValueBinder::dataTypeForValue($objRichText);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
}
|
81
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php
vendored
Normal file
81
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HyperlinkTest extends TestCase
|
||||
{
|
||||
public function testGetUrl()
|
||||
{
|
||||
$urlValue = 'https://www.example.com';
|
||||
|
||||
$testInstance = new Hyperlink($urlValue);
|
||||
|
||||
$result = $testInstance->getUrl();
|
||||
self::assertEquals($urlValue, $result);
|
||||
}
|
||||
|
||||
public function testSetUrl()
|
||||
{
|
||||
$initialUrlValue = 'https://www.example.com';
|
||||
$newUrlValue = 'http://github.com/PHPOffice/PhpSpreadsheet';
|
||||
|
||||
$testInstance = new Hyperlink($initialUrlValue);
|
||||
$result = $testInstance->setUrl($newUrlValue);
|
||||
self::assertInstanceOf(Hyperlink::class, $result);
|
||||
|
||||
$result = $testInstance->getUrl();
|
||||
self::assertEquals($newUrlValue, $result);
|
||||
}
|
||||
|
||||
public function testGetTooltip()
|
||||
{
|
||||
$tooltipValue = 'PhpSpreadsheet Web Site';
|
||||
|
||||
$testInstance = new Hyperlink(null, $tooltipValue);
|
||||
|
||||
$result = $testInstance->getTooltip();
|
||||
self::assertEquals($tooltipValue, $result);
|
||||
}
|
||||
|
||||
public function testSetTooltip()
|
||||
{
|
||||
$initialTooltipValue = 'PhpSpreadsheet Web Site';
|
||||
$newTooltipValue = 'PhpSpreadsheet Repository on Github';
|
||||
|
||||
$testInstance = new Hyperlink(null, $initialTooltipValue);
|
||||
$result = $testInstance->setTooltip($newTooltipValue);
|
||||
self::assertInstanceOf(Hyperlink::class, $result);
|
||||
|
||||
$result = $testInstance->getTooltip();
|
||||
self::assertEquals($newTooltipValue, $result);
|
||||
}
|
||||
|
||||
public function testIsInternal()
|
||||
{
|
||||
$initialUrlValue = 'https://www.example.com';
|
||||
$newUrlValue = 'sheet://Worksheet1!A1';
|
||||
|
||||
$testInstance = new Hyperlink($initialUrlValue);
|
||||
$result = $testInstance->isInternal();
|
||||
self::assertFalse($result);
|
||||
|
||||
$testInstance->setUrl($newUrlValue);
|
||||
$result = $testInstance->isInternal();
|
||||
self::assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGetHashCode()
|
||||
{
|
||||
$urlValue = 'https://www.example.com';
|
||||
$tooltipValue = 'PhpSpreadsheet Web Site';
|
||||
$initialExpectedHash = '3a8d5a682dba27276dce538c39402437';
|
||||
|
||||
$testInstance = new Hyperlink($urlValue, $tooltipValue);
|
||||
|
||||
$result = $testInstance->getHashCode();
|
||||
self::assertEquals($initialExpectedHash, $result);
|
||||
}
|
||||
}
|
62
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php
vendored
Normal file
62
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Chart/DataSeriesValuesTest.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DataSeriesValuesTest extends TestCase
|
||||
{
|
||||
public function testSetDataType()
|
||||
{
|
||||
$dataTypeValues = [
|
||||
'Number',
|
||||
'String',
|
||||
];
|
||||
|
||||
$testInstance = new DataSeriesValues();
|
||||
|
||||
foreach ($dataTypeValues as $dataTypeValue) {
|
||||
$result = $testInstance->setDataType($dataTypeValue);
|
||||
self::assertInstanceOf(DataSeriesValues::class, $result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetInvalidDataTypeThrowsException()
|
||||
{
|
||||
$testInstance = new DataSeriesValues();
|
||||
|
||||
try {
|
||||
$testInstance->setDataType('BOOLEAN');
|
||||
} catch (Exception $e) {
|
||||
self::assertEquals($e->getMessage(), 'Invalid datatype for chart data series values');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
public function testGetDataType()
|
||||
{
|
||||
$dataTypeValue = 'String';
|
||||
|
||||
$testInstance = new DataSeriesValues();
|
||||
$testInstance->setDataType($dataTypeValue);
|
||||
|
||||
$result = $testInstance->getDataType();
|
||||
self::assertEquals($dataTypeValue, $result);
|
||||
}
|
||||
|
||||
public function testGetLineWidth()
|
||||
{
|
||||
$testInstance = new DataSeriesValues();
|
||||
self::assertEquals(12700, $testInstance->getLineWidth(), 'should have default');
|
||||
|
||||
$testInstance->setLineWidth(40000);
|
||||
self::assertEquals(40000, $testInstance->getLineWidth());
|
||||
|
||||
$testInstance->setLineWidth(1);
|
||||
self::assertEquals(12700, $testInstance->getLineWidth(), 'should enforce minimum width');
|
||||
}
|
||||
}
|
30
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Chart/LayoutTest.php
vendored
Normal file
30
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Chart/LayoutTest.php
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Layout;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LayoutTest extends TestCase
|
||||
{
|
||||
public function testSetLayoutTarget()
|
||||
{
|
||||
$LayoutTargetValue = 'String';
|
||||
|
||||
$testInstance = new Layout();
|
||||
|
||||
$result = $testInstance->setLayoutTarget($LayoutTargetValue);
|
||||
self::assertInstanceOf(Layout::class, $result);
|
||||
}
|
||||
|
||||
public function testGetLayoutTarget()
|
||||
{
|
||||
$LayoutTargetValue = 'String';
|
||||
|
||||
$testInstance = new Layout();
|
||||
$testInstance->setLayoutTarget($LayoutTargetValue);
|
||||
|
||||
$result = $testInstance->getLayoutTarget();
|
||||
self::assertEquals($LayoutTargetValue, $result);
|
||||
}
|
||||
}
|
127
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Chart/LegendTest.php
vendored
Normal file
127
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Chart/LegendTest.php
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Chart;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Legend;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LegendTest extends TestCase
|
||||
{
|
||||
public function testSetPosition()
|
||||
{
|
||||
$positionValues = [
|
||||
Legend::POSITION_RIGHT,
|
||||
Legend::POSITION_LEFT,
|
||||
Legend::POSITION_TOP,
|
||||
Legend::POSITION_BOTTOM,
|
||||
Legend::POSITION_TOPRIGHT,
|
||||
];
|
||||
|
||||
$testInstance = new Legend();
|
||||
|
||||
foreach ($positionValues as $positionValue) {
|
||||
$result = $testInstance->setPosition($positionValue);
|
||||
self::assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetInvalidPositionReturnsFalse()
|
||||
{
|
||||
$testInstance = new Legend();
|
||||
|
||||
$result = $testInstance->setPosition('BottomLeft');
|
||||
self::assertFalse($result);
|
||||
// Ensure that value is unchanged
|
||||
$result = $testInstance->getPosition();
|
||||
self::assertEquals(Legend::POSITION_RIGHT, $result);
|
||||
}
|
||||
|
||||
public function testGetPosition()
|
||||
{
|
||||
$PositionValue = Legend::POSITION_BOTTOM;
|
||||
|
||||
$testInstance = new Legend();
|
||||
$testInstance->setPosition($PositionValue);
|
||||
|
||||
$result = $testInstance->getPosition();
|
||||
self::assertEquals($PositionValue, $result);
|
||||
}
|
||||
|
||||
public function testSetPositionXL()
|
||||
{
|
||||
$positionValues = [
|
||||
Legend::XL_LEGEND_POSITION_BOTTOM,
|
||||
Legend::XL_LEGEND_POSITION_CORNER,
|
||||
Legend::XL_LEGEND_POSITION_CUSTOM,
|
||||
Legend::XL_LEGEND_POSITION_LEFT,
|
||||
Legend::XL_LEGEND_POSITION_RIGHT,
|
||||
Legend::XL_LEGEND_POSITION_TOP,
|
||||
];
|
||||
|
||||
$testInstance = new Legend();
|
||||
|
||||
foreach ($positionValues as $positionValue) {
|
||||
$result = $testInstance->setPositionXL($positionValue);
|
||||
self::assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetInvalidXLPositionReturnsFalse()
|
||||
{
|
||||
$testInstance = new Legend();
|
||||
|
||||
$result = $testInstance->setPositionXL(999);
|
||||
self::assertFalse($result);
|
||||
// Ensure that value is unchanged
|
||||
$result = $testInstance->getPositionXL();
|
||||
self::assertEquals(Legend::XL_LEGEND_POSITION_RIGHT, $result);
|
||||
}
|
||||
|
||||
public function testGetPositionXL()
|
||||
{
|
||||
$PositionValue = Legend::XL_LEGEND_POSITION_CORNER;
|
||||
|
||||
$testInstance = new Legend();
|
||||
$testInstance->setPositionXL($PositionValue);
|
||||
|
||||
$result = $testInstance->getPositionXL();
|
||||
self::assertEquals($PositionValue, $result);
|
||||
}
|
||||
|
||||
public function testSetOverlay()
|
||||
{
|
||||
$overlayValues = [
|
||||
true,
|
||||
false,
|
||||
];
|
||||
|
||||
$testInstance = new Legend();
|
||||
|
||||
foreach ($overlayValues as $overlayValue) {
|
||||
$result = $testInstance->setOverlay($overlayValue);
|
||||
self::assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetInvalidOverlayReturnsFalse()
|
||||
{
|
||||
$testInstance = new Legend();
|
||||
|
||||
$result = $testInstance->setOverlay('INVALID');
|
||||
self::assertFalse($result);
|
||||
|
||||
$result = $testInstance->getOverlay();
|
||||
self::assertFalse($result);
|
||||
}
|
||||
|
||||
public function testGetOverlay()
|
||||
{
|
||||
$OverlayValue = true;
|
||||
|
||||
$testInstance = new Legend();
|
||||
$testInstance->setOverlay($OverlayValue);
|
||||
|
||||
$result = $testInstance->getOverlay();
|
||||
self::assertEquals($OverlayValue, $result);
|
||||
}
|
||||
}
|
117
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Collection/CellsTest.php
vendored
Normal file
117
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Collection/CellsTest.php
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Collection;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Collection\Cells;
|
||||
use PhpOffice\PhpSpreadsheet\Collection\Memory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CellsTest extends TestCase
|
||||
{
|
||||
public function testCollectionCell()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$collection = $sheet->getCellCollection();
|
||||
|
||||
// Assert empty state
|
||||
self::assertEquals([], $collection->getCoordinates(), 'cell list should be empty');
|
||||
self::assertEquals([], $collection->getSortedCoordinates(), 'sorted cell list should be empty');
|
||||
self::assertNull($collection->get('B2'), 'getting non-existing cell must return null');
|
||||
self::assertFalse($collection->has('B2'), 'non-existing cell should be non-existent');
|
||||
|
||||
// Add one cell
|
||||
$cell1 = $sheet->getCell('B2');
|
||||
self::assertSame($cell1, $collection->add('B2', $cell1), 'adding a cell should return the cell');
|
||||
|
||||
// Assert cell presence
|
||||
self::assertEquals(['B2'], $collection->getCoordinates(), 'cell list should contains the cell');
|
||||
self::assertEquals(['B2'], $collection->getSortedCoordinates(), 'sorted cell list contains the cell');
|
||||
self::assertSame($cell1, $collection->get('B2'), 'should get exact same object');
|
||||
self::assertTrue($collection->has('B2'), 'cell should exists');
|
||||
|
||||
// Add a second cell
|
||||
$cell2 = $sheet->getCell('A1');
|
||||
self::assertSame($cell2, $collection->add('A1', $cell2), 'adding a second cell should return the cell');
|
||||
self::assertEquals(['B2', 'A1'], $collection->getCoordinates(), 'cell list should contains the cell');
|
||||
self::assertEquals(['A1', 'B2'], $collection->getSortedCoordinates(), 'sorted cell list contains the cell');
|
||||
|
||||
// Assert collection copy
|
||||
$sheet2 = $spreadsheet->createSheet();
|
||||
$collection2 = $collection->cloneCellCollection($sheet2);
|
||||
self::assertTrue($collection2->has('A1'));
|
||||
$copiedCell2 = $collection2->get('A1');
|
||||
self::assertNotSame($cell2, $copiedCell2, 'copied cell should not be the same object any more');
|
||||
self::assertSame($collection2, $copiedCell2->getParent(), 'copied cell should be owned by the copied collection');
|
||||
self::assertSame('A1', $copiedCell2->getCoordinate(), 'copied cell should keep attributes');
|
||||
|
||||
// Assert deletion
|
||||
$collection->delete('B2');
|
||||
self::assertFalse($collection->has('B2'), 'cell should have been deleted');
|
||||
self::assertEquals(['A1'], $collection->getCoordinates(), 'cell list should contains the cell');
|
||||
|
||||
// Assert update
|
||||
$cell2 = $sheet->getCell('A1');
|
||||
self::assertSame($sheet->getCellCollection(), $collection);
|
||||
self::assertSame($cell2, $collection->update($cell2), 'should update existing cell');
|
||||
|
||||
$cell3 = $sheet->getCell('C3');
|
||||
self::assertSame($cell3, $collection->update($cell3), 'should silently add non-existing cell');
|
||||
self::assertEquals(['A1', 'C3'], $collection->getCoordinates(), 'cell list should contains the cell');
|
||||
}
|
||||
|
||||
public function testCacheLastCell()
|
||||
{
|
||||
$workbook = new Spreadsheet();
|
||||
$cells = ['A1', 'A2'];
|
||||
$sheet = $workbook->getActiveSheet();
|
||||
$sheet->setCellValue('A1', 1);
|
||||
$sheet->setCellValue('A2', 2);
|
||||
self::assertEquals($cells, $sheet->getCoordinates(), 'list should include last added cell');
|
||||
}
|
||||
|
||||
public function testCanGetCellAfterAnotherIsDeleted()
|
||||
{
|
||||
$workbook = new Spreadsheet();
|
||||
$sheet = $workbook->getActiveSheet();
|
||||
$collection = $sheet->getCellCollection();
|
||||
$sheet->setCellValue('A1', 1);
|
||||
$sheet->setCellValue('A2', 1);
|
||||
$collection->delete('A1');
|
||||
$sheet->setCellValue('A3', 1);
|
||||
self::assertNotNull($collection->get('A2'), 'should be able to get back the cell even when another cell was deleted while this one was the current one');
|
||||
}
|
||||
|
||||
public function testThrowsWhenCellCannotBeRetrievedFromCache()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$collection = $this->getMockBuilder(Cells::class)
|
||||
->setConstructorArgs([new Worksheet(), new Memory()])
|
||||
->setMethods(['has'])
|
||||
->getMock();
|
||||
|
||||
$collection->method('has')
|
||||
->willReturn(true);
|
||||
|
||||
$collection->get('A2');
|
||||
}
|
||||
|
||||
public function testThrowsWhenCellCannotBeStoredInCache()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$cache = $this->createMock(Memory::class);
|
||||
$cell = $this->createMock(Cell::class);
|
||||
$cache->method('set')
|
||||
->willReturn(false);
|
||||
|
||||
$collection = new Cells(new Worksheet(), $cache);
|
||||
|
||||
$collection->add('A1', $cell);
|
||||
$collection->add('A2', $cell);
|
||||
}
|
||||
}
|
82
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php
vendored
Normal file
82
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Custom;
|
||||
|
||||
use Complex\Complex;
|
||||
|
||||
class ComplexAssert
|
||||
{
|
||||
private $errorMessage = '';
|
||||
|
||||
private function testExpectedExceptions($expected, $actual)
|
||||
{
|
||||
// Expecting an error, so we do a straight string comparison
|
||||
if ($expected === $actual) {
|
||||
return true;
|
||||
} elseif ($expected === INF && $actual === 'INF') {
|
||||
return true;
|
||||
}
|
||||
$this->errorMessage = 'Expected Error: ' . $actual . ' !== ' . $expected;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function adjustDelta($expected, $actual, $delta)
|
||||
{
|
||||
$adjustedDelta = $delta;
|
||||
|
||||
if (abs($actual) > 10 && abs($expected) > 10) {
|
||||
$variance = floor(log10(abs($expected)));
|
||||
$adjustedDelta *= pow(10, $variance);
|
||||
}
|
||||
|
||||
return $adjustedDelta > 1.0 ? 1.0 : $adjustedDelta;
|
||||
}
|
||||
|
||||
public function assertComplexEquals($expected, $actual, $delta = 0)
|
||||
{
|
||||
if ($expected === INF || $expected[0] === '#') {
|
||||
return $this->testExpectedExceptions($expected, $actual);
|
||||
}
|
||||
|
||||
$expectedComplex = new Complex($expected);
|
||||
$actualComplex = new Complex($actual);
|
||||
|
||||
if (!is_numeric($actualComplex->getReal()) || !is_numeric($expectedComplex->getReal())) {
|
||||
if ($actualComplex->getReal() !== $expectedComplex->getReal()) {
|
||||
$this->errorMessage = 'Mismatched String: ' . $actualComplex->getReal() . ' !== ' . $expectedComplex->getReal();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$adjustedDelta = $this->adjustDelta($expectedComplex->getReal(), $actualComplex->getReal(), $delta);
|
||||
if (abs($actualComplex->getReal() - $expectedComplex->getReal()) > $adjustedDelta) {
|
||||
$this->errorMessage = 'Mismatched Real part: ' . $actualComplex->getReal() . ' != ' . $expectedComplex->getReal();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$adjustedDelta = $this->adjustDelta($expectedComplex->getImaginary(), $actualComplex->getImaginary(), $delta);
|
||||
if (abs($actualComplex->getImaginary() - $expectedComplex->getImaginary()) > $adjustedDelta) {
|
||||
$this->errorMessage = 'Mismatched Imaginary part: ' . $actualComplex->getImaginary() . ' != ' . $expectedComplex->getImaginary();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($actualComplex->getSuffix() !== $actualComplex->getSuffix()) {
|
||||
$this->errorMessage = 'Mismatched Suffix: ' . $actualComplex->getSuffix() . ' != ' . $expectedComplex->getSuffix();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return $this->errorMessage;
|
||||
}
|
||||
}
|
39
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php
vendored
Normal file
39
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\File;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Base class for functional test to write and reload file on disk across different formats.
|
||||
*/
|
||||
abstract class AbstractFunctional extends TestCase
|
||||
{
|
||||
/**
|
||||
* Write spreadsheet to disk, reload and return it.
|
||||
*
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param string $format
|
||||
* @param null|callable $readerCustomizer
|
||||
*
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
protected function writeAndReload(Spreadsheet $spreadsheet, $format, callable $readerCustomizer = null)
|
||||
{
|
||||
$filename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test');
|
||||
$writer = IOFactory::createWriter($spreadsheet, $format);
|
||||
$writer->save($filename);
|
||||
|
||||
$reader = IOFactory::createReader($format);
|
||||
if ($readerCustomizer) {
|
||||
$readerCustomizer($reader);
|
||||
}
|
||||
$reloadedSpreadsheet = $reader->load($filename);
|
||||
unlink($filename);
|
||||
|
||||
return $reloadedSpreadsheet;
|
||||
}
|
||||
}
|
43
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php
vendored
Normal file
43
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/ColumnWidthTest.php
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class ColumnWidthTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Xlsx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param $format
|
||||
*/
|
||||
public function testReadColumnWidth($format)
|
||||
{
|
||||
// create new sheet with column width
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->setCellValue('A1', 'Hello World !');
|
||||
$sheet->getColumnDimension('A')->setWidth(20);
|
||||
$this->assertColumn($spreadsheet);
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
$this->assertColumn($reloadedSpreadsheet);
|
||||
}
|
||||
|
||||
private function assertColumn(Spreadsheet $spreadsheet)
|
||||
{
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$columnDimensions = $sheet->getColumnDimensions();
|
||||
|
||||
self::assertArrayHasKey('A', $columnDimensions);
|
||||
$column = array_shift($columnDimensions);
|
||||
self::assertEquals(20, $column->getWidth());
|
||||
}
|
||||
}
|
44
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/CommentsTest.php
vendored
Normal file
44
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/CommentsTest.php
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class CommentsTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Html'],
|
||||
['Xlsx'],
|
||||
['Ods'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test load file with comment in sheet to load proper
|
||||
* count of comments in correct coords.
|
||||
*
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param $format
|
||||
*/
|
||||
public function testComments($format)
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
$spreadsheet->getActiveSheet()->getCell('E10')->setValue('Comment');
|
||||
$spreadsheet->getActiveSheet()
|
||||
->getComment('E10')
|
||||
->getText()
|
||||
->createText('Comment to test');
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
|
||||
$commentsLoaded = $reloadedSpreadsheet->getSheet(0)->getComments();
|
||||
self::assertCount(1, $commentsLoaded);
|
||||
|
||||
$commentCoordinate = key($commentsLoaded);
|
||||
self::assertSame('E10', $commentCoordinate);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class ConditionalStopIfTrueTest extends AbstractFunctional
|
||||
{
|
||||
const COLOR_GREEN = 'FF99FF66';
|
||||
const COLOR_RED = 'FFFF5050';
|
||||
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Xlsx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param string $format
|
||||
*/
|
||||
public function testConditionalStopIfTrue($format)
|
||||
{
|
||||
$pCoordinate = 'A1:A3';
|
||||
|
||||
// if blank cell -> no styling
|
||||
$condition0 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$condition0->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION);
|
||||
$condition0->addCondition('LEN(TRIM(A1))=0');
|
||||
$condition0->setStopIfTrue(true); // ! stop here
|
||||
|
||||
// if value below 0.6 (matches also blank cells!) -> red background
|
||||
$condition1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$condition1->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS);
|
||||
$condition1->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN);
|
||||
$condition1->addCondition(0.6);
|
||||
$condition1->getStyle()->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getEndColor()->setARGB(self::COLOR_RED);
|
||||
|
||||
// if value above 0.6 -> green background
|
||||
$condition2 = new \PhpOffice\PhpSpreadsheet\Style\Conditional();
|
||||
$condition2->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS);
|
||||
$condition2->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_GREATERTHAN);
|
||||
$condition2->addCondition(0.6);
|
||||
$condition2->getStyle()->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getEndColor()->setARGB(self::COLOR_GREEN);
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->getActiveSheet()->getCell('A1')->setValue(0.7);
|
||||
$spreadsheet->getActiveSheet()->getCell('A2')->setValue('');
|
||||
$spreadsheet->getActiveSheet()->getCell('A3')->setValue(0.4);
|
||||
|
||||
// put all three conditions in sheet
|
||||
$conditionalStyles = [];
|
||||
array_push($conditionalStyles, $condition0);
|
||||
array_push($conditionalStyles, $condition1);
|
||||
array_push($conditionalStyles, $condition2);
|
||||
$spreadsheet->getActiveSheet()->setConditionalStyles($pCoordinate, $conditionalStyles);
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
|
||||
// see if we successfully written "StopIfTrue"
|
||||
$newConditionalStyles = $reloadedSpreadsheet->getActiveSheet()->getConditionalStyles($pCoordinate);
|
||||
self::assertTrue($newConditionalStyles[0]->getStopIfTrue(), 'StopIfTrue should be set (=true) on first condition');
|
||||
self::assertFalse($newConditionalStyles[1]->getStopIfTrue(), 'StopIfTrue should not be set (=false) on second condition');
|
||||
self::assertFalse($newConditionalStyles[2]->getStopIfTrue(), 'StopIfTrue should not be set (=false) on third condition');
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Hyperlink;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
|
||||
|
||||
class DrawingImageHyperlinkTest extends AbstractFunctional
|
||||
{
|
||||
public function testDrawingImageHyperlinkTest()
|
||||
{
|
||||
$baseUrl = 'https://github.com/PHPOffice/PhpSpreadsheet';
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
$aSheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$gdImage = @imagecreatetruecolor(120, 20);
|
||||
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
|
||||
imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor);
|
||||
|
||||
$drawing = new MemoryDrawing();
|
||||
$drawing->setName('In-Memory image 1');
|
||||
$drawing->setDescription('In-Memory image 1');
|
||||
$drawing->setCoordinates('A1');
|
||||
$drawing->setImageResource($gdImage);
|
||||
$drawing->setRenderingFunction(
|
||||
MemoryDrawing::RENDERING_JPEG
|
||||
);
|
||||
$drawing->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT);
|
||||
$drawing->setHeight(36);
|
||||
$hyperLink = new Hyperlink($baseUrl, 'test image');
|
||||
$drawing->setHyperlink($hyperLink);
|
||||
$drawing->setWorksheet($aSheet);
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx');
|
||||
|
||||
foreach ($reloadedSpreadsheet->getActiveSheet()->getDrawingCollection() as $pDrawing) {
|
||||
self::assertEquals('https://github.com/PHPOffice/PhpSpreadsheet', $pDrawing->getHyperlink()->getUrl(), 'functional test drawing hyperlink');
|
||||
}
|
||||
}
|
||||
}
|
37
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php
vendored
Normal file
37
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/EnclosureTest.php
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class EnclosureTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Html'],
|
||||
['Xls'],
|
||||
['Xlsx'],
|
||||
['Ods'],
|
||||
['Csv'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param string $format
|
||||
*/
|
||||
public function testEnclosure($format)
|
||||
{
|
||||
$value = '<img alt="" src="http://example.com/image.jpg" />';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->getActiveSheet()->getCell('A1')->setValue($value);
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
|
||||
$actual = $reloadedSpreadsheet->getActiveSheet()->getCell('A1')->getCalculatedValue();
|
||||
self::assertSame($value, $actual, 'should be able to write and read strings with multiples quotes');
|
||||
}
|
||||
}
|
75
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php
vendored
Normal file
75
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class FreezePaneTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Xls'],
|
||||
['Xlsx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param string $format
|
||||
*/
|
||||
public function testFreezePane($format)
|
||||
{
|
||||
$cellSplit = 'B4';
|
||||
$topLeftCell = 'E7';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->getActiveSheet()->freezePane($cellSplit, $topLeftCell);
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
|
||||
// Read written file
|
||||
$reloadedActive = $reloadedSpreadsheet->getActiveSheet();
|
||||
$actualCellSplit = $reloadedActive->getFreezePane();
|
||||
$actualTopLeftCell = $reloadedActive->getTopLeftCell();
|
||||
|
||||
self::assertSame($cellSplit, $actualCellSplit, 'should be able to set freeze pane');
|
||||
self::assertSame($topLeftCell, $actualTopLeftCell, 'should be able to set the top left cell');
|
||||
}
|
||||
|
||||
public function providerFormatsInvalidSelectedCells()
|
||||
{
|
||||
return [
|
||||
['Xlsx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormatsInvalidSelectedCells
|
||||
*
|
||||
* @param string $format
|
||||
*/
|
||||
public function testFreezePaneWithInvalidSelectedCells($format)
|
||||
{
|
||||
$cellSplit = 'A7';
|
||||
$topLeftCell = 'A24';
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$worksheet->freezePane('A7', 'A24');
|
||||
$worksheet->setSelectedCells('F5');
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
|
||||
// Read written file
|
||||
$reloadedActive = $reloadedSpreadsheet->getActiveSheet();
|
||||
$actualCellSplit = $reloadedActive->getFreezePane();
|
||||
$actualTopLeftCell = $reloadedActive->getTopLeftCell();
|
||||
|
||||
self::assertSame($cellSplit, $actualCellSplit, 'should be able to set freeze pane');
|
||||
self::assertSame($topLeftCell, $actualTopLeftCell, 'should be able to set the top left cell');
|
||||
self::assertSame('A24', $reloadedActive->getSelectedCells(), 'selected cell should default to be first cell after the freeze pane');
|
||||
}
|
||||
}
|
63
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/HtmlCommentsTest.php
vendored
Normal file
63
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/HtmlCommentsTest.php
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class HtmlCommentsTest extends AbstractFunctional
|
||||
{
|
||||
private $spreadsheet;
|
||||
|
||||
public function providerCommentRichText()
|
||||
{
|
||||
$valueSingle = 'I am comment.';
|
||||
$valueMulti = 'I am ' . PHP_EOL . 'multi-line' . PHP_EOL . 'comment.';
|
||||
|
||||
$plainSingle = new RichText();
|
||||
$plainSingle->createText($valueSingle);
|
||||
|
||||
$plainMulti = new RichText();
|
||||
$plainMulti->createText($valueMulti);
|
||||
|
||||
$richSingle = new RichText();
|
||||
$richSingle->createTextRun($valueSingle)->getFont()->setBold(true);
|
||||
|
||||
$richMultiSimple = new RichText();
|
||||
$richMultiSimple->createTextRun($valueMulti)->getFont()->setBold(true);
|
||||
|
||||
$richMultiMixed = new RichText();
|
||||
$richMultiMixed->createText('I am' . PHP_EOL);
|
||||
$richMultiMixed->createTextRun('multi-line')->getFont()->setBold(true);
|
||||
$richMultiMixed->createText(PHP_EOL . 'comment!');
|
||||
|
||||
return [
|
||||
'single line plain text' => [$plainSingle],
|
||||
'multi-line plain text' => [$plainMulti],
|
||||
'single line simple rich text' => [$richSingle],
|
||||
'multi-line simple rich text' => [$richMultiSimple],
|
||||
'multi-line mixed rich text' => [$richMultiMixed],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCommentRichText
|
||||
*
|
||||
* @param mixed $richText
|
||||
*/
|
||||
public function testComments($richText)
|
||||
{
|
||||
$this->spreadsheet = new Spreadsheet();
|
||||
|
||||
$this->spreadsheet->getActiveSheet()->getCell('A1')->setValue('Comment');
|
||||
|
||||
$this->spreadsheet->getActiveSheet()
|
||||
->getComment('A1')
|
||||
->setText($richText);
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($this->spreadsheet, 'Html');
|
||||
|
||||
$actual = $reloadedSpreadsheet->getActiveSheet()->getComment('A1')->getText()->getPlainText();
|
||||
self::assertSame($richText->getPlainText(), $actual);
|
||||
}
|
||||
}
|
42
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php
vendored
Normal file
42
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class MergedCellsTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Html'],
|
||||
['Xls'],
|
||||
['Xlsx'],
|
||||
['Ods'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param string $format
|
||||
*/
|
||||
public function testMergedCells($format)
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A1', '1');
|
||||
$spreadsheet->getActiveSheet()->setCellValue('B1', '2');
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A2', '33');
|
||||
$spreadsheet->getActiveSheet()->mergeCells('A2:B2');
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
|
||||
$actual = 0;
|
||||
foreach ($reloadedSpreadsheet->getWorksheetIterator() as $worksheet) {
|
||||
$actual += count($worksheet->getMergeCells());
|
||||
}
|
||||
|
||||
self::assertSame(1, $actual, "Format $format failed, could not read 1 merged cell");
|
||||
}
|
||||
}
|
44
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php
vendored
Normal file
44
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\BaseReader;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class PrintAreaTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Xls'],
|
||||
['Xlsx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param string $format
|
||||
*/
|
||||
public function testPageSetup($format)
|
||||
{
|
||||
// Create new workbook with 3 sheets and different print areas
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$worksheet1 = $spreadsheet->getActiveSheet()->setTitle('Sheet 1');
|
||||
$worksheet1->getPageSetup()->setPrintArea('A1:B1');
|
||||
|
||||
for ($i = 2; $i < 4; ++$i) {
|
||||
$sheet = $spreadsheet->createSheet()->setTitle("Sheet $i");
|
||||
$sheet->getPageSetup()->setPrintArea("A$i:B$i");
|
||||
}
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function (BaseReader $reader) {
|
||||
$reader->setLoadSheetsOnly(['Sheet 1', 'Sheet 3']);
|
||||
});
|
||||
|
||||
$actual1 = $reloadedSpreadsheet->getSheetByName('Sheet 1')->getPageSetup()->getPrintArea();
|
||||
$actual3 = $reloadedSpreadsheet->getSheetByName('Sheet 3')->getPageSetup()->getPrintArea();
|
||||
self::assertSame('A1:B1', $actual1, 'should be able to write and read normal page setup');
|
||||
self::assertSame('A3:B3', $actual3, 'should be able to write and read page setup even when skipping sheets');
|
||||
}
|
||||
}
|
124
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php
vendored
Normal file
124
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class ReadFilterTest extends AbstractFunctional
|
||||
{
|
||||
public function providerCellsValues()
|
||||
{
|
||||
$cellValues = [
|
||||
// one argument as a multidimensional array
|
||||
[1, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[2, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[3, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[4, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[5, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[6, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[7, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[8, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[9, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
[10, 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],
|
||||
];
|
||||
|
||||
return [
|
||||
['Xlsx', $cellValues],
|
||||
['Ods', $cellValues],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test load Xlsx file with many empty cells with no filter used.
|
||||
*
|
||||
* @dataProvider providerCellsValues
|
||||
*
|
||||
* @param array $arrayData
|
||||
* @param mixed $format
|
||||
*/
|
||||
public function testXlsxLoadWithoutReadFilter($format, array $arrayData)
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
$spreadsheet->getActiveSheet()->fromArray($arrayData, null, 'A1');
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
$sheet = $reloadedSpreadsheet->getSheet(0);
|
||||
// test highest column (very specific num of columns because of some 3rd party software)
|
||||
self::assertSame('J', $sheet->getHighestColumn());
|
||||
|
||||
// test highest row (very specific num of rows because of some 3rd party software)
|
||||
self::assertEquals(10, $sheet->getHighestRow());
|
||||
|
||||
// test top left coordinate
|
||||
$sortedCoordinates = $sheet->getCellCollection()->getSortedCoordinates();
|
||||
$coordinateTopLeft = reset($sortedCoordinates);
|
||||
self::assertSame('A1', $coordinateTopLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test load Xlsx file with many empty cells (and big max row number) with readfilter.
|
||||
*
|
||||
* @dataProvider providerCellsValues
|
||||
*
|
||||
* @param array $arrayData
|
||||
* @param mixed $format
|
||||
*/
|
||||
public function testXlsxLoadWithReadFilter($format, array $arrayData)
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->getActiveSheet()->fromArray($arrayData, null, 'A1');
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function ($reader) {
|
||||
// Create a stub for the readFilter class.
|
||||
$readFilterStub = $this->createMock(IReadFilter::class);
|
||||
$readFilterStub->method('readCell')
|
||||
->will($this->returnCallback([$this, 'readFilterReadCell']));
|
||||
// apply filter
|
||||
$reader->setReadFilter($readFilterStub);
|
||||
});
|
||||
$sheet = $reloadedSpreadsheet->getSheet(0);
|
||||
// test highest column (very specific num of columns because of some 3rd party software)
|
||||
self::assertSame('D', $sheet->getHighestColumn());
|
||||
|
||||
// test highest row (very specific num of rows because of some 3rd party software)
|
||||
self::assertEquals(6, $sheet->getHighestRow());
|
||||
|
||||
// test top left coordinate
|
||||
$sortedCoordinates = $sheet->getCellCollection()->getSortedCoordinates();
|
||||
$coordinateTopLeft = reset($sortedCoordinates);
|
||||
self::assertSame('B2', $coordinateTopLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::readCell()
|
||||
*
|
||||
* @param string $column Column address (as a string value like "A", or "IV")
|
||||
* @param int $row Row number
|
||||
* @param string $worksheetName Optional worksheet name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function readFilterReadCell($column, $row, $worksheetName = '')
|
||||
{
|
||||
// define filter range
|
||||
$rowMin = 2;
|
||||
$rowMax = 6;
|
||||
$columnMin = 'B';
|
||||
$columnMax = 'D';
|
||||
|
||||
$r = (int) $row;
|
||||
if ($r > $rowMax || $r < $rowMin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$col = sprintf('%04s', $column);
|
||||
if ($col > sprintf('%04s', $columnMax) ||
|
||||
$col < sprintf('%04s', $columnMin)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class TypeAttributePreservationTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormulae()
|
||||
{
|
||||
$formats = ['Xlsx'];
|
||||
$data = require 'data/Functional/TypeAttributePreservation/Formula.php';
|
||||
|
||||
$result = [];
|
||||
foreach ($formats as $f) {
|
||||
foreach ($data as $d) {
|
||||
$result[] = [$f, $d];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure saved spreadsheets maintain the correct data type.
|
||||
*
|
||||
* @dataProvider providerFormulae
|
||||
*
|
||||
* @param string $format
|
||||
* @param array $values
|
||||
*/
|
||||
public function testFormulae($format, array $values)
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->fromArray($values);
|
||||
|
||||
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
|
||||
$reloadedSheet = $reloadedSpreadsheet->getActiveSheet();
|
||||
|
||||
$expected = $sheet->getCell('A1')->getCalculatedValue();
|
||||
|
||||
if ($sheet->getCell('A1')->getDataType() === 'f') {
|
||||
$actual = $reloadedSheet->getCell('A1')->getOldCalculatedValue();
|
||||
} else {
|
||||
$actual = $reloadedSheet->getCell('A1')->getValue();
|
||||
}
|
||||
|
||||
self::assertSame($expected, $actual);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class WorkbookViewAttributesTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Xlsx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that workbook bookview attributes such as 'showSheetTabs',
|
||||
* (the attribute controlling worksheet tabs visibility,)
|
||||
* are preserved when xlsx documents are read and written.
|
||||
*
|
||||
* @see https://github.com/PHPOffice/PhpSpreadsheet/issues/523
|
||||
*
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param string $format
|
||||
*/
|
||||
public function testPreserveWorkbookViewAttributes($format)
|
||||
{
|
||||
// Create a dummy workbook with two worksheets
|
||||
$workbook = new Spreadsheet();
|
||||
$worksheet1 = $workbook->getActiveSheet();
|
||||
$worksheet1->setTitle('Tweedledee');
|
||||
$worksheet1->setCellValue('A1', 1);
|
||||
$worksheet2 = $workbook->createSheet();
|
||||
$worksheet2->setTitle('Tweeldedum');
|
||||
$worksheet2->setCellValue('A1', 2);
|
||||
|
||||
// Check that the bookview attributes return default values
|
||||
$this->assertTrue($workbook->getShowHorizontalScroll());
|
||||
$this->assertTrue($workbook->getShowVerticalScroll());
|
||||
$this->assertTrue($workbook->getShowSheetTabs());
|
||||
$this->assertTrue($workbook->getAutoFilterDateGrouping());
|
||||
$this->assertFalse($workbook->getMinimized());
|
||||
$this->assertSame(0, $workbook->getFirstSheetIndex());
|
||||
$this->assertSame(600, $workbook->getTabRatio());
|
||||
$this->assertSame(Spreadsheet::VISIBILITY_VISIBLE, $workbook->getVisibility());
|
||||
|
||||
// Set the bookview attributes to non-default values
|
||||
$workbook->setShowHorizontalScroll(false);
|
||||
$workbook->setShowVerticalScroll(false);
|
||||
$workbook->setShowSheetTabs(false);
|
||||
$workbook->setAutoFilterDateGrouping(false);
|
||||
$workbook->setMinimized(true);
|
||||
$workbook->setFirstSheetIndex(1);
|
||||
$workbook->setTabRatio(700);
|
||||
$workbook->setVisibility(Spreadsheet::VISIBILITY_HIDDEN);
|
||||
|
||||
// Check that bookview attributes were set properly
|
||||
$this->assertFalse($workbook->getShowHorizontalScroll());
|
||||
$this->assertFalse($workbook->getShowVerticalScroll());
|
||||
$this->assertFalse($workbook->getShowSheetTabs());
|
||||
$this->assertFalse($workbook->getAutoFilterDateGrouping());
|
||||
$this->assertTrue($workbook->getMinimized());
|
||||
$this->assertSame(1, $workbook->getFirstSheetIndex());
|
||||
$this->assertSame(700, $workbook->getTabRatio());
|
||||
$this->assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook->getVisibility());
|
||||
|
||||
$workbook2 = $this->writeAndReload($workbook, $format);
|
||||
|
||||
// Check that the read spreadsheet has the right bookview attributes
|
||||
$this->assertFalse($workbook2->getShowHorizontalScroll());
|
||||
$this->assertFalse($workbook2->getShowVerticalScroll());
|
||||
$this->assertFalse($workbook2->getShowSheetTabs());
|
||||
$this->assertFalse($workbook2->getAutoFilterDateGrouping());
|
||||
$this->assertTrue($workbook2->getMinimized());
|
||||
$this->assertSame(1, $workbook2->getFirstSheetIndex());
|
||||
$this->assertSame(700, $workbook2->getTabRatio());
|
||||
$this->assertSame(Spreadsheet::VISIBILITY_HIDDEN, $workbook2->getVisibility());
|
||||
}
|
||||
}
|
33
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Helper/HtmlTest.php
vendored
Normal file
33
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Helper/HtmlTest.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Helper;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Html;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HtmlTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerUtf8EncodingSupport
|
||||
*
|
||||
* @param mixed $expected
|
||||
* @param mixed $input
|
||||
*/
|
||||
public function testUtf8EncodingSupport($expected, $input)
|
||||
{
|
||||
$html = new Html();
|
||||
$actual = $html->toRichTextObject($input);
|
||||
|
||||
self::assertSame($expected, $actual->getPlainText());
|
||||
}
|
||||
|
||||
public function providerUtf8EncodingSupport()
|
||||
{
|
||||
return [
|
||||
['foo', 'foo'],
|
||||
['können', 'können'],
|
||||
['русский', 'русский'],
|
||||
["foo\nbar", '<p>foo</p><p>bar</p>'],
|
||||
];
|
||||
}
|
||||
}
|
88
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Helper/MigratorTest.php
vendored
Normal file
88
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Helper/MigratorTest.php
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Helper;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Migrator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MigratorTest extends TestCase
|
||||
{
|
||||
public function testMappingOnlyContainExistingClasses()
|
||||
{
|
||||
$migrator = new Migrator();
|
||||
|
||||
foreach ($migrator->getMapping() as $classname) {
|
||||
if (substr_count($classname, '\\')) {
|
||||
self::assertTrue(class_exists($classname) || interface_exists($classname), 'mapping is wrong, class does not exists in project: ' . $classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testReplace()
|
||||
{
|
||||
$input = <<<'STRING'
|
||||
<?php
|
||||
|
||||
namespace Foo;
|
||||
|
||||
use PHPExcel;
|
||||
use PHPExcel_Worksheet;
|
||||
|
||||
class Bar
|
||||
{
|
||||
/**
|
||||
* @param PHPExcel $workbook
|
||||
* @param PHPExcel_Worksheet $sheet
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function baz(PHPExcel $workbook, PHPExcel_Worksheet $sheet)
|
||||
{
|
||||
PHPExcel::class;
|
||||
\PHPExcel::class;
|
||||
$PHPExcel->do();
|
||||
$fooobjPHPExcel->do();
|
||||
$objPHPExcel->do();
|
||||
$this->objPHPExcel->do();
|
||||
$this->PHPExcel->do();
|
||||
|
||||
return \PHPExcel_Cell::stringFromColumnIndex(9);
|
||||
}
|
||||
}
|
||||
STRING;
|
||||
|
||||
$expected = <<<'STRING'
|
||||
<?php
|
||||
|
||||
namespace Foo;
|
||||
|
||||
use \PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class Bar
|
||||
{
|
||||
/**
|
||||
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $workbook
|
||||
* @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function baz(\PhpOffice\PhpSpreadsheet\Spreadsheet $workbook, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet)
|
||||
{
|
||||
\PhpOffice\PhpSpreadsheet\Spreadsheet::class;
|
||||
\PhpOffice\PhpSpreadsheet\Spreadsheet::class;
|
||||
$PHPExcel->do();
|
||||
$fooobjPHPExcel->do();
|
||||
$objPHPExcel->do();
|
||||
$this->objPHPExcel->do();
|
||||
$this->PHPExcel->do();
|
||||
|
||||
return \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex(9);
|
||||
}
|
||||
}
|
||||
STRING;
|
||||
|
||||
$migrator = new Migrator();
|
||||
self::assertSame($expected, $migrator->replace($input));
|
||||
}
|
||||
}
|
62
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Helper/SampleTest.php
vendored
Normal file
62
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Helper/SampleTest.php
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Helper;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Helper\Sample;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider providerSample
|
||||
*
|
||||
* @param mixed $sample
|
||||
*/
|
||||
public function testSample($sample)
|
||||
{
|
||||
// Suppress output to console
|
||||
$this->setOutputCallback(function () {
|
||||
});
|
||||
|
||||
require $sample;
|
||||
}
|
||||
|
||||
public function providerSample()
|
||||
{
|
||||
$skipped = [
|
||||
'Chart/32_Chart_read_write_PDF.php', // Unfortunately JpGraph is not up to date for latest PHP and raise many warnings
|
||||
'Chart/32_Chart_read_write_HTML.php', // idem
|
||||
];
|
||||
|
||||
// TCPDF does not support PHP 7.2
|
||||
if (version_compare(PHP_VERSION, '7.2.0') >= 0) {
|
||||
$skipped[] = 'Pdf/21_Pdf_TCPDF.php';
|
||||
}
|
||||
|
||||
// Unfortunately some tests are too long be ran with code-coverage
|
||||
// analysis on Travis, so we need to exclude them
|
||||
global $argv;
|
||||
if (in_array('--coverage-clover', $argv)) {
|
||||
$tooLongToBeCovered = [
|
||||
'Basic/06_Largescale.php',
|
||||
'Basic/13_CalculationCyclicFormulae.php',
|
||||
];
|
||||
$skipped = array_merge($skipped, $tooLongToBeCovered);
|
||||
}
|
||||
|
||||
$helper = new Sample();
|
||||
$result = [];
|
||||
foreach ($helper->getSamples() as $samples) {
|
||||
foreach ($samples as $sample) {
|
||||
if (!in_array($sample, $skipped)) {
|
||||
$file = '../samples/' . $sample;
|
||||
$result[] = [$file];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
147
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/IOFactoryTest.php
vendored
Normal file
147
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/IOFactoryTest.php
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Reader;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IOFactoryTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerCreateWriter
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testCreateWriter($name, $expected)
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$actual = IOFactory::createWriter($spreadsheet, $name);
|
||||
self::assertInstanceOf($expected, $actual);
|
||||
}
|
||||
|
||||
public function providerCreateWriter()
|
||||
{
|
||||
return [
|
||||
['Xls', Writer\Xls::class],
|
||||
['Xlsx', Writer\Xlsx::class],
|
||||
['Ods', Writer\Ods::class],
|
||||
['Csv', Writer\Csv::class],
|
||||
['Html', Writer\Html::class],
|
||||
['Mpdf', Writer\Pdf\Mpdf::class],
|
||||
['Tcpdf', Writer\Pdf\Tcpdf::class],
|
||||
['Dompdf', Writer\Pdf\Dompdf::class],
|
||||
];
|
||||
}
|
||||
|
||||
public function testRegisterWriter()
|
||||
{
|
||||
IOFactory::registerWriter('Pdf', Writer\Pdf\Mpdf::class);
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$actual = IOFactory::createWriter($spreadsheet, 'Pdf');
|
||||
self::assertInstanceOf(Writer\Pdf\Mpdf::class, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCreateReader
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testCreateReader($name, $expected)
|
||||
{
|
||||
$actual = IOFactory::createReader($name);
|
||||
self::assertInstanceOf($expected, $actual);
|
||||
}
|
||||
|
||||
public function providerCreateReader()
|
||||
{
|
||||
return [
|
||||
['Xls', Reader\Xls::class],
|
||||
['Xlsx', Reader\Xlsx::class],
|
||||
['Xml', Reader\Xml::class],
|
||||
['Ods', Reader\Ods::class],
|
||||
['Gnumeric', Reader\Gnumeric::class],
|
||||
['Csv', Reader\Csv::class],
|
||||
['Slk', Reader\Slk::class],
|
||||
['Html', Reader\Html::class],
|
||||
];
|
||||
}
|
||||
|
||||
public function testRegisterReader()
|
||||
{
|
||||
IOFactory::registerReader('Custom', Reader\Html::class);
|
||||
$actual = IOFactory::createReader('Custom');
|
||||
self::assertInstanceOf(Reader\Html::class, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIdentify
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $expectedName
|
||||
* @param string $expectedClass
|
||||
*/
|
||||
public function testIdentify($file, $expectedName, $expectedClass)
|
||||
{
|
||||
$actual = IOFactory::identify($file);
|
||||
self::assertSame($expectedName, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIdentify
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $expectedName
|
||||
* @param string $expectedClass
|
||||
*/
|
||||
public function testCreateReaderForFile($file, $expectedName, $expectedClass)
|
||||
{
|
||||
$actual = IOFactory::createReaderForFile($file);
|
||||
self::assertInstanceOf($expectedClass, $actual);
|
||||
}
|
||||
|
||||
public function providerIdentify()
|
||||
{
|
||||
return [
|
||||
['../samples/templates/26template.xlsx', 'Xlsx', Reader\Xlsx::class],
|
||||
['../samples/templates/GnumericTest.gnumeric', 'Gnumeric', Reader\Gnumeric::class],
|
||||
['../samples/templates/30template.xls', 'Xls', Reader\Xls::class],
|
||||
['../samples/templates/OOCalcTest.ods', 'Ods', Reader\Ods::class],
|
||||
['../samples/templates/SylkTest.slk', 'Slk', Reader\Slk::class],
|
||||
['../samples/templates/Excel2003XMLTest.xml', 'Xml', Reader\Xml::class],
|
||||
['../samples/templates/46readHtml.html', 'Html', Reader\Html::class],
|
||||
];
|
||||
}
|
||||
|
||||
public function testIdentifyNonExistingFileThrowException()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
IOFactory::identify('/non/existing/file');
|
||||
}
|
||||
|
||||
public function testIdentifyExistingDirectoryThrowExceptions()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
IOFactory::identify('.');
|
||||
}
|
||||
|
||||
public function testRegisterInvalidWriter()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Writer\Exception::class);
|
||||
|
||||
IOFactory::registerWriter('foo', 'bar');
|
||||
}
|
||||
|
||||
public function testRegisterInvalidReader()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class);
|
||||
|
||||
IOFactory::registerReader('foo', 'bar');
|
||||
}
|
||||
}
|
109
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/CsvTest.php
vendored
Normal file
109
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/CsvTest.php
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Csv;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CsvTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerDelimiterDetection
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $expectedDelimiter
|
||||
* @param string $cell
|
||||
* @param float|int|string $expectedValue
|
||||
*/
|
||||
public function testDelimiterDetection($filename, $expectedDelimiter, $cell, $expectedValue)
|
||||
{
|
||||
$reader = new Csv();
|
||||
self::assertNull($reader->getDelimiter());
|
||||
|
||||
$spreadsheet = $reader->load($filename);
|
||||
|
||||
self::assertSame($expectedDelimiter, $reader->getDelimiter(), 'should be able to infer the delimiter');
|
||||
|
||||
$actual = $spreadsheet->getActiveSheet()->getCell($cell)->getValue();
|
||||
self::assertSame($expectedValue, $actual, 'should be able to retrieve correct value');
|
||||
}
|
||||
|
||||
public function providerDelimiterDetection()
|
||||
{
|
||||
return [
|
||||
[
|
||||
__DIR__ . '/../../data/Reader/CSV/enclosure.csv',
|
||||
',',
|
||||
'C4',
|
||||
'username2',
|
||||
],
|
||||
[
|
||||
__DIR__ . '/../../data/Reader/CSV/semicolon_separated.csv',
|
||||
';',
|
||||
'C2',
|
||||
'25,5',
|
||||
],
|
||||
[
|
||||
__DIR__ . '/../../data/Reader/HTML/csv_with_angle_bracket.csv',
|
||||
',',
|
||||
'B1',
|
||||
'Number of items with weight <= 50kg',
|
||||
],
|
||||
[
|
||||
__DIR__ . '/../../../samples/Reader/sampleData/example1.csv',
|
||||
',',
|
||||
'I4',
|
||||
'100%',
|
||||
],
|
||||
[
|
||||
__DIR__ . '/../../../samples/Reader/sampleData/example2.csv',
|
||||
',',
|
||||
'D8',
|
||||
-58.373161,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCanLoad
|
||||
*
|
||||
* @param bool $expected
|
||||
* @param string $filename
|
||||
*/
|
||||
public function testCanLoad($expected, $filename)
|
||||
{
|
||||
$reader = new Csv();
|
||||
self::assertSame($expected, $reader->canRead($filename));
|
||||
}
|
||||
|
||||
public function providerCanLoad()
|
||||
{
|
||||
return [
|
||||
[false, 'data/Reader/Ods/data.ods'],
|
||||
[false, 'data/Reader/Xml/WithoutStyle.xml'],
|
||||
[true, 'data/Reader/CSV/enclosure.csv'],
|
||||
[true, 'data/Reader/CSV/semicolon_separated.csv'],
|
||||
[true, 'data/Reader/CSV/contains_html.csv'],
|
||||
[true, 'data/Reader/CSV/csv_without_extension'],
|
||||
[true, 'data/Reader/HTML/csv_with_angle_bracket.csv'],
|
||||
[true, 'data/Reader/CSV/empty.csv'],
|
||||
[true, '../samples/Reader/sampleData/example1.csv'],
|
||||
[true, '../samples/Reader/sampleData/example2.csv'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testEscapeCharacters()
|
||||
{
|
||||
$reader = (new Csv())->setEscapeCharacter('"');
|
||||
$worksheet = $reader->load(__DIR__ . '/../../data/Reader/CSV/backslash.csv')
|
||||
->getActiveSheet();
|
||||
|
||||
$expected = [
|
||||
['field 1', 'field 2\\'],
|
||||
['field 3\\', 'field 4'],
|
||||
];
|
||||
|
||||
$this->assertSame('"', $reader->getEscapeCharacter());
|
||||
$this->assertSame($expected, $worksheet->toArray());
|
||||
}
|
||||
}
|
46
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/HtmlTest.php
vendored
Normal file
46
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/HtmlTest.php
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Html;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HtmlTest extends TestCase
|
||||
{
|
||||
public function testCsvWithAngleBracket()
|
||||
{
|
||||
$filename = __DIR__ . '/../../data/Reader/HTML/csv_with_angle_bracket.csv';
|
||||
$reader = new Html();
|
||||
self::assertFalse($reader->canRead($filename));
|
||||
}
|
||||
|
||||
public function providerCanReadVerySmallFile()
|
||||
{
|
||||
$padding = str_repeat('a', 2048);
|
||||
|
||||
return [
|
||||
[true, ' <html> ' . $padding . ' </html> '],
|
||||
[true, ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>' . $padding . '</html>'],
|
||||
[true, '<html></html>'],
|
||||
[false, ''],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCanReadVerySmallFile
|
||||
*
|
||||
* @param bool $expected
|
||||
* @param string $content
|
||||
*/
|
||||
public function testCanReadVerySmallFile($expected, $content)
|
||||
{
|
||||
$filename = tempnam(sys_get_temp_dir(), 'html');
|
||||
file_put_contents($filename, $content);
|
||||
|
||||
$reader = new Html();
|
||||
$actual = $reader->canRead($filename);
|
||||
unlink($filename);
|
||||
|
||||
self::assertSame($expected, $actual);
|
||||
}
|
||||
}
|
225
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/OdsTest.php
vendored
Normal file
225
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/OdsTest.php
vendored
Normal file
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Ods;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Font;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @todo The class doesn't read the bold/italic/underline properties (rich text)
|
||||
*/
|
||||
class OdsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Spreadsheet
|
||||
*/
|
||||
private $spreadsheetOdsTest;
|
||||
|
||||
/**
|
||||
* @var Spreadsheet
|
||||
*/
|
||||
private $spreadsheetData;
|
||||
|
||||
/**
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
private function loadOdsTestFile()
|
||||
{
|
||||
if (!$this->spreadsheetOdsTest) {
|
||||
$filename = __DIR__ . '/../../../samples/templates/OOCalcTest.ods';
|
||||
|
||||
// Load into this instance
|
||||
$reader = new Ods();
|
||||
$this->spreadsheetOdsTest = $reader->loadIntoExisting($filename, new Spreadsheet());
|
||||
}
|
||||
|
||||
return $this->spreadsheetOdsTest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Spreadsheet
|
||||
*/
|
||||
protected function loadDataFile()
|
||||
{
|
||||
if (!$this->spreadsheetData) {
|
||||
$filename = __DIR__ . '/../../data/Reader/Ods/data.ods';
|
||||
|
||||
// Load into this instance
|
||||
$reader = new Ods();
|
||||
$this->spreadsheetData = $reader->loadIntoExisting($filename, new Spreadsheet());
|
||||
}
|
||||
|
||||
return $this->spreadsheetData;
|
||||
}
|
||||
|
||||
public function testReadFileProperties()
|
||||
{
|
||||
$filename = __DIR__ . '/../../data/Reader/Ods/data.ods';
|
||||
|
||||
// Load into this instance
|
||||
$reader = new Ods();
|
||||
|
||||
// Test "listWorksheetNames" method
|
||||
|
||||
self::assertEquals([
|
||||
'Sheet1',
|
||||
'Second Sheet',
|
||||
], $reader->listWorksheetNames($filename));
|
||||
}
|
||||
|
||||
public function testLoadWorksheets()
|
||||
{
|
||||
$spreadsheet = $this->loadDataFile();
|
||||
|
||||
self::assertInstanceOf('PhpOffice\PhpSpreadsheet\Spreadsheet', $spreadsheet);
|
||||
|
||||
self::assertEquals(2, $spreadsheet->getSheetCount());
|
||||
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
self::assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet\Worksheet', $firstSheet);
|
||||
|
||||
$secondSheet = $spreadsheet->getSheet(1);
|
||||
self::assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet\Worksheet', $secondSheet);
|
||||
}
|
||||
|
||||
public function testReadValueAndComments()
|
||||
{
|
||||
$spreadsheet = $this->loadOdsTestFile();
|
||||
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
self::assertEquals(29, $firstSheet->getHighestRow());
|
||||
self::assertEquals('N', $firstSheet->getHighestColumn());
|
||||
|
||||
// Simple cell value
|
||||
self::assertEquals('Test String 1', $firstSheet->getCell('A1')->getValue());
|
||||
|
||||
// Merged cell
|
||||
self::assertEquals('BOX', $firstSheet->getCell('B18')->getValue());
|
||||
|
||||
// Comments/Annotations
|
||||
self::assertEquals(
|
||||
'Test for a simple colour-formatted string',
|
||||
$firstSheet->getComment('A1')->getText()->getPlainText()
|
||||
);
|
||||
|
||||
// Data types
|
||||
self::assertEquals(DataType::TYPE_STRING, $firstSheet->getCell('A1')->getDataType());
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('B1')->getDataType()); // Int
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('B6')->getDataType()); // Float
|
||||
self::assertEquals(1.23, $firstSheet->getCell('B6')->getValue());
|
||||
self::assertEquals(0, $firstSheet->getCell('G10')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A10')->getDataType()); // Date
|
||||
self::assertEquals(22269.0, $firstSheet->getCell('A10')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A13')->getDataType()); // Time
|
||||
self::assertEquals(25569.0625, $firstSheet->getCell('A13')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A15')->getDataType()); // Date + Time
|
||||
self::assertEquals(22269.0625, $firstSheet->getCell('A15')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A11')->getDataType()); // Fraction
|
||||
|
||||
self::assertEquals(DataType::TYPE_BOOL, $firstSheet->getCell('D6')->getDataType());
|
||||
self::assertTrue($firstSheet->getCell('D6')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_FORMULA, $firstSheet->getCell('C6')->getDataType()); // Formula
|
||||
self::assertEquals('=TRUE()', $firstSheet->getCell('C6')->getValue()); // Formula
|
||||
|
||||
// Percentage, Currency
|
||||
|
||||
$spreadsheet = $this->loadDataFile();
|
||||
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A1')->getDataType()); // Percentage (10%)
|
||||
self::assertEquals(0.1, $firstSheet->getCell('A1')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A2')->getDataType()); // Percentage (10.00%)
|
||||
self::assertEquals(0.1, $firstSheet->getCell('A2')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A4')->getDataType()); // Currency (€10.00)
|
||||
self::assertEquals(10, $firstSheet->getCell('A4')->getValue());
|
||||
|
||||
self::assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A5')->getDataType()); // Currency ($20)
|
||||
self::assertEquals(20, $firstSheet->getCell('A5')->getValue());
|
||||
}
|
||||
|
||||
public function testReadColors()
|
||||
{
|
||||
$spreadsheet = $this->loadOdsTestFile();
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
// Background color
|
||||
|
||||
$style = $firstSheet->getCell('K3')->getStyle();
|
||||
|
||||
self::assertEquals('none', $style->getFill()->getFillType());
|
||||
self::assertEquals('FFFFFFFF', $style->getFill()->getStartColor()->getARGB());
|
||||
self::assertEquals('FF000000', $style->getFill()->getEndColor()->getARGB());
|
||||
}
|
||||
|
||||
public function testReadRichText()
|
||||
{
|
||||
$spreadsheet = $this->loadOdsTestFile();
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
self::assertEquals(
|
||||
"I don't know if OOCalc supports Rich Text in the same way as Excel, " .
|
||||
'And this row should be autofit height with text wrap',
|
||||
$firstSheet->getCell('A28')->getValue()
|
||||
);
|
||||
}
|
||||
|
||||
public function testReadCellsWithRepeatedSpaces()
|
||||
{
|
||||
$spreadsheet = $this->loadDataFile();
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
self::assertEquals('This has 4 spaces before and 2 after ', $firstSheet->getCell('A8')->getValue());
|
||||
self::assertEquals('This only one after ', $firstSheet->getCell('A9')->getValue());
|
||||
self::assertEquals('Test with DIFFERENT styles and multiple spaces: ', $firstSheet->getCell('A10')->getValue());
|
||||
self::assertEquals("test with new \nLines", $firstSheet->getCell('A11')->getValue());
|
||||
}
|
||||
|
||||
public function testReadHyperlinks()
|
||||
{
|
||||
$spreadsheet = $this->loadOdsTestFile();
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
$hyperlink = $firstSheet->getCell('A29');
|
||||
|
||||
self::assertEquals(DataType::TYPE_STRING, $hyperlink->getDataType());
|
||||
self::assertEquals('PhpSpreadsheet', $hyperlink->getValue());
|
||||
self::assertEquals('https://github.com/PHPOffice/phpspreadsheet', $hyperlink->getHyperlink()->getUrl());
|
||||
}
|
||||
|
||||
// Below some test for features not implemented yet
|
||||
|
||||
public function testReadBoldItalicUnderline()
|
||||
{
|
||||
$this->markTestIncomplete('Features not implemented yet');
|
||||
|
||||
$spreadsheet = $this->loadOdsTestFile();
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
// Font styles
|
||||
|
||||
$style = $firstSheet->getCell('A1')->getStyle();
|
||||
self::assertEquals('FF000000', $style->getFont()->getColor()->getARGB());
|
||||
self::assertEquals(11, $style->getFont()->getSize());
|
||||
self::assertEquals(Font::UNDERLINE_NONE, $style->getFont()->getUnderline());
|
||||
|
||||
$style = $firstSheet->getCell('E3')->getStyle();
|
||||
self::assertEquals(Font::UNDERLINE_SINGLE, $style->getFont()->getUnderline());
|
||||
|
||||
$style = $firstSheet->getCell('E1')->getStyle();
|
||||
self::assertTrue($style->getFont()->getBold());
|
||||
self::assertTrue($style->getFont()->getItalic());
|
||||
}
|
||||
}
|
19
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/XlsxTest.php
vendored
Normal file
19
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/XlsxTest.php
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class XlsxTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test load Xlsx file without cell reference.
|
||||
*/
|
||||
public function testLoadXlsxWithoutCellReference()
|
||||
{
|
||||
$filename = './data/Reader/XLSX/without_cell_reference.xlsx';
|
||||
$reader = new Xlsx();
|
||||
$reader->load($filename);
|
||||
}
|
||||
}
|
105
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/XmlTest.php
vendored
Normal file
105
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Reader/XmlTest.php
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\BaseReader;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xml;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class XmlTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerInvalidXML
|
||||
*
|
||||
* @param mixed $filename
|
||||
*/
|
||||
public function testInvalidXML($filename)
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class);
|
||||
|
||||
$reader = $this->getMockForAbstractClass(BaseReader::class);
|
||||
$expectedResult = 'FAILURE: Should throw an Exception rather than return a value';
|
||||
$result = $reader->securityScanFile($filename);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerInvalidXML()
|
||||
{
|
||||
$tests = [];
|
||||
foreach (glob(__DIR__ . '/../../data/Reader/Xml/XEETestInvalidUTF*.xml') as $file) {
|
||||
$tests[basename($file)] = [realpath($file)];
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerInvalidSimpleXML
|
||||
*
|
||||
* @param $filename
|
||||
*/
|
||||
public function testInvalidSimpleXML($filename)
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class);
|
||||
|
||||
$xmlReader = new Xml();
|
||||
$xmlReader->trySimpleXMLLoadString($filename);
|
||||
}
|
||||
|
||||
public function providerInvalidSimpleXML()
|
||||
{
|
||||
$tests = [];
|
||||
foreach (glob(__DIR__ . '/../../data/Reader/Xml/XEETestInvalidSimpleXML*.xml') as $file) {
|
||||
$tests[basename($file)] = [realpath($file)];
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerValidXML
|
||||
*
|
||||
* @param mixed $filename
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testValidXML($filename, $expectedResult)
|
||||
{
|
||||
$reader = $this->getMockForAbstractClass(BaseReader::class);
|
||||
$result = $reader->securityScanFile($filename);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerValidXML()
|
||||
{
|
||||
$tests = [];
|
||||
foreach (glob(__DIR__ . '/../../data/Reader/Xml/XEETestValid*.xml') as $file) {
|
||||
$tests[basename($file)] = [realpath($file), file_get_contents($file)];
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it can read XML Hyperlink correctly.
|
||||
*/
|
||||
public function testReadHyperlinks()
|
||||
{
|
||||
$reader = new Xml();
|
||||
$spreadsheet = $reader->load('../samples/templates/Excel2003XMLTest.xml');
|
||||
$firstSheet = $spreadsheet->getSheet(0);
|
||||
|
||||
$hyperlink = $firstSheet->getCell('L1');
|
||||
|
||||
self::assertEquals(DataType::TYPE_STRING, $hyperlink->getDataType());
|
||||
self::assertEquals('PhpSpreadsheet', $hyperlink->getValue());
|
||||
self::assertEquals('http://phpspreadsheet.readthedocs.io/', $hyperlink->getHyperlink()->getUrl());
|
||||
}
|
||||
|
||||
public function testReadWithoutStyle()
|
||||
{
|
||||
$reader = new Xml();
|
||||
$spreadsheet = $reader->load(__DIR__ . '/../../data/Reader/Xml/WithoutStyle.xml');
|
||||
self::assertSame('Test String 1', $spreadsheet->getActiveSheet()->getCell('A1')->getValue());
|
||||
}
|
||||
}
|
56
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/ReferenceHelperTest.php
vendored
Normal file
56
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/ReferenceHelperTest.php
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\ReferenceHelper;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ReferenceHelperTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function testColumnSort()
|
||||
{
|
||||
$columnBase = $columnExpectedResult = [
|
||||
'A', 'B', 'Z',
|
||||
'AA', 'AB', 'AZ',
|
||||
'BA', 'BB', 'BZ',
|
||||
'ZA', 'ZB', 'ZZ',
|
||||
'AAA', 'AAB', 'AAZ',
|
||||
'ABA', 'ABB', 'ABZ',
|
||||
'AZA', 'AZB', 'AZZ',
|
||||
'BAA', 'BAB', 'BAZ',
|
||||
'BBA', 'BBB', 'BBZ',
|
||||
'BZA', 'BZB', 'BZZ',
|
||||
];
|
||||
shuffle($columnBase);
|
||||
usort($columnBase, [ReferenceHelper::class, 'columnSort']);
|
||||
foreach ($columnBase as $key => $value) {
|
||||
self::assertEquals($columnExpectedResult[$key], $value);
|
||||
}
|
||||
}
|
||||
|
||||
public function testColumnReverseSort()
|
||||
{
|
||||
$columnBase = $columnExpectedResult = [
|
||||
'A', 'B', 'Z',
|
||||
'AA', 'AB', 'AZ',
|
||||
'BA', 'BB', 'BZ',
|
||||
'ZA', 'ZB', 'ZZ',
|
||||
'AAA', 'AAB', 'AAZ',
|
||||
'ABA', 'ABB', 'ABZ',
|
||||
'AZA', 'AZB', 'AZZ',
|
||||
'BAA', 'BAB', 'BAZ',
|
||||
'BBA', 'BBB', 'BBZ',
|
||||
'BZA', 'BZB', 'BZZ',
|
||||
];
|
||||
shuffle($columnBase);
|
||||
$columnExpectedResult = array_reverse($columnExpectedResult);
|
||||
usort($columnBase, [ReferenceHelper::class, 'columnReverseSort']);
|
||||
foreach ($columnBase as $key => $value) {
|
||||
self::assertEquals($columnExpectedResult[$key], $value);
|
||||
}
|
||||
}
|
||||
}
|
40
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/SettingsTest.php
vendored
Normal file
40
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/SettingsTest.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $prevValue;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->prevValue = libxml_disable_entity_loader();
|
||||
libxml_disable_entity_loader(false); // Enable entity loader
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
libxml_disable_entity_loader($this->prevValue);
|
||||
}
|
||||
|
||||
public function testGetXMLSettings()
|
||||
{
|
||||
$result = Settings::getLibXmlLoaderOptions();
|
||||
self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR) & $result));
|
||||
self::assertFalse(libxml_disable_entity_loader());
|
||||
}
|
||||
|
||||
public function testSetXMLSettings()
|
||||
{
|
||||
Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID);
|
||||
$result = Settings::getLibXmlLoaderOptions();
|
||||
self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID) & $result));
|
||||
self::assertFalse(libxml_disable_entity_loader());
|
||||
}
|
||||
}
|
54
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/CodePageTest.php
vendored
Normal file
54
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/CodePageTest.php
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\CodePage;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CodePageTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerCodePage
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCodePageNumberToName($expectedResult, ...$args)
|
||||
{
|
||||
$result = CodePage::numberToName(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerCodePage()
|
||||
{
|
||||
return require 'data/Shared/CodePage.php';
|
||||
}
|
||||
|
||||
public function testNumberToNameWithInvalidCodePage()
|
||||
{
|
||||
$invalidCodePage = 12345;
|
||||
|
||||
try {
|
||||
CodePage::numberToName($invalidCodePage);
|
||||
} catch (Exception $e) {
|
||||
self::assertEquals($e->getMessage(), 'Unknown codepage: 12345');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
|
||||
public function testNumberToNameWithUnsupportedCodePage()
|
||||
{
|
||||
$unsupportedCodePage = 720;
|
||||
|
||||
try {
|
||||
CodePage::numberToName($unsupportedCodePage);
|
||||
} catch (Exception $e) {
|
||||
self::assertEquals($e->getMessage(), 'Code page 720 not supported.');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->fail('An expected exception has not been raised.');
|
||||
}
|
||||
}
|
171
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/DateTest.php
vendored
Normal file
171
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/DateTest.php
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DateTest extends TestCase
|
||||
{
|
||||
public function testSetExcelCalendar()
|
||||
{
|
||||
$calendarValues = [
|
||||
Date::CALENDAR_MAC_1904,
|
||||
Date::CALENDAR_WINDOWS_1900,
|
||||
];
|
||||
|
||||
foreach ($calendarValues as $calendarValue) {
|
||||
$result = Date::setExcelCalendar($calendarValue);
|
||||
self::assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetExcelCalendarWithInvalidValue()
|
||||
{
|
||||
$unsupportedCalendar = '2012';
|
||||
$result = Date::setExcelCalendar($unsupportedCalendar);
|
||||
self::assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDateTimeExcelToTimestamp1900
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDateTimeExcelToTimestamp1900($expectedResult, ...$args)
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
|
||||
|
||||
$result = Date::excelToTimestamp(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerDateTimeExcelToTimestamp1900()
|
||||
{
|
||||
return require 'data/Shared/Date/ExcelToTimestamp1900.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDateTimeTimestampToExcel1900
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDateTimeTimestampToExcel1900($expectedResult, ...$args)
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
|
||||
|
||||
$result = Date::timestampToExcel(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-5);
|
||||
}
|
||||
|
||||
public function providerDateTimeTimestampToExcel1900()
|
||||
{
|
||||
return require 'data/Shared/Date/TimestampToExcel1900.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDateTimeDateTimeToExcel
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDateTimeDateTimeToExcel($expectedResult, ...$args)
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
|
||||
|
||||
$result = Date::dateTimeToExcel(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-5);
|
||||
}
|
||||
|
||||
public function providerDateTimeDateTimeToExcel()
|
||||
{
|
||||
return require 'data/Shared/Date/DateTimeToExcel.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDateTimeFormattedPHPToExcel1900
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args)
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
|
||||
|
||||
$result = Date::formattedPHPToExcel(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-5);
|
||||
}
|
||||
|
||||
public function providerDateTimeFormattedPHPToExcel1900()
|
||||
{
|
||||
return require 'data/Shared/Date/FormattedPHPToExcel1900.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDateTimeExcelToTimestamp1904
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDateTimeExcelToTimestamp1904($expectedResult, ...$args)
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
|
||||
|
||||
$result = Date::excelToTimestamp(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerDateTimeExcelToTimestamp1904()
|
||||
{
|
||||
return require 'data/Shared/Date/ExcelToTimestamp1904.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDateTimeTimestampToExcel1904
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDateTimeTimestampToExcel1904($expectedResult, ...$args)
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_MAC_1904);
|
||||
|
||||
$result = Date::timestampToExcel(...$args);
|
||||
self::assertEquals($expectedResult, $result, null, 1E-5);
|
||||
}
|
||||
|
||||
public function providerDateTimeTimestampToExcel1904()
|
||||
{
|
||||
return require 'data/Shared/Date/TimestampToExcel1904.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsDateTimeFormatCode
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testIsDateTimeFormatCode($expectedResult, ...$args)
|
||||
{
|
||||
$result = Date::isDateTimeFormatCode(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerIsDateTimeFormatCode()
|
||||
{
|
||||
return require 'data/Shared/Date/FormatCodes.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDateTimeExcelToTimestamp1900Timezone
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testDateTimeExcelToTimestamp1900Timezone($expectedResult, ...$args)
|
||||
{
|
||||
Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900);
|
||||
|
||||
$result = Date::excelToTimestamp(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerDateTimeExcelToTimestamp1900Timezone()
|
||||
{
|
||||
return require 'data/Shared/Date/ExcelToTimestamp1900Timezone.php';
|
||||
}
|
||||
}
|
32
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/FileTest.php
vendored
Normal file
32
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/FileTest.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\File;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FileTest extends TestCase
|
||||
{
|
||||
public function testGetUseUploadTempDirectory()
|
||||
{
|
||||
$expectedResult = false;
|
||||
|
||||
$result = File::getUseUploadTempDirectory();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetUseUploadTempDirectory()
|
||||
{
|
||||
$useUploadTempDirectoryValues = [
|
||||
true,
|
||||
false,
|
||||
];
|
||||
|
||||
foreach ($useUploadTempDirectoryValues as $useUploadTempDirectoryValue) {
|
||||
File::setUseUploadTempDirectory($useUploadTempDirectoryValue);
|
||||
|
||||
$result = File::getUseUploadTempDirectory();
|
||||
self::assertEquals($useUploadTempDirectoryValue, $result);
|
||||
}
|
||||
}
|
||||
}
|
86
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/FontTest.php
vendored
Normal file
86
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/FontTest.php
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Font;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FontTest extends TestCase
|
||||
{
|
||||
public function testGetAutoSizeMethod()
|
||||
{
|
||||
$expectedResult = Font::AUTOSIZE_METHOD_APPROX;
|
||||
|
||||
$result = Font::getAutoSizeMethod();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetAutoSizeMethod()
|
||||
{
|
||||
$autosizeMethodValues = [
|
||||
Font::AUTOSIZE_METHOD_EXACT,
|
||||
Font::AUTOSIZE_METHOD_APPROX,
|
||||
];
|
||||
|
||||
foreach ($autosizeMethodValues as $autosizeMethodValue) {
|
||||
$result = Font::setAutoSizeMethod($autosizeMethodValue);
|
||||
self::assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetAutoSizeMethodWithInvalidValue()
|
||||
{
|
||||
$unsupportedAutosizeMethod = 'guess';
|
||||
|
||||
$result = Font::setAutoSizeMethod($unsupportedAutosizeMethod);
|
||||
self::assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerFontSizeToPixels
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFontSizeToPixels($expectedResult, ...$args)
|
||||
{
|
||||
$result = Font::fontSizeToPixels(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerFontSizeToPixels()
|
||||
{
|
||||
return require 'data/Shared/FontSizeToPixels.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerInchSizeToPixels
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testInchSizeToPixels($expectedResult, ...$args)
|
||||
{
|
||||
$result = Font::inchSizeToPixels(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerInchSizeToPixels()
|
||||
{
|
||||
return require 'data/Shared/InchSizeToPixels.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCentimeterSizeToPixels
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testCentimeterSizeToPixels($expectedResult, ...$args)
|
||||
{
|
||||
$result = Font::centimeterSizeToPixels(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerCentimeterSizeToPixels()
|
||||
{
|
||||
return require 'data/Shared/CentimeterSizeToPixels.php';
|
||||
}
|
||||
}
|
25
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php
vendored
Normal file
25
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/PasswordHasherTest.php
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\PasswordHasher;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PasswordHasherTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerHashPassword
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testHashPassword($expectedResult, ...$args)
|
||||
{
|
||||
$result = PasswordHasher::hashPassword(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerHashPassword()
|
||||
{
|
||||
return require 'data/Shared/PasswordHashes.php';
|
||||
}
|
||||
}
|
100
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php
vendored
Normal file
100
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/StringHelperTest.php
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StringHelperTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Reset Currency Code
|
||||
StringHelper::setCurrencyCode(null);
|
||||
}
|
||||
|
||||
public function testGetIsIconvEnabled()
|
||||
{
|
||||
$result = StringHelper::getIsIconvEnabled();
|
||||
self::assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGetDecimalSeparator()
|
||||
{
|
||||
$localeconv = localeconv();
|
||||
|
||||
$expectedResult = (!empty($localeconv['decimal_point'])) ? $localeconv['decimal_point'] : ',';
|
||||
$result = StringHelper::getDecimalSeparator();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetDecimalSeparator()
|
||||
{
|
||||
$expectedResult = ',';
|
||||
StringHelper::setDecimalSeparator($expectedResult);
|
||||
|
||||
$result = StringHelper::getDecimalSeparator();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetThousandsSeparator()
|
||||
{
|
||||
$localeconv = localeconv();
|
||||
|
||||
$expectedResult = (!empty($localeconv['thousands_sep'])) ? $localeconv['thousands_sep'] : ',';
|
||||
$result = StringHelper::getThousandsSeparator();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetThousandsSeparator()
|
||||
{
|
||||
$expectedResult = ' ';
|
||||
StringHelper::setThousandsSeparator($expectedResult);
|
||||
|
||||
$result = StringHelper::getThousandsSeparator();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetCurrencyCode()
|
||||
{
|
||||
$localeconv = localeconv();
|
||||
$expectedResult = (!empty($localeconv['currency_symbol']) ? $localeconv['currency_symbol'] : (!empty($localeconv['int_curr_symbol']) ? $localeconv['int_curr_symbol'] : '$'));
|
||||
$result = StringHelper::getCurrencyCode();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetCurrencyCode()
|
||||
{
|
||||
$expectedResult = '£';
|
||||
StringHelper::setCurrencyCode($expectedResult);
|
||||
|
||||
$result = StringHelper::getCurrencyCode();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testControlCharacterPHP2OOXML()
|
||||
{
|
||||
$expectedResult = 'foo_x000B_bar';
|
||||
$result = StringHelper::controlCharacterPHP2OOXML('foo' . chr(11) . 'bar');
|
||||
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testControlCharacterOOXML2PHP()
|
||||
{
|
||||
$expectedResult = 'foo' . chr(11) . 'bar';
|
||||
$result = StringHelper::controlCharacterOOXML2PHP('foo_x000B_bar');
|
||||
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSYLKtoUTF8()
|
||||
{
|
||||
$expectedResult = 'foo' . chr(11) . 'bar';
|
||||
$result = StringHelper::SYLKtoUTF8("foo\x1B ;bar");
|
||||
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
}
|
32
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php
vendored
Normal file
32
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Shared/TimeZoneTest.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\TimeZone;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TimeZoneTest extends TestCase
|
||||
{
|
||||
public function testSetTimezone()
|
||||
{
|
||||
$timezoneValues = [
|
||||
'Europe/Prague',
|
||||
'Asia/Tokyo',
|
||||
'America/Indiana/Indianapolis',
|
||||
'Pacific/Honolulu',
|
||||
'Atlantic/St_Helena',
|
||||
];
|
||||
|
||||
foreach ($timezoneValues as $timezoneValue) {
|
||||
$result = TimeZone::setTimezone($timezoneValue);
|
||||
self::assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetTimezoneWithInvalidValue()
|
||||
{
|
||||
$unsupportedTimezone = 'Etc/GMT+10';
|
||||
$result = TimeZone::setTimezone($unsupportedTimezone);
|
||||
self::assertFalse($result);
|
||||
}
|
||||
}
|
73
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php
vendored
Normal file
73
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/BorderRangeTest.php
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BorderRangeTest extends TestCase
|
||||
{
|
||||
public function testBorderRangeInAction()
|
||||
{
|
||||
// testcase for the initial bug problem: setting border+color fails
|
||||
// set red borders aroundlA1:B3 square. Verify that the borders set are actually correct
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$argb = 'FFFF0000';
|
||||
$color = new Color($argb);
|
||||
|
||||
$sheet->getStyle('A1:C1')->getBorders()->getTop()->setBorderStyle(Border::BORDER_THIN)->setColor($color);
|
||||
$sheet->getStyle('A1:A3')->getBorders()->getLeft()->setBorderStyle(Border::BORDER_THIN)->setColor($color);
|
||||
$sheet->getStyle('C1:C3')->getBorders()->getRight()->setBorderStyle(Border::BORDER_THIN)->setColor($color);
|
||||
$sheet->getStyle('A3:C3')->getBorders()->getBottom()->setBorderStyle(Border::BORDER_THIN)->setColor($color);
|
||||
|
||||
// upper row
|
||||
$expectations = [
|
||||
// cell => Left/Right/Top/Bottom
|
||||
'A1' => 'LT',
|
||||
'B1' => 'T',
|
||||
'C1' => 'RT',
|
||||
'A2' => 'L',
|
||||
'B2' => '',
|
||||
'C2' => 'R',
|
||||
'A3' => 'LB',
|
||||
'B3' => 'B',
|
||||
'C3' => 'RB',
|
||||
];
|
||||
$sides = [
|
||||
'L' => 'Left',
|
||||
'R' => 'Right',
|
||||
'T' => 'Top',
|
||||
'B' => 'Bottom',
|
||||
];
|
||||
|
||||
foreach ($expectations as $cell => $borders) {
|
||||
$bs = $sheet->getStyle($cell)->getBorders();
|
||||
foreach ($sides as $sidekey => $side) {
|
||||
$assertion = "setBorderStyle on a range of cells, $cell $side";
|
||||
$func = "get$side";
|
||||
$b = $bs->$func(); // boo
|
||||
|
||||
if (strpos($borders, $sidekey) === false) {
|
||||
self::assertSame(Border::BORDER_NONE, $b->getBorderStyle(), $assertion);
|
||||
} else {
|
||||
self::assertSame(Border::BORDER_THIN, $b->getBorderStyle(), $assertion);
|
||||
self::assertSame($argb, $b->getColor()->getARGB(), $assertion);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testBorderRangeDirectly()
|
||||
{
|
||||
// testcase for the underlying problem directly
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$style = $sheet->getStyle('A1:C1')->getBorders()->getTop()->setBorderStyle(Border::BORDER_THIN);
|
||||
self::assertSame('A1:C1', $style->getSelectedCells(), 'getSelectedCells should not change after a style operation on a border range');
|
||||
}
|
||||
}
|
26
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/BorderTest.php
vendored
Normal file
26
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/BorderTest.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BorderTest extends TestCase
|
||||
{
|
||||
public function testCase()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$borders = $spreadsheet->getActiveSheet()->getStyle('A1')->getBorders();
|
||||
$allBorders = $borders->getAllBorders();
|
||||
$bottom = $borders->getBottom();
|
||||
|
||||
$actual = $bottom->getBorderStyle();
|
||||
self::assertSame(Border::BORDER_NONE, $actual, 'should default to none');
|
||||
|
||||
$allBorders->setBorderStyle(Border::BORDER_THIN);
|
||||
|
||||
$actual = $bottom->getBorderStyle();
|
||||
self::assertSame(Border::BORDER_THIN, $actual, 'should have been set via allBorders');
|
||||
}
|
||||
}
|
73
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/ColorTest.php
vendored
Normal file
73
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/ColorTest.php
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ColorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerColorGetRed
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testGetRed($expectedResult, ...$args)
|
||||
{
|
||||
$result = Color::getRed(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerColorGetRed()
|
||||
{
|
||||
return require 'data/Style/ColorGetRed.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerColorGetGreen
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testGetGreen($expectedResult, ...$args)
|
||||
{
|
||||
$result = Color::getGreen(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerColorGetGreen()
|
||||
{
|
||||
return require 'data/Style/ColorGetGreen.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerColorGetBlue
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testGetBlue($expectedResult, ...$args)
|
||||
{
|
||||
$result = Color::getBlue(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerColorGetBlue()
|
||||
{
|
||||
return require 'data/Style/ColorGetBlue.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerColorChangeBrightness
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testChangeBrightness($expectedResult, ...$args)
|
||||
{
|
||||
$result = Color::changeBrightness(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerColorChangeBrightness()
|
||||
{
|
||||
return require 'data/Style/ColorChangeBrightness.php';
|
||||
}
|
||||
}
|
48
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php
vendored
Normal file
48
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Style/NumberFormatTest.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NumberFormatTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
StringHelper::setDecimalSeparator('.');
|
||||
StringHelper::setThousandsSeparator(',');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNumberFormat
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFormatValueWithMask($expectedResult, ...$args)
|
||||
{
|
||||
$result = NumberFormat::toFormattedString(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerNumberFormat()
|
||||
{
|
||||
return require 'data/Style/NumberFormat.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerNumberFormatDates
|
||||
*
|
||||
* @param mixed $expectedResult
|
||||
*/
|
||||
public function testFormatValueWithMaskDate($expectedResult, ...$args)
|
||||
{
|
||||
$result = NumberFormat::toFormattedString(...$args);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerNumberFormatDates()
|
||||
{
|
||||
return require 'data/Style/NumberFormatDates.php';
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet\AutoFilter\Column;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RuleTest extends TestCase
|
||||
{
|
||||
private $testAutoFilterRuleObject;
|
||||
|
||||
private $mockAutoFilterColumnObject;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockAutoFilterColumnObject = $this->getMockBuilder(Column::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->testAutoFilterRuleObject = new Column\Rule(
|
||||
$this->mockAutoFilterColumnObject
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetRuleType()
|
||||
{
|
||||
$result = $this->testAutoFilterRuleObject->getRuleType();
|
||||
self::assertEquals(Column\Rule::AUTOFILTER_RULETYPE_FILTER, $result);
|
||||
}
|
||||
|
||||
public function testSetRuleType()
|
||||
{
|
||||
$expectedResult = Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP;
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterRuleObject->setRuleType($expectedResult);
|
||||
self::assertInstanceOf(Column\Rule::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterRuleObject->getRuleType();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetValue()
|
||||
{
|
||||
$expectedResult = 100;
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterRuleObject->setValue($expectedResult);
|
||||
self::assertInstanceOf(Column\Rule::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterRuleObject->getValue();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetOperator()
|
||||
{
|
||||
$result = $this->testAutoFilterRuleObject->getOperator();
|
||||
self::assertEquals(Column\Rule::AUTOFILTER_COLUMN_RULE_EQUAL, $result);
|
||||
}
|
||||
|
||||
public function testSetOperator()
|
||||
{
|
||||
$expectedResult = Column\Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN;
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterRuleObject->setOperator($expectedResult);
|
||||
self::assertInstanceOf(Column\Rule::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterRuleObject->getOperator();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetGrouping()
|
||||
{
|
||||
$expectedResult = Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH;
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterRuleObject->setGrouping($expectedResult);
|
||||
self::assertInstanceOf(Column\Rule::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterRuleObject->getGrouping();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetParent()
|
||||
{
|
||||
$result = $this->testAutoFilterRuleObject->getParent();
|
||||
self::assertInstanceOf(Column::class, $result);
|
||||
}
|
||||
|
||||
public function testSetParent()
|
||||
{
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterRuleObject->setParent($this->mockAutoFilterColumnObject);
|
||||
self::assertInstanceOf(Column\Rule::class, $result);
|
||||
}
|
||||
|
||||
public function testClone()
|
||||
{
|
||||
$result = clone $this->testAutoFilterRuleObject;
|
||||
self::assertInstanceOf(Column\Rule::class, $result);
|
||||
}
|
||||
}
|
176
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php
vendored
Normal file
176
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/ColumnTest.php
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet\AutoFilter;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ColumnTest extends TestCase
|
||||
{
|
||||
private $testInitialColumn = 'H';
|
||||
|
||||
private $testAutoFilterColumnObject;
|
||||
|
||||
private $mockAutoFilterObject;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockAutoFilterObject = $this->getMockBuilder(AutoFilter::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockAutoFilterObject->expects($this->any())
|
||||
->method('testColumnInRange')
|
||||
->will($this->returnValue(3));
|
||||
|
||||
$this->testAutoFilterColumnObject = new AutoFilter\Column($this->testInitialColumn, $this->mockAutoFilterObject);
|
||||
}
|
||||
|
||||
public function testGetColumnIndex()
|
||||
{
|
||||
$result = $this->testAutoFilterColumnObject->getColumnIndex();
|
||||
self::assertEquals($this->testInitialColumn, $result);
|
||||
}
|
||||
|
||||
public function testSetColumnIndex()
|
||||
{
|
||||
$expectedResult = 'L';
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterColumnObject->setColumnIndex($expectedResult);
|
||||
self::assertInstanceOf(AutoFilter\Column::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterColumnObject->getColumnIndex();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetParent()
|
||||
{
|
||||
$result = $this->testAutoFilterColumnObject->getParent();
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
}
|
||||
|
||||
public function testSetParent()
|
||||
{
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterColumnObject->setParent($this->mockAutoFilterObject);
|
||||
self::assertInstanceOf(AutoFilter\Column::class, $result);
|
||||
}
|
||||
|
||||
public function testGetFilterType()
|
||||
{
|
||||
$result = $this->testAutoFilterColumnObject->getFilterType();
|
||||
self::assertEquals(AutoFilter\Column::AUTOFILTER_FILTERTYPE_FILTER, $result);
|
||||
}
|
||||
|
||||
public function testSetFilterType()
|
||||
{
|
||||
$result = $this->testAutoFilterColumnObject->setFilterType(AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
|
||||
self::assertInstanceOf(AutoFilter\Column::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterColumnObject->getFilterType();
|
||||
self::assertEquals(AutoFilter\Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER, $result);
|
||||
}
|
||||
|
||||
public function testSetInvalidFilterTypeThrowsException()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$expectedResult = 'Unfiltered';
|
||||
|
||||
$this->testAutoFilterColumnObject->setFilterType($expectedResult);
|
||||
}
|
||||
|
||||
public function testGetJoin()
|
||||
{
|
||||
$result = $this->testAutoFilterColumnObject->getJoin();
|
||||
self::assertEquals(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_OR, $result);
|
||||
}
|
||||
|
||||
public function testSetJoin()
|
||||
{
|
||||
$result = $this->testAutoFilterColumnObject->setJoin(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND);
|
||||
self::assertInstanceOf(AutoFilter\Column::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterColumnObject->getJoin();
|
||||
self::assertEquals(AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND, $result);
|
||||
}
|
||||
|
||||
public function testSetInvalidJoinThrowsException()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$expectedResult = 'Neither';
|
||||
|
||||
$this->testAutoFilterColumnObject->setJoin($expectedResult);
|
||||
}
|
||||
|
||||
public function testSetAttributes()
|
||||
{
|
||||
$attributeSet = [
|
||||
'val' => 100,
|
||||
'maxVal' => 200,
|
||||
];
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterColumnObject->setAttributes($attributeSet);
|
||||
self::assertInstanceOf(AutoFilter\Column::class, $result);
|
||||
}
|
||||
|
||||
public function testGetAttributes()
|
||||
{
|
||||
$attributeSet = [
|
||||
'val' => 100,
|
||||
'maxVal' => 200,
|
||||
];
|
||||
|
||||
$this->testAutoFilterColumnObject->setAttributes($attributeSet);
|
||||
|
||||
$result = $this->testAutoFilterColumnObject->getAttributes();
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertCount(count($attributeSet), $result);
|
||||
}
|
||||
|
||||
public function testSetAttribute()
|
||||
{
|
||||
$attributeSet = [
|
||||
'val' => 100,
|
||||
'maxVal' => 200,
|
||||
];
|
||||
|
||||
foreach ($attributeSet as $attributeName => $attributeValue) {
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterColumnObject->setAttribute($attributeName, $attributeValue);
|
||||
self::assertInstanceOf(AutoFilter\Column::class, $result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetAttribute()
|
||||
{
|
||||
$attributeSet = [
|
||||
'val' => 100,
|
||||
'maxVal' => 200,
|
||||
];
|
||||
|
||||
$this->testAutoFilterColumnObject->setAttributes($attributeSet);
|
||||
|
||||
foreach ($attributeSet as $attributeName => $attributeValue) {
|
||||
$result = $this->testAutoFilterColumnObject->getAttribute($attributeName);
|
||||
self::assertEquals($attributeValue, $result);
|
||||
}
|
||||
$result = $this->testAutoFilterColumnObject->getAttribute('nonExistentAttribute');
|
||||
self::assertNull($result);
|
||||
}
|
||||
|
||||
public function testClone()
|
||||
{
|
||||
$originalRule = $this->testAutoFilterColumnObject->createRule();
|
||||
$result = clone $this->testAutoFilterColumnObject;
|
||||
self::assertInstanceOf(AutoFilter\Column::class, $result);
|
||||
self::assertCount(1, $result->getRules());
|
||||
self::assertContainsOnlyInstancesOf(AutoFilter\Column\Rule::class, $result->getRules());
|
||||
$clonedRule = $result->getRules()[0];
|
||||
self::assertNotSame($originalRule, $clonedRule);
|
||||
self::assertSame($result, $clonedRule->getParent());
|
||||
}
|
||||
}
|
336
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php
vendored
Normal file
336
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php
vendored
Normal file
@ -0,0 +1,336 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Collection\Cells;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AutoFilterTest extends TestCase
|
||||
{
|
||||
private $testInitialRange = 'H2:O256';
|
||||
|
||||
/**
|
||||
* @var AutoFilter
|
||||
*/
|
||||
private $testAutoFilterObject;
|
||||
|
||||
private $mockWorksheetObject;
|
||||
|
||||
private $cellCollection;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockWorksheetObject = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->cellCollection = $this->getMockBuilder(Cells::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->mockWorksheetObject->expects($this->any())
|
||||
->method('getCellCollection')
|
||||
->will($this->returnValue($this->cellCollection));
|
||||
|
||||
$this->testAutoFilterObject = new AutoFilter($this->testInitialRange, $this->mockWorksheetObject);
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$expectedResult = $this->testInitialRange;
|
||||
|
||||
// magic __toString should return the active autofilter range
|
||||
$result = $this->testAutoFilterObject;
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetParent()
|
||||
{
|
||||
$result = $this->testAutoFilterObject->getParent();
|
||||
self::assertInstanceOf(Worksheet::class, $result);
|
||||
}
|
||||
|
||||
public function testSetParent()
|
||||
{
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterObject->setParent($this->mockWorksheetObject);
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
}
|
||||
|
||||
public function testGetRange()
|
||||
{
|
||||
$expectedResult = $this->testInitialRange;
|
||||
|
||||
// Result should be the active autofilter range
|
||||
$result = $this->testAutoFilterObject->getRange();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetRange()
|
||||
{
|
||||
$ranges = [
|
||||
'G1:J512' => 'Worksheet1!G1:J512',
|
||||
'K1:N20' => 'K1:N20',
|
||||
];
|
||||
|
||||
foreach ($ranges as $actualRange => $fullRange) {
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterObject->setRange($fullRange);
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
|
||||
// Result should be the new autofilter range
|
||||
$result = $this->testAutoFilterObject->getRange();
|
||||
self::assertEquals($actualRange, $result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testClearRange()
|
||||
{
|
||||
$expectedResult = '';
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterObject->setRange('');
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
|
||||
// Result should be a clear range
|
||||
$result = $this->testAutoFilterObject->getRange();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testSetRangeInvalidRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$expectedResult = 'A1';
|
||||
|
||||
$this->testAutoFilterObject->setRange($expectedResult);
|
||||
}
|
||||
|
||||
public function testGetColumnsEmpty()
|
||||
{
|
||||
// There should be no columns yet defined
|
||||
$result = $this->testAutoFilterObject->getColumns();
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertCount(0, $result);
|
||||
}
|
||||
|
||||
public function testGetColumnOffset()
|
||||
{
|
||||
$columnIndexes = [
|
||||
'H' => 0,
|
||||
'K' => 3,
|
||||
'M' => 5,
|
||||
];
|
||||
|
||||
// If we request a specific column by its column ID, we should get an
|
||||
// integer returned representing the column offset within the range
|
||||
foreach ($columnIndexes as $columnIndex => $columnOffset) {
|
||||
$result = $this->testAutoFilterObject->getColumnOffset($columnIndex);
|
||||
self::assertEquals($columnOffset, $result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetInvalidColumnOffset()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$invalidColumn = 'G';
|
||||
|
||||
$this->testAutoFilterObject->getColumnOffset($invalidColumn);
|
||||
}
|
||||
|
||||
public function testSetColumnWithString()
|
||||
{
|
||||
$expectedResult = 'L';
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterObject->setColumn($expectedResult);
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterObject->getColumns();
|
||||
// Result should be an array of \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\AutoFilter\Column
|
||||
// objects for each column we set indexed by the column ID
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertCount(1, $result);
|
||||
self::assertArrayHasKey($expectedResult, $result);
|
||||
self::assertInstanceOf(Column::class, $result[$expectedResult]);
|
||||
}
|
||||
|
||||
public function testSetInvalidColumnWithString()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$invalidColumn = 'A';
|
||||
|
||||
$this->testAutoFilterObject->setColumn($invalidColumn);
|
||||
}
|
||||
|
||||
public function testSetColumnWithColumnObject()
|
||||
{
|
||||
$expectedResult = 'M';
|
||||
$columnObject = new AutoFilter\Column($expectedResult);
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterObject->setColumn($columnObject);
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
|
||||
$result = $this->testAutoFilterObject->getColumns();
|
||||
// Result should be an array of \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\AutoFilter\Column
|
||||
// objects for each column we set indexed by the column ID
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertCount(1, $result);
|
||||
self::assertArrayHasKey($expectedResult, $result);
|
||||
self::assertInstanceOf(Column::class, $result[$expectedResult]);
|
||||
}
|
||||
|
||||
public function testSetInvalidColumnWithObject()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$invalidColumn = 'E';
|
||||
$this->testAutoFilterObject->setColumn($invalidColumn);
|
||||
}
|
||||
|
||||
public function testSetColumnWithInvalidDataType()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$invalidColumn = 123.456;
|
||||
$this->testAutoFilterObject->setColumn($invalidColumn);
|
||||
}
|
||||
|
||||
public function testGetColumns()
|
||||
{
|
||||
$columnIndexes = ['L', 'M'];
|
||||
|
||||
foreach ($columnIndexes as $columnIndex) {
|
||||
$this->testAutoFilterObject->setColumn($columnIndex);
|
||||
}
|
||||
|
||||
$result = $this->testAutoFilterObject->getColumns();
|
||||
// Result should be an array of \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\AutoFilter\Column
|
||||
// objects for each column we set indexed by the column ID
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertCount(count($columnIndexes), $result);
|
||||
foreach ($columnIndexes as $columnIndex) {
|
||||
self::assertArrayHasKey($columnIndex, $result);
|
||||
self::assertInstanceOf(Column::class, $result[$columnIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetColumn()
|
||||
{
|
||||
$columnIndexes = ['L', 'M'];
|
||||
|
||||
foreach ($columnIndexes as $columnIndex) {
|
||||
$this->testAutoFilterObject->setColumn($columnIndex);
|
||||
}
|
||||
|
||||
// If we request a specific column by its column ID, we should
|
||||
// get a \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\AutoFilter\Column object returned
|
||||
foreach ($columnIndexes as $columnIndex) {
|
||||
$result = $this->testAutoFilterObject->getColumn($columnIndex);
|
||||
self::assertInstanceOf(Column::class, $result);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetColumnByOffset()
|
||||
{
|
||||
$columnIndexes = [
|
||||
0 => 'H',
|
||||
3 => 'K',
|
||||
5 => 'M',
|
||||
];
|
||||
|
||||
// If we request a specific column by its offset, we should
|
||||
// get a \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\AutoFilter\Column object returned
|
||||
foreach ($columnIndexes as $columnIndex => $columnID) {
|
||||
$result = $this->testAutoFilterObject->getColumnByOffset($columnIndex);
|
||||
self::assertInstanceOf(Column::class, $result);
|
||||
self::assertEquals($result->getColumnIndex(), $columnID);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetColumnIfNotSet()
|
||||
{
|
||||
// If we request a specific column by its column ID, we should
|
||||
// get a \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\AutoFilter\Column object returned
|
||||
$result = $this->testAutoFilterObject->getColumn('K');
|
||||
self::assertInstanceOf(Column::class, $result);
|
||||
}
|
||||
|
||||
public function testGetColumnWithoutRangeSet()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
// Clear the range
|
||||
$this->testAutoFilterObject->setRange('');
|
||||
$this->testAutoFilterObject->getColumn('A');
|
||||
}
|
||||
|
||||
public function testClearRangeWithExistingColumns()
|
||||
{
|
||||
$expectedResult = '';
|
||||
|
||||
$columnIndexes = ['L', 'M', 'N'];
|
||||
foreach ($columnIndexes as $columnIndex) {
|
||||
$this->testAutoFilterObject->setColumn($columnIndex);
|
||||
}
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterObject->setRange('');
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
|
||||
// Range should be cleared
|
||||
$result = $this->testAutoFilterObject->getRange();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
|
||||
// Column array should be cleared
|
||||
$result = $this->testAutoFilterObject->getColumns();
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertCount(0, $result);
|
||||
}
|
||||
|
||||
public function testSetRangeWithExistingColumns()
|
||||
{
|
||||
$expectedResult = 'G1:J512';
|
||||
|
||||
// These columns should be retained
|
||||
$columnIndexes1 = ['I', 'J'];
|
||||
foreach ($columnIndexes1 as $columnIndex) {
|
||||
$this->testAutoFilterObject->setColumn($columnIndex);
|
||||
}
|
||||
// These columns should be discarded
|
||||
$columnIndexes2 = ['K', 'L', 'M'];
|
||||
foreach ($columnIndexes2 as $columnIndex) {
|
||||
$this->testAutoFilterObject->setColumn($columnIndex);
|
||||
}
|
||||
|
||||
// Setters return the instance to implement the fluent interface
|
||||
$result = $this->testAutoFilterObject->setRange($expectedResult);
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
|
||||
// Range should be correctly set
|
||||
$result = $this->testAutoFilterObject->getRange();
|
||||
self::assertEquals($expectedResult, $result);
|
||||
|
||||
// Only columns that existed in the original range and that
|
||||
// still fall within the new range should be retained
|
||||
$result = $this->testAutoFilterObject->getColumns();
|
||||
self::assertInternalType('array', $result);
|
||||
self::assertCount(count($columnIndexes1), $result);
|
||||
}
|
||||
|
||||
public function testClone()
|
||||
{
|
||||
$columnIndexes = ['L', 'M'];
|
||||
|
||||
foreach ($columnIndexes as $columnIndex) {
|
||||
$this->testAutoFilterObject->setColumn($columnIndex);
|
||||
}
|
||||
|
||||
$result = clone $this->testAutoFilterObject;
|
||||
self::assertInstanceOf(AutoFilter::class, $result);
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnCellIterator;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ColumnCellIteratorTest extends TestCase
|
||||
{
|
||||
public $mockWorksheet;
|
||||
|
||||
public $mockCell;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockCell = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getHighestRow')
|
||||
->will($this->returnValue(5));
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getCellByColumnAndRow')
|
||||
->will($this->returnValue($this->mockCell));
|
||||
}
|
||||
|
||||
public function testIteratorFullRange()
|
||||
{
|
||||
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A');
|
||||
$ColumnCellIndexResult = 1;
|
||||
self::assertEquals($ColumnCellIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $ColumnCell) {
|
||||
self::assertEquals($ColumnCellIndexResult++, $key);
|
||||
self::assertInstanceOf(Cell::class, $ColumnCell);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorStartEndRange()
|
||||
{
|
||||
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
|
||||
$ColumnCellIndexResult = 2;
|
||||
self::assertEquals($ColumnCellIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $ColumnCell) {
|
||||
self::assertEquals($ColumnCellIndexResult++, $key);
|
||||
self::assertInstanceOf(Cell::class, $ColumnCell);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorSeekAndPrev()
|
||||
{
|
||||
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
|
||||
$columnIndexResult = 4;
|
||||
$iterator->seek(4);
|
||||
self::assertEquals($columnIndexResult, $iterator->key());
|
||||
|
||||
for ($i = 1; $i < $columnIndexResult - 1; ++$i) {
|
||||
$iterator->prev();
|
||||
self::assertEquals($columnIndexResult - $i, $iterator->key());
|
||||
}
|
||||
}
|
||||
|
||||
public function testSeekOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
|
||||
$iterator->seek(1);
|
||||
}
|
||||
|
||||
public function testPrevOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new ColumnCellIterator($this->mockWorksheet, 'A', 2, 4);
|
||||
$iterator->prev();
|
||||
}
|
||||
}
|
85
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php
vendored
Normal file
85
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/ColumnIteratorTest.php
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Column;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnIterator;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ColumnIteratorTest extends TestCase
|
||||
{
|
||||
public $mockWorksheet;
|
||||
|
||||
public $mockColumn;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockColumn = $this->getMockBuilder(Column::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getHighestColumn')
|
||||
->will($this->returnValue('E'));
|
||||
}
|
||||
|
||||
public function testIteratorFullRange()
|
||||
{
|
||||
$iterator = new ColumnIterator($this->mockWorksheet);
|
||||
$columnIndexResult = 'A';
|
||||
self::assertEquals($columnIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $column) {
|
||||
self::assertEquals($columnIndexResult++, $key);
|
||||
self::assertInstanceOf(Column::class, $column);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorStartEndRange()
|
||||
{
|
||||
$iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D');
|
||||
$columnIndexResult = 'B';
|
||||
self::assertEquals($columnIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $column) {
|
||||
self::assertEquals($columnIndexResult++, $key);
|
||||
self::assertInstanceOf(Column::class, $column);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorSeekAndPrev()
|
||||
{
|
||||
$ranges = range('A', 'E');
|
||||
$iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D');
|
||||
$columnIndexResult = 'D';
|
||||
$iterator->seek('D');
|
||||
self::assertEquals($columnIndexResult, $iterator->key());
|
||||
|
||||
for ($i = 1; $i < array_search($columnIndexResult, $ranges); ++$i) {
|
||||
$iterator->prev();
|
||||
$expectedResult = $ranges[array_search($columnIndexResult, $ranges) - $i];
|
||||
self::assertEquals($expectedResult, $iterator->key());
|
||||
}
|
||||
}
|
||||
|
||||
public function testSeekOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D');
|
||||
$iterator->seek('A');
|
||||
}
|
||||
|
||||
public function testPrevOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new ColumnIterator($this->mockWorksheet, 'B', 'D');
|
||||
$iterator->prev();
|
||||
}
|
||||
}
|
48
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php
vendored
Normal file
48
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/ColumnTest.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Column;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnCellIterator;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ColumnTest extends TestCase
|
||||
{
|
||||
public $mockWorksheet;
|
||||
|
||||
public $mockColumn;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockWorksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getHighestRow')
|
||||
->will($this->returnValue(5));
|
||||
}
|
||||
|
||||
public function testInstantiateColumnDefault()
|
||||
{
|
||||
$column = new Column($this->mockWorksheet);
|
||||
self::assertInstanceOf(Column::class, $column);
|
||||
$columnIndex = $column->getColumnIndex();
|
||||
self::assertEquals('A', $columnIndex);
|
||||
}
|
||||
|
||||
public function testInstantiateColumnSpecified()
|
||||
{
|
||||
$column = new Column($this->mockWorksheet, 'E');
|
||||
self::assertInstanceOf(Column::class, $column);
|
||||
$columnIndex = $column->getColumnIndex();
|
||||
self::assertEquals('E', $columnIndex);
|
||||
}
|
||||
|
||||
public function testGetCellIterator()
|
||||
{
|
||||
$column = new Column($this->mockWorksheet);
|
||||
$cellIterator = $column->getCellIterator();
|
||||
self::assertInstanceOf(ColumnCellIterator::class, $cellIterator);
|
||||
}
|
||||
}
|
40
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
vendored
Normal file
40
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DrawingTest extends TestCase
|
||||
{
|
||||
public function testCloningWorksheetWithImages()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$aSheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$gdImage = @imagecreatetruecolor(120, 20);
|
||||
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
|
||||
imagestring($gdImage, 1, 5, 5, 'Created with PhpSpreadsheet', $textColor);
|
||||
|
||||
$drawing = new MemoryDrawing();
|
||||
$drawing->setName('In-Memory image 1');
|
||||
$drawing->setDescription('In-Memory image 1');
|
||||
$drawing->setCoordinates('A1');
|
||||
$drawing->setImageResource($gdImage);
|
||||
$drawing->setRenderingFunction(
|
||||
MemoryDrawing::RENDERING_JPEG
|
||||
);
|
||||
$drawing->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT);
|
||||
$drawing->setHeight(36);
|
||||
$drawing->setWorksheet($aSheet);
|
||||
|
||||
$originDrawingCount = count($aSheet->getDrawingCollection());
|
||||
$clonedWorksheet = clone $aSheet;
|
||||
$clonedDrawingCount = count($clonedWorksheet->getDrawingCollection());
|
||||
|
||||
self::assertEquals($originDrawingCount, $clonedDrawingCount);
|
||||
self::assertNotSame($aSheet, $clonedWorksheet);
|
||||
self::assertNotSame($aSheet->getDrawingCollection(), $clonedWorksheet->getDrawingCollection());
|
||||
}
|
||||
}
|
88
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php
vendored
Normal file
88
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/RowCellIteratorTest.php
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\RowCellIterator;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RowCellIteratorTest extends TestCase
|
||||
{
|
||||
public $mockWorksheet;
|
||||
|
||||
public $mockCell;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockCell = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getHighestColumn')
|
||||
->will($this->returnValue('E'));
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getCellByColumnAndRow')
|
||||
->will($this->returnValue($this->mockCell));
|
||||
}
|
||||
|
||||
public function testIteratorFullRange()
|
||||
{
|
||||
$iterator = new RowCellIterator($this->mockWorksheet);
|
||||
$RowCellIndexResult = 'A';
|
||||
self::assertEquals($RowCellIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $RowCell) {
|
||||
self::assertEquals($RowCellIndexResult++, $key);
|
||||
self::assertInstanceOf(Cell::class, $RowCell);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorStartEndRange()
|
||||
{
|
||||
$iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
|
||||
$RowCellIndexResult = 'B';
|
||||
self::assertEquals($RowCellIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $RowCell) {
|
||||
self::assertEquals($RowCellIndexResult++, $key);
|
||||
self::assertInstanceOf(Cell::class, $RowCell);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorSeekAndPrev()
|
||||
{
|
||||
$ranges = range('A', 'E');
|
||||
$iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
|
||||
$RowCellIndexResult = 'D';
|
||||
$iterator->seek('D');
|
||||
self::assertEquals($RowCellIndexResult, $iterator->key());
|
||||
|
||||
for ($i = 1; $i < array_search($RowCellIndexResult, $ranges); ++$i) {
|
||||
$iterator->prev();
|
||||
$expectedResult = $ranges[array_search($RowCellIndexResult, $ranges) - $i];
|
||||
self::assertEquals($expectedResult, $iterator->key());
|
||||
}
|
||||
}
|
||||
|
||||
public function testSeekOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
|
||||
$iterator->seek(1);
|
||||
}
|
||||
|
||||
public function testPrevOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
|
||||
$iterator->prev();
|
||||
}
|
||||
}
|
83
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php
vendored
Normal file
83
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/RowIteratorTest.php
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Row;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\RowIterator;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RowIteratorTest extends TestCase
|
||||
{
|
||||
public $mockWorksheet;
|
||||
|
||||
public $mockRow;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockRow = $this->getMockBuilder(Row::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getHighestRow')
|
||||
->will($this->returnValue(5));
|
||||
}
|
||||
|
||||
public function testIteratorFullRange()
|
||||
{
|
||||
$iterator = new RowIterator($this->mockWorksheet);
|
||||
$rowIndexResult = 1;
|
||||
self::assertEquals($rowIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $row) {
|
||||
self::assertEquals($rowIndexResult++, $key);
|
||||
self::assertInstanceOf(Row::class, $row);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorStartEndRange()
|
||||
{
|
||||
$iterator = new RowIterator($this->mockWorksheet, 2, 4);
|
||||
$rowIndexResult = 2;
|
||||
self::assertEquals($rowIndexResult, $iterator->key());
|
||||
|
||||
foreach ($iterator as $key => $row) {
|
||||
self::assertEquals($rowIndexResult++, $key);
|
||||
self::assertInstanceOf(Row::class, $row);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIteratorSeekAndPrev()
|
||||
{
|
||||
$iterator = new RowIterator($this->mockWorksheet, 2, 4);
|
||||
$columnIndexResult = 4;
|
||||
$iterator->seek(4);
|
||||
self::assertEquals($columnIndexResult, $iterator->key());
|
||||
|
||||
for ($i = 1; $i < $columnIndexResult - 1; ++$i) {
|
||||
$iterator->prev();
|
||||
self::assertEquals($columnIndexResult - $i, $iterator->key());
|
||||
}
|
||||
}
|
||||
|
||||
public function testSeekOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new RowIterator($this->mockWorksheet, 2, 4);
|
||||
$iterator->seek(1);
|
||||
}
|
||||
|
||||
public function testPrevOutOfRange()
|
||||
{
|
||||
$this->expectException(\PhpOffice\PhpSpreadsheet\Exception::class);
|
||||
|
||||
$iterator = new RowIterator($this->mockWorksheet, 2, 4);
|
||||
$iterator->prev();
|
||||
}
|
||||
}
|
48
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/RowTest.php
vendored
Normal file
48
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/RowTest.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Row;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\RowCellIterator;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RowTest extends TestCase
|
||||
{
|
||||
public $mockWorksheet;
|
||||
|
||||
public $mockRow;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->mockWorksheet = $this->getMockBuilder(Worksheet::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->mockWorksheet->expects($this->any())
|
||||
->method('getHighestColumn')
|
||||
->will($this->returnValue('E'));
|
||||
}
|
||||
|
||||
public function testInstantiateRowDefault()
|
||||
{
|
||||
$row = new Row($this->mockWorksheet);
|
||||
self::assertInstanceOf(Row::class, $row);
|
||||
$rowIndex = $row->getRowIndex();
|
||||
self::assertEquals(1, $rowIndex);
|
||||
}
|
||||
|
||||
public function testInstantiateRowSpecified()
|
||||
{
|
||||
$row = new Row($this->mockWorksheet, 5);
|
||||
self::assertInstanceOf(Row::class, $row);
|
||||
$rowIndex = $row->getRowIndex();
|
||||
self::assertEquals(5, $rowIndex);
|
||||
}
|
||||
|
||||
public function testGetCellIterator()
|
||||
{
|
||||
$row = new Row($this->mockWorksheet);
|
||||
$cellIterator = $row->getCellIterator();
|
||||
self::assertInstanceOf(RowCellIterator::class, $cellIterator);
|
||||
}
|
||||
}
|
133
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php
vendored
Normal file
133
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Worksheet/WorksheetTest.php
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Worksheet;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class WorksheetTest extends TestCase
|
||||
{
|
||||
public function testSetTitle()
|
||||
{
|
||||
$testTitle = str_repeat('a', 31);
|
||||
|
||||
$worksheet = new Worksheet();
|
||||
$worksheet->setTitle($testTitle);
|
||||
self::assertSame($testTitle, $worksheet->getTitle());
|
||||
}
|
||||
|
||||
public function setTitleInvalidProvider()
|
||||
{
|
||||
return [
|
||||
[str_repeat('a', 32), 'Maximum 31 characters allowed in sheet title.'],
|
||||
['invalid*title', 'Invalid character found in sheet title'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* @param string $expectMessage
|
||||
* @dataProvider setTitleInvalidProvider
|
||||
*/
|
||||
public function testSetTitleInvalid($title, $expectMessage)
|
||||
{
|
||||
// First, test setting title with validation disabled -- should be successful
|
||||
$worksheet = new Worksheet();
|
||||
$worksheet->setTitle($title, true, false);
|
||||
|
||||
// Next, test again with validation enabled -- this time we should fail
|
||||
$worksheet = new Worksheet();
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage($expectMessage);
|
||||
$worksheet->setTitle($title);
|
||||
}
|
||||
|
||||
public function testSetTitleDuplicate()
|
||||
{
|
||||
// Create a Spreadsheet with three Worksheets (the first is created automatically)
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->createSheet();
|
||||
$spreadsheet->createSheet();
|
||||
|
||||
// Set unique title -- should be unchanged
|
||||
$sheet = $spreadsheet->getSheet(0);
|
||||
$sheet->setTitle('Test Title');
|
||||
self::assertSame('Test Title', $sheet->getTitle());
|
||||
|
||||
// Set duplicate title -- should have numeric suffix appended
|
||||
$sheet = $spreadsheet->getSheet(1);
|
||||
$sheet->setTitle('Test Title');
|
||||
self::assertSame('Test Title 1', $sheet->getTitle());
|
||||
|
||||
// Set duplicate title with validation disabled -- should be unchanged
|
||||
$sheet = $spreadsheet->getSheet(2);
|
||||
$sheet->setTitle('Test Title', true, false);
|
||||
self::assertSame('Test Title', $sheet->getTitle());
|
||||
}
|
||||
|
||||
public function testSetCodeName()
|
||||
{
|
||||
$testCodeName = str_repeat('a', 31);
|
||||
|
||||
$worksheet = new Worksheet();
|
||||
$worksheet->setCodeName($testCodeName);
|
||||
self::assertSame($testCodeName, $worksheet->getCodeName());
|
||||
}
|
||||
|
||||
public function setCodeNameInvalidProvider()
|
||||
{
|
||||
return [
|
||||
[str_repeat('a', 32), 'Maximum 31 characters allowed in sheet code name.'],
|
||||
['invalid*code*name', 'Invalid character found in sheet code name'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $codeName
|
||||
* @param string $expectMessage
|
||||
* @dataProvider setCodeNameInvalidProvider
|
||||
*/
|
||||
public function testSetCodeNameInvalid($codeName, $expectMessage)
|
||||
{
|
||||
// First, test setting code name with validation disabled -- should be successful
|
||||
$worksheet = new Worksheet();
|
||||
$worksheet->setCodeName($codeName, false);
|
||||
|
||||
// Next, test again with validation enabled -- this time we should fail
|
||||
$worksheet = new Worksheet();
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage($expectMessage);
|
||||
$worksheet->setCodeName($codeName);
|
||||
}
|
||||
|
||||
public function testSetCodeNameDuplicate()
|
||||
{
|
||||
// Create a Spreadsheet with three Worksheets (the first is created automatically)
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$spreadsheet->createSheet();
|
||||
$spreadsheet->createSheet();
|
||||
|
||||
// Set unique code name -- should be massaged to Snake_Case
|
||||
$sheet = $spreadsheet->getSheet(0);
|
||||
$sheet->setCodeName('Test Code Name');
|
||||
self::assertSame('Test_Code_Name', $sheet->getCodeName());
|
||||
|
||||
// Set duplicate code name -- should be massaged and have numeric suffix appended
|
||||
$sheet = $spreadsheet->getSheet(1);
|
||||
$sheet->setCodeName('Test Code Name');
|
||||
self::assertSame('Test_Code_Name_1', $sheet->getCodeName());
|
||||
|
||||
// Set duplicate code name with validation disabled -- should be unchanged, and unmassaged
|
||||
$sheet = $spreadsheet->getSheet(2);
|
||||
$sheet->setCodeName('Test Code Name', false);
|
||||
self::assertSame('Test Code Name', $sheet->getCodeName());
|
||||
}
|
||||
|
||||
public function testFreezePaneSelectedCell()
|
||||
{
|
||||
$worksheet = new Worksheet();
|
||||
$worksheet->freezePane('B2');
|
||||
self::assertSame('B2', $worksheet->getTopLeftCell());
|
||||
}
|
||||
}
|
98
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php
vendored
Normal file
98
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Ods\Content;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Font;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Ods\Content;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ContentTest extends TestCase
|
||||
{
|
||||
private $samplesPath = __DIR__ . '/../../../data/Writer/Ods';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $compatibilityMode;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->compatibilityMode = Functions::getCompatibilityMode();
|
||||
Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
Functions::setCompatibilityMode($this->compatibilityMode);
|
||||
}
|
||||
|
||||
public function testWriteEmptySpreadsheet()
|
||||
{
|
||||
$content = new Content(new Ods(new Spreadsheet()));
|
||||
$xml = $content->write();
|
||||
|
||||
self::assertXmlStringEqualsXmlFile($this->samplesPath . '/content-empty.xml', $xml);
|
||||
}
|
||||
|
||||
public function testWriteSpreadsheet()
|
||||
{
|
||||
$workbook = new Spreadsheet();
|
||||
|
||||
// Worksheet 1
|
||||
$worksheet1 = $workbook->getActiveSheet();
|
||||
$worksheet1->setCellValue('A1', 1); // Number
|
||||
$worksheet1->setCellValue('B1', 12345.6789); // Number
|
||||
$worksheet1->setCellValue('C1', '1'); // Number without cast
|
||||
$worksheet1->setCellValueExplicit('D1', '01234', DataType::TYPE_STRING); // Number casted to string
|
||||
$worksheet1->setCellValue('E1', 'Lorem ipsum'); // String
|
||||
|
||||
$worksheet1->setCellValue('A2', true); // Boolean
|
||||
$worksheet1->setCellValue('B2', false); // Boolean
|
||||
$worksheet1->setCellValueExplicit(
|
||||
'C2',
|
||||
'=IF(A3, CONCATENATE(A1, " ", A2), CONCATENATE(A2, " ", A1))',
|
||||
DataType::TYPE_FORMULA
|
||||
); // Formula
|
||||
|
||||
$worksheet1->setCellValue('D2', Date::PHPToExcel(1488635026)); // Date
|
||||
$worksheet1->getStyle('D2')
|
||||
->getNumberFormat()
|
||||
->setFormatCode(NumberFormat::FORMAT_DATE_DATETIME);
|
||||
|
||||
// Styles
|
||||
$worksheet1->getStyle('A1')->getFont()->setBold(true);
|
||||
$worksheet1->getStyle('B1')->getFont()->setItalic(true);
|
||||
$worksheet1->getStyle('C1')->getFont()->setName('Courier');
|
||||
$worksheet1->getStyle('C1')->getFont()->setSize(14);
|
||||
$worksheet1->getStyle('C1')->getFont()->setColor(new Color(Color::COLOR_BLUE));
|
||||
|
||||
$worksheet1->getStyle('C1')->getFill()->setFillType(Fill::FILL_SOLID);
|
||||
$worksheet1->getStyle('C1')->getFill()->setStartColor(new Color(Color::COLOR_RED));
|
||||
|
||||
$worksheet1->getStyle('C1')->getFont()->setUnderline(Font::UNDERLINE_SINGLE);
|
||||
$worksheet1->getStyle('C2')->getFont()->setUnderline(Font::UNDERLINE_DOUBLE);
|
||||
$worksheet1->getStyle('D2')->getFont()->setUnderline(Font::UNDERLINE_NONE);
|
||||
|
||||
// Worksheet 2
|
||||
$worksheet2 = $workbook->createSheet();
|
||||
$worksheet2->setTitle('New Worksheet');
|
||||
$worksheet2->setCellValue('A1', 2);
|
||||
|
||||
// Write
|
||||
$content = new Content(new Ods($workbook));
|
||||
$xml = $content->write();
|
||||
|
||||
self::assertXmlStringEqualsXmlFile($this->samplesPath . '/content-with-data.xml', $xml);
|
||||
}
|
||||
}
|
143
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php
vendored
Normal file
143
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Xls\Workbook;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xls\Parser;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class WorkbookTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Workbook
|
||||
*/
|
||||
private $workbook;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$strTotal = 0;
|
||||
$strUnique = 0;
|
||||
$str_table = [];
|
||||
$colors = [];
|
||||
$parser = new Parser();
|
||||
|
||||
$this->workbook = new Workbook($spreadsheet, $strTotal, $strUnique, $str_table, $colors, $parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerAddColor
|
||||
*
|
||||
* @param array $testColors
|
||||
* @param array $expectedResult
|
||||
*/
|
||||
public function testAddColor(array $testColors, array $expectedResult)
|
||||
{
|
||||
$workbookReflection = new \ReflectionClass(Workbook::class);
|
||||
$methodAddColor = $workbookReflection->getMethod('addColor');
|
||||
$propertyPalette = $workbookReflection->getProperty('palette');
|
||||
$methodAddColor->setAccessible(true);
|
||||
$propertyPalette->setAccessible(true);
|
||||
|
||||
foreach ($testColors as $testColor) {
|
||||
$methodAddColor->invoke($this->workbook, $testColor);
|
||||
}
|
||||
|
||||
$palette = $propertyPalette->getValue($this->workbook);
|
||||
|
||||
self::assertEquals($expectedResult, $palette);
|
||||
}
|
||||
|
||||
public function providerAddColor()
|
||||
{
|
||||
$this->setUp();
|
||||
|
||||
$workbookReflection = new \ReflectionClass(Workbook::class);
|
||||
$propertyPalette = $workbookReflection->getProperty('palette');
|
||||
$propertyPalette->setAccessible(true);
|
||||
|
||||
$palette = $propertyPalette->getValue($this->workbook);
|
||||
|
||||
$newColor1 = [0x00, 0x00, 0x01, 0x00];
|
||||
$newColor2 = [0x00, 0x00, 0x02, 0x00];
|
||||
$newColor3 = [0x00, 0x00, 0x03, 0x00];
|
||||
|
||||
// Add one new color
|
||||
$paletteTestOne = $palette;
|
||||
$paletteTestOne[8] = $newColor1;
|
||||
|
||||
// Add one new color + one existing color after index 8
|
||||
$paletteTestTwo = $paletteTestOne;
|
||||
|
||||
// Add one new color + one existing color before index 9
|
||||
$paletteTestThree = $paletteTestOne;
|
||||
$paletteTestThree[9] = $palette[8];
|
||||
|
||||
// Add three new color
|
||||
$paletteTestFour = $palette;
|
||||
$paletteTestFour[8] = $newColor1;
|
||||
$paletteTestFour[9] = $newColor2;
|
||||
$paletteTestFour[10] = $newColor3;
|
||||
|
||||
// Add all existing color
|
||||
$colorsAdd = array_map([$this, 'paletteToColor'], $palette);
|
||||
$paletteTestFive = $palette;
|
||||
|
||||
// Add new color after all existing color
|
||||
$colorsAddTwo = array_map([$this, 'paletteToColor'], $palette);
|
||||
$colorsAddTwo[] = $this->paletteToColor($newColor1);
|
||||
$paletteTestSix = $palette;
|
||||
|
||||
// Add one existing color
|
||||
$paletteTestSeven = $palette;
|
||||
|
||||
// Add two existing color
|
||||
$paletteTestHeight = $palette;
|
||||
|
||||
// Add last existing color and add one new color
|
||||
$keyPalette = array_keys($palette);
|
||||
$last = end($keyPalette);
|
||||
$lastColor = $this->paletteToColor($palette[$last]);
|
||||
$paletteTestNine = $palette;
|
||||
|
||||
return [
|
||||
[[$this->paletteToColor($newColor1)], $paletteTestOne],
|
||||
[[$this->paletteToColor($newColor1), $this->paletteToColor($palette[12])], $paletteTestTwo],
|
||||
[[$this->paletteToColor($newColor1), $this->paletteToColor($palette[8])], $paletteTestThree],
|
||||
[[$this->paletteToColor($newColor1), $this->paletteToColor($newColor2), $this->paletteToColor($newColor3)], $paletteTestFour],
|
||||
[$colorsAdd, $paletteTestFive],
|
||||
[$colorsAddTwo, $paletteTestSix],
|
||||
[[$this->paletteToColor($palette[8])], $paletteTestSeven],
|
||||
[[$this->paletteToColor($palette[25]), $this->paletteToColor($palette[10])], $paletteTestHeight],
|
||||
[[$lastColor, $this->paletteToColor($newColor1)], $paletteTestNine],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Change palette color to rgb string.
|
||||
*
|
||||
* @param array $palette palette color
|
||||
*
|
||||
* @return string rgb string
|
||||
*/
|
||||
private function paletteToColor($palette)
|
||||
{
|
||||
return $this->right('00' . dechex((int) ($palette[0])), 2)
|
||||
. $this->right('00' . dechex((int) ($palette[1])), 2)
|
||||
. $this->right('00' . dechex((int) ($palette[2])), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return n right character in string.
|
||||
*
|
||||
* @param string $value text to get right character
|
||||
* @param int $nbchar number of char at right of string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function right($value, $nbchar)
|
||||
{
|
||||
return mb_substr($value, mb_strlen($value) - $nbchar, $nbchar);
|
||||
}
|
||||
}
|
103
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php
vendored
Normal file
103
inc/vendor/phpoffice/phpspreadsheet/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Writer\Xlsx;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Settings;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\File;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ZipArchive;
|
||||
|
||||
class UnparsedDataTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test load and save Xlsx file with unparsed data (form elements, protected sheets, alternate contents, printer settings,..).
|
||||
*/
|
||||
public function testLoadSaveXlsxWithUnparsedData()
|
||||
{
|
||||
$sampleFilename = './data/Writer/XLSX/form_pass_print.xlsm';
|
||||
$resultFilename = tempnam(File::sysGetTempDir(), 'phpspreadsheet-test');
|
||||
Settings::setLibXmlLoaderOptions(null); // reset to default options
|
||||
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
|
||||
$excel = $reader->load($sampleFilename);
|
||||
|
||||
$excel->getSheet(1)->setCellValue('B1', '222');
|
||||
|
||||
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($excel);
|
||||
$writer->save($resultFilename);
|
||||
self::assertFileExists($resultFilename);
|
||||
|
||||
$resultZip = new ZipArchive();
|
||||
$resultZip->open($resultFilename);
|
||||
$resultContentTypesRaw = $resultZip->getFromName('[Content_Types].xml');
|
||||
$resultControlPropRaw = $resultZip->getFromName('xl/ctrlProps/ctrlProp1.xml');
|
||||
$resultDrawingRaw = $resultZip->getFromName('xl/drawings/drawing1.xml');
|
||||
$resultVmlDrawingRaw = $resultZip->getFromName('xl/drawings/vmlDrawing1.vml');
|
||||
$resultPrinterSettingsRaw = $resultZip->getFromName('xl/printerSettings/printerSettings1.bin');
|
||||
$resultVbaProjectRaw = $resultZip->getFromName('xl/vbaProject.bin');
|
||||
$resultWorkbookRaw = $resultZip->getFromName('xl/workbook.xml');
|
||||
$resultSheet1RelsRaw = $resultZip->getFromName('xl/worksheets/_rels/sheet1.xml.rels');
|
||||
$resultSheet1Raw = $resultZip->getFromName('xl/worksheets/sheet1.xml');
|
||||
$resultSheet2Raw = $resultZip->getFromName('xl/worksheets/sheet2.xml');
|
||||
if (false === $resultZip->close()) {
|
||||
throw new Exception("Could not close zip file \"{$resultFilename}\".");
|
||||
}
|
||||
unlink($resultFilename);
|
||||
|
||||
// [Content_Types].xml
|
||||
$this->assertTrue(strpos($resultContentTypesRaw, 'application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings') > 0, 'Content type for printerSettings not found!');
|
||||
$this->assertTrue(strpos($resultContentTypesRaw, 'application/vnd.ms-office.vbaProject') > 0, 'Content type for VbaProject not found!');
|
||||
$this->assertTrue(strpos($resultContentTypesRaw, 'application/vnd.ms-excel.controlproperties+xml') > 0, 'Content type for ctrlProp not found!');
|
||||
|
||||
// xl/ctrlProps/ctrlProp1.xml
|
||||
$this->assertTrue(!empty($resultControlPropRaw), 'ctrlProp not found!');
|
||||
|
||||
// xl/drawings/drawing1.xml
|
||||
$this->assertTrue(strpos($resultDrawingRaw, '<mc:AlternateContent') > 0, 'AlternateContent at drawing.xml not found!');
|
||||
|
||||
// xl/drawings/vmlDrawing1.vml
|
||||
$this->assertTrue(!empty($resultVmlDrawingRaw), 'vmlDrawing not found!');
|
||||
|
||||
// xl/printerSettings/printerSettings1.bin
|
||||
$this->assertTrue(!empty($resultPrinterSettingsRaw), 'printerSettings.bin not found!');
|
||||
|
||||
// xl/vbaProject.bin
|
||||
$this->assertTrue(!empty($resultVbaProjectRaw), 'vbaProject.bin not found!');
|
||||
|
||||
// xl/workbook.xml
|
||||
$xmlWorkbook = simplexml_load_string($resultWorkbookRaw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions());
|
||||
if (!$xmlWorkbook->workbookProtection) {
|
||||
$this->fail('workbook.xml/workbookProtection not found!');
|
||||
} else {
|
||||
$this->assertEquals($xmlWorkbook->workbookProtection['workbookPassword'], 'CBEB', 'workbook.xml/workbookProtection[workbookPassword] is wrong!');
|
||||
$this->assertEquals($xmlWorkbook->workbookProtection['lockStructure'], 'true', 'workbook.xml/workbookProtection[lockStructure] is wrong!');
|
||||
|
||||
$this->assertEquals($xmlWorkbook->sheets->sheet[0]['state'], '', 'workbook.xml/sheets/sheet[0][state] is wrong!');
|
||||
$this->assertEquals($xmlWorkbook->sheets->sheet[1]['state'], 'hidden', 'workbook.xml/sheets/sheet[1][state] is wrong!');
|
||||
}
|
||||
unset($xmlWorkbook);
|
||||
|
||||
// xl/worksheets/_rels/sheet1.xml.rels
|
||||
$this->assertTrue(strpos($resultSheet1RelsRaw, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings') > 0, 'Sheet relation with printerSettings not found!');
|
||||
$this->assertTrue(strpos($resultSheet1RelsRaw, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing') > 0, 'Sheet relation with vmlDrawing not found!');
|
||||
$this->assertTrue(strpos($resultSheet1RelsRaw, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp') > 0, 'Sheet relation with ctrlProp not found!');
|
||||
|
||||
// xl/worksheets/sheet1.xml
|
||||
$this->assertTrue(strpos($resultSheet1Raw, '<mc:AlternateContent') > 0, 'AlternateContent at sheet1.xml not found!');
|
||||
$xmlWorksheet = simplexml_load_string($resultSheet1Raw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions());
|
||||
$pageSetupAttributes = $xmlWorksheet->pageSetup->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$this->assertTrue(!empty($pageSetupAttributes['id']), 'sheet1.xml/pageSetup[r:id] not found!');
|
||||
if (!$xmlWorksheet->sheetProtection) {
|
||||
$this->fail('sheet1.xml/sheetProtection not found!');
|
||||
} else {
|
||||
$this->assertEquals($xmlWorksheet->sheetProtection['password'], 'CBEB', 'sheet1.xml/sheetProtection[password] is wrong!');
|
||||
$this->assertEquals($xmlWorksheet->sheetProtection['sheet'], 'true', 'sheet1.xml/sheetProtection[sheet] is wrong!');
|
||||
$this->assertEquals($xmlWorksheet->sheetProtection['objects'], 'true', 'sheet1.xml/sheetProtection[objects] is wrong!');
|
||||
$this->assertEquals($xmlWorksheet->sheetProtection['scenarios'], 'true', 'sheet1.xml/sheetProtection[scenarios] is wrong!');
|
||||
}
|
||||
unset($xmlWorksheet);
|
||||
|
||||
// xl/worksheets/sheet2.xml
|
||||
$this->assertTrue(!empty($resultSheet2Raw), 'sheet2.xml not found!');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user