Permalink
Browse files

Merge pull request #10 from PHPOffice/develop

Update from develop branch
  • Loading branch information...
2 parents cc7882a + 357b4ff commit e6cdeb57ac164a5ec62645e893a2b1c87a714bda @Progi1984 Progi1984 committed Dec 13, 2013
View
@@ -1,3 +1,3 @@
-
+unitTests/codeCoverage
*.project
*.buildpath
@@ -25,24 +25,54 @@
* @version ##VERSION##, ##DATE##
*/
+PHPPowerPoint_Autoloader::Register();
+// check mbstring.func_overload
+if (ini_get('mbstring.func_overload') & 2) {
+ throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+}
+
+
+/**
+ * PHPPowerPoint_Autoloader
+ *
+ * @category PHPPowerPoint
+ * @package PHPPowerPoint
+ * @copyright Copyright (c) 2006 - 2012 PHPPowerPoint (https://github.com/Progi1984/PHPPowerPoint)
+ */
class PHPPowerPoint_Autoloader
{
+ /**
+ * Register the Autoloader with SPL
+ *
+ */
public static function Register() {
+ if (function_exists('__autoload')) {
+ // Register any existing autoloader function with SPL, so we don't get any clashes
+ spl_autoload_register('__autoload');
+ }
+ // Register ourselves with SPL
return spl_autoload_register(array('PHPPowerPoint_Autoloader', 'Load'));
} // function Register()
+ /**
+ * Autoload a class identified by name
+ *
+ * @param string $pClassName Name of the object to load
+ */
public static function Load($pObjectName){
if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPPowerPoint') === False)) {
- return false;
+ // Either already loaded, or not a PHPPowerPoint class request
+ return FALSE;
}
$pObjectFilePath = PHPPOWERPOINT_ROOT.
str_replace('_',DIRECTORY_SEPARATOR,$pObjectName).
'.php';
if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
- return false;
+ // Can't load
+ return FALSE;
}
require($pObjectFilePath);
@@ -35,6 +35,9 @@
*/
class PHPPowerPoint_Shared_Drawing
{
+
+ const DPI_96 = 96;
+
/**
* Convert pixels to EMU
*
@@ -90,7 +93,8 @@ public static function pointsToPixels($pValue = 0) {
* @return int Value in centimeters
*/
public static function pixelsToCentimeters($pValue = 0) {
- return $pValue * 0.028;
+ //return $pValue * 0.028;
+ return (($pValue / self::DPI_96) * 2.54);
}
/**
@@ -101,7 +105,7 @@ public static function pixelsToCentimeters($pValue = 0) {
*/
public static function centimetersToPixels($pValue = 0) {
if ($pValue != 0) {
- return $pValue * 0.028;
+ return ($pValue / 2.54) * self::DPI_96;
} else {
return 0;
}
View
@@ -42,6 +42,7 @@ To be planned:
- Feature: (MB) Work item 5580 - Editing chart data
- Feature: (MB) Work item 5461 - Solid Fill support
- Feature: (MB) Applied patch 8375
+- Feature: (Progi1984) Implement ODP Writer
- Bugfix: (MBaker) Allow solid colour fill
- Bugfix: (MB) Work item 3910 - Table width setting Office 2007
- Bugfix: (MB) Work item 4598 - Bullet characters in Master Slide Layouts of template file become corrupted
@@ -0,0 +1,56 @@
+<?php
+
+
+class AutoloaderTest extends PHPUnit_Framework_TestCase
+{
+
+ public function setUp()
+ {
+ if (!defined('PHPPOWERPOINT_ROOT'))
+ {
+ define('PHPPOWERPOINT_ROOT', APPLICATION_PATH . '/');
+ }
+ require_once(PHPPOWERPOINT_ROOT . 'PHPPowerPoint/Autoloader.php');
+ }
+
+ public function testAutoloaderNonPHPPowerPointClass()
+ {
+ $className = 'InvalidClass';
+
+ $result = PHPPowerPoint_Autoloader::Load($className);
+ // Must return a boolean...
+ $this->assertTrue(is_bool($result));
+ // ... indicating failure
+ $this->assertFalse($result);
+ }
+
+ public function testAutoloaderInvalidPHPPowerPointClass()
+ {
+ $className = 'PHPPowerPoint_Invalid_Class';
+
+ $result = PHPPowerPoint_Autoloader::Load($className);
+ // Must return a boolean...
+ $this->assertTrue(is_bool($result));
+ // ... indicating failure
+ $this->assertFalse($result);
+ }
+
+ public function testAutoloadValidPHPPowerPointClass()
+ {
+ $className = 'PHPPowerPoint_IOFactory';
+
+ $result = PHPPowerPoint_Autoloader::Load($className);
+ // Check that class has been loaded
+ $this->assertTrue(class_exists($className));
+ }
+
+ public function testAutoloadInstantiateSuccess()
+ {
+ $result = new PHPPowerPoint(1,2,3);
+ // Must return an object...
+ $this->assertTrue(is_object($result));
+ // ... of the correct type
+ $this->assertTrue(is_a($result,'PHPPowerPoint'));
+ }
+
+}
View
@@ -0,0 +1,44 @@
+<?php
+/**
+ * $Id: bootstrap.php 2892 2011-08-14 15:11:50Z markbaker@PHPPowerPoint.net $
+ *
+ * @copyright Copyright (C) 2011-2012 PHPPowerPoint. All rights reserved.
+ * @package PHPPowerPoint
+ * @subpackage PHPPowerPoint Unit Tests
+ * @author Mark Baker
+ */
+
+// 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'),
+ './',
+ 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 "PHPPowerPoint 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";
+}
View
@@ -0,0 +1,35 @@
+<?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="PHPPowerPoint Unit Test Suite">
+ <directory suffix="Test.php">./PHPPowerPoint</directory>
+ </testsuite>
+ <filter>
+ <whitelist>
+ <directory suffix=".php">../Classes</directory>
+ </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>

0 comments on commit e6cdeb5

Please sign in to comment.