Dateien nach "includes/PHPExcel/unitTests" hochladen
This commit is contained in:
		
							
								
								
									
										49
									
								
								includes/PHPExcel/unitTests/bootstrap.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								includes/PHPExcel/unitTests/bootstrap.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * $Id: bootstrap.php 2892 2011-08-14 15:11:50Z markbaker@phpexcel.net $
 | 
			
		||||
 *
 | 
			
		||||
 * @copyright   Copyright (C) 2011-2014 PHPExcel. All rights reserved.
 | 
			
		||||
 * @package     PHPExcel
 | 
			
		||||
 * @subpackage  PHPExcel Unit Tests
 | 
			
		||||
 * @author      Mark Baker
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
chdir(dirname(__FILE__));
 | 
			
		||||
 | 
			
		||||
setlocale(LC_ALL, 'en_US.utf8');
 | 
			
		||||
 | 
			
		||||
// PHP 5.3 Compat
 | 
			
		||||
date_default_timezone_set('Europe/London');
 | 
			
		||||
 | 
			
		||||
// Define path to application directory
 | 
			
		||||
defined('APPLICATION_PATH')
 | 
			
		||||
	|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes'));
 | 
			
		||||
 | 
			
		||||
// Define path to application tests directory
 | 
			
		||||
defined('APPLICATION_TESTS_PATH')
 | 
			
		||||
	|| define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__) ));
 | 
			
		||||
 | 
			
		||||
// Define application environment
 | 
			
		||||
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'ci');
 | 
			
		||||
 | 
			
		||||
// Ensure library/ is on include_path
 | 
			
		||||
set_include_path(implode(PATH_SEPARATOR, array(
 | 
			
		||||
	realpath(APPLICATION_PATH . '/../Classes'),
 | 
			
		||||
	'./',
 | 
			
		||||
	dirname(__FILE__),
 | 
			
		||||
	get_include_path(),
 | 
			
		||||
)));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @todo Sort out xdebug in vagrant so that this works in all sandboxes
 | 
			
		||||
 * For now, it is safer to test for it rather then remove it.
 | 
			
		||||
 */
 | 
			
		||||
echo "PHPExcel tests beginning\n";
 | 
			
		||||
 | 
			
		||||
if(extension_loaded('xdebug')) {
 | 
			
		||||
	echo "Xdebug extension loaded and running\n";
 | 
			
		||||
	xdebug_enable();
 | 
			
		||||
} else {
 | 
			
		||||
	echo 'Xdebug not found, you should run the following at the command line: echo "zend_extension=/usr/lib64/php/modules/xdebug.so" > /etc/php.d/xdebug.ini' . "\n";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								includes/PHPExcel/unitTests/phpunit-cc.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								includes/PHPExcel/unitTests/phpunit-cc.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?> 
 | 
			
		||||
<phpunit bootstrap="./bootstrap.php"
 | 
			
		||||
    backupGlobals="true"
 | 
			
		||||
    colors="true" 
 | 
			
		||||
    convertErrorsToExceptions="true" 
 | 
			
		||||
    convertNoticesToExceptions="true" 
 | 
			
		||||
    convertWarningsToExceptions="true" 
 | 
			
		||||
    processIsolation="false" 
 | 
			
		||||
    syntaxCheck="true" 
 | 
			
		||||
    verbose="true" 
 | 
			
		||||
    strict="true"
 | 
			
		||||
    stopOnError="false"
 | 
			
		||||
    stopOnFailure="false"
 | 
			
		||||
    stopOnIncomplete="false"
 | 
			
		||||
    stopOnSkipped="false">
 | 
			
		||||
    <php>
 | 
			
		||||
        <ini name="memory_limit" value="2048M"/>
 | 
			
		||||
    </php>
 | 
			
		||||
    <testsuite name="PHPExcel Unit Test Suite">
 | 
			
		||||
        <directory suffix="Test.php">./Classes</directory>
 | 
			
		||||
    </testsuite>
 | 
			
		||||
    <filter>
 | 
			
		||||
        <whitelist>
 | 
			
		||||
            <directory suffix=".php">../Classes</directory>
 | 
			
		||||
            <exclude>
 | 
			
		||||
                <directory>../Classes/PHPExcel/Shared/PCLZip</directory>
 | 
			
		||||
                <directory>../Classes/PHPExcel/Shared/JAMA</directory>
 | 
			
		||||
                <directory>../Classes/PHPExcel/Writer/PDF</directory>
 | 
			
		||||
            </exclude>
 | 
			
		||||
        </whitelist>
 | 
			
		||||
    </filter>
 | 
			
		||||
    <logging>
 | 
			
		||||
        <log type="coverage-html" target="./codeCoverage" charset="UTF-8"
 | 
			
		||||
             yui="true" highlight="false"
 | 
			
		||||
             lowUpperBound="35" highLowerBound="70"/>
 | 
			
		||||
        <log type="coverage-clover" target="./codeCoverage/codeCoverage.xml"/>
 | 
			
		||||
        <log type="metrics-xml" target="./metrics/metrics.xml"/>
 | 
			
		||||
        <log type="test-xml" target="./testResults/logfile.xml" logIncompleteSkipped="false"/>
 | 
			
		||||
    </logging>
 | 
			
		||||
</phpunit> 
 | 
			
		||||
							
								
								
									
										32
									
								
								includes/PHPExcel/unitTests/phpunit.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								includes/PHPExcel/unitTests/phpunit.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?> 
 | 
			
		||||
<phpunit bootstrap="./bootstrap.php"
 | 
			
		||||
    backupGlobals="true"
 | 
			
		||||
    colors="true" 
 | 
			
		||||
    convertErrorsToExceptions="true" 
 | 
			
		||||
    convertNoticesToExceptions="true" 
 | 
			
		||||
    convertWarningsToExceptions="true" 
 | 
			
		||||
    processIsolation="false" 
 | 
			
		||||
    syntaxCheck="true" 
 | 
			
		||||
    verbose="true" 
 | 
			
		||||
    strict="true"
 | 
			
		||||
    stopOnError="false"
 | 
			
		||||
    stopOnFailure="false"
 | 
			
		||||
    stopOnIncomplete="false"
 | 
			
		||||
    stopOnSkipped="false">
 | 
			
		||||
    <php>
 | 
			
		||||
        <ini name="memory_limit" value="2048M"/>
 | 
			
		||||
    </php>
 | 
			
		||||
    <testsuite name="PHPExcel Unit Test Suite">
 | 
			
		||||
        <directory suffix="Test.php">./Classes</directory>
 | 
			
		||||
    </testsuite>
 | 
			
		||||
    <filter>
 | 
			
		||||
        <whitelist>
 | 
			
		||||
            <directory suffix=".php">../Classes</directory>
 | 
			
		||||
            <exclude>
 | 
			
		||||
                <directory>../Classes/PHPExcel/Shared/PCLZip</directory>
 | 
			
		||||
                <directory>../Classes/PHPExcel/Shared/JAMA</directory>
 | 
			
		||||
                <directory>../Classes/PHPExcel/Writer/PDF</directory>
 | 
			
		||||
            </exclude>
 | 
			
		||||
        </whitelist>
 | 
			
		||||
    </filter>
 | 
			
		||||
</phpunit> 
 | 
			
		||||
							
								
								
									
										131
									
								
								includes/PHPExcel/unitTests/testDataFileIterator.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								includes/PHPExcel/unitTests/testDataFileIterator.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,131 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class testDataFileIterator implements Iterator
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    protected $file;
 | 
			
		||||
    protected $key = 0;
 | 
			
		||||
    protected $current;
 | 
			
		||||
 | 
			
		||||
    public function __construct($file)
 | 
			
		||||
    {
 | 
			
		||||
        $this->file = fopen($file, 'r');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function __destruct()
 | 
			
		||||
    {
 | 
			
		||||
        fclose($this->file);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function rewind()
 | 
			
		||||
    {
 | 
			
		||||
        rewind($this->file);
 | 
			
		||||
        $this->current = $this->_parseNextDataset();
 | 
			
		||||
        $this->key = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function valid()
 | 
			
		||||
    {
 | 
			
		||||
        return !feof($this->file);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function key()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->key;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function current()
 | 
			
		||||
    {
 | 
			
		||||
        return $this->current;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function next()
 | 
			
		||||
    {
 | 
			
		||||
        $this->current = $this->_parseNextDataset();
 | 
			
		||||
        $this->key++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function _parseNextDataset()
 | 
			
		||||
    {
 | 
			
		||||
        //    Read a line of test data from the file
 | 
			
		||||
        do {
 | 
			
		||||
            //    Only take lines that contain test data and that aren't commented out
 | 
			
		||||
            $testDataRow = trim(fgets($this->file));
 | 
			
		||||
        } while (($testDataRow > '') && ($testDataRow{0} === '#'));
 | 
			
		||||
 | 
			
		||||
        //    Discard any comments at the end of the line
 | 
			
		||||
        list($testData) = explode('//',$testDataRow);
 | 
			
		||||
 | 
			
		||||
        //    Split data into an array of individual values and a result
 | 
			
		||||
        $dataSet = $this->_getcsv($testData, ',', "'");
 | 
			
		||||
        foreach($dataSet as &$dataValue) {
 | 
			
		||||
            $dataValue = $this->_parseDataValue($dataValue);
 | 
			
		||||
        }
 | 
			
		||||
        unset($dataValue);
 | 
			
		||||
 | 
			
		||||
        return $dataSet;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function _getcsv($input, $delimiter, $enclosure)
 | 
			
		||||
    {
 | 
			
		||||
        if (function_exists('str_getcsv')) {
 | 
			
		||||
            return str_getcsv($input, $delimiter, $enclosure);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $temp = fopen('php://memory', 'rw');
 | 
			
		||||
        fwrite($temp, $input);
 | 
			
		||||
        rewind($temp);
 | 
			
		||||
        $data = fgetcsv($temp, strlen($input), $delimiter, $enclosure);
 | 
			
		||||
        fclose($temp);
 | 
			
		||||
 | 
			
		||||
        if ($data === false) {
 | 
			
		||||
            $data = array(null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function _parseDataValue($dataValue) {
 | 
			
		||||
        //    discard any white space
 | 
			
		||||
        $dataValue = trim($dataValue);
 | 
			
		||||
        //    test for the required datatype and convert accordingly
 | 
			
		||||
        if (!is_numeric($dataValue)) {
 | 
			
		||||
            if($dataValue == '') {
 | 
			
		||||
                $dataValue = NULL;
 | 
			
		||||
            } elseif($dataValue == '""') {
 | 
			
		||||
                $dataValue = '';
 | 
			
		||||
            } elseif(($dataValue[0] == '"') && ($dataValue[strlen($dataValue)-1] == '"')) {
 | 
			
		||||
                $dataValue = substr($dataValue,1,-1);
 | 
			
		||||
            } elseif(($dataValue[0] == '{') && ($dataValue[strlen($dataValue)-1] == '}')) {
 | 
			
		||||
                $dataValue = explode(';',substr($dataValue,1,-1));
 | 
			
		||||
                foreach($dataValue as &$dataRow) {
 | 
			
		||||
                    if (strpos($dataRow,'|') !== FALSE) {
 | 
			
		||||
                        $dataRow = explode('|',$dataRow);
 | 
			
		||||
                        foreach($dataRow as &$dataCell) {
 | 
			
		||||
                            $dataCell = $this->_parseDataValue($dataCell);
 | 
			
		||||
                        }
 | 
			
		||||
                        unset($dataCell);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        $dataRow = $this->_parseDataValue($dataRow);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                unset($dataRow);
 | 
			
		||||
            } else {
 | 
			
		||||
                switch (strtoupper($dataValue)) {
 | 
			
		||||
                    case 'NULL' :  $dataValue = NULL; break;
 | 
			
		||||
                    case 'TRUE' :  $dataValue = TRUE; break;
 | 
			
		||||
                    case 'FALSE' : $dataValue = FALSE; break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if (strpos($dataValue,'.') !== FALSE) {
 | 
			
		||||
                $dataValue = (float) $dataValue;
 | 
			
		||||
            } else {
 | 
			
		||||
                $dataValue = (int) $dataValue;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		return $dataValue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user