Skip to content

Commit 056052d

Browse files
committed
Merge pull request #11 from PHPOffice/develop
Update master branch from develop
2 parents 5437378 + 271e427 commit 056052d

File tree

7 files changed

+210
-4
lines changed

7 files changed

+210
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unitTests/codeCoverage

.travis.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
language: php
2+
php:
3+
- 5.3.3
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
8+
before_script:
9+
## Composer
10+
- curl -s http://getcomposer.org/installer | php
11+
- php composer.phar install
12+
## PHP_CodeSniffer
13+
- pyrus install pear/PHP_CodeSniffer
14+
- phpenv rehash
15+
## PHP Copy/Paste Detector
16+
- curl -o phpcpd.phar https://phar.phpunit.de/phpcpd.phar
17+
## PHP Mess Detector
18+
- pear config-set preferred_state beta
19+
- printf "\n" | pecl install imagick
20+
- pear channel-discover pear.phpmd.org
21+
- pear channel-discover pear.pdepend.org
22+
- pear install --alldeps phpmd/PHP_PMD
23+
- phpenv rehash
24+
## PHPLOC
25+
- curl -o phploc.phar https://phar.phpunit.de/phploc.phar
26+
27+
script:
28+
## PHP_CodeSniffer
29+
- phpcs --standard=PSR1 Classes/
30+
- phpcs --standard=PSR2 Classes/
31+
## PHP Copy/Paste Detector
32+
- php phpcpd.phar --verbose Classes/
33+
## PHP Mess Detector
34+
- phpmd Classes/ text codesize,unusedcode,naming,design
35+
## PHPLOC
36+
- php phploc.phar Classes/
37+
38+
notifications:
39+
email:
40+
- progi1984@gmail.com

Classes/PHPVisio/IOFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static function addSearchLocation($type = '', $location = '', $classname
120120
* @static
121121
* @access public
122122
* @param PHPVisio $phpProject
123-
* @param string $writerType Example: Excel2007
123+
* @param string $writerType Example: MSVisio2007
124124
* @return PHPVisio_Writer_IWriter
125125
* @throws Exception
126126
*/
@@ -178,7 +178,7 @@ public static function createReader($readerType = '') {
178178
*
179179
* @static
180180
* @access public
181-
* @param string $pFileName The name of the spreadsheet file
181+
* @param string $pFileName The name of the visio/dia file
182182
* @return PHPVisio
183183
* @throws Exception
184184
*/
@@ -192,7 +192,7 @@ public static function load($pFilename) {
192192
*
193193
* @static
194194
* @access public
195-
* @param string $pFileName The name of the spreadsheet file to identify
195+
* @param string $pFileName The name of the visio/dia file to identify
196196
* @return string
197197
* @throws Exception
198198
*/
@@ -209,7 +209,7 @@ public static function identify($pFilename) {
209209
*
210210
* @static
211211
* @access public
212-
* @param string $pFileName The name of the spreadsheet file
212+
* @param string $pFileName The name of the visio/dia file
213213
* @return PHPVisio_Reader_IReader
214214
* @throws Exception
215215
*/

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "phpoffice/phpvisio",
3+
"description": "PHPVisio - Read, Create and Write Diagrams documents in PHP",
4+
"keywords": ["PHP","Visio", "Dia", "vsdx","vsd","diagram"],
5+
"homepage": "http://phpoffice.github.io",
6+
"type": "library",
7+
"license": "LGPL",
8+
"authors": [
9+
{
10+
"name": "Mark Baker"
11+
},
12+
{
13+
"name": "Franck Lefevre",
14+
"homepage": "http://blog.rootslabs.net"
15+
}
16+
],
17+
"require": {
18+
"php": ">=5.2.0",
19+
"ext-xml": "*"
20+
},
21+
"recommend": {
22+
"ext-zip": "*",
23+
"ext-gd2": "*"
24+
},
25+
"autoload": {
26+
"psr-0": {
27+
"PHPVisio": "Classes/"
28+
}
29+
}
30+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
4+
class AutoloaderTest extends PHPUnit_Framework_TestCase
5+
{
6+
7+
public function setUp()
8+
{
9+
if (!defined('PHPVISIO_ROOT'))
10+
{
11+
define('PHPVISIO_ROOT', APPLICATION_PATH . '/');
12+
}
13+
require_once(PHPVISIO_ROOT . 'PHPVisio/Autoloader.php');
14+
}
15+
16+
public function testAutoloaderNonPHPVisioClass()
17+
{
18+
$className = 'InvalidClass';
19+
20+
$result = PHPVisio_Autoloader::Load($className);
21+
// Must return a boolean...
22+
$this->assertTrue(is_bool($result));
23+
// ... indicating failure
24+
$this->assertFalse($result);
25+
}
26+
27+
public function testAutoloaderInvalidPHPVisioClass()
28+
{
29+
$className = 'PHPVisio_Invalid_Class';
30+
31+
$result = PHPVisio_Autoloader::Load($className);
32+
// Must return a boolean...
33+
$this->assertTrue(is_bool($result));
34+
// ... indicating failure
35+
$this->assertFalse($result);
36+
}
37+
38+
public function testAutoloadValidPHPVisioClass()
39+
{
40+
$className = 'PHPVisio_IOFactory';
41+
42+
$result = PHPVisio_Autoloader::Load($className);
43+
// Check that class has been loaded
44+
$this->assertTrue(class_exists($className));
45+
}
46+
47+
public function testAutoloadInstantiateSuccess()
48+
{
49+
$result = new PHPVisio(1,2,3);
50+
// Must return an object...
51+
$this->assertTrue(is_object($result));
52+
// ... of the correct type
53+
$this->assertTrue(is_a($result,'PHPVisio'));
54+
}
55+
56+
}

unitTests/bootstrap.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* $Id: bootstrap.php 2892 2011-08-14 15:11:50Z markbaker@PHPVisio.net $
4+
*
5+
* @copyright Copyright (C) 2011-2012 PHPVisio. All rights reserved.
6+
* @package PHPVisio
7+
* @subpackage PHPVisio Unit Tests
8+
* @author Mark Baker
9+
*/
10+
11+
// PHP 5.3 Compat
12+
date_default_timezone_set('Europe/London');
13+
14+
// Define path to application directory
15+
defined('APPLICATION_PATH')
16+
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes'));
17+
18+
// Define path to application tests directory
19+
defined('APPLICATION_TESTS_PATH')
20+
|| define('APPLICATION_TESTS_PATH', realpath(dirname(__FILE__) ));
21+
22+
// Define application environment
23+
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'ci');
24+
25+
// Ensure library/ is on include_path
26+
set_include_path(implode(PATH_SEPARATOR, array(
27+
realpath(APPLICATION_PATH . '/../Classes'),
28+
'./',
29+
get_include_path(),
30+
)));
31+
32+
33+
/**
34+
* @todo Sort out xdebug in vagrant so that this works in all sandboxes
35+
* For now, it is safer to test for it rather then remove it.
36+
*/
37+
echo "PHPVisio tests beginning\n";
38+
39+
if(extension_loaded('xdebug')) {
40+
echo "Xdebug extension loaded and running\n";
41+
xdebug_enable();
42+
} else {
43+
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";
44+
}

unitTests/phpunit.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="./bootstrap.php"
3+
backupGlobals="true"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
syntaxCheck="true"
10+
verbose="true"
11+
strict="true"
12+
stopOnError="false"
13+
stopOnFailure="false"
14+
stopOnIncomplete="false"
15+
stopOnSkipped="false">
16+
<php>
17+
<ini name="memory_limit" value="2048M"/>
18+
</php>
19+
<testsuite name="PHPVisio Unit Test Suite">
20+
<directory suffix="Test.php">./Classes</directory>
21+
</testsuite>
22+
<filter>
23+
<whitelist>
24+
<directory suffix=".php">../Classes</directory>
25+
</whitelist>
26+
</filter>
27+
<logging>
28+
<log type="coverage-html" target="./codeCoverage" charset="UTF-8"
29+
yui="true" highlight="false"
30+
lowUpperBound="35" highLowerBound="70"/>
31+
<log type="coverage-clover" target="./codeCoverage/codeCoverage.xml"/>
32+
<log type="metrics-xml" target="./metrics/metrics.xml"/>
33+
<log type="test-xml" target="./testResults/logfile.xml" logIncompleteSkipped="false"/>
34+
</logging>
35+
</phpunit>

0 commit comments

Comments
 (0)