Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autoloader fixes and initial unit test structure
- Loading branch information
Mark Baker
committed
Jul 28, 2012
1 parent
a0d5f4c
commit 357b4ff
Showing
5 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
|
||
unitTests/codeCoverage | ||
*.project | ||
*.buildpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |