source: scripturizer/trunk/scripturizer_test.php @ 4567

Revision 4567, 5.9 KB checked in by xaglen, 6 years ago (diff)

re-fixed Libronix Links error (lost in code merger)

Line 
1<?php
2// This file is a test suite for the scripturizer plugin.
3// Just place it in the same directory as scripturizer.php and load it
4// to change the number of tests run, append ?n=XXX to the end of the url
5// http://www.example.com/scripturize_test.php?n=1000
6// will run 1,000 tests
7// this would only be useful when trying to determine the timing effects of regular expressions or other code changes
8
9include('scripturizer.php');
10 
11// these are dummy functions necessary to prevent errors since we're not actually running as part of Wordpress
12function get_settings($string) {
13        return 'http://localhost';
14        }
15function get_option($string) {
16        switch ($string) {
17                case 'scripturizer_default_translation':
18                        return 'NIV';
19                case 'scripturizer_dynamic_substitution':
20                case 'scripturizer_libronix':
21                        return TRUE;
22        case 'scripturizer_esv_key':
23                        return 'IP';
24                case 'scripturizer_xml_css':
25                        return '';
26        case 'scripturizer_esv_query_options':
27                        return '&action=doPassageQuery&include-passage-references=true&include-short-copyright=true&include-audio-link=false&output-format=plain-text&include-passage-horizontal-lines=false&include-heading-horizontal-lines=false&line-length=60&include-headings=false&include-subheadings=false&include-footnotes=false';
28                case 'scripturizer_xml_show_hide':     
29                        return TRUE;
30                default:
31                        return FALSE;
32        }
33}
34function update_option($string,$string2) {
35        return true;
36}
37function add_filter($x,$y) {}
38function add_action($x,$y) {}
39
40// this helps time the script - useful when evaluating changes to the regular expressions
41function microtime_float()
42{
43   list($usec, $sec) = explode(" ", microtime());
44   return ((float)$usec + (float)$sec);
45}
46?>
47<HTML><HEAD><TITLE>Testing Scripturizer Plugin</TITLE></HEAD>
48<BODY>
49<?php
50ob_start();
51?>
52<table>
53<tr>
54<td  colspan="3">
55<H1>Where To Look When You</H1>
56</td>
57</tr>
58<tr><td valign="top">
59<H3>Need Forgiveness</H3>
60<ul>
61<li>I John 1:9
62<li>I John 3:5
63<li>Ephesians 2:8-9
64<li>Romans 8:1
65<li>Isaiah 1:18
66</ul>
67<H3>Need Assurance of Salvation</H3>
68<ul>
69<li>I John 5:13
70<li>John 3:36
71<li>Romans 8:16
72</ul>
73<H3>Feel Abandoned By God</H3>
74<ul>
75<li>Deuteronomy 31:6
76<li>Deuteronomy 4:31
77<li>Psalm 91:14, 15
78<li>Psalm 37:25
79<li>I Samuel 12:22
80</ul>
81<H3>Need Healing</H3>
82<ul>
83<li>Exodus 15:26
84<li>Psalm 103:3
85<li>Jeremiah 17:14
86<li>Hebrews 13:8
87<li>III John 2
88<li>Jeremiah 30:17
89</ul>
90<H3>Need Guidance</H3>
91<ul>
92<li>Psalm 27:11
93<li>James 1:5-8
94<li>Psalm 32:8
95<li>Romans 8:14
96<li>II Corinthians 5:7
97<li>Proverbs 3:5,6
98</ul>
99</td><td valign="top" bgcolor="lightyellow">
100<H3>Wrestle With Grief</H3>
101<ul>
102<li>I Thessalonians 4:13, 14
103<li>Isaiah 41:10
104<li>II Thessalonians 2:16, 17
105<li>Matthew 5:4
106<li>II Corinthians 1:3, 4
107<li>II Corinthians 4:6-9
108<li>Psalm 23:4
109<li>Revelation 21:4
110<li>Psalm 34:18
111<li>Psalm 61:2
112</ul>
113<H3>Struggle With Alcoholism And Drugs</H3>
114<ul>
115<li>Romans 13:1
116<li>Proverbs 20:1
117<li>Proverbs 23:29-32
118<li>I Corinthians 6:10
119<li>I Corinthians 3:16, 17
120<li>Titus 3:3-5
121<li>Romans 13:14
122<li>John 8:36
123<li>I Corinthians 6:20
124</ul>
125<H3>Wrestle With Temptation</H3>
126<ul>
127<li>I Corinthians 10:12-13
128<li>James 4:7
129</ul>
130</td><td valign="top">
131<H3>Need To Repent</H3>
132<ul>
133<li>Hebrews 10:38
134<li>Luke 9:62
135<li>II Peter 3:9
136<li>Isaiah 55:7
137<li>Jeremiah 3:22
138</ul>
139<H3>Feel Lonely</H3>
140<ul>
141<li>Psalm 139:7
142<li>John 14:23
143<li>Deuteronomy 31:6
144<li>John 14:16
145</ul>
146<H3>Need to Control Your Thoughts</H3>
147<ul>
148<li>Romans 12:1-2
149<li>2 Corinthians 10:5
150<li>Psalm 139:23
151<li>Psalms 94:11; 1:1, 2
152<li>Philippians 4:8
153</ul>
154<H3>Need Encouragement</H3>
155<ul>
156<li>Proverbs 16:3
157<li>Psalm 10:17
158<li>Psalm 119:143
159</ul>
160<H3>Feel Anxious</H3>
161<ul>
162<li>Deuteronomy 31:6
163<li>Deuteronomy 33:27
164<li>Ephesians 6:13
165<li>Hebrews 13:5-6
166<li>Matthew 12:22-26
167</ul>
168</td></tr></table>
169<p></p>
170<hr>
171<H3>Test Cases</H3>
172<p>Does a single ' really botch things up? I have been told it does, but this test doesn't validate that...</p>
173<H4>These Should Not Be Scripturized</H4>
174<p>I read once about <a href="">Genesis 1:1</a> (already a link) <img src='' alt='Genesis 1:1' width="20" height="20"> (a reference in an ALT tag).</p>
175<pre>All this should be untouched due to preformatting: John 3:16, Mal 2.</pre>
176<code>And this is in a code block: Matthew 1:1-18, ESV</code>
177<p>[bible]John 3:16[/bible]This is text that should be enclosed by the ESV wordpress plugin and thus not affected.</p>
178<p>The 3 of us went downtown, and the 3 of us had a great time.</p>
179<H4>These Should Be Scripturized</H4>
180 <p>I also read about Genesis 3:13-15 (CEV) ,as well as Genesis 40:3, NET (Gen 3:4) also see Gen. 15:1 and 1st Tim 2 and 2 Kings 4:3, NET.  I should also investigate John 1:1 (NRSV).</p>
181<ul>
182<li> Matthew 4:5, NA26
183<li> Mat 4:5, NA26
184<li> Matt 4:5
185<li> Isaiah 3:2, LXX
186<li> 1st Kings 1:1, LXX
187<li> Mark 3, LXX
188<li> Zechariah 3, NOTRANS
189<li> III Jn 2:1 (GNT)
190<li> III Jn 2:1 (NLT)
191<li> 2nd Chron. 5 - NLT
192<li> Ex 2, MSG '
193<li> Ex 2, NRSV
194<li> Hosea 5:3,4
195<li> Matthew 19:5-7, 9, 20 & 21.
196<li> Matthew 19:5-7, 9, 20 & 21 (NET)
197<li> Matthew 19:5-7, 9, 20 & 21 (KJV).
198<li> Micah 1:8, HCSB
199<li> Acts 1:8, Darby
200<li> Song of Songs 1:3, NRSV
201<li> Song of Songs 1:3, NET
202<li> Song of Songs 1, NRSV
203<li> Song of Songs 1, NET
204<li> Phil 1:1
205<li> 2 The 1:2
206</ul>
207<H4>Undefined Behavior</H4>
208< I wonder < what Gen 5:3, ESV this > will do < (or for that matter, this: Gen 5:3, ESV)
209<?php
210$text=ob_get_clean();
211
212if (isset($_GET['n'])) {
213        $n=$_GET['n'];
214} else {
215                $n=100;
216}
217$time_start = microtime_float();
218for ($i=0;$i<$n;$i++) {
219        $output=scripturize($text);
220}
221$time_end = microtime_float();
222$time_elapsed=$time_end-$time_start;
223$average_time=$time_elapsed/$n;
224?>
225<H2>Text Scripturized <?php echo $n;?> Times In <?php echo $time_elapsed;?> Seconds</H2>
226<H3>Average Time: <?php echo $average_time;?> Seconds</H3>
227<?php echo $output;?>
228<hr>
229<H2>This Test Was Conducted Using The Following Code:</H2>
230<?php
231// if your edits don't seem to be having any effect, be sure that you're using the version of scripturizer.php that you think you are
232highlight_file('scripturizer.php');
233?>
234</BODY>
235</HTML>
Note: See TracBrowser for help on using the repository browser.