ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
DefaultValueBinderTest.php
Go to the documentation of this file.
1<?php
2
3require_once 'testDataFileIterator.php';
4
6{
7 protected $cellStub;
8
9 public function setUp()
10 {
11 if (!defined('PHPEXCEL_ROOT'))
12 {
13 define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
14 }
15 require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
16 }
17
18 protected function createCellStub()
19 {
20 // Create a stub for the Cell class.
21 $this->cellStub = $this->getMockBuilder('PHPExcel_Cell')
22 ->disableOriginalConstructor()
23 ->getMock();
24 // Configure the stub.
25 $this->cellStub->expects($this->any())
26 ->method('setValueExplicit')
27 ->will($this->returnValue(true));
28
29 }
30
34 public function testBindValue($value)
35 {
36 $this->createCellStub();
38 $result = $binder->bindValue($this->cellStub, $value);
39 $this->assertTrue($result);
40 }
41
42 public function binderProvider()
43 {
44 return array(
45 array(null),
46 array(''),
47 array('ABC'),
48 array('=SUM(A1:B2)'),
49 array(true),
50 array(false),
51 array(123),
52 array(-123.456),
53 array('123'),
54 array('-123.456'),
55 array('#REF!'),
56 array(new DateTime()),
57 );
58 }
59
63 public function testDataTypeForValue()
64 {
65 $args = func_get_args();
66 $expectedResult = array_pop($args);
67 $result = call_user_func_array(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $args);
68 $this->assertEquals($expectedResult, $result);
69 }
70
71 public function providerDataTypeForValue()
72 {
73 return new testDataFileIterator('rawTestData/Cell/DefaultValueBinder.data');
74 }
75
77 {
79 $objRichText->createText('Hello World');
80
82 $result = call_user_func(array('PHPExcel_Cell_DefaultValueBinder','dataTypeForValue'), $objRichText);
83 $this->assertEquals($expectedResult, $result);
84 }
85}
$objRichText
$result
An exception for terminatinating execution or to throw for unit testing.
testDataTypeForValue()
@dataProvider providerDataTypeForValue
testBindValue($value)
@dataProvider binderProvider
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27