update 1.0.8.0
Commits for version update
This commit is contained in:
73
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/AdvancedValueBinderTest.php
vendored
Normal file
73
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/AdvancedValueBinderTest.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
||||
}
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
public function provider()
|
||||
{
|
||||
if (!class_exists('PHPExcel_Style_NumberFormat')) {
|
||||
$this->setUp();
|
||||
}
|
||||
$currencyUSD = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
|
||||
$currencyEURO = str_replace('$', '€', PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
|
||||
return array(
|
||||
array('10%', 0.1, PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00, ',', '.', '$'),
|
||||
array('$10.11', 10.11, $currencyUSD, ',', '.', '$'),
|
||||
array('$1,010.12', 1010.12, $currencyUSD, ',', '.', '$'),
|
||||
array('$20,20', 20.2, $currencyUSD, '.', ',', '$'),
|
||||
array('$2.020,20', 2020.2, $currencyUSD, '.', ',', '$'),
|
||||
array('€2.020,20', 2020.2, $currencyEURO, '.', ',', '€'),
|
||||
array('€ 2.020,20', 2020.2, $currencyEURO, '.', ',', '€'),
|
||||
array('€2,020.22', 2020.22, $currencyEURO, ',', '.', '€'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode)
|
||||
{
|
||||
$sheet = $this->getMock(
|
||||
'PHPExcel_Worksheet',
|
||||
array('getStyle', 'getNumberFormat', 'setFormatCode','getCellCacheController')
|
||||
);
|
||||
$cache = $this->getMockBuilder('PHPExcel_CachedObjectStorage_Memory')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$cache->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('getCellCacheController')
|
||||
->will($this->returnValue($cache));
|
||||
|
||||
PHPExcel_Shared_String::setCurrencyCode($currencyCode);
|
||||
PHPExcel_Shared_String::setDecimalSeparator($decimalSeparator);
|
||||
PHPExcel_Shared_String::setThousandsSeparator($thousandsSeparator);
|
||||
|
||||
$cell = new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_STRING, $sheet);
|
||||
|
||||
$binder = new PHPExcel_Cell_AdvancedValueBinder();
|
||||
$binder->bindValue($cell, $value);
|
||||
$this->assertEquals($valueBinded, $cell->getValue());
|
||||
}
|
||||
}
|
24
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DataTypeTest.php
vendored
Normal file
24
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DataTypeTest.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
class DataTypeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (!defined('PHPEXCEL_ROOT'))
|
||||
{
|
||||
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
||||
}
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
public function testGetErrorCodes()
|
||||
{
|
||||
$result = call_user_func(array('PHPExcel_Cell_DataType','getErrorCodes'));
|
||||
$this->assertInternalType('array', $result);
|
||||
$this->assertGreaterThan(0, count($result));
|
||||
$this->assertArrayHasKey('#NULL!', $result);
|
||||
}
|
||||
|
||||
}
|
85
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php
vendored
Normal file
85
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/DefaultValueBinderTest.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
require_once 'testDataFileIterator.php';
|
||||
|
||||
class DefaultValueBinderTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $cellStub;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (!defined('PHPEXCEL_ROOT'))
|
||||
{
|
||||
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
||||
}
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
protected function createCellStub()
|
||||
{
|
||||
// Create a stub for the Cell class.
|
||||
$this->cellStub = $this->getMockBuilder('PHPExcel_Cell')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
// Configure the stub.
|
||||
$this->cellStub->expects($this->any())
|
||||
->method('setValueExplicit')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider binderProvider
|
||||
*/
|
||||
public function testBindValue($value)
|
||||
{
|
||||
$this->createCellStub();
|
||||
$binder = new PHPExcel_Cell_DefaultValueBinder();
|
||||
$result = $binder->bindValue($this->cellStub, $value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function binderProvider()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array(''),
|
||||
array('ABC'),
|
||||
array('=SUM(A1:B2)'),
|
||||
array(true),
|
||||
array(false),
|
||||
array(123),
|
||||
array(-123.456),
|
||||
array('123'),
|
||||
array('-123.456'),
|
||||
array('#REF!'),
|
||||
array(new DateTime()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerDataTypeForValue
|
||||
*/
|
||||
public function testDataTypeForValue()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$expectedResult = array_pop($args);
|
||||
$result = call_user_func_array(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $args);
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function providerDataTypeForValue()
|
||||
{
|
||||
return new testDataFileIterator('rawTestData/Cell/DefaultValueBinder.data');
|
||||
}
|
||||
|
||||
public function testDataTypeForRichTextObject()
|
||||
{
|
||||
$objRichText = new PHPExcel_RichText();
|
||||
$objRichText->createText('Hello World');
|
||||
|
||||
$expectedResult = PHPExcel_Cell_DataType::TYPE_INLINE;
|
||||
$result = call_user_func(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $objRichText);
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
}
|
88
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php
vendored
Normal file
88
vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Cell/HyperlinkTest.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
|
||||
class HyperlinkTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (!defined('PHPEXCEL_ROOT'))
|
||||
{
|
||||
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
||||
}
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
public function testGetUrl()
|
||||
{
|
||||
$urlValue = 'http://www.phpexcel.net';
|
||||
|
||||
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue);
|
||||
|
||||
$result = $testInstance->getUrl();
|
||||
$this->assertEquals($urlValue,$result);
|
||||
}
|
||||
|
||||
public function testSetUrl()
|
||||
{
|
||||
$initialUrlValue = 'http://www.phpexcel.net';
|
||||
$newUrlValue = 'http://github.com/PHPOffice/PHPExcel';
|
||||
|
||||
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
|
||||
$result = $testInstance->setUrl($newUrlValue);
|
||||
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
|
||||
|
||||
$result = $testInstance->getUrl();
|
||||
$this->assertEquals($newUrlValue,$result);
|
||||
}
|
||||
|
||||
public function testGetTooltip()
|
||||
{
|
||||
$tooltipValue = 'PHPExcel Web Site';
|
||||
|
||||
$testInstance = new PHPExcel_Cell_Hyperlink(NULL, $tooltipValue);
|
||||
|
||||
$result = $testInstance->getTooltip();
|
||||
$this->assertEquals($tooltipValue,$result);
|
||||
}
|
||||
|
||||
public function testSetTooltip()
|
||||
{
|
||||
$initialTooltipValue = 'PHPExcel Web Site';
|
||||
$newTooltipValue = 'PHPExcel Repository on Github';
|
||||
|
||||
$testInstance = new PHPExcel_Cell_Hyperlink(NULL, $initialTooltipValue);
|
||||
$result = $testInstance->setTooltip($newTooltipValue);
|
||||
$this->assertTrue($result instanceof PHPExcel_Cell_Hyperlink);
|
||||
|
||||
$result = $testInstance->getTooltip();
|
||||
$this->assertEquals($newTooltipValue,$result);
|
||||
}
|
||||
|
||||
public function testIsInternal()
|
||||
{
|
||||
$initialUrlValue = 'http://www.phpexcel.net';
|
||||
$newUrlValue = 'sheet://Worksheet1!A1';
|
||||
|
||||
$testInstance = new PHPExcel_Cell_Hyperlink($initialUrlValue);
|
||||
$result = $testInstance->isInternal();
|
||||
$this->assertFalse($result);
|
||||
|
||||
$testInstance->setUrl($newUrlValue);
|
||||
$result = $testInstance->isInternal();
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGetHashCode()
|
||||
{
|
||||
$urlValue = 'http://www.phpexcel.net';
|
||||
$tooltipValue = 'PHPExcel Web Site';
|
||||
$initialExpectedHash = 'd84d713aed1dbbc8a7c5af183d6c7dbb';
|
||||
|
||||
$testInstance = new PHPExcel_Cell_Hyperlink($urlValue, $tooltipValue);
|
||||
|
||||
$result = $testInstance->getHashCode();
|
||||
$this->assertEquals($initialExpectedHash,$result);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user