Updates to 3rd party libraries
Add Dockerfile and specific docker-php.ini
This commit is contained in:
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user