Skip to content

Commit

Permalink
Add a simple bootstrap file to decouple the test suite from Composer.
Browse files Browse the repository at this point in the history
The test case files all depend on PSR-4 autoloading, but no autoloader
exists when the library is installed through (for example) a
distribution package manager. Fortunately the bootstrap process is
simple and this can be fixed with a single "require" statement.

This commit adds a new file, test/bootstrap.php, which loads the
Html2Text library. We then use this new file to bootstrap PHPUnit. The
end result is that the test suite now works out-of-the-box without
Composer. Running,

  $ phpunit

should succeed from an unmodified tarball.
  • Loading branch information
orlitzky committed Dec 5, 2015
1 parent 0d40933 commit 1283bff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -7,7 +7,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
bootstrap="test/bootstrap.php"
>
<testsuites>
<testsuite name="Html2Text Test Suite">
Expand Down
11 changes: 11 additions & 0 deletions test/bootstrap.php
@@ -0,0 +1,11 @@
<?php
/*
* Our test cases rely on PSR-4 autoloading, but no autoloader is
* shipped with the library. Composer will create one, but if the
* library is installed in some other manner, the test suite won't
* run. By using this file to bootstrap PHPUnit, we allow the test
* suite to run out-of-the-box for distributions and users who prefer
* not to use Composer.
*/
require('src/Html2Text.php');
?>

0 comments on commit 1283bff

Please sign in to comment.