Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbull committed Mar 14, 2014
1 parent 308b3f9 commit 01ee252
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.DS_Store
composer.phar
composer.lock
phpunit.xml
vendor
.idea
.project
lib/fonts/*.afm.php
lib/fonts/*.ufm.php
lib/fonts/log.htm
lib/fonts/log.htm
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: php
php:
- 5.3
- 5.4
- 5.5

before_script:
## Composer
- curl -s http://getcomposer.org/installer | php
- php composer.phar install
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@
{
"name": "Brian Sweeney",
"email": "[email protected]"
},
{
"name": "Gabriel Bull",
"email": "[email protected]"
}
],
"autoload": {
"classmap": ["include/"]
"classmap": ["include/"],
"psr-0" : {
"DomPdf" : "include/"
}
},
"require": {
"php": ">=5.3.0",
"phenx/php-font-lib": "0.2.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}
}
16 changes: 16 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="test/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="DomPdf Test Suite">
<directory>./test/DomPdf/</directory>
</testsuite>
</testsuites>
</phpunit>
18 changes: 18 additions & 0 deletions test/DomPdf/Tests/AutoloaderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace DomPdf\Tests;

use PHPUnit_Framework_TestCase;
use DomPdf\Autoloader;

class AutoloaderTest extends PHPUnit_Framework_TestCase
{
public function testAutoload()
{
$declared = get_declared_classes();
$declaredCount = count($declared);
Autoloader::autoload('Foo');
$this->assertEquals($declaredCount, count(get_declared_classes()), 'DomPdf\\Autoloader::autoload() is trying to load classes outside of the DomPdf namespace');
Autoloader::autoload('DomPdf\Frame\FrameList'); // TODO change this class to the main DomPdf class when it is namespaced
$this->assertTrue(in_array('DomPdf\Frame\FrameList', get_declared_classes()), 'DomPdf\\Autoloader::autoload() failed to autoload the DomPdf\Frame\FrameList class');
}
}
12 changes: 12 additions & 0 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

define('DOMPDF_ENABLE_AUTOLOAD', false);
require_once __DIR__ . '/../dompdf_config.inc.php';

DomPdf\Autoloader::register();

if (!@include_once __DIR__ . '/../vendor/autoload.php') {
if (!@include_once __DIR__ . '/../../../autoload.php') {
trigger_error("Unable to load dependencies", E_USER_ERROR);
}
}

0 comments on commit 01ee252

Please sign in to comment.