Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Test suite for PHP_CompatInfo
4
 *
5
 * PHP version 5
6
 *
7
 * @category PHP
8
 * @package  PHP_CompatInfo
9
 * @author   Laurent Laville <pear@laurent-laville.org>
10
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
11
 * @version  CVS: $Id: AllTests.php,v 1.4 2008/07/22 20:27:11 farell Exp $
12
 * @link     http://pear.php.net/package/PHP_CompatInfo
13
 * @since    File available since Release 1.6.0
14
 */
15
 
16
if (!defined('PHPUnit_MAIN_METHOD')) {
17
    define('PHPUnit_MAIN_METHOD', 'PHP_CompatInfo_AllTests::main');
18
}
19
 
20
require_once 'PHPUnit/Framework/TestSuite.php';
21
require_once 'PHPUnit/TextUI/TestRunner.php';
22
 
23
chdir(dirname(__FILE__));
24
 
25
require_once 'PEAR/Config.php';
26
require_once 'PHP_CompatInfo_TestSuite_Standard.php';
27
require_once 'PHP_CompatInfo_TestSuite_Bugs.php';
28
 
29
/**
30
 * Class for running all test suites for PHP_CompatInfo package.
31
 *
32
 * @category PHP
33
 * @package  PHP_CompatInfo
34
 * @author   Laurent Laville <pear@laurent-laville.org>
35
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
36
 * @version  Release: @package_version@
37
 * @link     http://pear.php.net/package/PHP_CompatInfo
38
 * @since    File available since Release 1.6.0
39
 */
40
 
41
class PHP_CompatInfo_AllTests
42
{
43
    /**
44
     * Runs the test suite.
45
     *
46
     * @return void
47
     */
48
    public static function main()
49
    {
50
        PHPUnit_TextUI_TestRunner::run(self::suite());
51
    }
52
 
53
    /**
54
     * Adds the PHP_CompatInfo test suite.
55
     *
56
     * @return object the PHPUnit_Framework_TestSuite object
57
     */
58
    public static function suite()
59
    {
60
        $suite = new PHPUnit_Framework_TestSuite('PHP_CompatInfo Test Suite');
61
        $suite->addTestSuite('PHP_CompatInfo_TestSuite_Standard');
62
        $suite->addTestSuite('PHP_CompatInfo_TestSuite_Bugs');
63
 
64
        if (PHP_CompatInfo_AllTests::packageInstalled('Console_GetArgs', '1.3.3')
65
            && PHP_CompatInfo_AllTests::packageInstalled('Console_Table', '1.0.5')) {
66
            /* Add CLI test suite, only
67
               if packages below are installed on your system :
68
               - Console_GetArgs 1.3.3 or better
69
               - Console_Table   1.0.5 or better
70
             */
71
            include_once 'PHP_CompatInfo_TestSuite_Cli.php';
72
 
73
            $suite->addTestSuite('PHP_CompatInfo_TestSuite_Cli');
74
        }
75
        return $suite;
76
    }
77
 
78
    /**
79
     * Check if a package is installed
80
     *
81
     * Simple function to check if a package is installed under user
82
     * or system PEAR installation. Minimal version and channel info are supported.
83
     *
84
     * @param string $name        Package name
85
     * @param string $version     (optional) The minimal version
86
     *                            that should be installed
87
     * @param string $channel     (optional) The package channel distribution
88
     * @param string $user_file   (optional) file to read PEAR user-defined
89
     *                            options from
90
     * @param string $system_file (optional) file to read PEAR system-wide
91
     *                            defaults from
92
     *
93
     * @static
94
     * @return bool
95
     * @since  PEAR_Info version 1.6.0 (2005-01-03)
96
     * @see    PEAR_Info::packageInstalled()
97
     */
98
    public static function packageInstalled($name, $version = null, $channel = null,
99
        $user_file = '', $system_file = '')
100
    {
101
        $config =& PEAR_Config::singleton($user_file, $system_file);
102
        $reg    =& $config->getRegistry();
103
 
104
        if (is_null($version)) {
105
            return $reg->packageExists($name, $channel);
106
        } else {
107
            $info = &$reg->getPackage($name, $channel);
108
            if (is_object($info)) {
109
                $installed['version'] = $info->getVersion();
110
            } else {
111
                $installed = $info;
112
            }
113
            return version_compare($version, $installed['version'], '<=');
114
        }
115
    }
116
}
117
 
118
if (PHPUnit_MAIN_METHOD == 'PHP_CompatInfo_AllTests::main') {
119
    PHP_CompatInfo_AllTests::main();
120
}
121
?>