Start changing some unit tests to use a json provider rather than the current excessively complex csv provider

This commit is contained in:
MarkBaker 2015-05-28 23:15:46 +01:00
parent 53584ec9a3
commit 93d16b886f
6 changed files with 41 additions and 64 deletions

View File

@ -1,6 +1,5 @@
<?php <?php
require_once 'testDataFileIterator.php';
require_once 'testDataFileIteratorJson.php'; require_once 'testDataFileIteratorJson.php';
class DefaultValueBinderTest extends PHPUnit_Framework_TestCase class DefaultValueBinderTest extends PHPUnit_Framework_TestCase
@ -62,8 +61,7 @@ class DefaultValueBinderTest extends PHPUnit_Framework_TestCase
*/ */
public function testDataTypeForValue() public function testDataTypeForValue()
{ {
$args = func_get_args(); list($args, $expectedResult) = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('\\PHPExcel\\Cell\\DefaultValueBinder','dataTypeForValue'), $args); $result = call_user_func_array(array('\\PHPExcel\\Cell\\DefaultValueBinder','dataTypeForValue'), $args);
$this->assertEquals($expectedResult, $result); $this->assertEquals($expectedResult, $result);
} }

View File

@ -1,7 +1,7 @@
<?php <?php
require_once 'testDataFileIterator.php'; require_once 'testDataFileIterator.php';
require_once 'testDataFileIteratorJson.php';
class ColorTest extends PHPUnit_Framework_TestCase class ColorTest extends PHPUnit_Framework_TestCase
{ {
@ -11,7 +11,7 @@ class ColorTest extends PHPUnit_Framework_TestCase
if (!defined('PHPEXCEL_ROOT')) { if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
} }
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); require_once(PHPEXCEL_ROOT . '/Bootstrap.php');
} }
/** /**
@ -21,7 +21,7 @@ class ColorTest extends PHPUnit_Framework_TestCase
{ {
$args = func_get_args(); $args = func_get_args();
$expectedResult = array_pop($args); $expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Style_Color','getRed'), $args); $result = call_user_func_array(array('\\PHPExcel\\Style\\Color','getRed'), $args);
$this->assertEquals($expectedResult, $result); $this->assertEquals($expectedResult, $result);
} }
@ -37,7 +37,7 @@ class ColorTest extends PHPUnit_Framework_TestCase
{ {
$args = func_get_args(); $args = func_get_args();
$expectedResult = array_pop($args); $expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Style_Color','getGreen'), $args); $result = call_user_func_array(array('\\PHPExcel\\Style\\Color','getGreen'), $args);
$this->assertEquals($expectedResult, $result); $this->assertEquals($expectedResult, $result);
} }
@ -53,7 +53,7 @@ class ColorTest extends PHPUnit_Framework_TestCase
{ {
$args = func_get_args(); $args = func_get_args();
$expectedResult = array_pop($args); $expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Style_Color','getBlue'), $args); $result = call_user_func_array(array('\\PHPExcel\\Style\\Color','getBlue'), $args);
$this->assertEquals($expectedResult, $result); $this->assertEquals($expectedResult, $result);
} }
@ -67,14 +67,13 @@ class ColorTest extends PHPUnit_Framework_TestCase
*/ */
public function testChangeBrightness() public function testChangeBrightness()
{ {
$args = func_get_args(); list($args, $expectedResult) = func_get_args();
$expectedResult = array_pop($args); $result = call_user_func_array(array('\\PHPExcel\\Style\\Color','changeBrightness'), $args);
$result = call_user_func_array(array('PHPExcel_Style_Color','changeBrightness'), $args);
$this->assertEquals($expectedResult, $result); $this->assertEquals($expectedResult, $result);
} }
public function providerColorChangeBrightness() public function providerColorChangeBrightness()
{ {
return new testDataFileIterator('rawTestData/Style/ColorChangeBrightness.data'); return new testDataFileIteratorJson('rawTestData/Style/ColorChangeBrightness.json');
} }
} }

View File

@ -1,19 +0,0 @@
NULL, "null"
, "null"
"#NULL!", "e"
FALSE, "b"
TRUE, "b"
"FALSE", "s"
"TRUE", "s"
"", "s"
"ABC", "s"
"123", "n"
123, "n"
0.123, "n"
"-123", "n"
"1.23E4", "n"
"-1.23E4", "n"
"1.23E-4", "n"
"000123", "s"
"=123", "f"
"#DIV/0!", "e"

View File

@ -1,19 +1,18 @@
[null,"null"] [[null],"null"]
[null,"null"] [["#NULL!"],"e"]
["#NULL!","e"] [[false],"b"]
[false,"b"] [[true],"b"]
[true,"b"] [["FALSE"],"s"]
["FALSE","s"] [["TRUE"],"s"]
["TRUE","s"] [[""],"s"]
["","s"] [["ABC"],"s"]
["ABC","s"] [["123"],"n"]
["123","n"] [[123],"n"]
[123,"n"] [[0.123],"n"]
[0.123,"n"] [["-123"],"n"]
["-123","n"] [["1.23E4"],"n"]
["1.23E4","n"] [["-1.23E4"],"n"]
["-1.23E4","n"] [["1.23E-4"],"n"]
["1.23E-4","n"] [["000123"],"s"]
["000123","s"] [["=123"],"f"]
["=123","f"] [["#DIV\/0!"],"e"]
["#DIV\/0!","e"]

View File

@ -1,14 +0,0 @@
"FFAABBCC", 0.1, "FFB2C1D1" // RGBA
"FFAABBCC", -0.1, "FF99A8B7" // RGBA
"AABBCC", 0.1, "B2C1D1" // RGB
"AABBCC", -0.1, "99A8B7" // RGB
"FF0000", 0.1, "FF1919"
"FF0000", -0.1, "E50000"
"FF8080", 0.1, "FF8C8C"
"FF8080", -0.1, "E57373"
"FF0000", 0.15, "FF2626"
"FF0000", -0.15, "D80000"
"FF8080", 0.15, "FF9393"
"FF8080", -0.15, "D86C6C"
"FFF008", 0.5, "FFF783"
"FFF008", -0.5, "7F7804"

View File

@ -0,0 +1,14 @@
[["FFAABBCC",0.1],"FFB2C1D1"] // RGBA
[["FFAABBCC",-0.1],"FF99A8B7"] // RGBA
[["AABBCC",0.1],"B2C1D1"] // RGB
[["AABBCC",-0.1],"99A8B7"]
[["FF0000",0.1],"FF1919"]
[["FF0000",-0.1],"E50000"]
[["FF8080",0.1],"FF8C8C"]
[["FF8080",-0.1],"E57373"]
[["FF0000",0.15],"FF2626"]
[["FF0000",-0.15],"D80000"]
[["FF8080",0.15],"FF9393"]
[["FF8080",-0.15],"D86C6C"]
[["FFF008",0.5],"FFF783"]
[["FFF008",-0.5],"7F7804"]