]> git.mxchange.org Git - friendica.git/blob - simplepie/test/test.php
Add simplepie
[friendica.git] / simplepie / test / test.php
1 <?php
2
3 if (version_compare(PHP_VERSION, '5.3', '>='))
4 {
5         error_reporting(E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED);
6 }
7 else
8 {
9         error_reporting(E_ALL);
10 }
11
12 if (version_compare(PHP_VERSION, '5.1', '>='))
13 {
14         $tz = timezone_identifiers_list();
15         date_default_timezone_set($tz[array_rand($tz)]);
16 }
17
18 header('Content-type: text/html; charset=UTF-8');
19
20 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
21 <html lang="en">
22 <head>
23 <title>SimplePie: Unit Tests</title>
24 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
25
26 <style type="text/css">
27 * {
28         margin: 0;
29         padding: 0;
30 }
31
32 body {
33         font: 12px/18px Verdana, sans-serif;
34         color: #333;
35         background: #fff url(background.gif) repeat-x top left;
36 }
37
38 #site {
39         width: 500px;
40         margin: 20px auto;
41 }
42
43 a {
44         color: #000;
45         text-decoration: underline;
46 }
47
48 a:hover {
49         color: #fff;
50         background-color: #333;
51         text-decoration: none;
52 }
53
54 h1 {
55         font-size: 18px;
56         margin: 30px 0 10px 0;
57         text-align: center;
58 }
59
60 h1 + p {
61         text-align: center;
62 }
63
64 h2 {
65         font-size: 16px;
66         margin: 20px 0 5px 0;
67         padding-top: 20px;
68         border-top: 1px solid #ccc;
69 }
70
71 h2 + p + p, h2 + p + p a {
72         font-size: 10px;
73         line-height: 12px;
74         color: #666;
75 }
76
77 #summary + p + p {
78         margin: 20px 0 0 0;
79         padding-top: 10px;
80         border-top: 1px solid #ccc;
81 }
82
83 small {
84         font-size: 10px;
85 }
86
87 .pass {
88         color: green;
89 }
90
91 .fail {
92         color: red;
93 }
94 </style>
95
96 <script type="text/javascript">
97 // Sleight - Alpha transparency PNG's in Internet Explorer 5.5/6.0
98 // (c) 2001, Aaron Boodman; http://www.youngpup.net
99
100 if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
101         document.writeln('<style type="text/css">img, input.image { visibility:hidden; } </style>');
102         window.attachEvent("onload", fnLoadPngs);
103 }
104
105 function fnLoadPngs() {
106         var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
107         var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
108
109         for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
110                 if (itsAllGood && img.src.match(/\png$/i) != null) {
111                         var src = img.src;
112                         var div = document.createElement("DIV");
113                         div.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizing='scale')";
114                         div.style.width = img.width + "px";
115                         div.style.height = img.height + "px";
116                         img.replaceNode(div);
117                 }
118                 img.style.visibility = "visible";
119         }
120 }
121 </script>
122
123 </head>
124
125 <body>
126
127 <div id="site">
128         <h1><img src="logo.png" alt="SimplePie Compatibility Test" title="SimplePie Compatibility Test"></h1>
129         <p><a href="#summary">Skip to the results</a> | 
130         <?php
131         if (isset($_GET['remote'])) echo '<a href="?">Re-run without remote tests</a>';
132         else echo '<a href="?remote=true">Re-run with remote tests</a>';
133         ?>
134         </p>
135 <?php
136
137 require_once '../simplepie.inc';
138 require_once 'functions.php';
139
140 $tests = array(
141         'absolutize',
142         'date',
143         'feed_category_label',
144         'feed_copyright',
145         'feed_description',
146         'feed_image_height',
147         'feed_image_link',
148         'feed_image_title',
149         'feed_image_url',
150         'feed_image_width',
151         'feed_language',
152         'feed_link',
153         'feed_title',
154         'first_item_author_name',
155         'first_item_category_label',
156         'first_item_content',
157         'first_item_contributor_name',
158         'first_item_date',
159         'first_item_description',
160         'first_item_id',
161         'first_item_latitude',
162         'first_item_longitude',
163         'first_item_permalink',
164         'first_item_title',
165 );
166
167 $master = new Unit_Test2_Group('SimplePie Test Suite');
168
169 foreach ($tests as $test)
170 {
171         $test_group = new SimplePie_Unit_Test2_Group(ucwords(str_replace('_', ' ', $test)));
172         $test_group->load_folder($test);
173         $master->add($test_group);
174 }
175
176 $test_group = new SimplePie_Unit_Test2_Group('Who knows a <title> from a hole in the ground?');
177 $test_group->load_folder('who_knows_a_title_from_a_hole_in_the_ground');
178 $master->add($test_group);
179
180 $test_group = new SimplePie_Unit_Test2_Group('iTunesRSS');
181 $test_group->load_folder('itunes_rss');
182 $master->add($test_group);
183
184 if (isset($_GET['remote']))
185 {
186         $test_group = new SimplePie_Unit_Test2_Group('Atom autodiscovery test suite');
187         $test_group->add(new diveintomark_Atom_Autodiscovery);
188         $master->add($test_group);
189 }
190
191 $master->run();
192
193 $passed_percentage = floor($master->passes() / $master->total() * 100);
194 $failed_percentage = ceil($master->fails() / $master->total() * 100);
195
196 ?>
197         <h2 id="summary" class=<?php echo ($passed_percentage == 100) ? 'pass' : 'fail'; ?>><?php echo $passed_percentage; ?>% passed!</h2>
198         <?php echo '<p>We ran ' . $master->total() . ' tests in ' . round($master->time(), 3) . ' seconds (' . round($master->time() / $master->total(), 3) . ' seconds per test) of which ' . $master->passes() . ' (' . $passed_percentage . '%) passed, and ' . $master->fails() . ' (' . $failed_percentage . '%) failed.</p>'; ?>
199         
200         <p><small>Powered by <a href="<?php echo SIMPLEPIE_URL; ?>"><?php echo SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . ', Build ' . SIMPLEPIE_BUILD; ?></a>.  SimplePie is &copy; 2004&ndash;<?php echo date('Y'); ?>, Ryan Parman and Geoffrey Sneddon, and licensed under the <a href="http://www.opensource.org/licenses/bsd-license.php">BSD License</a>.</small></p>
201
202 </div>
203
204 </body>
205 </html>