Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
Fixed test bootstraping
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Pennequin authored and fabpot committed Dec 12, 2010
1 parent 934ca3c commit c69e73a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion phpunit.xml → phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
bootstrap="test/bootstrap.php"
>
<testsuites>
<testsuite name="Twig Test Suite">
<testsuite name="Twig Extensions Test Suite">
<directory>./test/Twig/</directory>
</testsuite>
</testsuites>
Expand All @@ -22,4 +22,8 @@
<directory suffix=".php">./lib/Twig/</directory>
</whitelist>
</filter>

<php>
<const name="TWIG_LIBRARY_PATH" value="/path/to/library/where/Twig/located" />
</php>
</phpunit>
19 changes: 18 additions & 1 deletion test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,22 @@
* file that was distributed with this source code.
*/

require_once dirname(__FILE__).'/../lib/Twig/Autoloader.php';
if (!defined('TWIG_LIBRARY_PATH')) {
die('path to twig library must be defined in phpunit.xml configuration');
}

require_once TWIG_LIBRARY_PATH.'/Twig/Autoloader.php';
Twig_Autoloader::register();

function twigExtensionAutoload($class)
{
if (0 !== strpos($class, 'Twig_Extensions')) {
return;
}

if (file_exists($file = dirname(__FILE__).'/../lib/'.str_replace('_', '/', $class).'.php')) {
require $file;
}
}

spl_autoload_register('twigExtensionAutoload');

0 comments on commit c69e73a

Please sign in to comment.