File: test_sortPackagesForUninstall_SOAPpackage.phpt

package info (click to toggle)
php-pear 1%3A1.10.1%2Bsubmodules%2Bnotgz-9%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 18,600 kB
  • sloc: php: 51,665; ansic: 38,629; xml: 32,572; yacc: 677; pascal: 452; makefile: 122; sh: 116
file content (87 lines) | stat: -rw-r--r-- 3,389 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
--TEST--
PEAR_Installer->sortPackagesForUninstall() - real-world example (uninstall the SOAP package)
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
    echo 'skip';
}
?>
--FILE--
<?php
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
/*
 * Deptree:
 * - SOAP         wants: HTTP_Request, Mail_Mime, Net_DIME, Net_URL
 * - HTTP_Request wants: Net_URL, Net_Socket
 * - Mail_Mime    wants: -nothing-
 * - Net_DIME     wants: -nothing-
 * - Net_Socket   wants: -nothing-
 * - Net_URL      wants: -nothing-
 *
 * Expected order:
 * 1. SOAP
 * 2. HTTP_Request
 * 3. Mail_Mime, Net_DIME, Net_Socket, Net_URL
 */
$p1 = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test_sortPackagesForUninstall' . DIRECTORY_SEPARATOR . 'SOAP-0.8.1.tgz';
$p2 = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test_sortPackagesForUninstall' . DIRECTORY_SEPARATOR . 'Mail_Mime-1.2.1.tgz';
$p3 = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test_sortPackagesForUninstall' . DIRECTORY_SEPARATOR . 'HTTP_Request-1.2.4.tgz';
$p4 = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test_sortPackagesForUninstall' . DIRECTORY_SEPARATOR . 'Net_URL-1.0.14.tgz';
$p5 = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test_sortPackagesForUninstall' . DIRECTORY_SEPARATOR . 'Net_DIME-0.3.tgz';
$p6 = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'test_sortPackagesForUninstall' . DIRECTORY_SEPARATOR . 'Net_Socket-1.0.5.tgz';

for ($i = 1; $i <= 6; $i++) {
    $packages[] = ${"p$i"};
}
$dl = new PEAR_Installer($fakelog);
$config = &test_PEAR_Config::singleton($temp_path . '/pear.ini', $temp_path . '/pear.conf');

test_PEAR_Dependency2::singleton($config);
$_test_dep->setPHPVersion('4.3.10');
$_test_dep->setExtensions(array('pcre' => '1.0'));
require_once 'PEAR/Command/Install.php';
class test_PEAR_Command_Install extends PEAR_Command_Install
{
    function &getDownloader(&$ui, $options, &$config)
    {
        if (!isset($GLOBALS['__Stupid_php4_a'])) {
            $GLOBALS['__Stupid_php4_a'] = new test_PEAR_Downloader($this->ui, array(), $this->config);
        }
        return $GLOBALS['__Stupid_php4_a'];
    }

    function &getInstaller(&$ui)
    {
        if (!isset($GLOBALS['__Stupid_php4_b'])) {
            $GLOBALS['__Stupid_php4_b'] = new test_PEAR_Installer($this->ui, array(), $this->config);
        }
        return $GLOBALS['__Stupid_php4_b'];
    }
}
$command = new test_PEAR_Command_Install($fakelog, $config);
$command->run('install', array(), $packages);
$phpunit->assertNoErrors('after install');
$fakelog->getLog();
$paramnames = array('Mail_Mime', 'SOAP', 'Net_DIME', 'HTTP_Request', 'Net_URL', 'Net_Socket');
$reg = &$config->getRegistry();
$params = array();
foreach ($paramnames as $name) {
    $params[] = &$reg->getPackage($name);
}
$dl->sortPackagesForUninstall($params);
$phpunit->assertEquals('SOAP', $params[0]->getPackage(), '0');
$phpunit->assertEquals('HTTP_Request', $params[1]->getPackage(), '1');

$packages = array('Mail_Mime', 'Net_DIME', 'Net_URL', 'Net_Socket');
$phpunit->assertTrue(in_array($params[2]->getPackage(), $packages), 2);
$phpunit->assertTrue(in_array($params[3]->getPackage(), $packages), 3);
$phpunit->assertTrue(in_array($params[4]->getPackage(), $packages), 4);
$phpunit->assertTrue(in_array($params[5]->getPackage(), $packages), 5);
echo 'tests done';
?>
--CLEAN--
<?php
require_once dirname(__FILE__) . '/teardown.php.inc';
?>
--EXPECT--
tests done