Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
PEAR_Info using render options
3
--FILE--
4
<?php
5
$ds         = DIRECTORY_SEPARATOR;
6
$dir        = dirname(__FILE__);
7
$sysconfdir = $dir . $ds . 'sysconf_dir';
8
$peardir    = $dir . $ds . 'pear_dir';
9
$userdir    = $dir . $ds . 'user_dir';
10
$tpldir     = $dir . $ds . 'templates';
11
 
12
putenv("PHP_PEAR_SYSCONF_DIR=" . $sysconfdir);
13
chdir($dir);
14
 
15
// we get PEAR_Info class only here due to setting of PEAR_CONFIG_SYSCONFDIR
16
include_once 'PEAR/Info.php';
17
 
18
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
19
    $u_conf_file  = $peardir . $ds . 'pear.ini';
20
    $conf_file    = $peardir . $ds . 'pearsys.ini';
21
    $custom_file1 = $peardir . $ds . 'name1.pearsys.ini';
22
    $custom_file2 = $userdir . $ds . 'name2.pearsys.ini';
23
} else {
24
    $u_conf_file  = $peardir . $ds . '.pearrc';
25
    $conf_file    = $peardir . $ds . 'pear.conf';
26
    $custom_file1 = $peardir . $ds . 'name1.pear.conf';
27
    $custom_file2 = $userdir . $ds . 'name2.pear.conf';
28
}
29
 
30
if (!file_exists($conf_file)) {
31
    // write once PEAR system-wide config file for simulation
32
    $config =& PEAR_Config::singleton();
33
    $config->set('php_dir', $peardir);
34
    $config->writeConfigFile($conf_file);
35
 
36
    // also writes custom pear system config files
37
    $config->writeConfigFile($custom_file1);
38
    $config->writeConfigFile($custom_file2);
39
}
40
 
41
/**
42
 * TestCase 1:
43
 * usage of stylesheet to customize look and feel
44
 */
45
$testCase = 'testCustomStyleSheet';
46
 
47
$GLOBALS['_PEAR_Config_instance'] = null;
48
 
49
$pearInfo   = new PEAR_Info($peardir);
50
$css_exists = $pearInfo->setStyleSheet($tpldir . $ds . 'blueskin.css');
51
 
52
$result = ($css_exists)
53
    ? 'OK' : 'CSS file does not exists';
54
 
55
echo $testCase . ' : ' . $result;
56
echo "\n";
57
 
58
/**
59
 * TestCase 2:
60
 * display main page with default stylesheet
61
 */
62
$testCase = 'testDefaultStyleSheet';
63
 
64
$GLOBALS['_PEAR_Config_instance'] = null;
65
 
66
$options = array('resume' =>  PEAR_INFO_GENERAL |
67
                              PEAR_INFO_PACKAGES_VERSION |
68
                              PEAR_INFO_FULLPAGE,
69
                 'channels' => array());
70
 
71
$pearInfo = new PEAR_Info($peardir, '', '', $options);
72
$html = $pearInfo->toHtml();
73
 
74
$packages_tpl = file_get_contents($tpldir . $ds . 'packages.tpl');
75
$packages_tpl = str_replace(
76
                    array(
77
                        '{styles}',
78
                        '{script_filename}',
79
                        '{config_file}',
80
                        '{usr_config_file}',
81
                        '{sys_config_file}'
82
                    ),
83
                    array(
84
                        $pearInfo->getStyleSheet(),
85
                        __FILE__,
86
                        $conf_file,
87
                        $u_conf_file,
88
                        $conf_file
89
                    ),
90
                    $packages_tpl);
91
 
92
if (OS_WINDOWS) {
93
    $html = str_replace("\r\n", "\n", $html);
94
}
95
 
96
$result = (strcasecmp($html, $packages_tpl) == 0)
97
    ? 'OK' : 'HTML strings are not same';
98
 
99
echo $testCase . ' : ' . $result;
100
echo "\n";
101
 
102
/**
103
 * TestCase 3:
104
 * display credits page with default stylesheet
105
 */
106
$testCase = 'testCreditsWithDefaultStyleSheet';
107
 
108
$GLOBALS['_PEAR_Config_instance'] = null;
109
 
110
$options = array('resume' =>  PEAR_INFO_GENERAL |
111
                              PEAR_INFO_CREDITS_ALL |
112
                              PEAR_INFO_FULLPAGE,
113
                 'channels' => array());
114
 
115
$pearInfo = new PEAR_Info($peardir, '', '', $options);
116
ob_start();
117
$pearInfo->show();
118
$html = ob_get_contents();
119
ob_end_clean();
120
 
121
$credits_tpl = file_get_contents($tpldir . $ds . 'credits.tpl');
122
$credits_tpl = str_replace(
123
                    array(
124
                        '{styles}',
125
                        '{script_filename}',
126
                        '{config_file}',
127
                        '{usr_config_file}',
128
                        '{sys_config_file}'
129
                    ),
130
                    array(
131
                        $pearInfo->getStyleSheet(),
132
                        __FILE__,
133
                        $conf_file,
134
                        $u_conf_file,
135
                        $conf_file
136
                    ),
137
                    $credits_tpl);
138
 
139
if (OS_WINDOWS) {
140
    $html = str_replace("\r\n", "\n", $html);
141
}
142
 
143
$result = (strcasecmp($html, $credits_tpl) == 0)
144
    ? 'OK' : 'HTML strings are not same';
145
 
146
echo $testCase . ' : ' . $result;
147
?>
148
--CLEAN--
149
<?php
150
$ds         = DIRECTORY_SEPARATOR;
151
$dir        = dirname(__FILE__);
152
$sysconfdir = $dir . $ds . 'sysconf_dir';
153
$peardir    = $dir . $ds . 'pear_dir';
154
$userdir    = $dir . $ds . 'user_dir';
155
 
156
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
157
    $conf_file    = $peardir . $ds . 'pearsys.ini';
158
    $custom_file1 = $peardir . $ds . 'name1.pearsys.ini';
159
    $custom_file2 = $userdir . $ds . 'name2.pearsys.ini';
160
} else {
161
    $conf_file    = $peardir . $ds . 'pear.conf';
162
    $custom_file1 = $peardir . $ds . 'name1.pear.conf';
163
    $custom_file2 = $userdir . $ds . 'name2.pear.conf';
164
}
165
 
166
unlink ($conf_file);
167
unlink ($custom_file1);
168
unlink ($custom_file2);
169
?>
170
--EXPECT--
171
testCustomStyleSheet : OK
172
testDefaultStyleSheet : OK
173
testCreditsWithDefaultStyleSheet : OK