ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
AdvancedValueBinderTest.php
Go to the documentation of this file.
1<?php
2
4{
5 public function setUp()
6 {
7 if (!defined('PHPEXCEL_ROOT')) {
8 define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
9 }
10 require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
11 }
12
13 public function provider()
14 {
15 if (!class_exists('PHPExcel_Style_NumberFormat')) {
16 $this->setUp();
17 }
19 $currencyEURO = str_replace('$', '€', PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
20
21 return array(
22 array('10%', 0.1, PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00, ',', '.', '$'),
23 array('$10.11', 10.11, $currencyUSD, ',', '.', '$'),
24 array('$1,010.12', 1010.12, $currencyUSD, ',', '.', '$'),
25 array('$20,20', 20.2, $currencyUSD, '.', ',', '$'),
26 array('$2.020,20', 2020.2, $currencyUSD, '.', ',', '$'),
27 array('€2.020,20', 2020.2, $currencyEURO, '.', ',', '€'),
28 array('€ 2.020,20', 2020.2, $currencyEURO, '.', ',', '€'),
29 array('€2,020.22', 2020.22, $currencyEURO, ',', '.', '€'),
30 );
31 }
32
36 public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode)
37 {
38 $sheet = $this->getMock(
39 'PHPExcel_Worksheet',
40 array('getStyle', 'getNumberFormat', 'setFormatCode','getCellCacheController')
41 );
42 $cache = $this->getMockBuilder('PHPExcel_CachedObjectStorage_Memory')
43 ->disableOriginalConstructor()
44 ->getMock();
45 $cache->expects($this->any())
46 ->method('getParent')
47 ->will($this->returnValue($sheet));
48
49 $sheet->expects($this->once())
50 ->method('getStyle')
51 ->will($this->returnSelf());
52 $sheet->expects($this->once())
53 ->method('getNumberFormat')
54 ->will($this->returnSelf());
55 $sheet->expects($this->once())
56 ->method('setFormatCode')
57 ->with($format)
58 ->will($this->returnSelf());
59 $sheet->expects($this->any())
60 ->method('getCellCacheController')
61 ->will($this->returnValue($cache));
62
66
67 $cell = new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_STRING, $sheet);
68
70 $binder->bindValue($cell, $value);
71 $this->assertEquals($valueBinded, $cell->getValue());
72 }
73}
testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode)
@dataProvider provider
An exception for terminatinating execution or to throw for unit testing.
static setDecimalSeparator($pValue='.')
Set the decimal separator.
Definition: String.php:708
static setCurrencyCode($pValue='$')
Set the currency code.
Definition: String.php:772
static setThousandsSeparator($pValue=',')
Set the thousands separator.
Definition: String.php:740
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27