Permalink
Browse files

Set include_path in such a way that tests can be run from anywhere an…

…d pick up the right files to be tested.

git-svn-id: http://svn.php.net/repository/pear/packages/PEAR_PackageFileManager/trunk@322107 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 970d2c8 commit 1a6beb6b2d6ed92efee74ea20bf8dd9fb15b335e Daniel Convissor committed Jan 12, 2012
Showing with 35 additions and 2 deletions.
  1. +3 −1 package.xml
  2. +3 −1 package_PFM1.xml
  3. +29 −0 tests/setup.php.inc
View
@@ -141,7 +141,9 @@ Features include
</dir> <!-- /tests/PEAR_PackageFileManager2/writePackageFile -->
</dir> <!-- /tests/PEAR_PackageFileManager2 -->
<file name="phpt_test.php.inc" role="test" />
- <file name="setup.php.inc" role="test" />
+ <file name="setup.php.inc" role="test">
+ <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" />
+ </file>
</dir> <!-- /tests -->
<file name="LICENSE" role="doc" />
<file name="PackageFileManager2.php" role="php">
View
@@ -150,7 +150,9 @@ No changes since alpha1
</dir> <!-- /tests/setOptions -->
<file name="Bad_file.php" role="test" />
<file name="phpt_test.php.inc" role="test" />
- <file name="setup.php.inc" role="test" />
+ <file name="setup.php.inc" role="test">
+ <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" />
+ </file>
<file name="test1_package.xml" role="test" />
<file name="Test_file.php" role="test" />
</dir> <!-- /tests -->
View
@@ -1,4 +1,33 @@
<?php
+
+/*
+ * Set include path so tests can be run from anywhere.
+ */
+
+if ('@php_dir@' == '@'.'php_dir'.'@') {
+ // This package hasn't been installed, use parent of this dir.
+ $php_dir = dirname(dirname(__FILE__));
+} else {
+ $php_dir = '@php_dir@';
+}
+
+$dirs = array(
+ dirname($_SERVER['PHP_SELF']),
+ dirname(dirname($_SERVER['PHP_SELF'])),
+ dirname(__FILE__),
+ $php_dir,
+ '.',
+);
+
+$dirs = array_merge($dirs, explode(PATH_SEPARATOR, get_include_path()));
+$dirs = array_unique($dirs);
+set_include_path(implode(PATH_SEPARATOR, $dirs));
+
+
+/*
+ * Other tasks.
+ */
+
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpt_test.php.inc';
require_once 'PEAR/PackageFileManager.php';
$pfm = new PEAR_PackageFileManager;

0 comments on commit 1a6beb6

Please sign in to comment.