Addtional unit tests for vlue binders
This commit is contained in:
parent
89eac0feed
commit
3297f503c2
|
|
@ -26,6 +26,7 @@ class DefaultValueBinder implements IValueBinder
|
|||
if ($value instanceof DateTimeInterface) {
|
||||
$value = $value->format('Y-m-d H:i:s');
|
||||
} elseif (!($value instanceof RichText)) {
|
||||
// Attempt to cast any unexpected objects to string
|
||||
$value = (string) $value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use PhpOffice\PhpSpreadsheet\Collection\Cells;
|
|||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AdvancedValueBinderTest extends TestCase
|
||||
|
|
@ -42,6 +43,23 @@ class AdvancedValueBinderTest extends TestCase
|
|||
StringHelper::setThousandsSeparator($this->thousandsSeparator);
|
||||
}
|
||||
|
||||
public function testNullValue()
|
||||
{
|
||||
/** @var Cell&MockObject $cellStub */
|
||||
$cellStub = $this->getMockBuilder(Cell::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
// Configure the stub.
|
||||
$cellStub->expects(self::once())
|
||||
->method('setValueExplicit')
|
||||
->with(null, DataType::TYPE_NULL)
|
||||
->willReturn(true);
|
||||
|
||||
$binder = new AdvancedValueBinder();
|
||||
$binder->bindValue($cellStub, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider currencyProvider
|
||||
*
|
||||
|
|
@ -105,6 +123,7 @@ class AdvancedValueBinderTest extends TestCase
|
|||
['€2.020,20', 2020.2, $currencyEURO, '.', ',', '€'],
|
||||
['€ 2.020,20', 2020.2, $currencyEURO, '.', ',', '€'],
|
||||
['€2,020.22', 2020.22, $currencyEURO, ',', '.', '€'],
|
||||
['$10.11', 10.11, $currencyUSD, ',', '.', '€'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,4 +77,8 @@ return [
|
|||
's',
|
||||
'123456\n',
|
||||
],
|
||||
'Numeric that exceeds PHP MAX_INT Size' => [
|
||||
's',
|
||||
'1234567890123459012345689012345690',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue