From 7614e213b4d5f460dd61bc4ad72a71729f273376 Mon Sep 17 00:00:00 2001
From: TarekAloch
Date: Mon, 11 Nov 2013 19:20:52 -0500
Subject: [PATCH] removing core files from project and basing directory under
p2
---
README.md | 31 -
{p2/config => config}/config.php | 0
{p2/config => config}/feature_flags.php | 0
core/bootstrap.php | 22 -
core/config/config.php | 51 -
core/controllers/c_app.php | 32 -
core/controllers/c_tests.php | 13 -
core/environment-details.php | 17 -
core/images/placeholder.png | Bin 13616 -> 0 bytes
core/images/placeholder_200_200.png | Bin 2621 -> 0 bytes
core/libraries/DB.php | 587 ----
core/libraries/DB_Test.php | 249 --
core/libraries/Debug.php | 65 -
core/libraries/Email.php | 105 -
core/libraries/File.php | 114 -
core/libraries/Form.php | 584 ----
core/libraries/Geolocate.php | 100 -
core/libraries/Image.php | 380 ---
core/libraries/Log.php | 398 ---
core/libraries/Router.php | 227 --
core/libraries/Test.php | 47 -
core/libraries/Time.php | 228 --
core/libraries/Upload.php | 39 -
core/libraries/User.php | 324 ---
core/libraries/Utils.php | 487 ----
core/libraries/View.php | 246 --
core/vendors/PHPMailer/PHPMailer.php | 2532 -----------------
core/vendors/PHPMailer/class.pop3.php | 410 ---
core/vendors/PHPMailer/class.smtp.php | 818 ------
core/vendors/jstz.min.js | 11 -
core/vendors/krumo/krumo.ini | 20 -
core/vendors/krumo/krumo.js | 98 -
core/vendors/krumo/krumo.php | 1310 ---------
core/vendors/krumo/skins/green/bg.gif | Bin 141 -> 0 bytes
core/vendors/krumo/skins/green/skin.css | 158 -
.../HELP_MY_TESTS_DONT_WORK_ANYMORE | 399 ---
core/vendors/simpletest/LICENSE | 502 ----
core/vendors/simpletest/README | 102 -
core/vendors/simpletest/VERSION | 1 -
core/vendors/simpletest/arguments.php | 224 --
core/vendors/simpletest/authentication.php | 237 --
core/vendors/simpletest/autorun.php | 101 -
core/vendors/simpletest/browser.php | 1144 --------
core/vendors/simpletest/collector.php | 122 -
core/vendors/simpletest/compatibility.php | 166 --
core/vendors/simpletest/cookies.php | 380 ---
core/vendors/simpletest/default_reporter.php | 163 --
core/vendors/simpletest/detached.php | 96 -
.../docs/en/authentication_documentation.html | 378 ---
.../docs/en/browser_documentation.html | 501 ----
core/vendors/simpletest/docs/en/docs.css | 121 -
.../docs/en/expectation_documentation.html | 476 ----
.../docs/en/form_testing_documentation.html | 351 ---
.../docs/en/group_test_documentation.html | 252 --
core/vendors/simpletest/docs/en/index.html | 542 ----
.../docs/en/mock_objects_documentation.html | 870 ------
core/vendors/simpletest/docs/en/overview.html | 487 ----
.../docs/en/partial_mocks_documentation.html | 457 ---
.../docs/en/reporter_documentation.html | 616 ----
.../docs/en/unit_test_documentation.html | 442 ---
.../docs/en/web_tester_documentation.html | 588 ----
.../docs/fr/authentication_documentation.html | 372 ---
.../docs/fr/browser_documentation.html | 500 ----
core/vendors/simpletest/docs/fr/docs.css | 84 -
.../docs/fr/expectation_documentation.html | 451 ---
.../docs/fr/form_testing_documentation.html | 363 ---
.../docs/fr/group_test_documentation.html | 265 --
core/vendors/simpletest/docs/fr/index.html | 576 ----
.../docs/fr/mock_objects_documentation.html | 933 ------
core/vendors/simpletest/docs/fr/overview.html | 321 ---
.../docs/fr/partial_mocks_documentation.html | 475 ----
.../docs/fr/reporter_documentation.html | 630 ----
.../docs/fr/unit_test_documentation.html | 447 ---
.../docs/fr/web_tester_documentation.html | 570 ----
core/vendors/simpletest/dumper.php | 407 ---
core/vendors/simpletest/eclipse.php | 307 --
core/vendors/simpletest/encoding.php | 649 -----
core/vendors/simpletest/errors.php | 267 --
core/vendors/simpletest/exceptions.php | 226 --
core/vendors/simpletest/expectation.php | 984 -------
.../simpletest/extensions/pear_test_case.php | 196 --
.../vendors/simpletest/extensions/testdox.php | 53 -
.../simpletest/extensions/testdox/test.php | 107 -
core/vendors/simpletest/form.php | 361 ---
core/vendors/simpletest/frames.php | 592 ----
core/vendors/simpletest/http.php | 628 ----
core/vendors/simpletest/invoker.php | 139 -
core/vendors/simpletest/mock_objects.php | 1641 -----------
core/vendors/simpletest/page.php | 542 ----
core/vendors/simpletest/php_parser.php | 1054 -------
core/vendors/simpletest/recorder.php | 101 -
core/vendors/simpletest/reflection_php4.php | 136 -
core/vendors/simpletest/reflection_php5.php | 386 ---
core/vendors/simpletest/remote.php | 115 -
core/vendors/simpletest/reporter.php | 445 ---
core/vendors/simpletest/scorer.php | 875 ------
core/vendors/simpletest/selector.php | 141 -
core/vendors/simpletest/shell_tester.php | 330 ---
core/vendors/simpletest/simpletest.php | 391 ---
core/vendors/simpletest/socket.php | 312 --
core/vendors/simpletest/tag.php | 1527 ----------
.../simpletest/test/acceptance_test.php | 1729 -----------
core/vendors/simpletest/test/adapter_test.php | 50 -
core/vendors/simpletest/test/all_tests.php | 13 -
.../simpletest/test/arguments_test.php | 82 -
.../simpletest/test/authentication_test.php | 145 -
core/vendors/simpletest/test/autorun_test.php | 23 -
.../simpletest/test/bad_test_suite.php | 10 -
core/vendors/simpletest/test/browser_test.php | 802 ------
.../simpletest/test/collector_test.php | 50 -
.../simpletest/test/command_line_test.php | 40 -
.../simpletest/test/compatibility_test.php | 87 -
core/vendors/simpletest/test/cookies_test.php | 227 --
.../vendors/simpletest/test/detached_test.php | 15 -
core/vendors/simpletest/test/dumper_test.php | 88 -
core/vendors/simpletest/test/eclipse_test.php | 32 -
.../vendors/simpletest/test/encoding_test.php | 240 --
core/vendors/simpletest/test/errors_test.php | 229 --
.../simpletest/test/exceptions_test.php | 183 --
.../simpletest/test/expectation_test.php | 317 ---
core/vendors/simpletest/test/form_test.php | 344 ---
core/vendors/simpletest/test/frames_test.php | 549 ----
core/vendors/simpletest/test/http_test.php | 492 ----
.../simpletest/test/interfaces_test.php | 137 -
.../test/interfaces_test_php5_1.php | 14 -
core/vendors/simpletest/test/live_test.php | 47 -
.../simpletest/test/mock_objects_test.php | 985 -------
core/vendors/simpletest/test/page_test.php | 166 --
.../simpletest/test/parse_error_test.php | 9 -
core/vendors/simpletest/test/parsing_test.php | 642 -----
.../simpletest/test/php_parser_test.php | 489 ----
.../vendors/simpletest/test/recorder_test.php | 23 -
.../simpletest/test/reflection_php5_test.php | 263 --
core/vendors/simpletest/test/remote_test.php | 19 -
core/vendors/simpletest/test/shell_test.php | 38 -
.../simpletest/test/shell_tester_test.php | 42 -
.../simpletest/test/simpletest_test.php | 58 -
core/vendors/simpletest/test/site/file.html | 6 -
core/vendors/simpletest/test/socket_test.php | 25 -
.../test/support/collector/collectable.1 | 0
.../test/support/collector/collectable.2 | 0
.../test/support/empty_test_file.php | 3 -
.../simpletest/test/support/failing_test.php | 9 -
.../simpletest/test/support/latin1_sample | 1 -
.../simpletest/test/support/passing_test.php | 9 -
.../test/support/recorder_sample.php | 14 -
.../simpletest/test/support/spl_examples.php | 15 -
.../support/supplementary_upload_sample.txt | 1 -
.../vendors/simpletest/test/support/test1.php | 7 -
.../simpletest/test/support/upload_sample.txt | 1 -
core/vendors/simpletest/test/tag_test.php | 554 ----
.../simpletest/test/test_with_parse_error.php | 8 -
.../simpletest/test/unit_tester_test.php | 61 -
core/vendors/simpletest/test/unit_tests.php | 49 -
core/vendors/simpletest/test/url_test.php | 515 ----
.../simpletest/test/user_agent_test.php | 348 ---
core/vendors/simpletest/test/visual_test.php | 495 ----
.../simpletest/test/web_tester_test.php | 155 -
core/vendors/simpletest/test/xml_test.php | 187 --
core/vendors/simpletest/test_case.php | 658 -----
core/vendors/simpletest/tidy_parser.php | 382 ---
core/vendors/simpletest/unit_tester.php | 413 ---
core/vendors/simpletest/url.php | 550 ----
core/vendors/simpletest/user_agent.php | 328 ---
core/vendors/simpletest/web_tester.php | 1532 ----------
core/vendors/simpletest/xml.php | 647 -----
core/views/_v_email.php | 3 -
core/views/_v_template.php | 22 -
core/views/v_message.php | 9 -
environment.php | 36 -
p2/index.php => index.php | 0
171 files changed, 54042 deletions(-)
delete mode 100644 README.md
rename {p2/config => config}/config.php (100%)
rename {p2/config => config}/feature_flags.php (100%)
delete mode 100755 core/bootstrap.php
delete mode 100755 core/config/config.php
delete mode 100755 core/controllers/c_app.php
delete mode 100755 core/controllers/c_tests.php
delete mode 100755 core/environment-details.php
delete mode 100755 core/images/placeholder.png
delete mode 100755 core/images/placeholder_200_200.png
delete mode 100755 core/libraries/DB.php
delete mode 100755 core/libraries/DB_Test.php
delete mode 100755 core/libraries/Debug.php
delete mode 100755 core/libraries/Email.php
delete mode 100755 core/libraries/File.php
delete mode 100755 core/libraries/Form.php
delete mode 100755 core/libraries/Geolocate.php
delete mode 100755 core/libraries/Image.php
delete mode 100755 core/libraries/Log.php
delete mode 100755 core/libraries/Router.php
delete mode 100755 core/libraries/Test.php
delete mode 100755 core/libraries/Time.php
delete mode 100755 core/libraries/Upload.php
delete mode 100755 core/libraries/User.php
delete mode 100755 core/libraries/Utils.php
delete mode 100755 core/libraries/View.php
delete mode 100755 core/vendors/PHPMailer/PHPMailer.php
delete mode 100755 core/vendors/PHPMailer/class.pop3.php
delete mode 100755 core/vendors/PHPMailer/class.smtp.php
delete mode 100755 core/vendors/jstz.min.js
delete mode 100755 core/vendors/krumo/krumo.ini
delete mode 100755 core/vendors/krumo/krumo.js
delete mode 100755 core/vendors/krumo/krumo.php
delete mode 100755 core/vendors/krumo/skins/green/bg.gif
delete mode 100755 core/vendors/krumo/skins/green/skin.css
delete mode 100755 core/vendors/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE
delete mode 100755 core/vendors/simpletest/LICENSE
delete mode 100755 core/vendors/simpletest/README
delete mode 100755 core/vendors/simpletest/VERSION
delete mode 100755 core/vendors/simpletest/arguments.php
delete mode 100755 core/vendors/simpletest/authentication.php
delete mode 100755 core/vendors/simpletest/autorun.php
delete mode 100755 core/vendors/simpletest/browser.php
delete mode 100755 core/vendors/simpletest/collector.php
delete mode 100755 core/vendors/simpletest/compatibility.php
delete mode 100755 core/vendors/simpletest/cookies.php
delete mode 100755 core/vendors/simpletest/default_reporter.php
delete mode 100755 core/vendors/simpletest/detached.php
delete mode 100755 core/vendors/simpletest/docs/en/authentication_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/browser_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/docs.css
delete mode 100755 core/vendors/simpletest/docs/en/expectation_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/form_testing_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/group_test_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/index.html
delete mode 100755 core/vendors/simpletest/docs/en/mock_objects_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/overview.html
delete mode 100755 core/vendors/simpletest/docs/en/partial_mocks_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/reporter_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/unit_test_documentation.html
delete mode 100755 core/vendors/simpletest/docs/en/web_tester_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/authentication_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/browser_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/docs.css
delete mode 100755 core/vendors/simpletest/docs/fr/expectation_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/form_testing_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/group_test_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/index.html
delete mode 100755 core/vendors/simpletest/docs/fr/mock_objects_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/overview.html
delete mode 100755 core/vendors/simpletest/docs/fr/partial_mocks_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/reporter_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/unit_test_documentation.html
delete mode 100755 core/vendors/simpletest/docs/fr/web_tester_documentation.html
delete mode 100755 core/vendors/simpletest/dumper.php
delete mode 100755 core/vendors/simpletest/eclipse.php
delete mode 100755 core/vendors/simpletest/encoding.php
delete mode 100755 core/vendors/simpletest/errors.php
delete mode 100755 core/vendors/simpletest/exceptions.php
delete mode 100755 core/vendors/simpletest/expectation.php
delete mode 100755 core/vendors/simpletest/extensions/pear_test_case.php
delete mode 100755 core/vendors/simpletest/extensions/testdox.php
delete mode 100755 core/vendors/simpletest/extensions/testdox/test.php
delete mode 100755 core/vendors/simpletest/form.php
delete mode 100755 core/vendors/simpletest/frames.php
delete mode 100755 core/vendors/simpletest/http.php
delete mode 100755 core/vendors/simpletest/invoker.php
delete mode 100755 core/vendors/simpletest/mock_objects.php
delete mode 100755 core/vendors/simpletest/page.php
delete mode 100755 core/vendors/simpletest/php_parser.php
delete mode 100755 core/vendors/simpletest/recorder.php
delete mode 100755 core/vendors/simpletest/reflection_php4.php
delete mode 100755 core/vendors/simpletest/reflection_php5.php
delete mode 100755 core/vendors/simpletest/remote.php
delete mode 100755 core/vendors/simpletest/reporter.php
delete mode 100755 core/vendors/simpletest/scorer.php
delete mode 100755 core/vendors/simpletest/selector.php
delete mode 100755 core/vendors/simpletest/shell_tester.php
delete mode 100755 core/vendors/simpletest/simpletest.php
delete mode 100755 core/vendors/simpletest/socket.php
delete mode 100755 core/vendors/simpletest/tag.php
delete mode 100755 core/vendors/simpletest/test/acceptance_test.php
delete mode 100755 core/vendors/simpletest/test/adapter_test.php
delete mode 100755 core/vendors/simpletest/test/all_tests.php
delete mode 100755 core/vendors/simpletest/test/arguments_test.php
delete mode 100755 core/vendors/simpletest/test/authentication_test.php
delete mode 100755 core/vendors/simpletest/test/autorun_test.php
delete mode 100755 core/vendors/simpletest/test/bad_test_suite.php
delete mode 100755 core/vendors/simpletest/test/browser_test.php
delete mode 100755 core/vendors/simpletest/test/collector_test.php
delete mode 100755 core/vendors/simpletest/test/command_line_test.php
delete mode 100755 core/vendors/simpletest/test/compatibility_test.php
delete mode 100755 core/vendors/simpletest/test/cookies_test.php
delete mode 100755 core/vendors/simpletest/test/detached_test.php
delete mode 100755 core/vendors/simpletest/test/dumper_test.php
delete mode 100755 core/vendors/simpletest/test/eclipse_test.php
delete mode 100755 core/vendors/simpletest/test/encoding_test.php
delete mode 100755 core/vendors/simpletest/test/errors_test.php
delete mode 100755 core/vendors/simpletest/test/exceptions_test.php
delete mode 100755 core/vendors/simpletest/test/expectation_test.php
delete mode 100755 core/vendors/simpletest/test/form_test.php
delete mode 100755 core/vendors/simpletest/test/frames_test.php
delete mode 100755 core/vendors/simpletest/test/http_test.php
delete mode 100755 core/vendors/simpletest/test/interfaces_test.php
delete mode 100755 core/vendors/simpletest/test/interfaces_test_php5_1.php
delete mode 100755 core/vendors/simpletest/test/live_test.php
delete mode 100755 core/vendors/simpletest/test/mock_objects_test.php
delete mode 100755 core/vendors/simpletest/test/page_test.php
delete mode 100755 core/vendors/simpletest/test/parse_error_test.php
delete mode 100755 core/vendors/simpletest/test/parsing_test.php
delete mode 100755 core/vendors/simpletest/test/php_parser_test.php
delete mode 100755 core/vendors/simpletest/test/recorder_test.php
delete mode 100755 core/vendors/simpletest/test/reflection_php5_test.php
delete mode 100755 core/vendors/simpletest/test/remote_test.php
delete mode 100755 core/vendors/simpletest/test/shell_test.php
delete mode 100755 core/vendors/simpletest/test/shell_tester_test.php
delete mode 100755 core/vendors/simpletest/test/simpletest_test.php
delete mode 100755 core/vendors/simpletest/test/site/file.html
delete mode 100755 core/vendors/simpletest/test/socket_test.php
delete mode 100755 core/vendors/simpletest/test/support/collector/collectable.1
delete mode 100755 core/vendors/simpletest/test/support/collector/collectable.2
delete mode 100755 core/vendors/simpletest/test/support/empty_test_file.php
delete mode 100755 core/vendors/simpletest/test/support/failing_test.php
delete mode 100755 core/vendors/simpletest/test/support/latin1_sample
delete mode 100755 core/vendors/simpletest/test/support/passing_test.php
delete mode 100755 core/vendors/simpletest/test/support/recorder_sample.php
delete mode 100755 core/vendors/simpletest/test/support/spl_examples.php
delete mode 100755 core/vendors/simpletest/test/support/supplementary_upload_sample.txt
delete mode 100755 core/vendors/simpletest/test/support/test1.php
delete mode 100755 core/vendors/simpletest/test/support/upload_sample.txt
delete mode 100755 core/vendors/simpletest/test/tag_test.php
delete mode 100755 core/vendors/simpletest/test/test_with_parse_error.php
delete mode 100755 core/vendors/simpletest/test/unit_tester_test.php
delete mode 100755 core/vendors/simpletest/test/unit_tests.php
delete mode 100755 core/vendors/simpletest/test/url_test.php
delete mode 100755 core/vendors/simpletest/test/user_agent_test.php
delete mode 100755 core/vendors/simpletest/test/visual_test.php
delete mode 100755 core/vendors/simpletest/test/web_tester_test.php
delete mode 100755 core/vendors/simpletest/test/xml_test.php
delete mode 100755 core/vendors/simpletest/test_case.php
delete mode 100755 core/vendors/simpletest/tidy_parser.php
delete mode 100755 core/vendors/simpletest/unit_tester.php
delete mode 100755 core/vendors/simpletest/url.php
delete mode 100755 core/vendors/simpletest/user_agent.php
delete mode 100755 core/vendors/simpletest/web_tester.php
delete mode 100755 core/vendors/simpletest/xml.php
delete mode 100755 core/views/_v_email.php
delete mode 100755 core/views/_v_template.php
delete mode 100755 core/views/v_message.php
delete mode 100755 environment.php
rename p2/index.php => index.php (100%)
diff --git a/README.md b/README.md
deleted file mode 100644
index 834f4be..0000000
--- a/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-p2.tarekaloch.biz
-=================
-taloch@fas.harvard.edu
-
-Users to your microblog can...
-
-
-
- 1.Sign up
-
- 2.Log in
-
- 3.Log out
-
- 4.Add posts
-
- 5.See a list of all other users
-
- 6.Follow and unfollow other users
-
- 7.View a stream of posts from the users they follow
-
- 8.+1 other feature of your choosing
-
- 9.+1 other feature of your choosing
-
- 10.On your main landing page, clearly state what your two +1 features are.
-
-In addition to these set requirements, you're responsible for covering all the logistical pieces of this application.
-
-For example, you'll need to make sure non-logged in users can't see user-only areas, you'll need a navigation menu, you'll need a landing page, etc.
diff --git a/p2/config/config.php b/config/config.php
similarity index 100%
rename from p2/config/config.php
rename to config/config.php
diff --git a/p2/config/feature_flags.php b/config/feature_flags.php
similarity index 100%
rename from p2/config/feature_flags.php
rename to config/feature_flags.php
diff --git a/core/bootstrap.php b/core/bootstrap.php
deleted file mode 100755
index 5a3e1d1..0000000
--- a/core/bootstrap.php
+++ /dev/null
@@ -1,22 +0,0 @@
- $value ) {
- setcookie( $key, $value, time() - 3600, '/' );
- }
-
- echo "Cleared Cookies";
- }
-
-} // eoc
\ No newline at end of file
diff --git a/core/controllers/c_tests.php b/core/controllers/c_tests.php
deleted file mode 100755
index 2566320..0000000
--- a/core/controllers/c_tests.php
+++ /dev/null
@@ -1,13 +0,0 @@
-";
-
- echo Time::display(Time::now());
-
- if(ENABLE_OUTGOING_EMAIL) echo "OUTGOING EMAILS ENABLED";
- else echo " No outgoing emails";
-
- if(REMOTE_DB) echo " LIVE DB ";
- else echo " Local DB;";
-
- echo "";
-}
-
-
\ No newline at end of file
diff --git a/core/images/placeholder.png b/core/images/placeholder.png
deleted file mode 100755
index cc015db615ca5c80156280e7dcc9d6446cadee19..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 13616
zcmeGjYg7|wHo9oF)UJxF)*^%uw%S5M2ni6xG>`xR1IoidMQBJS5HOjT4Dyi2N?R2b
zg`l#CyIGJ|iNf)P0z&LsVOf?&f+;>0SPJqGB`TnRKz2d~x;^^#-@RY5b_V#YdVkaV7z}0=+m{)H!7L5KV3y>pSPGBKa&qoj|3E{08o;u}yci$|;0coVw*cEPnBU+}
z*k~X|B=NxM>(w}{NZ^6vQaFwrsTU9{@=cKe!6^YD{FHdUn*c}Oj@_0-g9(TMh=)xQ
z?~}-BNglX)x-|IOI84N0=Ru%&51fgqFwRb_7bpX;6av|S??@tHsZ;{VnL?$K?6FRc
zBqyRH{G~dOoM{v)&B+Ced~on=GJ%j5#Pmkyg6}+Vu@EGs5s8V3iG)Nl0hGlMNp5a#
zMjB2|4lsm+JXr$qk{l#*+XV_tK+czmq>u=dV2u=c(O?4PfrB|Ui6E9Pl9k92HNgra
zCh??162Z|Z(gGld^Xs5u@glSw3IcxS_rDUBha^h@Vh|t)6J&hYa6((-R8pFk4B$ba
zECdAiEogCPEC_+}SWt@f3Z`PWaCm%?#5k~Z9)rW7u_bbdC*cEZrUwqDK@f=qG)E@}
z!`so@jp@R2A(2=lhLfwOE1B%-!lJr5F}%DNaG4-KK@3Qs1zf?;xQut=8l6Ebg=c00
zGSLA*;4K5i*mGY59+zuW#e=vxhr8@l{>K7NbE
z#@UUo>!?Jfw4w@a2|a!0=Dt&%BNH0BVQ5fonAH!CecLm0&~k31I!ZmK
zH_U-4xy`QQMI*Gdn~~Ml*4EPn|BOyvgZItBGBQgJmDHE?WfK@Lfce2D<
z5Xw^0Gk%cRLNn}h8M7l%(=f$1YD0EUME9n7JTvwxc0SktcY?Hg*NZ%E;d`f9;z2}K@
zSuw4*J6d?L#U1m55s!Pq7{^VbT+6lmqbvoy
z;3BSI7T(;pqcrTjTanengdF*MCJtq1`(Iq;c6sIPR)2lI&7~yes%_@;~gEG}Y0BE8sVo1wW~~Reo4_Gyj@T
z)3ag61=+O8Yo3mdlk2dR%nenV_T148XXtklQvYCZ|9pW+T^DDvW2mM=`Q%PLHu26+
zReg((4mhtJPb20D|5B+0Z(Y70PUCX#C3H`2M@$~tGH^IW|Df}mMr)i)*XyGF(3tIl
zyJ#={z_zX9uqH09uEpCE3N|l#!kA~0U(DT0mp?e}FF9l~u5%95k@+k?kLG*iM}LdN
zW>!H>q!4k7HoV%r*ZD{p<7A~-)l94NW<*V;CBfo#rExH&-q*X@_qVqS5VM_C*z|@Z
zyh>N=<09%psg#1QhKH+VWGi(&6#6D14uhyBQai<+dfjw1tt0o-qWboKk$QEcsyfvn
zkTm|u=HZ4sL`Hx1ji@i1?^3(-ddahey4V*hW=@vew|V|{#J`94nfrAq5||WxxXt;R
ztYfr`pFO>rn%=WQ`_7_HLp@Ti4qNp~xCS4+r!oAP|;7w&4|
zTDy}bP2A6$kJxcHp)8}seP*`tW%C4We4C}YtUGv;KQmBwg%CB_vjoxduf?n4QpHPK
zZkuI7k)l-9QW)sd&}P-Q{zF82e=cb~E@xi5`>OE5xnR$J<6F#ZrNU2|^;t+Y*zX(OnS2aN<
zE3||w{+Ce97pHQ|RgwLb%39&06JbDvvSG`Ck+x3|%YUxr#1GgPIRE(c;(^93*6p^o
zl{Z#<6`pw6R<3tdbt8uVxaD4&XGTXm;cu;PvfDTBS6%MdeR>km?)HlkUiXQ9X0Z0$
zr3^&Wd0DXK>wLP{Ug0L(;n>yPXok;5Lvf`74Mk&C4Mal`4MpQyB`6ThifC5MM6)8g
zKt&g*XjViQsPn65G%KQeMR@y(W<@kBqFE8mifC3uvm#nSMJuRi1=U!QM=Pjk1r=>(
zpnXNOuZZ>)(Y_+u;{U~w9JH^9_7%~-B6`{eJ#B-Ywn6ub$Qd%Uf{Ip9(F!VBK}9R5
h|4$XvSB9k@U^>kCd!}RiAme|S*sK6%mFJh4{|0ER%~JpX
diff --git a/core/images/placeholder_200_200.png b/core/images/placeholder_200_200.png
deleted file mode 100755
index fc3a5ac4dab8cca501f28c6d4f24e86829199cc2..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 2621
zcmeHJ`&$!d77hWCqPBoiM2n7rt?MpHNHie{Nl73;0|qV07M4XNBm<<7Oq>iPkRm9x
zE$bFosNC#^UWDw@HQ1s^#F}O63RVyyiUI;s6j6*Qw}+e984B1Rmfb&Kcb=K~&U|yu
zd(L^!JI^yYd&5K4Ic{>q;c)8&Z}TJ2wF$c%@aUbuVqQTPcO)nZ5kc{YMgoI4o(zfu
z0f9o207ifkS=zxXARC9X^^%LDkSO79mK0KuB$y9Lt5BiQI2_wwtCC2QKm>>b6XZ$`
zVWi$n0OT?bA(AHa5vl^gMETq4Fepk77faKVq)ZvX|1E&6WuX8H5Rm{{MY2-O(sBq3
zxGdDhw#fuw!39a;5PmKyO1KvYgkTV$k#-WLJ`@T-r;{kVXmmQo8=(47sAM1Xq!TH-
zSTs6|>I*C$1T-5gi)TgfgBNq5PaHxbf~Z(zvPPpJX?BtzIDt%IGMN|#l}bcCi0U*Y
zBGD3+YR@GEKB$($aup(nlmLb(iGxxQ4gsz7=N1&IWmu(pktUQdvR0xZQ%F8oOG}PI
z;eU2jD3-m|NCfz@-hT_M7N@B|as;S`QeY`MxOh)2m5LPzgAxRS#SoOd#NysW2!Ygz
zkO~MC(SctJB~rN(+t{%XAr!I%N;M);N=8>}4!(#aK)X3Kg1}55n?PP!+u~yK{sPV&^tMC^vP7KtL|=->+R0yiKgNsi4`$41uUN--!C4PB%L>#Sn^=eZ9TPj?rQ59gn=Ug2=Jx++oF`a=kvazNcS>vzcC3ut`2P
zH#avNsVD#HI(zMJtq1n+Z}&d;x9_??Z6Bj6W?#3HttpKlAJk-KmVcad^HcgY#r~tm
z>GiKwv~K<<0J!CwwiVs_D#Q7e@5RFW-kzTO)_-ju^Qvw?`CRfSD=T@MrM29Dj6{PA
zt7gxBaJ(z$5`QS@H4||<_&0W|@vu#)g=#D7^7^s;F-SB`jXxAQ|K-xY=kN8tDHhe7
z;&QJYzByV~bmOW|X;E51RoF*#VPnkS3tzOgoqg_7Yk;z|Vz{p!Fdu69-S)VgMl=)o
zc*jtfpsMqY&xh{1m`&?41gm>{%e;~CRW|PVre`-xqYY9I-WVxkAL)tZ)~RFe?w}u-
z6jBVa%@_W3$p-5crn!7SpL*@ZKx1Bv%&w=}LrU6IyC$xMDSGf^lHOY0fyaM)v^g?C
zVZ9Fjd1$yQQjeree746J<|d^rkYyaiTc5eqDl8X`t&O3X<*VE7M>^#bW%Cw%uuPHr#h
zKKSayqaUN(*rCbmo$}SO6Z}ix=G09}_nF8^C(Ath?^Koz^fTVI!NYoK%2igiE-}fw
zCij!eB*T`D_7P&vKh9?r4U3gA*;#Y;X(ywSVB{9Atuee)AKO=LkLuHWfIP~k`PJBBqt@NpsyTJ8HALU}O4qEZ
z!SY_n5GK~?fk#0}$U{Qf;M8o?i=mw#-n<;2pt8F1xc0J{x-3dW%Z)I%VkNPqD=_!{
zFSeW8-|Fu?`u@W7N)mF#H4?wkX8p%QWl^n;xg&?s0S)ec1`SU8w074x^_<As!)
zn0dp>HX8IiE(!REeBh$j^~-N4+{s(F8Z28U{PO(t^Yyn&qcw!S!XpO5y^85A4o$C9
z^Nb_jx{}Hh7E{AE-A4DpI>u(tj#Cht_+Hrt+4J@DM<4eO>~GK9=*gW|I_z**K5gv(
z*UV!tJN||Fl9B&n?Qr-%Ws8zoR?Z@2O)s3_l+B6b$!-rsmWyFuH?}l9*yPDYzjgmm
zUiukRCr`Qz8(eyG2~{xIae2lhiJ2ny#L17eT-1j+}3
A>i_@%
diff --git a/core/libraries/DB.php b/core/libraries/DB.php
deleted file mode 100755
index 59dde2e..0000000
--- a/core/libraries/DB.php
+++ /dev/null
@@ -1,587 +0,0 @@
-connection = mysql_connect(DB_HOST, DB_USER, DB_PASS, TRUE);
-
- # If there are problems connecting...Show full message on local, email message and die gracefully on live
- if(mysql_error()) {
- if (IN_PRODUCTION) {
-
- # Email app owner
- $subject = "SQL Error";
- $body = "SQL Error ".$sql." ".mysql_error($this->connection);
- $body .= "Query History ";
- foreach($this->query_history as $k => $v) {
- $body .= $k." = ".$v." ";
- }
- Utils::alert_admin($subject, $body);
-
- # Show a nice cryptic error
- die("There's been an error processing your request (#DB46) ");
-
- } else {
- die(Debug::dump("SQL Error: ".$sql." ".mysql_error()));
- }
- }
-
- # use utf8 character encoding
- mysql_set_charset('utf8', $this->connection);
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- singleton pattern:
- DB::instance(DB_NAME)->query('...');
- -------------------------------------------------------------------------------------------------*/
- public static function instance($db = NULL) {
-
- # use existing instance
- if (! isset(self::$instance)) {
-
- # create a new instance
- self::$instance = new DB($db);
- }
-
- # select database
-
- self::$instance->select_db($db);
-
- # return instance
- return self::$instance;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
-
- -------------------------------------------------------------------------------------------------*/
- public function select_db($db = NULL) {
-
- # start benchmark
- $this->benchmark_start = microtime(TRUE);
-
- # only select database if it hasn't already or a new database was specified
- if ($this->database === NULL || $db != $this->database || self::$always_select === TRUE) {
-
- # store specified database
- $this->database = $db;
-
- # select database
- mysql_select_db($this->database, $this->connection);
-
- }
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Perform a query with connected database
- This method is the go-to method for all the other methods in this class,
- Essentially a wrapper for PHP's mysql_query()
- -------------------------------------------------------------------------------------------------*/
- public function query($sql) {
-
- # if debugging, just return the query (if you want to see what the query looks like before executing it)
- # TODO: this should return an EXPLAIN of the query which gives us the benchmark as well
- if (self::$debug)
- return $sql;
-
- # store query history
- $this->query_history[] = $sql;
-
- # send query
- $result = mysql_query($sql, $this->connection);
-
- # store query benchmark
- $this->query_benchmarks[] = number_format(microtime(TRUE) - $this->benchmark_start, 4);
-
- # handle MySQL errors
- if (! $result) {
-
- # don't show error and sql query in production
- if (IN_PRODUCTION) {
-
- # Email app owner
- $subject = "SQL Error";
- $body = "SQL Error ".$sql." ".mysql_error($this->connection);
- $body .= "Query History ";
- foreach($this->query_history as $k => $v) {
- $body .= $k." = ".$v." ";
- }
- Utils::alert_admin($subject, $body);
-
- # Show a nice cryptic error
- die("There's been an error processing your request (#DB138) ");
-
- } else {
- die(Debug::dump("SQL Error: ".$sql." ".mysql_error($this->connection)));
- }
- }
-
- # return sucessful result
- return $result;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Dump the last query
- -------------------------------------------------------------------------------------------------*/
- public function last_query($dump = TRUE) {
-
- # last query
- $last_query = end($this->query_history);
-
- # last query benchmarks
- $last_query_benchmark = end($this->query_benchmarks);
-
- # toggle dumping output or just returning query string
- return ($dump) ? Debug::dump("($last_query_benchmark sec) ".$last_query, "Last MySQL Query") : $last_query;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Show entire query history w/benchmarks
- -------------------------------------------------------------------------------------------------*/
- public function query_history($dump = TRUE) {
-
- $history = array();
-
- # store total execution time
- $total_execution = 0;
-
- # build array with benchmarks
- foreach ($this->query_history as $i => $query) {
-
- if (isset($this->query_benchmarks[$i])) {
-
- $query = '('.$this->query_benchmarks[$i].' sec) '.$query;
- $total_execution += $this->query_benchmarks[$i];
-
- }
-
- $history[] = $query;
- }
-
- # add total query execution time to end
- $history[] = "MySQL Total Execution: $total_execution sec";
-
- # toggle dumping output or just returning query history array
- return ($dump) ? Debug::dump($history, "MySQL Query History", FALSE) : $history;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- When you just want to get one single value from the database
- Does *not* sanitize
- Returns the value (no array)
-
- Ex:
- $user_id = DB::instance(DB_NAME)->select_field("SELECT user_id FROM users WHERE id = 55");
- -------------------------------------------------------------------------------------------------*/
- public function select_field($sql) {
-
- $result = $this->query($sql);
- $row = mysql_fetch_array($result);
- $field = $row[0];
- return $field;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Select a single row from the database
- Optional $type can be 'assoc', 'array' or 'object'
- Does *not* sanitize
- Returns an array
-
- Ex:
- $user_details = DB::instance(DB_NAME)->select_row("SELECT * FROM users WHERE id = 55");
- -------------------------------------------------------------------------------------------------*/
- public function select_row($sql, $type = 'assoc') {
-
- $result = $this->query($sql);
- $mysql_fetch = 'mysql_fetch_'.$type;
- return $mysql_fetch($result);
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Returns all the rows in an array
- Does *not* sanitize
- Optional $type can be 'assoc', 'array' or 'object'
- -------------------------------------------------------------------------------------------------*/
- public function select_rows($sql, $type = 'assoc') {
-
- $rows = array();
- $mysql_fetch = 'mysql_fetch_'.$type;
-
- $result = $this->query($sql);
-
- while($row = $mysql_fetch($result)) {
- $rows[] = $row;
- }
-
- return $rows;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Alias to select_row for objects
- Does *not* sanitize
- -------------------------------------------------------------------------------------------------*/
- public function select_object($sql) {
-
- return $this->select_row($sql, 'object');
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Return a key->value array given two columns
- Does *not* sanitize
- Ex:
- $users = DB::instance(DB_NAME)->select_kv("SELECT user_id, first_name FROM users", 'user_id', 'name');
- -------------------------------------------------------------------------------------------------*/
- public function select_kv($sql, $key_column, $value_column) {
-
- $array = array();
-
- foreach ($this->select_rows($sql) as $row) {
-
- # avoid empty keys, but 0 is okay
- if ($row[$key_column] !== NULL && $row[$key_column] !== "")
- $array[$row[$key_column]] = $row[$value_column];
- }
-
- return $array;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Takes select_rows one step further by making the index of the results array some specified field
- For example, if you wanted a full array of users where the index was the user_id, you could use this.
- Key column must be unique, otherwise data will overwrite itself in the array.
- Does *not* sanitize
-
- Ex:
- $users = DB::instance(DB_NAME)->select_array('SELECT * FROM users', 'user_id');
- -------------------------------------------------------------------------------------------------*/
- public function select_array($sql, $key_column) {
-
- $array = array();
-
- foreach ($this->select_rows($sql) as $row) {
-
- # avoid empty keys, but 0 is okay
- if ($row[$key_column] !== NULL && $row[$key_column] !== "")
- $array[$row[$key_column]] = $row;
- }
-
- return $array;
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Insert a row given an array of key => values
- Returns the id of the row that was inserted
- Does sanitize
-
- Ex:
- $data = Array("first_name" => "Joe", "last_name" => "Smith");
- $user_id = DB::instance(DB_NAME)->insert("users", $data);
- -------------------------------------------------------------------------------------------------*/
- # Alias
- public function insert($table, $data) { return self::insert_row($table, $data); }
- public function insert_row($table, $data) {
-
- # setup insert statement
- $sql = "INSERT INTO $table SET";
-
- # add columns and values
- foreach ($data as $column => $value)
- $sql .= " $column = '".mysql_real_escape_string($value)."',";
-
- # remove trailing comma
- $sql = substr($sql, 0, -1);
-
- # perform query
- $this->query($sql);
-
- # return auto_increment id
- return mysql_insert_id();
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Accepts multi-dimensional $data array of rows
- Returns number of rows affected
- Does sanitize
-
- Ex:
- $data[] = Array("first_name" => "John", "last_name" => "Smith");
- $data[] = Array("first_name" => "Jane", "last_name" => "Doe");
-
- $results = DB::insert(DB_NAME)->insert_rows("users", $data);
- -------------------------------------------------------------------------------------------------*/
- public function insert_rows($table, $data) {
-
- # Fields
- $fields = "";
- foreach($data[0] as $field => $row) {
- $fields .= $field.",";
- }
-
- $fields = substr($fields, 0, -1);
-
- # Rows
- $row_string = "";
- $rows_string = "";
- foreach($data as $row) {
- $row_string = "(";
- foreach($row as $field => $value) {
- $row_string .= "'".mysql_real_escape_string($value)."',";
- }
- $row_string = substr($row_string, 0, -1);
- $row_string .= "),";
- $rows_string .= $row_string;
- }
-
- $rows_string = substr($rows_string, 0, -1);
-
- # Query
- $q = "INSERT INTO ".$table."
- (".$fields.")
- VALUES
- ".$rows_string;
-
- # Run it
- $run = $this->query($q);
- return mysql_affected_rows();
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Update a single row given an array of key => values
- example $where_condition: "WHERE id = 1 LIMIT 1"
- Does sanitize
-
- Ex:
- $data = Array("first_name" => "John");
- DB::instance("users", $data, "WHERE user_id = 56");
- -------------------------------------------------------------------------------------------------*/
- # Alias
- public function update($table, $data, $where_condition) { return self::update_row($table, $data, $where_condition); }
- public function update_row($table, $data, $where_condition) {
-
- # setup update statement
- $sql = "UPDATE $table SET";
-
- # add columns and values
- foreach ($data as $column => $value) {
- # allow setting columns to NULL
- if ($value === NULL) {
- $sql .= " $column = NULL,";
- } else {
- $sql .= " $column = '".mysql_real_escape_string($value)."',";
- }
- }
-
- # remove trailing comma
- $sql = substr($sql, 0, -1);
-
- # Add condition
- $sql .= " ".$where_condition;
-
- # perform query
- $this->query($sql);
-
- return mysql_affected_rows();
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- If the primary key exists update row, otherwise insert row
- Requires primary id be first part of the data array - that's what it uses to check for duplicate
- Returns the created id
- Does sanitize
-
- Ex:
- $data = Array("user_id" => 50", "first_name" => "Joe", "last_name" => "Smith");
- $user_id = DB::instance(DB_NAME)->update_or_insert_row("users", $data);
- -------------------------------------------------------------------------------------------------*/
- public function update_or_insert_row($table, $data) {
-
- # Build fields and values
- $fields = "";
- $values = "";
- $dup = "";
-
- foreach($data as $field => $value) {
- $fields .= $field.",";
- $values .= "'".mysql_real_escape_string($value)."',";
- $dup .= $field."="."'".mysql_real_escape_string($value)."',";
- }
-
- $fields = substr($fields, 0, -1);
- $values = substr($values, 0, -1);
- $dup = substr($dup, 0, -1);
-
- # Query
- $q = "INSERT INTO ".$table."
- (".$fields.")
- VALUES
- (".$values.")
- ON DUPLICATE KEY UPDATE ".$dup;
- ;
-
- $this->query($q);
-
- return mysql_insert_id();
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Just like above method, but for multiple rows
- If the primary key exists update, otherwise insert
-
- Requires primary id be first part of the data array - that's what it uses to check for duplicate
- Requires all fields to be present, otherwise a missing field will get set to blank
- Does sanitize
-
- Example SQL string result:
-
- INSERT INTO tasks (person_id,first_name,email)
- VALUES (1,'Ethel','ethel@aol.com'),(3,'Leroy','leroy@hotmail.com'),(3,'Francis','francis@gmail.com')
- ON DUPLICATE KEY UPDATE first_name=VALUES(first_name),email=VALUES(email)'
-
- Ex:
- $data[] = Array("person_id" => 1, "first_name" => 'Ethel', "email" => 'ethel@aol.com');
- $data[] = Array("person_id" => 2, "first_name" => 'Leroy', "email" => 'leroy@hotmail.com');
- $data[] = Array("person_id" => 3, "first_name" => 'Francis', "email" => 'francis@gmail.com.com');
- $update = DB::instance("courses_webstartwomen_com")->update_or_insert_rows('people', $data);
- -------------------------------------------------------------------------------------------------*/
- public function update_or_insert_rows($table, $data) {
-
- # Build the fields string. Ex: (person_id,first_name,email)
- # And the duplicate key update string. Ex: first_name=VALUES(first_name),email=VALUES(email)
- # We do this by using the indexes on the first row of data
- # NOTE: The index of the data array has to start at 0 in order for this to work
- $fields = "";
- $dup = "";
- foreach($data[0] as $index => $value) {
- $fields .= $index.",";
- $dup .= $index."=VALUES(".$index."),";
- }
-
- # Remove last comma
- $fields = substr($fields, 0, -1);
- $dup = substr($dup, 0, -1);
-
- # Build the data string. Ex: (1,'Ethel','ethel@aol.com'),(3,'Leroy','leroy@hotmail.com'),(3,'Francis','francis@gmail.com')
- $values = "";
- foreach($data as $row) {
-
- $values .= "(";
- foreach($row as $value) {
- $values .= "'".mysql_real_escape_string($value)."',";
- }
- $values = substr($values, 0, -1);
- $values .= "),";
- }
- # Remove last comma
- $values = substr($values, 0, -1);
-
- # Put it all together
- $sql = "INSERT INTO ".$table." (".$fields.")
- VALUES ".$values."
- ON DUPLICATE KEY UPDATE ".$dup;
-
- # Run it
- $run = $this->query($sql);
- return mysql_affected_rows();
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Ex:
- DB::instance(DB_NAME)->delete('users', "WHERE email = 'max@gmail.com'");
- Does *not* sanitize
-
- Returns 1 if it found something to delete
- -------------------------------------------------------------------------------------------------*/
- public function delete($table, $where_condition) {
-
- $sql = 'DELETE FROM '.$table.' '.$where_condition;
-
- return $this->query($sql);
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
- Accepts an array or string of data
- Returns escaped data
-
- Ex:
- $_POST = DB::instance(DB_NAME)->sanitize($_POST);
- -------------------------------------------------------------------------------------------------*/
- public function sanitize($data) {
-
- if(is_array($data)){
-
- foreach($data as $k => $v){
- if(is_array($v)){
- $data[$k] = self::sanitize($v);
- } else {
- $data[$k] = mysql_real_escape_string($v, $this->connection);
- }
- }
-
- } else {
- $data = mysql_real_escape_string($data, $this->connection);
- }
-
- return $data;
-
- }
-
-
-}
diff --git a/core/libraries/DB_Test.php b/core/libraries/DB_Test.php
deleted file mode 100755
index 863c7bb..0000000
--- a/core/libraries/DB_Test.php
+++ /dev/null
@@ -1,249 +0,0 @@
-query("CREATE DATABASE ".$this->db_name.";");
- DB::instance($this->db_name)->select_db($this->db_name);
-
- # Create table
- $q = "CREATE TABLE users
- (
- user_id int NOT NULL AUTO_INCREMENT,
- PRIMARY KEY(user_id),
- first_name varchar(255),
- last_name varchar(255)
- )";
-
- DB::instance($this->db_name)->query($q);
-
- }
-
-
- function testInsert() {
-
- $user_id = DB::instance($this->db_name)->insert('users', Array('first_name' => 'Joe', 'last_name' => 'Smith'));
- $this->assertNotNull($user_id);
-
- $delete = DB::instance($this->db_name)->delete('users', "WHERE first_name = 'Jo'");
- $this->assertTrue($delete);
-
- }
-
-
- function testLastQuery() {
-
- $last_query = DB::instance($this->db_name)->last_query();
- $this->assertNotNull($last_query);
-
- }
-
- function testQueryHistory() {
-
- // Gives us back Krumo debug. If it contains the plural "elements" it's recognizing the above queries. If it's singular, it means it isn't.
- $query_history = DB::instance($this->db_name)->query_history();
-
- $needle_found = strpos($query_history, "elements");
-
- $this->assertTrue($needle_found > 0);
-
- }
-
-
- function testSelectField() {
-
- self::__insert();
-
- $q = "SELECT first_name
- FROM users
- WHERE first_name = 'Joe'";
-
- $first_name = DB::instance($this->db_name)->select_field($q);
-
- $this->assertTrue($first_name == "Joe");
-
- self::__delete();
-
-
- }
-
-
- function testSelectRow() {
-
- self::__insert();
-
- $user = DB::instance($this->db_name)->select_row("SELECT * FROM users WHERE first_name = 'Joe'");
-
- $this->assertIsA($user, 'array');
-
- self::__delete();
-
- }
-
-
- function testSelectObject() {
-
- self::__insert();
-
- $user = DB::instance($this->db_name)->select_object("SELECT * FROM users WHERE first_name = 'Joe'");
-
- $this->assertIsA($user, 'stdClass');
-
- self::__delete();
-
- }
-
-
- function testSelectRows() {
-
- self::__insert();
- self::__insert();
-
- $users = DB::instance($this->db_name)->select_rows("SELECT * FROM users");
- $this->assertTrue(sizeof($users) == 2);
-
- self::__delete();
-
- }
-
-
- function testSelectKv() {
-
- self::__insert();
- self::__insert();
-
- $users = DB::instance($this->db_name)->select_kv("SELECT user_id, first_name FROM users", "user_id", "first_name");
-
- foreach($users as $k => $v) {
- $this->assertTrue($v = "Joe");
- }
-
- self::__delete();
-
- }
-
-
- function testSelectArray() {
-
- self::__insert();
- self::__insert();
-
- $users = DB::instance($this->db_name)->select_array('SELECT * FROM users', 'first_name');
-
-
- foreach($users as $k => $v) {
- //$this->assertTrue($k == "Joe");
- }
-
- self::__delete();
-
- }
-
-
- function testUpdateOrInsertRow() {
-
- # This should be an insert
- $data = Array("first_name" => "Joe", "last_name" => "Smith");
- $user_id = DB::instance($this->db_name)->update_or_insert_row("users", $data, "WHERE 0");
- $this->assertTrue($user_id > 1);
-
- # This should be an update
- $data = Array("user_id" => $user_id, "first_name" => "Joe", "last_name" => "Roberts");
- $results = DB::instance($this->db_name)->update_or_insert_row("users", $data, "WHERE user_id = ".$user_id);
-
- # Test by making sure our table still only has one entry
- $count = DB::instance($this->db_name)->select_field("SELECT COUNT(user_id) FROM users");
- $this->assertTrue($count == 1);
-
- self::__delete();
-
-
- }
-
-
- function testUpdateOrInsertRows() {
-
- # This should be an insert
- $data[] = Array("first_name" => "Joe", "last_name" => "Smith");
- $data[] = Array("first_name" => "Jane", "last_name" => "Doe");
- $affected_rows = DB::instance($this->db_name)->update_or_insert_rows("users", $data, "WHERE 0");
- $this->assertTrue($affected_rows == 2);
-
- # Get the user_id of the field we just inserted so we can update it
- $user_id = DB::instance($this->db_name)->select_field("SELECT user_id FROM users");
-
- # This should be an update on just Joe
- $data = "";
- $data[] = Array("user_id" => $user_id, "first_name" => "Joe", "last_name" => "Roberts");
- $results = DB::instance($this->db_name)->update_or_insert_rows("users", $data, "WHERE user_id = ".$user_id);
-
- # Test by making sure our table still only has two entries
- $this->assertTrue(self::__row_count() == 2);
-
- self::__delete();
-
- }
-
-
- function testDelete() {
-
- self::__insert();
-
- DB::instance($this->db_name)->DELETE("users", "WHERE first_name = 'Joe'");
-
- $this->assertTrue(self::__row_count() == 0);
-
- }
-
-
- function testSanitize() {
-
- # Sanitize a string
- $data = "O'Brien";
- $data = DB::instance($this->db_name)->sanitize($data);
- $this->assertTrue($data == "O\'Brien");
-
- # Santize an array
- $data = Array("last_name" => "O'Brien");
- $data = DB::instance($this->db_name)->sanitize($data);
- $this->assertTrue($data['last_name'] == "O\'Brien");
-
- # Sanitize a multi-dimensional array
- $data = Array("user1" => Array("last_name" => "O'Brien"),
- "user2" => Array("last_name" => "O'Neil"),
- );
-
- $data = DB::instance($this->db_name)->sanitize($data);
- $this->assertTrue($data['user1']['last_name'] == "O\'Brien");
-
- }
-
- function testDrop() {
-
- # Don't really need to test this, but do want to delete our test database
- # Can't use __deconstruct because this class doesn't get destroyed
- DB::instance($this->db_name)->query("DROP DATABASE ".$this->db_name.";");
-
- }
-
-
- function __insert() {
- return DB::instance($this->db_name)->insert('users', Array('first_name' => 'Joe', 'last_name' => 'Smith'));
- }
-
- function __delete() {
- DB::instance($this->db_name)->query('DELETE FROM users');
- }
-
- function __row_count() {
- return DB::instance($this->db_name)->select_field("SELECT COUNT(user_id) FROM users");
- }
-
-
-
-
-}
\ No newline at end of file
diff --git a/core/libraries/Debug.php b/core/libraries/Debug.php
deleted file mode 100755
index 1c95b8b..0000000
--- a/core/libraries/Debug.php
+++ /dev/null
@@ -1,65 +0,0 @@
-DEBUG INFO '.PHP_EOL;
- echo 'Routed Controller/Method: '.Router::$controller.'/'.Router::$method.' '.PHP_EOL;
- echo 'Execution Time: '.EXECUTION_TIME.' sec'.PHP_EOL;
-
- // show mysql query history
- echo DB::instance()->query_history().PHP_EOL;
-
- // show included files
- krumo::includes(FALSE).PHP_EOL;
-
- echo ' '.PHP_EOL;
-
- // disable krumo in production
- } elseif (IN_PRODUCTION) {
-
- // disable krumo output
- krumo::disable();
-
- }
-
- }
-
-
- /*-------------------------------------------------------------------------------------------------
-
- -------------------------------------------------------------------------------------------------*/
- public static function console($message) {
- define("NL","\r\n");
- echo ''.NL;
-
- }
-
-}
\ No newline at end of file
diff --git a/core/libraries/Email.php b/core/libraries/Email.php
deleted file mode 100755
index d42ce48..0000000
--- a/core/libraries/Email.php
+++ /dev/null
@@ -1,105 +0,0 @@
-
-/*-------------------------------------------------------------------------------------------------
-Uses PHPMailer
-http://code.google.com/a/apache-extras.org/p/phpmailer/wiki/ExamplesPage
--------------------------------------------------------------------------------------------------*/
-class Email {
-
- public static function send($to = Array(), $from, $subject, $body, $html = FALSE, $cc = Array(), $bcc = Array()) {
-
- # Instantiate log to track all outgoing email
- $log = Log::instance(LOG_PATH."Email", Log::DEBUG, true);
- $log->logInfo("Controller/Method: ".Router::$controller."/".Router::$method);
-
- # Instantiate PHPMailer class
- $mail = new PHPMailer(false); # Defaults to PHP
-
- # SMTP settings are in app/config/config.php
-
- if(defined('SMTP_HOST') && defined('SMTP_USERNAME') && defined('SMTP_PASSWORD')) {
-
- $mail->IsSMTP();
-
- # Don't show error's in production
- $mail->SMTPDebug = (IN_PRODUCTION) ? 0 : 1;
-
- # SMTP settings
- $mail->Host = SMTP_HOST;
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = 'ssl';
- $mail->Port = 465;
- $mail->Username = SMTP_USERNAME;
- $mail->Password = SMTP_PASSWORD;
- }
-
- # Sender
- $mail->SetFrom($from['email'], $from['name']);
-
- # Recipient(s)
-
- # Tabula rasa
- $to_string = ""; $cc_string = ""; $bcc_string = "";
-
- # To
- foreach($to as $recipient) {
- if(ENABLE_OUTGOING_EMAIL) $mail->AddAddress($recipient['email'], $recipient['name']);
- $to_string .= $recipient['name']." (".$recipient['email']."), ";
- }
-
- # CC(s) and BCC(s) (if we have them)
- if($cc) {
- foreach($cc as $recipient) {
- if(ENABLE_OUTGOING_EMAIL) $mail->AddCC($recipient['email'], $recipient['name']);
- $cc_string .= $recipient['name']." (".$recipient['email']."), ";
- }
- }
- if($bcc) {
- foreach($bcc as $recipient) {
- if(ENABLE_OUTGOING_EMAIL) $mail->AddBCC($recipient['email'], $recipient['name']);
- $bcc_string .= $recipient['name']." (".$recipient['email']."), ";
- }
- }
-
- # Note if we've disabled outgoing emails
- if(!ENABLE_OUTGOING_EMAIL) {
- $log->logInfo("OUTGOING EMAILS ARE DISABLED. THIS EMAIL WAS NOT SENT TO THE RECIPIENTS, ONLY ".SYSTEM_EMAIL);
- $mail->AddAddress(SYSTEM_EMAIL, APP_NAME);
- }
-
- # Logging
- $log->logInfo("From: ".$from['name']." (".$from['email'].")");
- $log->logInfo("To: ".$to_string);
- $log->logInfo("CC: ".$cc_string);
- $log->logInfo("BCC: ".$bcc_string);
- $log->logInfo("Subject: ".$subject);
- $log->logInfo("Body: ".substr($body, 0, 50));
-
- # Content
- $mail->Subject = $subject;
-
- # Plain text
- if(!$html) {
- $mail->IsHTML(false);
- $mail->Body = $body;
- $mail->ContentType = 'text/plain';
- $mail->AltBody = $body;
- }
- # HTML email
- else {
- $mail->IsHTML(true);
- $mail->MsgHTML($body);
- $mail->AltBody = "To view the message, please use an HTML compatible email viewer."; # Optional, comment out and test
- }
-
- # Send email
- if(!$mail->Send()) {
- $log->logInfo("FAILED TO SEND EMAIL");
- return false;
- }
- else {
- return true;
- }
-
- } # eof
-
-} # eoc
\ No newline at end of file
diff --git a/core/libraries/File.php b/core/libraries/File.php
deleted file mode 100755
index 3ed49c0..0000000
--- a/core/libraries/File.php
+++ /dev/null
@@ -1,114 +0,0 @@
-.php"
- $file = 'c_'.str_replace('_controller', '', $class);
-
- if ($path = File::find('controllers/'.$file)) {
-
- require $path;
- return TRUE;
-
- } else {
-
- return FALSE;
-
- }
-
- // try the libraries folders
- } elseif ($path = File::find('libraries/'.$class)) {
-
- require $path;
- return TRUE;
-
- // try the vendors folders
- } elseif ($path = File::find('vendors/'.$class.'/'.$class)) {
-
- require $path;
- return TRUE;
-
- }
-
- // couldn't find the file
- return FALSE;
-
- }
-}
\ No newline at end of file
diff --git a/core/libraries/Form.php b/core/libraries/Form.php
deleted file mode 100755
index 3c4a069..0000000
--- a/core/libraries/Form.php
+++ /dev/null
@@ -1,584 +0,0 @@
- data) -- e.g. $_GET or $_POST
- public $data = array();
-
- // *optional: pretty field labels (field => label)
- public $labels = array();
-
- // *optional: error messages (field => error message)
- public $error_msgs = array();
-
- // list of fields that have validation errors
- public $errors = array();
-
- public $country_list = array(
- 'AF'=>'Afghanistan',
- 'AL'=>'Albania',
- 'DZ'=>'Algeria',
- 'AS'=>'American Samoa',
- 'AD'=>'Andorra',
- 'AO'=>'Angola',
- 'AI'=>'Anguilla',
- 'AQ'=>'Antarctica',
- 'AG'=>'Antigua And Barbuda',
- 'AR'=>'Argentina',
- 'AM'=>'Armenia',
- 'AW'=>'Aruba',
- 'AU'=>'Australia',
- 'AT'=>'Austria',
- 'AZ'=>'Azerbaijan',
- 'BS'=>'Bahamas',
- 'BH'=>'Bahrain',
- 'BD'=>'Bangladesh',
- 'BB'=>'Barbados',
- 'BY'=>'Belarus',
- 'BE'=>'Belgium',
- 'BZ'=>'Belize',
- 'BJ'=>'Benin',
- 'BM'=>'Bermuda',
- 'BT'=>'Bhutan',
- 'BO'=>'Bolivia',
- 'BA'=>'Bosnia And Herzegovina',
- 'BW'=>'Botswana',
- 'BV'=>'Bouvet Island',
- 'BR'=>'Brazil',
- 'IO'=>'British Indian Ocean Territory',
- 'BN'=>'Brunei',
- 'BG'=>'Bulgaria',
- 'BF'=>'Burkina Faso',
- 'BI'=>'Burundi',
- 'KH'=>'Cambodia',
- 'CM'=>'Cameroon',
- 'CA'=>'Canada',
- 'CV'=>'Cape Verde',
- 'KY'=>'Cayman Islands',
- 'CF'=>'Central African Republic',
- 'TD'=>'Chad',
- 'CL'=>'Chile',
- 'CN'=>'China',
- 'CX'=>'Christmas Island',
- 'CC'=>'Cocos (Keeling) Islands',
- 'CO'=>'Columbia',
- 'KM'=>'Comoros',
- 'CG'=>'Congo',
- 'CK'=>'Cook Islands',
- 'CR'=>'Costa Rica',
- 'CI'=>'Cote D\'Ivorie (Ivory Coast)',
- 'HR'=>'Croatia (Hrvatska)',
- 'CU'=>'Cuba',
- 'CY'=>'Cyprus',
- 'CZ'=>'Czech Republic',
- 'CD'=>'Democratic Republic Of Congo (Zaire)',
- 'DK'=>'Denmark',
- 'DJ'=>'Djibouti',
- 'DM'=>'Dominica',
- 'DO'=>'Dominican Republic',
- 'TP'=>'East Timor',
- 'EC'=>'Ecuador',
- 'EG'=>'Egypt',
- 'SV'=>'El Salvador',
- 'GQ'=>'Equatorial Guinea',
- 'ER'=>'Eritrea',
- 'EE'=>'Estonia',
- 'ET'=>'Ethiopia',
- 'FK'=>'Falkland Islands (Malvinas)',
- 'FO'=>'Faroe Islands',
- 'FJ'=>'Fiji',
- 'FI'=>'Finland',
- 'FR'=>'France',
- 'FX'=>'France, Metropolitan',
- 'GF'=>'French Guinea',
- 'PF'=>'French Polynesia',
- 'TF'=>'French Southern Territories',
- 'GA'=>'Gabon',
- 'GM'=>'Gambia',
- 'GE'=>'Georgia',
- 'DE'=>'Germany',
- 'GH'=>'Ghana',
- 'GI'=>'Gibraltar',
- 'GR'=>'Greece',
- 'GL'=>'Greenland',
- 'GD'=>'Grenada',
- 'GP'=>'Guadeloupe',
- 'GU'=>'Guam',
- 'GT'=>'Guatemala',
- 'GN'=>'Guinea',
- 'GW'=>'Guinea-Bissau',
- 'GY'=>'Guyana',
- 'HT'=>'Haiti',
- 'HM'=>'Heard And McDonald Islands',
- 'HN'=>'Honduras',
- 'HK'=>'Hong Kong',
- 'HU'=>'Hungary',
- 'IS'=>'Iceland',
- 'IN'=>'India',
- 'ID'=>'Indonesia',
- 'IR'=>'Iran',
- 'IQ'=>'Iraq',
- 'IE'=>'Ireland',
- 'IL'=>'Israel',
- 'IT'=>'Italy',
- 'JM'=>'Jamaica',
- 'JP'=>'Japan',
- 'JO'=>'Jordan',
- 'KZ'=>'Kazakhstan',
- 'KE'=>'Kenya',
- 'KI'=>'Kiribati',
- 'KW'=>'Kuwait',
- 'KG'=>'Kyrgyzstan',
- 'LA'=>'Laos',
- 'LV'=>'Latvia',
- 'LB'=>'Lebanon',
- 'LS'=>'Lesotho',
- 'LR'=>'Liberia',
- 'LY'=>'Libya',
- 'LI'=>'Liechtenstein',
- 'LT'=>'Lithuania',
- 'LU'=>'Luxembourg',
- 'MO'=>'Macau',
- 'MK'=>'Macedonia',
- 'MG'=>'Madagascar',
- 'MW'=>'Malawi',
- 'MY'=>'Malaysia',
- 'MV'=>'Maldives',
- 'ML'=>'Mali',
- 'MT'=>'Malta',
- 'MH'=>'Marshall Islands',
- 'MQ'=>'Martinique',
- 'MR'=>'Mauritania',
- 'MU'=>'Mauritius',
- 'YT'=>'Mayotte',
- 'MX'=>'Mexico',
- 'FM'=>'Micronesia',
- 'MD'=>'Moldova',
- 'MC'=>'Monaco',
- 'MN'=>'Mongolia',
- 'MS'=>'Montserrat',
- 'MA'=>'Morocco',
- 'MZ'=>'Mozambique',
- 'MM'=>'Myanmar (Burma)',
- 'NA'=>'Namibia',
- 'NR'=>'Nauru',
- 'NP'=>'Nepal',
- 'NL'=>'Netherlands',
- 'AN'=>'Netherlands Antilles',
- 'NC'=>'New Caledonia',
- 'NZ'=>'New Zealand',
- 'NI'=>'Nicaragua',
- 'NE'=>'Niger',
- 'NG'=>'Nigeria',
- 'NU'=>'Niue',
- 'NF'=>'Norfolk Island',
- 'KP'=>'North Korea',
- 'MP'=>'Northern Mariana Islands',
- 'NO'=>'Norway',
- 'OM'=>'Oman',
- 'PK'=>'Pakistan',
- 'PW'=>'Palau',
- 'PA'=>'Panama',
- 'PG'=>'Papua New Guinea',
- 'PY'=>'Paraguay',
- 'PE'=>'Peru',
- 'PH'=>'Philippines',
- 'PN'=>'Pitcairn',
- 'PL'=>'Poland',
- 'PT'=>'Portugal',
- 'PR'=>'Puerto Rico',
- 'QA'=>'Qatar',
- 'RE'=>'Reunion',
- 'RO'=>'Romania',
- 'RU'=>'Russia',
- 'RW'=>'Rwanda',
- 'SH'=>'Saint Helena',
- 'KN'=>'Saint Kitts And Nevis',
- 'LC'=>'Saint Lucia',
- 'PM'=>'Saint Pierre And Miquelon',
- 'VC'=>'Saint Vincent And The Grenadines',
- 'SM'=>'San Marino',
- 'ST'=>'Sao Tome And Principe',
- 'SA'=>'Saudi Arabia',
- 'SN'=>'Senegal',
- 'SC'=>'Seychelles',
- 'SL'=>'Sierra Leone',
- 'SG'=>'Singapore',
- 'SK'=>'Slovak Republic',
- 'SI'=>'Slovenia',
- 'SB'=>'Solomon Islands',
- 'SO'=>'Somalia',
- 'ZA'=>'South Africa',
- 'GS'=>'South Georgia And South Sandwich Islands',
- 'KR'=>'South Korea',
- 'ES'=>'Spain',
- 'LK'=>'Sri Lanka',
- 'SD'=>'Sudan',
- 'SR'=>'Suriname',
- 'SJ'=>'Svalbard And Jan Mayen',
- 'SZ'=>'Swaziland',
- 'SE'=>'Sweden',
- 'CH'=>'Switzerland',
- 'SY'=>'Syria',
- 'TW'=>'Taiwan',
- 'TJ'=>'Tajikistan',
- 'TZ'=>'Tanzania',
- 'TH'=>'Thailand',
- 'TG'=>'Togo',
- 'TK'=>'Tokelau',
- 'TO'=>'Tonga',
- 'TT'=>'Trinidad And Tobago',
- 'TN'=>'Tunisia',
- 'TR'=>'Turkey',
- 'TM'=>'Turkmenistan',
- 'TC'=>'Turks And Caicos Islands',
- 'TV'=>'Tuvalu',
- 'UG'=>'Uganda',
- 'UA'=>'Ukraine',
- 'AE'=>'United Arab Emirates',
- 'UK'=>'United Kingdom',
- 'US'=>'United States',
- 'UM'=>'United States Minor Outlying Islands',
- 'UY'=>'Uruguay',
- 'UZ'=>'Uzbekistan',
- 'VU'=>'Vanuatu',
- 'VA'=>'Vatican City (Holy See)',
- 'VE'=>'Venezuela',
- 'VN'=>'Vietnam',
- 'VG'=>'Virgin Islands (British)',
- 'VI'=>'Virgin Islands (US)',
- 'WF'=>'Wallis And Futuna Islands',
- 'EH'=>'Western Sahara',
- 'WS'=>'Western Samoa',
- 'YE'=>'Yemen',
- 'YU'=>'Yugoslavia',
- 'ZM'=>'Zambia',
- 'ZW'=>'Zimbabwe'
- );
-
- public $state_list = array(
- '' => "Choose...",
- 'AL'=>"Alabama",
- 'AK'=>"Alaska",
- 'AZ'=>"Arizona",
- 'AR'=>"Arkansas",
- 'CA'=>"California",
- 'CO'=>"Colorado",
- 'CT'=>"Connecticut",
- 'DE'=>"Delaware",
- 'DC'=>"District Of Columbia",
- 'FL'=>"Florida",
- 'GA'=>"Georgia",
- 'HI'=>"Hawaii",
- 'ID'=>"Idaho",
- 'IL'=>"Illinois",
- 'IN'=>"Indiana",
- 'IA'=>"Iowa",
- 'KS'=>"Kansas",
- 'KY'=>"Kentucky",
- 'LA'=>"Louisiana",
- 'ME'=>"Maine",
- 'MD'=>"Maryland",
- 'MA'=>"Massachusetts",
- 'MI'=>"Michigan",
- 'MN'=>"Minnesota",
- 'MS'=>"Mississippi",
- 'MO'=>"Missouri",
- 'MT'=>"Montana",
- 'NE'=>"Nebraska",
- 'NV'=>"Nevada",
- 'NH'=>"New Hampshire",
- 'NJ'=>"New Jersey",
- 'NM'=>"New Mexico",
- 'NY'=>"New York",
- 'NC'=>"North Carolina",
- 'ND'=>"North Dakota",
- 'OH'=>"Ohio",
- 'OK'=>"Oklahoma",
- 'OR'=>"Oregon",
- 'PA'=>"Pennsylvania",
- 'RI'=>"Rhode Island",
- 'SC'=>"South Carolina",
- 'SD'=>"South Dakota",
- 'TN'=>"Tennessee",
- 'TX'=>"Texas",
- 'UT'=>"Utah",
- 'VT'=>"Vermont",
- 'VA'=>"Virginia",
- 'WA'=>"Washington",
- 'WV'=>"West Virginia",
- 'WI'=>"Wisconsin",
- 'WY'=>"Wyoming");
-
- // construct with form data (pass in $_POST or $_GET)
- public function __construct($data = NULL, $strip_slashes = FALSE, $strip_html = FALSE) {
-
- // stripslashes on input data
- $this->strip_slashes = $strip_slashes;
-
- // stripslashes on input data
- $this->strip_html = $strip_html;
-
- // clean input data and optionally stripslashes/strip_tags
- if ($data !== NULL)
- $this->data = self::clean_data($data, $strip_slashes, $strip_html);
-
- }
-
- // set form defaults
- public function defaults(array $defaults) {
-
- // first clean defaults
- $defaults = self::clean_data($defaults);
-
- // merge defaults with data, not overwriting any existing fields
- $this->data = array_merge($defaults, $this->data);
-
- }
-
- public function open($name = 'form', $action = NULL, $html = NULL, $method = 'post') {
-
- // init HTML form
- echo '
- *
- * @access public
- * @static
- */
- Public Static Function phpini() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- if (!readable(get_cfg_var('cfg_file_path'))) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of the configuration settings read from
.
-
-
-
-This is a list of all your configuration settings.
-
- include_path option.
- *
- * @access public
- * @static
- */
- Public Static Function path() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of the specified directories under your include_path
option.
-
- $_REQUEST array.
- *
- * @access public
- * @static
- */
- Public Static Function request() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of all the values from the $_REQUEST
array.
-
- $_GET array.
- *
- * @access public
- * @static
- */
- Public Static Function get() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of all the values from the $_GET
array.
-
- $_POST array.
- *
- * @access public
- * @static
- */
- Public Static Function post() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of all the values from the $_POST
array.
-
- $_SERVER array.
- *
- * @access public
- * @static
- */
- Public Static Function server() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of all the values from the $_SERVER
array.
-
- $_COOKIE array.
- *
- * @access public
- * @static
- */
- Public Static Function cookie() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of all the values from the $_COOKIE
array.
-
- $_ENV array.
- *
- * @access public
- * @static
- */
- Public Static Function env() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of all the values from the $_ENV
array.
-
- $_SESSION array.
- *
- * @access public
- * @static
- */
- Public Static Function session() {
-
- // disabled ?
- //
- if (!krumo::_debug()) {
- return false;
- }
-
- // render it
- //
- ?>
-
-This is a list of all the values from the $_SESSION
array.
-
-
-
-This is a list of all the values from the
INI file.
-
- 1) {
- $_ = func_get_args();
- foreach($_ as $d) {
- krumo::dump($d);
- }
- return;
- }
- */
-
- // the css ?
- //
- krumo::_css();
-
- // find caller
- //
- $_ = debug_backtrace();
-
- while($d = array_pop($_)) {
- if ((strToLower($d['function']) == 'krumo') || (strToLower(@$d['class']) == 'krumo')) {
- break;
- }
- }
-
- // the content
- //
- ?>
-
-$bee){
- if (is_object($bee)) {
- unset($hive[$i]->$_recursion_marker);
- } else {
- unset($hive[$i][$_recursion_marker]);
- }
- }
- }
-
- // PHP 4.x.x array reference bug...
- //
- if (is_array($data) && version_compare(PHP_VERSION, "5", "<")) {
- unset($GLOBALS[krumo::_marker()]);
- }
- }
-
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-
- /**
- * Returns values from Krumo's configuration
- *
- * @param string $group
- * @param string $name
- * @param mixed $fallback
- * @return mixed
- *
- * @access private
- * @static
- */
- Private Static Function _config($group, $name, $fallback=null) {
-
- static $_config = array();
-
- // not loaded ?
- //
- if (empty($_config)) {
- $_config = (array) @parse_ini_file(
- KRUMO_DIR . 'krumo.ini',
- true);
- }
-
- // exists ?
- //
- return (isset($_config[$group][$name]))
- ? $_config[$group][$name]
- : $fallback;
- }
-
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-
- /**
- * Print the skin (CSS)
- *
- * @return boolean
- * @access private
- * @static
- */
- Private Static Function _css() {
-
- static $_css = false;
-
- // already set ?
- //
- if ($_css) {
- return true;
- }
-
- $css = '';
- $skin = krumo::_config('skin', 'selected', 'default');
-
- // custom selected skin ?
- //
- $_ = KRUMO_DIR . "skins/{$skin}/skin.css";
- if ($fp = @fopen($_, 'r', 1)) {
- $css = fread($fp, filesize($_));
- fclose($fp);
- }
-
- // defautl skin ?
- //
- if (!$css && ($skin != 'default')) {
- $skin = 'default';
- $_ = KRUMO_DIR . "skins/default/skin.css";
- $css = join('', @file($_));
- }
-
- // print ?
- //
- if ($_css = $css != '') {
-
- // fix the urls
- //
- $css_url = krumo::_config('css', 'url') . "skins/{$skin}/";
- $css = preg_replace('~%url%~Uis', $css_url, $css);
-
- // the CSS
- //
- ?>
-
-
-
-
-
-
-
-
-$_recursion_marker++)
- : @($bee[$_recursion_marker]++);
-
- $_[0][] =& $bee;
- }
-
- // return all bees
- //
- return $_[0];
- }
-
- // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-
- /**
- * Render a dump for the properties of an array or objeect
- *
- * @param mixed &$data
- * @access private
- * @static
- */
- Private Static Function _vars(&$data) {
-
- $_is_object = is_object($data);
-
- // test for references in order to
- // prevent endless recursion loops
- //
- $_recursion_marker = krumo::_marker();
- $_r = ($_is_object)
- ? @$data->$_recursion_marker
- : @$data[$_recursion_marker] ;
- $_r = (integer) $_r;
-
- // recursion detected
- //
- if ($_r > 0) {
- return krumo::_recursion();
- }
-
- // stain it
- //
- krumo::_hive($data);
-
- // render it
- //
- ?>
-
-
- $k;
- } else {
- $v =& $data[$k];
- }
-
- krumo::_dump($v,$k);
- } ?>
-
-
-
-
-
-
-
- 0) {?> onClick="krumo.toggle(this);"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
-
-
- (
Array, )
-
-
-
-
|
- (Callback )
- ::();
-
-
-
-
-
-
-
-
-
- 0) {?> onClick="krumo.toggle(this);"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
-
-
- (
Object )
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- KRUMO_TRUNCATE_LENGTH) {
- $_ = substr($data, 0, KRUMO_TRUNCATE_LENGTH - 3) . '...';
- $_extra = true;
- }
-?>
-
-
- onClick="krumo.toggle(this);"
- onMouseOver="krumo.over(this);"
- onMouseOut="krumo.out(this);">
-
-
- (
String,
- characters )
-
-
-
-
|
- (Callback )
- ();
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/core/vendors/krumo/skins/green/bg.gif b/core/vendors/krumo/skins/green/bg.gif
deleted file mode 100755
index aa4e75ec1636ec9332fe79436b641ac71b89604c..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 141
zcmZ?wbhEHbjAGzq*v!E2|Nno6GzNx^3`7FOpDc_Zr8*!2WCjC^RX~fv%QZi;P8Z*g
z
-*/
-
-/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
-
-ul.krumo-node {
- margin: 0px;
- padding: 0px;
- }
-ul.krumo-node ul {
- margin-left: 20px;
- }
-* html ul.krumo-node ul {
- margin-left: 24px;
- }
-div.krumo-root {
- border: solid 1px black;
- margin: 1em 0em;
- }
-ul.krumo-first {
- font: normal 12px arial;
- border: solid 2px white;
- border-top-width:1px;
- background: url(%url%bg.gif);
- }
-
-/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
-
-li.krumo-child {
- display:block;
- list-style: none;
- padding: 0px;
- margin: 0px;
- overflow:hidden;
- }
-div.krumo-element {
- cursor:default;
-
- line-height: 24px;
- display:block;
-
- clear:both;
- white-space:nowrap;
-
- border-top: solid 1px white;
- background: #D7F4CA;
- padding-left: 10px;
- }
-* html div.krumo-element {
- padding-bottom: 3px;
- }
-a.krumo-name {
- color:#004000;
- font: bold 13px Arial;
- }
-a.krumo-name big {
- font: bold 20pt Georgia;
- line-height: 14px;
- position:relative;
- top:2px;
- left:-2px;
- }
-* html a.krumo-name big {
- font: bold 19pt Georgia;
- top: 5px;
- left: 0px;
- line-height: 9px;
- height: 12px;
- padding: 0px;
- margin: 0px;
- }
-div.krumo-expand {
- background: #C0EEAC;
- cursor:pointer;
- }
-div.krumo-hover {
- background: gold;
- }
-
-/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
-
-div.krumo-preview {
- font: normal 13px courier new;
- padding: 5px 5px 14px 5px;
- background: white;
- border-top: 0px;
- overflow:auto;
- }
-* html div.krumo-preview {
- padding-top: 2px;
- }
-
-/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
-
-li.krumo-footnote {
- background:white;
- padding: 2px 5px;
- list-style:none;
- border-top: solid 1px #bebebe;
- margin-top:2px;
- cursor:default;
- }
-* html li.krumo-footnote {
- line-height: 13px;
- }
-div.krumo-version {
- float:right;
- }
-li.krumo-footnote h6 {
- font: bold 11px verdana;
- margin: 0px;
- padding: 0px;
- color:#008040;
- display:inline;
- }
-* html li.krumo-footnote h6 {
- margin-right: 3px;
- }
-li.krumo-footnote a {
- font: bold 10px arial;
- color: #434343;
- text-decoration:none;
- }
-li.krumo-footnote a:hover {
- color:black;
- }
-
-li.krumo-footnote span.krumo-call {
- font:normal 11px verdana;
- position: relative;
- top: 1px;
- }
-li.krumo-footnote span.krumo-call code {
- font-weight:bold;
- }
-
-/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
-
-div.krumo-title {
- font: normal 11px verdana ;
- position:relative;
- top:9px;
- cursor:default;
- line-height:2px;
- }
-
-/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
-
-strong.krumo-array-length,
-strong.krumo-string-length {
- font-weight: normal;
- }
-
-/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
diff --git a/core/vendors/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE b/core/vendors/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE
deleted file mode 100755
index a65e83e..0000000
--- a/core/vendors/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE
+++ /dev/null
@@ -1,399 +0,0 @@
-Simple Test interface changes
-=============================
-Because the SimpleTest tool set is still evolving it is likely that tests
-written with earlier versions will fail with the newest ones. The most
-dramatic changes are in the alpha releases. Here is a list of possible
-problems and their fixes...
-
-assertText() no longer finds a string inside a ', 'js');
- $this->mapHandler('comment', 'ignore');
- $this->addEntryPattern('', 'comment');
- }
-
- /**
- * Pattern matches to start and end a tag.
- * @param string $tag Name of tag to scan for.
- * @access private
- */
- protected function addTag($tag) {
- $this->addSpecialPattern("$tag>", 'text', 'acceptEndToken');
- $this->addEntryPattern("<$tag", 'text', 'tag');
- }
-
- /**
- * Pattern matches to parse the inside of a tag
- * including the attributes and their quoting.
- * @access private
- */
- protected function addInTagTokens() {
- $this->mapHandler('tag', 'acceptStartToken');
- $this->addSpecialPattern('\s+', 'tag', 'ignore');
- $this->addAttributeTokens();
- $this->addExitPattern('/>', 'tag');
- $this->addExitPattern('>', 'tag');
- }
-
- /**
- * Matches attributes that are either single quoted,
- * double quoted or unquoted.
- * @access private
- */
- protected function addAttributeTokens() {
- $this->mapHandler('dq_attribute', 'acceptAttributeToken');
- $this->addEntryPattern('=\s*"', 'tag', 'dq_attribute');
- $this->addPattern("\\\\\"", 'dq_attribute');
- $this->addExitPattern('"', 'dq_attribute');
- $this->mapHandler('sq_attribute', 'acceptAttributeToken');
- $this->addEntryPattern("=\s*'", 'tag', 'sq_attribute');
- $this->addPattern("\\\\'", 'sq_attribute');
- $this->addExitPattern("'", 'sq_attribute');
- $this->mapHandler('uq_attribute', 'acceptAttributeToken');
- $this->addSpecialPattern('=\s*[^>\s]*', 'tag', 'uq_attribute');
- }
-}
-
-/**
- * Converts HTML tokens into selected SAX events.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleHtmlSaxParser {
- private $lexer;
- private $listener;
- private $tag;
- private $attributes;
- private $current_attribute;
-
- /**
- * Sets the listener.
- * @param SimplePhpPageBuilder $listener SAX event handler.
- * @access public
- */
- function __construct($listener) {
- $this->listener = $listener;
- $this->lexer = $this->createLexer($this);
- $this->tag = '';
- $this->attributes = array();
- $this->current_attribute = '';
- }
-
- /**
- * Runs the content through the lexer which
- * should call back to the acceptors.
- * @param string $raw Page text to parse.
- * @return boolean False if parse error.
- * @access public
- */
- function parse($raw) {
- return $this->lexer->parse($raw);
- }
-
- /**
- * Sets up the matching lexer. Starts in 'text' mode.
- * @param SimpleSaxParser $parser Event generator, usually $self.
- * @return SimpleLexer Lexer suitable for this parser.
- * @access public
- */
- static function createLexer(&$parser) {
- return new SimpleHtmlLexer($parser);
- }
-
- /**
- * Accepts a token from the tag mode. If the
- * starting element completes then the element
- * is dispatched and the current attributes
- * set back to empty. The element or attribute
- * name is converted to lower case.
- * @param string $token Incoming characters.
- * @param integer $event Lexer event type.
- * @return boolean False if parse error.
- * @access public
- */
- function acceptStartToken($token, $event) {
- if ($event == LEXER_ENTER) {
- $this->tag = strtolower(substr($token, 1));
- return true;
- }
- if ($event == LEXER_EXIT) {
- $success = $this->listener->startElement(
- $this->tag,
- $this->attributes);
- $this->tag = '';
- $this->attributes = array();
- return $success;
- }
- if ($token != '=') {
- $this->current_attribute = strtolower(html_entity_decode($token, ENT_QUOTES));
- $this->attributes[$this->current_attribute] = '';
- }
- return true;
- }
-
- /**
- * Accepts a token from the end tag mode.
- * The element name is converted to lower case.
- * @param string $token Incoming characters.
- * @param integer $event Lexer event type.
- * @return boolean False if parse error.
- * @access public
- */
- function acceptEndToken($token, $event) {
- if (! preg_match('/<\/(.*)>/', $token, $matches)) {
- return false;
- }
- return $this->listener->endElement(strtolower($matches[1]));
- }
-
- /**
- * Part of the tag data.
- * @param string $token Incoming characters.
- * @param integer $event Lexer event type.
- * @return boolean False if parse error.
- * @access public
- */
- function acceptAttributeToken($token, $event) {
- if ($this->current_attribute) {
- if ($event == LEXER_UNMATCHED) {
- $this->attributes[$this->current_attribute] .=
- html_entity_decode($token, ENT_QUOTES);
- }
- if ($event == LEXER_SPECIAL) {
- $this->attributes[$this->current_attribute] .=
- preg_replace('/^=\s*/' , '', html_entity_decode($token, ENT_QUOTES));
- }
- }
- return true;
- }
-
- /**
- * A character entity.
- * @param string $token Incoming characters.
- * @param integer $event Lexer event type.
- * @return boolean False if parse error.
- * @access public
- */
- function acceptEntityToken($token, $event) {
- }
-
- /**
- * Character data between tags regarded as
- * important.
- * @param string $token Incoming characters.
- * @param integer $event Lexer event type.
- * @return boolean False if parse error.
- * @access public
- */
- function acceptTextToken($token, $event) {
- return $this->listener->addContent($token);
- }
-
- /**
- * Incoming data to be ignored.
- * @param string $token Incoming characters.
- * @param integer $event Lexer event type.
- * @return boolean False if parse error.
- * @access public
- */
- function ignore($token, $event) {
- return true;
- }
-}
-
-/**
- * SAX event handler. Maintains a list of
- * open tags and dispatches them as they close.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimplePhpPageBuilder {
- private $tags;
- private $page;
- private $private_content_tag;
- private $open_forms = array();
- private $complete_forms = array();
- private $frameset = false;
- private $loading_frames = array();
- private $frameset_nesting_level = 0;
- private $left_over_labels = array();
-
- /**
- * Frees up any references so as to allow the PHP garbage
- * collection from unset() to work.
- * @access public
- */
- function free() {
- unset($this->tags);
- unset($this->page);
- unset($this->private_content_tags);
- $this->open_forms = array();
- $this->complete_forms = array();
- $this->frameset = false;
- $this->loading_frames = array();
- $this->frameset_nesting_level = 0;
- $this->left_over_labels = array();
- }
-
- /**
- * This builder is always available.
- * @return boolean Always true.
- */
- function can() {
- return true;
- }
-
- /**
- * Reads the raw content and send events
- * into the page to be built.
- * @param $response SimpleHttpResponse Fetched response.
- * @return SimplePage Newly parsed page.
- * @access public
- */
- function parse($response) {
- $this->tags = array();
- $this->page = $this->createPage($response);
- $parser = $this->createParser($this);
- $parser->parse($response->getContent());
- $this->acceptPageEnd();
- $page = $this->page;
- $this->free();
- return $page;
- }
-
- /**
- * Creates an empty page.
- * @return SimplePage New unparsed page.
- * @access protected
- */
- protected function createPage($response) {
- return new SimplePage($response);
- }
-
- /**
- * Creates the parser used with the builder.
- * @param SimplePhpPageBuilder $listener Target of parser.
- * @return SimpleSaxParser Parser to generate
- * events for the builder.
- * @access protected
- */
- protected function createParser(&$listener) {
- return new SimpleHtmlSaxParser($listener);
- }
-
- /**
- * Start of element event. Opens a new tag.
- * @param string $name Element name.
- * @param hash $attributes Attributes without content
- * are marked as true.
- * @return boolean False on parse error.
- * @access public
- */
- function startElement($name, $attributes) {
- $factory = new SimpleTagBuilder();
- $tag = $factory->createTag($name, $attributes);
- if (! $tag) {
- return true;
- }
- if ($tag->getTagName() == 'label') {
- $this->acceptLabelStart($tag);
- $this->openTag($tag);
- return true;
- }
- if ($tag->getTagName() == 'form') {
- $this->acceptFormStart($tag);
- return true;
- }
- if ($tag->getTagName() == 'frameset') {
- $this->acceptFramesetStart($tag);
- return true;
- }
- if ($tag->getTagName() == 'frame') {
- $this->acceptFrame($tag);
- return true;
- }
- if ($tag->isPrivateContent() && ! isset($this->private_content_tag)) {
- $this->private_content_tag = &$tag;
- }
- if ($tag->expectEndTag()) {
- $this->openTag($tag);
- return true;
- }
- $this->acceptTag($tag);
- return true;
- }
-
- /**
- * End of element event.
- * @param string $name Element name.
- * @return boolean False on parse error.
- * @access public
- */
- function endElement($name) {
- if ($name == 'label') {
- $this->acceptLabelEnd();
- return true;
- }
- if ($name == 'form') {
- $this->acceptFormEnd();
- return true;
- }
- if ($name == 'frameset') {
- $this->acceptFramesetEnd();
- return true;
- }
- if ($this->hasNamedTagOnOpenTagStack($name)) {
- $tag = array_pop($this->tags[$name]);
- if ($tag->isPrivateContent() && $this->private_content_tag->getTagName() == $name) {
- unset($this->private_content_tag);
- }
- $this->addContentTagToOpenTags($tag);
- $this->acceptTag($tag);
- return true;
- }
- return true;
- }
-
- /**
- * Test to see if there are any open tags awaiting
- * closure that match the tag name.
- * @param string $name Element name.
- * @return boolean True if any are still open.
- * @access private
- */
- protected function hasNamedTagOnOpenTagStack($name) {
- return isset($this->tags[$name]) && (count($this->tags[$name]) > 0);
- }
-
- /**
- * Unparsed, but relevant data. The data is added
- * to every open tag.
- * @param string $text May include unparsed tags.
- * @return boolean False on parse error.
- * @access public
- */
- function addContent($text) {
- if (isset($this->private_content_tag)) {
- $this->private_content_tag->addContent($text);
- } else {
- $this->addContentToAllOpenTags($text);
- }
- return true;
- }
-
- /**
- * Any content fills all currently open tags unless it
- * is part of an option tag.
- * @param string $text May include unparsed tags.
- * @access private
- */
- protected function addContentToAllOpenTags($text) {
- foreach (array_keys($this->tags) as $name) {
- for ($i = 0, $count = count($this->tags[$name]); $i < $count; $i++) {
- $this->tags[$name][$i]->addContent($text);
- }
- }
- }
-
- /**
- * Parsed data in tag form. The parsed tag is added
- * to every open tag. Used for adding options to select
- * fields only.
- * @param SimpleTag $tag Option tags only.
- * @access private
- */
- protected function addContentTagToOpenTags(&$tag) {
- if ($tag->getTagName() != 'option') {
- return;
- }
- foreach (array_keys($this->tags) as $name) {
- for ($i = 0, $count = count($this->tags[$name]); $i < $count; $i++) {
- $this->tags[$name][$i]->addTag($tag);
- }
- }
- }
-
- /**
- * Opens a tag for receiving content. Multiple tags
- * will be receiving input at the same time.
- * @param SimpleTag $tag New content tag.
- * @access private
- */
- protected function openTag($tag) {
- $name = $tag->getTagName();
- if (! in_array($name, array_keys($this->tags))) {
- $this->tags[$name] = array();
- }
- $this->tags[$name][] = $tag;
- }
-
- /**
- * Adds a tag to the page.
- * @param SimpleTag $tag Tag to accept.
- * @access public
- */
- protected function acceptTag($tag) {
- if ($tag->getTagName() == "a") {
- $this->page->addLink($tag);
- } elseif ($tag->getTagName() == "base") {
- $this->page->setBase($tag->getAttribute('href'));
- } elseif ($tag->getTagName() == "title") {
- $this->page->setTitle($tag);
- } elseif ($this->isFormElement($tag->getTagName())) {
- for ($i = 0; $i < count($this->open_forms); $i++) {
- $this->open_forms[$i]->addWidget($tag);
- }
- $this->last_widget = $tag;
- }
- }
-
- /**
- * Opens a label for a described widget.
- * @param SimpleFormTag $tag Tag to accept.
- * @access public
- */
- protected function acceptLabelStart($tag) {
- $this->label = $tag;
- unset($this->last_widget);
- }
-
- /**
- * Closes the most recently opened label.
- * @access public
- */
- protected function acceptLabelEnd() {
- if (isset($this->label)) {
- if (isset($this->last_widget)) {
- $this->last_widget->setLabel($this->label->getText());
- unset($this->last_widget);
- } else {
- $this->left_over_labels[] = SimpleTestCompatibility::copy($this->label);
- }
- unset($this->label);
- }
- }
-
- /**
- * Tests to see if a tag is a possible form
- * element.
- * @param string $name HTML element name.
- * @return boolean True if form element.
- * @access private
- */
- protected function isFormElement($name) {
- return in_array($name, array('input', 'button', 'textarea', 'select'));
- }
-
- /**
- * Opens a form. New widgets go here.
- * @param SimpleFormTag $tag Tag to accept.
- * @access public
- */
- protected function acceptFormStart($tag) {
- $this->open_forms[] = new SimpleForm($tag, $this->page);
- }
-
- /**
- * Closes the most recently opened form.
- * @access public
- */
- protected function acceptFormEnd() {
- if (count($this->open_forms)) {
- $this->complete_forms[] = array_pop($this->open_forms);
- }
- }
-
- /**
- * Opens a frameset. A frameset may contain nested
- * frameset tags.
- * @param SimpleFramesetTag $tag Tag to accept.
- * @access public
- */
- protected function acceptFramesetStart($tag) {
- if (! $this->isLoadingFrames()) {
- $this->frameset = $tag;
- }
- $this->frameset_nesting_level++;
- }
-
- /**
- * Closes the most recently opened frameset.
- * @access public
- */
- protected function acceptFramesetEnd() {
- if ($this->isLoadingFrames()) {
- $this->frameset_nesting_level--;
- }
- }
-
- /**
- * Takes a single frame tag and stashes it in
- * the current frame set.
- * @param SimpleFrameTag $tag Tag to accept.
- * @access public
- */
- protected function acceptFrame($tag) {
- if ($this->isLoadingFrames()) {
- if ($tag->getAttribute('src')) {
- $this->loading_frames[] = $tag;
- }
- }
- }
-
- /**
- * Test to see if in the middle of reading
- * a frameset.
- * @return boolean True if inframeset.
- * @access private
- */
- protected function isLoadingFrames() {
- return $this->frameset and $this->frameset_nesting_level > 0;
- }
-
- /**
- * Marker for end of complete page. Any work in
- * progress can now be closed.
- * @access public
- */
- protected function acceptPageEnd() {
- while (count($this->open_forms)) {
- $this->complete_forms[] = array_pop($this->open_forms);
- }
- foreach ($this->left_over_labels as $label) {
- for ($i = 0, $count = count($this->complete_forms); $i < $count; $i++) {
- $this->complete_forms[$i]->attachLabelBySelector(
- new SimpleById($label->getFor()),
- $label->getText());
- }
- }
- $this->page->setForms($this->complete_forms);
- $this->page->setFrames($this->loading_frames);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/recorder.php b/core/vendors/simpletest/recorder.php
deleted file mode 100755
index b3d0d01..0000000
--- a/core/vendors/simpletest/recorder.php
+++ /dev/null
@@ -1,101 +0,0 @@
-time, $this->breadcrumb, $this->message) =
- array(time(), $breadcrumb, $message);
- }
-}
-
-/**
- * A single pass captured for later.
- * @package SimpleTest
- * @subpackage Extensions
- */
-class SimpleResultOfPass extends SimpleResult { }
-
-/**
- * A single failure captured for later.
- * @package SimpleTest
- * @subpackage Extensions
- */
-class SimpleResultOfFail extends SimpleResult { }
-
-/**
- * A single exception captured for later.
- * @package SimpleTest
- * @subpackage Extensions
- */
-class SimpleResultOfException extends SimpleResult { }
-
-/**
- * Array-based test recorder. Returns an array
- * with timestamp, status, test name and message for each pass and failure.
- * @package SimpleTest
- * @subpackage Extensions
- */
-class Recorder extends SimpleReporterDecorator {
- public $results = array();
-
- /**
- * Stashes the pass as a SimpleResultOfPass
- * for later retrieval.
- * @param string $message Pass message to be displayed
- * eventually.
- */
- function paintPass($message) {
- parent::paintPass($message);
- $this->results[] = new SimpleResultOfPass(parent::getTestList(), $message);
- }
-
- /**
- * Stashes the fail as a SimpleResultOfFail
- * for later retrieval.
- * @param string $message Failure message to be displayed
- * eventually.
- */
- function paintFail($message) {
- parent::paintFail($message);
- $this->results[] = new SimpleResultOfFail(parent::getTestList(), $message);
- }
-
- /**
- * Stashes the exception as a SimpleResultOfException
- * for later retrieval.
- * @param string $message Exception message to be displayed
- * eventually.
- */
- function paintException($message) {
- parent::paintException($message);
- $this->results[] = new SimpleResultOfException(parent::getTestList(), $message);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/reflection_php4.php b/core/vendors/simpletest/reflection_php4.php
deleted file mode 100755
index 39801ea..0000000
--- a/core/vendors/simpletest/reflection_php4.php
+++ /dev/null
@@ -1,136 +0,0 @@
-_interface = $interface;
- }
-
- /**
- * Checks that a class has been declared.
- * @return boolean True if defined.
- * @access public
- */
- function classExists() {
- return class_exists($this->_interface);
- }
-
- /**
- * Needed to kill the autoload feature in PHP5
- * for classes created dynamically.
- * @return boolean True if defined.
- * @access public
- */
- function classExistsSansAutoload() {
- return class_exists($this->_interface);
- }
-
- /**
- * Checks that a class or interface has been
- * declared.
- * @return boolean True if defined.
- * @access public
- */
- function classOrInterfaceExists() {
- return class_exists($this->_interface);
- }
-
- /**
- * Needed to kill the autoload feature in PHP5
- * for classes created dynamically.
- * @return boolean True if defined.
- * @access public
- */
- function classOrInterfaceExistsSansAutoload() {
- return class_exists($this->_interface);
- }
-
- /**
- * Gets the list of methods on a class or
- * interface.
- * @returns array List of method names.
- * @access public
- */
- function getMethods() {
- return get_class_methods($this->_interface);
- }
-
- /**
- * Gets the list of interfaces from a class. If the
- * class name is actually an interface then just that
- * interface is returned.
- * @returns array List of interfaces.
- * @access public
- */
- function getInterfaces() {
- return array();
- }
-
- /**
- * Finds the parent class name.
- * @returns string Parent class name.
- * @access public
- */
- function getParent() {
- return strtolower(get_parent_class($this->_interface));
- }
-
- /**
- * Determines if the class is abstract, which for PHP 4
- * will never be the case.
- * @returns boolean True if abstract.
- * @access public
- */
- function isAbstract() {
- return false;
- }
-
- /**
- * Determines if the the entity is an interface, which for PHP 4
- * will never be the case.
- * @returns boolean True if interface.
- * @access public
- */
- function isInterface() {
- return false;
- }
-
- /**
- * Scans for final methods, but as it's PHP 4 there
- * aren't any.
- * @returns boolean True if the class has a final method.
- * @access public
- */
- function hasFinal() {
- return false;
- }
-
- /**
- * Gets the source code matching the declaration
- * of a method.
- * @param string $method Method name.
- * @access public
- */
- function getSignature($method) {
- return "function &$method()";
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/reflection_php5.php b/core/vendors/simpletest/reflection_php5.php
deleted file mode 100755
index 43d8a7b..0000000
--- a/core/vendors/simpletest/reflection_php5.php
+++ /dev/null
@@ -1,386 +0,0 @@
-interface = $interface;
- }
-
- /**
- * Checks that a class has been declared. Versions
- * before PHP5.0.2 need a check that it's not really
- * an interface.
- * @return boolean True if defined.
- * @access public
- */
- function classExists() {
- if (! class_exists($this->interface)) {
- return false;
- }
- $reflection = new ReflectionClass($this->interface);
- return ! $reflection->isInterface();
- }
-
- /**
- * Needed to kill the autoload feature in PHP5
- * for classes created dynamically.
- * @return boolean True if defined.
- * @access public
- */
- function classExistsSansAutoload() {
- return class_exists($this->interface, false);
- }
-
- /**
- * Checks that a class or interface has been
- * declared.
- * @return boolean True if defined.
- * @access public
- */
- function classOrInterfaceExists() {
- return $this->classOrInterfaceExistsWithAutoload($this->interface, true);
- }
-
- /**
- * Needed to kill the autoload feature in PHP5
- * for classes created dynamically.
- * @return boolean True if defined.
- * @access public
- */
- function classOrInterfaceExistsSansAutoload() {
- return $this->classOrInterfaceExistsWithAutoload($this->interface, false);
- }
-
- /**
- * Needed to select the autoload feature in PHP5
- * for classes created dynamically.
- * @param string $interface Class or interface name.
- * @param boolean $autoload True totriggerautoload.
- * @return boolean True if interface defined.
- * @access private
- */
- protected function classOrInterfaceExistsWithAutoload($interface, $autoload) {
- if (function_exists('interface_exists')) {
- if (interface_exists($this->interface, $autoload)) {
- return true;
- }
- }
- return class_exists($this->interface, $autoload);
- }
-
- /**
- * Gets the list of methods on a class or
- * interface.
- * @returns array List of method names.
- * @access public
- */
- function getMethods() {
- return array_unique(get_class_methods($this->interface));
- }
-
- /**
- * Gets the list of interfaces from a class. If the
- * class name is actually an interface then just that
- * interface is returned.
- * @returns array List of interfaces.
- * @access public
- */
- function getInterfaces() {
- $reflection = new ReflectionClass($this->interface);
- if ($reflection->isInterface()) {
- return array($this->interface);
- }
- return $this->onlyParents($reflection->getInterfaces());
- }
-
- /**
- * Gets the list of methods for the implemented
- * interfaces only.
- * @returns array List of enforced method signatures.
- * @access public
- */
- function getInterfaceMethods() {
- $methods = array();
- foreach ($this->getInterfaces() as $interface) {
- $methods = array_merge($methods, get_class_methods($interface));
- }
- return array_unique($methods);
- }
-
- /**
- * Checks to see if the method signature has to be tightly
- * specified.
- * @param string $method Method name.
- * @returns boolean True if enforced.
- * @access private
- */
- protected function isInterfaceMethod($method) {
- return in_array($method, $this->getInterfaceMethods());
- }
-
- /**
- * Finds the parent class name.
- * @returns string Parent class name.
- * @access public
- */
- function getParent() {
- $reflection = new ReflectionClass($this->interface);
- $parent = $reflection->getParentClass();
- if ($parent) {
- return $parent->getName();
- }
- return false;
- }
-
- /**
- * Trivially determines if the class is abstract.
- * @returns boolean True if abstract.
- * @access public
- */
- function isAbstract() {
- $reflection = new ReflectionClass($this->interface);
- return $reflection->isAbstract();
- }
-
- /**
- * Trivially determines if the class is an interface.
- * @returns boolean True if interface.
- * @access public
- */
- function isInterface() {
- $reflection = new ReflectionClass($this->interface);
- return $reflection->isInterface();
- }
-
- /**
- * Scans for final methods, as they screw up inherited
- * mocks by not allowing you to override them.
- * @returns boolean True if the class has a final method.
- * @access public
- */
- function hasFinal() {
- $reflection = new ReflectionClass($this->interface);
- foreach ($reflection->getMethods() as $method) {
- if ($method->isFinal()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Whittles a list of interfaces down to only the
- * necessary top level parents.
- * @param array $interfaces Reflection API interfaces
- * to reduce.
- * @returns array List of parent interface names.
- * @access private
- */
- protected function onlyParents($interfaces) {
- $parents = array();
- $blacklist = array();
- foreach ($interfaces as $interface) {
- foreach($interfaces as $possible_parent) {
- if ($interface->getName() == $possible_parent->getName()) {
- continue;
- }
- if ($interface->isSubClassOf($possible_parent)) {
- $blacklist[$possible_parent->getName()] = true;
- }
- }
- if (!isset($blacklist[$interface->getName()])) {
- $parents[] = $interface->getName();
- }
- }
- return $parents;
- }
-
- /**
- * Checks whether a method is abstract or not.
- * @param string $name Method name.
- * @return bool true if method is abstract, else false
- * @access private
- */
- protected function isAbstractMethod($name) {
- $interface = new ReflectionClass($this->interface);
- if (! $interface->hasMethod($name)) {
- return false;
- }
- return $interface->getMethod($name)->isAbstract();
- }
-
- /**
- * Checks whether a method is the constructor.
- * @param string $name Method name.
- * @return bool true if method is the constructor
- * @access private
- */
- protected function isConstructor($name) {
- return ($name == '__construct') || ($name == $this->interface);
- }
-
- /**
- * Checks whether a method is abstract in all parents or not.
- * @param string $name Method name.
- * @return bool true if method is abstract in parent, else false
- * @access private
- */
- protected function isAbstractMethodInParents($name) {
- $interface = new ReflectionClass($this->interface);
- $parent = $interface->getParentClass();
- while($parent) {
- if (! $parent->hasMethod($name)) {
- return false;
- }
- if ($parent->getMethod($name)->isAbstract()) {
- return true;
- }
- $parent = $parent->getParentClass();
- }
- return false;
- }
-
- /**
- * Checks whether a method is static or not.
- * @param string $name Method name
- * @return bool true if method is static, else false
- * @access private
- */
- protected function isStaticMethod($name) {
- $interface = new ReflectionClass($this->interface);
- if (! $interface->hasMethod($name)) {
- return false;
- }
- return $interface->getMethod($name)->isStatic();
- }
-
- /**
- * Writes the source code matching the declaration
- * of a method.
- * @param string $name Method name.
- * @return string Method signature up to last
- * bracket.
- * @access public
- */
- function getSignature($name) {
- if ($name == '__set') {
- return 'function __set($key, $value)';
- }
- if ($name == '__call') {
- return 'function __call($method, $arguments)';
- }
- if (version_compare(phpversion(), '5.1.0', '>=')) {
- if (in_array($name, array('__get', '__isset', $name == '__unset'))) {
- return "function {$name}(\$key)";
- }
- }
- if ($name == '__toString') {
- return "function $name()";
- }
-
- // This wonky try-catch is a work around for a faulty method_exists()
- // in early versions of PHP 5 which would return false for static
- // methods. The Reflection classes work fine, but hasMethod()
- // doesn't exist prior to PHP 5.1.0, so we need to use a more crude
- // detection method.
- try {
- $interface = new ReflectionClass($this->interface);
- $interface->getMethod($name);
- } catch (ReflectionException $e) {
- return "function $name()";
- }
- return $this->getFullSignature($name);
- }
-
- /**
- * For a signature specified in an interface, full
- * details must be replicated to be a valid implementation.
- * @param string $name Method name.
- * @return string Method signature up to last
- * bracket.
- * @access private
- */
- protected function getFullSignature($name) {
- $interface = new ReflectionClass($this->interface);
- $method = $interface->getMethod($name);
- $reference = $method->returnsReference() ? '&' : '';
- $static = $method->isStatic() ? 'static ' : '';
- return "{$static}function $reference$name(" .
- implode(', ', $this->getParameterSignatures($method)) .
- ")";
- }
-
- /**
- * Gets the source code for each parameter.
- * @param ReflectionMethod $method Method object from
- * reflection API
- * @return array List of strings, each
- * a snippet of code.
- * @access private
- */
- protected function getParameterSignatures($method) {
- $signatures = array();
- foreach ($method->getParameters() as $parameter) {
- $signature = '';
- $type = $parameter->getClass();
- if (is_null($type) && version_compare(phpversion(), '5.1.0', '>=') && $parameter->isArray()) {
- $signature .= 'array ';
- } elseif (!is_null($type)) {
- $signature .= $type->getName() . ' ';
- }
- if ($parameter->isPassedByReference()) {
- $signature .= '&';
- }
- $signature .= '$' . $this->suppressSpurious($parameter->getName());
- if ($this->isOptional($parameter)) {
- $signature .= ' = null';
- }
- $signatures[] = $signature;
- }
- return $signatures;
- }
-
- /**
- * The SPL library has problems with the
- * Reflection library. In particular, you can
- * get extra characters in parameter names :(.
- * @param string $name Parameter name.
- * @return string Cleaner name.
- * @access private
- */
- protected function suppressSpurious($name) {
- return str_replace(array('[', ']', ' '), '', $name);
- }
-
- /**
- * Test of a reflection parameter being optional
- * that works with early versions of PHP5.
- * @param reflectionParameter $parameter Is this optional.
- * @return boolean True if optional.
- * @access private
- */
- protected function isOptional($parameter) {
- if (method_exists($parameter, 'isOptional')) {
- return $parameter->isOptional();
- }
- return false;
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/remote.php b/core/vendors/simpletest/remote.php
deleted file mode 100755
index 4bb37b7..0000000
--- a/core/vendors/simpletest/remote.php
+++ /dev/null
@@ -1,115 +0,0 @@
-url = $url;
- $this->dry_url = $dry_url ? $dry_url : $url;
- $this->size = false;
- }
-
- /**
- * Accessor for the test name for subclasses.
- * @return string Name of the test.
- * @access public
- */
- function getLabel() {
- return $this->url;
- }
-
- /**
- * Runs the top level test for this class. Currently
- * reads the data as a single chunk. I'll fix this
- * once I have added iteration to the browser.
- * @param SimpleReporter $reporter Target of test results.
- * @returns boolean True if no failures.
- * @access public
- */
- function run($reporter) {
- $browser = $this->createBrowser();
- $xml = $browser->get($this->url);
- if (! $xml) {
- trigger_error('Cannot read remote test URL [' . $this->url . ']');
- return false;
- }
- $parser = $this->createParser($reporter);
- if (! $parser->parse($xml)) {
- trigger_error('Cannot parse incoming XML from [' . $this->url . ']');
- return false;
- }
- return true;
- }
-
- /**
- * Creates a new web browser object for fetching
- * the XML report.
- * @return SimpleBrowser New browser.
- * @access protected
- */
- protected function createBrowser() {
- return new SimpleBrowser();
- }
-
- /**
- * Creates the XML parser.
- * @param SimpleReporter $reporter Target of test results.
- * @return SimpleTestXmlListener XML reader.
- * @access protected
- */
- protected function createParser($reporter) {
- return new SimpleTestXmlParser($reporter);
- }
-
- /**
- * Accessor for the number of subtests.
- * @return integer Number of test cases.
- * @access public
- */
- function getSize() {
- if ($this->size === false) {
- $browser = $this->createBrowser();
- $xml = $browser->get($this->dry_url);
- if (! $xml) {
- trigger_error('Cannot read remote test URL [' . $this->dry_url . ']');
- return false;
- }
- $reporter = new SimpleReporter();
- $parser = $this->createParser($reporter);
- if (! $parser->parse($xml)) {
- trigger_error('Cannot parse incoming XML from [' . $this->dry_url . ']');
- return false;
- }
- $this->size = $reporter->getTestCaseCount();
- }
- return $this->size;
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/reporter.php b/core/vendors/simpletest/reporter.php
deleted file mode 100755
index bd4f3fa..0000000
--- a/core/vendors/simpletest/reporter.php
+++ /dev/null
@@ -1,445 +0,0 @@
-character_set = $character_set;
- }
-
- /**
- * Paints the top of the web page setting the
- * title to the name of the starting test.
- * @param string $test_name Name class of test.
- * @access public
- */
- function paintHeader($test_name) {
- $this->sendNoCacheHeaders();
- print "";
- print "\n\n$test_name \n";
- print " \n";
- print "\n";
- print "\n\n";
- print "$test_name \n";
- flush();
- }
-
- /**
- * Send the headers necessary to ensure the page is
- * reloaded on every request. Otherwise you could be
- * scratching your head over out of date test data.
- * @access public
- */
- static function sendNoCacheHeaders() {
- if (! headers_sent()) {
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Cache-Control: no-store, no-cache, must-revalidate");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
- }
- }
-
- /**
- * Paints the CSS. Add additional styles here.
- * @return string CSS code as text.
- * @access protected
- */
- protected function getCss() {
- return ".fail { background-color: inherit; color: red; }" .
- ".pass { background-color: inherit; color: green; }" .
- " pre { background-color: lightgray; color: inherit; }";
- }
-
- /**
- * Paints the end of the test with a summary of
- * the passes and failures.
- * @param string $test_name Name class of test.
- * @access public
- */
- function paintFooter($test_name) {
- $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
- print "";
- print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
- print " test cases complete:\n";
- print "" . $this->getPassCount() . " passes, ";
- print "" . $this->getFailCount() . " fails and ";
- print "" . $this->getExceptionCount() . " exceptions.";
- print "
\n";
- print "\n\n";
- }
-
- /**
- * Paints the test failure with a breadcrumbs
- * trail of the nesting test suites below the
- * top level test.
- * @param string $message Failure message displayed in
- * the context of the other tests.
- */
- function paintFail($message) {
- parent::paintFail($message);
- print "Fail : ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> " . $this->htmlEntities($message) . " \n";
- }
-
- /**
- * Paints a PHP error.
- * @param string $message Message is ignored.
- * @access public
- */
- function paintError($message) {
- parent::paintError($message);
- print "Exception : ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> " . $this->htmlEntities($message) . " \n";
- }
-
- /**
- * Paints a PHP exception.
- * @param Exception $exception Exception to display.
- * @access public
- */
- function paintException($exception) {
- parent::paintException($exception);
- print "Exception : ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- $message = 'Unexpected exception of type [' . get_class($exception) .
- '] with message ['. $exception->getMessage() .
- '] in ['. $exception->getFile() .
- ' line ' . $exception->getLine() . ']';
- print " -> " . $this->htmlEntities($message) . " \n";
- }
-
- /**
- * Prints the message for skipping tests.
- * @param string $message Text of skip condition.
- * @access public
- */
- function paintSkip($message) {
- parent::paintSkip($message);
- print "Skipped : ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> " . $this->htmlEntities($message) . " \n";
- }
-
- /**
- * Paints formatted text such as dumped privateiables.
- * @param string $message Text to show.
- * @access public
- */
- function paintFormattedMessage($message) {
- print '' . $this->htmlEntities($message) . ' ';
- }
-
- /**
- * Character set adjusted entity conversion.
- * @param string $message Plain text or Unicode message.
- * @return string Browser readable message.
- * @access protected
- */
- protected function htmlEntities($message) {
- return htmlentities($message, ENT_COMPAT, $this->character_set);
- }
-}
-
-/**
- * Sample minimal test displayer. Generates only
- * failure messages and a pass count. For command
- * line use. I've tried to make it look like JUnit,
- * but I wanted to output the errors as they arrived
- * which meant dropping the dots.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class TextReporter extends SimpleReporter {
-
- /**
- * Does nothing yet. The first output will
- * be sent on the first test start.
- */
- function __construct() {
- parent::__construct();
- }
-
- /**
- * Paints the title only.
- * @param string $test_name Name class of test.
- * @access public
- */
- function paintHeader($test_name) {
- if (! SimpleReporter::inCli()) {
- header('Content-type: text/plain');
- }
- print "$test_name\n";
- flush();
- }
-
- /**
- * Paints the end of the test with a summary of
- * the passes and failures.
- * @param string $test_name Name class of test.
- * @access public
- */
- function paintFooter($test_name) {
- if ($this->getFailCount() + $this->getExceptionCount() == 0) {
- print "OK\n";
- } else {
- print "FAILURES!!!\n";
- }
- print "Test cases run: " . $this->getTestCaseProgress() .
- "/" . $this->getTestCaseCount() .
- ", Passes: " . $this->getPassCount() .
- ", Failures: " . $this->getFailCount() .
- ", Exceptions: " . $this->getExceptionCount() . "\n";
- }
-
- /**
- * Paints the test failure as a stack trace.
- * @param string $message Failure message displayed in
- * the context of the other tests.
- * @access public
- */
- function paintFail($message) {
- parent::paintFail($message);
- print $this->getFailCount() . ") $message\n";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
- print "\n";
- }
-
- /**
- * Paints a PHP error or exception.
- * @param string $message Message to be shown.
- * @access public
- * @abstract
- */
- function paintError($message) {
- parent::paintError($message);
- print "Exception " . $this->getExceptionCount() . "!\n$message\n";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
- print "\n";
- }
-
- /**
- * Paints a PHP error or exception.
- * @param Exception $exception Exception to describe.
- * @access public
- * @abstract
- */
- function paintException($exception) {
- parent::paintException($exception);
- $message = 'Unexpected exception of type [' . get_class($exception) .
- '] with message ['. $exception->getMessage() .
- '] in ['. $exception->getFile() .
- ' line ' . $exception->getLine() . ']';
- print "Exception " . $this->getExceptionCount() . "!\n$message\n";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
- print "\n";
- }
-
- /**
- * Prints the message for skipping tests.
- * @param string $message Text of skip condition.
- * @access public
- */
- function paintSkip($message) {
- parent::paintSkip($message);
- print "Skip: $message\n";
- }
-
- /**
- * Paints formatted text such as dumped privateiables.
- * @param string $message Text to show.
- * @access public
- */
- function paintFormattedMessage($message) {
- print "$message\n";
- flush();
- }
-}
-
-/**
- * Runs just a single test group, a single case or
- * even a single test within that case.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class SelectiveReporter extends SimpleReporterDecorator {
- private $just_this_case = false;
- private $just_this_test = false;
- private $on;
-
- /**
- * Selects the test case or group to be run,
- * and optionally a specific test.
- * @param SimpleScorer $reporter Reporter to receive events.
- * @param string $just_this_case Only this case or group will run.
- * @param string $just_this_test Only this test method will run.
- */
- function __construct($reporter, $just_this_case = false, $just_this_test = false) {
- if (isset($just_this_case) && $just_this_case) {
- $this->just_this_case = strtolower($just_this_case);
- $this->off();
- } else {
- $this->on();
- }
- if (isset($just_this_test) && $just_this_test) {
- $this->just_this_test = strtolower($just_this_test);
- }
- parent::__construct($reporter);
- }
-
- /**
- * Compares criteria to actual the case/group name.
- * @param string $test_case The incoming test.
- * @return boolean True if matched.
- * @access protected
- */
- protected function matchesTestCase($test_case) {
- return $this->just_this_case == strtolower($test_case);
- }
-
- /**
- * Compares criteria to actual the test name. If no
- * name was specified at the beginning, then all tests
- * can run.
- * @param string $method The incoming test method.
- * @return boolean True if matched.
- * @access protected
- */
- protected function shouldRunTest($test_case, $method) {
- if ($this->isOn() || $this->matchesTestCase($test_case)) {
- if ($this->just_this_test) {
- return $this->just_this_test == strtolower($method);
- } else {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Switch on testing for the group or subgroup.
- * @access private
- */
- protected function on() {
- $this->on = true;
- }
-
- /**
- * Switch off testing for the group or subgroup.
- * @access private
- */
- protected function off() {
- $this->on = false;
- }
-
- /**
- * Is this group actually being tested?
- * @return boolean True if the current test group is active.
- * @access private
- */
- protected function isOn() {
- return $this->on;
- }
-
- /**
- * Veto everything that doesn't match the method wanted.
- * @param string $test_case Name of test case.
- * @param string $method Name of test method.
- * @return boolean True if test should be run.
- * @access public
- */
- function shouldInvoke($test_case, $method) {
- if ($this->shouldRunTest($test_case, $method)) {
- return $this->reporter->shouldInvoke($test_case, $method);
- }
- return false;
- }
-
- /**
- * Paints the start of a group test.
- * @param string $test_case Name of test or other label.
- * @param integer $size Number of test cases starting.
- * @access public
- */
- function paintGroupStart($test_case, $size) {
- if ($this->just_this_case && $this->matchesTestCase($test_case)) {
- $this->on();
- }
- $this->reporter->paintGroupStart($test_case, $size);
- }
-
- /**
- * Paints the end of a group test.
- * @param string $test_case Name of test or other label.
- * @access public
- */
- function paintGroupEnd($test_case) {
- $this->reporter->paintGroupEnd($test_case);
- if ($this->just_this_case && $this->matchesTestCase($test_case)) {
- $this->off();
- }
- }
-}
-
-/**
- * Suppresses skip messages.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class NoSkipsReporter extends SimpleReporterDecorator {
-
- /**
- * Does nothing.
- * @param string $message Text of skip condition.
- * @access public
- */
- function paintSkip($message) { }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/scorer.php b/core/vendors/simpletest/scorer.php
deleted file mode 100755
index 27776f4..0000000
--- a/core/vendors/simpletest/scorer.php
+++ /dev/null
@@ -1,875 +0,0 @@
-passes = 0;
- $this->fails = 0;
- $this->exceptions = 0;
- $this->is_dry_run = false;
- }
-
- /**
- * Signals that the next evaluation will be a dry
- * run. That is, the structure events will be
- * recorded, but no tests will be run.
- * @param boolean $is_dry Dry run if true.
- * @access public
- */
- function makeDry($is_dry = true) {
- $this->is_dry_run = $is_dry;
- }
-
- /**
- * The reporter has a veto on what should be run.
- * @param string $test_case_name name of test case.
- * @param string $method Name of test method.
- * @access public
- */
- function shouldInvoke($test_case_name, $method) {
- return ! $this->is_dry_run;
- }
-
- /**
- * Can wrap the invoker in preperation for running
- * a test.
- * @param SimpleInvoker $invoker Individual test runner.
- * @return SimpleInvoker Wrapped test runner.
- * @access public
- */
- function createInvoker($invoker) {
- return $invoker;
- }
-
- /**
- * Accessor for current status. Will be false
- * if there have been any failures or exceptions.
- * Used for command line tools.
- * @return boolean True if no failures.
- * @access public
- */
- function getStatus() {
- if ($this->exceptions + $this->fails > 0) {
- return false;
- }
- return true;
- }
-
- /**
- * Paints the start of a group test.
- * @param string $test_name Name of test or other label.
- * @param integer $size Number of test cases starting.
- * @access public
- */
- function paintGroupStart($test_name, $size) {
- }
-
- /**
- * Paints the end of a group test.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintGroupEnd($test_name) {
- }
-
- /**
- * Paints the start of a test case.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintCaseStart($test_name) {
- }
-
- /**
- * Paints the end of a test case.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintCaseEnd($test_name) {
- }
-
- /**
- * Paints the start of a test method.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintMethodStart($test_name) {
- }
-
- /**
- * Paints the end of a test method.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintMethodEnd($test_name) {
- }
-
- /**
- * Increments the pass count.
- * @param string $message Message is ignored.
- * @access public
- */
- function paintPass($message) {
- $this->passes++;
- }
-
- /**
- * Increments the fail count.
- * @param string $message Message is ignored.
- * @access public
- */
- function paintFail($message) {
- $this->fails++;
- }
-
- /**
- * Deals with PHP 4 throwing an error.
- * @param string $message Text of error formatted by
- * the test case.
- * @access public
- */
- function paintError($message) {
- $this->exceptions++;
- }
-
- /**
- * Deals with PHP 5 throwing an exception.
- * @param Exception $exception The actual exception thrown.
- * @access public
- */
- function paintException($exception) {
- $this->exceptions++;
- }
-
- /**
- * Prints the message for skipping tests.
- * @param string $message Text of skip condition.
- * @access public
- */
- function paintSkip($message) {
- }
-
- /**
- * Accessor for the number of passes so far.
- * @return integer Number of passes.
- * @access public
- */
- function getPassCount() {
- return $this->passes;
- }
-
- /**
- * Accessor for the number of fails so far.
- * @return integer Number of fails.
- * @access public
- */
- function getFailCount() {
- return $this->fails;
- }
-
- /**
- * Accessor for the number of untrapped errors
- * so far.
- * @return integer Number of exceptions.
- * @access public
- */
- function getExceptionCount() {
- return $this->exceptions;
- }
-
- /**
- * Paints a simple supplementary message.
- * @param string $message Text to display.
- * @access public
- */
- function paintMessage($message) {
- }
-
- /**
- * Paints a formatted ASCII message such as a
- * privateiable dump.
- * @param string $message Text to display.
- * @access public
- */
- function paintFormattedMessage($message) {
- }
-
- /**
- * By default just ignores user generated events.
- * @param string $type Event type as text.
- * @param mixed $payload Message or object.
- * @access public
- */
- function paintSignal($type, $payload) {
- }
-}
-
-/**
- * Recipient of generated test messages that can display
- * page footers and headers. Also keeps track of the
- * test nesting. This is the main base class on which
- * to build the finished test (page based) displays.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class SimpleReporter extends SimpleScorer {
- private $test_stack;
- private $size;
- private $progress;
-
- /**
- * Starts the display with no results in.
- * @access public
- */
- function __construct() {
- parent::__construct();
- $this->test_stack = array();
- $this->size = null;
- $this->progress = 0;
- }
-
- /**
- * Gets the formatter for small generic data items.
- * @return SimpleDumper Formatter.
- * @access public
- */
- function getDumper() {
- return new SimpleDumper();
- }
-
- /**
- * Paints the start of a group test. Will also paint
- * the page header and footer if this is the
- * first test. Will stash the size if the first
- * start.
- * @param string $test_name Name of test that is starting.
- * @param integer $size Number of test cases starting.
- * @access public
- */
- function paintGroupStart($test_name, $size) {
- if (! isset($this->size)) {
- $this->size = $size;
- }
- if (count($this->test_stack) == 0) {
- $this->paintHeader($test_name);
- }
- $this->test_stack[] = $test_name;
- }
-
- /**
- * Paints the end of a group test. Will paint the page
- * footer if the stack of tests has unwound.
- * @param string $test_name Name of test that is ending.
- * @param integer $progress Number of test cases ending.
- * @access public
- */
- function paintGroupEnd($test_name) {
- array_pop($this->test_stack);
- if (count($this->test_stack) == 0) {
- $this->paintFooter($test_name);
- }
- }
-
- /**
- * Paints the start of a test case. Will also paint
- * the page header and footer if this is the
- * first test. Will stash the size if the first
- * start.
- * @param string $test_name Name of test that is starting.
- * @access public
- */
- function paintCaseStart($test_name) {
- if (! isset($this->size)) {
- $this->size = 1;
- }
- if (count($this->test_stack) == 0) {
- $this->paintHeader($test_name);
- }
- $this->test_stack[] = $test_name;
- }
-
- /**
- * Paints the end of a test case. Will paint the page
- * footer if the stack of tests has unwound.
- * @param string $test_name Name of test that is ending.
- * @access public
- */
- function paintCaseEnd($test_name) {
- $this->progress++;
- array_pop($this->test_stack);
- if (count($this->test_stack) == 0) {
- $this->paintFooter($test_name);
- }
- }
-
- /**
- * Paints the start of a test method.
- * @param string $test_name Name of test that is starting.
- * @access public
- */
- function paintMethodStart($test_name) {
- $this->test_stack[] = $test_name;
- }
-
- /**
- * Paints the end of a test method. Will paint the page
- * footer if the stack of tests has unwound.
- * @param string $test_name Name of test that is ending.
- * @access public
- */
- function paintMethodEnd($test_name) {
- array_pop($this->test_stack);
- }
-
- /**
- * Paints the test document header.
- * @param string $test_name First test top level
- * to start.
- * @access public
- * @abstract
- */
- function paintHeader($test_name) {
- }
-
- /**
- * Paints the test document footer.
- * @param string $test_name The top level test.
- * @access public
- * @abstract
- */
- function paintFooter($test_name) {
- }
-
- /**
- * Accessor for internal test stack. For
- * subclasses that need to see the whole test
- * history for display purposes.
- * @return array List of methods in nesting order.
- * @access public
- */
- function getTestList() {
- return $this->test_stack;
- }
-
- /**
- * Accessor for total test size in number
- * of test cases. Null until the first
- * test is started.
- * @return integer Total number of cases at start.
- * @access public
- */
- function getTestCaseCount() {
- return $this->size;
- }
-
- /**
- * Accessor for the number of test cases
- * completed so far.
- * @return integer Number of ended cases.
- * @access public
- */
- function getTestCaseProgress() {
- return $this->progress;
- }
-
- /**
- * Static check for running in the comand line.
- * @return boolean True if CLI.
- * @access public
- */
- static function inCli() {
- return php_sapi_name() == 'cli';
- }
-}
-
-/**
- * For modifying the behaviour of the visual reporters.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class SimpleReporterDecorator {
- protected $reporter;
-
- /**
- * Mediates between the reporter and the test case.
- * @param SimpleScorer $reporter Reporter to receive events.
- */
- function __construct($reporter) {
- $this->reporter = $reporter;
- }
-
- /**
- * Signals that the next evaluation will be a dry
- * run. That is, the structure events will be
- * recorded, but no tests will be run.
- * @param boolean $is_dry Dry run if true.
- * @access public
- */
- function makeDry($is_dry = true) {
- $this->reporter->makeDry($is_dry);
- }
-
- /**
- * Accessor for current status. Will be false
- * if there have been any failures or exceptions.
- * Used for command line tools.
- * @return boolean True if no failures.
- * @access public
- */
- function getStatus() {
- return $this->reporter->getStatus();
- }
-
- /**
- * The nesting of the test cases so far. Not
- * all reporters have this facility.
- * @return array Test list if accessible.
- * @access public
- */
- function getTestList() {
- if (method_exists($this->reporter, 'getTestList')) {
- return $this->reporter->getTestList();
- } else {
- return array();
- }
- }
-
- /**
- * The reporter has a veto on what should be run.
- * @param string $test_case_name Name of test case.
- * @param string $method Name of test method.
- * @return boolean True if test should be run.
- * @access public
- */
- function shouldInvoke($test_case_name, $method) {
- return $this->reporter->shouldInvoke($test_case_name, $method);
- }
-
- /**
- * Can wrap the invoker in preparation for running
- * a test.
- * @param SimpleInvoker $invoker Individual test runner.
- * @return SimpleInvoker Wrapped test runner.
- * @access public
- */
- function createInvoker($invoker) {
- return $this->reporter->createInvoker($invoker);
- }
-
- /**
- * Gets the formatter for privateiables and other small
- * generic data items.
- * @return SimpleDumper Formatter.
- * @access public
- */
- function getDumper() {
- return $this->reporter->getDumper();
- }
-
- /**
- * Paints the start of a group test.
- * @param string $test_name Name of test or other label.
- * @param integer $size Number of test cases starting.
- * @access public
- */
- function paintGroupStart($test_name, $size) {
- $this->reporter->paintGroupStart($test_name, $size);
- }
-
- /**
- * Paints the end of a group test.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintGroupEnd($test_name) {
- $this->reporter->paintGroupEnd($test_name);
- }
-
- /**
- * Paints the start of a test case.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintCaseStart($test_name) {
- $this->reporter->paintCaseStart($test_name);
- }
-
- /**
- * Paints the end of a test case.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintCaseEnd($test_name) {
- $this->reporter->paintCaseEnd($test_name);
- }
-
- /**
- * Paints the start of a test method.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintMethodStart($test_name) {
- $this->reporter->paintMethodStart($test_name);
- }
-
- /**
- * Paints the end of a test method.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintMethodEnd($test_name) {
- $this->reporter->paintMethodEnd($test_name);
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Message is ignored.
- * @access public
- */
- function paintPass($message) {
- $this->reporter->paintPass($message);
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Message is ignored.
- * @access public
- */
- function paintFail($message) {
- $this->reporter->paintFail($message);
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Text of error formatted by
- * the test case.
- * @access public
- */
- function paintError($message) {
- $this->reporter->paintError($message);
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param Exception $exception Exception to show.
- * @access public
- */
- function paintException($exception) {
- $this->reporter->paintException($exception);
- }
-
- /**
- * Prints the message for skipping tests.
- * @param string $message Text of skip condition.
- * @access public
- */
- function paintSkip($message) {
- $this->reporter->paintSkip($message);
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Text to display.
- * @access public
- */
- function paintMessage($message) {
- $this->reporter->paintMessage($message);
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Text to display.
- * @access public
- */
- function paintFormattedMessage($message) {
- $this->reporter->paintFormattedMessage($message);
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $type Event type as text.
- * @param mixed $payload Message or object.
- * @return boolean Should return false if this
- * type of signal should fail the
- * test suite.
- * @access public
- */
- function paintSignal($type, $payload) {
- $this->reporter->paintSignal($type, $payload);
- }
-}
-
-/**
- * For sending messages to multiple reporters at
- * the same time.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class MultipleReporter {
- private $reporters = array();
-
- /**
- * Adds a reporter to the subscriber list.
- * @param SimpleScorer $reporter Reporter to receive events.
- * @access public
- */
- function attachReporter($reporter) {
- $this->reporters[] = $reporter;
- }
-
- /**
- * Signals that the next evaluation will be a dry
- * run. That is, the structure events will be
- * recorded, but no tests will be run.
- * @param boolean $is_dry Dry run if true.
- * @access public
- */
- function makeDry($is_dry = true) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->makeDry($is_dry);
- }
- }
-
- /**
- * Accessor for current status. Will be false
- * if there have been any failures or exceptions.
- * If any reporter reports a failure, the whole
- * suite fails.
- * @return boolean True if no failures.
- * @access public
- */
- function getStatus() {
- for ($i = 0; $i < count($this->reporters); $i++) {
- if (! $this->reporters[$i]->getStatus()) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * The reporter has a veto on what should be run.
- * It requires all reporters to want to run the method.
- * @param string $test_case_name name of test case.
- * @param string $method Name of test method.
- * @access public
- */
- function shouldInvoke($test_case_name, $method) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- if (! $this->reporters[$i]->shouldInvoke($test_case_name, $method)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Every reporter gets a chance to wrap the invoker.
- * @param SimpleInvoker $invoker Individual test runner.
- * @return SimpleInvoker Wrapped test runner.
- * @access public
- */
- function createInvoker($invoker) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $invoker = $this->reporters[$i]->createInvoker($invoker);
- }
- return $invoker;
- }
-
- /**
- * Gets the formatter for privateiables and other small
- * generic data items.
- * @return SimpleDumper Formatter.
- * @access public
- */
- function getDumper() {
- return new SimpleDumper();
- }
-
- /**
- * Paints the start of a group test.
- * @param string $test_name Name of test or other label.
- * @param integer $size Number of test cases starting.
- * @access public
- */
- function paintGroupStart($test_name, $size) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintGroupStart($test_name, $size);
- }
- }
-
- /**
- * Paints the end of a group test.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintGroupEnd($test_name) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintGroupEnd($test_name);
- }
- }
-
- /**
- * Paints the start of a test case.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintCaseStart($test_name) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintCaseStart($test_name);
- }
- }
-
- /**
- * Paints the end of a test case.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintCaseEnd($test_name) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintCaseEnd($test_name);
- }
- }
-
- /**
- * Paints the start of a test method.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintMethodStart($test_name) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintMethodStart($test_name);
- }
- }
-
- /**
- * Paints the end of a test method.
- * @param string $test_name Name of test or other label.
- * @access public
- */
- function paintMethodEnd($test_name) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintMethodEnd($test_name);
- }
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Message is ignored.
- * @access public
- */
- function paintPass($message) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintPass($message);
- }
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Message is ignored.
- * @access public
- */
- function paintFail($message) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintFail($message);
- }
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Text of error formatted by
- * the test case.
- * @access public
- */
- function paintError($message) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintError($message);
- }
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param Exception $exception Exception to display.
- * @access public
- */
- function paintException($exception) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintException($exception);
- }
- }
-
- /**
- * Prints the message for skipping tests.
- * @param string $message Text of skip condition.
- * @access public
- */
- function paintSkip($message) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintSkip($message);
- }
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Text to display.
- * @access public
- */
- function paintMessage($message) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintMessage($message);
- }
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $message Text to display.
- * @access public
- */
- function paintFormattedMessage($message) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintFormattedMessage($message);
- }
- }
-
- /**
- * Chains to the wrapped reporter.
- * @param string $type Event type as text.
- * @param mixed $payload Message or object.
- * @return boolean Should return false if this
- * type of signal should fail the
- * test suite.
- * @access public
- */
- function paintSignal($type, $payload) {
- for ($i = 0; $i < count($this->reporters); $i++) {
- $this->reporters[$i]->paintSignal($type, $payload);
- }
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/selector.php b/core/vendors/simpletest/selector.php
deleted file mode 100755
index ba2fed3..0000000
--- a/core/vendors/simpletest/selector.php
+++ /dev/null
@@ -1,141 +0,0 @@
-name = $name;
- }
-
- /**
- * Accessor for name.
- * @returns string $name Name to match.
- */
- function getName() {
- return $this->name;
- }
-
- /**
- * Compares with name attribute of widget.
- * @param SimpleWidget $widget Control to compare.
- * @access public
- */
- function isMatch($widget) {
- return ($widget->getName() == $this->name);
- }
-}
-
-/**
- * Used to extract form elements for testing against.
- * Searches by visible label or alt text.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleByLabel {
- private $label;
-
- /**
- * Stashes the name for later comparison.
- * @param string $label Visible text to match.
- */
- function __construct($label) {
- $this->label = $label;
- }
-
- /**
- * Comparison. Compares visible text of widget or
- * related label.
- * @param SimpleWidget $widget Control to compare.
- * @access public
- */
- function isMatch($widget) {
- if (! method_exists($widget, 'isLabel')) {
- return false;
- }
- return $widget->isLabel($this->label);
- }
-}
-
-/**
- * Used to extract form elements for testing against.
- * Searches dy id attribute.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleById {
- private $id;
-
- /**
- * Stashes the name for later comparison.
- * @param string $id ID atribute to match.
- */
- function __construct($id) {
- $this->id = $id;
- }
-
- /**
- * Comparison. Compares id attribute of widget.
- * @param SimpleWidget $widget Control to compare.
- * @access public
- */
- function isMatch($widget) {
- return $widget->isId($this->id);
- }
-}
-
-/**
- * Used to extract form elements for testing against.
- * Searches by visible label, name or alt text.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleByLabelOrName {
- private $label;
-
- /**
- * Stashes the name/label for later comparison.
- * @param string $label Visible text to match.
- */
- function __construct($label) {
- $this->label = $label;
- }
-
- /**
- * Comparison. Compares visible text of widget or
- * related label or name.
- * @param SimpleWidget $widget Control to compare.
- * @access public
- */
- function isMatch($widget) {
- if (method_exists($widget, 'isLabel')) {
- if ($widget->isLabel($this->label)) {
- return true;
- }
- }
- return ($widget->getName() == $this->label);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/shell_tester.php b/core/vendors/simpletest/shell_tester.php
deleted file mode 100755
index 9a3bd38..0000000
--- a/core/vendors/simpletest/shell_tester.php
+++ /dev/null
@@ -1,330 +0,0 @@
-output = false;
- }
-
- /**
- * Actually runs the command. Does not trap the
- * error stream output as this need PHP 4.3+.
- * @param string $command The actual command line
- * to run.
- * @return integer Exit code.
- * @access public
- */
- function execute($command) {
- $this->output = false;
- exec($command, $this->output, $ret);
- return $ret;
- }
-
- /**
- * Accessor for the last output.
- * @return string Output as text.
- * @access public
- */
- function getOutput() {
- return implode("\n", $this->output);
- }
-
- /**
- * Accessor for the last output.
- * @return array Output as array of lines.
- * @access public
- */
- function getOutputAsList() {
- return $this->output;
- }
-}
-
-/**
- * Test case for testing of command line scripts and
- * utilities. Usually scripts that are external to the
- * PHP code, but support it in some way.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class ShellTestCase extends SimpleTestCase {
- private $current_shell;
- private $last_status;
- private $last_command;
-
- /**
- * Creates an empty test case. Should be subclassed
- * with test methods for a functional test case.
- * @param string $label Name of test case. Will use
- * the class name if none specified.
- * @access public
- */
- function __construct($label = false) {
- parent::__construct($label);
- $this->current_shell = $this->createShell();
- $this->last_status = false;
- $this->last_command = '';
- }
-
- /**
- * Executes a command and buffers the results.
- * @param string $command Command to run.
- * @return boolean True if zero exit code.
- * @access public
- */
- function execute($command) {
- $shell = $this->getShell();
- $this->last_status = $shell->execute($command);
- $this->last_command = $command;
- return ($this->last_status === 0);
- }
-
- /**
- * Dumps the output of the last command.
- * @access public
- */
- function dumpOutput() {
- $this->dump($this->getOutput());
- }
-
- /**
- * Accessor for the last output.
- * @return string Output as text.
- * @access public
- */
- function getOutput() {
- $shell = $this->getShell();
- return $shell->getOutput();
- }
-
- /**
- * Accessor for the last output.
- * @return array Output as array of lines.
- * @access public
- */
- function getOutputAsList() {
- $shell = $this->getShell();
- return $shell->getOutputAsList();
- }
-
- /**
- * Called from within the test methods to register
- * passes and failures.
- * @param boolean $result Pass on true.
- * @param string $message Message to display describing
- * the test state.
- * @return boolean True on pass
- * @access public
- */
- function assertTrue($result, $message = false) {
- return $this->assert(new TrueExpectation(), $result, $message);
- }
-
- /**
- * Will be true on false and vice versa. False
- * is the PHP definition of false, so that null,
- * empty strings, zero and an empty array all count
- * as false.
- * @param boolean $result Pass on false.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertFalse($result, $message = '%s') {
- return $this->assert(new FalseExpectation(), $result, $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * the same value only. Otherwise a fail. This
- * is for testing hand extracted text, etc.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertEqual($first, $second, $message = "%s") {
- return $this->assert(
- new EqualExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * a different value. Otherwise a fail. This
- * is for testing hand extracted text, etc.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertNotEqual($first, $second, $message = "%s") {
- return $this->assert(
- new NotEqualExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Tests the last status code from the shell.
- * @param integer $status Expected status of last
- * command.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertExitCode($status, $message = "%s") {
- $message = sprintf($message, "Expected status code of [$status] from [" .
- $this->last_command . "], but got [" .
- $this->last_status . "]");
- return $this->assertTrue($status === $this->last_status, $message);
- }
-
- /**
- * Attempt to exactly match the combined STDERR and
- * STDOUT output.
- * @param string $expected Expected output.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertOutput($expected, $message = "%s") {
- $shell = $this->getShell();
- return $this->assert(
- new EqualExpectation($expected),
- $shell->getOutput(),
- $message);
- }
-
- /**
- * Scans the output for a Perl regex. If found
- * anywhere it passes, else it fails.
- * @param string $pattern Regex to search for.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertOutputPattern($pattern, $message = "%s") {
- $shell = $this->getShell();
- return $this->assert(
- new PatternExpectation($pattern),
- $shell->getOutput(),
- $message);
- }
-
- /**
- * If a Perl regex is found anywhere in the current
- * output then a failure is generated, else a pass.
- * @param string $pattern Regex to search for.
- * @param $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertNoOutputPattern($pattern, $message = "%s") {
- $shell = $this->getShell();
- return $this->assert(
- new NoPatternExpectation($pattern),
- $shell->getOutput(),
- $message);
- }
-
- /**
- * File existence check.
- * @param string $path Full filename and path.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertFileExists($path, $message = "%s") {
- $message = sprintf($message, "File [$path] should exist");
- return $this->assertTrue(file_exists($path), $message);
- }
-
- /**
- * File non-existence check.
- * @param string $path Full filename and path.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertFileNotExists($path, $message = "%s") {
- $message = sprintf($message, "File [$path] should not exist");
- return $this->assertFalse(file_exists($path), $message);
- }
-
- /**
- * Scans a file for a Perl regex. If found
- * anywhere it passes, else it fails.
- * @param string $pattern Regex to search for.
- * @param string $path Full filename and path.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertFilePattern($pattern, $path, $message = "%s") {
- return $this->assert(
- new PatternExpectation($pattern),
- implode('', file($path)),
- $message);
- }
-
- /**
- * If a Perl regex is found anywhere in the named
- * file then a failure is generated, else a pass.
- * @param string $pattern Regex to search for.
- * @param string $path Full filename and path.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertNoFilePattern($pattern, $path, $message = "%s") {
- return $this->assert(
- new NoPatternExpectation($pattern),
- implode('', file($path)),
- $message);
- }
-
- /**
- * Accessor for current shell. Used for testing the
- * the tester itself.
- * @return Shell Current shell.
- * @access protected
- */
- protected function getShell() {
- return $this->current_shell;
- }
-
- /**
- * Factory for the shell to run the command on.
- * @return Shell New shell object.
- * @access protected
- */
- protected function createShell() {
- return new SimpleShell();
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/simpletest.php b/core/vendors/simpletest/simpletest.php
deleted file mode 100755
index 425c869..0000000
--- a/core/vendors/simpletest/simpletest.php
+++ /dev/null
@@ -1,391 +0,0 @@
-getParent()) {
- SimpleTest::ignore($parent);
- }
- }
- }
- }
-
- /**
- * Puts the object to the global pool of 'preferred' objects
- * which can be retrieved with SimpleTest :: preferred() method.
- * Instances of the same class are overwritten.
- * @param object $object Preferred object
- * @see preferred()
- */
- static function prefer($object) {
- $registry = &SimpleTest::getRegistry();
- $registry['Preferred'][] = $object;
- }
-
- /**
- * Retrieves 'preferred' objects from global pool. Class filter
- * can be applied in order to retrieve the object of the specific
- * class
- * @param array|string $classes Allowed classes or interfaces.
- * @return array|object|null
- * @see prefer()
- */
- static function preferred($classes) {
- if (! is_array($classes)) {
- $classes = array($classes);
- }
- $registry = &SimpleTest::getRegistry();
- for ($i = count($registry['Preferred']) - 1; $i >= 0; $i--) {
- foreach ($classes as $class) {
- if (SimpleTestCompatibility::isA($registry['Preferred'][$i], $class)) {
- return $registry['Preferred'][$i];
- }
- }
- }
- return null;
- }
-
- /**
- * Test to see if a test case is in the ignore
- * list. Quite obviously the ignore list should
- * be a separate object and will be one day.
- * This method is internal to SimpleTest. Don't
- * use it.
- * @param string $class Class name to test.
- * @return boolean True if should not be run.
- */
- static function isIgnored($class) {
- $registry = &SimpleTest::getRegistry();
- return isset($registry['IgnoreList'][strtolower($class)]);
- }
-
- /**
- * Sets proxy to use on all requests for when
- * testing from behind a firewall. Set host
- * to false to disable. This will take effect
- * if there are no other proxy settings.
- * @param string $proxy Proxy host as URL.
- * @param string $username Proxy username for authentication.
- * @param string $password Proxy password for authentication.
- */
- static function useProxy($proxy, $username = false, $password = false) {
- $registry = &SimpleTest::getRegistry();
- $registry['DefaultProxy'] = $proxy;
- $registry['DefaultProxyUsername'] = $username;
- $registry['DefaultProxyPassword'] = $password;
- }
-
- /**
- * Accessor for default proxy host.
- * @return string Proxy URL.
- */
- static function getDefaultProxy() {
- $registry = &SimpleTest::getRegistry();
- return $registry['DefaultProxy'];
- }
-
- /**
- * Accessor for default proxy username.
- * @return string Proxy username for authentication.
- */
- static function getDefaultProxyUsername() {
- $registry = &SimpleTest::getRegistry();
- return $registry['DefaultProxyUsername'];
- }
-
- /**
- * Accessor for default proxy password.
- * @return string Proxy password for authentication.
- */
- static function getDefaultProxyPassword() {
- $registry = &SimpleTest::getRegistry();
- return $registry['DefaultProxyPassword'];
- }
-
- /**
- * Accessor for default HTML parsers.
- * @return array List of parsers to try in
- * order until one responds true
- * to can().
- */
- static function getParsers() {
- $registry = &SimpleTest::getRegistry();
- return $registry['Parsers'];
- }
-
- /**
- * Set the list of HTML parsers to attempt to use by default.
- * @param array $parsers List of parsers to try in
- * order until one responds true
- * to can().
- */
- static function setParsers($parsers) {
- $registry = &SimpleTest::getRegistry();
- $registry['Parsers'] = $parsers;
- }
-
- /**
- * Accessor for global registry of options.
- * @return hash All stored values.
- */
- protected static function &getRegistry() {
- static $registry = false;
- if (! $registry) {
- $registry = SimpleTest::getDefaults();
- }
- return $registry;
- }
-
- /**
- * Accessor for the context of the current
- * test run.
- * @return SimpleTestContext Current test run.
- */
- static function getContext() {
- static $context = false;
- if (! $context) {
- $context = new SimpleTestContext();
- }
- return $context;
- }
-
- /**
- * Constant default values.
- * @return hash All registry defaults.
- */
- protected static function getDefaults() {
- return array(
- 'Parsers' => false,
- 'MockBaseClass' => 'SimpleMock',
- 'IgnoreList' => array(),
- 'DefaultProxy' => false,
- 'DefaultProxyUsername' => false,
- 'DefaultProxyPassword' => false,
- 'Preferred' => array(new HtmlReporter(), new TextReporter(), new XmlReporter()));
- }
-
- /**
- * @deprecated
- */
- static function setMockBaseClass($mock_base) {
- $registry = &SimpleTest::getRegistry();
- $registry['MockBaseClass'] = $mock_base;
- }
-
- /**
- * @deprecated
- */
- static function getMockBaseClass() {
- $registry = &SimpleTest::getRegistry();
- return $registry['MockBaseClass'];
- }
-}
-
-/**
- * Container for all components for a specific
- * test run. Makes things like error queues
- * available to PHP event handlers, and also
- * gets around some nasty reference issues in
- * the mocks.
- * @package SimpleTest
- */
-class SimpleTestContext {
- private $test;
- private $reporter;
- private $resources;
-
- /**
- * Clears down the current context.
- * @access public
- */
- function clear() {
- $this->resources = array();
- }
-
- /**
- * Sets the current test case instance. This
- * global instance can be used by the mock objects
- * to send message to the test cases.
- * @param SimpleTestCase $test Test case to register.
- */
- function setTest($test) {
- $this->clear();
- $this->test = $test;
- }
-
- /**
- * Accessor for currently running test case.
- * @return SimpleTestCase Current test.
- */
- function getTest() {
- return $this->test;
- }
-
- /**
- * Sets the current reporter. This
- * global instance can be used by the mock objects
- * to send messages.
- * @param SimpleReporter $reporter Reporter to register.
- */
- function setReporter($reporter) {
- $this->clear();
- $this->reporter = $reporter;
- }
-
- /**
- * Accessor for current reporter.
- * @return SimpleReporter Current reporter.
- */
- function getReporter() {
- return $this->reporter;
- }
-
- /**
- * Accessor for the Singleton resource.
- * @return object Global resource.
- */
- function get($resource) {
- if (! isset($this->resources[$resource])) {
- $this->resources[$resource] = new $resource();
- }
- return $this->resources[$resource];
- }
-}
-
-/**
- * Interrogates the stack trace to recover the
- * failure point.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class SimpleStackTrace {
- private $prefixes;
-
- /**
- * Stashes the list of target prefixes.
- * @param array $prefixes List of method prefixes
- * to search for.
- */
- function __construct($prefixes) {
- $this->prefixes = $prefixes;
- }
-
- /**
- * Extracts the last method name that was not within
- * Simpletest itself. Captures a stack trace if none given.
- * @param array $stack List of stack frames.
- * @return string Snippet of test report with line
- * number and file.
- */
- function traceMethod($stack = false) {
- $stack = $stack ? $stack : $this->captureTrace();
- foreach ($stack as $frame) {
- if ($this->frameLiesWithinSimpleTestFolder($frame)) {
- continue;
- }
- if ($this->frameMatchesPrefix($frame)) {
- return ' at [' . $frame['file'] . ' line ' . $frame['line'] . ']';
- }
- }
- return '';
- }
-
- /**
- * Test to see if error is generated by SimpleTest itself.
- * @param array $frame PHP stack frame.
- * @return boolean True if a SimpleTest file.
- */
- protected function frameLiesWithinSimpleTestFolder($frame) {
- if (isset($frame['file'])) {
- $path = substr(SIMPLE_TEST, 0, -1);
- if (strpos($frame['file'], $path) === 0) {
- if (dirname($frame['file']) == $path) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Tries to determine if the method call is an assert, etc.
- * @param array $frame PHP stack frame.
- * @return boolean True if matches a target.
- */
- protected function frameMatchesPrefix($frame) {
- foreach ($this->prefixes as $prefix) {
- if (strncmp($frame['function'], $prefix, strlen($prefix)) == 0) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Grabs a current stack trace.
- * @return array Fulle trace.
- */
- protected function captureTrace() {
- if (function_exists('debug_backtrace')) {
- return array_reverse(debug_backtrace());
- }
- return array();
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/socket.php b/core/vendors/simpletest/socket.php
deleted file mode 100755
index 06e8ca6..0000000
--- a/core/vendors/simpletest/socket.php
+++ /dev/null
@@ -1,312 +0,0 @@
-clearError();
- }
-
- /**
- * Test for an outstanding error.
- * @return boolean True if there is an error.
- * @access public
- */
- function isError() {
- return ($this->error != '');
- }
-
- /**
- * Accessor for an outstanding error.
- * @return string Empty string if no error otherwise
- * the error message.
- * @access public
- */
- function getError() {
- return $this->error;
- }
-
- /**
- * Sets the internal error.
- * @param string Error message to stash.
- * @access protected
- */
- function setError($error) {
- $this->error = $error;
- }
-
- /**
- * Resets the error state to no error.
- * @access protected
- */
- function clearError() {
- $this->setError('');
- }
-}
-
-/**
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleFileSocket extends SimpleStickyError {
- private $handle;
- private $is_open = false;
- private $sent = '';
- private $block_size;
-
- /**
- * Opens a socket for reading and writing.
- * @param SimpleUrl $file Target URI to fetch.
- * @param integer $block_size Size of chunk to read.
- * @access public
- */
- function __construct($file, $block_size = 1024) {
- parent::__construct();
- if (! ($this->handle = $this->openFile($file, $error))) {
- $file_string = $file->asString();
- $this->setError("Cannot open [$file_string] with [$error]");
- return;
- }
- $this->is_open = true;
- $this->block_size = $block_size;
- }
-
- /**
- * Writes some data to the socket and saves alocal copy.
- * @param string $message String to send to socket.
- * @return boolean True if successful.
- * @access public
- */
- function write($message) {
- return true;
- }
-
- /**
- * Reads data from the socket. The error suppresion
- * is a workaround for PHP4 always throwing a warning
- * with a secure socket.
- * @return integer/boolean Incoming bytes. False
- * on error.
- * @access public
- */
- function read() {
- $raw = @fread($this->handle, $this->block_size);
- if ($raw === false) {
- $this->setError('Cannot read from socket');
- $this->close();
- }
- return $raw;
- }
-
- /**
- * Accessor for socket open state.
- * @return boolean True if open.
- * @access public
- */
- function isOpen() {
- return $this->is_open;
- }
-
- /**
- * Closes the socket preventing further reads.
- * Cannot be reopened once closed.
- * @return boolean True if successful.
- * @access public
- */
- function close() {
- if (!$this->is_open) return false;
- $this->is_open = false;
- return fclose($this->handle);
- }
-
- /**
- * Accessor for content so far.
- * @return string Bytes sent only.
- * @access public
- */
- function getSent() {
- return $this->sent;
- }
-
- /**
- * Actually opens the low level socket.
- * @param SimpleUrl $file SimpleUrl file target.
- * @param string $error Recipient of error message.
- * @param integer $timeout Maximum time to wait for connection.
- * @access protected
- */
- protected function openFile($file, &$error) {
- return @fopen($file->asString(), 'r');
- }
-}
-
-/**
- * Wrapper for TCP/IP socket.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleSocket extends SimpleStickyError {
- private $handle;
- private $is_open = false;
- private $sent = '';
- private $lock_size;
-
- /**
- * Opens a socket for reading and writing.
- * @param string $host Hostname to send request to.
- * @param integer $port Port on remote machine to open.
- * @param integer $timeout Connection timeout in seconds.
- * @param integer $block_size Size of chunk to read.
- * @access public
- */
- function __construct($host, $port, $timeout, $block_size = 255) {
- parent::__construct();
- if (! ($this->handle = $this->openSocket($host, $port, $error_number, $error, $timeout))) {
- $this->setError("Cannot open [$host:$port] with [$error] within [$timeout] seconds");
- return;
- }
- $this->is_open = true;
- $this->block_size = $block_size;
- SimpleTestCompatibility::setTimeout($this->handle, $timeout);
- }
-
- /**
- * Writes some data to the socket and saves alocal copy.
- * @param string $message String to send to socket.
- * @return boolean True if successful.
- * @access public
- */
- function write($message) {
- if ($this->isError() || ! $this->isOpen()) {
- return false;
- }
- $count = fwrite($this->handle, $message);
- if (! $count) {
- if ($count === false) {
- $this->setError('Cannot write to socket');
- $this->close();
- }
- return false;
- }
- fflush($this->handle);
- $this->sent .= $message;
- return true;
- }
-
- /**
- * Reads data from the socket. The error suppresion
- * is a workaround for PHP4 always throwing a warning
- * with a secure socket.
- * @return integer/boolean Incoming bytes. False
- * on error.
- * @access public
- */
- function read() {
- if ($this->isError() || ! $this->isOpen()) {
- return false;
- }
- $raw = @fread($this->handle, $this->block_size);
- if ($raw === false) {
- $this->setError('Cannot read from socket');
- $this->close();
- }
- return $raw;
- }
-
- /**
- * Accessor for socket open state.
- * @return boolean True if open.
- * @access public
- */
- function isOpen() {
- return $this->is_open;
- }
-
- /**
- * Closes the socket preventing further reads.
- * Cannot be reopened once closed.
- * @return boolean True if successful.
- * @access public
- */
- function close() {
- $this->is_open = false;
- return fclose($this->handle);
- }
-
- /**
- * Accessor for content so far.
- * @return string Bytes sent only.
- * @access public
- */
- function getSent() {
- return $this->sent;
- }
-
- /**
- * Actually opens the low level socket.
- * @param string $host Host to connect to.
- * @param integer $port Port on host.
- * @param integer $error_number Recipient of error code.
- * @param string $error Recipoent of error message.
- * @param integer $timeout Maximum time to wait for connection.
- * @access protected
- */
- protected function openSocket($host, $port, &$error_number, &$error, $timeout) {
- return @fsockopen($host, $port, $error_number, $error, $timeout);
- }
-}
-
-/**
- * Wrapper for TCP/IP socket over TLS.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleSecureSocket extends SimpleSocket {
-
- /**
- * Opens a secure socket for reading and writing.
- * @param string $host Hostname to send request to.
- * @param integer $port Port on remote machine to open.
- * @param integer $timeout Connection timeout in seconds.
- * @access public
- */
- function __construct($host, $port, $timeout) {
- parent::__construct($host, $port, $timeout);
- }
-
- /**
- * Actually opens the low level socket.
- * @param string $host Host to connect to.
- * @param integer $port Port on host.
- * @param integer $error_number Recipient of error code.
- * @param string $error Recipient of error message.
- * @param integer $timeout Maximum time to wait for connection.
- * @access protected
- */
- function openSocket($host, $port, &$error_number, &$error, $timeout) {
- return parent::openSocket("tls://$host", $port, $error_number, $error, $timeout);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/tag.php b/core/vendors/simpletest/tag.php
deleted file mode 100755
index afe649e..0000000
--- a/core/vendors/simpletest/tag.php
+++ /dev/null
@@ -1,1527 +0,0 @@
- 'SimpleAnchorTag',
- 'title' => 'SimpleTitleTag',
- 'base' => 'SimpleBaseTag',
- 'button' => 'SimpleButtonTag',
- 'textarea' => 'SimpleTextAreaTag',
- 'option' => 'SimpleOptionTag',
- 'label' => 'SimpleLabelTag',
- 'form' => 'SimpleFormTag',
- 'frame' => 'SimpleFrameTag');
- $attributes = $this->keysToLowerCase($attributes);
- if (array_key_exists($name, $map)) {
- $tag_class = $map[$name];
- return new $tag_class($attributes);
- } elseif ($name == 'select') {
- return $this->createSelectionTag($attributes);
- } elseif ($name == 'input') {
- return $this->createInputTag($attributes);
- }
- return new SimpleTag($name, $attributes);
- }
-
- /**
- * Factory for selection fields.
- * @param hash $attributes Element attributes.
- * @return SimpleTag Tag object.
- * @access protected
- */
- protected function createSelectionTag($attributes) {
- if (isset($attributes['multiple'])) {
- return new MultipleSelectionTag($attributes);
- }
- return new SimpleSelectionTag($attributes);
- }
-
- /**
- * Factory for input tags.
- * @param hash $attributes Element attributes.
- * @return SimpleTag Tag object.
- * @access protected
- */
- protected function createInputTag($attributes) {
- if (! isset($attributes['type'])) {
- return new SimpleTextTag($attributes);
- }
- $type = strtolower(trim($attributes['type']));
- $map = array(
- 'submit' => 'SimpleSubmitTag',
- 'image' => 'SimpleImageSubmitTag',
- 'checkbox' => 'SimpleCheckboxTag',
- 'radio' => 'SimpleRadioButtonTag',
- 'text' => 'SimpleTextTag',
- 'hidden' => 'SimpleTextTag',
- 'password' => 'SimpleTextTag',
- 'file' => 'SimpleUploadTag');
- if (array_key_exists($type, $map)) {
- $tag_class = $map[$type];
- return new $tag_class($attributes);
- }
- return false;
- }
-
- /**
- * Make the keys lower case for case insensitive look-ups.
- * @param hash $map Hash to convert.
- * @return hash Unchanged values, but keys lower case.
- * @access private
- */
- protected function keysToLowerCase($map) {
- $lower = array();
- foreach ($map as $key => $value) {
- $lower[strtolower($key)] = $value;
- }
- return $lower;
- }
-}
-
-/**
- * HTML or XML tag.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleTag {
- private $name;
- private $attributes;
- private $content;
-
- /**
- * Starts with a named tag with attributes only.
- * @param string $name Tag name.
- * @param hash $attributes Attribute names and
- * string values. Note that
- * the keys must have been
- * converted to lower case.
- */
- function __construct($name, $attributes) {
- $this->name = strtolower(trim($name));
- $this->attributes = $attributes;
- $this->content = '';
- }
-
- /**
- * Check to see if the tag can have both start and
- * end tags with content in between.
- * @return boolean True if content allowed.
- * @access public
- */
- function expectEndTag() {
- return true;
- }
-
- /**
- * The current tag should not swallow all content for
- * itself as it's searchable page content. Private
- * content tags are usually widgets that contain default
- * values.
- * @return boolean False as content is available
- * to other tags by default.
- * @access public
- */
- function isPrivateContent() {
- return false;
- }
-
- /**
- * Appends string content to the current content.
- * @param string $content Additional text.
- * @access public
- */
- function addContent($content) {
- $this->content .= (string)$content;
- return $this;
- }
-
- /**
- * Adds an enclosed tag to the content.
- * @param SimpleTag $tag New tag.
- * @access public
- */
- function addTag($tag) {
- }
-
- /**
- * Adds multiple enclosed tags to the content.
- * @param array List of SimpleTag objects to be added.
- */
- function addTags($tags) {
- foreach ($tags as $tag) {
- $this->addTag($tag);
- }
- }
-
- /**
- * Accessor for tag name.
- * @return string Name of tag.
- * @access public
- */
- function getTagName() {
- return $this->name;
- }
-
- /**
- * List of legal child elements.
- * @return array List of element names.
- * @access public
- */
- function getChildElements() {
- return array();
- }
-
- /**
- * Accessor for an attribute.
- * @param string $label Attribute name.
- * @return string Attribute value.
- * @access public
- */
- function getAttribute($label) {
- $label = strtolower($label);
- if (! isset($this->attributes[$label])) {
- return false;
- }
- return (string)$this->attributes[$label];
- }
-
- /**
- * Sets an attribute.
- * @param string $label Attribute name.
- * @return string $value New attribute value.
- * @access protected
- */
- protected function setAttribute($label, $value) {
- $this->attributes[strtolower($label)] = $value;
- }
-
- /**
- * Accessor for the whole content so far.
- * @return string Content as big raw string.
- * @access public
- */
- function getContent() {
- return $this->content;
- }
-
- /**
- * Accessor for content reduced to visible text. Acts
- * like a text mode browser, normalising space and
- * reducing images to their alt text.
- * @return string Content as plain text.
- * @access public
- */
- function getText() {
- return SimplePage::normalise($this->content);
- }
-
- /**
- * Test to see if id attribute matches.
- * @param string $id ID to test against.
- * @return boolean True on match.
- * @access public
- */
- function isId($id) {
- return ($this->getAttribute('id') == $id);
- }
-}
-
-/**
- * Base url.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleBaseTag extends SimpleTag {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('base', $attributes);
- }
-
- /**
- * Base tag is not a block tag.
- * @return boolean false
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-}
-
-/**
- * Page title.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleTitleTag extends SimpleTag {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('title', $attributes);
- }
-}
-
-/**
- * Link.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleAnchorTag extends SimpleTag {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('a', $attributes);
- }
-
- /**
- * Accessor for URL as string.
- * @return string Coerced as string.
- * @access public
- */
- function getHref() {
- $url = $this->getAttribute('href');
- if (is_bool($url)) {
- $url = '';
- }
- return $url;
- }
-}
-
-/**
- * Form element.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleWidget extends SimpleTag {
- private $value;
- private $label;
- private $is_set;
-
- /**
- * Starts with a named tag with attributes only.
- * @param string $name Tag name.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($name, $attributes) {
- parent::__construct($name, $attributes);
- $this->value = false;
- $this->label = false;
- $this->is_set = false;
- }
-
- /**
- * Accessor for name submitted as the key in
- * GET/POST privateiables hash.
- * @return string Parsed value.
- * @access public
- */
- function getName() {
- return $this->getAttribute('name');
- }
-
- /**
- * Accessor for default value parsed with the tag.
- * @return string Parsed value.
- * @access public
- */
- function getDefault() {
- return $this->getAttribute('value');
- }
-
- /**
- * Accessor for currently set value or default if
- * none.
- * @return string Value set by form or default
- * if none.
- * @access public
- */
- function getValue() {
- if (! $this->is_set) {
- return $this->getDefault();
- }
- return $this->value;
- }
-
- /**
- * Sets the current form element value.
- * @param string $value New value.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- $this->value = $value;
- $this->is_set = true;
- return true;
- }
-
- /**
- * Resets the form element value back to the
- * default.
- * @access public
- */
- function resetValue() {
- $this->is_set = false;
- }
-
- /**
- * Allows setting of a label externally, say by a
- * label tag.
- * @param string $label Label to attach.
- * @access public
- */
- function setLabel($label) {
- $this->label = trim($label);
- return $this;
- }
-
- /**
- * Reads external or internal label.
- * @param string $label Label to test.
- * @return boolean True is match.
- * @access public
- */
- function isLabel($label) {
- return $this->label == trim($label);
- }
-
- /**
- * Dispatches the value into the form encoded packet.
- * @param SimpleEncoding $encoding Form packet.
- * @access public
- */
- function write($encoding) {
- if ($this->getName()) {
- $encoding->add($this->getName(), $this->getValue());
- }
- }
-}
-
-/**
- * Text, password and hidden field.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleTextTag extends SimpleWidget {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('input', $attributes);
- if ($this->getAttribute('value') === false) {
- $this->setAttribute('value', '');
- }
- }
-
- /**
- * Tag contains no content.
- * @return boolean False.
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-
- /**
- * Sets the current form element value. Cannot
- * change the value of a hidden field.
- * @param string $value New value.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- if ($this->getAttribute('type') == 'hidden') {
- return false;
- }
- return parent::setValue($value);
- }
-}
-
-/**
- * Submit button as input tag.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleSubmitTag extends SimpleWidget {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('input', $attributes);
- if ($this->getAttribute('value') === false) {
- $this->setAttribute('value', 'Submit');
- }
- }
-
- /**
- * Tag contains no end element.
- * @return boolean False.
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-
- /**
- * Disables the setting of the button value.
- * @param string $value Ignored.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- return false;
- }
-
- /**
- * Value of browser visible text.
- * @return string Visible label.
- * @access public
- */
- function getLabel() {
- return $this->getValue();
- }
-
- /**
- * Test for a label match when searching.
- * @param string $label Label to test.
- * @return boolean True on match.
- * @access public
- */
- function isLabel($label) {
- return trim($label) == trim($this->getLabel());
- }
-}
-
-/**
- * Image button as input tag.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleImageSubmitTag extends SimpleWidget {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('input', $attributes);
- }
-
- /**
- * Tag contains no end element.
- * @return boolean False.
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-
- /**
- * Disables the setting of the button value.
- * @param string $value Ignored.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- return false;
- }
-
- /**
- * Value of browser visible text.
- * @return string Visible label.
- * @access public
- */
- function getLabel() {
- if ($this->getAttribute('title')) {
- return $this->getAttribute('title');
- }
- return $this->getAttribute('alt');
- }
-
- /**
- * Test for a label match when searching.
- * @param string $label Label to test.
- * @return boolean True on match.
- * @access public
- */
- function isLabel($label) {
- return trim($label) == trim($this->getLabel());
- }
-
- /**
- * Dispatches the value into the form encoded packet.
- * @param SimpleEncoding $encoding Form packet.
- * @param integer $x X coordinate of click.
- * @param integer $y Y coordinate of click.
- * @access public
- */
- function write($encoding, $x = 1, $y = 1) {
- if ($this->getName()) {
- $encoding->add($this->getName() . '.x', $x);
- $encoding->add($this->getName() . '.y', $y);
- } else {
- $encoding->add('x', $x);
- $encoding->add('y', $y);
- }
- }
-}
-
-/**
- * Submit button as button tag.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleButtonTag extends SimpleWidget {
-
- /**
- * Starts with a named tag with attributes only.
- * Defaults are very browser dependent.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('button', $attributes);
- }
-
- /**
- * Check to see if the tag can have both start and
- * end tags with content in between.
- * @return boolean True if content allowed.
- * @access public
- */
- function expectEndTag() {
- return true;
- }
-
- /**
- * Disables the setting of the button value.
- * @param string $value Ignored.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- return false;
- }
-
- /**
- * Value of browser visible text.
- * @return string Visible label.
- * @access public
- */
- function getLabel() {
- return $this->getContent();
- }
-
- /**
- * Test for a label match when searching.
- * @param string $label Label to test.
- * @return boolean True on match.
- * @access public
- */
- function isLabel($label) {
- return trim($label) == trim($this->getLabel());
- }
-}
-
-/**
- * Content tag for text area.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleTextAreaTag extends SimpleWidget {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('textarea', $attributes);
- }
-
- /**
- * Accessor for starting value.
- * @return string Parsed value.
- * @access public
- */
- function getDefault() {
- return $this->wrap(html_entity_decode($this->getContent(), ENT_QUOTES));
- }
-
- /**
- * Applies word wrapping if needed.
- * @param string $value New value.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- return parent::setValue($this->wrap($value));
- }
-
- /**
- * Test to see if text should be wrapped.
- * @return boolean True if wrapping on.
- * @access private
- */
- function wrapIsEnabled() {
- if ($this->getAttribute('cols')) {
- $wrap = $this->getAttribute('wrap');
- if (($wrap == 'physical') || ($wrap == 'hard')) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Performs the formatting that is peculiar to
- * this tag. There is strange behaviour in this
- * one, including stripping a leading new line.
- * Go figure. I am using Firefox as a guide.
- * @param string $text Text to wrap.
- * @return string Text wrapped with carriage
- * returns and line feeds
- * @access private
- */
- protected function wrap($text) {
- $text = str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $text));
- $text = str_replace("\r\n\n", "\r\n", str_replace("\r", "\r\n", $text));
- if (strncmp($text, "\r\n", strlen("\r\n")) == 0) {
- $text = substr($text, strlen("\r\n"));
- }
- if ($this->wrapIsEnabled()) {
- return wordwrap(
- $text,
- (integer)$this->getAttribute('cols'),
- "\r\n");
- }
- return $text;
- }
-
- /**
- * The content of textarea is not part of the page.
- * @return boolean True.
- * @access public
- */
- function isPrivateContent() {
- return true;
- }
-}
-
-/**
- * File upload widget.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleUploadTag extends SimpleWidget {
-
- /**
- * Starts with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('input', $attributes);
- }
-
- /**
- * Tag contains no content.
- * @return boolean False.
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-
- /**
- * Dispatches the value into the form encoded packet.
- * @param SimpleEncoding $encoding Form packet.
- * @access public
- */
- function write($encoding) {
- if (! file_exists($this->getValue())) {
- return;
- }
- $encoding->attach(
- $this->getName(),
- implode('', file($this->getValue())),
- basename($this->getValue()));
- }
-}
-
-/**
- * Drop down widget.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleSelectionTag extends SimpleWidget {
- private $options;
- private $choice;
-
- /**
- * Starts with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('select', $attributes);
- $this->options = array();
- $this->choice = false;
- }
-
- /**
- * Adds an option tag to a selection field.
- * @param SimpleOptionTag $tag New option.
- * @access public
- */
- function addTag($tag) {
- if ($tag->getTagName() == 'option') {
- $this->options[] = $tag;
- }
- }
-
- /**
- * Text within the selection element is ignored.
- * @param string $content Ignored.
- * @access public
- */
- function addContent($content) {
- return $this;
- }
-
- /**
- * Scans options for defaults. If none, then
- * the first option is selected.
- * @return string Selected field.
- * @access public
- */
- function getDefault() {
- for ($i = 0, $count = count($this->options); $i < $count; $i++) {
- if ($this->options[$i]->getAttribute('selected') !== false) {
- return $this->options[$i]->getDefault();
- }
- }
- if ($count > 0) {
- return $this->options[0]->getDefault();
- }
- return '';
- }
-
- /**
- * Can only set allowed values.
- * @param string $value New choice.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- for ($i = 0, $count = count($this->options); $i < $count; $i++) {
- if ($this->options[$i]->isValue($value)) {
- $this->choice = $i;
- return true;
- }
- }
- return false;
- }
-
- /**
- * Accessor for current selection value.
- * @return string Value attribute or
- * content of opton.
- * @access public
- */
- function getValue() {
- if ($this->choice === false) {
- return $this->getDefault();
- }
- return $this->options[$this->choice]->getValue();
- }
-}
-
-/**
- * Drop down widget.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class MultipleSelectionTag extends SimpleWidget {
- private $options;
- private $values;
-
- /**
- * Starts with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('select', $attributes);
- $this->options = array();
- $this->values = false;
- }
-
- /**
- * Adds an option tag to a selection field.
- * @param SimpleOptionTag $tag New option.
- * @access public
- */
- function addTag($tag) {
- if ($tag->getTagName() == 'option') {
- $this->options[] = &$tag;
- }
- }
-
- /**
- * Text within the selection element is ignored.
- * @param string $content Ignored.
- * @access public
- */
- function addContent($content) {
- return $this;
- }
-
- /**
- * Scans options for defaults to populate the
- * value array().
- * @return array Selected fields.
- * @access public
- */
- function getDefault() {
- $default = array();
- for ($i = 0, $count = count($this->options); $i < $count; $i++) {
- if ($this->options[$i]->getAttribute('selected') !== false) {
- $default[] = $this->options[$i]->getDefault();
- }
- }
- return $default;
- }
-
- /**
- * Can only set allowed values. Any illegal value
- * will result in a failure, but all correct values
- * will be set.
- * @param array $desired New choices.
- * @return boolean True if all allowed.
- * @access public
- */
- function setValue($desired) {
- $achieved = array();
- foreach ($desired as $value) {
- $success = false;
- for ($i = 0, $count = count($this->options); $i < $count; $i++) {
- if ($this->options[$i]->isValue($value)) {
- $achieved[] = $this->options[$i]->getValue();
- $success = true;
- break;
- }
- }
- if (! $success) {
- return false;
- }
- }
- $this->values = $achieved;
- return true;
- }
-
- /**
- * Accessor for current selection value.
- * @return array List of currently set options.
- * @access public
- */
- function getValue() {
- if ($this->values === false) {
- return $this->getDefault();
- }
- return $this->values;
- }
-}
-
-/**
- * Option for selection field.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleOptionTag extends SimpleWidget {
-
- /**
- * Stashes the attributes.
- */
- function __construct($attributes) {
- parent::__construct('option', $attributes);
- }
-
- /**
- * Does nothing.
- * @param string $value Ignored.
- * @return boolean Not allowed.
- * @access public
- */
- function setValue($value) {
- return false;
- }
-
- /**
- * Test to see if a value matches the option.
- * @param string $compare Value to compare with.
- * @return boolean True if possible match.
- * @access public
- */
- function isValue($compare) {
- $compare = trim($compare);
- if (trim($this->getValue()) == $compare) {
- return true;
- }
- return trim(strip_tags($this->getContent())) == $compare;
- }
-
- /**
- * Accessor for starting value. Will be set to
- * the option label if no value exists.
- * @return string Parsed value.
- * @access public
- */
- function getDefault() {
- if ($this->getAttribute('value') === false) {
- return strip_tags($this->getContent());
- }
- return $this->getAttribute('value');
- }
-
- /**
- * The content of options is not part of the page.
- * @return boolean True.
- * @access public
- */
- function isPrivateContent() {
- return true;
- }
-}
-
-/**
- * Radio button.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleRadioButtonTag extends SimpleWidget {
-
- /**
- * Stashes the attributes.
- * @param array $attributes Hash of attributes.
- */
- function __construct($attributes) {
- parent::__construct('input', $attributes);
- if ($this->getAttribute('value') === false) {
- $this->setAttribute('value', 'on');
- }
- }
-
- /**
- * Tag contains no content.
- * @return boolean False.
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-
- /**
- * The only allowed value sn the one in the
- * "value" attribute.
- * @param string $value New value.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- if ($value === false) {
- return parent::setValue($value);
- }
- if ($value != $this->getAttribute('value')) {
- return false;
- }
- return parent::setValue($value);
- }
-
- /**
- * Accessor for starting value.
- * @return string Parsed value.
- * @access public
- */
- function getDefault() {
- if ($this->getAttribute('checked') !== false) {
- return $this->getAttribute('value');
- }
- return false;
- }
-}
-
-/**
- * Checkbox widget.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleCheckboxTag extends SimpleWidget {
-
- /**
- * Starts with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('input', $attributes);
- if ($this->getAttribute('value') === false) {
- $this->setAttribute('value', 'on');
- }
- }
-
- /**
- * Tag contains no content.
- * @return boolean False.
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-
- /**
- * The only allowed value in the one in the
- * "value" attribute. The default for this
- * attribute is "on". If this widget is set to
- * true, then the usual value will be taken.
- * @param string $value New value.
- * @return boolean True if allowed.
- * @access public
- */
- function setValue($value) {
- if ($value === false) {
- return parent::setValue($value);
- }
- if ($value === true) {
- return parent::setValue($this->getAttribute('value'));
- }
- if ($value != $this->getAttribute('value')) {
- return false;
- }
- return parent::setValue($value);
- }
-
- /**
- * Accessor for starting value. The default
- * value is "on".
- * @return string Parsed value.
- * @access public
- */
- function getDefault() {
- if ($this->getAttribute('checked') !== false) {
- return $this->getAttribute('value');
- }
- return false;
- }
-}
-
-/**
- * A group of multiple widgets with some shared behaviour.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleTagGroup {
- private $widgets = array();
-
- /**
- * Adds a tag to the group.
- * @param SimpleWidget $widget
- * @access public
- */
- function addWidget($widget) {
- $this->widgets[] = $widget;
- }
-
- /**
- * Accessor to widget set.
- * @return array All widgets.
- * @access protected
- */
- protected function &getWidgets() {
- return $this->widgets;
- }
-
- /**
- * Accessor for an attribute.
- * @param string $label Attribute name.
- * @return boolean Always false.
- * @access public
- */
- function getAttribute($label) {
- return false;
- }
-
- /**
- * Fetches the name for the widget from the first
- * member.
- * @return string Name of widget.
- * @access public
- */
- function getName() {
- if (count($this->widgets) > 0) {
- return $this->widgets[0]->getName();
- }
- }
-
- /**
- * Scans the widgets for one with the appropriate
- * ID field.
- * @param string $id ID value to try.
- * @return boolean True if matched.
- * @access public
- */
- function isId($id) {
- for ($i = 0, $count = count($this->widgets); $i < $count; $i++) {
- if ($this->widgets[$i]->isId($id)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Scans the widgets for one with the appropriate
- * attached label.
- * @param string $label Attached label to try.
- * @return boolean True if matched.
- * @access public
- */
- function isLabel($label) {
- for ($i = 0, $count = count($this->widgets); $i < $count; $i++) {
- if ($this->widgets[$i]->isLabel($label)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Dispatches the value into the form encoded packet.
- * @param SimpleEncoding $encoding Form packet.
- * @access public
- */
- function write($encoding) {
- $encoding->add($this->getName(), $this->getValue());
- }
-}
-
-/**
- * A group of tags with the same name within a form.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleCheckboxGroup extends SimpleTagGroup {
-
- /**
- * Accessor for current selected widget or false
- * if none.
- * @return string/array Widget values or false if none.
- * @access public
- */
- function getValue() {
- $values = array();
- $widgets = $this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- if ($widgets[$i]->getValue() !== false) {
- $values[] = $widgets[$i]->getValue();
- }
- }
- return $this->coerceValues($values);
- }
-
- /**
- * Accessor for starting value that is active.
- * @return string/array Widget values or false if none.
- * @access public
- */
- function getDefault() {
- $values = array();
- $widgets = $this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- if ($widgets[$i]->getDefault() !== false) {
- $values[] = $widgets[$i]->getDefault();
- }
- }
- return $this->coerceValues($values);
- }
-
- /**
- * Accessor for current set values.
- * @param string/array/boolean $values Either a single string, a
- * hash or false for nothing set.
- * @return boolean True if all values can be set.
- * @access public
- */
- function setValue($values) {
- $values = $this->makeArray($values);
- if (! $this->valuesArePossible($values)) {
- return false;
- }
- $widgets = $this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- $possible = $widgets[$i]->getAttribute('value');
- if (in_array($widgets[$i]->getAttribute('value'), $values)) {
- $widgets[$i]->setValue($possible);
- } else {
- $widgets[$i]->setValue(false);
- }
- }
- return true;
- }
-
- /**
- * Tests to see if a possible value set is legal.
- * @param string/array/boolean $values Either a single string, a
- * hash or false for nothing set.
- * @return boolean False if trying to set a
- * missing value.
- * @access private
- */
- protected function valuesArePossible($values) {
- $matches = array();
- $widgets = &$this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- $possible = $widgets[$i]->getAttribute('value');
- if (in_array($possible, $values)) {
- $matches[] = $possible;
- }
- }
- return ($values == $matches);
- }
-
- /**
- * Converts the output to an appropriate format. This means
- * that no values is false, a single value is just that
- * value and only two or more are contained in an array.
- * @param array $values List of values of widgets.
- * @return string/array/boolean Expected format for a tag.
- * @access private
- */
- protected function coerceValues($values) {
- if (count($values) == 0) {
- return false;
- } elseif (count($values) == 1) {
- return $values[0];
- } else {
- return $values;
- }
- }
-
- /**
- * Converts false or string into array. The opposite of
- * the coercian method.
- * @param string/array/boolean $value A single item is converted
- * to a one item list. False
- * gives an empty list.
- * @return array List of values, possibly empty.
- * @access private
- */
- protected function makeArray($value) {
- if ($value === false) {
- return array();
- }
- if (is_string($value)) {
- return array($value);
- }
- return $value;
- }
-}
-
-/**
- * A group of tags with the same name within a form.
- * Used for radio buttons.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleRadioGroup extends SimpleTagGroup {
-
- /**
- * Each tag is tried in turn until one is
- * successfully set. The others will be
- * unchecked if successful.
- * @param string $value New value.
- * @return boolean True if any allowed.
- * @access public
- */
- function setValue($value) {
- if (! $this->valueIsPossible($value)) {
- return false;
- }
- $index = false;
- $widgets = $this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- if (! $widgets[$i]->setValue($value)) {
- $widgets[$i]->setValue(false);
- }
- }
- return true;
- }
-
- /**
- * Tests to see if a value is allowed.
- * @param string Attempted value.
- * @return boolean True if a valid value.
- * @access private
- */
- protected function valueIsPossible($value) {
- $widgets = $this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- if ($widgets[$i]->getAttribute('value') == $value) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Accessor for current selected widget or false
- * if none.
- * @return string/boolean Value attribute or
- * content of opton.
- * @access public
- */
- function getValue() {
- $widgets = $this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- if ($widgets[$i]->getValue() !== false) {
- return $widgets[$i]->getValue();
- }
- }
- return false;
- }
-
- /**
- * Accessor for starting value that is active.
- * @return string/boolean Value of first checked
- * widget or false if none.
- * @access public
- */
- function getDefault() {
- $widgets = $this->getWidgets();
- for ($i = 0, $count = count($widgets); $i < $count; $i++) {
- if ($widgets[$i]->getDefault() !== false) {
- return $widgets[$i]->getDefault();
- }
- }
- return false;
- }
-}
-
-/**
- * Tag to keep track of labels.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleLabelTag extends SimpleTag {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('label', $attributes);
- }
-
- /**
- * Access for the ID to attach the label to.
- * @return string For attribute.
- * @access public
- */
- function getFor() {
- return $this->getAttribute('for');
- }
-}
-
-/**
- * Tag to aid parsing the form.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleFormTag extends SimpleTag {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('form', $attributes);
- }
-}
-
-/**
- * Tag to aid parsing the frames in a page.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class SimpleFrameTag extends SimpleTag {
-
- /**
- * Starts with a named tag with attributes only.
- * @param hash $attributes Attribute names and
- * string values.
- */
- function __construct($attributes) {
- parent::__construct('frame', $attributes);
- }
-
- /**
- * Tag contains no content.
- * @return boolean False.
- * @access public
- */
- function expectEndTag() {
- return false;
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/acceptance_test.php b/core/vendors/simpletest/test/acceptance_test.php
deleted file mode 100755
index e96fe73..0000000
--- a/core/vendors/simpletest/test/acceptance_test.php
+++ /dev/null
@@ -1,1729 +0,0 @@
-addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $this->assertTrue($browser->get($this->samples() . 'network_confirm.php'));
- $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
- $this->assertPattern('/Request method.*?GET<\/dd>/', $browser->getContent());
- $this->assertEqual($browser->getTitle(), 'Simple test target file');
- $this->assertEqual($browser->getResponseCode(), 200);
- $this->assertEqual($browser->getMimeType(), 'text/html');
- }
-
- function testPost() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $this->assertTrue($browser->post($this->samples() . 'network_confirm.php'));
- $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
- $this->assertPattern('/Request method.*?POST<\/dd>/', $browser->getContent());
- }
-
- function testAbsoluteLinkFollowing() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'link_confirm.php');
- $this->assertTrue($browser->clickLink('Absolute'));
- $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
- }
-
- function testRelativeEncodedLinkFollowing() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'link_confirm.php');
- // Warning: the below data is ISO 8859-1 encoded
- $this->assertTrue($browser->clickLink("m\xE4rc\xEAl kiek'eboe"));
- $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
- }
-
- function testRelativeLinkFollowing() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'link_confirm.php');
- $this->assertTrue($browser->clickLink('Relative'));
- $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
- }
-
- function testUnifiedClickLinkClicking() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'link_confirm.php');
- $this->assertTrue($browser->click('Relative'));
- $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
- }
-
- function testIdLinkFollowing() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'link_confirm.php');
- $this->assertTrue($browser->clickLinkById(1));
- $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
- }
-
- function testCookieReading() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'set_cookies.php');
- $this->assertEqual($browser->getCurrentCookieValue('session_cookie'), 'A');
- $this->assertEqual($browser->getCurrentCookieValue('short_cookie'), 'B');
- $this->assertEqual($browser->getCurrentCookieValue('day_cookie'), 'C');
- }
-
- function testSimpleSubmit() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'form.html');
- $this->assertTrue($browser->clickSubmit('Go!'));
- $this->assertPattern('/Request method.*?POST<\/dd>/', $browser->getContent());
- $this->assertPattern('/go=\[Go!\]/', $browser->getContent());
- }
-
- function testUnifiedClickCanSubmit() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $browser->get($this->samples() . 'form.html');
- $this->assertTrue($browser->click('Go!'));
- $this->assertPattern('/go=\[Go!\]/', $browser->getContent());
- }
-}
-
-class TestOfLocalFileBrowser extends UnitTestCase {
- function samples() {
- return 'file://'.dirname(__FILE__).'/site/';
- }
-
- function testGet() {
- $browser = new SimpleBrowser();
- $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- $this->assertTrue($browser->get($this->samples() . 'file.html'));
- $this->assertPattern('/Link to SimpleTest/', $browser->getContent());
- $this->assertEqual($browser->getTitle(), 'Link to SimpleTest');
- $this->assertFalse($browser->getResponseCode());
- $this->assertEqual($browser->getMimeType(), '');
- }
-}
-
-class TestOfRequestMethods extends UnitTestCase {
- function samples() {
- return SimpleTestAcceptanceTest::samples();
- }
-
- function testHeadRequest() {
- $browser = new SimpleBrowser();
- $this->assertTrue($browser->head($this->samples() . 'request_methods.php'));
- $this->assertEqual($browser->getResponseCode(), 202);
- }
-
- function testGetRequest() {
- $browser = new SimpleBrowser();
- $this->assertTrue($browser->get($this->samples() . 'request_methods.php'));
- $this->assertEqual($browser->getResponseCode(), 405);
- }
-
- function testPostWithPlainEncoding() {
- $browser = new SimpleBrowser();
- $this->assertTrue($browser->post($this->samples() . 'request_methods.php', 'A content message'));
- $this->assertEqual($browser->getResponseCode(), 406);
- $this->assertPattern('/Please ensure content type is an XML format/', $browser->getContent());
- }
-
- function testPostWithXmlEncoding() {
- $browser = new SimpleBrowser();
- $this->assertTrue($browser->post($this->samples() . 'request_methods.php', 'c ', 'text/xml'));
- $this->assertEqual($browser->getResponseCode(), 201);
- $this->assertPattern('/c/', $browser->getContent());
- }
-
- function testPutWithPlainEncoding() {
- $browser = new SimpleBrowser();
- $this->assertTrue($browser->put($this->samples() . 'request_methods.php', 'A content message'));
- $this->assertEqual($browser->getResponseCode(), 406);
- $this->assertPattern('/Please ensure content type is an XML format/', $browser->getContent());
- }
-
- function testPutWithXmlEncoding() {
- $browser = new SimpleBrowser();
- $this->assertTrue($browser->put($this->samples() . 'request_methods.php', 'c ', 'application/xml'));
- $this->assertEqual($browser->getResponseCode(), 201);
- $this->assertPattern('/c/', $browser->getContent());
- }
-
- function testDeleteRequest() {
- $browser = new SimpleBrowser();
- $browser->delete($this->samples() . 'request_methods.php');
- $this->assertEqual($browser->getResponseCode(), 202);
- $this->assertPattern('/Your delete request was accepted/', $browser->getContent());
- }
-
-}
-
-class TestRadioFields extends SimpleTestAcceptanceTest {
- function testSetFieldAsInteger() {
- $this->get($this->samples() . 'form_with_radio_buttons.html');
- $this->assertTrue($this->setField('tested_field', 2));
- $this->clickSubmitByName('send');
- $this->assertEqual($this->getUrl(), $this->samples() . 'form_with_radio_buttons.html?tested_field=2&send=click+me');
- }
-
- function testSetFieldAsString() {
- $this->get($this->samples() . 'form_with_radio_buttons.html');
- $this->assertTrue($this->setField('tested_field', '2'));
- $this->clickSubmitByName('send');
- $this->assertEqual($this->getUrl(), $this->samples() . 'form_with_radio_buttons.html?tested_field=2&send=click+me');
- }
-}
-
-class TestOfLiveFetching extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testFormWithArrayBasedInputs() {
- $this->get($this->samples() . 'form_with_array_based_inputs.php');
- $this->setField('value[]', '3', '1');
- $this->setField('value[]', '4', '2');
- $this->clickSubmit('Go');
- $this->assertPattern('/QUERY_STRING : value%5B%5D=3&value%5B%5D=4&submit=Go/');
- }
-
- function testFormWithQuotedValues() {
- $this->get($this->samples() . 'form_with_quoted_values.php');
- $this->assertField('a', 'default');
- $this->assertFieldById('text_field', 'default');
- $this->clickSubmit('Go');
- $this->assertPattern('/a=default&submit=Go/');
- }
-
- function testGet() {
- $this->assertTrue($this->get($this->samples() . 'network_confirm.php'));
- $this->assertEqual($this->getUrl(), $this->samples() . 'network_confirm.php');
- $this->assertText('target for the SimpleTest');
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertTitle('Simple test target file');
- $this->assertTitle(new PatternExpectation('/target file/'));
- $this->assertResponse(200);
- $this->assertMime('text/html');
- $this->assertHeader('connection', 'close');
- $this->assertHeader('connection', new PatternExpectation('/los/'));
- }
-
- function testSlowGet() {
- $this->assertTrue($this->get($this->samples() . 'slow_page.php'));
- }
-
- function testTimedOutGet() {
- $this->setConnectionTimeout(1);
- $this->ignoreErrors();
- $this->assertFalse($this->get($this->samples() . 'slow_page.php'));
- }
-
- function testPost() {
- $this->assertTrue($this->post($this->samples() . 'network_confirm.php'));
- $this->assertText('target for the SimpleTest');
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- }
-
- function testGetWithData() {
- $this->get($this->samples() . 'network_confirm.php', array("a" => "aaa"));
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertText('a=[aaa]');
- }
-
- function testPostWithData() {
- $this->post($this->samples() . 'network_confirm.php', array("a" => "aaa"));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aaa]');
- }
-
- function testPostWithRecursiveData() {
- $this->post($this->samples() . 'network_confirm.php', array("a" => "aaa"));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aaa]');
-
- $this->post($this->samples() . 'network_confirm.php', array("a[aa]" => "aaa"));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aa=[aaa]]');
-
- $this->post($this->samples() . 'network_confirm.php', array("a[aa][aaa]" => "aaaa"));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aa=[aaa=[aaaa]]]');
-
- $this->post($this->samples() . 'network_confirm.php', array("a" => array("aa" => "aaa")));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aa=[aaa]]');
-
- $this->post($this->samples() . 'network_confirm.php', array("a" => array("aa" => array("aaa" => "aaaa"))));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aa=[aaa=[aaaa]]]');
- }
-
- function testRelativeGet() {
- $this->get($this->samples() . 'link_confirm.php');
- $this->assertTrue($this->get('network_confirm.php'));
- $this->assertText('target for the SimpleTest');
- }
-
- function testRelativePost() {
- $this->post($this->samples() . 'link_confirm.php', array('a' => '123'));
- $this->assertTrue($this->post('network_confirm.php'));
- $this->assertText('target for the SimpleTest');
- }
-}
-
-class TestOfLinkFollowing extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testLinkAssertions() {
- $this->get($this->samples() . 'link_confirm.php');
- $this->assertLink('Absolute', $this->samples() . 'network_confirm.php');
- $this->assertLink('Absolute', new PatternExpectation('/confirm/'));
- $this->assertClickable('Absolute');
- }
-
- function testAbsoluteLinkFollowing() {
- $this->get($this->samples() . 'link_confirm.php');
- $this->assertTrue($this->clickLink('Absolute'));
- $this->assertText('target for the SimpleTest');
- }
-
- function testRelativeLinkFollowing() {
- $this->get($this->samples() . 'link_confirm.php');
- $this->assertTrue($this->clickLink('Relative'));
- $this->assertText('target for the SimpleTest');
- }
-
- function testLinkIdFollowing() {
- $this->get($this->samples() . 'link_confirm.php');
- $this->assertLinkById(1);
- $this->assertTrue($this->clickLinkById(1));
- $this->assertText('target for the SimpleTest');
- }
-
- function testAbsoluteUrlBehavesAbsolutely() {
- $this->get($this->samples() . 'link_confirm.php');
- $this->get('http://www.lastcraft.com');
- $this->assertText('No guarantee of quality is given or even intended');
- }
-
- function testRelativeUrlRespectsBaseTag() {
- $this->get($this->samples() . 'base_tag/base_link.html');
- $this->click('Back to test pages');
- $this->assertTitle('Simple test target file');
- }
-}
-
-class TestOfLivePageLinkingWithMinimalLinks extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testClickToExplicitelyNamedSelfReturns() {
- $this->get($this->samples() . 'front_controller_style/a_page.php');
- $this->assertEqual($this->getUrl(), $this->samples() . 'front_controller_style/a_page.php');
- $this->assertTitle('Simple test page with links');
- $this->assertLink('Self');
- $this->clickLink('Self');
- $this->assertTitle('Simple test page with links');
- }
-
- function testClickToMissingPageReturnsToSamePage() {
- $this->get($this->samples() . 'front_controller_style/a_page.php');
- $this->clickLink('No page');
- $this->assertTitle('Simple test page with links');
- $this->assertText('[action=no_page]');
- }
-
- function testClickToBareActionReturnsToSamePage() {
- $this->get($this->samples() . 'front_controller_style/a_page.php');
- $this->clickLink('Bare action');
- $this->assertTitle('Simple test page with links');
- $this->assertText('[action=]');
- }
-
- function testClickToSingleQuestionMarkReturnsToSamePage() {
- $this->get($this->samples() . 'front_controller_style/a_page.php');
- $this->clickLink('Empty query');
- $this->assertTitle('Simple test page with links');
- }
-
- function testClickToEmptyStringReturnsToSamePage() {
- $this->get($this->samples() . 'front_controller_style/a_page.php');
- $this->clickLink('Empty link');
- $this->assertTitle('Simple test page with links');
- }
-
- function testClickToSingleDotGoesToCurrentDirectory() {
- $this->get($this->samples() . 'front_controller_style/a_page.php');
- $this->clickLink('Current directory');
- $this->assertTitle(
- 'Simple test front controller',
- '%s -> index.php needs to be set as a default web server home page');
- }
-
- function testClickBackADirectoryLevel() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->clickLink('Down one');
- $this->assertPattern('|Index of .*?/test|i');
- }
-}
-
-class TestOfLiveFrontControllerEmulation extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testJumpToNamedPage() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->assertText('Simple test front controller');
- $this->clickLink('Index');
- $this->assertResponse(200);
- $this->assertText('[action=index]');
- }
-
- function testJumpToUnnamedPage() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->clickLink('No page');
- $this->assertResponse(200);
- $this->assertText('Simple test front controller');
- $this->assertText('[action=no_page]');
- }
-
- function testJumpToUnnamedPageWithBareParameter() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->clickLink('Bare action');
- $this->assertResponse(200);
- $this->assertText('Simple test front controller');
- $this->assertText('[action=]');
- }
-
- function testJumpToUnnamedPageWithEmptyQuery() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->clickLink('Empty query');
- $this->assertResponse(200);
- $this->assertPattern('/Simple test front controller/');
- $this->assertPattern('/raw get data.*?\[\].*?get data/si');
- }
-
- function testJumpToUnnamedPageWithEmptyLink() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->clickLink('Empty link');
- $this->assertResponse(200);
- $this->assertPattern('/Simple test front controller/');
- $this->assertPattern('/raw get data.*?\[\].*?get data/si');
- }
-
- function testJumpBackADirectoryLevel() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->clickLink('Down one');
- $this->assertPattern('|Index of .*?/test|');
- }
-
- function testSubmitToNamedPage() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->assertText('Simple test front controller');
- $this->clickSubmit('Index');
- $this->assertResponse(200);
- $this->assertText('[action=Index]');
- }
-
- function testSubmitToSameDirectory() {
- $this->get($this->samples() . 'front_controller_style/index.php');
- $this->clickSubmit('Same directory');
- $this->assertResponse(200);
- $this->assertText('[action=Same+directory]');
- }
-
- function testSubmitToEmptyAction() {
- $this->get($this->samples() . 'front_controller_style/index.php');
- $this->clickSubmit('Empty action');
- $this->assertResponse(200);
- $this->assertText('[action=Empty+action]');
- }
-
- function testSubmitToNoAction() {
- $this->get($this->samples() . 'front_controller_style/index.php');
- $this->clickSubmit('No action');
- $this->assertResponse(200);
- $this->assertText('[action=No+action]');
- }
-
- function testSubmitBackADirectoryLevel() {
- $this->get($this->samples() . 'front_controller_style/');
- $this->clickSubmit('Down one');
- $this->assertPattern('|Index of .*?/test|');
- }
-
- function testSubmitToNamedPageWithMixedPostAndGet() {
- $this->get($this->samples() . 'front_controller_style/?a=A');
- $this->assertText('Simple test front controller');
- $this->clickSubmit('Index post');
- $this->assertText('action=[Index post]');
- $this->assertNoText('[a=A]');
- }
-
- function testSubmitToSameDirectoryMixedPostAndGet() {
- $this->get($this->samples() . 'front_controller_style/index.php?a=A');
- $this->clickSubmit('Same directory post');
- $this->assertText('action=[Same directory post]');
- $this->assertNoText('[a=A]');
- }
-
- function testSubmitToEmptyActionMixedPostAndGet() {
- $this->get($this->samples() . 'front_controller_style/index.php?a=A');
- $this->clickSubmit('Empty action post');
- $this->assertText('action=[Empty action post]');
- $this->assertText('[a=A]');
- }
-
- function testSubmitToNoActionMixedPostAndGet() {
- $this->get($this->samples() . 'front_controller_style/index.php?a=A');
- $this->clickSubmit('No action post');
- $this->assertText('action=[No action post]');
- $this->assertText('[a=A]');
- }
-}
-
-class TestOfLiveHeaders extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testConfirmingHeaderExistence() {
- $this->get('http://www.lastcraft.com/');
- $this->assertHeader('content-type');
- $this->assertHeader('content-type', 'text/html');
- $this->assertHeader('content-type', new PatternExpectation('/HTML/i'));
- $this->assertNoHeader('WWW-Authenticate');
- }
-}
-
-class TestOfLiveRedirects extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testNoRedirects() {
- $this->setMaximumRedirects(0);
- $this->get($this->samples() . 'redirect.php');
- $this->assertTitle('Redirection test');
- }
-
- function testRedirects() {
- $this->setMaximumRedirects(1);
- $this->get($this->samples() . 'redirect.php');
- $this->assertTitle('Simple test target file');
- }
-
- function testRedirectLosesGetData() {
- $this->get($this->samples() . 'redirect.php', array('a' => 'aaa'));
- $this->assertNoText('a=[aaa]');
- }
-
- function testRedirectKeepsExtraRequestDataOfItsOwn() {
- $this->get($this->samples() . 'redirect.php');
- $this->assertText('r=[rrr]');
- }
-
- function testRedirectLosesPostData() {
- $this->post($this->samples() . 'redirect.php', array('a' => 'aaa'));
- $this->assertTitle('Simple test target file');
- $this->assertNoText('a=[aaa]');
- }
-
- function testRedirectWithBaseUrlChange() {
- $this->get($this->samples() . 'base_change_redirect.php');
- $this->assertTitle('Simple test target file in folder');
- $this->get($this->samples() . 'path/base_change_redirect.php');
- $this->assertTitle('Simple test target file');
- }
-
- function testRedirectWithDoubleBaseUrlChange() {
- $this->get($this->samples() . 'double_base_change_redirect.php');
- $this->assertTitle('Simple test target file');
- }
-}
-
-class TestOfLiveCookies extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function here() {
- return new SimpleUrl($this->samples());
- }
-
- function thisHost() {
- $here = $this->here();
- return $here->getHost();
- }
-
- function thisPath() {
- $here = $this->here();
- return $here->getPath();
- }
-
- function testCookieSettingAndAssertions() {
- $this->setCookie('a', 'Test cookie a');
- $this->setCookie('b', 'Test cookie b', $this->thisHost());
- $this->setCookie('c', 'Test cookie c', $this->thisHost(), $this->thisPath());
- $this->get($this->samples() . 'network_confirm.php');
- $this->assertText('Test cookie a');
- $this->assertText('Test cookie b');
- $this->assertText('Test cookie c');
- $this->assertCookie('a');
- $this->assertCookie('b', 'Test cookie b');
- $this->assertTrue($this->getCookie('c') == 'Test cookie c');
- }
-
- function testNoCookieSetWhenCookiesDisabled() {
- $this->setCookie('a', 'Test cookie a');
- $this->ignoreCookies();
- $this->get($this->samples() . 'network_confirm.php');
- $this->assertNoText('Test cookie a');
- }
-
- function testCookieReading() {
- $this->get($this->samples() . 'set_cookies.php');
- $this->assertCookie('session_cookie', 'A');
- $this->assertCookie('short_cookie', 'B');
- $this->assertCookie('day_cookie', 'C');
- }
-
- function testNoCookie() {
- $this->assertNoCookie('aRandomCookie');
- }
-
- function testNoCookieReadingWhenCookiesDisabled() {
- $this->ignoreCookies();
- $this->get($this->samples() . 'set_cookies.php');
- $this->assertNoCookie('session_cookie');
- $this->assertNoCookie('short_cookie');
- $this->assertNoCookie('day_cookie');
- }
-
- function testCookiePatternAssertions() {
- $this->get($this->samples() . 'set_cookies.php');
- $this->assertCookie('session_cookie', new PatternExpectation('/a/i'));
- }
-
- function testTemporaryCookieExpiry() {
- $this->get($this->samples() . 'set_cookies.php');
- $this->restart();
- $this->assertNoCookie('session_cookie');
- $this->assertCookie('day_cookie', 'C');
- }
-
- function testTimedCookieExpiryWith100SecondMargin() {
- $this->get($this->samples() . 'set_cookies.php');
- $this->ageCookies(3600);
- $this->restart(time() + 100);
- $this->assertNoCookie('session_cookie');
- $this->assertNoCookie('hour_cookie');
- $this->assertCookie('day_cookie', 'C');
- }
-
- function testNoClockOverDriftBy100Seconds() {
- $this->get($this->samples() . 'set_cookies.php');
- $this->restart(time() + 200);
- $this->assertNoCookie(
- 'short_cookie',
- '%s -> Please check your computer clock setting if you are not using NTP');
- }
-
- function testNoClockUnderDriftBy100Seconds() {
- $this->get($this->samples() . 'set_cookies.php');
- $this->restart(time() + 0);
- $this->assertCookie(
- 'short_cookie',
- 'B',
- '%s -> Please check your computer clock setting if you are not using NTP');
- }
-
- function testCookiePath() {
- $this->get($this->samples() . 'set_cookies.php');
- $this->assertNoCookie('path_cookie', 'D');
- $this->get('./path/show_cookies.php');
- $this->assertPattern('/path_cookie/');
- $this->assertCookie('path_cookie', 'D');
- }
-}
-
-class LiveTestOfForms extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testSimpleSubmit() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('go=[Go!]');
- }
-
- function testDefaultFormValues() {
- $this->get($this->samples() . 'form.html');
- $this->assertFieldByName('a', '');
- $this->assertFieldByName('b', 'Default text');
- $this->assertFieldByName('c', '');
- $this->assertFieldByName('d', 'd1');
- $this->assertFieldByName('e', false);
- $this->assertFieldByName('f', 'on');
- $this->assertFieldByName('g', 'g3');
- $this->assertFieldByName('h', 2);
- $this->assertFieldByName('go', 'Go!');
- $this->assertClickable('Go!');
- $this->assertSubmit('Go!');
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('go=[Go!]');
- $this->assertText('a=[]');
- $this->assertText('b=[Default text]');
- $this->assertText('c=[]');
- $this->assertText('d=[d1]');
- $this->assertNoText('e=[');
- $this->assertText('f=[on]');
- $this->assertText('g=[g3]');
- }
-
- function testFormSubmissionByButtonLabel() {
- $this->get($this->samples() . 'form.html');
- $this->setFieldByName('a', 'aaa');
- $this->setFieldByName('b', 'bbb');
- $this->setFieldByName('c', 'ccc');
- $this->setFieldByName('d', 'D2');
- $this->setFieldByName('e', 'on');
- $this->setFieldByName('f', false);
- $this->setFieldByName('g', 'g2');
- $this->setFieldByName('h', 1);
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[aaa]');
- $this->assertText('b=[bbb]');
- $this->assertText('c=[ccc]');
- $this->assertText('d=[d2]');
- $this->assertText('e=[on]');
- $this->assertNoText('f=[');
- $this->assertText('g=[g2]');
- }
-
- function testAdditionalFormValues() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickSubmit('Go!', array('add' => 'A')));
- $this->assertText('go=[Go!]');
- $this->assertText('add=[A]');
- }
-
- function testFormSubmissionByName() {
- $this->get($this->samples() . 'form.html');
- $this->setFieldByName('a', 'A');
- $this->assertTrue($this->clickSubmitByName('go'));
- $this->assertText('a=[A]');
- }
-
- function testFormSubmissionByNameAndAdditionalParameters() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickSubmitByName('go', array('add' => 'A')));
- $this->assertText('go=[Go!]');
- $this->assertText('add=[A]');
- }
-
- function testFormSubmissionBySubmitButtonLabeledSubmit() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickSubmitByName('test'));
- $this->assertText('test=[Submit]');
- }
-
- function testFormSubmissionWithIds() {
- $this->get($this->samples() . 'form.html');
- $this->assertFieldById(1, '');
- $this->assertFieldById(2, 'Default text');
- $this->assertFieldById(3, '');
- $this->assertFieldById(4, 'd1');
- $this->assertFieldById(5, false);
- $this->assertFieldById(6, 'on');
- $this->assertFieldById(8, 'g3');
- $this->assertFieldById(11, 2);
- $this->setFieldById(1, 'aaa');
- $this->setFieldById(2, 'bbb');
- $this->setFieldById(3, 'ccc');
- $this->setFieldById(4, 'D2');
- $this->setFieldById(5, 'on');
- $this->setFieldById(6, false);
- $this->setFieldById(8, 'g2');
- $this->setFieldById(11, 'H1');
- $this->assertTrue($this->clickSubmitById(99));
- $this->assertText('a=[aaa]');
- $this->assertText('b=[bbb]');
- $this->assertText('c=[ccc]');
- $this->assertText('d=[d2]');
- $this->assertText('e=[on]');
- $this->assertNoText('f=[');
- $this->assertText('g=[g2]');
- $this->assertText('h=[1]');
- $this->assertText('go=[Go!]');
- }
-
- function testFormSubmissionWithIdsAndAdditionnalData() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickSubmitById(99, array('additionnal' => "data")));
- $this->assertText('additionnal=[data]');
- }
-
- function testFormSubmissionWithLabels() {
- $this->get($this->samples() . 'form.html');
- $this->assertField('Text A', '');
- $this->assertField('Text B', 'Default text');
- $this->assertField('Text area C', '');
- $this->assertField('Selection D', 'd1');
- $this->assertField('Checkbox E', false);
- $this->assertField('Checkbox F', 'on');
- $this->assertField('3', 'g3');
- $this->assertField('Selection H', 2);
- $this->setField('Text A', 'aaa');
- $this->setField('Text B', 'bbb');
- $this->setField('Text area C', 'ccc');
- $this->setField('Selection D', 'D2');
- $this->setField('Checkbox E', 'on');
- $this->setField('Checkbox F', false);
- $this->setField('2', 'g2');
- $this->setField('Selection H', 'H1');
- $this->clickSubmit('Go!');
- $this->assertText('a=[aaa]');
- $this->assertText('b=[bbb]');
- $this->assertText('c=[ccc]');
- $this->assertText('d=[d2]');
- $this->assertText('e=[on]');
- $this->assertNoText('f=[');
- $this->assertText('g=[g2]');
- $this->assertText('h=[1]');
- $this->assertText('go=[Go!]');
- }
-
- function testSettingCheckboxWithBooleanTrueSetsUnderlyingValue() {
- $this->get($this->samples() . 'form.html');
- $this->setField('Checkbox E', true);
- $this->assertField('Checkbox E', 'on');
- $this->clickSubmit('Go!');
- $this->assertText('e=[on]');
- }
-
- function testFormSubmissionWithMixedPostAndGet() {
- $this->get($this->samples() . 'form_with_mixed_post_and_get.html');
- $this->setField('Text A', 'Hello');
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[Hello]');
- $this->assertText('x=[X]');
- $this->assertText('y=[Y]');
- }
-
- function testFormSubmissionWithMixedPostAndEncodedGet() {
- $this->get($this->samples() . 'form_with_mixed_post_and_get.html');
- $this->setField('Text B', 'Hello');
- $this->assertTrue($this->clickSubmit('Go encoded!'));
- $this->assertText('b=[Hello]');
- $this->assertText('x=[X]');
- $this->assertText('y=[Y]');
- }
-
- function testFormSubmissionWithoutAction() {
- $this->get($this->samples() . 'form_without_action.php?test=test');
- $this->assertText('_GET : [test]');
- $this->assertTrue($this->clickSubmit('Submit Post With Empty Action'));
- $this->assertText('_GET : [test]');
- $this->assertText('_POST : [test]');
- }
-
- function testImageSubmissionByLabel() {
- $this->get($this->samples() . 'form.html');
- $this->assertImage('Image go!');
- $this->assertTrue($this->clickImage('Image go!', 10, 12));
- $this->assertText('go_x=[10]');
- $this->assertText('go_y=[12]');
- }
-
- function testImageSubmissionByLabelWithAdditionalParameters() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickImage('Image go!', 10, 12, array('add' => 'A')));
- $this->assertText('add=[A]');
- }
-
- function testImageSubmissionByName() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickImageByName('go', 10, 12));
- $this->assertText('go_x=[10]');
- $this->assertText('go_y=[12]');
- }
-
- function testImageSubmissionById() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickImageById(97, 10, 12));
- $this->assertText('go_x=[10]');
- $this->assertText('go_y=[12]');
- }
-
- function testButtonSubmissionByLabel() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->clickSubmit('Button go!', 10, 12));
- $this->assertPattern('/go=\[ButtonGo\]/s');
- }
-
- function testNamelessSubmitSendsNoValue() {
- $this->get($this->samples() . 'form_with_unnamed_submit.html');
- $this->click('Go!');
- $this->assertNoText('Go!');
- $this->assertNoText('submit');
- }
-
- function testNamelessImageSendsXAndYValues() {
- $this->get($this->samples() . 'form_with_unnamed_submit.html');
- $this->clickImage('Image go!', 4, 5);
- $this->assertNoText('ImageGo');
- $this->assertText('x=[4]');
- $this->assertText('y=[5]');
- }
-
- function testNamelessButtonSendsNoValue() {
- $this->get($this->samples() . 'form_with_unnamed_submit.html');
- $this->click('Button Go!');
- $this->assertNoText('ButtonGo');
- }
-
- function testSelfSubmit() {
- $this->get($this->samples() . 'self_form.php');
- $this->assertNoText('[Submitted]');
- $this->assertNoText('[Wrong form]');
- $this->assertTrue($this->clickSubmit());
- $this->assertText('[Submitted]');
- $this->assertNoText('[Wrong form]');
- $this->assertTitle('Test of form self submission');
- }
-
- function testSelfSubmitWithParameters() {
- $this->get($this->samples() . 'self_form.php');
- $this->setFieldByName('visible', 'Resent');
- $this->assertTrue($this->clickSubmit());
- $this->assertText('[Resent]');
- }
-
- function testSettingOfBlankOption() {
- $this->get($this->samples() . 'form.html');
- $this->assertTrue($this->setFieldByName('d', ''));
- $this->clickSubmit('Go!');
- $this->assertText('d=[]');
- }
-
- function testAssertingFieldValueWithPattern() {
- $this->get($this->samples() . 'form.html');
- $this->setField('c', 'A very long string');
- $this->assertField('c', new PatternExpectation('/very long/'));
- }
-
- function testSendingMultipartFormDataEncodedForm() {
- $this->get($this->samples() . 'form_data_encoded_form.html');
- $this->assertField('Text A', '');
- $this->assertField('Text B', 'Default text');
- $this->assertField('Text area C', '');
- $this->assertField('Selection D', 'd1');
- $this->assertField('Checkbox E', false);
- $this->assertField('Checkbox F', 'on');
- $this->assertField('3', 'g3');
- $this->assertField('Selection H', 2);
- $this->setField('Text A', 'aaa');
- $this->setField('Text B', 'bbb');
- $this->setField('Text area C', 'ccc');
- $this->setField('Selection D', 'D2');
- $this->setField('Checkbox E', 'on');
- $this->setField('Checkbox F', false);
- $this->setField('2', 'g2');
- $this->setField('Selection H', 'H1');
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[aaa]');
- $this->assertText('b=[bbb]');
- $this->assertText('c=[ccc]');
- $this->assertText('d=[d2]');
- $this->assertText('e=[on]');
- $this->assertNoText('f=[');
- $this->assertText('g=[g2]');
- $this->assertText('h=[1]');
- $this->assertText('go=[Go!]');
- }
-
- function testSettingVariousBlanksInFields() {
- $this->get($this->samples() . 'form_with_false_defaults.html');
- $this->assertField('Text A', '');
- $this->setField('Text A', '0');
- $this->assertField('Text A', '0');
- $this->assertField('Text area B', '');
- $this->setField('Text area B', '0');
- $this->assertField('Text area B', '0');
- $this->assertField('Selection D', '');
- $this->setField('Selection D', 'D2');
- $this->assertField('Selection D', 'D2');
- $this->setField('Selection D', 'D3');
- $this->assertField('Selection D', '0');
- $this->setField('Selection D', 'D4');
- $this->assertField('Selection D', '?');
- $this->assertField('Checkbox E', '');
- $this->assertField('Checkbox F', 'on');
- $this->assertField('Checkbox G', '0');
- $this->assertField('Checkbox H', '?');
- $this->assertFieldByName('i', 'on');
- $this->setFieldByName('i', '');
- $this->assertFieldByName('i', '');
- $this->setFieldByName('i', '0');
- $this->assertFieldByName('i', '0');
- $this->setFieldByName('i', '?');
- $this->assertFieldByName('i', '?');
- }
-
- function testDefaultValueOfTextareaHasNewlinesAndWhitespacePreserved() {
- $this->get($this->samples() . 'form_with_false_defaults.html');
- $this->assertField('Text area C', ' ');
- }
-
- function chars($t) {
- for ($i = 0; $i < strlen($t); $i++) {
- print "[$t[$i]]";
- }
- }
-
- function testSubmissionOfBlankFields() {
- $this->get($this->samples() . 'form_with_false_defaults.html');
- $this->setField('Text A', '');
- $this->setField('Text area B', '');
- $this->setFieldByName('i', '');
- $this->click('Go!');
- $this->assertText('a=[]');
- $this->assertText('b=[]');
- $this->assertText('d=[]');
- $this->assertText('e=[]');
- $this->assertText('i=[]');
- }
-
- function testDefaultValueOfTextareaHasNewlinesAndWhitespacePreservedOnSubmission() {
- $this->get($this->samples() . 'form_with_false_defaults.html');
- $this->click('Go!');
- $this->assertPattern('/c=\[ \]/');
- }
-
- function testSubmissionOfEmptyValues() {
- $this->get($this->samples() . 'form_with_false_defaults.html');
- $this->setField('Selection D', 'D2');
- $this->click('Go!');
- $this->assertText('a=[]');
- $this->assertText('b=[]');
- $this->assertText('d=[D2]');
- $this->assertText('f=[on]');
- $this->assertText('i=[on]');
- }
-
- function testSubmissionOfZeroes() {
- $this->get($this->samples() . 'form_with_false_defaults.html');
- $this->setField('Text A', '0');
- $this->setField('Text area B', '0');
- $this->setField('Selection D', 'D3');
- $this->setFieldByName('i', '0');
- $this->click('Go!');
- $this->assertText('a=[0]');
- $this->assertText('b=[0]');
- $this->assertText('d=[0]');
- $this->assertText('g=[0]');
- $this->assertText('i=[0]');
- }
-
- function testSubmissionOfQuestionMarks() {
- $this->get($this->samples() . 'form_with_false_defaults.html');
- $this->setField('Text A', '?');
- $this->setField('Text area B', '?');
- $this->setField('Selection D', 'D4');
- $this->setFieldByName('i', '?');
- $this->click('Go!');
- $this->assertText('a=[?]');
- $this->assertText('b=[?]');
- $this->assertText('d=[?]');
- $this->assertText('h=[?]');
- $this->assertText('i=[?]');
- }
-
- function testSubmissionOfHtmlEncodedValues() {
- $this->get($this->samples() . 'form_with_tricky_defaults.html');
- $this->assertField('Text A', '&\'"<>');
- $this->assertField('Text B', '"');
- $this->assertField('Text area C', '&\'"<>');
- $this->assertField('Selection D', "'");
- $this->assertField('Checkbox E', '&\'"<>');
- $this->assertField('Checkbox F', false);
- $this->assertFieldByname('i', "'");
- $this->click('Go!');
- $this->assertText('a=[&\'"<>, "]');
- $this->assertText('c=[&\'"<>]');
- $this->assertText("d=[']");
- $this->assertText('e=[&\'"<>]');
- $this->assertText("i=[']");
- }
-
- function testFormActionRespectsBaseTag() {
- $this->get($this->samples() . 'base_tag/form.html');
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('go=[Go!]');
- $this->assertText('a=[]');
- }
-}
-
-class TestOfLiveMultiValueWidgets extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testDefaultFormValueSubmission() {
- $this->get($this->samples() . 'multiple_widget_form.html');
- $this->assertFieldByName('a', array('a2', 'a3'));
- $this->assertFieldByName('b', array('b2', 'b3'));
- $this->assertFieldByName('c[]', array('c2', 'c3'));
- $this->assertFieldByName('d', array('2', '3'));
- $this->assertFieldByName('e', array('2', '3'));
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[a2, a3]');
- $this->assertText('b=[b2, b3]');
- $this->assertText('c=[c2, c3]');
- $this->assertText('d=[2, 3]');
- $this->assertText('e=[2, 3]');
- }
-
- function testSubmittingMultipleValues() {
- $this->get($this->samples() . 'multiple_widget_form.html');
- $this->setFieldByName('a', array('a1', 'a4'));
- $this->assertFieldByName('a', array('a1', 'a4'));
- $this->assertFieldByName('a', array('a4', 'a1'));
- $this->setFieldByName('b', array('b1', 'b4'));
- $this->assertFieldByName('b', array('b1', 'b4'));
- $this->setFieldByName('c[]', array('c1', 'c4'));
- $this->assertField('c[]', array('c1', 'c4'));
- $this->setFieldByName('d', array('1', '4'));
- $this->assertField('d', array('1', '4'));
- $this->setFieldByName('e', array('e1', 'e4'));
- $this->assertField('e', array('1', '4'));
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[a1, a4]');
- $this->assertText('b=[b1, b4]');
- $this->assertText('c=[c1, c4]');
- $this->assertText('d=[1, 4]');
- $this->assertText('e=[1, 4]');
- }
-
- function testSettingByOptionValue() {
- $this->get($this->samples() . 'multiple_widget_form.html');
- $this->setFieldByName('d', array('1', '4'));
- $this->assertField('d', array('1', '4'));
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('d=[1, 4]');
- }
-
- function testSubmittingMultipleValuesByLabel() {
- $this->get($this->samples() . 'multiple_widget_form.html');
- $this->setField('Multiple selection A', array('a1', 'a4'));
- $this->assertField('Multiple selection A', array('a1', 'a4'));
- $this->assertField('Multiple selection A', array('a4', 'a1'));
- $this->setField('multiple selection C', array('c1', 'c4'));
- $this->assertField('multiple selection C', array('c1', 'c4'));
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[a1, a4]');
- $this->assertText('c=[c1, c4]');
- }
-
- function testSavantStyleHiddenFieldDefaults() {
- $this->get($this->samples() . 'savant_style_form.html');
- $this->assertFieldByName('a', array('a0'));
- $this->assertFieldByName('b', array('b0'));
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[a0]');
- $this->assertText('b=[b0]');
- }
-
- function testSavantStyleHiddenDefaultsAreOverridden() {
- $this->get($this->samples() . 'savant_style_form.html');
- $this->assertTrue($this->setFieldByName('a', array('a1')));
- $this->assertTrue($this->setFieldByName('b', 'b1'));
- $this->assertTrue($this->clickSubmit('Go!'));
- $this->assertText('a=[a1]');
- $this->assertText('b=[b1]');
- }
-
- function testSavantStyleFormSettingById() {
- $this->get($this->samples() . 'savant_style_form.html');
- $this->assertFieldById(1, array('a0'));
- $this->assertFieldById(4, array('b0'));
- $this->assertTrue($this->setFieldById(2, 'a1'));
- $this->assertTrue($this->setFieldById(5, 'b1'));
- $this->assertTrue($this->clickSubmitById(99));
- $this->assertText('a=[a1]');
- $this->assertText('b=[b1]');
- }
-}
-
-class TestOfFileUploads extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testSingleFileUpload() {
- $this->get($this->samples() . 'upload_form.html');
- $this->assertTrue($this->setField('Content:',
- dirname(__FILE__) . '/support/upload_sample.txt'));
- $this->assertField('Content:', dirname(__FILE__) . '/support/upload_sample.txt');
- $this->click('Go!');
- $this->assertText('Sample for testing file upload');
- }
-
- function testMultipleFileUpload() {
- $this->get($this->samples() . 'upload_form.html');
- $this->assertTrue($this->setField('Content:',
- dirname(__FILE__) . '/support/upload_sample.txt'));
- $this->assertTrue($this->setField('Supplemental:',
- dirname(__FILE__) . '/support/supplementary_upload_sample.txt'));
- $this->assertField('Supplemental:',
- dirname(__FILE__) . '/support/supplementary_upload_sample.txt');
- $this->click('Go!');
- $this->assertText('Sample for testing file upload');
- $this->assertText('Some more text content');
- }
-
- function testBinaryFileUpload() {
- $this->get($this->samples() . 'upload_form.html');
- $this->assertTrue($this->setField('Content:',
- dirname(__FILE__) . '/support/latin1_sample'));
- $this->click('Go!');
- $this->assertText(
- implode('', file(dirname(__FILE__) . '/support/latin1_sample')));
- }
-}
-
-class TestOfLiveHistoryNavigation extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testRetry() {
- $this->get($this->samples() . 'cookie_based_counter.php');
- $this->assertPattern('/count: 1/i');
- $this->retry();
- $this->assertPattern('/count: 2/i');
- $this->retry();
- $this->assertPattern('/count: 3/i');
- }
-
- function testOfBackButton() {
- $this->get($this->samples() . '1.html');
- $this->clickLink('2');
- $this->assertTitle('2');
- $this->assertTrue($this->back());
- $this->assertTitle('1');
- $this->assertTrue($this->forward());
- $this->assertTitle('2');
- $this->assertFalse($this->forward());
- }
-
- function testGetRetryResubmitsData() {
- $this->assertTrue($this->get(
- $this->samples() . 'network_confirm.php?a=aaa'));
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertText('a=[aaa]');
- $this->retry();
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertText('a=[aaa]');
- }
-
- function testGetRetryResubmitsExtraData() {
- $this->assertTrue($this->get(
- $this->samples() . 'network_confirm.php',
- array('a' => 'aaa')));
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertText('a=[aaa]');
- $this->retry();
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertText('a=[aaa]');
- }
-
- function testPostRetryResubmitsData() {
- $this->assertTrue($this->post(
- $this->samples() . 'network_confirm.php',
- array('a' => 'aaa')));
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aaa]');
- $this->retry();
- $this->assertPattern('/Request method.*?POST<\/dd>/');
- $this->assertText('a=[aaa]');
- }
-
- function testGetRetryResubmitsRepeatedData() {
- $this->assertTrue($this->get(
- $this->samples() . 'network_confirm.php?a=1&a=2'));
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertText('a=[1, 2]');
- $this->retry();
- $this->assertPattern('/Request method.*?GET<\/dd>/');
- $this->assertText('a=[1, 2]');
- }
-}
-
-class TestOfLiveAuthentication extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testChallengeFromProtectedPage() {
- $this->get($this->samples() . 'protected/');
- $this->assertResponse(401);
- $this->assertAuthentication('Basic');
- $this->assertRealm('SimpleTest basic authentication');
- $this->assertRealm(new PatternExpectation('/simpletest/i'));
- $this->authenticate('test', 'secret');
- $this->assertResponse(200);
- $this->retry();
- $this->assertResponse(200);
- }
-
- function testTrailingSlashImpliedWithinRealm() {
- $this->get($this->samples() . 'protected/');
- $this->authenticate('test', 'secret');
- $this->assertResponse(200);
- $this->get($this->samples() . 'protected');
- $this->assertResponse(200);
- }
-
- function testTrailingSlashImpliedSettingRealm() {
- $this->get($this->samples() . 'protected');
- $this->authenticate('test', 'secret');
- $this->assertResponse(200);
- $this->get($this->samples() . 'protected/');
- $this->assertResponse(200);
- }
-
- function testEncodedAuthenticationFetchesPage() {
- $this->get('http://test:secret@www.lastcraft.com/test/protected/');
- $this->assertResponse(200);
- }
-
- function testEncodedAuthenticationFetchesPageAfterTrailingSlashRedirect() {
- $this->get('http://test:secret@www.lastcraft.com/test/protected');
- $this->assertResponse(200);
- }
-
- function testRealmExtendsToWholeDirectory() {
- $this->get($this->samples() . 'protected/1.html');
- $this->authenticate('test', 'secret');
- $this->clickLink('2');
- $this->assertResponse(200);
- $this->clickLink('3');
- $this->assertResponse(200);
- }
-
- function testRedirectKeepsAuthentication() {
- $this->get($this->samples() . 'protected/local_redirect.php');
- $this->authenticate('test', 'secret');
- $this->assertTitle('Simple test target file');
- }
-
- function testRedirectKeepsEncodedAuthentication() {
- $this->get('http://test:secret@www.lastcraft.com/test/protected/local_redirect.php');
- $this->assertResponse(200);
- $this->assertTitle('Simple test target file');
- }
-
- function testSessionRestartLosesAuthentication() {
- $this->get($this->samples() . 'protected/');
- $this->authenticate('test', 'secret');
- $this->assertResponse(200);
- $this->restart();
- $this->get($this->samples() . 'protected/');
- $this->assertResponse(401);
- }
-}
-
-class TestOfLoadingFrames extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testNoFramesContentWhenFramesDisabled() {
- $this->ignoreFrames();
- $this->get($this->samples() . 'one_page_frameset.html');
- $this->assertTitle('Frameset for testing of SimpleTest');
- $this->assertText('This content is for no frames only');
- }
-
- function testPatternMatchCanReadTheOnlyFrame() {
- $this->get($this->samples() . 'one_page_frameset.html');
- $this->assertText('A target for the SimpleTest test suite');
- $this->assertNoText('This content is for no frames only');
- }
-
- function testMessyFramesetResponsesByName() {
- $this->assertTrue($this->get(
- $this->samples() . 'messy_frameset.html'));
- $this->assertTitle('Frameset for testing of SimpleTest');
-
- $this->assertTrue($this->setFrameFocus('Front controller'));
- $this->assertResponse(200);
- $this->assertText('Simple test front controller');
-
- $this->assertTrue($this->setFrameFocus('One'));
- $this->assertResponse(200);
- $this->assertLink('2');
-
- $this->assertTrue($this->setFrameFocus('Frame links'));
- $this->assertResponse(200);
- $this->assertLink('Set one to 2');
-
- $this->assertTrue($this->setFrameFocus('Counter'));
- $this->assertResponse(200);
- $this->assertText('Count: 1');
-
- $this->assertTrue($this->setFrameFocus('Redirected'));
- $this->assertResponse(200);
- $this->assertText('r=rrr');
-
- $this->assertTrue($this->setFrameFocus('Protected'));
- $this->assertResponse(401);
-
- $this->assertTrue($this->setFrameFocus('Protected redirect'));
- $this->assertResponse(401);
-
- $this->assertTrue($this->setFrameFocusByIndex(1));
- $this->assertResponse(200);
- $this->assertText('Simple test front controller');
-
- $this->assertTrue($this->setFrameFocusByIndex(2));
- $this->assertResponse(200);
- $this->assertLink('2');
-
- $this->assertTrue($this->setFrameFocusByIndex(3));
- $this->assertResponse(200);
- $this->assertLink('Set one to 2');
-
- $this->assertTrue($this->setFrameFocusByIndex(4));
- $this->assertResponse(200);
- $this->assertText('Count: 1');
-
- $this->assertTrue($this->setFrameFocusByIndex(5));
- $this->assertResponse(200);
- $this->assertText('r=rrr');
-
- $this->assertTrue($this->setFrameFocusByIndex(6));
- $this->assertResponse(401);
-
- $this->assertTrue($this->setFrameFocusByIndex(7));
- }
-
- function testReloadingFramesetPage() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->assertText('Count: 1');
- $this->retry();
- $this->assertText('Count: 2');
- $this->retry();
- $this->assertText('Count: 3');
- }
-
- function testReloadingSingleFrameWithCookieCounter() {
- $this->get($this->samples() . 'counting_frameset.html');
- $this->setFrameFocus('a');
- $this->assertText('Count: 1');
- $this->setFrameFocus('b');
- $this->assertText('Count: 2');
-
- $this->setFrameFocus('a');
- $this->retry();
- $this->assertText('Count: 3');
- $this->retry();
- $this->assertText('Count: 4');
- $this->setFrameFocus('b');
- $this->assertText('Count: 2');
- }
-
- function testReloadingFrameWhenUnfocusedReloadsWholeFrameset() {
- $this->get($this->samples() . 'counting_frameset.html');
- $this->setFrameFocus('a');
- $this->assertText('Count: 1');
- $this->setFrameFocus('b');
- $this->assertText('Count: 2');
-
- $this->clearFrameFocus('a');
- $this->retry();
-
- $this->assertTitle('Frameset for testing of SimpleTest');
- $this->setFrameFocus('a');
- $this->assertText('Count: 3');
- $this->setFrameFocus('b');
- $this->assertText('Count: 4');
- }
-
- function testClickingNormalLinkReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickLink('2');
- $this->assertLink('3');
- $this->assertText('Simple test front controller');
- }
-
- function testJumpToNamedPageReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->assertPattern('/Simple test front controller/');
- $this->clickLink('Index');
- $this->assertResponse(200);
- $this->assertText('[action=index]');
- $this->assertText('Count: 1');
- }
-
- function testJumpToUnnamedPageReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickLink('No page');
- $this->assertResponse(200);
- $this->assertText('Simple test front controller');
- $this->assertText('[action=no_page]');
- $this->assertText('Count: 1');
- }
-
- function testJumpToUnnamedPageWithBareParameterReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickLink('Bare action');
- $this->assertResponse(200);
- $this->assertText('Simple test front controller');
- $this->assertText('[action=]');
- $this->assertText('Count: 1');
- }
-
- function testJumpToUnnamedPageWithEmptyQueryReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickLink('Empty query');
- $this->assertResponse(200);
- $this->assertPattern('/Simple test front controller/');
- $this->assertPattern('/raw get data.*?\[\].*?get data/si');
- $this->assertPattern('/Count: 1/');
- }
-
- function testJumpToUnnamedPageWithEmptyLinkReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickLink('Empty link');
- $this->assertResponse(200);
- $this->assertPattern('/Simple test front controller/');
- $this->assertPattern('/raw get data.*?\[\].*?get data/si');
- $this->assertPattern('/Count: 1/');
- }
-
- function testJumpBackADirectoryLevelReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickLink('Down one');
- $this->assertPattern('/index of .*\/test/i');
- $this->assertPattern('/Count: 1/');
- }
-
- function testSubmitToNamedPageReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->assertPattern('/Simple test front controller/');
- $this->clickSubmit('Index');
- $this->assertResponse(200);
- $this->assertText('[action=Index]');
- $this->assertText('Count: 1');
- }
-
- function testSubmitToSameDirectoryReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickSubmit('Same directory');
- $this->assertResponse(200);
- $this->assertText('[action=Same+directory]');
- $this->assertText('Count: 1');
- }
-
- function testSubmitToEmptyActionReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickSubmit('Empty action');
- $this->assertResponse(200);
- $this->assertText('[action=Empty+action]');
- $this->assertText('Count: 1');
- }
-
- function testSubmitToNoActionReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickSubmit('No action');
- $this->assertResponse(200);
- $this->assertText('[action=No+action]');
- $this->assertText('Count: 1');
- }
-
- function testSubmitBackADirectoryLevelReplacesJustThatFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickSubmit('Down one');
- $this->assertPattern('/index of .*\/test/i');
- $this->assertPattern('/Count: 1/');
- }
-
- function testTopLinkExitsFrameset() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->clickLink('Exit the frameset');
- $this->assertTitle('Simple test target file');
- }
-
- function testLinkInOnePageCanLoadAnother() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->assertNoLink('3');
- $this->clickLink('Set one to 2');
- $this->assertLink('3');
- $this->assertNoLink('2');
- $this->assertTitle('Frameset for testing of SimpleTest');
- }
-
- function testFrameWithRelativeLinksRespectsBaseTagForThatPage() {
- $this->get($this->samples() . 'base_tag/frameset.html');
- $this->click('Back to test pages');
- $this->assertTitle('Frameset for testing of SimpleTest');
- $this->assertText('A target for the SimpleTest test suite');
- }
-
- function testRelativeLinkInFrameIsNotAffectedByFramesetBaseTag() {
- $this->get($this->samples() . 'base_tag/frameset_with_base_tag.html');
- $this->assertText('This is page 1');
- $this->click('To page 2');
- $this->assertTitle('Frameset for testing of SimpleTest');
- $this->assertText('This is page 2');
- }
-}
-
-class TestOfFrameAuthentication extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testUnauthenticatedFrameSendsChallenge() {
- $this->get($this->samples() . 'protected/');
- $this->setFrameFocus('Protected');
- $this->assertAuthentication('Basic');
- $this->assertRealm('SimpleTest basic authentication');
- $this->assertResponse(401);
- }
-
- function testCanReadFrameFromAlreadyAuthenticatedRealm() {
- $this->get($this->samples() . 'protected/');
- $this->authenticate('test', 'secret');
- $this->get($this->samples() . 'messy_frameset.html');
- $this->setFrameFocus('Protected');
- $this->assertResponse(200);
- $this->assertText('A target for the SimpleTest test suite');
- }
-
- function testCanAuthenticateFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->setFrameFocus('Protected');
- $this->authenticate('test', 'secret');
- $this->assertResponse(200);
- $this->assertText('A target for the SimpleTest test suite');
- $this->clearFrameFocus();
- $this->assertText('Count: 1');
- }
-
- function testCanAuthenticateRedirectedFrame() {
- $this->get($this->samples() . 'messy_frameset.html');
- $this->setFrameFocus('Protected redirect');
- $this->assertResponse(401);
- $this->authenticate('test', 'secret');
- $this->assertResponse(200);
- $this->assertText('A target for the SimpleTest test suite');
- $this->clearFrameFocus();
- $this->assertText('Count: 1');
- }
-}
-
-class TestOfNestedFrames extends SimpleTestAcceptanceTest {
- function setUp() {
- $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
- }
-
- function testCanNavigateToSpecificContent() {
- $this->get($this->samples() . 'nested_frameset.html');
- $this->assertTitle('Nested frameset for testing of SimpleTest');
-
- $this->assertPattern('/This is frame A/');
- $this->assertPattern('/This is frame B/');
- $this->assertPattern('/Simple test front controller/');
- $this->assertLink('2');
- $this->assertLink('Set one to 2');
- $this->assertPattern('/Count: 1/');
- $this->assertPattern('/r=rrr/');
-
- $this->setFrameFocus('pair');
- $this->assertPattern('/This is frame A/');
- $this->assertPattern('/This is frame B/');
- $this->assertNoPattern('/Simple test front controller/');
- $this->assertNoLink('2');
-
- $this->setFrameFocus('aaa');
- $this->assertPattern('/This is frame A/');
- $this->assertNoPattern('/This is frame B/');
-
- $this->clearFrameFocus();
- $this->assertResponse(200);
- $this->setFrameFocus('messy');
- $this->assertResponse(200);
- $this->setFrameFocus('Front controller');
- $this->assertResponse(200);
- $this->assertPattern('/Simple test front controller/');
- $this->assertNoLink('2');
- }
-
- function testReloadingFramesetPage() {
- $this->get($this->samples() . 'nested_frameset.html');
- $this->assertPattern('/Count: 1/');
- $this->retry();
- $this->assertPattern('/Count: 2/');
- $this->retry();
- $this->assertPattern('/Count: 3/');
- }
-
- function testRetryingNestedPageOnlyRetriesThatSet() {
- $this->get($this->samples() . 'nested_frameset.html');
- $this->assertPattern('/Count: 1/');
- $this->setFrameFocus('messy');
- $this->retry();
- $this->assertPattern('/Count: 2/');
- $this->setFrameFocus('Counter');
- $this->retry();
- $this->assertPattern('/Count: 3/');
-
- $this->clearFrameFocus();
- $this->setFrameFocus('messy');
- $this->setFrameFocus('Front controller');
- $this->retry();
-
- $this->clearFrameFocus();
- $this->assertPattern('/Count: 3/');
- }
-
- function testAuthenticatingNestedPage() {
- $this->get($this->samples() . 'nested_frameset.html');
- $this->setFrameFocus('messy');
- $this->setFrameFocus('Protected');
- $this->assertAuthentication('Basic');
- $this->assertRealm('SimpleTest basic authentication');
- $this->assertResponse(401);
-
- $this->authenticate('test', 'secret');
- $this->assertResponse(200);
- $this->assertPattern('/A target for the SimpleTest test suite/');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/adapter_test.php b/core/vendors/simpletest/test/adapter_test.php
deleted file mode 100755
index c1a06a2..0000000
--- a/core/vendors/simpletest/test/adapter_test.php
+++ /dev/null
@@ -1,50 +0,0 @@
-assertTrue(true, "PEAR true");
- $this->assertFalse(false, "PEAR false");
- }
-
- function testName() {
- $this->assertTrue($this->getName() == get_class($this));
- }
-
- function testPass() {
- $this->pass("PEAR pass");
- }
-
- function testNulls() {
- $value = null;
- $this->assertNull($value, "PEAR null");
- $value = 0;
- $this->assertNotNull($value, "PEAR not null");
- }
-
- function testType() {
- $this->assertType("Hello", "string", "PEAR type");
- }
-
- function testEquals() {
- $this->assertEquals(12, 12, "PEAR identity");
- $this->setLooselyTyped(true);
- $this->assertEquals("12", 12, "PEAR equality");
- }
-
- function testSame() {
- $same = new SameTestClass();
- $this->assertSame($same, $same, "PEAR same");
- }
-
- function testRegExp() {
- $this->assertRegExp('/hello/', "A big hello from me", "PEAR regex");
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/all_tests.php b/core/vendors/simpletest/test/all_tests.php
deleted file mode 100755
index 99ce945..0000000
--- a/core/vendors/simpletest/test/all_tests.php
+++ /dev/null
@@ -1,13 +0,0 @@
-TestSuite('All tests for SimpleTest ' . SimpleTest::getVersion());
- $this->addFile(dirname(__FILE__) . '/unit_tests.php');
- $this->addFile(dirname(__FILE__) . '/shell_test.php');
- $this->addFile(dirname(__FILE__) . '/live_test.php');
- $this->addFile(dirname(__FILE__) . '/acceptance_test.php');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/arguments_test.php b/core/vendors/simpletest/test/arguments_test.php
deleted file mode 100755
index 0cca4e9..0000000
--- a/core/vendors/simpletest/test/arguments_test.php
+++ /dev/null
@@ -1,82 +0,0 @@
-assertIdentical($arguments->a, false);
- $this->assertIdentical($arguments->all(), array());
- }
-
- function testSingleArgumentNameRecordedAsTrue() {
- $arguments = new SimpleArguments(array('me', '-a'));
- $this->assertIdentical($arguments->a, true);
- }
-
- function testSingleArgumentCanBeGivenAValue() {
- $arguments = new SimpleArguments(array('me', '-a=AAA'));
- $this->assertIdentical($arguments->a, 'AAA');
- }
-
- function testSingleArgumentCanBeGivenSpaceSeparatedValue() {
- $arguments = new SimpleArguments(array('me', '-a', 'AAA'));
- $this->assertIdentical($arguments->a, 'AAA');
- }
-
- function testWillBuildArrayFromRepeatedValue() {
- $arguments = new SimpleArguments(array('me', '-a', 'A', '-a', 'AA'));
- $this->assertIdentical($arguments->a, array('A', 'AA'));
- }
-
- function testWillBuildArrayFromMultiplyRepeatedValues() {
- $arguments = new SimpleArguments(array('me', '-a', 'A', '-a', 'AA', '-a', 'AAA'));
- $this->assertIdentical($arguments->a, array('A', 'AA', 'AAA'));
- }
-
- function testCanParseLongFormArguments() {
- $arguments = new SimpleArguments(array('me', '--aa=AA', '--bb', 'BB'));
- $this->assertIdentical($arguments->aa, 'AA');
- $this->assertIdentical($arguments->bb, 'BB');
- }
-
- function testGetsFullSetOfResultsAsHash() {
- $arguments = new SimpleArguments(array('me', '-a', '-b=1', '-b', '2', '--aa=AA', '--bb', 'BB', '-c'));
- $this->assertEqual($arguments->all(),
- array('a' => true, 'b' => array('1', '2'), 'aa' => 'AA', 'bb' => 'BB', 'c' => true));
- }
-}
-
-class TestOfHelpOutput extends UnitTestCase {
- function testDisplaysGeneralHelpBanner() {
- $help = new SimpleHelp('Cool program');
- $this->assertEqual($help->render(), "Cool program\n");
- }
-
- function testDisplaysOnlySingleLineEndings() {
- $help = new SimpleHelp("Cool program\n");
- $this->assertEqual($help->render(), "Cool program\n");
- }
-
- function testDisplaysHelpOnShortFlag() {
- $help = new SimpleHelp('Cool program');
- $help->explainFlag('a', 'Enables A');
- $this->assertEqual($help->render(), "Cool program\n-a Enables A\n");
- }
-
- function testHasAtleastFourSpacesAfterLongestFlag() {
- $help = new SimpleHelp('Cool program');
- $help->explainFlag('a', 'Enables A');
- $help->explainFlag('long', 'Enables Long');
- $this->assertEqual($help->render(),
- "Cool program\n-a Enables A\n--long Enables Long\n");
- }
-
- function testCanDisplaysMultipleFlagsForEachOption() {
- $help = new SimpleHelp('Cool program');
- $help->explainFlag(array('a', 'aa'), 'Enables A');
- $this->assertEqual($help->render(), "Cool program\n-a Enables A\n --aa\n");
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/authentication_test.php b/core/vendors/simpletest/test/authentication_test.php
deleted file mode 100755
index 081cccd..0000000
--- a/core/vendors/simpletest/test/authentication_test.php
+++ /dev/null
@@ -1,145 +0,0 @@
-assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/hello.html')));
- }
-
- function testInsideWithLongerUrl() {
- $realm = new SimpleRealm(
- 'Basic',
- new SimpleUrl('http://www.here.com/path/'));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/hello.html')));
- }
-
- function testBelowRootIsOutside() {
- $realm = new SimpleRealm(
- 'Basic',
- new SimpleUrl('http://www.here.com/path/'));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/more/hello.html')));
- }
-
- function testOldNetscapeDefinitionIsOutside() {
- $realm = new SimpleRealm(
- 'Basic',
- new SimpleUrl('http://www.here.com/path/'));
- $this->assertFalse($realm->isWithin(
- new SimpleUrl('http://www.here.com/pathmore/hello.html')));
- }
-
- function testInsideWithMissingTrailingSlash() {
- $realm = new SimpleRealm(
- 'Basic',
- new SimpleUrl('http://www.here.com/path/'));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path')));
- }
-
- function testDifferentPageNameStillInside() {
- $realm = new SimpleRealm(
- 'Basic',
- new SimpleUrl('http://www.here.com/path/hello.html'));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/goodbye.html')));
- }
-
- function testNewUrlInSameDirectoryDoesNotChangeRealm() {
- $realm = new SimpleRealm(
- 'Basic',
- new SimpleUrl('http://www.here.com/path/hello.html'));
- $realm->stretch(new SimpleUrl('http://www.here.com/path/goodbye.html'));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/index.html')));
- $this->assertFalse($realm->isWithin(
- new SimpleUrl('http://www.here.com/index.html')));
- }
-
- function testNewUrlMakesRealmTheCommonPath() {
- $realm = new SimpleRealm(
- 'Basic',
- new SimpleUrl('http://www.here.com/path/here/hello.html'));
- $realm->stretch(new SimpleUrl('http://www.here.com/path/there/goodbye.html'));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/here/index.html')));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/there/index.html')));
- $this->assertTrue($realm->isWithin(
- new SimpleUrl('http://www.here.com/path/index.html')));
- $this->assertFalse($realm->isWithin(
- new SimpleUrl('http://www.here.com/index.html')));
- $this->assertFalse($realm->isWithin(
- new SimpleUrl('http://www.here.com/paths/index.html')));
- $this->assertFalse($realm->isWithin(
- new SimpleUrl('http://www.here.com/pathindex.html')));
- }
-}
-
-class TestOfAuthenticator extends UnitTestCase {
-
- function testNoRealms() {
- $request = new MockSimpleHttpRequest();
- $request->expectNever('addHeaderLine');
- $authenticator = new SimpleAuthenticator();
- $authenticator->addHeaders($request, new SimpleUrl('http://here.com/'));
- }
-
- function &createSingleRealm() {
- $authenticator = new SimpleAuthenticator();
- $authenticator->addRealm(
- new SimpleUrl('http://www.here.com/path/hello.html'),
- 'Basic',
- 'Sanctuary');
- $authenticator->setIdentityForRealm('www.here.com', 'Sanctuary', 'test', 'secret');
- return $authenticator;
- }
-
- function testOutsideRealm() {
- $request = new MockSimpleHttpRequest();
- $request->expectNever('addHeaderLine');
- $authenticator = &$this->createSingleRealm();
- $authenticator->addHeaders(
- $request,
- new SimpleUrl('http://www.here.com/hello.html'));
- }
-
- function testWithinRealm() {
- $request = new MockSimpleHttpRequest();
- $request->expectOnce('addHeaderLine');
- $authenticator = &$this->createSingleRealm();
- $authenticator->addHeaders(
- $request,
- new SimpleUrl('http://www.here.com/path/more/hello.html'));
- }
-
- function testRestartingClearsRealm() {
- $request = new MockSimpleHttpRequest();
- $request->expectNever('addHeaderLine');
- $authenticator = &$this->createSingleRealm();
- $authenticator->restartSession();
- $authenticator->addHeaders(
- $request,
- new SimpleUrl('http://www.here.com/hello.html'));
- }
-
- function testDifferentHostIsOutsideRealm() {
- $request = new MockSimpleHttpRequest();
- $request->expectNever('addHeaderLine');
- $authenticator = &$this->createSingleRealm();
- $authenticator->addHeaders(
- $request,
- new SimpleUrl('http://here.com/path/hello.html'));
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/autorun_test.php b/core/vendors/simpletest/test/autorun_test.php
deleted file mode 100755
index d85ea19..0000000
--- a/core/vendors/simpletest/test/autorun_test.php
+++ /dev/null
@@ -1,23 +0,0 @@
-addFile(dirname(__FILE__) . '/support/test1.php');
- $this->assertEqual($tests->getSize(), 1);
- }
-
- function testExitStatusOneIfTestsFail() {
- exec('php ' . dirname(__FILE__) . '/support/failing_test.php', $output, $exit_status);
- $this->assertEqual($exit_status, 1);
- }
-
- function testExitStatusZeroIfTestsPass() {
- exec('php ' . dirname(__FILE__) . '/support/passing_test.php', $output, $exit_status);
- $this->assertEqual($exit_status, 0);
- }
-}
-
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/bad_test_suite.php b/core/vendors/simpletest/test/bad_test_suite.php
deleted file mode 100755
index b426013..0000000
--- a/core/vendors/simpletest/test/bad_test_suite.php
+++ /dev/null
@@ -1,10 +0,0 @@
-TestSuite('Two bad test cases');
- $this->addFile(dirname(__FILE__) . '/support/empty_test_file.php');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/browser_test.php b/core/vendors/simpletest/test/browser_test.php
deleted file mode 100755
index 3a52aaa..0000000
--- a/core/vendors/simpletest/test/browser_test.php
+++ /dev/null
@@ -1,802 +0,0 @@
-assertIdentical($history->getUrl(), false);
- $this->assertIdentical($history->getParameters(), false);
- }
-
- function testCannotMoveInEmptyHistory() {
- $history = new SimpleBrowserHistory();
- $this->assertFalse($history->back());
- $this->assertFalse($history->forward());
- }
-
- function testCurrentTargetAccessors() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.here.com/'),
- new SimpleGetEncoding());
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.here.com/'));
- $this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
- }
-
- function testSecondEntryAccessors() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.first.com/'),
- new SimpleGetEncoding());
- $history->recordEntry(
- new SimpleUrl('http://www.second.com/'),
- new SimplePostEncoding(array('a' => 1)));
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.second.com/'));
- $this->assertIdentical(
- $history->getParameters(),
- new SimplePostEncoding(array('a' => 1)));
- }
-
- function testGoingBackwards() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.first.com/'),
- new SimpleGetEncoding());
- $history->recordEntry(
- new SimpleUrl('http://www.second.com/'),
- new SimplePostEncoding(array('a' => 1)));
- $this->assertTrue($history->back());
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
- $this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
- }
-
- function testGoingBackwardsOffBeginning() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.first.com/'),
- new SimpleGetEncoding());
- $this->assertFalse($history->back());
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
- $this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
- }
-
- function testGoingForwardsOffEnd() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.first.com/'),
- new SimpleGetEncoding());
- $this->assertFalse($history->forward());
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
- $this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
- }
-
- function testGoingBackwardsAndForwards() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.first.com/'),
- new SimpleGetEncoding());
- $history->recordEntry(
- new SimpleUrl('http://www.second.com/'),
- new SimplePostEncoding(array('a' => 1)));
- $this->assertTrue($history->back());
- $this->assertTrue($history->forward());
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.second.com/'));
- $this->assertIdentical(
- $history->getParameters(),
- new SimplePostEncoding(array('a' => 1)));
- }
-
- function testNewEntryReplacesNextOne() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.first.com/'),
- new SimpleGetEncoding());
- $history->recordEntry(
- new SimpleUrl('http://www.second.com/'),
- new SimplePostEncoding(array('a' => 1)));
- $history->back();
- $history->recordEntry(
- new SimpleUrl('http://www.third.com/'),
- new SimpleGetEncoding());
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.third.com/'));
- $this->assertIdentical($history->getParameters(), new SimpleGetEncoding());
- }
-
- function testNewEntryDropsFutureEntries() {
- $history = new SimpleBrowserHistory();
- $history->recordEntry(
- new SimpleUrl('http://www.first.com/'),
- new SimpleGetEncoding());
- $history->recordEntry(
- new SimpleUrl('http://www.second.com/'),
- new SimpleGetEncoding());
- $history->recordEntry(
- new SimpleUrl('http://www.third.com/'),
- new SimpleGetEncoding());
- $history->back();
- $history->back();
- $history->recordEntry(
- new SimpleUrl('http://www.fourth.com/'),
- new SimpleGetEncoding());
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.fourth.com/'));
- $this->assertFalse($history->forward());
- $history->back();
- $this->assertIdentical($history->getUrl(), new SimpleUrl('http://www.first.com/'));
- $this->assertFalse($history->back());
- }
-}
-
-class TestOfParsedPageAccess extends UnitTestCase {
-
- function loadPage(&$page) {
- $response = new MockSimpleHttpResponse($this);
- $agent = new MockSimpleUserAgent($this);
- $agent->returns('fetchResponse', $response);
-
- $browser = new MockParseSimpleBrowser($this);
- $browser->returns('createUserAgent', $agent);
- $browser->returns('parse', $page);
- $browser->__construct();
-
- $browser->get('http://this.com/page.html');
- return $browser;
- }
-
- function testAccessorsWhenNoPage() {
- $agent = new MockSimpleUserAgent($this);
- $browser = new MockParseSimpleBrowser($this);
- $browser->returns('createUserAgent', $agent);
- $browser->__construct();
- $this->assertEqual($browser->getContent(), '');
- }
-
- function testParse() {
- $page = new MockSimplePage();
- $page->setReturnValue('getRequest', "GET here.html\r\n\r\n");
- $page->setReturnValue('getRaw', 'Raw HTML');
- $page->setReturnValue('getTitle', 'Here');
- $page->setReturnValue('getFrameFocus', 'Frame');
- $page->setReturnValue('getMimeType', 'text/html');
- $page->setReturnValue('getResponseCode', 200);
- $page->setReturnValue('getAuthentication', 'Basic');
- $page->setReturnValue('getRealm', 'Somewhere');
- $page->setReturnValue('getTransportError', 'Ouch!');
-
- $browser = $this->loadPage($page);
- $this->assertEqual($browser->getRequest(), "GET here.html\r\n\r\n");
- $this->assertEqual($browser->getContent(), 'Raw HTML');
- $this->assertEqual($browser->getTitle(), 'Here');
- $this->assertEqual($browser->getFrameFocus(), 'Frame');
- $this->assertIdentical($browser->getResponseCode(), 200);
- $this->assertEqual($browser->getMimeType(), 'text/html');
- $this->assertEqual($browser->getAuthentication(), 'Basic');
- $this->assertEqual($browser->getRealm(), 'Somewhere');
- $this->assertEqual($browser->getTransportError(), 'Ouch!');
- }
-
- function testLinkAffirmationWhenPresent() {
- $page = new MockSimplePage();
- $page->setReturnValue('getUrlsByLabel', array('http://www.nowhere.com'));
- $page->expectOnce('getUrlsByLabel', array('a link label'));
- $browser = $this->loadPage($page);
- $this->assertIdentical($browser->getLink('a link label'), 'http://www.nowhere.com');
- }
-
- function testLinkAffirmationByIdWhenPresent() {
- $page = new MockSimplePage();
- $page->setReturnValue('getUrlById', 'a_page.com', array(99));
- $page->setReturnValue('getUrlById', false, array('*'));
- $browser = $this->loadPage($page);
- $this->assertIdentical($browser->getLinkById(99), 'a_page.com');
- $this->assertFalse($browser->getLinkById(98));
- }
-
- function testSettingFieldIsPassedToPage() {
- $page = new MockSimplePage();
- $page->expectOnce('setField', array(new SimpleByLabelOrName('key'), 'Value', false));
- $page->setReturnValue('getField', 'Value');
- $browser = $this->loadPage($page);
- $this->assertEqual($browser->getField('key'), 'Value');
- $browser->setField('key', 'Value');
- }
-}
-
-class TestOfBrowserNavigation extends UnitTestCase {
- function createBrowser($agent, $page) {
- $browser = new MockParseSimpleBrowser();
- $browser->returns('createUserAgent', $agent);
- $browser->returns('parse', $page);
- $browser->__construct();
- return $browser;
- }
-
- function testBrowserRequestMethods() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(
- 0,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/get.req'), new SimpleGetEncoding()));
- $agent->expectAt(
- 1,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/post.req'), new SimplePostEncoding()));
- $agent->expectAt(
- 2,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/put.req'), new SimplePutEncoding()));
- $agent->expectAt(
- 3,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/delete.req'), new SimpleDeleteEncoding()));
- $agent->expectAt(
- 4,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/head.req'), new SimpleHeadEncoding()));
- $agent->expectCallCount('fetchResponse', 5);
-
- $page = new MockSimplePage();
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/get.req');
- $browser->post('http://this.com/post.req');
- $browser->put('http://this.com/put.req');
- $browser->delete('http://this.com/delete.req');
- $browser->head('http://this.com/head.req');
- }
-
- function testClickLinkRequestsPage() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(
- 0,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/page.html'), new SimpleGetEncoding()));
- $agent->expectAt(
- 1,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/new.html'), new SimpleGetEncoding()));
- $agent->expectCallCount('fetchResponse', 2);
-
- $page = new MockSimplePage();
- $page->setReturnValue('getUrlsByLabel', array(new SimpleUrl('http://this.com/new.html')));
- $page->expectOnce('getUrlsByLabel', array('New'));
- $page->setReturnValue('getRaw', 'A page');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickLink('New'));
- }
-
- function testClickLinkWithUnknownFrameStillRequestsWholePage() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(
- 0,
- 'fetchResponse',
- array(new SimpleUrl('http://this.com/page.html'), new SimpleGetEncoding()));
- $target = new SimpleUrl('http://this.com/new.html');
- $target->setTarget('missing');
- $agent->expectAt(
- 1,
- 'fetchResponse',
- array($target, new SimpleGetEncoding()));
- $agent->expectCallCount('fetchResponse', 2);
-
- $parsed_url = new SimpleUrl('http://this.com/new.html');
- $parsed_url->setTarget('missing');
-
- $page = new MockSimplePage();
- $page->setReturnValue('getUrlsByLabel', array($parsed_url));
- $page->setReturnValue('hasFrames', false);
- $page->expectOnce('getUrlsByLabel', array('New'));
- $page->setReturnValue('getRaw', 'A page');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickLink('New'));
- }
-
- function testClickingMissingLinkFails() {
- $agent = new MockSimpleUserAgent($this);
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
-
- $page = new MockSimplePage();
- $page->setReturnValue('getUrlsByLabel', array());
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $this->assertTrue($browser->get('http://this.com/page.html'));
- $this->assertFalse($browser->clickLink('New'));
- }
-
- function testClickIndexedLink() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(
- 1,
- 'fetchResponse',
- array(new SimpleUrl('1.html'), new SimpleGetEncoding()));
- $agent->expectCallCount('fetchResponse', 2);
-
- $page = new MockSimplePage();
- $page->setReturnValue(
- 'getUrlsByLabel',
- array(new SimpleUrl('0.html'), new SimpleUrl('1.html')));
- $page->setReturnValue('getRaw', 'A page');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickLink('New', 1));
- }
-
- function testClinkLinkById() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(1, 'fetchResponse', array(
- new SimpleUrl('http://this.com/link.html'),
- new SimpleGetEncoding()));
- $agent->expectCallCount('fetchResponse', 2);
-
- $page = new MockSimplePage();
- $page->setReturnValue('getUrlById', new SimpleUrl('http://this.com/link.html'));
- $page->expectOnce('getUrlById', array(2));
- $page->setReturnValue('getRaw', 'A page');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickLinkById(2));
- }
-
- function testClickingMissingLinkIdFails() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
-
- $page = new MockSimplePage();
- $page->setReturnValue('getUrlById', false);
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertFalse($browser->clickLink(0));
- }
-
- function testSubmitFormByLabel() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(1, 'fetchResponse', array(
- new SimpleUrl('http://this.com/handler.html'),
- new SimplePostEncoding(array('a' => 'A'))));
- $agent->expectCallCount('fetchResponse', 2);
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
- $form->setReturnValue('getMethod', 'post');
- $form->setReturnValue('submitButton', new SimplePostEncoding(array('a' => 'A')));
- $form->expectOnce('submitButton', array(new SimpleByLabel('Go'), false));
-
- $page = new MockSimplePage();
- $page->returns('getFormBySubmit', $form);
- $page->expectOnce('getFormBySubmit', array(new SimpleByLabel('Go')));
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickSubmit('Go'));
- }
-
- function testDefaultSubmitFormByLabel() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(1, 'fetchResponse', array(
- new SimpleUrl('http://this.com/page.html'),
- new SimpleGetEncoding(array('a' => 'A'))));
- $agent->expectCallCount('fetchResponse', 2);
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/page.html'));
- $form->setReturnValue('getMethod', 'get');
- $form->setReturnValue('submitButton', new SimpleGetEncoding(array('a' => 'A')));
-
- $page = new MockSimplePage();
- $page->returns('getFormBySubmit', $form);
- $page->expectOnce('getFormBySubmit', array(new SimpleByLabel('Submit')));
- $page->setReturnValue('getRaw', 'stuff');
- $page->setReturnValue('getUrl', new SimpleUrl('http://this.com/page.html'));
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickSubmit());
- }
-
- function testSubmitFormByName() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
- $form->setReturnValue('getMethod', 'post');
- $form->setReturnValue('submitButton', new SimplePostEncoding(array('a' => 'A')));
-
- $page = new MockSimplePage();
- $page->returns('getFormBySubmit', $form);
- $page->expectOnce('getFormBySubmit', array(new SimpleByName('me')));
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickSubmitByName('me'));
- }
-
- function testSubmitFormById() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
- $form->setReturnValue('getMethod', 'post');
- $form->setReturnValue('submitButton', new SimplePostEncoding(array('a' => 'A')));
- $form->expectOnce('submitButton', array(new SimpleById(99), false));
-
- $page = new MockSimplePage();
- $page->returns('getFormBySubmit', $form);
- $page->expectOnce('getFormBySubmit', array(new SimpleById(99)));
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickSubmitById(99));
- }
-
- function testSubmitFormByImageLabel() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
- $form->setReturnValue('getMethod', 'post');
- $form->setReturnValue('submitImage', new SimplePostEncoding(array('a' => 'A')));
- $form->expectOnce('submitImage', array(new SimpleByLabel('Go!'), 10, 11, false));
-
- $page = new MockSimplePage();
- $page->returns('getFormByImage', $form);
- $page->expectOnce('getFormByImage', array(new SimpleByLabel('Go!')));
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickImage('Go!', 10, 11));
- }
-
- function testSubmitFormByImageName() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
- $form->setReturnValue('getMethod', 'post');
- $form->setReturnValue('submitImage', new SimplePostEncoding(array('a' => 'A')));
- $form->expectOnce('submitImage', array(new SimpleByName('a'), 10, 11, false));
-
- $page = new MockSimplePage();
- $page->returns('getFormByImage', $form);
- $page->expectOnce('getFormByImage', array(new SimpleByName('a')));
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickImageByName('a', 10, 11));
- }
-
- function testSubmitFormByImageId() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
- $form->setReturnValue('getMethod', 'post');
- $form->setReturnValue('submitImage', new SimplePostEncoding(array('a' => 'A')));
- $form->expectOnce('submitImage', array(new SimpleById(99), 10, 11, false));
-
- $page = new MockSimplePage();
- $page->returns('getFormByImage', $form);
- $page->expectOnce('getFormByImage', array(new SimpleById(99)));
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->clickImageById(99, 10, 11));
- }
-
- function testSubmitFormByFormId() {
- $agent = new MockSimpleUserAgent();
- $agent->returns('fetchResponse', new MockSimpleHttpResponse());
- $agent->expectAt(1, 'fetchResponse', array(
- new SimpleUrl('http://this.com/handler.html'),
- new SimplePostEncoding(array('a' => 'A'))));
- $agent->expectCallCount('fetchResponse', 2);
-
- $form = new MockSimpleForm();
- $form->setReturnValue('getAction', new SimpleUrl('http://this.com/handler.html'));
- $form->setReturnValue('getMethod', 'post');
- $form->setReturnValue('submit', new SimplePostEncoding(array('a' => 'A')));
-
- $page = new MockSimplePage();
- $page->returns('getFormById', $form);
- $page->expectOnce('getFormById', array(33));
- $page->setReturnValue('getRaw', 'stuff');
-
- $browser = $this->createBrowser($agent, $page);
- $browser->get('http://this.com/page.html');
- $this->assertTrue($browser->submitFormById(33));
- }
-}
-
-class TestOfBrowserFrames extends UnitTestCase {
-
- function createBrowser($agent) {
- $browser = new MockUserAgentSimpleBrowser();
- $browser->returns('createUserAgent', $agent);
- $browser->__construct();
- return $browser;
- }
-
- function createUserAgent($pages) {
- $agent = new MockSimpleUserAgent();
- foreach ($pages as $url => $raw) {
- $url = new SimpleUrl($url);
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getUrl', $url);
- $response->setReturnValue('getContent', $raw);
- $agent->returns('fetchResponse', $response, array($url, '*'));
- }
- return $agent;
- }
-
- function testSimplePageHasNoFrames() {
- $browser = $this->createBrowser($this->createUserAgent(
- array('http://site.with.no.frames/' => 'A non-framed page')));
- $this->assertEqual(
- $browser->get('http://site.with.no.frames/'),
- 'A non-framed page');
- $this->assertIdentical($browser->getFrames(), 'http://site.with.no.frames/');
- }
-
- function testFramesetWithSingleFrame() {
- $frameset = ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.one.frame/' => $frameset,
- 'http://site.with.one.frame/frame.html' => 'A frame')));
- $this->assertEqual($browser->get('http://site.with.one.frame/'), 'A frame');
- $this->assertIdentical(
- $browser->getFrames(),
- array('a' => 'http://site.with.one.frame/frame.html'));
- }
-
- function testTitleTakenFromFramesetPage() {
- $frameset = 'Frameset title ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.one.frame/' => $frameset,
- 'http://site.with.one.frame/frame.html' => 'Page title ')));
- $browser->get('http://site.with.one.frame/');
- $this->assertEqual($browser->getTitle(), 'Frameset title');
- }
-
- function testFramesetWithSingleUnnamedFrame() {
- $frameset = ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.one.frame/' => $frameset,
- 'http://site.with.one.frame/frame.html' => 'One frame')));
- $this->assertEqual(
- $browser->get('http://site.with.one.frame/'),
- 'One frame');
- $this->assertIdentical(
- $browser->getFrames(),
- array(1 => 'http://site.with.one.frame/frame.html'));
- }
-
- function testFramesetWithMultipleFrames() {
- $frameset = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.frames/' => $frameset,
- 'http://site.with.frames/frame_a.html' => 'A frame',
- 'http://site.with.frames/frame_b.html' => 'B frame',
- 'http://site.with.frames/frame_c.html' => 'C frame')));
- $this->assertEqual(
- $browser->get('http://site.with.frames/'),
- 'A frameB frameC frame');
- $this->assertIdentical($browser->getFrames(), array(
- 'a' => 'http://site.with.frames/frame_a.html',
- 'b' => 'http://site.with.frames/frame_b.html',
- 'c' => 'http://site.with.frames/frame_c.html'));
- }
-
- function testFrameFocusByName() {
- $frameset = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.frames/' => $frameset,
- 'http://site.with.frames/frame_a.html' => 'A frame',
- 'http://site.with.frames/frame_b.html' => 'B frame',
- 'http://site.with.frames/frame_c.html' => 'C frame')));
- $browser->get('http://site.with.frames/');
- $browser->setFrameFocus('a');
- $this->assertEqual($browser->getContent(), 'A frame');
- $browser->setFrameFocus('b');
- $this->assertEqual($browser->getContent(), 'B frame');
- $browser->setFrameFocus('c');
- $this->assertEqual($browser->getContent(), 'C frame');
- }
-
- function testFramesetWithSomeNamedFrames() {
- $frameset = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.frames/' => $frameset,
- 'http://site.with.frames/frame_a.html' => 'A frame',
- 'http://site.with.frames/frame_b.html' => 'B frame',
- 'http://site.with.frames/frame_c.html' => 'C frame',
- 'http://site.with.frames/frame_d.html' => 'D frame')));
- $this->assertEqual(
- $browser->get('http://site.with.frames/'),
- 'A frameB frameC frameD frame');
- $this->assertIdentical($browser->getFrames(), array(
- 'a' => 'http://site.with.frames/frame_a.html',
- 2 => 'http://site.with.frames/frame_b.html',
- 'c' => 'http://site.with.frames/frame_c.html',
- 4 => 'http://site.with.frames/frame_d.html'));
- }
-
- function testFrameFocusWithMixedNamesAndIndexes() {
- $frameset = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.frames/' => $frameset,
- 'http://site.with.frames/frame_a.html' => 'A frame',
- 'http://site.with.frames/frame_b.html' => 'B frame',
- 'http://site.with.frames/frame_c.html' => 'C frame',
- 'http://site.with.frames/frame_d.html' => 'D frame')));
- $browser->get('http://site.with.frames/');
- $browser->setFrameFocus('a');
- $this->assertEqual($browser->getContent(), 'A frame');
- $browser->setFrameFocus(2);
- $this->assertEqual($browser->getContent(), 'B frame');
- $browser->setFrameFocus('c');
- $this->assertEqual($browser->getContent(), 'C frame');
- $browser->setFrameFocus(4);
- $this->assertEqual($browser->getContent(), 'D frame');
- $browser->clearFrameFocus();
- $this->assertEqual($browser->getContent(), 'A frameB frameC frameD frame');
- }
-
- function testNestedFrameset() {
- $inner = '' .
- ' ' .
- ' ';
- $outer = '' .
- ' ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.nested.frame/' => $outer,
- 'http://site.with.nested.frame/inner.html' => $inner,
- 'http://site.with.nested.frame/page.html' => 'The page')));
- $this->assertEqual(
- $browser->get('http://site.with.nested.frame/'),
- 'The page');
- $this->assertIdentical($browser->getFrames(), array(
- 'inner' => array(
- 'page' => 'http://site.with.nested.frame/page.html')));
- }
-
- function testCanNavigateToNestedFrame() {
- $inner = '' .
- ' ' .
- ' ' .
- ' ';
- $outer = '' .
- ' ' .
- ' ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.nested.frames/' => $outer,
- 'http://site.with.nested.frames/inner.html' => $inner,
- 'http://site.with.nested.frames/one.html' => 'Page one',
- 'http://site.with.nested.frames/two.html' => 'Page two',
- 'http://site.with.nested.frames/three.html' => 'Page three')));
-
- $browser->get('http://site.with.nested.frames/');
- $this->assertEqual($browser->getContent(), 'Page onePage twoPage three');
-
- $this->assertTrue($browser->setFrameFocus('inner'));
- $this->assertEqual($browser->getFrameFocus(), array('inner'));
- $this->assertTrue($browser->setFrameFocus('one'));
- $this->assertEqual($browser->getFrameFocus(), array('inner', 'one'));
- $this->assertEqual($browser->getContent(), 'Page one');
-
- $this->assertTrue($browser->setFrameFocus('two'));
- $this->assertEqual($browser->getFrameFocus(), array('inner', 'two'));
- $this->assertEqual($browser->getContent(), 'Page two');
-
- $browser->clearFrameFocus();
- $this->assertTrue($browser->setFrameFocus('three'));
- $this->assertEqual($browser->getFrameFocus(), array('three'));
- $this->assertEqual($browser->getContent(), 'Page three');
-
- $this->assertTrue($browser->setFrameFocus('inner'));
- $this->assertEqual($browser->getContent(), 'Page onePage two');
- }
-
- function testCanNavigateToNestedFrameByIndex() {
- $inner = '' .
- ' ' .
- ' ' .
- ' ';
- $outer = '' .
- ' ' .
- ' ' .
- ' ';
- $browser = $this->createBrowser($this->createUserAgent(array(
- 'http://site.with.nested.frames/' => $outer,
- 'http://site.with.nested.frames/inner.html' => $inner,
- 'http://site.with.nested.frames/one.html' => 'Page one',
- 'http://site.with.nested.frames/two.html' => 'Page two',
- 'http://site.with.nested.frames/three.html' => 'Page three')));
-
- $browser->get('http://site.with.nested.frames/');
- $this->assertEqual($browser->getContent(), 'Page onePage twoPage three');
-
- $this->assertTrue($browser->setFrameFocusByIndex(1));
- $this->assertEqual($browser->getFrameFocus(), array(1));
- $this->assertTrue($browser->setFrameFocusByIndex(1));
- $this->assertEqual($browser->getFrameFocus(), array(1, 1));
- $this->assertEqual($browser->getContent(), 'Page one');
-
- $this->assertTrue($browser->setFrameFocusByIndex(2));
- $this->assertEqual($browser->getFrameFocus(), array(1, 2));
- $this->assertEqual($browser->getContent(), 'Page two');
-
- $browser->clearFrameFocus();
- $this->assertTrue($browser->setFrameFocusByIndex(2));
- $this->assertEqual($browser->getFrameFocus(), array(2));
- $this->assertEqual($browser->getContent(), 'Page three');
-
- $this->assertTrue($browser->setFrameFocusByIndex(1));
- $this->assertEqual($browser->getContent(), 'Page onePage two');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/collector_test.php b/core/vendors/simpletest/test/collector_test.php
deleted file mode 100755
index efdbf37..0000000
--- a/core/vendors/simpletest/test/collector_test.php
+++ /dev/null
@@ -1,50 +0,0 @@
-expectMinimumCallCount('addFile', 2);
- $suite->expect(
- 'addFile',
- array(new PatternExpectation('/collectable\\.(1|2)$/')));
- $collector = new SimpleCollector();
- $collector->collect($suite, dirname(__FILE__) . '/support/collector/');
- }
-}
-
-class TestOfPatternCollector extends UnitTestCase {
-
- function testAddingEverythingToGroup() {
- $suite = new MockTestSuite();
- $suite->expectCallCount('addFile', 2);
- $suite->expect(
- 'addFile',
- array(new PatternExpectation('/collectable\\.(1|2)$/')));
- $collector = new SimplePatternCollector('/.*/');
- $collector->collect($suite, dirname(__FILE__) . '/support/collector/');
- }
-
- function testOnlyMatchedFilesAreAddedToGroup() {
- $suite = new MockTestSuite();
- $suite->expectOnce('addFile', array(new PathEqualExpectation(
- dirname(__FILE__) . '/support/collector/collectable.1')));
- $collector = new SimplePatternCollector('/1$/');
- $collector->collect($suite, dirname(__FILE__) . '/support/collector/');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/command_line_test.php b/core/vendors/simpletest/test/command_line_test.php
deleted file mode 100755
index 5baabff..0000000
--- a/core/vendors/simpletest/test/command_line_test.php
+++ /dev/null
@@ -1,40 +0,0 @@
-assertIdentical($parser->getTest(), '');
- $this->assertIdentical($parser->getTestCase(), '');
- }
-
- function testNotXmlByDefault() {
- $parser = new SimpleCommandLineParser(array());
- $this->assertFalse($parser->isXml());
- }
-
- function testCanDetectRequestForXml() {
- $parser = new SimpleCommandLineParser(array('--xml'));
- $this->assertTrue($parser->isXml());
- }
-
- function testCanReadAssignmentSyntax() {
- $parser = new SimpleCommandLineParser(array('--test=myTest'));
- $this->assertEqual($parser->getTest(), 'myTest');
- }
-
- function testCanReadFollowOnSyntax() {
- $parser = new SimpleCommandLineParser(array('--test', 'myTest'));
- $this->assertEqual($parser->getTest(), 'myTest');
- }
-
- function testCanReadShortForms() {
- $parser = new SimpleCommandLineParser(array('-t', 'myTest', '-c', 'MyClass', '-x'));
- $this->assertEqual($parser->getTest(), 'myTest');
- $this->assertEqual($parser->getTestCase(), 'MyClass');
- $this->assertTrue($parser->isXml());
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/compatibility_test.php b/core/vendors/simpletest/test/compatibility_test.php
deleted file mode 100755
index b8635e5..0000000
--- a/core/vendors/simpletest/test/compatibility_test.php
+++ /dev/null
@@ -1,87 +0,0 @@
-assertTrue(SimpleTestCompatibility::isA(
- new ComparisonClass(),
- 'ComparisonClass'));
- $this->assertFalse(SimpleTestCompatibility::isA(
- new ComparisonClass(),
- 'ComparisonSubclass'));
- $this->assertTrue(SimpleTestCompatibility::isA(
- new ComparisonSubclass(),
- 'ComparisonClass'));
- }
-
- function testIdentityOfNumericStrings() {
- $numericString1 = "123";
- $numericString2 = "00123";
- $this->assertNotIdentical($numericString1, $numericString2);
- }
-
- function testIdentityOfObjects() {
- $object1 = new ComparisonClass();
- $object2 = new ComparisonClass();
- $this->assertIdentical($object1, $object2);
- }
-
- function testReferences () {
- $thing = "Hello";
- $thing_reference = &$thing;
- $thing_copy = $thing;
- $this->assertTrue(SimpleTestCompatibility::isReference(
- $thing,
- $thing));
- $this->assertTrue(SimpleTestCompatibility::isReference(
- $thing,
- $thing_reference));
- $this->assertFalse(SimpleTestCompatibility::isReference(
- $thing,
- $thing_copy));
- }
-
- function testObjectReferences () {
- $object = new ComparisonClass();
- $object_reference = $object;
- $object_copy = new ComparisonClass();
- $object_assignment = $object;
- $this->assertTrue(SimpleTestCompatibility::isReference(
- $object,
- $object));
- $this->assertTrue(SimpleTestCompatibility::isReference(
- $object,
- $object_reference));
- $this->assertFalse(SimpleTestCompatibility::isReference(
- $object,
- $object_copy));
- if (version_compare(phpversion(), '5', '>=')) {
- $this->assertTrue(SimpleTestCompatibility::isReference(
- $object,
- $object_assignment));
- } else {
- $this->assertFalse(SimpleTestCompatibility::isReference(
- $object,
- $object_assignment));
- }
- }
-
- function testInteraceComparison() {
- $object = new ComparisonClassWithInterface();
- $this->assertFalse(SimpleTestCompatibility::isA(
- new ComparisonClass(),
- 'ComparisonInterface'));
- $this->assertTrue(SimpleTestCompatibility::isA(
- new ComparisonClassWithInterface(),
- 'ComparisonInterface'));
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/cookies_test.php b/core/vendors/simpletest/test/cookies_test.php
deleted file mode 100755
index 0b49e43..0000000
--- a/core/vendors/simpletest/test/cookies_test.php
+++ /dev/null
@@ -1,227 +0,0 @@
-assertFalse($cookie->getValue());
- $this->assertEqual($cookie->getPath(), "/");
- $this->assertIdentical($cookie->getHost(), false);
- $this->assertFalse($cookie->getExpiry());
- $this->assertFalse($cookie->isSecure());
- }
-
- function testCookieAccessors() {
- $cookie = new SimpleCookie(
- "name",
- "value",
- "/path",
- "Mon, 18 Nov 2002 15:50:29 GMT",
- true);
- $this->assertEqual($cookie->getName(), "name");
- $this->assertEqual($cookie->getValue(), "value");
- $this->assertEqual($cookie->getPath(), "/path/");
- $this->assertEqual($cookie->getExpiry(), "Mon, 18 Nov 2002 15:50:29 GMT");
- $this->assertTrue($cookie->isSecure());
- }
-
- function testFullHostname() {
- $cookie = new SimpleCookie("name");
- $this->assertTrue($cookie->setHost("host.name.here"));
- $this->assertEqual($cookie->getHost(), "host.name.here");
- $this->assertTrue($cookie->setHost("host.com"));
- $this->assertEqual($cookie->getHost(), "host.com");
- }
-
- function testHostTruncation() {
- $cookie = new SimpleCookie("name");
- $cookie->setHost("this.host.name.here");
- $this->assertEqual($cookie->getHost(), "host.name.here");
- $cookie->setHost("this.host.com");
- $this->assertEqual($cookie->getHost(), "host.com");
- $this->assertTrue($cookie->setHost("dashes.in-host.com"));
- $this->assertEqual($cookie->getHost(), "in-host.com");
- }
-
- function testBadHosts() {
- $cookie = new SimpleCookie("name");
- $this->assertFalse($cookie->setHost("gibberish"));
- $this->assertFalse($cookie->setHost("host.here"));
- $this->assertFalse($cookie->setHost("host..com"));
- $this->assertFalse($cookie->setHost("..."));
- $this->assertFalse($cookie->setHost("host.com."));
- }
-
- function testHostValidity() {
- $cookie = new SimpleCookie("name");
- $cookie->setHost("this.host.name.here");
- $this->assertTrue($cookie->isValidHost("host.name.here"));
- $this->assertTrue($cookie->isValidHost("that.host.name.here"));
- $this->assertFalse($cookie->isValidHost("bad.host"));
- $this->assertFalse($cookie->isValidHost("nearly.name.here"));
- }
-
- function testPathValidity() {
- $cookie = new SimpleCookie("name", "value", "/path");
- $this->assertFalse($cookie->isValidPath("/"));
- $this->assertTrue($cookie->isValidPath("/path/"));
- $this->assertTrue($cookie->isValidPath("/path/more"));
- }
-
- function testSessionExpiring() {
- $cookie = new SimpleCookie("name", "value", "/path");
- $this->assertTrue($cookie->isExpired(0));
- }
-
- function testTimestampExpiry() {
- $cookie = new SimpleCookie("name", "value", "/path", 456);
- $this->assertFalse($cookie->isExpired(0));
- $this->assertTrue($cookie->isExpired(457));
- $this->assertFalse($cookie->isExpired(455));
- }
-
- function testDateExpiry() {
- $cookie = new SimpleCookie(
- "name",
- "value",
- "/path",
- "Mon, 18 Nov 2002 15:50:29 GMT");
- $this->assertTrue($cookie->isExpired("Mon, 18 Nov 2002 15:50:30 GMT"));
- $this->assertFalse($cookie->isExpired("Mon, 18 Nov 2002 15:50:28 GMT"));
- }
-
- function testAging() {
- $cookie = new SimpleCookie("name", "value", "/path", 200);
- $cookie->agePrematurely(199);
- $this->assertFalse($cookie->isExpired(0));
- $cookie->agePrematurely(2);
- $this->assertTrue($cookie->isExpired(0));
- }
-}
-
-class TestOfCookieJar extends UnitTestCase {
-
- function testAddCookie() {
- $jar = new SimpleCookieJar();
- $jar->setCookie("a", "A");
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=A'));
- }
-
- function testHostFilter() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A', 'my-host.com');
- $jar->setCookie('b', 'B', 'another-host.com');
- $jar->setCookie('c', 'C');
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('my-host.com')),
- array('a=A', 'c=C'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('another-host.com')),
- array('b=B', 'c=C'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('www.another-host.com')),
- array('b=B', 'c=C'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('new-host.org')),
- array('c=C'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('/')),
- array('a=A', 'b=B', 'c=C'));
- }
-
- function testPathFilter() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A', false, '/path/');
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/elsewhere')), array());
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/')), array('a=A'));
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path')), array('a=A'));
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/pa')), array());
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/here')), array('a=A'));
- }
-
- function testPathFilterDeeply() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A', false, '/path/more_path/');
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/')), array());
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path')), array());
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/pa')), array());
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/more_path/')), array('a=A'));
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/more_path/and_more')), array('a=A'));
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/path/not_here/')), array());
- }
-
- function testMultipleCookieWithDifferentPathsButSameName() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'abc', false, '/');
- $jar->setCookie('a', '123', false, '/path/here/');
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('/')),
- array('a=abc'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('my-host.com/')),
- array('a=abc'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('my-host.com/path/')),
- array('a=abc'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('my-host.com/path/here')),
- array('a=abc', 'a=123'));
- $this->assertEqual(
- $jar->selectAsPairs(new SimpleUrl('my-host.com/path/here/there')),
- array('a=abc', 'a=123'));
- }
-
- function testOverwrite() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'abc', false, '/');
- $jar->setCookie('a', 'cde', false, '/');
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=cde'));
- }
-
- function testClearSessionCookies() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A', false, '/');
- $jar->restartSession();
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
- }
-
- function testExpiryFilterByDate() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A', false, '/', 'Wed, 25-Dec-02 04:24:20 GMT');
- $jar->restartSession("Wed, 25-Dec-02 04:24:19 GMT");
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=A'));
- $jar->restartSession("Wed, 25-Dec-02 04:24:21 GMT");
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
- }
-
- function testExpiryFilterByAgeing() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A', false, '/', 'Wed, 25-Dec-02 04:24:20 GMT');
- $jar->restartSession("Wed, 25-Dec-02 04:24:19 GMT");
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=A'));
- $jar->agePrematurely(2);
- $jar->restartSession("Wed, 25-Dec-02 04:24:19 GMT");
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
- }
-
- function testCookieClearing() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'abc', false, '/');
- $jar->setCookie('a', '', false, '/');
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a='));
- }
-
- function testCookieClearByLoweringDate() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'abc', false, '/', 'Wed, 25-Dec-02 04:24:21 GMT');
- $jar->setCookie('a', 'def', false, '/', 'Wed, 25-Dec-02 04:24:19 GMT');
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=def'));
- $jar->restartSession('Wed, 25-Dec-02 04:24:20 GMT');
- $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/detached_test.php b/core/vendors/simpletest/test/detached_test.php
deleted file mode 100755
index f651d97..0000000
--- a/core/vendors/simpletest/test/detached_test.php
+++ /dev/null
@@ -1,15 +0,0 @@
-add(new DetachedTestCase($command));
-if (SimpleReporter::inCli()) {
- exit ($test->run(new TextReporter()) ? 0 : 1);
-}
-$test->run(new HtmlReporter());
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/dumper_test.php b/core/vendors/simpletest/test/dumper_test.php
deleted file mode 100755
index 789047d..0000000
--- a/core/vendors/simpletest/test/dumper_test.php
+++ /dev/null
@@ -1,88 +0,0 @@
-assertEqual(
- $dumper->clipString("Hello", 6),
- "Hello",
- "Hello, 6->%s");
- $this->assertEqual(
- $dumper->clipString("Hello", 5),
- "Hello",
- "Hello, 5->%s");
- $this->assertEqual(
- $dumper->clipString("Hello world", 3),
- "Hel...",
- "Hello world, 3->%s");
- $this->assertEqual(
- $dumper->clipString("Hello world", 6, 3),
- "Hello ...",
- "Hello world, 6, 3->%s");
- $this->assertEqual(
- $dumper->clipString("Hello world", 3, 6),
- "...o w...",
- "Hello world, 3, 6->%s");
- $this->assertEqual(
- $dumper->clipString("Hello world", 4, 11),
- "...orld",
- "Hello world, 4, 11->%s");
- $this->assertEqual(
- $dumper->clipString("Hello world", 4, 12),
- "...orld",
- "Hello world, 4, 12->%s");
- }
-
- function testDescribeNull() {
- $dumper = new SimpleDumper();
- $this->assertPattern('/null/i', $dumper->describeValue(null));
- }
-
- function testDescribeBoolean() {
- $dumper = new SimpleDumper();
- $this->assertPattern('/boolean/i', $dumper->describeValue(true));
- $this->assertPattern('/true/i', $dumper->describeValue(true));
- $this->assertPattern('/false/i', $dumper->describeValue(false));
- }
-
- function testDescribeString() {
- $dumper = new SimpleDumper();
- $this->assertPattern('/string/i', $dumper->describeValue('Hello'));
- $this->assertPattern('/Hello/', $dumper->describeValue('Hello'));
- }
-
- function testDescribeInteger() {
- $dumper = new SimpleDumper();
- $this->assertPattern('/integer/i', $dumper->describeValue(35));
- $this->assertPattern('/35/', $dumper->describeValue(35));
- }
-
- function testDescribeFloat() {
- $dumper = new SimpleDumper();
- $this->assertPattern('/float/i', $dumper->describeValue(0.99));
- $this->assertPattern('/0\.99/', $dumper->describeValue(0.99));
- }
-
- function testDescribeArray() {
- $dumper = new SimpleDumper();
- $this->assertPattern('/array/i', $dumper->describeValue(array(1, 4)));
- $this->assertPattern('/2/i', $dumper->describeValue(array(1, 4)));
- }
-
- function testDescribeObject() {
- $dumper = new SimpleDumper();
- $this->assertPattern(
- '/object/i',
- $dumper->describeValue(new DumperDummy()));
- $this->assertPattern(
- '/DumperDummy/i',
- $dumper->describeValue(new DumperDummy()));
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/eclipse_test.php b/core/vendors/simpletest/test/eclipse_test.php
deleted file mode 100755
index c90cbc9..0000000
--- a/core/vendors/simpletest/test/eclipse_test.php
+++ /dev/null
@@ -1,32 +0,0 @@
-expectOnce('write',array($expected));
- $listener->setReturnValue('write',-1);
-
- $pathparts = pathinfo($fullpath);
- $filename = $pathparts['basename'];
- $test= &new TestSuite($filename);
- $test->addTestFile($fullpath);
- $test->run(new EclipseReporter($listener));
- $this->assertEqual($expected,$listener->output);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/encoding_test.php b/core/vendors/simpletest/test/encoding_test.php
deleted file mode 100755
index a09236e..0000000
--- a/core/vendors/simpletest/test/encoding_test.php
+++ /dev/null
@@ -1,240 +0,0 @@
-assertEqual($pair->asRequest(), 'a=A');
- }
-
- function testMimeEncodedAsHeadersAndContent() {
- $pair = new SimpleEncodedPair('a', 'A');
- $this->assertEqual(
- $pair->asMime(),
- "Content-Disposition: form-data; name=\"a\"\r\n\r\nA");
- }
-
- function testAttachmentEncodedAsHeadersWithDispositionAndContent() {
- $part = new SimpleAttachment('a', 'A', 'aaa.txt');
- $this->assertEqual(
- $part->asMime(),
- "Content-Disposition: form-data; name=\"a\"; filename=\"aaa.txt\"\r\n" .
- "Content-Type: text/plain\r\n\r\nA");
- }
-}
-
-class TestOfEncoding extends UnitTestCase {
- private $content_so_far;
-
- function write($content) {
- $this->content_so_far .= $content;
- }
-
- function clear() {
- $this->content_so_far = '';
- }
-
- function assertWritten($encoding, $content, $message = '%s') {
- $this->clear();
- $encoding->writeTo($this);
- $this->assertIdentical($this->content_so_far, $content, $message);
- }
-
- function testGetEmpty() {
- $encoding = new SimpleGetEncoding();
- $this->assertIdentical($encoding->getValue('a'), false);
- $this->assertIdentical($encoding->asUrlRequest(), '');
- }
-
- function testPostEmpty() {
- $encoding = new SimplePostEncoding();
- $this->assertIdentical($encoding->getValue('a'), false);
- $this->assertWritten($encoding, '');
- }
-
- function testPrefilled() {
- $encoding = new SimplePostEncoding(array('a' => 'aaa'));
- $this->assertIdentical($encoding->getValue('a'), 'aaa');
- $this->assertWritten($encoding, 'a=aaa');
- }
-
- function testPrefilledWithTwoLevels() {
- $query = array('a' => array('aa' => 'aaa'));
- $encoding = new SimplePostEncoding($query);
- $this->assertTrue($encoding->hasMoreThanOneLevel($query));
- $this->assertEqual($encoding->rewriteArrayWithMultipleLevels($query), array('a[aa]' => 'aaa'));
- $this->assertIdentical($encoding->getValue('a[aa]'), 'aaa');
- $this->assertWritten($encoding, 'a%5Baa%5D=aaa');
- }
-
- function testPrefilledWithThreeLevels() {
- $query = array('a' => array('aa' => array('aaa' => 'aaaa')));
- $encoding = new SimplePostEncoding($query);
- $this->assertTrue($encoding->hasMoreThanOneLevel($query));
- $this->assertEqual($encoding->rewriteArrayWithMultipleLevels($query), array('a[aa][aaa]' => 'aaaa'));
- $this->assertIdentical($encoding->getValue('a[aa][aaa]'), 'aaaa');
- $this->assertWritten($encoding, 'a%5Baa%5D%5Baaa%5D=aaaa');
- }
-
- function testPrefilledWithObject() {
- $encoding = new SimplePostEncoding(new SimpleEncoding(array('a' => 'aaa')));
- $this->assertIdentical($encoding->getValue('a'), 'aaa');
- $this->assertWritten($encoding, 'a=aaa');
- }
-
- function testMultiplePrefilled() {
- $query = array('a' => array('a1', 'a2'));
- $encoding = new SimplePostEncoding($query);
- $this->assertTrue($encoding->hasMoreThanOneLevel($query));
- $this->assertEqual($encoding->rewriteArrayWithMultipleLevels($query), array('a[0]' => 'a1', 'a[1]' => 'a2'));
- $this->assertIdentical($encoding->getValue('a[0]'), 'a1');
- $this->assertIdentical($encoding->getValue('a[1]'), 'a2');
- $this->assertWritten($encoding, 'a%5B0%5D=a1&a%5B1%5D=a2');
- }
-
- function testSingleParameter() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a', 'Hello');
- $this->assertEqual($encoding->getValue('a'), 'Hello');
- $this->assertWritten($encoding, 'a=Hello');
- }
-
- function testFalseParameter() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a', false);
- $this->assertEqual($encoding->getValue('a'), false);
- $this->assertWritten($encoding, '');
- }
-
- function testUrlEncoding() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a', 'Hello there!');
- $this->assertWritten($encoding, 'a=Hello+there%21');
- }
-
- function testUrlEncodingOfKey() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a!', 'Hello');
- $this->assertWritten($encoding, 'a%21=Hello');
- }
-
- function testMultipleParameter() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a', 'Hello');
- $encoding->add('b', 'Goodbye');
- $this->assertWritten($encoding, 'a=Hello&b=Goodbye');
- }
-
- function testEmptyParameters() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a', '');
- $encoding->add('b', '');
- $this->assertWritten($encoding, 'a=&b=');
- }
-
- function testRepeatedParameter() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a', 'Hello');
- $encoding->add('a', 'Goodbye');
- $this->assertIdentical($encoding->getValue('a'), array('Hello', 'Goodbye'));
- $this->assertWritten($encoding, 'a=Hello&a=Goodbye');
- }
-
- function testAddingLists() {
- $encoding = new SimplePostEncoding();
- $encoding->add('a', array('Hello', 'Goodbye'));
- $this->assertIdentical($encoding->getValue('a'), array('Hello', 'Goodbye'));
- $this->assertWritten($encoding, 'a=Hello&a=Goodbye');
- }
-
- function testMergeInHash() {
- $encoding = new SimpleGetEncoding(array('a' => 'A1', 'b' => 'B'));
- $encoding->merge(array('a' => 'A2'));
- $this->assertIdentical($encoding->getValue('a'), array('A1', 'A2'));
- $this->assertIdentical($encoding->getValue('b'), 'B');
- }
-
- function testMergeInObject() {
- $encoding = new SimpleGetEncoding(array('a' => 'A1', 'b' => 'B'));
- $encoding->merge(new SimpleEncoding(array('a' => 'A2')));
- $this->assertIdentical($encoding->getValue('a'), array('A1', 'A2'));
- $this->assertIdentical($encoding->getValue('b'), 'B');
- }
-
- function testPrefilledMultipart() {
- $encoding = new SimpleMultipartEncoding(array('a' => 'aaa'), 'boundary');
- $this->assertIdentical($encoding->getValue('a'), 'aaa');
- $this->assertwritten($encoding,
- "--boundary\r\n" .
- "Content-Disposition: form-data; name=\"a\"\r\n" .
- "\r\n" .
- "aaa\r\n" .
- "--boundary--\r\n");
- }
-
- function testAttachment() {
- $encoding = new SimpleMultipartEncoding(array(), 'boundary');
- $encoding->attach('a', 'aaa', 'aaa.txt');
- $this->assertIdentical($encoding->getValue('a'), 'aaa.txt');
- $this->assertwritten($encoding,
- "--boundary\r\n" .
- "Content-Disposition: form-data; name=\"a\"; filename=\"aaa.txt\"\r\n" .
- "Content-Type: text/plain\r\n" .
- "\r\n" .
- "aaa\r\n" .
- "--boundary--\r\n");
- }
-
- function testEntityEncodingDefaultContentType() {
- $encoding = new SimpleEntityEncoding();
- $this->assertIdentical($encoding->getContentType(), 'application/x-www-form-urlencoded');
- $this->assertWritten($encoding, '');
- }
-
- function testEntityEncodingTextBody() {
- $encoding = new SimpleEntityEncoding('plain text');
- $this->assertIdentical($encoding->getContentType(), 'text/plain');
- $this->assertWritten($encoding, 'plain text');
- }
-
- function testEntityEncodingXmlBody() {
- $encoding = new SimpleEntityEncoding('xml
text
', 'text/xml');
- $this->assertIdentical($encoding->getContentType(), 'text/xml');
- $this->assertWritten($encoding, 'xmltext
');
- }
-}
-
-class TestOfEncodingHeaders extends UnitTestCase {
-
- function testEmptyEncodingWritesZeroContentLength() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Content-Length: 0\r\n"));
- $socket->expectAt(1, 'write', array("Content-Type: application/x-www-form-urlencoded\r\n"));
- $encoding = new SimpleEntityEncoding();
- $encoding->writeHeadersTo($socket);
- }
-
- function testTextEncodingWritesDefaultContentType() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Content-Length: 18\r\n"));
- $socket->expectAt(1, 'write', array("Content-Type: text/plain\r\n"));
- $encoding = new SimpleEntityEncoding('one two three four');
- $encoding->writeHeadersTo($socket);
- }
-
- function testEmptyMultipartEncodingWritesEndBoundaryContentLength() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Content-Length: 14\r\n"));
- $socket->expectAt(1, 'write', array("Content-Type: multipart/form-data; boundary=boundary\r\n"));
- $encoding = new SimpleMultipartEncoding(array(), 'boundary');
- $encoding->writeHeadersTo($socket);
- }
-
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/errors_test.php b/core/vendors/simpletest/test/errors_test.php
deleted file mode 100755
index ebb9e05..0000000
--- a/core/vendors/simpletest/test/errors_test.php
+++ /dev/null
@@ -1,229 +0,0 @@
-get('SimpleErrorQueue');
- $queue->clear();
- }
-
- function tearDown() {
- $context = SimpleTest::getContext();
- $queue = $context->get('SimpleErrorQueue');
- $queue->clear();
- }
-
- function testExpectationMatchCancelsIncomingError() {
- $test = new MockSimpleTestCase();
- $test->expectOnce('assert', array(
- new IdenticalExpectation(new AnythingExpectation()),
- 'B',
- 'a message'));
- $test->setReturnValue('assert', true);
- $test->expectNever('error');
- $queue = new SimpleErrorQueue();
- $queue->setTestCase($test);
- $queue->expectError(new AnythingExpectation(), 'a message');
- $queue->add(1024, 'B', 'b.php', 100);
- }
-}
-
-class TestOfErrorTrap extends UnitTestCase {
- private $old;
-
- function setUp() {
- $this->old = error_reporting(E_ALL);
- set_error_handler('SimpleTestErrorHandler');
- }
-
- function tearDown() {
- restore_error_handler();
- error_reporting($this->old);
- }
-
- function testQueueStartsEmpty() {
- $context = SimpleTest::getContext();
- $queue = $context->get('SimpleErrorQueue');
- $this->assertFalse($queue->extract());
- }
-
- function testErrorsAreSwallowedByMatchingExpectation() {
- $this->expectError('Ouch!');
- trigger_error('Ouch!');
- }
-
- function testErrorsAreSwallowedInOrder() {
- $this->expectError('a');
- $this->expectError('b');
- trigger_error('a');
- trigger_error('b');
- }
-
- function testAnyErrorCanBeSwallowed() {
- $this->expectError();
- trigger_error('Ouch!');
- }
-
- function testErrorCanBeSwallowedByPatternMatching() {
- $this->expectError(new PatternExpectation('/ouch/i'));
- trigger_error('Ouch!');
- }
-
- function testErrorWithPercentsPassesWithNoSprintfError() {
- $this->expectError("%");
- trigger_error('%');
- }
-}
-
-class TestOfErrors extends UnitTestCase {
- private $old;
-
- function setUp() {
- $this->old = error_reporting(E_ALL);
- }
-
- function tearDown() {
- error_reporting($this->old);
- }
-
- function testDefaultWhenAllReported() {
- error_reporting(E_ALL);
- $this->expectError('Ouch!');
- trigger_error('Ouch!');
- }
-
- function testNoticeWhenReported() {
- error_reporting(E_ALL);
- $this->expectError('Ouch!');
- trigger_error('Ouch!', E_USER_NOTICE);
- }
-
- function testWarningWhenReported() {
- error_reporting(E_ALL);
- $this->expectError('Ouch!');
- trigger_error('Ouch!', E_USER_WARNING);
- }
-
- function testErrorWhenReported() {
- error_reporting(E_ALL);
- $this->expectError('Ouch!');
- trigger_error('Ouch!', E_USER_ERROR);
- }
-
- function testNoNoticeWhenNotReported() {
- error_reporting(0);
- trigger_error('Ouch!', E_USER_NOTICE);
- }
-
- function testNoWarningWhenNotReported() {
- error_reporting(0);
- trigger_error('Ouch!', E_USER_WARNING);
- }
-
- function testNoticeSuppressedWhenReported() {
- error_reporting(E_ALL);
- @trigger_error('Ouch!', E_USER_NOTICE);
- }
-
- function testWarningSuppressedWhenReported() {
- error_reporting(E_ALL);
- @trigger_error('Ouch!', E_USER_WARNING);
- }
-
- function testErrorWithPercentsReportedWithNoSprintfError() {
- $this->expectError('%');
- trigger_error('%');
- }
-}
-
-class TestOfPHP52RecoverableErrors extends UnitTestCase {
- function skip() {
- $this->skipIf(
- version_compare(phpversion(), '5.2', '<'),
- 'E_RECOVERABLE_ERROR not tested for PHP below 5.2');
- }
-
- function testError() {
- eval('
- class RecoverableErrorTestingStub {
- function ouch(RecoverableErrorTestingStub $obj) {
- }
- }
- ');
-
- $stub = new RecoverableErrorTestingStub();
- $this->expectError(new PatternExpectation('/must be an instance of RecoverableErrorTestingStub/i'));
- $stub->ouch(new stdClass());
- }
-}
-
-class TestOfErrorsExcludingPHP52AndAbove extends UnitTestCase {
- function skip() {
- $this->skipIf(
- version_compare(phpversion(), '5.2', '>='),
- 'E_USER_ERROR not tested for PHP 5.2 and above');
- }
-
- function testNoErrorWhenNotReported() {
- error_reporting(0);
- trigger_error('Ouch!', E_USER_ERROR);
- }
-
- function testErrorSuppressedWhenReported() {
- error_reporting(E_ALL);
- @trigger_error('Ouch!', E_USER_ERROR);
- }
-}
-
-SimpleTest::ignore('TestOfNotEnoughErrors');
-/**
- * This test is ignored as it is used by {@link TestRunnerForLeftOverAndNotEnoughErrors}
- * to verify that it fails as expected.
- *
- * @ignore
- */
-class TestOfNotEnoughErrors extends UnitTestCase {
- function testExpectTwoErrorsThrowOne() {
- $this->expectError('Error 1');
- trigger_error('Error 1');
- $this->expectError('Error 2');
- }
-}
-
-SimpleTest::ignore('TestOfLeftOverErrors');
-/**
- * This test is ignored as it is used by {@link TestRunnerForLeftOverAndNotEnoughErrors}
- * to verify that it fails as expected.
- *
- * @ignore
- */
-class TestOfLeftOverErrors extends UnitTestCase {
- function testExpectOneErrorGetTwo() {
- $this->expectError('Error 1');
- trigger_error('Error 1');
- trigger_error('Error 2');
- }
-}
-
-class TestRunnerForLeftOverAndNotEnoughErrors extends UnitTestCase {
- function testRunLeftOverErrorsTestCase() {
- $test = new TestOfLeftOverErrors();
- $this->assertFalse($test->run(new SimpleReporter()));
- }
-
- function testRunNotEnoughErrors() {
- $test = new TestOfNotEnoughErrors();
- $this->assertFalse($test->run(new SimpleReporter()));
- }
-}
-
-// TODO: Add stacked error handler test
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/exceptions_test.php b/core/vendors/simpletest/test/exceptions_test.php
deleted file mode 100755
index 1011543..0000000
--- a/core/vendors/simpletest/test/exceptions_test.php
+++ /dev/null
@@ -1,183 +0,0 @@
-assertTrue($expectation->test(new MyTestException()));
- $this->assertTrue($expectation->test(new HigherTestException()));
- $this->assertFalse($expectation->test(new OtherTestException()));
- }
-
- function testMatchesClassAndMessageWhenExceptionExpected() {
- $expectation = new ExceptionExpectation(new MyTestException('Hello'));
- $this->assertTrue($expectation->test(new MyTestException('Hello')));
- $this->assertFalse($expectation->test(new HigherTestException('Hello')));
- $this->assertFalse($expectation->test(new OtherTestException('Hello')));
- $this->assertFalse($expectation->test(new MyTestException('Goodbye')));
- $this->assertFalse($expectation->test(new MyTestException()));
- }
-
- function testMessagelessExceptionMatchesOnlyOnClass() {
- $expectation = new ExceptionExpectation(new MyTestException());
- $this->assertTrue($expectation->test(new MyTestException()));
- $this->assertFalse($expectation->test(new HigherTestException()));
- }
-}
-
-class TestOfExceptionTrap extends UnitTestCase {
-
- function testNoExceptionsInQueueMeansNoTestMessages() {
- $test = new MockSimpleTestCase();
- $test->expectNever('assert');
- $queue = new SimpleExceptionTrap();
- $this->assertFalse($queue->isExpected($test, new Exception()));
- }
-
- function testMatchingExceptionGivesTrue() {
- $expectation = new MockSimpleExpectation();
- $expectation->setReturnValue('test', true);
- $test = new MockSimpleTestCase();
- $test->setReturnValue('assert', true);
- $queue = new SimpleExceptionTrap();
- $queue->expectException($expectation, 'message');
- $this->assertTrue($queue->isExpected($test, new Exception()));
- }
-
- function testMatchingExceptionTriggersAssertion() {
- $test = new MockSimpleTestCase();
- $test->expectOnce('assert', array(
- '*',
- new ExceptionExpectation(new Exception()),
- 'message'));
- $queue = new SimpleExceptionTrap();
- $queue->expectException(new ExceptionExpectation(new Exception()), 'message');
- $queue->isExpected($test, new Exception());
- }
-}
-
-class TestOfCatchingExceptions extends UnitTestCase {
-
- function testCanCatchAnyExpectedException() {
- $this->expectException();
- throw new Exception();
- }
-
- function testCanMatchExceptionByClass() {
- $this->expectException('MyTestException');
- throw new HigherTestException();
- }
-
- function testCanMatchExceptionExactly() {
- $this->expectException(new Exception('Ouch'));
- throw new Exception('Ouch');
- }
-
- function testLastListedExceptionIsTheOneThatCounts() {
- $this->expectException('OtherTestException');
- $this->expectException('MyTestException');
- throw new HigherTestException();
- }
-}
-
-class TestOfIgnoringExceptions extends UnitTestCase {
-
- function testCanIgnoreAnyException() {
- $this->ignoreException();
- throw new Exception();
- }
-
- function testCanIgnoreSpecificException() {
- $this->ignoreException('MyTestException');
- throw new MyTestException();
- }
-
- function testCanIgnoreExceptionExactly() {
- $this->ignoreException(new Exception('Ouch'));
- throw new Exception('Ouch');
- }
-
- function testIgnoredExceptionsDoNotMaskExpectedExceptions() {
- $this->ignoreException('Exception');
- $this->expectException('MyTestException');
- throw new MyTestException();
- }
-
- function testCanIgnoreMultipleExceptions() {
- $this->ignoreException('MyTestException');
- $this->ignoreException('OtherTestException');
- throw new OtherTestException();
- }
-}
-
-class TestOfCallingTearDownAfterExceptions extends UnitTestCase {
- private $debri = 0;
-
- function tearDown() {
- $this->debri--;
- }
-
- function testLeaveSomeDebri() {
- $this->debri++;
- $this->expectException();
- throw new Exception(__FUNCTION__);
- }
-
- function testDebriWasRemovedOnce() {
- $this->assertEqual($this->debri, 0);
- }
-}
-
-class TestOfExceptionThrownInSetUpDoesNotRunTestBody extends UnitTestCase {
-
- function setUp() {
- $this->expectException();
- throw new Exception();
- }
-
- function testShouldNotBeRun() {
- $this->fail('This test body should not be run');
- }
-
- function testShouldNotBeRunEither() {
- $this->fail('This test body should not be run either');
- }
-}
-
-class TestOfExpectExceptionWithSetUp extends UnitTestCase {
-
- function setUp() {
- $this->expectException();
- }
-
- function testThisExceptionShouldBeCaught() {
- throw new Exception();
- }
-
- function testJustThrowingMyTestException() {
- throw new MyTestException();
- }
-}
-
-class TestOfThrowingExceptionsInTearDown extends UnitTestCase {
-
- function tearDown() {
- throw new Exception();
- }
-
- function testDoesntFatal() {
- $this->expectException();
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/expectation_test.php b/core/vendors/simpletest/test/expectation_test.php
deleted file mode 100755
index 31fbe65..0000000
--- a/core/vendors/simpletest/test/expectation_test.php
+++ /dev/null
@@ -1,317 +0,0 @@
-assertTrue($is_true->test(true));
- $this->assertFalse($is_true->test(false));
- }
-
- function testStringMatch() {
- $hello = new EqualExpectation("Hello");
- $this->assertTrue($hello->test("Hello"));
- $this->assertFalse($hello->test("Goodbye"));
- }
-
- function testInteger() {
- $fifteen = new EqualExpectation(15);
- $this->assertTrue($fifteen->test(15));
- $this->assertFalse($fifteen->test(14));
- }
-
- function testFloat() {
- $pi = new EqualExpectation(3.14);
- $this->assertTrue($pi->test(3.14));
- $this->assertFalse($pi->test(3.15));
- }
-
- function testArray() {
- $colours = new EqualExpectation(array("r", "g", "b"));
- $this->assertTrue($colours->test(array("r", "g", "b")));
- $this->assertFalse($colours->test(array("g", "b", "r")));
- }
-
- function testHash() {
- $is_blue = new EqualExpectation(array("r" => 0, "g" => 0, "b" => 255));
- $this->assertTrue($is_blue->test(array("r" => 0, "g" => 0, "b" => 255)));
- $this->assertFalse($is_blue->test(array("r" => 0, "g" => 255, "b" => 0)));
- }
-
- function testHashWithOutOfOrderKeysShouldStillMatch() {
- $any_order = new EqualExpectation(array('a' => 1, 'b' => 2));
- $this->assertTrue($any_order->test(array('b' => 2, 'a' => 1)));
- }
-}
-
-class TestOfWithin extends UnitTestCase {
-
- function testWithinFloatingPointMargin() {
- $within = new WithinMarginExpectation(1.0, 0.2);
- $this->assertFalse($within->test(0.7));
- $this->assertTrue($within->test(0.8));
- $this->assertTrue($within->test(0.9));
- $this->assertTrue($within->test(1.1));
- $this->assertTrue($within->test(1.2));
- $this->assertFalse($within->test(1.3));
- }
-
- function testOutsideFloatingPointMargin() {
- $within = new OutsideMarginExpectation(1.0, 0.2);
- $this->assertTrue($within->test(0.7));
- $this->assertFalse($within->test(0.8));
- $this->assertFalse($within->test(1.2));
- $this->assertTrue($within->test(1.3));
- }
-}
-
-class TestOfInequality extends UnitTestCase {
-
- function testStringMismatch() {
- $not_hello = new NotEqualExpectation("Hello");
- $this->assertTrue($not_hello->test("Goodbye"));
- $this->assertFalse($not_hello->test("Hello"));
- }
-}
-
-class RecursiveNasty {
- private $me;
-
- function RecursiveNasty() {
- $this->me = $this;
- }
-}
-
-class OpaqueContainer {
- private $stuff;
- private $value;
-
- public function __construct($value) {
- $this->value = $value;
- }
-}
-
-class DerivedOpaqueContainer extends OpaqueContainer {
- // Deliberately have a variable whose name with the same suffix as a later
- // variable
- private $new_value = 1;
-
- // Deliberately obscures the variable of the same name in the base
- // class.
- private $value;
-
- public function __construct($value, $base_value) {
- parent::__construct($base_value);
- $this->value = $value;
- }
-}
-
-class TestOfIdentity extends UnitTestCase {
-
- function testType() {
- $string = new IdenticalExpectation("37");
- $this->assertTrue($string->test("37"));
- $this->assertFalse($string->test(37));
- $this->assertFalse($string->test("38"));
- }
-
- function _testNastyPhp5Bug() {
- $this->assertFalse(new RecursiveNasty() != new RecursiveNasty());
- }
-
- function _testReallyHorribleRecursiveStructure() {
- $hopeful = new IdenticalExpectation(new RecursiveNasty());
- $this->assertTrue($hopeful->test(new RecursiveNasty()));
- }
-
- function testCanComparePrivateMembers() {
- $expectFive = new IdenticalExpectation(new OpaqueContainer(5));
- $this->assertTrue($expectFive->test(new OpaqueContainer(5)));
- $this->assertFalse($expectFive->test(new OpaqueContainer(6)));
- }
-
- function testCanComparePrivateMembersOfObjectsInArrays() {
- $expectFive = new IdenticalExpectation(array(new OpaqueContainer(5)));
- $this->assertTrue($expectFive->test(array(new OpaqueContainer(5))));
- $this->assertFalse($expectFive->test(array(new OpaqueContainer(6))));
- }
-
- function testCanComparePrivateMembersOfObjectsWherePrivateMemberOfBaseClassIsObscured() {
- $expectFive = new IdenticalExpectation(array(new DerivedOpaqueContainer(1,2)));
- $this->assertTrue($expectFive->test(array(new DerivedOpaqueContainer(1,2))));
- $this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(0,2))));
- $this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(0,9))));
- $this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(1,0))));
- }
-}
-
-class TransparentContainer {
- public $value;
-
- public function __construct($value) {
- $this->value = $value;
- }
-}
-
-class TestOfMemberComparison extends UnitTestCase {
-
- function testMemberExpectationCanMatchPublicMember() {
- $expect_five = new MemberExpectation('value', 5);
- $this->assertTrue($expect_five->test(new TransparentContainer(5)));
- $this->assertFalse($expect_five->test(new TransparentContainer(8)));
- }
-
- function testMemberExpectationCanMatchPrivateMember() {
- $expect_five = new MemberExpectation('value', 5);
- $this->assertTrue($expect_five->test(new OpaqueContainer(5)));
- $this->assertFalse($expect_five->test(new OpaqueContainer(8)));
- }
-
- function testMemberExpectationCanMatchPrivateMemberObscuredByDerivedClass() {
- $expect_five = new MemberExpectation('value', 5);
- $this->assertTrue($expect_five->test(new DerivedOpaqueContainer(5,8)));
- $this->assertTrue($expect_five->test(new DerivedOpaqueContainer(5,5)));
- $this->assertFalse($expect_five->test(new DerivedOpaqueContainer(8,8)));
- $this->assertFalse($expect_five->test(new DerivedOpaqueContainer(8,5)));
- }
-
-}
-
-class DummyReferencedObject{}
-
-class TestOfReference extends UnitTestCase {
-
- function testReference() {
- $foo = "foo";
- $ref = &$foo;
- $not_ref = $foo;
- $bar = "bar";
-
- $expect = new ReferenceExpectation($foo);
- $this->assertTrue($expect->test($ref));
- $this->assertFalse($expect->test($not_ref));
- $this->assertFalse($expect->test($bar));
- }
-}
-
-class TestOfNonIdentity extends UnitTestCase {
-
- function testType() {
- $string = new NotIdenticalExpectation("37");
- $this->assertTrue($string->test("38"));
- $this->assertTrue($string->test(37));
- $this->assertFalse($string->test("37"));
- }
-}
-
-class TestOfPatterns extends UnitTestCase {
-
- function testWanted() {
- $pattern = new PatternExpectation('/hello/i');
- $this->assertTrue($pattern->test("Hello world"));
- $this->assertFalse($pattern->test("Goodbye world"));
- }
-
- function testUnwanted() {
- $pattern = new NoPatternExpectation('/hello/i');
- $this->assertFalse($pattern->test("Hello world"));
- $this->assertTrue($pattern->test("Goodbye world"));
- }
-}
-
-class ExpectedMethodTarget {
- function hasThisMethod() {}
-}
-
-class TestOfMethodExistence extends UnitTestCase {
-
- function testHasMethod() {
- $instance = new ExpectedMethodTarget();
- $expectation = new MethodExistsExpectation('hasThisMethod');
- $this->assertTrue($expectation->test($instance));
- $expectation = new MethodExistsExpectation('doesNotHaveThisMethod');
- $this->assertFalse($expectation->test($instance));
- }
-}
-
-class TestOfIsA extends UnitTestCase {
-
- function testString() {
- $expectation = new IsAExpectation('string');
- $this->assertTrue($expectation->test('Hello'));
- $this->assertFalse($expectation->test(5));
- }
-
- function testBoolean() {
- $expectation = new IsAExpectation('boolean');
- $this->assertTrue($expectation->test(true));
- $this->assertFalse($expectation->test(1));
- }
-
- function testBool() {
- $expectation = new IsAExpectation('bool');
- $this->assertTrue($expectation->test(true));
- $this->assertFalse($expectation->test(1));
- }
-
- function testDouble() {
- $expectation = new IsAExpectation('double');
- $this->assertTrue($expectation->test(5.0));
- $this->assertFalse($expectation->test(5));
- }
-
- function testFloat() {
- $expectation = new IsAExpectation('float');
- $this->assertTrue($expectation->test(5.0));
- $this->assertFalse($expectation->test(5));
- }
-
- function testReal() {
- $expectation = new IsAExpectation('real');
- $this->assertTrue($expectation->test(5.0));
- $this->assertFalse($expectation->test(5));
- }
-
- function testInteger() {
- $expectation = new IsAExpectation('integer');
- $this->assertTrue($expectation->test(5));
- $this->assertFalse($expectation->test(5.0));
- }
-
- function testInt() {
- $expectation = new IsAExpectation('int');
- $this->assertTrue($expectation->test(5));
- $this->assertFalse($expectation->test(5.0));
- }
-
- function testScalar() {
- $expectation = new IsAExpectation('scalar');
- $this->assertTrue($expectation->test(5));
- $this->assertFalse($expectation->test(array(5)));
- }
-
- function testNumeric() {
- $expectation = new IsAExpectation('numeric');
- $this->assertTrue($expectation->test(5));
- $this->assertFalse($expectation->test('string'));
- }
-
- function testNull() {
- $expectation = new IsAExpectation('null');
- $this->assertTrue($expectation->test(null));
- $this->assertFalse($expectation->test('string'));
- }
-}
-
-class TestOfNotA extends UnitTestCase {
-
- function testString() {
- $expectation = new NotAExpectation('string');
- $this->assertFalse($expectation->test('Hello'));
- $this->assertTrue($expectation->test(5));
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/form_test.php b/core/vendors/simpletest/test/form_test.php
deleted file mode 100755
index 70a18f2..0000000
--- a/core/vendors/simpletest/test/form_test.php
+++ /dev/null
@@ -1,344 +0,0 @@
-returns('getUrl', new SimpleUrl($url));
- $page->returns('expandUrl', new SimpleUrl($url));
- return $page;
- }
-
- function testFormAttributes() {
- $tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php', 'id' => '33'));
- $form = new SimpleForm($tag, $this->page('http://host/a/index.html'));
- $this->assertEqual($form->getMethod(), 'get');
- $this->assertIdentical($form->getId(), '33');
- $this->assertNull($form->getValue(new SimpleByName('a')));
- }
-
- function testAction() {
- $page = new MockSimplePage();
- $page->expectOnce('expandUrl', array(new SimpleUrl('here.php')));
- $page->setReturnValue('expandUrl', new SimpleUrl('http://host/here.php'));
- $tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php'));
- $form = new SimpleForm($tag, $page);
- $this->assertEqual($form->getAction(), new SimpleUrl('http://host/here.php'));
- }
-
- function testEmptyAction() {
- $tag = new SimpleFormTag(array('method' => 'GET', 'action' => '', 'id' => '33'));
- $form = new SimpleForm($tag, $this->page('http://host/a/index.html'));
- $this->assertEqual(
- $form->getAction(),
- new SimpleUrl('http://host/a/index.html'));
- }
-
- function testMissingAction() {
- $tag = new SimpleFormTag(array('method' => 'GET'));
- $form = new SimpleForm($tag, $this->page('http://host/a/index.html'));
- $this->assertEqual(
- $form->getAction(),
- new SimpleUrl('http://host/a/index.html'));
- }
-
- function testRootAction() {
- $page = new MockSimplePage();
- $page->expectOnce('expandUrl', array(new SimpleUrl('/')));
- $page->setReturnValue('expandUrl', new SimpleUrl('http://host/'));
- $tag = new SimpleFormTag(array('method' => 'GET', 'action' => '/'));
- $form = new SimpleForm($tag, $page);
- $this->assertEqual(
- $form->getAction(),
- new SimpleUrl('http://host/'));
- }
-
- function testDefaultFrameTargetOnForm() {
- $page = new MockSimplePage();
- $page->expectOnce('expandUrl', array(new SimpleUrl('here.php')));
- $page->setReturnValue('expandUrl', new SimpleUrl('http://host/here.php'));
- $tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php'));
- $form = new SimpleForm($tag, $page);
- $form->setDefaultTarget('frame');
- $expected = new SimpleUrl('http://host/here.php');
- $expected->setTarget('frame');
- $this->assertEqual($form->getAction(), $expected);
- }
-
- function testTextWidget() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleTextTag(
- array('name' => 'me', 'type' => 'text', 'value' => 'Myself')));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'Myself');
- $this->assertTrue($form->setField(new SimpleByName('me'), 'Not me'));
- $this->assertFalse($form->setField(new SimpleByName('not_present'), 'Not me'));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'Not me');
- $this->assertNull($form->getValue(new SimpleByName('not_present')));
- }
-
- function testTextWidgetById() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleTextTag(
- array('name' => 'me', 'type' => 'text', 'value' => 'Myself', 'id' => 50)));
- $this->assertIdentical($form->getValue(new SimpleById(50)), 'Myself');
- $this->assertTrue($form->setField(new SimpleById(50), 'Not me'));
- $this->assertIdentical($form->getValue(new SimpleById(50)), 'Not me');
- }
-
- function testTextWidgetByLabel() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $widget = new SimpleTextTag(array('name' => 'me', 'type' => 'text', 'value' => 'a'));
- $form->addWidget($widget);
- $widget->setLabel('thing');
- $this->assertIdentical($form->getValue(new SimpleByLabel('thing')), 'a');
- $this->assertTrue($form->setField(new SimpleByLabel('thing'), 'b'));
- $this->assertIdentical($form->getValue(new SimpleByLabel('thing')), 'b');
- }
-
- function testSubmitEmpty() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $this->assertIdentical($form->submit(), new SimpleGetEncoding());
- }
-
- function testSubmitButton() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
- $form->addWidget(new SimpleSubmitTag(
- array('type' => 'submit', 'name' => 'go', 'value' => 'Go!', 'id' => '9')));
- $this->assertTrue($form->hasSubmit(new SimpleByName('go')));
- $this->assertEqual($form->getValue(new SimpleByName('go')), 'Go!');
- $this->assertEqual($form->getValue(new SimpleById(9)), 'Go!');
- $this->assertEqual(
- $form->submitButton(new SimpleByName('go')),
- new SimpleGetEncoding(array('go' => 'Go!')));
- $this->assertEqual(
- $form->submitButton(new SimpleByLabel('Go!')),
- new SimpleGetEncoding(array('go' => 'Go!')));
- $this->assertEqual(
- $form->submitButton(new SimpleById(9)),
- new SimpleGetEncoding(array('go' => 'Go!')));
- }
-
- function testSubmitWithAdditionalParameters() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
- $form->addWidget(new SimpleSubmitTag(
- array('type' => 'submit', 'name' => 'go', 'value' => 'Go!')));
- $this->assertEqual(
- $form->submitButton(new SimpleByLabel('Go!'), array('a' => 'A')),
- new SimpleGetEncoding(array('go' => 'Go!', 'a' => 'A')));
- }
-
- function testSubmitButtonWithLabelOfSubmit() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
- $form->addWidget(new SimpleSubmitTag(
- array('type' => 'submit', 'name' => 'test', 'value' => 'Submit')));
- $this->assertEqual(
- $form->submitButton(new SimpleByName('test')),
- new SimpleGetEncoding(array('test' => 'Submit')));
- $this->assertEqual(
- $form->submitButton(new SimpleByLabel('Submit')),
- new SimpleGetEncoding(array('test' => 'Submit')));
- }
-
- function testSubmitButtonWithWhitespacePaddedLabelOfSubmit() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
- $form->addWidget(new SimpleSubmitTag(
- array('type' => 'submit', 'name' => 'test', 'value' => ' Submit ')));
- $this->assertEqual(
- $form->submitButton(new SimpleByLabel('Submit')),
- new SimpleGetEncoding(array('test' => ' Submit ')));
- }
-
- function testImageSubmitButton() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleImageSubmitTag(array(
- 'type' => 'image',
- 'src' => 'source.jpg',
- 'name' => 'go',
- 'alt' => 'Go!',
- 'id' => '9')));
- $this->assertTrue($form->hasImage(new SimpleByLabel('Go!')));
- $this->assertEqual(
- $form->submitImage(new SimpleByLabel('Go!'), 100, 101),
- new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101)));
- $this->assertTrue($form->hasImage(new SimpleByName('go')));
- $this->assertEqual(
- $form->submitImage(new SimpleByName('go'), 100, 101),
- new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101)));
- $this->assertTrue($form->hasImage(new SimpleById(9)));
- $this->assertEqual(
- $form->submitImage(new SimpleById(9), 100, 101),
- new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101)));
- }
-
- function testImageSubmitButtonWithAdditionalData() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleImageSubmitTag(array(
- 'type' => 'image',
- 'src' => 'source.jpg',
- 'name' => 'go',
- 'alt' => 'Go!')));
- $this->assertEqual(
- $form->submitImage(new SimpleByLabel('Go!'), 100, 101, array('a' => 'A')),
- new SimpleGetEncoding(array('go.x' => 100, 'go.y' => 101, 'a' => 'A')));
- }
-
- function testButtonTag() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('http://host'));
- $widget = new SimpleButtonTag(
- array('type' => 'submit', 'name' => 'go', 'value' => 'Go', 'id' => '9'));
- $widget->addContent('Go!');
- $form->addWidget($widget);
- $this->assertTrue($form->hasSubmit(new SimpleByName('go')));
- $this->assertTrue($form->hasSubmit(new SimpleByLabel('Go!')));
- $this->assertEqual(
- $form->submitButton(new SimpleByName('go')),
- new SimpleGetEncoding(array('go' => 'Go')));
- $this->assertEqual(
- $form->submitButton(new SimpleByLabel('Go!')),
- new SimpleGetEncoding(array('go' => 'Go')));
- $this->assertEqual(
- $form->submitButton(new SimpleById(9)),
- new SimpleGetEncoding(array('go' => 'Go')));
- }
-
- function testMultipleFieldsWithSameNameSubmitted() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $input = new SimpleTextTag(array('name' => 'elements[]', 'value' => '1'));
- $form->addWidget($input);
- $input = new SimpleTextTag(array('name' => 'elements[]', 'value' => '2'));
- $form->addWidget($input);
- $form->setField(new SimpleByLabelOrName('elements[]'), '3', 1);
- $form->setField(new SimpleByLabelOrName('elements[]'), '4', 2);
- $submit = $form->submit();
- $requests = $submit->getAll();
- $this->assertEqual(count($requests), 2);
- $this->assertIdentical($requests[0], new SimpleEncodedPair('elements[]', '3'));
- $this->assertIdentical($requests[1], new SimpleEncodedPair('elements[]', '4'));
- }
-
- function testSingleSelectFieldSubmitted() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $select = new SimpleSelectionTag(array('name' => 'a'));
- $select->addTag(new SimpleOptionTag(
- array('value' => 'aaa', 'selected' => '')));
- $form->addWidget($select);
- $this->assertIdentical(
- $form->submit(),
- new SimpleGetEncoding(array('a' => 'aaa')));
- }
-
- function testSingleSelectFieldSubmittedWithPost() {
- $form = new SimpleForm(new SimpleFormTag(array('method' => 'post')), $this->page('htp://host'));
- $select = new SimpleSelectionTag(array('name' => 'a'));
- $select->addTag(new SimpleOptionTag(
- array('value' => 'aaa', 'selected' => '')));
- $form->addWidget($select);
- $this->assertIdentical(
- $form->submit(),
- new SimplePostEncoding(array('a' => 'aaa')));
- }
-
- function testUnchecked() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleCheckboxTag(
- array('name' => 'me', 'type' => 'checkbox')));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), false);
- $this->assertTrue($form->setField(new SimpleByName('me'), 'on'));
- $this->assertEqual($form->getValue(new SimpleByName('me')), 'on');
- $this->assertFalse($form->setField(new SimpleByName('me'), 'other'));
- $this->assertEqual($form->getValue(new SimpleByName('me')), 'on');
- }
-
- function testChecked() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleCheckboxTag(
- array('name' => 'me', 'value' => 'a', 'type' => 'checkbox', 'checked' => '')));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
- $this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
- $this->assertEqual($form->getValue(new SimpleByName('me')), 'a');
- $this->assertTrue($form->setField(new SimpleByName('me'), false));
- $this->assertEqual($form->getValue(new SimpleByName('me')), false);
- }
-
- function testSingleUncheckedRadioButton() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleRadioButtonTag(
- array('name' => 'me', 'value' => 'a', 'type' => 'radio')));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), false);
- $this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
- $this->assertEqual($form->getValue(new SimpleByName('me')), 'a');
- }
-
- function testSingleCheckedRadioButton() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleRadioButtonTag(
- array('name' => 'me', 'value' => 'a', 'type' => 'radio', 'checked' => '')));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
- $this->assertFalse($form->setField(new SimpleByName('me'), 'other'));
- }
-
- function testUncheckedRadioButtons() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleRadioButtonTag(
- array('name' => 'me', 'value' => 'a', 'type' => 'radio')));
- $form->addWidget(new SimpleRadioButtonTag(
- array('name' => 'me', 'value' => 'b', 'type' => 'radio')));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), false);
- $this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
- $this->assertTrue($form->setField(new SimpleByName('me'), 'b'));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'b');
- $this->assertFalse($form->setField(new SimpleByName('me'), 'c'));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'b');
- }
-
- function testCheckedRadioButtons() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleRadioButtonTag(
- array('name' => 'me', 'value' => 'a', 'type' => 'radio')));
- $form->addWidget(new SimpleRadioButtonTag(
- array('name' => 'me', 'value' => 'b', 'type' => 'radio', 'checked' => '')));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'b');
- $this->assertTrue($form->setField(new SimpleByName('me'), 'a'));
- $this->assertIdentical($form->getValue(new SimpleByName('me')), 'a');
- }
-
- function testMultipleFieldsWithSameKey() {
- $form = new SimpleForm(new SimpleFormTag(array()), $this->page('htp://host'));
- $form->addWidget(new SimpleCheckboxTag(
- array('name' => 'a', 'type' => 'checkbox', 'value' => 'me')));
- $form->addWidget(new SimpleCheckboxTag(
- array('name' => 'a', 'type' => 'checkbox', 'value' => 'you')));
- $this->assertIdentical($form->getValue(new SimpleByName('a')), false);
- $this->assertTrue($form->setField(new SimpleByName('a'), 'me'));
- $this->assertIdentical($form->getValue(new SimpleByName('a')), 'me');
- }
-
- function testRemoveGetParamsFromAction() {
- Mock::generatePartial('SimplePage', 'MockPartialSimplePage', array('getUrl'));
- $page = new MockPartialSimplePage();
- $page->returns('getUrl', new SimpleUrl('htp://host/'));
-
- # Keep GET params in "action", if the form has no widgets
- $form = new SimpleForm(new SimpleFormTag(array('action'=>'?test=1')), $page);
- $this->assertEqual($form->getAction()->asString(), 'htp://host/');
-
- $form = new SimpleForm(new SimpleFormTag(array('action'=>'?test=1')), $page);
- $form->addWidget(new SimpleTextTag(array('name' => 'me', 'type' => 'text', 'value' => 'a')));
- $this->assertEqual($form->getAction()->asString(), 'htp://host/');
-
- $form = new SimpleForm(new SimpleFormTag(array('action'=>'')), $page);
- $this->assertEqual($form->getAction()->asString(), 'htp://host/');
-
- $form = new SimpleForm(new SimpleFormTag(array('action'=>'?test=1', 'method'=>'post')), $page);
- $this->assertEqual($form->getAction()->asString(), 'htp://host/?test=1');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/frames_test.php b/core/vendors/simpletest/test/frames_test.php
deleted file mode 100755
index 2930970..0000000
--- a/core/vendors/simpletest/test/frames_test.php
+++ /dev/null
@@ -1,549 +0,0 @@
-setReturnValue('getTitle', 'This page');
- $frameset = new SimpleFrameset($page);
- $this->assertEqual($frameset->getTitle(), 'This page');
- }
-
- function TestHeadersReadFromFramesetByDefault() {
- $page = new MockSimplePage();
- $page->setReturnValue('getHeaders', 'Header: content');
- $page->setReturnValue('getMimeType', 'text/xml');
- $page->setReturnValue('getResponseCode', 401);
- $page->setReturnValue('getTransportError', 'Could not parse headers');
- $page->setReturnValue('getAuthentication', 'Basic');
- $page->setReturnValue('getRealm', 'Safe place');
-
- $frameset = new SimpleFrameset($page);
-
- $this->assertIdentical($frameset->getHeaders(), 'Header: content');
- $this->assertIdentical($frameset->getMimeType(), 'text/xml');
- $this->assertIdentical($frameset->getResponseCode(), 401);
- $this->assertIdentical($frameset->getTransportError(), 'Could not parse headers');
- $this->assertIdentical($frameset->getAuthentication(), 'Basic');
- $this->assertIdentical($frameset->getRealm(), 'Safe place');
- }
-
- function testEmptyFramesetHasNoContent() {
- $page = new MockSimplePage();
- $page->setReturnValue('getRaw', 'This content');
- $frameset = new SimpleFrameset($page);
- $this->assertEqual($frameset->getRaw(), '');
- }
-
- function testRawContentIsFromOnlyFrame() {
- $page = new MockSimplePage();
- $page->expectNever('getRaw');
-
- $frame = new MockSimplePage();
- $frame->setReturnValue('getRaw', 'Stuff');
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame);
- $this->assertEqual($frameset->getRaw(), 'Stuff');
- }
-
- function testRawContentIsFromAllFrames() {
- $page = new MockSimplePage();
- $page->expectNever('getRaw');
-
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getRaw', 'Stuff1');
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getRaw', 'Stuff2');
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1);
- $frameset->addFrame($frame2);
- $this->assertEqual($frameset->getRaw(), 'Stuff1Stuff2');
- }
-
- function testTextContentIsFromOnlyFrame() {
- $page = new MockSimplePage();
- $page->expectNever('getText');
-
- $frame = new MockSimplePage();
- $frame->setReturnValue('getText', 'Stuff');
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame);
- $this->assertEqual($frameset->getText(), 'Stuff');
- }
-
- function testTextContentIsFromAllFrames() {
- $page = new MockSimplePage();
- $page->expectNever('getText');
-
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getText', 'Stuff1');
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getText', 'Stuff2');
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1);
- $frameset->addFrame($frame2);
- $this->assertEqual($frameset->getText(), 'Stuff1 Stuff2');
- }
-
- function testFieldFoundIsFirstInFramelist() {
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getField', null);
- $frame1->expectOnce('getField', array(new SimpleByName('a')));
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getField', 'A');
- $frame2->expectOnce('getField', array(new SimpleByName('a')));
-
- $frame3 = new MockSimplePage();
- $frame3->expectNever('getField');
-
- $page = new MockSimplePage();
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1);
- $frameset->addFrame($frame2);
- $frameset->addFrame($frame3);
- $this->assertIdentical($frameset->getField(new SimpleByName('a')), 'A');
- }
-
- function testFrameReplacementByIndex() {
- $page = new MockSimplePage();
- $page->expectNever('getRaw');
-
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getRaw', 'Stuff1');
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getRaw', 'Stuff2');
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1);
- $frameset->setFrame(array(1), $frame2);
- $this->assertEqual($frameset->getRaw(), 'Stuff2');
- }
-
- function testFrameReplacementByName() {
- $page = new MockSimplePage();
- $page->expectNever('getRaw');
-
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getRaw', 'Stuff1');
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getRaw', 'Stuff2');
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1, 'a');
- $frameset->setFrame(array('a'), $frame2);
- $this->assertEqual($frameset->getRaw(), 'Stuff2');
- }
-}
-
-class TestOfFrameNavigation extends UnitTestCase {
-
- function testStartsWithoutFrameFocus() {
- $page = new MockSimplePage();
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame(new MockSimplePage());
- $this->assertFalse($frameset->getFrameFocus());
- }
-
- function testCanFocusOnSingleFrame() {
- $page = new MockSimplePage();
- $page->expectNever('getRaw');
-
- $frame = new MockSimplePage();
- $frame->setReturnValue('getFrameFocus', array());
- $frame->setReturnValue('getRaw', 'Stuff');
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame);
-
- $this->assertFalse($frameset->setFrameFocusByIndex(0));
- $this->assertTrue($frameset->setFrameFocusByIndex(1));
- $this->assertEqual($frameset->getRaw(), 'Stuff');
- $this->assertFalse($frameset->setFrameFocusByIndex(2));
- $this->assertIdentical($frameset->getFrameFocus(), array(1));
- }
-
- function testContentComesFromFrameInFocus() {
- $page = new MockSimplePage();
-
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getRaw', 'Stuff1');
- $frame1->setReturnValue('getFrameFocus', array());
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getRaw', 'Stuff2');
- $frame2->setReturnValue('getFrameFocus', array());
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1);
- $frameset->addFrame($frame2);
-
- $this->assertTrue($frameset->setFrameFocusByIndex(1));
- $this->assertEqual($frameset->getFrameFocus(), array(1));
- $this->assertEqual($frameset->getRaw(), 'Stuff1');
-
- $this->assertTrue($frameset->setFrameFocusByIndex(2));
- $this->assertEqual($frameset->getFrameFocus(), array(2));
- $this->assertEqual($frameset->getRaw(), 'Stuff2');
-
- $this->assertFalse($frameset->setFrameFocusByIndex(3));
- $this->assertEqual($frameset->getFrameFocus(), array(2));
-
- $frameset->clearFrameFocus();
- $this->assertEqual($frameset->getRaw(), 'Stuff1Stuff2');
- }
-
- function testCanFocusByName() {
- $page = new MockSimplePage();
-
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getRaw', 'Stuff1');
- $frame1->setReturnValue('getFrameFocus', array());
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getRaw', 'Stuff2');
- $frame2->setReturnValue('getFrameFocus', array());
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1, 'A');
- $frameset->addFrame($frame2, 'B');
-
- $this->assertTrue($frameset->setFrameFocus('A'));
- $this->assertEqual($frameset->getFrameFocus(), array('A'));
- $this->assertEqual($frameset->getRaw(), 'Stuff1');
-
- $this->assertTrue($frameset->setFrameFocusByIndex(2));
- $this->assertEqual($frameset->getFrameFocus(), array('B'));
- $this->assertEqual($frameset->getRaw(), 'Stuff2');
-
- $this->assertFalse($frameset->setFrameFocus('z'));
-
- $frameset->clearFrameFocus();
- $this->assertEqual($frameset->getRaw(), 'Stuff1Stuff2');
- }
-}
-
-class TestOfFramesetPageInterface extends UnitTestCase {
- private $page_interface;
- private $frameset_interface;
-
- function __construct() {
- parent::__construct();
- $this->page_interface = $this->getPageMethods();
- $this->frameset_interface = $this->getFramesetMethods();
- }
-
- function assertListInAnyOrder($list, $expected) {
- sort($list);
- sort($expected);
- $this->assertEqual($list, $expected);
- }
-
- private function getPageMethods() {
- $methods = array();
- foreach (get_class_methods('SimplePage') as $method) {
- if (strtolower($method) == strtolower('SimplePage')) {
- continue;
- }
- if (strtolower($method) == strtolower('getFrameset')) {
- continue;
- }
- if (strncmp($method, '_', 1) == 0) {
- continue;
- }
- if (in_array($method, array('setTitle', 'setBase', 'setForms', 'normalise', 'setFrames', 'addLink'))) {
- continue;
- }
- $methods[] = $method;
- }
- return $methods;
- }
-
- private function getFramesetMethods() {
- $methods = array();
- foreach (get_class_methods('SimpleFrameset') as $method) {
- if (strtolower($method) == strtolower('SimpleFrameset')) {
- continue;
- }
- if (strncmp($method, '_', 1) == 0) {
- continue;
- }
- if (strncmp($method, 'add', 3) == 0) {
- continue;
- }
- $methods[] = $method;
- }
- return $methods;
- }
-
- function testFramsetHasPageInterface() {
- $difference = array();
- foreach ($this->page_interface as $method) {
- if (! in_array($method, $this->frameset_interface)) {
- $this->fail("No [$method] in Frameset class");
- return;
- }
- }
- $this->pass('Frameset covers Page interface');
- }
-
- function testHeadersReadFromFrameIfInFocus() {
- $frame = new MockSimplePage();
- $frame->setReturnValue('getUrl', new SimpleUrl('http://localhost/stuff'));
-
- $frame->setReturnValue('getRequest', 'POST stuff');
- $frame->setReturnValue('getMethod', 'POST');
- $frame->setReturnValue('getRequestData', array('a' => 'A'));
- $frame->setReturnValue('getHeaders', 'Header: content');
- $frame->setReturnValue('getMimeType', 'text/xml');
- $frame->setReturnValue('getResponseCode', 401);
- $frame->setReturnValue('getTransportError', 'Could not parse headers');
- $frame->setReturnValue('getAuthentication', 'Basic');
- $frame->setReturnValue('getRealm', 'Safe place');
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame);
- $frameset->setFrameFocusByIndex(1);
-
- $url = new SimpleUrl('http://localhost/stuff');
- $url->setTarget(1);
- $this->assertIdentical($frameset->getUrl(), $url);
-
- $this->assertIdentical($frameset->getRequest(), 'POST stuff');
- $this->assertIdentical($frameset->getMethod(), 'POST');
- $this->assertIdentical($frameset->getRequestData(), array('a' => 'A'));
- $this->assertIdentical($frameset->getHeaders(), 'Header: content');
- $this->assertIdentical($frameset->getMimeType(), 'text/xml');
- $this->assertIdentical($frameset->getResponseCode(), 401);
- $this->assertIdentical($frameset->getTransportError(), 'Could not parse headers');
- $this->assertIdentical($frameset->getAuthentication(), 'Basic');
- $this->assertIdentical($frameset->getRealm(), 'Safe place');
- }
-
- function testUrlsComeFromBothFrames() {
- $page = new MockSimplePage();
- $page->expectNever('getUrls');
-
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue(
- 'getUrls',
- array('http://www.lastcraft.com/', 'http://myserver/'));
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue(
- 'getUrls',
- array('http://www.lastcraft.com/', 'http://test/'));
-
- $frameset = new SimpleFrameset($page);
- $frameset->addFrame($frame1);
- $frameset->addFrame($frame2);
- $this->assertListInAnyOrder(
- $frameset->getUrls(),
- array('http://www.lastcraft.com/', 'http://myserver/', 'http://test/'));
- }
-
- function testLabelledUrlsComeFromBothFrames() {
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue(
- 'getUrlsByLabel',
- array(new SimpleUrl('goodbye.php')),
- array('a'));
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue(
- 'getUrlsByLabel',
- array(new SimpleUrl('hello.php')),
- array('a'));
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame1);
- $frameset->addFrame($frame2, 'Two');
-
- $expected1 = new SimpleUrl('goodbye.php');
- $expected1->setTarget(1);
- $expected2 = new SimpleUrl('hello.php');
- $expected2->setTarget('Two');
- $this->assertEqual(
- $frameset->getUrlsByLabel('a'),
- array($expected1, $expected2));
- }
-
- function testUrlByIdComesFromFirstFrameToRespond() {
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getUrlById', new SimpleUrl('four.php'), array(4));
- $frame1->setReturnValue('getUrlById', false, array(5));
-
- $frame2 = new MockSimplePage();
- $frame2->setReturnValue('getUrlById', false, array(4));
- $frame2->setReturnValue('getUrlById', new SimpleUrl('five.php'), array(5));
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame1);
- $frameset->addFrame($frame2);
-
- $four = new SimpleUrl('four.php');
- $four->setTarget(1);
- $this->assertEqual($frameset->getUrlById(4), $four);
- $five = new SimpleUrl('five.php');
- $five->setTarget(2);
- $this->assertEqual($frameset->getUrlById(5), $five);
- }
-
- function testReadUrlsFromFrameInFocus() {
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getUrls', array('a'));
- $frame1->setReturnValue('getUrlsByLabel', array(new SimpleUrl('l')));
- $frame1->setReturnValue('getUrlById', new SimpleUrl('i'));
-
- $frame2 = new MockSimplePage();
- $frame2->expectNever('getUrls');
- $frame2->expectNever('getUrlsByLabel');
- $frame2->expectNever('getUrlById');
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame1, 'A');
- $frameset->addFrame($frame2, 'B');
- $frameset->setFrameFocus('A');
-
- $this->assertIdentical($frameset->getUrls(), array('a'));
- $expected = new SimpleUrl('l');
- $expected->setTarget('A');
- $this->assertIdentical($frameset->getUrlsByLabel('label'), array($expected));
- $expected = new SimpleUrl('i');
- $expected->setTarget('A');
- $this->assertIdentical($frameset->getUrlById(99), $expected);
- }
-
- function testReadFrameTaggedUrlsFromFrameInFocus() {
- $frame = new MockSimplePage();
-
- $by_label = new SimpleUrl('l');
- $by_label->setTarget('L');
- $frame->setReturnValue('getUrlsByLabel', array($by_label));
-
- $by_id = new SimpleUrl('i');
- $by_id->setTarget('I');
- $frame->setReturnValue('getUrlById', $by_id);
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame, 'A');
- $frameset->setFrameFocus('A');
-
- $this->assertIdentical($frameset->getUrlsByLabel('label'), array($by_label));
- $this->assertIdentical($frameset->getUrlById(99), $by_id);
- }
-
- function testFindingFormsById() {
- $frame = new MockSimplePage();
- $form = new MockSimpleForm();
- $frame->returns('getFormById', $form, array('a'));
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame(new MockSimplePage(), 'A');
- $frameset->addFrame($frame, 'B');
- $this->assertSame($frameset->getFormById('a'), $form);
-
- $frameset->setFrameFocus('A');
- $this->assertNull($frameset->getFormById('a'));
-
- $frameset->setFrameFocus('B');
- $this->assertSame($frameset->getFormById('a'), $form);
- }
-
- function testFindingFormsBySubmit() {
- $frame = new MockSimplePage();
- $form = new MockSimpleForm();
- $frame->returns(
- 'getFormBySubmit',
- $form,
- array(new SimpleByLabel('a')));
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame(new MockSimplePage(), 'A');
- $frameset->addFrame($frame, 'B');
- $this->assertSame($frameset->getFormBySubmit(new SimpleByLabel('a')), $form);
-
- $frameset->setFrameFocus('A');
- $this->assertNull($frameset->getFormBySubmit(new SimpleByLabel('a')));
-
- $frameset->setFrameFocus('B');
- $this->assertSame($frameset->getFormBySubmit(new SimpleByLabel('a')), $form);
- }
-
- function testFindingFormsByImage() {
- $frame = new MockSimplePage();
- $form = new MockSimpleForm();
- $frame->returns(
- 'getFormByImage',
- $form,
- array(new SimpleByLabel('a')));
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame(new MockSimplePage(), 'A');
- $frameset->addFrame($frame, 'B');
- $this->assertSame($frameset->getFormByImage(new SimpleByLabel('a')), $form);
-
- $frameset->setFrameFocus('A');
- $this->assertNull($frameset->getFormByImage(new SimpleByLabel('a')));
-
- $frameset->setFrameFocus('B');
- $this->assertSame($frameset->getFormByImage(new SimpleByLabel('a')), $form);
- }
-
- function testSettingAllFrameFieldsWhenNoFrameFocus() {
- $frame1 = new MockSimplePage();
- $frame1->expectOnce('setField', array(new SimpleById(22), 'A'));
-
- $frame2 = new MockSimplePage();
- $frame2->expectOnce('setField', array(new SimpleById(22), 'A'));
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame1, 'A');
- $frameset->addFrame($frame2, 'B');
- $frameset->setField(new SimpleById(22), 'A');
- }
-
- function testOnlySettingFieldFromFocusedFrame() {
- $frame1 = new MockSimplePage();
- $frame1->expectOnce('setField', array(new SimpleByLabelOrName('a'), 'A'));
-
- $frame2 = new MockSimplePage();
- $frame2->expectNever('setField');
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame1, 'A');
- $frameset->addFrame($frame2, 'B');
- $frameset->setFrameFocus('A');
- $frameset->setField(new SimpleByLabelOrName('a'), 'A');
- }
-
- function testOnlyGettingFieldFromFocusedFrame() {
- $frame1 = new MockSimplePage();
- $frame1->setReturnValue('getField', 'f', array(new SimpleByName('a')));
-
- $frame2 = new MockSimplePage();
- $frame2->expectNever('getField');
-
- $frameset = new SimpleFrameset(new MockSimplePage());
- $frameset->addFrame($frame1, 'A');
- $frameset->addFrame($frame2, 'B');
- $frameset->setFrameFocus('A');
- $this->assertIdentical($frameset->getField(new SimpleByName('a')), 'f');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/http_test.php b/core/vendors/simpletest/test/http_test.php
deleted file mode 100755
index bd3fdd0..0000000
--- a/core/vendors/simpletest/test/http_test.php
+++ /dev/null
@@ -1,492 +0,0 @@
-expectAt(0, 'write', array("GET /here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
- $route = new PartialSimpleRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
- $this->assertSame($route->createConnection('GET', 15), $socket);
- }
-
- function testDefaultPostRequest() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("POST /here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
- $route = new PartialSimpleRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
-
- $route->createConnection('POST', 15);
- }
-
- function testDefaultDeleteRequest() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("DELETE /here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
- $route = new PartialSimpleRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
- $this->assertSame($route->createConnection('DELETE', 15), $socket);
- }
-
- function testDefaultHeadRequest() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("HEAD /here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
- $route = new PartialSimpleRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(new SimpleUrl('http://a.valid.host/here.html'));
- $this->assertSame($route->createConnection('HEAD', 15), $socket);
- }
-
- function testGetWithPort() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("GET /here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: a.valid.host:81\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
-
- $route = new PartialSimpleRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(new SimpleUrl('http://a.valid.host:81/here.html'));
-
- $route->createConnection('GET', 15);
- }
-
- function testGetWithParameters() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("GET /here.html?a=1&b=2 HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: a.valid.host\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
-
- $route = new PartialSimpleRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(new SimpleUrl('http://a.valid.host/here.html?a=1&b=2'));
-
- $route->createConnection('GET', 15);
- }
-}
-
-class TestOfProxyRoute extends UnitTestCase {
-
- function testDefaultGet() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("GET http://a.valid.host/here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
-
- $route = new PartialSimpleProxyRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(
- new SimpleUrl('http://a.valid.host/here.html'),
- new SimpleUrl('http://my-proxy'));
- $route->createConnection('GET', 15);
- }
-
- function testDefaultPost() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("POST http://a.valid.host/here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
-
- $route = new PartialSimpleProxyRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(
- new SimpleUrl('http://a.valid.host/here.html'),
- new SimpleUrl('http://my-proxy'));
- $route->createConnection('POST', 15);
- }
-
- function testGetWithPort() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("GET http://a.valid.host:81/here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: my-proxy:8081\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
-
- $route = new PartialSimpleProxyRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(
- new SimpleUrl('http://a.valid.host:81/here.html'),
- new SimpleUrl('http://my-proxy:8081'));
- $route->createConnection('GET', 15);
- }
-
- function testGetWithParameters() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("GET http://a.valid.host/here.html?a=1&b=2 HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
- $socket->expectAt(2, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 3);
-
- $route = new PartialSimpleProxyRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(
- new SimpleUrl('http://a.valid.host/here.html?a=1&b=2'),
- new SimpleUrl('http://my-proxy'));
- $route->createConnection('GET', 15);
- }
-
- function testGetWithAuthentication() {
- $encoded = base64_encode('Me:Secret');
-
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("GET http://a.valid.host/here.html HTTP/1.0\r\n"));
- $socket->expectAt(1, 'write', array("Host: my-proxy:8080\r\n"));
- $socket->expectAt(2, 'write', array("Proxy-Authorization: Basic $encoded\r\n"));
- $socket->expectAt(3, 'write', array("Connection: close\r\n"));
- $socket->expectCallCount('write', 4);
-
- $route = new PartialSimpleProxyRoute();
- $route->setReturnReference('createSocket', $socket);
- $route->__construct(
- new SimpleUrl('http://a.valid.host/here.html'),
- new SimpleUrl('http://my-proxy'),
- 'Me',
- 'Secret');
- $route->createConnection('GET', 15);
- }
-}
-
-class TestOfHttpRequest extends UnitTestCase {
-
- function testReadingBadConnection() {
- $socket = new MockSimpleSocket();
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $request = new SimpleHttpRequest($route, new SimpleGetEncoding());
- $reponse = $request->fetch(15);
- $this->assertTrue($reponse->isError());
- }
-
- function testReadingGoodConnection() {
- $socket = new MockSimpleSocket();
- $socket->expectOnce('write', array("\r\n"));
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $route->expect('createConnection', array('GET', 15));
-
- $request = new SimpleHttpRequest($route, new SimpleGetEncoding());
- $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
- }
-
- function testWritingAdditionalHeaders() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("My: stuff\r\n"));
- $socket->expectAt(1, 'write', array("\r\n"));
- $socket->expectCallCount('write', 2);
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
-
- $request = new SimpleHttpRequest($route, new SimpleGetEncoding());
- $request->addHeaderLine('My: stuff');
- $request->fetch(15);
- }
-
- function testCookieWriting() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Cookie: a=A\r\n"));
- $socket->expectAt(1, 'write', array("\r\n"));
- $socket->expectCallCount('write', 2);
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
-
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A');
-
- $request = new SimpleHttpRequest($route, new SimpleGetEncoding());
- $request->readCookiesFromJar($jar, new SimpleUrl('/'));
- $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
- }
-
- function testMultipleCookieWriting() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Cookie: a=A;b=B\r\n"));
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
-
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A');
- $jar->setCookie('b', 'B');
-
- $request = new SimpleHttpRequest($route, new SimpleGetEncoding());
- $request->readCookiesFromJar($jar, new SimpleUrl('/'));
- $request->fetch(15);
- }
-
- function testReadingDeleteConnection() {
- $socket = new MockSimpleSocket();
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $route->expect('createConnection', array('DELETE', 15));
-
- $request = new SimpleHttpRequest($route, new SimpleDeleteEncoding());
- $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
- }
-}
-
-class TestOfHttpPostRequest extends UnitTestCase {
-
- function testReadingBadConnectionCausesErrorBecauseOfDeadSocket() {
- $socket = new MockSimpleSocket();
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $request = new SimpleHttpRequest($route, new SimplePostEncoding());
- $reponse = $request->fetch(15);
- $this->assertTrue($reponse->isError());
- }
-
- function testReadingGoodConnection() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Content-Length: 0\r\n"));
- $socket->expectAt(1, 'write', array("Content-Type: application/x-www-form-urlencoded\r\n"));
- $socket->expectAt(2, 'write', array("\r\n"));
- $socket->expectAt(3, 'write', array(""));
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $route->expect('createConnection', array('POST', 15));
-
- $request = new SimpleHttpRequest($route, new SimplePostEncoding());
- $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
- }
-
- function testContentHeadersCalculatedWithUrlEncodedParams() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Content-Length: 3\r\n"));
- $socket->expectAt(1, 'write', array("Content-Type: application/x-www-form-urlencoded\r\n"));
- $socket->expectAt(2, 'write', array("\r\n"));
- $socket->expectAt(3, 'write', array("a=A"));
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $route->expect('createConnection', array('POST', 15));
-
- $request = new SimpleHttpRequest(
- $route,
- new SimplePostEncoding(array('a' => 'A')));
- $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
- }
-
- function testContentHeadersCalculatedWithRawEntityBody() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Content-Length: 8\r\n"));
- $socket->expectAt(1, 'write', array("Content-Type: text/plain\r\n"));
- $socket->expectAt(2, 'write', array("\r\n"));
- $socket->expectAt(3, 'write', array("raw body"));
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $route->expect('createConnection', array('POST', 15));
-
- $request = new SimpleHttpRequest(
- $route,
- new SimplePostEncoding('raw body'));
- $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
- }
-
- function testContentHeadersCalculatedWithXmlEntityBody() {
- $socket = new MockSimpleSocket();
- $socket->expectAt(0, 'write', array("Content-Length: 27\r\n"));
- $socket->expectAt(1, 'write', array("Content-Type: text/xml\r\n"));
- $socket->expectAt(2, 'write', array("\r\n"));
- $socket->expectAt(3, 'write', array("one two "));
-
- $route = new MockSimpleRoute();
- $route->setReturnReference('createConnection', $socket);
- $route->expect('createConnection', array('POST', 15));
-
- $request = new SimpleHttpRequest(
- $route,
- new SimplePostEncoding('one two ', 'text/xml'));
- $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
- }
-}
-
-class TestOfHttpHeaders extends UnitTestCase {
-
- function testParseBasicHeaders() {
- $headers = new SimpleHttpHeaders(
- "HTTP/1.1 200 OK\r\n" .
- "Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n" .
- "Content-Type: text/plain\r\n" .
- "Server: Apache/1.3.24 (Win32) PHP/4.2.3\r\n" .
- "Connection: close");
- $this->assertIdentical($headers->getHttpVersion(), "1.1");
- $this->assertIdentical($headers->getResponseCode(), 200);
- $this->assertEqual($headers->getMimeType(), "text/plain");
- }
-
- function testNonStandardResponseHeader() {
- $headers = new SimpleHttpHeaders(
- "HTTP/1.1 302 (HTTP-Version SP Status-Code CRLF)\r\n" .
- "Connection: close");
- $this->assertIdentical($headers->getResponseCode(), 302);
- }
-
- function testCanParseMultipleCookies() {
- $jar = new MockSimpleCookieJar();
- $jar->expectAt(0, 'setCookie', array('a', 'aaa', 'host', '/here/', 'Wed, 25 Dec 2002 04:24:20 GMT'));
- $jar->expectAt(1, 'setCookie', array('b', 'bbb', 'host', '/', false));
-
- $headers = new SimpleHttpHeaders(
- "HTTP/1.1 200 OK\r\n" .
- "Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n" .
- "Content-Type: text/plain\r\n" .
- "Server: Apache/1.3.24 (Win32) PHP/4.2.3\r\n" .
- "Set-Cookie: a=aaa; expires=Wed, 25-Dec-02 04:24:20 GMT; path=/here/\r\n" .
- "Set-Cookie: b=bbb\r\n" .
- "Connection: close");
- $headers->writeCookiesToJar($jar, new SimpleUrl('http://host'));
- }
-
- function testCanRecogniseRedirect() {
- $headers = new SimpleHttpHeaders("HTTP/1.1 301 OK\r\n" .
- "Content-Type: text/plain\r\n" .
- "Content-Length: 0\r\n" .
- "Location: http://www.somewhere-else.com/\r\n" .
- "Connection: close");
- $this->assertIdentical($headers->getResponseCode(), 301);
- $this->assertEqual($headers->getLocation(), "http://www.somewhere-else.com/");
- $this->assertTrue($headers->isRedirect());
- }
-
- function testCanParseChallenge() {
- $headers = new SimpleHttpHeaders("HTTP/1.1 401 Authorization required\r\n" .
- "Content-Type: text/plain\r\n" .
- "Connection: close\r\n" .
- "WWW-Authenticate: Basic realm=\"Somewhere\"");
- $this->assertEqual($headers->getAuthentication(), 'Basic');
- $this->assertEqual($headers->getRealm(), 'Somewhere');
- $this->assertTrue($headers->isChallenge());
- }
-}
-
-class TestOfHttpResponse extends UnitTestCase {
-
- function testBadRequest() {
- $socket = new MockSimpleSocket();
- $socket->setReturnValue('getSent', '');
-
- $response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
- $this->assertTrue($response->isError());
- $this->assertPattern('/Nothing fetched/', $response->getError());
- $this->assertIdentical($response->getContent(), false);
- $this->assertIdentical($response->getSent(), '');
- }
-
- function testBadSocketDuringResponse() {
- $socket = new MockSimpleSocket();
- $socket->setReturnValueAt(0, "read", "HTTP/1.1 200 OK\r\n");
- $socket->setReturnValueAt(1, "read", "Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n");
- $socket->setReturnValue("read", "");
- $socket->setReturnValue('getSent', 'HTTP/1.1 ...');
-
- $response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
- $this->assertTrue($response->isError());
- $this->assertEqual($response->getContent(), '');
- $this->assertEqual($response->getSent(), 'HTTP/1.1 ...');
- }
-
- function testIncompleteHeader() {
- $socket = new MockSimpleSocket();
- $socket->setReturnValueAt(0, "read", "HTTP/1.1 200 OK\r\n");
- $socket->setReturnValueAt(1, "read", "Date: Mon, 18 Nov 2002 15:50:29 GMT\r\n");
- $socket->setReturnValueAt(2, "read", "Content-Type: text/plain\r\n");
- $socket->setReturnValue("read", "");
-
- $response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
- $this->assertTrue($response->isError());
- $this->assertEqual($response->getContent(), "");
- }
-
- function testParseOfResponseHeadersWhenChunked() {
- $socket = new MockSimpleSocket();
- $socket->setReturnValueAt(0, "read", "HTTP/1.1 200 OK\r\nDate: Mon, 18 Nov 2002 15:50:29 GMT\r\n");
- $socket->setReturnValueAt(1, "read", "Content-Type: text/plain\r\n");
- $socket->setReturnValueAt(2, "read", "Server: Apache/1.3.24 (Win32) PHP/4.2.3\r\nConne");
- $socket->setReturnValueAt(3, "read", "ction: close\r\n\r\nthis is a test file\n");
- $socket->setReturnValueAt(4, "read", "with two lines in it\n");
- $socket->setReturnValue("read", "");
-
- $response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
- $this->assertFalse($response->isError());
- $this->assertEqual(
- $response->getContent(),
- "this is a test file\nwith two lines in it\n");
- $headers = $response->getHeaders();
- $this->assertIdentical($headers->getHttpVersion(), "1.1");
- $this->assertIdentical($headers->getResponseCode(), 200);
- $this->assertEqual($headers->getMimeType(), "text/plain");
- $this->assertFalse($headers->isRedirect());
- $this->assertFalse($headers->getLocation());
- }
-
- function testRedirect() {
- $socket = new MockSimpleSocket();
- $socket->setReturnValueAt(0, "read", "HTTP/1.1 301 OK\r\n");
- $socket->setReturnValueAt(1, "read", "Content-Type: text/plain\r\n");
- $socket->setReturnValueAt(2, "read", "Location: http://www.somewhere-else.com/\r\n");
- $socket->setReturnValueAt(3, "read", "Connection: close\r\n");
- $socket->setReturnValueAt(4, "read", "\r\n");
- $socket->setReturnValue("read", "");
-
- $response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
- $headers = $response->getHeaders();
- $this->assertTrue($headers->isRedirect());
- $this->assertEqual($headers->getLocation(), "http://www.somewhere-else.com/");
- }
-
- function testRedirectWithPort() {
- $socket = new MockSimpleSocket();
- $socket->setReturnValueAt(0, "read", "HTTP/1.1 301 OK\r\n");
- $socket->setReturnValueAt(1, "read", "Content-Type: text/plain\r\n");
- $socket->setReturnValueAt(2, "read", "Location: http://www.somewhere-else.com:80/\r\n");
- $socket->setReturnValueAt(3, "read", "Connection: close\r\n");
- $socket->setReturnValueAt(4, "read", "\r\n");
- $socket->setReturnValue("read", "");
-
- $response = new SimpleHttpResponse($socket, new SimpleUrl('here'), new SimpleGetEncoding());
- $headers = $response->getHeaders();
- $this->assertTrue($headers->isRedirect());
- $this->assertEqual($headers->getLocation(), "http://www.somewhere-else.com:80/");
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/interfaces_test.php b/core/vendors/simpletest/test/interfaces_test.php
deleted file mode 100755
index ab30fe4..0000000
--- a/core/vendors/simpletest/test/interfaces_test.php
+++ /dev/null
@@ -1,137 +0,0 @@
-=')) {
- include(dirname(__FILE__) . '/interfaces_test_php5_1.php');
-}
-
-interface DummyInterface {
- function aMethod();
- function anotherMethod($a);
- function &referenceMethod(&$a);
-}
-
-Mock::generate('DummyInterface');
-Mock::generatePartial('DummyInterface', 'PartialDummyInterface', array());
-
-class TestOfMockInterfaces extends UnitTestCase {
-
- function testCanMockAnInterface() {
- $mock = new MockDummyInterface();
- $this->assertIsA($mock, 'SimpleMock');
- $this->assertIsA($mock, 'MockDummyInterface');
- $this->assertTrue(method_exists($mock, 'aMethod'));
- $this->assertTrue(method_exists($mock, 'anotherMethod'));
- $this->assertNull($mock->aMethod());
- }
-
- function testMockedInterfaceExpectsParameters() {
- $mock = new MockDummyInterface();
- $this->expectError();
- $mock->anotherMethod();
- }
-
- function testCannotPartiallyMockAnInterface() {
- $this->assertFalse(class_exists('PartialDummyInterface'));
- }
-}
-
-class TestOfSpl extends UnitTestCase {
-
- function skip() {
- $this->skipUnless(function_exists('spl_classes'), 'No SPL module loaded');
- }
-
- function testCanMockAllSplClasses() {
- if (! function_exists('spl_classes')) {
- return;
- }
- foreach(spl_classes() as $class) {
- if ($class == 'SplHeap' or $class = 'SplFileObject') {
- continue;
- }
- if (version_compare(PHP_VERSION, '5.1', '<') &&
- $class == 'CachingIterator' ||
- $class == 'CachingRecursiveIterator' ||
- $class == 'FilterIterator' ||
- $class == 'LimitIterator' ||
- $class == 'ParentIterator') {
- // These iterators require an iterator be passed to them during
- // construction in PHP 5.0; there is no way for SimpleTest
- // to supply such an iterator, however, so support for it is
- // disabled.
- continue;
- }
- $mock_class = "Mock$class";
- Mock::generate($class);
- $this->assertIsA(new $mock_class(), $mock_class);
- }
- }
-
- function testExtensionOfCommonSplClasses() {
- Mock::generate('IteratorImplementation');
- $this->assertIsA(
- new IteratorImplementation(),
- 'IteratorImplementation');
- Mock::generate('IteratorAggregateImplementation');
- $this->assertIsA(
- new IteratorAggregateImplementation(),
- 'IteratorAggregateImplementation');
- }
-}
-
-class WithHint {
- function hinted(DummyInterface $object) { }
-}
-
-class ImplementsDummy implements DummyInterface {
- function aMethod() { }
- function anotherMethod($a) { }
- function &referenceMethod(&$a) { }
- function extraMethod($a = false) { }
-}
-Mock::generate('ImplementsDummy');
-
-class TestOfImplementations extends UnitTestCase {
-
- function testMockedInterfaceCanPassThroughTypeHint() {
- $mock = new MockDummyInterface();
- $hinter = new WithHint();
- $hinter->hinted($mock);
- }
-
- function testImplementedInterfacesAreCarried() {
- $mock = new MockImplementsDummy();
- $hinter = new WithHint();
- $hinter->hinted($mock);
- }
-
- function testNoSpuriousWarningsWhenSkippingDefaultedParameter() {
- $mock = new MockImplementsDummy();
- $mock->extraMethod();
- }
-}
-
-interface SampleInterfaceWithConstruct {
- function __construct($something);
-}
-
-class TestOfInterfaceMocksWithConstruct extends UnitTestCase {
- function TODO_testBasicConstructOfAnInterface() { // Fails in PHP 5.3dev
- Mock::generate('SampleInterfaceWithConstruct');
- }
-}
-
-interface SampleInterfaceWithClone {
- function __clone();
-}
-
-class TestOfSampleInterfaceWithClone extends UnitTestCase {
- function testCanMockWithoutErrors() {
- Mock::generate('SampleInterfaceWithClone');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/interfaces_test_php5_1.php b/core/vendors/simpletest/test/interfaces_test_php5_1.php
deleted file mode 100755
index 3d154f9..0000000
--- a/core/vendors/simpletest/test/interfaces_test_php5_1.php
+++ /dev/null
@@ -1,14 +0,0 @@
-assertIsA($mock, 'SampleInterfaceWithHintInSignature');
- }
-}
-
diff --git a/core/vendors/simpletest/test/live_test.php b/core/vendors/simpletest/test/live_test.php
deleted file mode 100755
index 3fbb544..0000000
--- a/core/vendors/simpletest/test/live_test.php
+++ /dev/null
@@ -1,47 +0,0 @@
-assertTrue($socket->isError());
- $this->assertPattern(
- '/Cannot open \\[bad_url:111\\] with \\[/',
- $socket->getError());
- $this->assertFalse($socket->isOpen());
- $this->assertFalse($socket->write('A message'));
- }
-
- function testSocketClosure() {
- $socket = new SimpleSocket('www.lastcraft.com', 80, 15, 8);
- $this->assertTrue($socket->isOpen());
- $this->assertTrue($socket->write("GET /test/network_confirm.php HTTP/1.0\r\n"));
- $socket->write("Host: www.lastcraft.com\r\n");
- $socket->write("Connection: close\r\n\r\n");
- $this->assertEqual($socket->read(), "HTTP/1.1");
- $socket->close();
- $this->assertIdentical($socket->read(), false);
- }
-
- function testRecordOfSentCharacters() {
- $socket = new SimpleSocket('www.lastcraft.com', 80, 15);
- $this->assertTrue($socket->write("GET /test/network_confirm.php HTTP/1.0\r\n"));
- $socket->write("Host: www.lastcraft.com\r\n");
- $socket->write("Connection: close\r\n\r\n");
- $socket->close();
- $this->assertEqual($socket->getSent(),
- "GET /test/network_confirm.php HTTP/1.0\r\n" .
- "Host: www.lastcraft.com\r\n" .
- "Connection: close\r\n\r\n");
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/mock_objects_test.php b/core/vendors/simpletest/test/mock_objects_test.php
deleted file mode 100755
index 7f31789..0000000
--- a/core/vendors/simpletest/test/mock_objects_test.php
+++ /dev/null
@@ -1,985 +0,0 @@
-assertTrue($expectation->test(33));
- $this->assertTrue($expectation->test(false));
- $this->assertTrue($expectation->test(null));
- }
-}
-
-class TestOfParametersExpectation extends UnitTestCase {
-
- function testEmptyMatch() {
- $expectation = new ParametersExpectation(array());
- $this->assertTrue($expectation->test(array()));
- $this->assertFalse($expectation->test(array(33)));
- }
-
- function testSingleMatch() {
- $expectation = new ParametersExpectation(array(0));
- $this->assertFalse($expectation->test(array(1)));
- $this->assertTrue($expectation->test(array(0)));
- }
-
- function testAnyMatch() {
- $expectation = new ParametersExpectation(false);
- $this->assertTrue($expectation->test(array()));
- $this->assertTrue($expectation->test(array(1, 2)));
- }
-
- function testMissingParameter() {
- $expectation = new ParametersExpectation(array(0));
- $this->assertFalse($expectation->test(array()));
- }
-
- function testNullParameter() {
- $expectation = new ParametersExpectation(array(null));
- $this->assertTrue($expectation->test(array(null)));
- $this->assertFalse($expectation->test(array()));
- }
-
- function testAnythingExpectations() {
- $expectation = new ParametersExpectation(array(new AnythingExpectation()));
- $this->assertFalse($expectation->test(array()));
- $this->assertIdentical($expectation->test(array(null)), true);
- $this->assertIdentical($expectation->test(array(13)), true);
- }
-
- function testOtherExpectations() {
- $expectation = new ParametersExpectation(
- array(new PatternExpectation('/hello/i')));
- $this->assertFalse($expectation->test(array('Goodbye')));
- $this->assertTrue($expectation->test(array('hello')));
- $this->assertTrue($expectation->test(array('Hello')));
- }
-
- function testIdentityOnly() {
- $expectation = new ParametersExpectation(array("0"));
- $this->assertFalse($expectation->test(array(0)));
- $this->assertTrue($expectation->test(array("0")));
- }
-
- function testLongList() {
- $expectation = new ParametersExpectation(
- array("0", 0, new AnythingExpectation(), false));
- $this->assertTrue($expectation->test(array("0", 0, 37, false)));
- $this->assertFalse($expectation->test(array("0", 0, 37, true)));
- $this->assertFalse($expectation->test(array("0", 0, 37)));
- }
-}
-
-class TestOfSimpleSignatureMap extends UnitTestCase {
-
- function testEmpty() {
- $map = new SimpleSignatureMap();
- $this->assertFalse($map->isMatch("any", array()));
- $this->assertNull($map->findFirstAction("any", array()));
- }
-
- function testDifferentCallSignaturesCanHaveDifferentReferences() {
- $map = new SimpleSignatureMap();
- $fred = 'Fred';
- $jim = 'jim';
- $map->add(array(0), $fred);
- $map->add(array('0'), $jim);
- $this->assertSame($fred, $map->findFirstAction(array(0)));
- $this->assertSame($jim, $map->findFirstAction(array('0')));
- }
-
- function testWildcard() {
- $fred = 'Fred';
- $map = new SimpleSignatureMap();
- $map->add(array(new AnythingExpectation(), 1, 3), $fred);
- $this->assertTrue($map->isMatch(array(2, 1, 3)));
- $this->assertSame($map->findFirstAction(array(2, 1, 3)), $fred);
- }
-
- function testAllWildcard() {
- $fred = 'Fred';
- $map = new SimpleSignatureMap();
- $this->assertFalse($map->isMatch(array(2, 1, 3)));
- $map->add('', $fred);
- $this->assertTrue($map->isMatch(array(2, 1, 3)));
- $this->assertSame($map->findFirstAction(array(2, 1, 3)), $fred);
- }
-
- function testOrdering() {
- $map = new SimpleSignatureMap();
- $map->add(array(1, 2), new SimpleByValue("1, 2"));
- $map->add(array(1, 3), new SimpleByValue("1, 3"));
- $map->add(array(1), new SimpleByValue("1"));
- $map->add(array(1, 4), new SimpleByValue("1, 4"));
- $map->add(array(new AnythingExpectation()), new SimpleByValue("Any"));
- $map->add(array(2), new SimpleByValue("2"));
- $map->add("", new SimpleByValue("Default"));
- $map->add(array(), new SimpleByValue("None"));
- $this->assertEqual($map->findFirstAction(array(1, 2)), new SimpleByValue("1, 2"));
- $this->assertEqual($map->findFirstAction(array(1, 3)), new SimpleByValue("1, 3"));
- $this->assertEqual($map->findFirstAction(array(1, 4)), new SimpleByValue("1, 4"));
- $this->assertEqual($map->findFirstAction(array(1)), new SimpleByValue("1"));
- $this->assertEqual($map->findFirstAction(array(2)), new SimpleByValue("Any"));
- $this->assertEqual($map->findFirstAction(array(3)), new SimpleByValue("Any"));
- $this->assertEqual($map->findFirstAction(array()), new SimpleByValue("Default"));
- }
-}
-
-class TestOfCallSchedule extends UnitTestCase {
- function testCanBeSetToAlwaysReturnTheSameReference() {
- $a = 5;
- $schedule = new SimpleCallSchedule();
- $schedule->register('aMethod', false, new SimpleByReference($a));
- $this->assertReference($schedule->respond(0, 'aMethod', array()), $a);
- $this->assertReference($schedule->respond(1, 'aMethod', array()), $a);
- }
-
- function testSpecificSignaturesOverrideTheAlwaysCase() {
- $any = 'any';
- $one = 'two';
- $schedule = new SimpleCallSchedule();
- $schedule->register('aMethod', array(1), new SimpleByReference($one));
- $schedule->register('aMethod', false, new SimpleByReference($any));
- $this->assertReference($schedule->respond(0, 'aMethod', array(2)), $any);
- $this->assertReference($schedule->respond(0, 'aMethod', array(1)), $one);
- }
-
- function testReturnsCanBeSetOverTime() {
- $one = 'one';
- $two = 'two';
- $schedule = new SimpleCallSchedule();
- $schedule->registerAt(0, 'aMethod', false, new SimpleByReference($one));
- $schedule->registerAt(1, 'aMethod', false, new SimpleByReference($two));
- $this->assertReference($schedule->respond(0, 'aMethod', array()), $one);
- $this->assertReference($schedule->respond(1, 'aMethod', array()), $two);
- }
-
- function testReturnsOverTimecanBeAlteredByTheArguments() {
- $one = '1';
- $two = '2';
- $two_a = '2a';
- $schedule = new SimpleCallSchedule();
- $schedule->registerAt(0, 'aMethod', false, new SimpleByReference($one));
- $schedule->registerAt(1, 'aMethod', array('a'), new SimpleByReference($two_a));
- $schedule->registerAt(1, 'aMethod', false, new SimpleByReference($two));
- $this->assertReference($schedule->respond(0, 'aMethod', array()), $one);
- $this->assertReference($schedule->respond(1, 'aMethod', array()), $two);
- $this->assertReference($schedule->respond(1, 'aMethod', array('a')), $two_a);
- }
-
- function testCanReturnByValue() {
- $a = 5;
- $schedule = new SimpleCallSchedule();
- $schedule->register('aMethod', false, new SimpleByValue($a));
- $this->assertCopy($schedule->respond(0, 'aMethod', array()), $a);
- }
-
- function testCanThrowException() {
- if (version_compare(phpversion(), '5', '>=')) {
- $schedule = new SimpleCallSchedule();
- $schedule->register('aMethod', false, new SimpleThrower(new Exception('Ouch')));
- $this->expectException(new Exception('Ouch'));
- $schedule->respond(0, 'aMethod', array());
- }
- }
-
- function testCanEmitError() {
- $schedule = new SimpleCallSchedule();
- $schedule->register('aMethod', false, new SimpleErrorThrower('Ouch', E_USER_WARNING));
- $this->expectError('Ouch');
- $schedule->respond(0, 'aMethod', array());
- }
-}
-
-class Dummy {
- function Dummy() {
- }
-
- function aMethod() {
- return true;
- }
-
- function &aReferenceMethod() {
- return true;
- }
-
- function anotherMethod() {
- return true;
- }
-}
-Mock::generate('Dummy');
-Mock::generate('Dummy', 'AnotherMockDummy');
-Mock::generate('Dummy', 'MockDummyWithExtraMethods', array('extraMethod'));
-
-class TestOfMockGeneration extends UnitTestCase {
-
- function testCloning() {
- $mock = new MockDummy();
- $this->assertTrue(method_exists($mock, "aMethod"));
- $this->assertNull($mock->aMethod());
- }
-
- function testCloningWithExtraMethod() {
- $mock = new MockDummyWithExtraMethods();
- $this->assertTrue(method_exists($mock, "extraMethod"));
- }
-
- function testCloningWithChosenClassName() {
- $mock = new AnotherMockDummy();
- $this->assertTrue(method_exists($mock, "aMethod"));
- }
-}
-
-class TestOfMockReturns extends UnitTestCase {
-
- function testDefaultReturn() {
- $mock = new MockDummy();
- $mock->returnsByValue("aMethod", "aaa");
- $this->assertIdentical($mock->aMethod(), "aaa");
- $this->assertIdentical($mock->aMethod(), "aaa");
- }
-
- function testParameteredReturn() {
- $mock = new MockDummy();
- $mock->returnsByValue('aMethod', 'aaa', array(1, 2, 3));
- $this->assertNull($mock->aMethod());
- $this->assertIdentical($mock->aMethod(1, 2, 3), 'aaa');
- }
-
- function testSetReturnGivesObjectReference() {
- $mock = new MockDummy();
- $object = new Dummy();
- $mock->returns('aMethod', $object, array(1, 2, 3));
- $this->assertSame($mock->aMethod(1, 2, 3), $object);
- }
-
- function testSetReturnReferenceGivesOriginalReference() {
- $mock = new MockDummy();
- $object = 1;
- $mock->returnsByReference('aReferenceMethod', $object, array(1, 2, 3));
- $this->assertReference($mock->aReferenceMethod(1, 2, 3), $object);
- }
-
- function testReturnValueCanBeChosenJustByPatternMatchingArguments() {
- $mock = new MockDummy();
- $mock->returnsByValue(
- "aMethod",
- "aaa",
- array(new PatternExpectation('/hello/i')));
- $this->assertIdentical($mock->aMethod('Hello'), 'aaa');
- $this->assertNull($mock->aMethod('Goodbye'));
- }
-
- function testMultipleMethods() {
- $mock = new MockDummy();
- $mock->returnsByValue("aMethod", 100, array(1));
- $mock->returnsByValue("aMethod", 200, array(2));
- $mock->returnsByValue("anotherMethod", 10, array(1));
- $mock->returnsByValue("anotherMethod", 20, array(2));
- $this->assertIdentical($mock->aMethod(1), 100);
- $this->assertIdentical($mock->anotherMethod(1), 10);
- $this->assertIdentical($mock->aMethod(2), 200);
- $this->assertIdentical($mock->anotherMethod(2), 20);
- }
-
- function testReturnSequence() {
- $mock = new MockDummy();
- $mock->returnsByValueAt(0, "aMethod", "aaa");
- $mock->returnsByValueAt(1, "aMethod", "bbb");
- $mock->returnsByValueAt(3, "aMethod", "ddd");
- $this->assertIdentical($mock->aMethod(), "aaa");
- $this->assertIdentical($mock->aMethod(), "bbb");
- $this->assertNull($mock->aMethod());
- $this->assertIdentical($mock->aMethod(), "ddd");
- }
-
- function testSetReturnReferenceAtGivesOriginal() {
- $mock = new MockDummy();
- $object = 100;
- $mock->returnsByReferenceAt(1, "aReferenceMethod", $object);
- $this->assertNull($mock->aReferenceMethod());
- $this->assertReference($mock->aReferenceMethod(), $object);
- $this->assertNull($mock->aReferenceMethod());
- }
-
- function testReturnsAtGivesOriginalObjectHandle() {
- $mock = new MockDummy();
- $object = new Dummy();
- $mock->returnsAt(1, "aMethod", $object);
- $this->assertNull($mock->aMethod());
- $this->assertSame($mock->aMethod(), $object);
- $this->assertNull($mock->aMethod());
- }
-
- function testComplicatedReturnSequence() {
- $mock = new MockDummy();
- $object = new Dummy();
- $mock->returnsAt(1, "aMethod", "aaa", array("a"));
- $mock->returnsAt(1, "aMethod", "bbb");
- $mock->returnsAt(2, "aMethod", $object, array('*', 2));
- $mock->returnsAt(2, "aMethod", "value", array('*', 3));
- $mock->returns("aMethod", 3, array(3));
- $this->assertNull($mock->aMethod());
- $this->assertEqual($mock->aMethod("a"), "aaa");
- $this->assertSame($mock->aMethod(1, 2), $object);
- $this->assertEqual($mock->aMethod(3), 3);
- $this->assertNull($mock->aMethod());
- }
-
- function testMultipleMethodSequences() {
- $mock = new MockDummy();
- $mock->returnsByValueAt(0, "aMethod", "aaa");
- $mock->returnsByValueAt(1, "aMethod", "bbb");
- $mock->returnsByValueAt(0, "anotherMethod", "ccc");
- $mock->returnsByValueAt(1, "anotherMethod", "ddd");
- $this->assertIdentical($mock->aMethod(), "aaa");
- $this->assertIdentical($mock->anotherMethod(), "ccc");
- $this->assertIdentical($mock->aMethod(), "bbb");
- $this->assertIdentical($mock->anotherMethod(), "ddd");
- }
-
- function testSequenceFallback() {
- $mock = new MockDummy();
- $mock->returnsByValueAt(0, "aMethod", "aaa", array('a'));
- $mock->returnsByValueAt(1, "aMethod", "bbb", array('a'));
- $mock->returnsByValue("aMethod", "AAA");
- $this->assertIdentical($mock->aMethod('a'), "aaa");
- $this->assertIdentical($mock->aMethod('b'), "AAA");
- }
-
- function testMethodInterference() {
- $mock = new MockDummy();
- $mock->returnsByValueAt(0, "anotherMethod", "aaa");
- $mock->returnsByValue("aMethod", "AAA");
- $this->assertIdentical($mock->aMethod(), "AAA");
- $this->assertIdentical($mock->anotherMethod(), "aaa");
- }
-}
-
-class TestOfMockExpectationsThatPass extends UnitTestCase {
-
- function testAnyArgument() {
- $mock = new MockDummy();
- $mock->expect('aMethod', array('*'));
- $mock->aMethod(1);
- $mock->aMethod('hello');
- }
-
- function testAnyTwoArguments() {
- $mock = new MockDummy();
- $mock->expect('aMethod', array('*', '*'));
- $mock->aMethod(1, 2);
- }
-
- function testSpecificArgument() {
- $mock = new MockDummy();
- $mock->expect('aMethod', array(1));
- $mock->aMethod(1);
- }
-
- function testExpectation() {
- $mock = new MockDummy();
- $mock->expect('aMethod', array(new IsAExpectation('Dummy')));
- $mock->aMethod(new Dummy());
- }
-
- function testArgumentsInSequence() {
- $mock = new MockDummy();
- $mock->expectAt(0, 'aMethod', array(1, 2));
- $mock->expectAt(1, 'aMethod', array(3, 4));
- $mock->aMethod(1, 2);
- $mock->aMethod(3, 4);
- }
-
- function testAtLeastOnceSatisfiedByOneCall() {
- $mock = new MockDummy();
- $mock->expectAtLeastOnce('aMethod');
- $mock->aMethod();
- }
-
- function testAtLeastOnceSatisfiedByTwoCalls() {
- $mock = new MockDummy();
- $mock->expectAtLeastOnce('aMethod');
- $mock->aMethod();
- $mock->aMethod();
- }
-
- function testOnceSatisfiedByOneCall() {
- $mock = new MockDummy();
- $mock->expectOnce('aMethod');
- $mock->aMethod();
- }
-
- function testMinimumCallsSatisfiedByEnoughCalls() {
- $mock = new MockDummy();
- $mock->expectMinimumCallCount('aMethod', 1);
- $mock->aMethod();
- }
-
- function testMinimumCallsSatisfiedByTooManyCalls() {
- $mock = new MockDummy();
- $mock->expectMinimumCallCount('aMethod', 3);
- $mock->aMethod();
- $mock->aMethod();
- $mock->aMethod();
- $mock->aMethod();
- }
-
- function testMaximumCallsSatisfiedByEnoughCalls() {
- $mock = new MockDummy();
- $mock->expectMaximumCallCount('aMethod', 1);
- $mock->aMethod();
- }
-
- function testMaximumCallsSatisfiedByNoCalls() {
- $mock = new MockDummy();
- $mock->expectMaximumCallCount('aMethod', 1);
- }
-}
-
-class MockWithInjectedTestCase extends SimpleMock {
- protected function getCurrentTestCase() {
- return SimpleTest::getContext()->getTest()->getMockedTest();
- }
-}
-SimpleTest::setMockBaseClass('MockWithInjectedTestCase');
-Mock::generate('Dummy', 'MockDummyWithInjectedTestCase');
-SimpleTest::setMockBaseClass('SimpleMock');
-Mock::generate('SimpleTestCase');
-
-class LikeExpectation extends IdenticalExpectation {
- function __construct($expectation) {
- $expectation->message = '';
- parent::__construct($expectation);
- }
-
- function test($compare) {
- $compare->message = '';
- return parent::test($compare);
- }
-
- function testMessage($compare) {
- $compare->message = '';
- return parent::testMessage($compare);
- }
-}
-
-class TestOfMockExpectations extends UnitTestCase {
- private $test;
-
- function setUp() {
- $this->test = new MockSimpleTestCase();
- }
-
- function getMockedTest() {
- return $this->test;
- }
-
- function testSettingExpectationOnNonMethodThrowsError() {
- $mock = new MockDummyWithInjectedTestCase();
- $this->expectError();
- $mock->expectMaximumCallCount('aMissingMethod', 2);
- }
-
- function testMaxCallsDetectsOverrun() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 2), 3));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectMaximumCallCount('aMethod', 2);
- $mock->aMethod();
- $mock->aMethod();
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testTallyOnMaxCallsSendsPassOnUnderrun() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 2), 2));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectMaximumCallCount("aMethod", 2);
- $mock->aMethod();
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testExpectNeverDetectsOverrun() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 0), 1));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectNever('aMethod');
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testTallyOnExpectNeverStillSendsPassOnUnderrun() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 0), 0));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectNever('aMethod');
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testMinCalls() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 2), 2));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectMinimumCallCount('aMethod', 2);
- $mock->aMethod();
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testFailedNever() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 0), 1));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectNever('aMethod');
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testUnderOnce() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 1), 0));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectOnce('aMethod');
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testOverOnce() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 1), 2));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectOnce('aMethod');
- $mock->aMethod();
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testUnderAtLeastOnce() {
- $this->test->expectOnce('assert', array(new MemberExpectation('count', 1), 0));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectAtLeastOnce("aMethod");
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testZeroArguments() {
- $this->test->expectOnce('assert',
- array(new MemberExpectation('expected', array()), array(), '*'));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expect('aMethod', array());
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testExpectedArguments() {
- $this->test->expectOnce('assert',
- array(new MemberExpectation('expected', array(1, 2, 3)), array(1, 2, 3), '*'));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expect('aMethod', array(1, 2, 3));
- $mock->aMethod(1, 2, 3);
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testFailedArguments() {
- $this->test->expectOnce('assert',
- array(new MemberExpectation('expected', array('this')), array('that'), '*'));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expect('aMethod', array('this'));
- $mock->aMethod('that');
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testWildcardsAreTranslatedToAnythingExpectations() {
- $this->test->expectOnce('assert',
- array(new MemberExpectation('expected',
- array(new AnythingExpectation(),
- 123,
- new AnythingExpectation())),
- array(100, 123, 101), '*'));
- $mock = new MockDummyWithInjectedTestCase($this);
- $mock->expect("aMethod", array('*', 123, '*'));
- $mock->aMethod(100, 123, 101);
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testSpecificPassingSequence() {
- $this->test->expectAt(0, 'assert',
- array(new MemberExpectation('expected', array(1, 2, 3)), array(1, 2, 3), '*'));
- $this->test->expectAt(1, 'assert',
- array(new MemberExpectation('expected', array('Hello')), array('Hello'), '*'));
- $mock = new MockDummyWithInjectedTestCase();
- $mock->expectAt(1, 'aMethod', array(1, 2, 3));
- $mock->expectAt(2, 'aMethod', array('Hello'));
- $mock->aMethod();
- $mock->aMethod(1, 2, 3);
- $mock->aMethod('Hello');
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-
- function testNonArrayForExpectedParametersGivesError() {
- $mock = new MockDummyWithInjectedTestCase();
- $this->expectError(new PatternExpectation('/\$args.*not an array/i'));
- $mock->expect("aMethod", "foo");
- $mock->aMethod();
- $mock->mock->atTestEnd('testSomething', $this->test);
- }
-}
-
-class TestOfMockComparisons extends UnitTestCase {
-
- function testEqualComparisonOfMocksDoesNotCrash() {
- $expectation = new EqualExpectation(new MockDummy());
- $this->assertTrue($expectation->test(new MockDummy(), true));
- }
-
- function testIdenticalComparisonOfMocksDoesNotCrash() {
- $expectation = new IdenticalExpectation(new MockDummy());
- $this->assertTrue($expectation->test(new MockDummy()));
- }
-}
-
-class ClassWithSpecialMethods {
- function __get($name) { }
- function __set($name, $value) { }
- function __isset($name) { }
- function __unset($name) { }
- function __call($method, $arguments) { }
- function __toString() { }
-}
-Mock::generate('ClassWithSpecialMethods');
-
-class TestOfSpecialMethodsAfterPHP51 extends UnitTestCase {
-
- function skip() {
- $this->skipIf(version_compare(phpversion(), '5.1', '<'), '__isset and __unset overloading not tested unless PHP 5.1+');
- }
-
- function testCanEmulateIsset() {
- $mock = new MockClassWithSpecialMethods();
- $mock->returnsByValue('__isset', true);
- $this->assertIdentical(isset($mock->a), true);
- }
-
- function testCanExpectUnset() {
- $mock = new MockClassWithSpecialMethods();
- $mock->expectOnce('__unset', array('a'));
- unset($mock->a);
- }
-
-}
-
-class TestOfSpecialMethods extends UnitTestCase {
- function skip() {
- $this->skipIf(version_compare(phpversion(), '5', '<'), 'Overloading not tested unless PHP 5+');
- }
-
- function testCanMockTheThingAtAll() {
- $mock = new MockClassWithSpecialMethods();
- }
-
- function testReturnFromSpecialAccessor() {
- $mock = new MockClassWithSpecialMethods();
- $mock->returnsByValue('__get', '1st Return', array('first'));
- $mock->returnsByValue('__get', '2nd Return', array('second'));
- $this->assertEqual($mock->first, '1st Return');
- $this->assertEqual($mock->second, '2nd Return');
- }
-
- function testcanExpectTheSettingOfValue() {
- $mock = new MockClassWithSpecialMethods();
- $mock->expectOnce('__set', array('a', 'A'));
- $mock->a = 'A';
- }
-
- function testCanSimulateAnOverloadmethod() {
- $mock = new MockClassWithSpecialMethods();
- $mock->expectOnce('__call', array('amOverloaded', array('A')));
- $mock->returnsByValue('__call', 'aaa');
- $this->assertIdentical($mock->amOverloaded('A'), 'aaa');
- }
-
- function testToStringMagic() {
- $mock = new MockClassWithSpecialMethods();
- $mock->expectOnce('__toString');
- $mock->returnsByValue('__toString', 'AAA');
- ob_start();
- print $mock;
- $output = ob_get_contents();
- ob_end_clean();
- $this->assertEqual($output, 'AAA');
- }
-}
-
-class WithStaticMethod {
- static function aStaticMethod() { }
-}
-Mock::generate('WithStaticMethod');
-
-class TestOfMockingClassesWithStaticMethods extends UnitTestCase {
-
- function testStaticMethodIsMockedAsStatic() {
- $mock = new WithStaticMethod();
- $reflection = new ReflectionClass($mock);
- $method = $reflection->getMethod('aStaticMethod');
- $this->assertTrue($method->isStatic());
- }
-}
-
-class MockTestException extends Exception { }
-
-class TestOfThrowingExceptionsFromMocks extends UnitTestCase {
-
- function testCanThrowOnMethodCall() {
- $mock = new MockDummy();
- $mock->throwOn('aMethod');
- $this->expectException();
- $mock->aMethod();
- }
-
- function testCanThrowSpecificExceptionOnMethodCall() {
- $mock = new MockDummy();
- $mock->throwOn('aMethod', new MockTestException());
- $this->expectException();
- $mock->aMethod();
- }
-
- function testThrowsOnlyWhenCallSignatureMatches() {
- $mock = new MockDummy();
- $mock->throwOn('aMethod', new MockTestException(), array(3));
- $mock->aMethod(1);
- $mock->aMethod(2);
- $this->expectException();
- $mock->aMethod(3);
- }
-
- function testCanThrowOnParticularInvocation() {
- $mock = new MockDummy();
- $mock->throwAt(2, 'aMethod', new MockTestException());
- $mock->aMethod();
- $mock->aMethod();
- $this->expectException();
- $mock->aMethod();
- }
-}
-
-class TestOfThrowingErrorsFromMocks extends UnitTestCase {
-
- function testCanGenerateErrorFromMethodCall() {
- $mock = new MockDummy();
- $mock->errorOn('aMethod', 'Ouch!');
- $this->expectError('Ouch!');
- $mock->aMethod();
- }
-
- function testGeneratesErrorOnlyWhenCallSignatureMatches() {
- $mock = new MockDummy();
- $mock->errorOn('aMethod', 'Ouch!', array(3));
- $mock->aMethod(1);
- $mock->aMethod(2);
- $this->expectError();
- $mock->aMethod(3);
- }
-
- function testCanGenerateErrorOnParticularInvocation() {
- $mock = new MockDummy();
- $mock->errorAt(2, 'aMethod', 'Ouch!');
- $mock->aMethod();
- $mock->aMethod();
- $this->expectError();
- $mock->aMethod();
- }
-}
-
-Mock::generatePartial('Dummy', 'TestDummy', array('anotherMethod', 'aReferenceMethod'));
-
-class TestOfPartialMocks extends UnitTestCase {
-
- function testMethodReplacementWithNoBehaviourReturnsNull() {
- $mock = new TestDummy();
- $this->assertEqual($mock->aMethod(99), 99);
- $this->assertNull($mock->anotherMethod());
- }
-
- function testSettingReturns() {
- $mock = new TestDummy();
- $mock->returnsByValue('anotherMethod', 33, array(3));
- $mock->returnsByValue('anotherMethod', 22);
- $mock->returnsByValueAt(2, 'anotherMethod', 44, array(3));
- $this->assertEqual($mock->anotherMethod(), 22);
- $this->assertEqual($mock->anotherMethod(3), 33);
- $this->assertEqual($mock->anotherMethod(3), 44);
- }
-
- function testSetReturnReferenceGivesOriginal() {
- $mock = new TestDummy();
- $object = 99;
- $mock->returnsByReferenceAt(0, 'aReferenceMethod', $object, array(3));
- $this->assertReference($mock->aReferenceMethod(3), $object);
- }
-
- function testReturnsAtGivesOriginalObjectHandle() {
- $mock = new TestDummy();
- $object = new Dummy();
- $mock->returnsAt(0, 'anotherMethod', $object, array(3));
- $this->assertSame($mock->anotherMethod(3), $object);
- }
-
- function testExpectations() {
- $mock = new TestDummy();
- $mock->expectCallCount('anotherMethod', 2);
- $mock->expect('anotherMethod', array(77));
- $mock->expectAt(1, 'anotherMethod', array(66));
- $mock->anotherMethod(77);
- $mock->anotherMethod(66);
- }
-
- function testSettingExpectationOnMissingMethodThrowsError() {
- $mock = new TestDummy();
- $this->expectError();
- $mock->expectCallCount('aMissingMethod', 2);
- }
-}
-
-class ConstructorSuperClass {
- function ConstructorSuperClass() { }
-}
-
-class ConstructorSubClass extends ConstructorSuperClass { }
-
-class TestOfPHP4StyleSuperClassConstruct extends UnitTestCase {
- function testBasicConstruct() {
- Mock::generate('ConstructorSubClass');
- $mock = new MockConstructorSubClass();
- $this->assertIsA($mock, 'ConstructorSubClass');
- $this->assertTrue(method_exists($mock, 'ConstructorSuperClass'));
- }
-}
-
-class TestOfPHP5StaticMethodMocking extends UnitTestCase {
- function testCanCreateAMockObjectWithStaticMethodsWithoutError() {
- eval('
- class SimpleObjectContainingStaticMethod {
- static function someStatic() { }
- }
- ');
- Mock::generate('SimpleObjectContainingStaticMethod');
- }
-}
-
-class TestOfPHP5AbstractMethodMocking extends UnitTestCase {
- function testCanCreateAMockObjectFromAnAbstractWithProperFunctionDeclarations() {
- eval('
- abstract class SimpleAbstractClassContainingAbstractMethods {
- abstract function anAbstract();
- abstract function anAbstractWithParameter($foo);
- abstract function anAbstractWithMultipleParameters($foo, $bar);
- }
- ');
- Mock::generate('SimpleAbstractClassContainingAbstractMethods');
- $this->assertTrue(
- method_exists(
- // Testing with class name alone does not work in PHP 5.0
- new MockSimpleAbstractClassContainingAbstractMethods,
- 'anAbstract'
- )
- );
- $this->assertTrue(
- method_exists(
- new MockSimpleAbstractClassContainingAbstractMethods,
- 'anAbstractWithParameter'
- )
- );
- $this->assertTrue(
- method_exists(
- new MockSimpleAbstractClassContainingAbstractMethods,
- 'anAbstractWithMultipleParameters'
- )
- );
- }
-
- function testMethodsDefinedAsAbstractInParentShouldHaveFullSignature() {
- eval('
- abstract class SimpleParentAbstractClassContainingAbstractMethods {
- abstract function anAbstract();
- abstract function anAbstractWithParameter($foo);
- abstract function anAbstractWithMultipleParameters($foo, $bar);
- }
-
- class SimpleChildAbstractClassContainingAbstractMethods extends SimpleParentAbstractClassContainingAbstractMethods {
- function anAbstract(){}
- function anAbstractWithParameter($foo){}
- function anAbstractWithMultipleParameters($foo, $bar){}
- }
-
- class EvenDeeperEmptyChildClass extends SimpleChildAbstractClassContainingAbstractMethods {}
- ');
- Mock::generate('SimpleChildAbstractClassContainingAbstractMethods');
- $this->assertTrue(
- method_exists(
- new MockSimpleChildAbstractClassContainingAbstractMethods,
- 'anAbstract'
- )
- );
- $this->assertTrue(
- method_exists(
- new MockSimpleChildAbstractClassContainingAbstractMethods,
- 'anAbstractWithParameter'
- )
- );
- $this->assertTrue(
- method_exists(
- new MockSimpleChildAbstractClassContainingAbstractMethods,
- 'anAbstractWithMultipleParameters'
- )
- );
- Mock::generate('EvenDeeperEmptyChildClass');
- $this->assertTrue(
- method_exists(
- new MockEvenDeeperEmptyChildClass,
- 'anAbstract'
- )
- );
- $this->assertTrue(
- method_exists(
- new MockEvenDeeperEmptyChildClass,
- 'anAbstractWithParameter'
- )
- );
- $this->assertTrue(
- method_exists(
- new MockEvenDeeperEmptyChildClass,
- 'anAbstractWithMultipleParameters'
- )
- );
- }
-}
-
-class DummyWithProtected
-{
- public function aMethodCallsProtected() { return $this->aProtectedMethod(); }
- protected function aProtectedMethod() { return true; }
-}
-
-Mock::generatePartial('DummyWithProtected', 'TestDummyWithProtected', array('aProtectedMethod'));
-class TestOfProtectedMethodPartialMocks extends UnitTestCase
-{
- function testProtectedMethodExists() {
- $this->assertTrue(
- method_exists(
- new TestDummyWithProtected,
- 'aProtectedMethod'
- )
- );
- }
-
- function testProtectedMethodIsCalled() {
- $object = new DummyWithProtected();
- $this->assertTrue($object->aMethodCallsProtected(), 'ensure original was called');
- }
-
- function testMockedMethodIsCalled() {
- $object = new TestDummyWithProtected();
- $object->returnsByValue('aProtectedMethod', false);
- $this->assertFalse($object->aMethodCallsProtected());
- }
-}
-
-?>
diff --git a/core/vendors/simpletest/test/page_test.php b/core/vendors/simpletest/test/page_test.php
deleted file mode 100755
index fdc15c5..0000000
--- a/core/vendors/simpletest/test/page_test.php
+++ /dev/null
@@ -1,166 +0,0 @@
-assertEqual($page->getTransportError(), 'No page fetched yet');
- $this->assertIdentical($page->getRaw(), false);
- $this->assertIdentical($page->getHeaders(), false);
- $this->assertIdentical($page->getMimeType(), false);
- $this->assertIdentical($page->getResponseCode(), false);
- $this->assertIdentical($page->getAuthentication(), false);
- $this->assertIdentical($page->getRealm(), false);
- $this->assertFalse($page->hasFrames());
- $this->assertIdentical($page->getUrls(), array());
- $this->assertIdentical($page->getTitle(), false);
- }
-}
-
-class TestOfPageHeaders extends UnitTestCase {
-
- function testUrlAccessor() {
- $headers = new MockSimpleHttpHeaders();
-
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getHeaders', $headers);
- $response->setReturnValue('getMethod', 'POST');
- $response->setReturnValue('getUrl', new SimpleUrl('here'));
- $response->setReturnValue('getRequestData', array('a' => 'A'));
-
- $page = new SimplePage($response);
- $this->assertEqual($page->getMethod(), 'POST');
- $this->assertEqual($page->getUrl(), new SimpleUrl('here'));
- $this->assertEqual($page->getRequestData(), array('a' => 'A'));
- }
-
- function testTransportError() {
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getError', 'Ouch');
-
- $page = new SimplePage($response);
- $this->assertEqual($page->getTransportError(), 'Ouch');
- }
-
- function testHeadersAccessor() {
- $headers = new MockSimpleHttpHeaders();
- $headers->setReturnValue('getRaw', 'My: Headers');
-
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getHeaders', $headers);
-
- $page = new SimplePage($response);
- $this->assertEqual($page->getHeaders(), 'My: Headers');
- }
-
- function testMimeAccessor() {
- $headers = new MockSimpleHttpHeaders();
- $headers->setReturnValue('getMimeType', 'text/html');
-
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getHeaders', $headers);
-
- $page = new SimplePage($response);
- $this->assertEqual($page->getMimeType(), 'text/html');
- }
-
- function testResponseAccessor() {
- $headers = new MockSimpleHttpHeaders();
- $headers->setReturnValue('getResponseCode', 301);
-
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getHeaders', $headers);
-
- $page = new SimplePage($response);
- $this->assertIdentical($page->getResponseCode(), 301);
- }
-
- function testAuthenticationAccessors() {
- $headers = new MockSimpleHttpHeaders();
- $headers->setReturnValue('getAuthentication', 'Basic');
- $headers->setReturnValue('getRealm', 'Secret stuff');
-
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getHeaders', $headers);
-
- $page = new SimplePage($response);
- $this->assertEqual($page->getAuthentication(), 'Basic');
- $this->assertEqual($page->getRealm(), 'Secret stuff');
- }
-}
-
-class TestOfHtmlStrippingAndNormalisation extends UnitTestCase {
-
- function testImageSuppressionWhileKeepingParagraphsAndAltText() {
- $this->assertEqual(
- SimplePage::normalise('some text
'),
- 'some text bar');
- }
-
- function testSpaceNormalisation() {
- $this->assertEqual(
- SimplePage::normalise("\nOne\tTwo \nThree\t"),
- 'One Two Three');
- }
-
- function testMultilinesCommentSuppression() {
- $this->assertEqual(
- SimplePage::normalise(''),
- '');
- }
-
- function testCommentSuppression() {
- $this->assertEqual(
- SimplePage::normalise(''),
- '');
- }
-
- function testJavascriptSuppression() {
- $this->assertEqual(
- SimplePage::normalise(''),
- '');
- $this->assertEqual(
- SimplePage::normalise(''),
- '');
- $this->assertEqual(
- SimplePage::normalise(''),
- '');
- }
-
- function testTagSuppression() {
- $this->assertEqual(
- SimplePage::normalise('Hello '),
- 'Hello');
- }
-
- function testAdjoiningTagSuppression() {
- $this->assertEqual(
- SimplePage::normalise('Hello Goodbye '),
- 'HelloGoodbye');
- }
-
- function testExtractImageAltTextWithDifferentQuotes() {
- $this->assertEqual(
- SimplePage::normalise(' '),
- 'One Two Three');
- }
-
- function testExtractImageAltTextMultipleTimes() {
- $this->assertEqual(
- SimplePage::normalise(' '),
- 'One Two Three');
- }
-
- function testHtmlEntityTranslation() {
- $this->assertEqual(
- SimplePage::normalise('<>"&''),
- '<>"&\'');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/parse_error_test.php b/core/vendors/simpletest/test/parse_error_test.php
deleted file mode 100755
index c3ffb3d..0000000
--- a/core/vendors/simpletest/test/parse_error_test.php
+++ /dev/null
@@ -1,9 +0,0 @@
-addFile('test_with_parse_error.php');
-$test->run(new HtmlReporter());
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/parsing_test.php b/core/vendors/simpletest/test/parsing_test.php
deleted file mode 100755
index 2c5e6ca..0000000
--- a/core/vendors/simpletest/test/parsing_test.php
+++ /dev/null
@@ -1,642 +0,0 @@
-whenVisiting('http://host/', 'Raw HTML');
- $this->assertEqual($page->getRaw(), 'Raw HTML');
- }
-
- function testTextAccessor() {
- $page = $this->whenVisiting('http://host/', 'Some "messy" HTML');
- $this->assertEqual($page->getText(), 'Some "messy" HTML');
- }
-
- function testFramesetAbsence() {
- $page = $this->whenVisiting('http://here/', '');
- $this->assertFalse($page->hasFrames());
- $this->assertIdentical($page->getFrameset(), false);
- }
-
- function testPageWithNoUrlsGivesEmptyArrayOfLinks() {
- $page = $this->whenVisiting('http://here/', 'Stuff
');
- $this->assertIdentical($page->getUrls(), array());
- }
-
- function testAddAbsoluteLink() {
- $page = $this->whenVisiting('http://host',
- 'Label ');
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://somewhere.com')));
- }
-
- function testUrlLabelsHaveHtmlTagsStripped() {
- $page = $this->whenVisiting('http://host',
- 'Label ');
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://somewhere.com')));
- }
-
- function testAddStrictRelativeLink() {
- $page = $this->whenVisiting('http://host',
- 'Label ');
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://host/somewhere.php')));
- }
-
- function testAddBareRelativeLink() {
- $page = $this->whenVisiting('http://host',
- 'Label ');
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://host/somewhere.php')));
- }
-
- function testAddRelativeLinkWithBaseTag() {
- $raw = ' ' .
- 'Label ' .
- '';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://www.lastcraft.com/stuff/somewhere.php')));
- }
-
- function testAddAbsoluteLinkWithBaseTag() {
- $raw = ' ' .
- 'Label ' .
- '';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://here.com/somewhere.php')));
- }
-
- function testCanFindLinkInsideForm() {
- $raw = 'Label ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://host/somewhere.php')));
- }
-
- function testCanGetLinksByIdOrLabel() {
- $raw = 'Label ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual(
- $page->getUrlsByLabel('Label'),
- array(new SimpleUrl('http://host/somewhere.php')));
- $this->assertFalse($page->getUrlById(0));
- $this->assertEqual(
- $page->getUrlById(33),
- new SimpleUrl('http://host/somewhere.php'));
- }
-
- function testCanFindLinkByNormalisedLabel() {
- $raw = 'Long & thin ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual(
- $page->getUrlsByLabel('Long & thin'),
- array(new SimpleUrl('http://host/somewhere.php')));
- }
-
- function testCanFindLinkByImageAltText() {
- $raw = ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual(
- array_map(array($this, 'urlToString'), $page->getUrlsByLabel('')),
- array('http://host/somewhere.php'));
- }
-
- function testTitle() {
- $page = $this->whenVisiting('http://host',
- 'Me ');
- $this->assertEqual($page->getTitle(), 'Me');
- }
-
- function testTitleWithEntityReference() {
- $page = $this->whenVisiting('http://host',
- 'Me&Me ');
- $this->assertEqual($page->getTitle(), "Me&Me");
- }
-
- function testOnlyFramesInFramesetAreRecognised() {
- $raw =
- '' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://here', $raw);
- $this->assertTrue($page->hasFrames());
- $this->assertSameFrameset($page->getFrameset(), array(
- 1 => new SimpleUrl('http://here/2.html'),
- 2 => new SimpleUrl('http://here/3.html')));
- }
-
- function testReadsNamesInFrames() {
- $raw =
- '' .
- ' ' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://here', $raw);
- $this->assertTrue($page->hasFrames());
- $this->assertSameFrameset($page->getFrameset(), array(
- 1 => new SimpleUrl('http://here/1.html'),
- 'A' => new SimpleUrl('http://here/2.html'),
- 'B' => new SimpleUrl('http://here/3.html'),
- 4 => new SimpleUrl('http://here/4.html')));
- }
-
- function testRelativeFramesRespectBaseTag() {
- $raw = ' ';
- $page = $this->whenVisiting('http://here', $raw);
- $this->assertSameFrameset(
- $page->getFrameset(),
- array(1 => new SimpleUrl('https://there.com/stuff/1.html')));
- }
-
- function testSingleFrameInNestedFrameset() {
- $raw = '' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->hasFrames());
- $this->assertIdentical(
- $page->getFrameset(),
- array(1 => new SimpleUrl('http://host/a.html')));
- }
-
- function testFramesCollectedWithNestedFramesetTags() {
- $raw = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->hasFrames());
- $this->assertIdentical($page->getFrameset(), array(
- 1 => new SimpleUrl('http://host/a.html'),
- 2 => new SimpleUrl('http://host/b.html'),
- 3 => new SimpleUrl('http://host/c.html')));
- }
-
- function testNamedFrames() {
- $raw = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->hasFrames());
- $this->assertIdentical($page->getFrameset(), array(
- 1 => new SimpleUrl('http://host/a.html'),
- '_one' => new SimpleUrl('http://host/b.html'),
- 3 => new SimpleUrl('http://host/c.html'),
- '_two' => new SimpleUrl('http://host/d.html')));
- }
-
- function testCanReadElementOfCompleteForm() {
- $raw = '' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('here')), "Hello");
- }
-
- function testCanReadElementOfUnclosedForm() {
- $raw = '' .
- ' ' .
- '';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('here')), "Hello");
- }
-
- function testCanReadElementByLabel() {
- $raw = ' ' .
- 'Where ' .
- '';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByLabel('Where')), "Hello");
- }
-
- function testCanFindFormByLabel() {
- $raw = ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertNull($page->getFormBySubmit(new SimpleByLabel('submit')));
- $this->assertNull($page->getFormBySubmit(new SimpleByName('submit')));
- $this->assertIsA(
- $page->getFormBySubmit(new SimpleByLabel('Submit')),
- 'SimpleForm');
- }
-
- function testConfirmSubmitAttributesAreCaseSensitive() {
- $raw = ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertIsA(
- $page->getFormBySubmit(new SimpleByName('S')),
- 'SimpleForm');
- $this->assertIsA(
- $page->getFormBySubmit(new SimpleByLabel('S')),
- 'SimpleForm');
- }
-
- function testCanFindFormByImage() {
- $raw = '' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertIsA(
- $page->getFormByImage(new SimpleByLabel('Label')),
- 'SimpleForm');
- $this->assertIsA(
- $page->getFormByImage(new SimpleByName('me')),
- 'SimpleForm');
- $this->assertIsA(
- $page->getFormByImage(new SimpleById(100)),
- 'SimpleForm');
- }
-
- function testCanFindFormByButtonTag() {
- $raw = '' .
- 'BBB ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertNull($page->getFormBySubmit(new SimpleByLabel('b')));
- $this->assertNull($page->getFormBySubmit(new SimpleByLabel('B')));
- $this->assertIsA(
- $page->getFormBySubmit(new SimpleByName('b')),
- 'SimpleForm');
- $this->assertIsA(
- $page->getFormBySubmit(new SimpleByLabel('BBB')),
- 'SimpleForm');
- }
-
- function testCanFindFormById() {
- $raw = ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertNull($page->getFormById(54));
- $this->assertIsA($page->getFormById(55), 'SimpleForm');
- }
-
- function testFormCanBeSubmitted() {
- $raw = '' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $form = $page->getFormBySubmit(new SimpleByLabel('Submit'));
- $this->assertEqual(
- $form->submitButton(new SimpleByLabel('Submit')),
- new SimpleGetEncoding(array('s' => 'Submit')));
- }
-
- function testUnparsedTagDoesNotCrash() {
- $raw = ' ';
- $this->whenVisiting('http://host', $raw);
- }
-
- function testReadingTextField() {
- $raw = '' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertNull($page->getField(new SimpleByName('missing')));
- $this->assertIdentical($page->getField(new SimpleByName('a')), '');
- $this->assertIdentical($page->getField(new SimpleByName('b')), 'bbb');
- }
-
- function testEntitiesAreDecodedInDefaultTextFieldValue() {
- $raw = ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), '&\'"<>');
- }
-
- function testReadingTextFieldIsCaseInsensitive() {
- $raw = '' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertNull($page->getField(new SimpleByName('missing')));
- $this->assertIdentical($page->getField(new SimpleByName('a')), '');
- $this->assertIdentical($page->getField(new SimpleByName('b')), 'bbb');
- }
-
- function testSettingTextField() {
- $raw = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->setField(new SimpleByName('a'), 'aaa'));
- $this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');
- $this->assertTrue($page->setField(new SimpleById(3), 'bbb'));
- $this->assertEqual($page->getField(new SimpleBYId(3)), 'bbb');
- $this->assertFalse($page->setField(new SimpleByName('z'), 'zzz'));
- $this->assertNull($page->getField(new SimpleByName('z')));
- }
-
- function testSettingTextFieldByEnclosingLabel() {
- $raw = '' .
- 'Stuff' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), 'A');
- $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
- $this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'aaa'));
- $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'aaa');
- }
-
- function testLabelsWithoutForDoNotAttachToInputsWithNoId() {
- $raw = '
- Text A
- Text B
- ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByLabelOrName('Text A')), 'one');
- $this->assertEqual($page->getField(new SimpleByLabelOrName('Text B')), 'two');
- $this->assertTrue($page->setField(new SimpleByLabelOrName('Text A'), '1'));
- $this->assertTrue($page->setField(new SimpleByLabelOrName('Text B'), '2'));
- $this->assertEqual($page->getField(new SimpleByLabelOrName('Text A')), '1');
- $this->assertEqual($page->getField(new SimpleByLabelOrName('Text B')), '2');
- }
-
- function testGettingTextFieldByEnclosingLabelWithConflictingOtherFields() {
- $raw = '' .
- 'Stuff' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), 'A');
- $this->assertEqual($page->getField(new SimpleByName('b')), 'B');
- $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
- }
-
- function testSettingTextFieldByExternalLabel() {
- $raw = '' .
- 'Stuff ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
- $this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'aaa'));
- $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'aaa');
- }
-
- function testReadingTextArea() {
- $raw = '' .
- 'aaa ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');
- }
-
- function testEntitiesAreDecodedInTextareaValue() {
- $raw = '&\'"<> ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), '&\'"<>');
- }
-
- function testNewlinesPreservedInTextArea() {
- $raw = "hello\r\nworld ";
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), "hello\r\nworld");
- }
-
- function testWhitespacePreservedInTextArea() {
- $raw = ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), ' ');
- }
-
- function testComplexWhitespaceInTextArea() {
- $raw = "\n" .
- " \n" .
- " \n" .
- " \n".
- " Text area C\n" .
- " \n" .
- " \n" .
- " \n" .
- " \n" .
- " \n" .
- "";
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('c')), " ");
- }
-
- function testSettingTextArea() {
- $raw = '' .
- 'aaa ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->setField(new SimpleByName('a'), 'AAA'));
- $this->assertEqual($page->getField(new SimpleByName('a')), 'AAA');
- }
-
- function testDontIncludeTextAreaContentInLabel() {
- $raw = 'Text area Cmouse ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByLabel('Text area C')), 'mouse');
- }
-
- function testSettingSelectionField() {
- $raw = '' .
- '' .
- 'aaa ' .
- 'bbb ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), 'bbb');
- $this->assertFalse($page->setField(new SimpleByName('a'), 'ccc'));
- $this->assertTrue($page->setField(new SimpleByName('a'), 'aaa'));
- $this->assertEqual($page->getField(new SimpleByName('a')), 'aaa');
- }
-
- function testSelectionOptionsAreNormalised() {
- $raw = '' .
- '' .
- 'Big bold ' .
- 'small italic ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('a')), 'Big bold');
- $this->assertTrue($page->setField(new SimpleByName('a'), 'small italic'));
- $this->assertEqual($page->getField(new SimpleByName('a')), 'small italic');
- }
-
- function testCanParseBlankOptions() {
- $raw = '
-
- D1
- D2
-
-
- ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->setField(new SimpleByName('d'), ''));
- }
-
- function testTwoSelectionFieldsAreIndependent() {
- $raw = '
-
- D1
- D2
-
-
- H1
- H2
-
- ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->setField(new SimpleByName('d'), 'd2'));
- $this->assertTrue($page->setField(new SimpleByName('h'), 'h1'));
- $this->assertEqual($page->getField(new SimpleByName('d')), 'd2');
- }
-
- function testEmptyOptionDoesNotScrewUpTwoSelectionFields() {
- $raw = '
-
- D1
- D2
-
-
-
- H1
- H2
-
- ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->setField(new SimpleByName('d'), 'd2'));
- $this->assertTrue($page->setField(new SimpleByName('h'), 'h1'));
- $this->assertEqual($page->getField(new SimpleByName('d')), 'd2');
- }
-
- function testSettingSelectionFieldByEnclosingLabel() {
- $raw = '' .
- 'Stuff' .
- 'A B ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'A');
- $this->assertTrue($page->setField(new SimpleByLabel('Stuff'), 'B'));
- $this->assertEqual($page->getField(new SimpleByLabel('Stuff')), 'B');
- }
-
- function testTwoSelectionFieldsWithLabelsAreIndependent() {
- $raw = '
- Labelled D
-
- D1
- D2
-
-
- Labelled H
-
- H1
- H2
-
-
- ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertTrue($page->setField(new SimpleByLabel('Labelled D'), 'd2'));
- $this->assertTrue($page->setField(new SimpleByLabel('Labelled H'), 'h1'));
- $this->assertEqual($page->getField(new SimpleByLabel('Labelled D')), 'd2');
- }
-
- function testSettingRadioButtonByEnclosingLabel() {
- $raw = '' .
- 'A ' .
- 'B ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByLabel('A')), 'a');
- $this->assertTrue($page->setField(new SimpleBylabel('B'), 'b'));
- $this->assertEqual($page->getField(new SimpleByLabel('B')), 'b');
- }
-
- function testCanParseInputsWithAllKindsOfAttributeQuoting() {
- $raw = '' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByName('first')), 'one');
- $this->assertEqual($page->getField(new SimpleByName('second')), false);
- $this->assertEqual($page->getField(new SimpleByName('third')), 'three');
- }
-
- function urlToString($url) {
- return $url->asString();
- }
-
- function assertSameFrameset($actual, $expected) {
- $this->assertIdentical(array_map(array($this, 'urlToString'), $actual),
- array_map(array($this, 'urlToString'), $expected));
- }
-}
-
-class TestOfParsingUsingPhpParser extends TestOfParsing {
-
- function whenVisiting($url, $content) {
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getContent', $content);
- $response->setReturnValue('getUrl', new SimpleUrl($url));
- $builder = new SimplePhpPageBuilder();
- return $builder->parse($response);
- }
-
- function testNastyTitle() {
- $page = $this->whenVisiting('http://host',
- ' Me&Me ');
- $this->assertEqual($page->getTitle(), "Me&Me");
- }
-
- function testLabelShouldStopAtClosingLabelTag() {
- $raw = 'startstuff end stuff ';
- $page = $this->whenVisiting('http://host', $raw);
- $this->assertEqual($page->getField(new SimpleByLabel('startend')), 'stuff');
- }
-}
-
-class TestOfParsingUsingTidyParser extends TestOfParsing {
-
- function skip() {
- $this->skipUnless(extension_loaded('tidy'), 'Install \'tidy\' php extension to enable html tidy based parser');
- }
-
- function whenVisiting($url, $content) {
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getContent', $content);
- $response->setReturnValue('getUrl', new SimpleUrl($url));
- $builder = new SimpleTidyPageBuilder();
- return $builder->parse($response);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/php_parser_test.php b/core/vendors/simpletest/test/php_parser_test.php
deleted file mode 100755
index d95c7d0..0000000
--- a/core/vendors/simpletest/test/php_parser_test.php
+++ /dev/null
@@ -1,489 +0,0 @@
-assertFalse($regex->match("Hello", $match));
- $this->assertEqual($match, "");
- }
-
- function testNoSubject() {
- $regex = new ParallelRegex(false);
- $regex->addPattern(".*");
- $this->assertTrue($regex->match("", $match));
- $this->assertEqual($match, "");
- }
-
- function testMatchAll() {
- $regex = new ParallelRegex(false);
- $regex->addPattern(".*");
- $this->assertTrue($regex->match("Hello", $match));
- $this->assertEqual($match, "Hello");
- }
-
- function testCaseSensitive() {
- $regex = new ParallelRegex(true);
- $regex->addPattern("abc");
- $this->assertTrue($regex->match("abcdef", $match));
- $this->assertEqual($match, "abc");
- $this->assertTrue($regex->match("AAABCabcdef", $match));
- $this->assertEqual($match, "abc");
- }
-
- function testCaseInsensitive() {
- $regex = new ParallelRegex(false);
- $regex->addPattern("abc");
- $this->assertTrue($regex->match("abcdef", $match));
- $this->assertEqual($match, "abc");
- $this->assertTrue($regex->match("AAABCabcdef", $match));
- $this->assertEqual($match, "ABC");
- }
-
- function testMatchMultiple() {
- $regex = new ParallelRegex(true);
- $regex->addPattern("abc");
- $regex->addPattern("ABC");
- $this->assertTrue($regex->match("abcdef", $match));
- $this->assertEqual($match, "abc");
- $this->assertTrue($regex->match("AAABCabcdef", $match));
- $this->assertEqual($match, "ABC");
- $this->assertFalse($regex->match("Hello", $match));
- }
-
- function testPatternLabels() {
- $regex = new ParallelRegex(false);
- $regex->addPattern("abc", "letter");
- $regex->addPattern("123", "number");
- $this->assertIdentical($regex->match("abcdef", $match), "letter");
- $this->assertEqual($match, "abc");
- $this->assertIdentical($regex->match("0123456789", $match), "number");
- $this->assertEqual($match, "123");
- }
-}
-
-class TestOfStateStack extends UnitTestCase {
-
- function testStartState() {
- $stack = new SimpleStateStack("one");
- $this->assertEqual($stack->getCurrent(), "one");
- }
-
- function testExhaustion() {
- $stack = new SimpleStateStack("one");
- $this->assertFalse($stack->leave());
- }
-
- function testStateMoves() {
- $stack = new SimpleStateStack("one");
- $stack->enter("two");
- $this->assertEqual($stack->getCurrent(), "two");
- $stack->enter("three");
- $this->assertEqual($stack->getCurrent(), "three");
- $this->assertTrue($stack->leave());
- $this->assertEqual($stack->getCurrent(), "two");
- $stack->enter("third");
- $this->assertEqual($stack->getCurrent(), "third");
- $this->assertTrue($stack->leave());
- $this->assertTrue($stack->leave());
- $this->assertEqual($stack->getCurrent(), "one");
- }
-}
-
-class TestParser {
-
- function accept() {
- }
-
- function a() {
- }
-
- function b() {
- }
-}
-Mock::generate('TestParser');
-
-class TestOfLexer extends UnitTestCase {
-
- function testEmptyPage() {
- $handler = new MockTestParser();
- $handler->expectNever("accept");
- $handler->setReturnValue("accept", true);
- $handler->expectNever("accept");
- $handler->setReturnValue("accept", true);
- $lexer = new SimpleLexer($handler);
- $lexer->addPattern("a+");
- $this->assertTrue($lexer->parse(""));
- }
-
- function testSinglePattern() {
- $handler = new MockTestParser();
- $handler->expectAt(0, "accept", array("aaa", LEXER_MATCHED));
- $handler->expectAt(1, "accept", array("x", LEXER_UNMATCHED));
- $handler->expectAt(2, "accept", array("a", LEXER_MATCHED));
- $handler->expectAt(3, "accept", array("yyy", LEXER_UNMATCHED));
- $handler->expectAt(4, "accept", array("a", LEXER_MATCHED));
- $handler->expectAt(5, "accept", array("x", LEXER_UNMATCHED));
- $handler->expectAt(6, "accept", array("aaa", LEXER_MATCHED));
- $handler->expectAt(7, "accept", array("z", LEXER_UNMATCHED));
- $handler->expectCallCount("accept", 8);
- $handler->setReturnValue("accept", true);
- $lexer = new SimpleLexer($handler);
- $lexer->addPattern("a+");
- $this->assertTrue($lexer->parse("aaaxayyyaxaaaz"));
- }
-
- function testMultiplePattern() {
- $handler = new MockTestParser();
- $target = array("a", "b", "a", "bb", "x", "b", "a", "xxxxxx", "a", "x");
- for ($i = 0; $i < count($target); $i++) {
- $handler->expectAt($i, "accept", array($target[$i], '*'));
- }
- $handler->expectCallCount("accept", count($target));
- $handler->setReturnValue("accept", true);
- $lexer = new SimpleLexer($handler);
- $lexer->addPattern("a+");
- $lexer->addPattern("b+");
- $this->assertTrue($lexer->parse("ababbxbaxxxxxxax"));
- }
-}
-
-class TestOfLexerModes extends UnitTestCase {
-
- function testIsolatedPattern() {
- $handler = new MockTestParser();
- $handler->expectAt(0, "a", array("a", LEXER_MATCHED));
- $handler->expectAt(1, "a", array("b", LEXER_UNMATCHED));
- $handler->expectAt(2, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(3, "a", array("bxb", LEXER_UNMATCHED));
- $handler->expectAt(4, "a", array("aaa", LEXER_MATCHED));
- $handler->expectAt(5, "a", array("x", LEXER_UNMATCHED));
- $handler->expectAt(6, "a", array("aaaa", LEXER_MATCHED));
- $handler->expectAt(7, "a", array("x", LEXER_UNMATCHED));
- $handler->expectCallCount("a", 8);
- $handler->setReturnValue("a", true);
- $lexer = new SimpleLexer($handler, "a");
- $lexer->addPattern("a+", "a");
- $lexer->addPattern("b+", "b");
- $this->assertTrue($lexer->parse("abaabxbaaaxaaaax"));
- }
-
- function testModeChange() {
- $handler = new MockTestParser();
- $handler->expectAt(0, "a", array("a", LEXER_MATCHED));
- $handler->expectAt(1, "a", array("b", LEXER_UNMATCHED));
- $handler->expectAt(2, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(3, "a", array("b", LEXER_UNMATCHED));
- $handler->expectAt(4, "a", array("aaa", LEXER_MATCHED));
- $handler->expectAt(0, "b", array(":", LEXER_ENTER));
- $handler->expectAt(1, "b", array("a", LEXER_UNMATCHED));
- $handler->expectAt(2, "b", array("b", LEXER_MATCHED));
- $handler->expectAt(3, "b", array("a", LEXER_UNMATCHED));
- $handler->expectAt(4, "b", array("bb", LEXER_MATCHED));
- $handler->expectAt(5, "b", array("a", LEXER_UNMATCHED));
- $handler->expectAt(6, "b", array("bbb", LEXER_MATCHED));
- $handler->expectAt(7, "b", array("a", LEXER_UNMATCHED));
- $handler->expectCallCount("a", 5);
- $handler->expectCallCount("b", 8);
- $handler->setReturnValue("a", true);
- $handler->setReturnValue("b", true);
- $lexer = new SimpleLexer($handler, "a");
- $lexer->addPattern("a+", "a");
- $lexer->addEntryPattern(":", "a", "b");
- $lexer->addPattern("b+", "b");
- $this->assertTrue($lexer->parse("abaabaaa:ababbabbba"));
- }
-
- function testNesting() {
- $handler = new MockTestParser();
- $handler->setReturnValue("a", true);
- $handler->setReturnValue("b", true);
- $handler->expectAt(0, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(1, "a", array("b", LEXER_UNMATCHED));
- $handler->expectAt(2, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(3, "a", array("b", LEXER_UNMATCHED));
- $handler->expectAt(0, "b", array("(", LEXER_ENTER));
- $handler->expectAt(1, "b", array("bb", LEXER_MATCHED));
- $handler->expectAt(2, "b", array("a", LEXER_UNMATCHED));
- $handler->expectAt(3, "b", array("bb", LEXER_MATCHED));
- $handler->expectAt(4, "b", array(")", LEXER_EXIT));
- $handler->expectAt(4, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(5, "a", array("b", LEXER_UNMATCHED));
- $handler->expectCallCount("a", 6);
- $handler->expectCallCount("b", 5);
- $lexer = new SimpleLexer($handler, "a");
- $lexer->addPattern("a+", "a");
- $lexer->addEntryPattern("(", "a", "b");
- $lexer->addPattern("b+", "b");
- $lexer->addExitPattern(")", "b");
- $this->assertTrue($lexer->parse("aabaab(bbabb)aab"));
- }
-
- function testSingular() {
- $handler = new MockTestParser();
- $handler->setReturnValue("a", true);
- $handler->setReturnValue("b", true);
- $handler->expectAt(0, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(1, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(2, "a", array("xx", LEXER_UNMATCHED));
- $handler->expectAt(3, "a", array("xx", LEXER_UNMATCHED));
- $handler->expectAt(0, "b", array("b", LEXER_SPECIAL));
- $handler->expectAt(1, "b", array("bbb", LEXER_SPECIAL));
- $handler->expectCallCount("a", 4);
- $handler->expectCallCount("b", 2);
- $lexer = new SimpleLexer($handler, "a");
- $lexer->addPattern("a+", "a");
- $lexer->addSpecialPattern("b+", "a", "b");
- $this->assertTrue($lexer->parse("aabaaxxbbbxx"));
- }
-
- function testUnwindTooFar() {
- $handler = new MockTestParser();
- $handler->setReturnValue("a", true);
- $handler->expectAt(0, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(1, "a", array(")", LEXER_EXIT));
- $handler->expectCallCount("a", 2);
- $lexer = new SimpleLexer($handler, "a");
- $lexer->addPattern("a+", "a");
- $lexer->addExitPattern(")", "a");
- $this->assertFalse($lexer->parse("aa)aa"));
- }
-}
-
-class TestOfLexerHandlers extends UnitTestCase {
-
- function testModeMapping() {
- $handler = new MockTestParser();
- $handler->setReturnValue("a", true);
- $handler->expectAt(0, "a", array("aa", LEXER_MATCHED));
- $handler->expectAt(1, "a", array("(", LEXER_ENTER));
- $handler->expectAt(2, "a", array("bb", LEXER_MATCHED));
- $handler->expectAt(3, "a", array("a", LEXER_UNMATCHED));
- $handler->expectAt(4, "a", array("bb", LEXER_MATCHED));
- $handler->expectAt(5, "a", array(")", LEXER_EXIT));
- $handler->expectAt(6, "a", array("b", LEXER_UNMATCHED));
- $handler->expectCallCount("a", 7);
- $lexer = new SimpleLexer($handler, "mode_a");
- $lexer->addPattern("a+", "mode_a");
- $lexer->addEntryPattern("(", "mode_a", "mode_b");
- $lexer->addPattern("b+", "mode_b");
- $lexer->addExitPattern(")", "mode_b");
- $lexer->mapHandler("mode_a", "a");
- $lexer->mapHandler("mode_b", "a");
- $this->assertTrue($lexer->parse("aa(bbabb)b"));
- }
-}
-
-class TestOfSimpleHtmlLexer extends UnitTestCase {
-
- function &createParser() {
- $parser = new MockSimpleHtmlSaxParser();
- $parser->setReturnValue('acceptStartToken', true);
- $parser->setReturnValue('acceptEndToken', true);
- $parser->setReturnValue('acceptAttributeToken', true);
- $parser->setReturnValue('acceptEntityToken', true);
- $parser->setReturnValue('acceptTextToken', true);
- $parser->setReturnValue('ignore', true);
- return $parser;
- }
-
- function testNoContent() {
- $parser = $this->createParser();
- $parser->expectNever('acceptStartToken');
- $parser->expectNever('acceptEndToken');
- $parser->expectNever('acceptAttributeToken');
- $parser->expectNever('acceptEntityToken');
- $parser->expectNever('acceptTextToken');
- $lexer = new SimpleHtmlLexer($parser);
- $this->assertTrue($lexer->parse(''));
- }
-
- function testUninteresting() {
- $parser = $this->createParser();
- $parser->expectOnce('acceptTextToken', array('', '*'));
- $lexer = new SimpleHtmlLexer($parser);
- $this->assertTrue($lexer->parse(''));
- }
-
- function testSkipCss() {
- $parser = $this->createParser();
- $parser->expectNever('acceptTextToken');
- $parser->expectAtLeastOnce('ignore');
- $lexer = new SimpleHtmlLexer($parser);
- $this->assertTrue($lexer->parse(""));
- }
-
- function testSkipJavaScript() {
- $parser = $this->createParser();
- $parser->expectNever('acceptTextToken');
- $parser->expectAtLeastOnce('ignore');
- $lexer = new SimpleHtmlLexer($parser);
- $this->assertTrue($lexer->parse(""));
- }
-
- function testSkipHtmlComments() {
- $parser = $this->createParser();
- $parser->expectNever('acceptTextToken');
- $parser->expectAtLeastOnce('ignore');
- $lexer = new SimpleHtmlLexer($parser);
- $this->assertTrue($lexer->parse(""));
- }
-
- function testTagWithNoAttributes() {
- $parser = $this->createParser();
- $parser->expectAt(0, 'acceptStartToken', array('expectAt(1, 'acceptStartToken', array('>', '*'));
- $parser->expectCallCount('acceptStartToken', 2);
- $parser->expectOnce('acceptTextToken', array('Hello', '*'));
- $parser->expectOnce('acceptEndToken', array(' ', '*'));
- $lexer = new SimpleHtmlLexer($parser);
- $this->assertTrue($lexer->parse('Hello '));
- }
-
- function testTagWithAttributes() {
- $parser = $this->createParser();
- $parser->expectOnce('acceptTextToken', array('label', '*'));
- $parser->expectAt(0, 'acceptStartToken', array(' expectAt(1, 'acceptStartToken', array('href', '*'));
- $parser->expectAt(2, 'acceptStartToken', array('>', '*'));
- $parser->expectCallCount('acceptStartToken', 3);
- $parser->expectAt(0, 'acceptAttributeToken', array('= "', '*'));
- $parser->expectAt(1, 'acceptAttributeToken', array('here.html', '*'));
- $parser->expectAt(2, 'acceptAttributeToken', array('"', '*'));
- $parser->expectCallCount('acceptAttributeToken', 3);
- $parser->expectOnce('acceptEndToken', array(' ', '*'));
- $lexer = new SimpleHtmlLexer($parser);
- $this->assertTrue($lexer->parse('label '));
- }
-}
-
-class TestOfHtmlSaxParser extends UnitTestCase {
-
- function createListener() {
- $listener = new MockSimplePhpPageBuilder();
- $listener->setReturnValue('startElement', true);
- $listener->setReturnValue('addContent', true);
- $listener->setReturnValue('endElement', true);
- return $listener;
- }
-
- function testFramesetTag() {
- $listener = $this->createListener();
- $listener->expectOnce('startElement', array('frameset', array()));
- $listener->expectOnce('addContent', array('Frames'));
- $listener->expectOnce('endElement', array('frameset'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse('Frames '));
- }
-
- function testTagWithUnquotedAttributes() {
- $listener = $this->createListener();
- $listener->expectOnce(
- 'startElement',
- array('input', array('name' => 'a.b.c', 'value' => 'd')));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse(' '));
- }
-
- function testTagInsideContent() {
- $listener = $this->createListener();
- $listener->expectOnce('startElement', array('a', array()));
- $listener->expectAt(0, 'addContent', array(''));
- $listener->expectAt(1, 'addContent', array(''));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse(' '));
- }
-
- function testTagWithInternalContent() {
- $listener = $this->createListener();
- $listener->expectOnce('startElement', array('a', array()));
- $listener->expectOnce('addContent', array('label'));
- $listener->expectOnce('endElement', array('a'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse('label '));
- }
-
- function testLinkAddress() {
- $listener = $this->createListener();
- $listener->expectOnce('startElement', array('a', array('href' => 'here.html')));
- $listener->expectOnce('addContent', array('label'));
- $listener->expectOnce('endElement', array('a'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse("label "));
- }
-
- function testEncodedAttribute() {
- $listener = $this->createListener();
- $listener->expectOnce('startElement', array('a', array('href' => 'here&there.html')));
- $listener->expectOnce('addContent', array('label'));
- $listener->expectOnce('endElement', array('a'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse("label "));
- }
-
- function testTagWithId() {
- $listener = $this->createListener();
- $listener->expectOnce('startElement', array('a', array('id' => '0')));
- $listener->expectOnce('addContent', array('label'));
- $listener->expectOnce('endElement', array('a'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse('label '));
- }
-
- function testTagWithEmptyAttributes() {
- $listener = $this->createListener();
- $listener->expectOnce(
- 'startElement',
- array('option', array('value' => '', 'selected' => '')));
- $listener->expectOnce('addContent', array('label'));
- $listener->expectOnce('endElement', array('option'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse('label '));
- }
-
- function testComplexTagWithLotsOfCaseVariations() {
- $listener = $this->createListener();
- $listener->expectOnce(
- 'startElement',
- array('a', array('href' => 'here.html', 'style' => "'cool'")));
- $listener->expectOnce('addContent', array('label'));
- $listener->expectOnce('endElement', array('a'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse('label '));
- }
-
- function testXhtmlSelfClosingTag() {
- $listener = $this->createListener();
- $listener->expectOnce(
- 'startElement',
- array('input', array('type' => 'submit', 'name' => 'N', 'value' => 'V')));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse(' '));
- }
-
- function testNestedFrameInFrameset() {
- $listener = $this->createListener();
- $listener->expectAt(0, 'startElement', array('frameset', array()));
- $listener->expectAt(1, 'startElement', array('frame', array('src' => 'frame.html')));
- $listener->expectCallCount('startElement', 2);
- $listener->expectOnce('addContent', array('Hello '));
- $listener->expectOnce('endElement', array('frameset'));
- $parser = new SimpleHtmlSaxParser($listener);
- $this->assertTrue($parser->parse(
- 'Hello '));
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/recorder_test.php b/core/vendors/simpletest/test/recorder_test.php
deleted file mode 100755
index fdae4c1..0000000
--- a/core/vendors/simpletest/test/recorder_test.php
+++ /dev/null
@@ -1,23 +0,0 @@
-addFile(dirname(__FILE__) . '/support/recorder_sample.php');
- $recorder = new Recorder(new SimpleReporter());
- $test->run($recorder);
- $this->assertEqual(count($recorder->results), 2);
- $this->assertIsA($recorder->results[0], 'SimpleResultOfPass');
- $this->assertEqual('testTrueIsTrue', array_pop($recorder->results[0]->breadcrumb));
- $this->assertPattern('/ at \[.*\Wrecorder_sample\.php line 7\]/', $recorder->results[0]->message);
- $this->assertIsA($recorder->results[1], 'SimpleResultOfFail');
- $this->assertEqual('testFalseIsTrue', array_pop($recorder->results[1]->breadcrumb));
- $this->assertPattern("/Expected false, got \[Boolean: true\] at \[.*\Wrecorder_sample\.php line 11\]/",
- $recorder->results[1]->message);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/reflection_php5_test.php b/core/vendors/simpletest/test/reflection_php5_test.php
deleted file mode 100755
index d9f46e6..0000000
--- a/core/vendors/simpletest/test/reflection_php5_test.php
+++ /dev/null
@@ -1,263 +0,0 @@
-assertTrue($reflection->classOrInterfaceExists());
- $this->assertTrue($reflection->classOrInterfaceExistsSansAutoload());
- $this->assertFalse($reflection->isAbstract());
- $this->assertFalse($reflection->isInterface());
- }
-
- function testClassNonExistence() {
- $reflection = new SimpleReflection('UnknownThing');
- $this->assertFalse($reflection->classOrInterfaceExists());
- $this->assertFalse($reflection->classOrInterfaceExistsSansAutoload());
- }
-
- function testDetectionOfAbstractClass() {
- $reflection = new SimpleReflection('AnyOldClass');
- $this->assertTrue($reflection->isAbstract());
- }
-
- function testDetectionOfFinalMethods() {
- $reflection = new SimpleReflection('AnyOldClass');
- $this->assertFalse($reflection->hasFinal());
- $reflection = new SimpleReflection('AnyOldLeafClassWithAFinal');
- $this->assertTrue($reflection->hasFinal());
- }
-
- function testFindingParentClass() {
- $reflection = new SimpleReflection('AnyOldSubclass');
- $this->assertEqual($reflection->getParent(), 'AnyOldImplementation');
- }
-
- function testInterfaceExistence() {
- $reflection = new SimpleReflection('AnyOldInterface');
- $this->assertTrue($reflection->classOrInterfaceExists());
- $this->assertTrue($reflection->classOrInterfaceExistsSansAutoload());
- $this->assertTrue($reflection->isInterface());
- }
-
- function testMethodsListFromClass() {
- $reflection = new SimpleReflection('AnyOldClass');
- $this->assertIdentical($reflection->getMethods(), array('aMethod'));
- }
-
- function testMethodsListFromInterface() {
- $reflection = new SimpleReflection('AnyOldInterface');
- $this->assertIdentical($reflection->getMethods(), array('aMethod'));
- $this->assertIdentical($reflection->getInterfaceMethods(), array('aMethod'));
- }
-
- function testMethodsComeFromDescendentInterfacesASWell() {
- $reflection = new SimpleReflection('AnyDescendentInterface');
- $this->assertIdentical($reflection->getMethods(), array('aMethod'));
- }
-
- function testCanSeparateInterfaceMethodsFromOthers() {
- $reflection = new SimpleReflection('AnyOldImplementation');
- $this->assertIdentical($reflection->getMethods(), array('aMethod', 'extraMethod'));
- $this->assertIdentical($reflection->getInterfaceMethods(), array('aMethod'));
- }
-
- function testMethodsComeFromDescendentInterfacesInAbstractClass() {
- $reflection = new SimpleReflection('AnyAbstractImplementation');
- $this->assertIdentical($reflection->getMethods(), array('aMethod'));
- }
-
- function testInterfaceHasOnlyItselfToImplement() {
- $reflection = new SimpleReflection('AnyOldInterface');
- $this->assertEqual(
- $reflection->getInterfaces(),
- array('AnyOldInterface'));
- }
-
- function testInterfacesListedForClass() {
- $reflection = new SimpleReflection('AnyOldImplementation');
- $this->assertEqual(
- $reflection->getInterfaces(),
- array('AnyOldInterface'));
- }
-
- function testInterfacesListedForSubclass() {
- $reflection = new SimpleReflection('AnyOldSubclass');
- $this->assertEqual(
- $reflection->getInterfaces(),
- array('AnyOldInterface'));
- }
-
- function testNoParameterCreationWhenNoInterface() {
- $reflection = new SimpleReflection('AnyOldArgumentClass');
- $function = $reflection->getSignature('aMethod');
- if (version_compare(phpversion(), '5.0.2', '<=')) {
- $this->assertEqual('function amethod($argument)', strtolower($function));
- } else {
- $this->assertEqual('function aMethod($argument)', $function);
- }
- }
-
- function testParameterCreationWithoutTypeHinting() {
- $reflection = new SimpleReflection('AnyOldArgumentImplementation');
- $function = $reflection->getSignature('aMethod');
- if (version_compare(phpversion(), '5.0.2', '<=')) {
- $this->assertEqual('function amethod(AnyOldInterface $argument)', $function);
- } else {
- $this->assertEqual('function aMethod(AnyOldInterface $argument)', $function);
- }
- }
-
- function testParameterCreationForTypeHinting() {
- $reflection = new SimpleReflection('AnyOldTypeHintedClass');
- $function = $reflection->getSignature('aMethod');
- if (version_compare(phpversion(), '5.0.2', '<=')) {
- $this->assertEqual('function amethod(AnyOldInterface $argument)', $function);
- } else {
- $this->assertEqual('function aMethod(AnyOldInterface $argument)', $function);
- }
- }
-
- function testIssetFunctionSignature() {
- $reflection = new SimpleReflection('AnyOldOverloadedClass');
- $function = $reflection->getSignature('__isset');
- $this->assertEqual('function __isset($key)', $function);
- }
-
- function testUnsetFunctionSignature() {
- $reflection = new SimpleReflection('AnyOldOverloadedClass');
- $function = $reflection->getSignature('__unset');
- $this->assertEqual('function __unset($key)', $function);
- }
-
- function testProperlyReflectsTheFinalInterfaceWhenObjectImplementsAnExtendedInterface() {
- $reflection = new SimpleReflection('AnyDescendentImplementation');
- $interfaces = $reflection->getInterfaces();
- $this->assertEqual(1, count($interfaces));
- $this->assertEqual('AnyDescendentInterface', array_shift($interfaces));
- }
-
- function testCreatingSignatureForAbstractMethod() {
- $reflection = new SimpleReflection('AnotherOldAbstractClass');
- $this->assertEqual($reflection->getSignature('aMethod'), 'function aMethod(AnyOldInterface $argument)');
- }
-
- function testCanProperlyGenerateStaticMethodSignatures() {
- $reflection = new SimpleReflection('AnyOldClassWithStaticMethods');
- $this->assertEqual('static function aStatic()', $reflection->getSignature('aStatic'));
- $this->assertEqual(
- 'static function aStaticWithParameters($arg1, $arg2)',
- $reflection->getSignature('aStaticWithParameters')
- );
- }
-}
-
-class TestOfReflectionWithTypeHints extends UnitTestCase {
- function skip() {
- $this->skipIf(version_compare(phpversion(), '5.1.0', '<'), 'Reflection with type hints only tested for PHP 5.1.0 and above');
- }
-
- function testParameterCreationForTypeHintingWithArray() {
- eval('interface AnyOldArrayTypeHintedInterface {
- function amethod(array $argument);
- }
- class AnyOldArrayTypeHintedClass implements AnyOldArrayTypeHintedInterface {
- function amethod(array $argument) {}
- }');
- $reflection = new SimpleReflection('AnyOldArrayTypeHintedClass');
- $function = $reflection->getSignature('amethod');
- $this->assertEqual('function amethod(array $argument)', $function);
- }
-}
-
-class TestOfAbstractsWithAbstractMethods extends UnitTestCase {
- function testCanProperlyGenerateAbstractMethods() {
- $reflection = new SimpleReflection('AnyOldAbstractClassWithAbstractMethods');
- $this->assertEqual(
- 'function anAbstract()',
- $reflection->getSignature('anAbstract')
- );
- $this->assertEqual(
- 'function anAbstractWithParameter($foo)',
- $reflection->getSignature('anAbstractWithParameter')
- );
- $this->assertEqual(
- 'function anAbstractWithMultipleParameters($foo, $bar)',
- $reflection->getSignature('anAbstractWithMultipleParameters')
- );
- }
-}
-
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/remote_test.php b/core/vendors/simpletest/test/remote_test.php
deleted file mode 100755
index 5f3f96a..0000000
--- a/core/vendors/simpletest/test/remote_test.php
+++ /dev/null
@@ -1,19 +0,0 @@
-add(new RemoteTestCase($test_url . '?xml=yes', $test_url . '?xml=yes&dry=yes'));
-if (SimpleReporter::inCli()) {
- exit ($test->run(new TextReporter()) ? 0 : 1);
-}
-$test->run(new HtmlReporter());
diff --git a/core/vendors/simpletest/test/shell_test.php b/core/vendors/simpletest/test/shell_test.php
deleted file mode 100755
index d1d769a..0000000
--- a/core/vendors/simpletest/test/shell_test.php
+++ /dev/null
@@ -1,38 +0,0 @@
-assertIdentical($shell->execute('echo Hello'), 0);
- $this->assertPattern('/Hello/', $shell->getOutput());
- }
-
- function testBadCommand() {
- $shell = new SimpleShell();
- $this->assertNotEqual($ret = $shell->execute('blurgh! 2>&1'), 0);
- }
-}
-
-class TestOfShellTesterAndShell extends ShellTestCase {
-
- function testEcho() {
- $this->assertTrue($this->execute('echo Hello'));
- $this->assertExitCode(0);
- $this->assertoutput('Hello');
- }
-
- function testFileExistence() {
- $this->assertFileExists(dirname(__FILE__) . '/all_tests.php');
- $this->assertFileNotExists('wibble');
- }
-
- function testFilePatterns() {
- $this->assertFilePattern('/all[_ ]tests/i', dirname(__FILE__) . '/all_tests.php');
- $this->assertNoFilePattern('/sputnik/i', dirname(__FILE__) . '/all_tests.php');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/shell_tester_test.php b/core/vendors/simpletest/test/shell_tester_test.php
deleted file mode 100755
index b12c602..0000000
--- a/core/vendors/simpletest/test/shell_tester_test.php
+++ /dev/null
@@ -1,42 +0,0 @@
-mock_shell;
- }
-
- function testGenericEquality() {
- $this->assertEqual('a', 'a');
- $this->assertNotEqual('a', 'A');
- }
-
- function testExitCode() {
- $this->mock_shell = new MockSimpleShell();
- $this->mock_shell->setReturnValue('execute', 0);
- $this->mock_shell->expectOnce('execute', array('ls'));
- $this->assertTrue($this->execute('ls'));
- $this->assertExitCode(0);
- }
-
- function testOutput() {
- $this->mock_shell = new MockSimpleShell();
- $this->mock_shell->setReturnValue('execute', 0);
- $this->mock_shell->setReturnValue('getOutput', "Line 1\nLine 2\n");
- $this->assertOutput("Line 1\nLine 2\n");
- }
-
- function testOutputPatterns() {
- $this->mock_shell = new MockSimpleShell();
- $this->mock_shell->setReturnValue('execute', 0);
- $this->mock_shell->setReturnValue('getOutput', "Line 1\nLine 2\n");
- $this->assertOutputPattern('/line/i');
- $this->assertNoOutputPattern('/line 2/');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/simpletest_test.php b/core/vendors/simpletest/test/simpletest_test.php
deleted file mode 100755
index daa65c6..0000000
--- a/core/vendors/simpletest/test/simpletest_test.php
+++ /dev/null
@@ -1,58 +0,0 @@
-fail('Should be ignored');
- }
-}
-
-class ShouldNeverBeRunEither extends ShouldNeverBeRun { }
-
-class TestOfStackTrace extends UnitTestCase {
-
- function testCanFindAssertInTrace() {
- $trace = new SimpleStackTrace(array('assert'));
- $this->assertEqual(
- $trace->traceMethod(array(array(
- 'file' => '/my_test.php',
- 'line' => 24,
- 'function' => 'assertSomething'))),
- ' at [/my_test.php line 24]');
- }
-}
-
-class DummyResource { }
-
-class TestOfContext extends UnitTestCase {
-
- function testCurrentContextIsUnique() {
- $this->assertSame(
- SimpleTest::getContext(),
- SimpleTest::getContext());
- }
-
- function testContextHoldsCurrentTestCase() {
- $context = SimpleTest::getContext();
- $this->assertSame($this, $context->getTest());
- }
-
- function testResourceIsSingleInstanceWithContext() {
- $context = new SimpleTestContext();
- $this->assertSame(
- $context->get('DummyResource'),
- $context->get('DummyResource'));
- }
-
- function testClearingContextResetsResources() {
- $context = new SimpleTestContext();
- $resource = $context->get('DummyResource');
- $context->clear();
- $this->assertClone($resource, $context->get('DummyResource'));
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/site/file.html b/core/vendors/simpletest/test/site/file.html
deleted file mode 100755
index cc41aee..0000000
--- a/core/vendors/simpletest/test/site/file.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
- Link to SimpleTest
-
- Link to SimpleTest
-
-
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/socket_test.php b/core/vendors/simpletest/test/socket_test.php
deleted file mode 100755
index 729adda..0000000
--- a/core/vendors/simpletest/test/socket_test.php
+++ /dev/null
@@ -1,25 +0,0 @@
-assertFalse($error->isError());
- $error->setError('Ouch');
- $this->assertTrue($error->isError());
- $this->assertEqual($error->getError(), 'Ouch');
- }
-
- function testClearingError() {
- $error = new SimpleStickyError();
- $error->setError('Ouch');
- $this->assertTrue($error->isError());
- $error->clearError();
- $this->assertFalse($error->isError());
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/collector/collectable.1 b/core/vendors/simpletest/test/support/collector/collectable.1
deleted file mode 100755
index e69de29..0000000
diff --git a/core/vendors/simpletest/test/support/collector/collectable.2 b/core/vendors/simpletest/test/support/collector/collectable.2
deleted file mode 100755
index e69de29..0000000
diff --git a/core/vendors/simpletest/test/support/empty_test_file.php b/core/vendors/simpletest/test/support/empty_test_file.php
deleted file mode 100755
index 31e3f7b..0000000
--- a/core/vendors/simpletest/test/support/empty_test_file.php
+++ /dev/null
@@ -1,3 +0,0 @@
-
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/failing_test.php b/core/vendors/simpletest/test/support/failing_test.php
deleted file mode 100755
index 30f0d75..0000000
--- a/core/vendors/simpletest/test/support/failing_test.php
+++ /dev/null
@@ -1,9 +0,0 @@
-assertEqual(1,2);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/latin1_sample b/core/vendors/simpletest/test/support/latin1_sample
deleted file mode 100755
index 1903525..0000000
--- a/core/vendors/simpletest/test/support/latin1_sample
+++ /dev/null
@@ -1 +0,0 @@
-£¹²³¼½¾@¶øþðßæ«»¢µ
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/passing_test.php b/core/vendors/simpletest/test/support/passing_test.php
deleted file mode 100755
index b786321..0000000
--- a/core/vendors/simpletest/test/support/passing_test.php
+++ /dev/null
@@ -1,9 +0,0 @@
-assertEqual(2,2);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/recorder_sample.php b/core/vendors/simpletest/test/support/recorder_sample.php
deleted file mode 100755
index 4f157f6..0000000
--- a/core/vendors/simpletest/test/support/recorder_sample.php
+++ /dev/null
@@ -1,14 +0,0 @@
-assertTrue(true);
- }
-
- function testFalseIsTrue() {
- $this->assertFalse(true);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/spl_examples.php b/core/vendors/simpletest/test/support/spl_examples.php
deleted file mode 100755
index 45add35..0000000
--- a/core/vendors/simpletest/test/support/spl_examples.php
+++ /dev/null
@@ -1,15 +0,0 @@
-
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/supplementary_upload_sample.txt b/core/vendors/simpletest/test/support/supplementary_upload_sample.txt
deleted file mode 100755
index d8aa9e8..0000000
--- a/core/vendors/simpletest/test/support/supplementary_upload_sample.txt
+++ /dev/null
@@ -1 +0,0 @@
-Some more text content
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/support/test1.php b/core/vendors/simpletest/test/support/test1.php
deleted file mode 100755
index b414586..0000000
--- a/core/vendors/simpletest/test/support/test1.php
+++ /dev/null
@@ -1,7 +0,0 @@
-assertEqual(3,1+2, "pass1");
- }
-}
-?>
diff --git a/core/vendors/simpletest/test/support/upload_sample.txt b/core/vendors/simpletest/test/support/upload_sample.txt
deleted file mode 100755
index ec98d7c..0000000
--- a/core/vendors/simpletest/test/support/upload_sample.txt
+++ /dev/null
@@ -1 +0,0 @@
-Sample for testing file upload
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/tag_test.php b/core/vendors/simpletest/test/tag_test.php
deleted file mode 100755
index 5e8a377..0000000
--- a/core/vendors/simpletest/test/tag_test.php
+++ /dev/null
@@ -1,554 +0,0 @@
- '1', 'b' => ''));
- $this->assertEqual($tag->getTagName(), 'title');
- $this->assertIdentical($tag->getAttribute('a'), '1');
- $this->assertIdentical($tag->getAttribute('b'), '');
- $this->assertIdentical($tag->getAttribute('c'), false);
- $this->assertIdentical($tag->getContent(), '');
- }
-
- function testTitleContent() {
- $tag = new SimpleTitleTag(array());
- $this->assertTrue($tag->expectEndTag());
- $tag->addContent('Hello');
- $tag->addContent('World');
- $this->assertEqual($tag->getText(), 'HelloWorld');
- }
-
- function testMessyTitleContent() {
- $tag = new SimpleTitleTag(array());
- $this->assertTrue($tag->expectEndTag());
- $tag->addContent('Hello ');
- $tag->addContent('World ');
- $this->assertEqual($tag->getText(), 'HelloWorld');
- }
-
- function testTagWithNoEnd() {
- $tag = new SimpleTextTag(array());
- $this->assertFalse($tag->expectEndTag());
- }
-
- function testAnchorHref() {
- $tag = new SimpleAnchorTag(array('href' => 'http://here/'));
- $this->assertEqual($tag->getHref(), 'http://here/');
-
- $tag = new SimpleAnchorTag(array('href' => ''));
- $this->assertIdentical($tag->getAttribute('href'), '');
- $this->assertIdentical($tag->getHref(), '');
-
- $tag = new SimpleAnchorTag(array());
- $this->assertIdentical($tag->getAttribute('href'), false);
- $this->assertIdentical($tag->getHref(), '');
- }
-
- function testIsIdMatchesIdAttribute() {
- $tag = new SimpleAnchorTag(array('href' => 'http://here/', 'id' => 7));
- $this->assertIdentical($tag->getAttribute('id'), '7');
- $this->assertTrue($tag->isId(7));
- }
-}
-
-class TestOfWidget extends UnitTestCase {
-
- function testTextEmptyDefault() {
- $tag = new SimpleTextTag(array('type' => 'text'));
- $this->assertIdentical($tag->getDefault(), '');
- $this->assertIdentical($tag->getValue(), '');
- }
-
- function testSettingOfExternalLabel() {
- $tag = new SimpleTextTag(array('type' => 'text'));
- $tag->setLabel('it');
- $this->assertTrue($tag->isLabel('it'));
- }
-
- function testTextDefault() {
- $tag = new SimpleTextTag(array('value' => 'aaa'));
- $this->assertEqual($tag->getDefault(), 'aaa');
- $this->assertEqual($tag->getValue(), 'aaa');
- }
-
- function testSettingTextValue() {
- $tag = new SimpleTextTag(array('value' => 'aaa'));
- $tag->setValue('bbb');
- $this->assertEqual($tag->getValue(), 'bbb');
- $tag->resetValue();
- $this->assertEqual($tag->getValue(), 'aaa');
- }
-
- function testFailToSetHiddenValue() {
- $tag = new SimpleTextTag(array('value' => 'aaa', 'type' => 'hidden'));
- $this->assertFalse($tag->setValue('bbb'));
- $this->assertEqual($tag->getValue(), 'aaa');
- }
-
- function testSubmitDefaults() {
- $tag = new SimpleSubmitTag(array('type' => 'submit'));
- $this->assertIdentical($tag->getName(), false);
- $this->assertEqual($tag->getValue(), 'Submit');
- $this->assertFalse($tag->setValue('Cannot set this'));
- $this->assertEqual($tag->getValue(), 'Submit');
- $this->assertEqual($tag->getLabel(), 'Submit');
-
- $encoding = new MockSimpleMultipartEncoding();
- $encoding->expectNever('add');
- $tag->write($encoding);
- }
-
- function testPopulatedSubmit() {
- $tag = new SimpleSubmitTag(
- array('type' => 'submit', 'name' => 's', 'value' => 'Ok!'));
- $this->assertEqual($tag->getName(), 's');
- $this->assertEqual($tag->getValue(), 'Ok!');
- $this->assertEqual($tag->getLabel(), 'Ok!');
-
- $encoding = new MockSimpleMultipartEncoding();
- $encoding->expectOnce('add', array('s', 'Ok!'));
- $tag->write($encoding);
- }
-
- function testImageSubmit() {
- $tag = new SimpleImageSubmitTag(
- array('type' => 'image', 'name' => 's', 'alt' => 'Label'));
- $this->assertEqual($tag->getName(), 's');
- $this->assertEqual($tag->getLabel(), 'Label');
-
- $encoding = new MockSimpleMultipartEncoding();
- $encoding->expectAt(0, 'add', array('s.x', 20));
- $encoding->expectAt(1, 'add', array('s.y', 30));
- $tag->write($encoding, 20, 30);
- }
-
- function testImageSubmitTitlePreferredOverAltForLabel() {
- $tag = new SimpleImageSubmitTag(
- array('type' => 'image', 'name' => 's', 'alt' => 'Label', 'title' => 'Title'));
- $this->assertEqual($tag->getLabel(), 'Title');
- }
-
- function testButton() {
- $tag = new SimpleButtonTag(
- array('type' => 'submit', 'name' => 's', 'value' => 'do'));
- $tag->addContent('I am a button');
- $this->assertEqual($tag->getName(), 's');
- $this->assertEqual($tag->getValue(), 'do');
- $this->assertEqual($tag->getLabel(), 'I am a button');
-
- $encoding = new MockSimpleMultipartEncoding();
- $encoding->expectOnce('add', array('s', 'do'));
- $tag->write($encoding);
- }
-}
-
-class TestOfTextArea extends UnitTestCase {
-
- function testDefault() {
- $tag = new SimpleTextAreaTag(array('name' => 'a'));
- $tag->addContent('Some text');
- $this->assertEqual($tag->getName(), 'a');
- $this->assertEqual($tag->getDefault(), 'Some text');
- }
-
- function testWrapping() {
- $tag = new SimpleTextAreaTag(array('cols' => '10', 'wrap' => 'physical'));
- $tag->addContent("Lot's of text that should be wrapped");
- $this->assertEqual(
- $tag->getDefault(),
- "Lot's of\r\ntext that\r\nshould be\r\nwrapped");
- $tag->setValue("New long text\r\nwith two lines");
- $this->assertEqual(
- $tag->getValue(),
- "New long\r\ntext\r\nwith two\r\nlines");
- }
-
- function testWrappingRemovesLeadingcariageReturn() {
- $tag = new SimpleTextAreaTag(array('cols' => '20', 'wrap' => 'physical'));
- $tag->addContent("\rStuff");
- $this->assertEqual($tag->getDefault(), 'Stuff');
- $tag->setValue("\nNew stuff\n");
- $this->assertEqual($tag->getValue(), "New stuff\r\n");
- }
-
- function testBreaksAreNewlineAndCarriageReturn() {
- $tag = new SimpleTextAreaTag(array('cols' => '10'));
- $tag->addContent("Some\nText\rwith\r\nbreaks");
- $this->assertEqual($tag->getValue(), "Some\r\nText\r\nwith\r\nbreaks");
- }
-}
-
-class TestOfCheckbox extends UnitTestCase {
-
- function testCanSetCheckboxToNamedValueWithBooleanTrue() {
- $tag = new SimpleCheckboxTag(array('name' => 'a', 'value' => 'A'));
- $this->assertEqual($tag->getValue(), false);
- $tag->setValue(true);
- $this->assertIdentical($tag->getValue(), 'A');
- }
-}
-
-class TestOfSelection extends UnitTestCase {
-
- function testEmpty() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $this->assertIdentical($tag->getValue(), '');
- }
-
- function testSingle() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $option = new SimpleOptionTag(array());
- $option->addContent('AAA');
- $tag->addTag($option);
- $this->assertEqual($tag->getValue(), 'AAA');
- }
-
- function testSingleDefault() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $option = new SimpleOptionTag(array('selected' => ''));
- $option->addContent('AAA');
- $tag->addTag($option);
- $this->assertEqual($tag->getValue(), 'AAA');
- }
-
- function testSingleMappedDefault() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $option = new SimpleOptionTag(array('selected' => '', 'value' => 'aaa'));
- $option->addContent('AAA');
- $tag->addTag($option);
- $this->assertEqual($tag->getValue(), 'aaa');
- }
-
- function testStartsWithDefault() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $a = new SimpleOptionTag(array());
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array('selected' => ''));
- $b->addContent('BBB');
- $tag->addTag($b);
- $c = new SimpleOptionTag(array());
- $c->addContent('CCC');
- $tag->addTag($c);
- $this->assertEqual($tag->getValue(), 'BBB');
- }
-
- function testSettingOption() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $a = new SimpleOptionTag(array());
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array('selected' => ''));
- $b->addContent('BBB');
- $tag->addTag($b);
- $c = new SimpleOptionTag(array());
- $c->addContent('CCC');
- $tag->setValue('AAA');
- $this->assertEqual($tag->getValue(), 'AAA');
- }
-
- function testSettingMappedOption() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $a = new SimpleOptionTag(array('value' => 'aaa'));
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array('value' => 'bbb', 'selected' => ''));
- $b->addContent('BBB');
- $tag->addTag($b);
- $c = new SimpleOptionTag(array('value' => 'ccc'));
- $c->addContent('CCC');
- $tag->addTag($c);
- $tag->setValue('AAA');
- $this->assertEqual($tag->getValue(), 'aaa');
- $tag->setValue('ccc');
- $this->assertEqual($tag->getValue(), 'ccc');
- }
-
- function testSelectionDespiteSpuriousWhitespace() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $a = new SimpleOptionTag(array());
- $a->addContent(' AAA ');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array('selected' => ''));
- $b->addContent(' BBB ');
- $tag->addTag($b);
- $c = new SimpleOptionTag(array());
- $c->addContent(' CCC ');
- $tag->addTag($c);
- $this->assertEqual($tag->getValue(), ' BBB ');
- $tag->setValue('AAA');
- $this->assertEqual($tag->getValue(), ' AAA ');
- }
-
- function testFailToSetIllegalOption() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $a = new SimpleOptionTag(array());
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array('selected' => ''));
- $b->addContent('BBB');
- $tag->addTag($b);
- $c = new SimpleOptionTag(array());
- $c->addContent('CCC');
- $tag->addTag($c);
- $this->assertFalse($tag->setValue('Not present'));
- $this->assertEqual($tag->getValue(), 'BBB');
- }
-
- function testNastyOptionValuesThatLookLikeFalse() {
- $tag = new SimpleSelectionTag(array('name' => 'a'));
- $a = new SimpleOptionTag(array('value' => '1'));
- $a->addContent('One');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array('value' => '0'));
- $b->addContent('Zero');
- $tag->addTag($b);
- $this->assertIdentical($tag->getValue(), '1');
- $tag->setValue('Zero');
- $this->assertIdentical($tag->getValue(), '0');
- }
-
- function testBlankOption() {
- $tag = new SimpleSelectionTag(array('name' => 'A'));
- $a = new SimpleOptionTag(array());
- $tag->addTag($a);
- $b = new SimpleOptionTag(array());
- $b->addContent('b');
- $tag->addTag($b);
- $this->assertIdentical($tag->getValue(), '');
- $tag->setValue('b');
- $this->assertIdentical($tag->getValue(), 'b');
- $tag->setValue('');
- $this->assertIdentical($tag->getValue(), '');
- }
-
- function testMultipleDefaultWithNoSelections() {
- $tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
- $a = new SimpleOptionTag(array());
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array());
- $b->addContent('BBB');
- $tag->addTag($b);
- $this->assertIdentical($tag->getDefault(), array());
- $this->assertIdentical($tag->getValue(), array());
- }
-
- function testMultipleDefaultWithSelections() {
- $tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
- $a = new SimpleOptionTag(array('selected' => ''));
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array('selected' => ''));
- $b->addContent('BBB');
- $tag->addTag($b);
- $this->assertIdentical($tag->getDefault(), array('AAA', 'BBB'));
- $this->assertIdentical($tag->getValue(), array('AAA', 'BBB'));
- }
-
- function testSettingMultiple() {
- $tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
- $a = new SimpleOptionTag(array('selected' => ''));
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array());
- $b->addContent('BBB');
- $tag->addTag($b);
- $c = new SimpleOptionTag(array('selected' => '', 'value' => 'ccc'));
- $c->addContent('CCC');
- $tag->addTag($c);
- $this->assertIdentical($tag->getDefault(), array('AAA', 'ccc'));
- $this->assertTrue($tag->setValue(array('BBB', 'ccc')));
- $this->assertIdentical($tag->getValue(), array('BBB', 'ccc'));
- $this->assertTrue($tag->setValue(array()));
- $this->assertIdentical($tag->getValue(), array());
- }
-
- function testFailToSetIllegalOptionsInMultiple() {
- $tag = new MultipleSelectionTag(array('name' => 'a', 'multiple' => ''));
- $a = new SimpleOptionTag(array('selected' => ''));
- $a->addContent('AAA');
- $tag->addTag($a);
- $b = new SimpleOptionTag(array());
- $b->addContent('BBB');
- $tag->addTag($b);
- $this->assertFalse($tag->setValue(array('CCC')));
- $this->assertTrue($tag->setValue(array('AAA', 'BBB')));
- $this->assertFalse($tag->setValue(array('AAA', 'CCC')));
- }
-}
-
-class TestOfRadioGroup extends UnitTestCase {
-
- function testEmptyGroup() {
- $group = new SimpleRadioGroup();
- $this->assertIdentical($group->getDefault(), false);
- $this->assertIdentical($group->getValue(), false);
- $this->assertFalse($group->setValue('a'));
- }
-
- function testReadingSingleButtonGroup() {
- $group = new SimpleRadioGroup();
- $group->addWidget(new SimpleRadioButtonTag(
- array('value' => 'A', 'checked' => '')));
- $this->assertIdentical($group->getDefault(), 'A');
- $this->assertIdentical($group->getValue(), 'A');
- }
-
- function testReadingMultipleButtonGroup() {
- $group = new SimpleRadioGroup();
- $group->addWidget(new SimpleRadioButtonTag(
- array('value' => 'A')));
- $group->addWidget(new SimpleRadioButtonTag(
- array('value' => 'B', 'checked' => '')));
- $this->assertIdentical($group->getDefault(), 'B');
- $this->assertIdentical($group->getValue(), 'B');
- }
-
- function testFailToSetUnlistedValue() {
- $group = new SimpleRadioGroup();
- $group->addWidget(new SimpleRadioButtonTag(array('value' => 'z')));
- $this->assertFalse($group->setValue('a'));
- $this->assertIdentical($group->getValue(), false);
- }
-
- function testSettingNewValueClearsTheOldOne() {
- $group = new SimpleRadioGroup();
- $group->addWidget(new SimpleRadioButtonTag(
- array('value' => 'A')));
- $group->addWidget(new SimpleRadioButtonTag(
- array('value' => 'B', 'checked' => '')));
- $this->assertTrue($group->setValue('A'));
- $this->assertIdentical($group->getValue(), 'A');
- }
-
- function testIsIdMatchesAnyWidgetInSet() {
- $group = new SimpleRadioGroup();
- $group->addWidget(new SimpleRadioButtonTag(
- array('value' => 'A', 'id' => 'i1')));
- $group->addWidget(new SimpleRadioButtonTag(
- array('value' => 'B', 'id' => 'i2')));
- $this->assertFalse($group->isId('i0'));
- $this->assertTrue($group->isId('i1'));
- $this->assertTrue($group->isId('i2'));
- }
-
- function testIsLabelMatchesAnyWidgetInSet() {
- $group = new SimpleRadioGroup();
- $button1 = new SimpleRadioButtonTag(array('value' => 'A'));
- $button1->setLabel('one');
- $group->addWidget($button1);
- $button2 = new SimpleRadioButtonTag(array('value' => 'B'));
- $button2->setLabel('two');
- $group->addWidget($button2);
- $this->assertFalse($group->isLabel('three'));
- $this->assertTrue($group->isLabel('one'));
- $this->assertTrue($group->isLabel('two'));
- }
-}
-
-class TestOfTagGroup extends UnitTestCase {
-
- function testReadingMultipleCheckboxGroup() {
- $group = new SimpleCheckboxGroup();
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
- $group->addWidget(new SimpleCheckboxTag(
- array('value' => 'B', 'checked' => '')));
- $this->assertIdentical($group->getDefault(), 'B');
- $this->assertIdentical($group->getValue(), 'B');
- }
-
- function testReadingMultipleUncheckedItems() {
- $group = new SimpleCheckboxGroup();
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
- $this->assertIdentical($group->getDefault(), false);
- $this->assertIdentical($group->getValue(), false);
- }
-
- function testReadingMultipleCheckedItems() {
- $group = new SimpleCheckboxGroup();
- $group->addWidget(new SimpleCheckboxTag(
- array('value' => 'A', 'checked' => '')));
- $group->addWidget(new SimpleCheckboxTag(
- array('value' => 'B', 'checked' => '')));
- $this->assertIdentical($group->getDefault(), array('A', 'B'));
- $this->assertIdentical($group->getValue(), array('A', 'B'));
- }
-
- function testSettingSingleValue() {
- $group = new SimpleCheckboxGroup();
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
- $this->assertTrue($group->setValue('A'));
- $this->assertIdentical($group->getValue(), 'A');
- $this->assertTrue($group->setValue('B'));
- $this->assertIdentical($group->getValue(), 'B');
- }
-
- function testSettingMultipleValues() {
- $group = new SimpleCheckboxGroup();
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
- $this->assertTrue($group->setValue(array('A', 'B')));
- $this->assertIdentical($group->getValue(), array('A', 'B'));
- }
-
- function testSettingNoValue() {
- $group = new SimpleCheckboxGroup();
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'A')));
- $group->addWidget(new SimpleCheckboxTag(array('value' => 'B')));
- $this->assertTrue($group->setValue(false));
- $this->assertIdentical($group->getValue(), false);
- }
-
- function testIsIdMatchesAnyIdInSet() {
- $group = new SimpleCheckboxGroup();
- $group->addWidget(new SimpleCheckboxTag(array('id' => 1, 'value' => 'A')));
- $group->addWidget(new SimpleCheckboxTag(array('id' => 2, 'value' => 'B')));
- $this->assertFalse($group->isId(0));
- $this->assertTrue($group->isId(1));
- $this->assertTrue($group->isId(2));
- }
-}
-
-class TestOfUploadWidget extends UnitTestCase {
-
- function testValueIsFilePath() {
- $upload = new SimpleUploadTag(array('name' => 'a'));
- $upload->setValue(dirname(__FILE__) . '/support/upload_sample.txt');
- $this->assertEqual($upload->getValue(), dirname(__FILE__) . '/support/upload_sample.txt');
- }
-
- function testSubmitsFileContents() {
- $encoding = new MockSimpleMultipartEncoding();
- $encoding->expectOnce('attach', array(
- 'a',
- 'Sample for testing file upload',
- 'upload_sample.txt'));
- $upload = new SimpleUploadTag(array('name' => 'a'));
- $upload->setValue(dirname(__FILE__) . '/support/upload_sample.txt');
- $upload->write($encoding);
- }
-}
-
-class TestOfLabelTag extends UnitTestCase {
-
- function testLabelShouldHaveAnEndTag() {
- $label = new SimpleLabelTag(array());
- $this->assertTrue($label->expectEndTag());
- }
-
- function testContentIsTextOnly() {
- $label = new SimpleLabelTag(array());
- $label->addContent('Here are words');
- $this->assertEqual($label->getText(), 'Here are words');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/test_with_parse_error.php b/core/vendors/simpletest/test/test_with_parse_error.php
deleted file mode 100755
index 41a5832..0000000
--- a/core/vendors/simpletest/test/test_with_parse_error.php
+++ /dev/null
@@ -1,8 +0,0 @@
-
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/unit_tester_test.php b/core/vendors/simpletest/test/unit_tester_test.php
deleted file mode 100755
index ce9850f..0000000
--- a/core/vendors/simpletest/test/unit_tester_test.php
+++ /dev/null
@@ -1,61 +0,0 @@
-assertTrue($this->assertTrue(true));
- }
-
- function testAssertFalseReturnsAssertionAsBoolean() {
- $this->assertTrue($this->assertFalse(false));
- }
-
- function testAssertEqualReturnsAssertionAsBoolean() {
- $this->assertTrue($this->assertEqual(5, 5));
- }
-
- function testAssertIdenticalReturnsAssertionAsBoolean() {
- $this->assertTrue($this->assertIdentical(5, 5));
- }
-
- function testCoreAssertionsDoNotThrowErrors() {
- $this->assertIsA($this, 'UnitTestCase');
- $this->assertNotA($this, 'WebTestCase');
- }
-
- function testReferenceAssertionOnObjects() {
- $a = new ReferenceForTesting();
- $b = $a;
- $this->assertSame($a, $b);
- }
-
- function testReferenceAssertionOnScalars() {
- $a = 25;
- $b = &$a;
- $this->assertReference($a, $b);
- }
-
- function testCloneOnObjects() {
- $a = new ReferenceForTesting();
- $b = new ReferenceForTesting();
- $this->assertClone($a, $b);
- }
-
- function TODO_testCloneOnScalars() {
- $a = 25;
- $b = 25;
- $this->assertClone($a, $b);
- }
-
- function testCopyOnScalars() {
- $a = 25;
- $b = 25;
- $this->assertCopy($a, $b);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/unit_tests.php b/core/vendors/simpletest/test/unit_tests.php
deleted file mode 100755
index 9e62129..0000000
--- a/core/vendors/simpletest/test/unit_tests.php
+++ /dev/null
@@ -1,49 +0,0 @@
-TestSuite('Unit tests');
- $path = dirname(__FILE__);
- $this->addFile($path . '/errors_test.php');
- $this->addFile($path . '/exceptions_test.php');
- $this->addFile($path . '/arguments_test.php');
- $this->addFile($path . '/autorun_test.php');
- $this->addFile($path . '/compatibility_test.php');
- $this->addFile($path . '/simpletest_test.php');
- $this->addFile($path . '/dumper_test.php');
- $this->addFile($path . '/expectation_test.php');
- $this->addFile($path . '/unit_tester_test.php');
- $this->addFile($path . '/reflection_php5_test.php');
- $this->addFile($path . '/mock_objects_test.php');
- $this->addFile($path . '/interfaces_test.php');
- $this->addFile($path . '/collector_test.php');
- $this->addFile($path . '/recorder_test.php');
- $this->addFile($path . '/adapter_test.php');
- $this->addFile($path . '/socket_test.php');
- $this->addFile($path . '/encoding_test.php');
- $this->addFile($path . '/url_test.php');
- $this->addFile($path . '/cookies_test.php');
- $this->addFile($path . '/http_test.php');
- $this->addFile($path . '/authentication_test.php');
- $this->addFile($path . '/user_agent_test.php');
- $this->addFile($path . '/php_parser_test.php');
- $this->addFile($path . '/parsing_test.php');
- $this->addFile($path . '/tag_test.php');
- $this->addFile($path . '/form_test.php');
- $this->addFile($path . '/page_test.php');
- $this->addFile($path . '/frames_test.php');
- $this->addFile($path . '/browser_test.php');
- $this->addFile($path . '/web_tester_test.php');
- $this->addFile($path . '/shell_tester_test.php');
- $this->addFile($path . '/xml_test.php');
- $this->addFile($path . '/../extensions/testdox/test.php');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/url_test.php b/core/vendors/simpletest/test/url_test.php
deleted file mode 100755
index 80119af..0000000
--- a/core/vendors/simpletest/test/url_test.php
+++ /dev/null
@@ -1,515 +0,0 @@
-assertEqual($url->getScheme(), '');
- $this->assertEqual($url->getHost(), '');
- $this->assertEqual($url->getScheme('http'), 'http');
- $this->assertEqual($url->getHost('localhost'), 'localhost');
- $this->assertEqual($url->getPath(), '');
- }
-
- function testBasicParsing() {
- $url = new SimpleUrl('https://www.lastcraft.com/test/');
- $this->assertEqual($url->getScheme(), 'https');
- $this->assertEqual($url->getHost(), 'www.lastcraft.com');
- $this->assertEqual($url->getPath(), '/test/');
- }
-
- function testRelativeUrls() {
- $url = new SimpleUrl('../somewhere.php');
- $this->assertEqual($url->getScheme(), false);
- $this->assertEqual($url->getHost(), false);
- $this->assertEqual($url->getPath(), '../somewhere.php');
- }
-
- function testParseBareParameter() {
- $url = new SimpleUrl('?a');
- $this->assertEqual($url->getPath(), '');
- $this->assertEqual($url->getEncodedRequest(), '?a');
- $url->addRequestParameter('x', 'X');
- $this->assertEqual($url->getEncodedRequest(), '?a=&x=X');
- }
-
- function testParseEmptyParameter() {
- $url = new SimpleUrl('?a=');
- $this->assertEqual($url->getPath(), '');
- $this->assertEqual($url->getEncodedRequest(), '?a=');
- $url->addRequestParameter('x', 'X');
- $this->assertEqual($url->getEncodedRequest(), '?a=&x=X');
- }
-
- function testParseParameterPair() {
- $url = new SimpleUrl('?a=A');
- $this->assertEqual($url->getPath(), '');
- $this->assertEqual($url->getEncodedRequest(), '?a=A');
- $url->addRequestParameter('x', 'X');
- $this->assertEqual($url->getEncodedRequest(), '?a=A&x=X');
- }
-
- function testParseMultipleParameters() {
- $url = new SimpleUrl('?a=A&b=B');
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=B');
- $url->addRequestParameter('x', 'X');
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=B&x=X');
- }
-
- function testParsingParameterMixture() {
- $url = new SimpleUrl('?a=A&b=&c');
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c');
- $url->addRequestParameter('x', 'X');
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c=&x=X');
- }
-
- function testAddParametersFromScratch() {
- $url = new SimpleUrl('');
- $url->addRequestParameter('a', 'A');
- $this->assertEqual($url->getEncodedRequest(), '?a=A');
- $url->addRequestParameter('b', 'B');
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=B');
- $url->addRequestParameter('a', 'aaa');
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=B&a=aaa');
- }
-
- function testClearingParameters() {
- $url = new SimpleUrl('');
- $url->addRequestParameter('a', 'A');
- $url->clearRequest();
- $this->assertIdentical($url->getEncodedRequest(), '');
- }
-
- function testEncodingParameters() {
- $url = new SimpleUrl('');
- $url->addRequestParameter('a', '?!"\'#~@[]{}:;<>,./|$%^&*()_+-=');
- $this->assertIdentical(
- $request = $url->getEncodedRequest(),
- '?a=%3F%21%22%27%23%7E%40%5B%5D%7B%7D%3A%3B%3C%3E%2C.%2F%7C%24%25%5E%26%2A%28%29_%2B-%3D');
- }
-
- function testDecodingParameters() {
- $url = new SimpleUrl('?a=%3F%21%22%27%23%7E%40%5B%5D%7B%7D%3A%3B%3C%3E%2C.%2F%7C%24%25%5E%26%2A%28%29_%2B-%3D');
- $this->assertEqual(
- $url->getEncodedRequest(),
- '?a=' . urlencode('?!"\'#~@[]{}:;<>,./|$%^&*()_+-='));
- }
-
- function testUrlInQueryDoesNotConfuseParsing() {
- $url = new SimpleUrl('wibble/login.php?url=http://www.google.com/moo/');
- $this->assertFalse($url->getScheme());
- $this->assertFalse($url->getHost());
- $this->assertEqual($url->getPath(), 'wibble/login.php');
- $this->assertEqual($url->getEncodedRequest(), '?url=http://www.google.com/moo/');
- }
-
- function testSettingCordinates() {
- $url = new SimpleUrl('');
- $url->setCoordinates('32', '45');
- $this->assertIdentical($url->getX(), 32);
- $this->assertIdentical($url->getY(), 45);
- $this->assertEqual($url->getEncodedRequest(), '');
- }
-
- function testParseCordinates() {
- $url = new SimpleUrl('?32,45');
- $this->assertIdentical($url->getX(), 32);
- $this->assertIdentical($url->getY(), 45);
- }
-
- function testClearingCordinates() {
- $url = new SimpleUrl('?32,45');
- $url->setCoordinates();
- $this->assertIdentical($url->getX(), false);
- $this->assertIdentical($url->getY(), false);
- }
-
- function testParsingParameterCordinateMixture() {
- $url = new SimpleUrl('?a=A&b=&c?32,45');
- $this->assertIdentical($url->getX(), 32);
- $this->assertIdentical($url->getY(), 45);
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c');
- }
-
- function testParsingParameterWithBadCordinates() {
- $url = new SimpleUrl('?a=A&b=&c?32');
- $this->assertIdentical($url->getX(), false);
- $this->assertIdentical($url->getY(), false);
- $this->assertEqual($url->getEncodedRequest(), '?a=A&b=&c?32');
- }
-
- function testPageSplitting() {
- $url = new SimpleUrl('./here/../there/somewhere.php');
- $this->assertEqual($url->getPath(), './here/../there/somewhere.php');
- $this->assertEqual($url->getPage(), 'somewhere.php');
- $this->assertEqual($url->getBasePath(), './here/../there/');
- }
-
- function testAbsolutePathPageSplitting() {
- $url = new SimpleUrl("http://host.com/here/there/somewhere.php");
- $this->assertEqual($url->getPath(), "/here/there/somewhere.php");
- $this->assertEqual($url->getPage(), "somewhere.php");
- $this->assertEqual($url->getBasePath(), "/here/there/");
- }
-
- function testSplittingUrlWithNoPageGivesEmptyPage() {
- $url = new SimpleUrl('/here/there/');
- $this->assertEqual($url->getPath(), '/here/there/');
- $this->assertEqual($url->getPage(), '');
- $this->assertEqual($url->getBasePath(), '/here/there/');
- }
-
- function testPathNormalisation() {
- $url = new SimpleUrl();
- $this->assertEqual(
- $url->normalisePath('https://host.com/I/am/here/../there/somewhere.php'),
- 'https://host.com/I/am/there/somewhere.php');
- }
-
- // regression test for #1535407
- function testPathNormalisationWithSinglePeriod() {
- $url = new SimpleUrl();
- $this->assertEqual(
- $url->normalisePath('https://host.com/I/am/here/./../there/somewhere.php'),
- 'https://host.com/I/am/there/somewhere.php');
- }
-
- // regression test for #1852413
- function testHostnameExtractedFromUContainingAtSign() {
- $url = new SimpleUrl("http://localhost/name@example.com");
- $this->assertEqual($url->getScheme(), "http");
- $this->assertEqual($url->getUsername(), "");
- $this->assertEqual($url->getPassword(), "");
- $this->assertEqual($url->getHost(), "localhost");
- $this->assertEqual($url->getPath(), "/name@example.com");
- }
-
- function testHostnameInLocalhost() {
- $url = new SimpleUrl("http://localhost/name/example.com");
- $this->assertEqual($url->getScheme(), "http");
- $this->assertEqual($url->getUsername(), "");
- $this->assertEqual($url->getPassword(), "");
- $this->assertEqual($url->getHost(), "localhost");
- $this->assertEqual($url->getPath(), "/name/example.com");
- }
-
- function testUsernameAndPasswordAreUrlDecoded() {
- $url = new SimpleUrl('http://' . urlencode('test@test') .
- ':' . urlencode('$!�@*&%') . '@www.lastcraft.com');
- $this->assertEqual($url->getUsername(), 'test@test');
- $this->assertEqual($url->getPassword(), '$!�@*&%');
- }
-
- function testBlitz() {
- $this->assertUrl(
- "https://username:password@www.somewhere.com:243/this/that/here.php?a=1&b=2#anchor",
- array("https", "username", "password", "www.somewhere.com", 243, "/this/that/here.php", "com", "?a=1&b=2", "anchor"),
- array("a" => "1", "b" => "2"));
- $this->assertUrl(
- "username:password@www.somewhere.com/this/that/here.php?a=1",
- array(false, "username", "password", "www.somewhere.com", false, "/this/that/here.php", "com", "?a=1", false),
- array("a" => "1"));
- $this->assertUrl(
- "username:password@somewhere.com:243?1,2",
- array(false, "username", "password", "somewhere.com", 243, "/", "com", "", false),
- array(),
- array(1, 2));
- $this->assertUrl(
- "https://www.somewhere.com",
- array("https", false, false, "www.somewhere.com", false, "/", "com", "", false));
- $this->assertUrl(
- "username@www.somewhere.com:243#anchor",
- array(false, "username", false, "www.somewhere.com", 243, "/", "com", "", "anchor"));
- $this->assertUrl(
- "/this/that/here.php?a=1&b=2?3,4",
- array(false, false, false, false, false, "/this/that/here.php", false, "?a=1&b=2", false),
- array("a" => "1", "b" => "2"),
- array(3, 4));
- $this->assertUrl(
- "username@/here.php?a=1&b=2",
- array(false, "username", false, false, false, "/here.php", false, "?a=1&b=2", false),
- array("a" => "1", "b" => "2"));
- }
-
- function testAmbiguousHosts() {
- $this->assertUrl(
- "tigger",
- array(false, false, false, false, false, "tigger", false, "", false));
- $this->assertUrl(
- "/tigger",
- array(false, false, false, false, false, "/tigger", false, "", false));
- $this->assertUrl(
- "//tigger",
- array(false, false, false, "tigger", false, "/", false, "", false));
- $this->assertUrl(
- "//tigger/",
- array(false, false, false, "tigger", false, "/", false, "", false));
- $this->assertUrl(
- "tigger.com",
- array(false, false, false, "tigger.com", false, "/", "com", "", false));
- $this->assertUrl(
- "me.net/tigger",
- array(false, false, false, "me.net", false, "/tigger", "net", "", false));
- }
-
- function testAsString() {
- $this->assertPreserved('https://www.here.com');
- $this->assertPreserved('http://me:secret@www.here.com');
- $this->assertPreserved('http://here/there');
- $this->assertPreserved('http://here/there?a=A&b=B');
- $this->assertPreserved('http://here/there?a=1&a=2');
- $this->assertPreserved('http://here/there?a=1&a=2?9,8');
- $this->assertPreserved('http://host?a=1&a=2');
- $this->assertPreserved('http://host#stuff');
- $this->assertPreserved('http://me:secret@www.here.com/a/b/c/here.html?a=A?7,6');
- $this->assertPreserved('http://www.here.com/?a=A__b=B');
- $this->assertPreserved('http://www.example.com:8080/');
- }
-
- function testUrlWithTwoSlashesInPath() {
- $url = new SimpleUrl('/article/categoryedit/insert//');
- $this->assertEqual($url->getPath(), '/article/categoryedit/insert//');
- }
-
- function testUrlWithRequestKeyEncoded() {
- $url = new SimpleUrl('/?foo%5B1%5D=bar');
- $this->assertEqual($url->getEncodedRequest(), '?foo%5B1%5D=bar');
- $url->addRequestParameter('a[1]', 'b[]');
- $this->assertEqual($url->getEncodedRequest(), '?foo%5B1%5D=bar&a%5B1%5D=b%5B%5D');
-
- $url = new SimpleUrl('/');
- $url->addRequestParameter('a[1]', 'b[]');
- $this->assertEqual($url->getEncodedRequest(), '?a%5B1%5D=b%5B%5D');
- }
-
- function testUrlWithRequestKeyEncodedAndParamNamLookingLikePair() {
- $url = new SimpleUrl('/');
- $url->addRequestParameter('foo[]=bar', '');
- $this->assertEqual($url->getEncodedRequest(), '?foo%5B%5D%3Dbar=');
- $url = new SimpleUrl('/?foo%5B%5D%3Dbar=');
- $this->assertEqual($url->getEncodedRequest(), '?foo%5B%5D%3Dbar=');
- }
-
- function assertUrl($raw, $parts, $params = false, $coords = false) {
- if (! is_array($params)) {
- $params = array();
- }
- $url = new SimpleUrl($raw);
- $this->assertIdentical($url->getScheme(), $parts[0], "[$raw] scheme -> %s");
- $this->assertIdentical($url->getUsername(), $parts[1], "[$raw] username -> %s");
- $this->assertIdentical($url->getPassword(), $parts[2], "[$raw] password -> %s");
- $this->assertIdentical($url->getHost(), $parts[3], "[$raw] host -> %s");
- $this->assertIdentical($url->getPort(), $parts[4], "[$raw] port -> %s");
- $this->assertIdentical($url->getPath(), $parts[5], "[$raw] path -> %s");
- $this->assertIdentical($url->getTld(), $parts[6], "[$raw] tld -> %s");
- $this->assertIdentical($url->getEncodedRequest(), $parts[7], "[$raw] encoded -> %s");
- $this->assertIdentical($url->getFragment(), $parts[8], "[$raw] fragment -> %s");
- if ($coords) {
- $this->assertIdentical($url->getX(), $coords[0], "[$raw] x -> %s");
- $this->assertIdentical($url->getY(), $coords[1], "[$raw] y -> %s");
- }
- }
-
- function assertPreserved($string) {
- $url = new SimpleUrl($string);
- $this->assertEqual($url->asString(), $string);
- }
-}
-
-class TestOfAbsoluteUrls extends UnitTestCase {
-
- function testDirectoriesAfterFilename() {
- $string = '../../index.php/foo/bar';
- $url = new SimpleUrl($string);
- $this->assertEqual($url->asString(), $string);
-
- $absolute = $url->makeAbsolute('http://www.domain.com/some/path/');
- $this->assertEqual($absolute->asString(), 'http://www.domain.com/index.php/foo/bar');
- }
-
- function testMakingAbsolute() {
- $url = new SimpleUrl('../there/somewhere.php');
- $this->assertEqual($url->getPath(), '../there/somewhere.php');
- $absolute = $url->makeAbsolute('https://host.com:1234/I/am/here/');
- $this->assertEqual($absolute->getScheme(), 'https');
- $this->assertEqual($absolute->getHost(), 'host.com');
- $this->assertEqual($absolute->getPort(), 1234);
- $this->assertEqual($absolute->getPath(), '/I/am/there/somewhere.php');
- }
-
- function testMakingAnEmptyUrlAbsolute() {
- $url = new SimpleUrl('');
- $this->assertEqual($url->getPath(), '');
- $absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
- $this->assertEqual($absolute->getScheme(), 'http');
- $this->assertEqual($absolute->getHost(), 'host.com');
- $this->assertEqual($absolute->getPath(), '/I/am/here/page.html');
- }
-
- function testMakingAnEmptyUrlAbsoluteWithMissingPageName() {
- $url = new SimpleUrl('');
- $this->assertEqual($url->getPath(), '');
- $absolute = $url->makeAbsolute('http://host.com/I/am/here/');
- $this->assertEqual($absolute->getScheme(), 'http');
- $this->assertEqual($absolute->getHost(), 'host.com');
- $this->assertEqual($absolute->getPath(), '/I/am/here/');
- }
-
- function testMakingAShortQueryUrlAbsolute() {
- $url = new SimpleUrl('?a#b');
- $this->assertEqual($url->getPath(), '');
- $absolute = $url->makeAbsolute('http://host.com/I/am/here/');
- $this->assertEqual($absolute->getScheme(), 'http');
- $this->assertEqual($absolute->getHost(), 'host.com');
- $this->assertEqual($absolute->getPath(), '/I/am/here/');
- $this->assertEqual($absolute->getEncodedRequest(), '?a');
- $this->assertEqual($absolute->getFragment(), 'b');
- }
-
- function testMakingADirectoryUrlAbsolute() {
- $url = new SimpleUrl('hello/');
- $this->assertEqual($url->getPath(), 'hello/');
- $this->assertEqual($url->getBasePath(), 'hello/');
- $this->assertEqual($url->getPage(), '');
- $absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
- $this->assertEqual($absolute->getPath(), '/I/am/here/hello/');
- }
-
- function testMakingARootUrlAbsolute() {
- $url = new SimpleUrl('/');
- $this->assertEqual($url->getPath(), '/');
- $absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
- $this->assertEqual($absolute->getPath(), '/');
- }
-
- function testMakingARootPageUrlAbsolute() {
- $url = new SimpleUrl('/here.html');
- $absolute = $url->makeAbsolute('http://host.com/I/am/here/page.html');
- $this->assertEqual($absolute->getPath(), '/here.html');
- }
-
- function testCarryAuthenticationFromRootPage() {
- $url = new SimpleUrl('here.html');
- $absolute = $url->makeAbsolute('http://test:secret@host.com/');
- $this->assertEqual($absolute->getPath(), '/here.html');
- $this->assertEqual($absolute->getUsername(), 'test');
- $this->assertEqual($absolute->getPassword(), 'secret');
- }
-
- function testMakingCoordinateUrlAbsolute() {
- $url = new SimpleUrl('?1,2');
- $this->assertEqual($url->getPath(), '');
- $absolute = $url->makeAbsolute('http://host.com/I/am/here/');
- $this->assertEqual($absolute->getScheme(), 'http');
- $this->assertEqual($absolute->getHost(), 'host.com');
- $this->assertEqual($absolute->getPath(), '/I/am/here/');
- $this->assertEqual($absolute->getX(), 1);
- $this->assertEqual($absolute->getY(), 2);
- }
-
- function testMakingAbsoluteAppendedPath() {
- $url = new SimpleUrl('./there/somewhere.php');
- $absolute = $url->makeAbsolute('https://host.com/here/');
- $this->assertEqual($absolute->getPath(), '/here/there/somewhere.php');
- }
-
- function testMakingAbsoluteBadlyFormedAppendedPath() {
- $url = new SimpleUrl('there/somewhere.php');
- $absolute = $url->makeAbsolute('https://host.com/here/');
- $this->assertEqual($absolute->getPath(), '/here/there/somewhere.php');
- }
-
- function testMakingAbsoluteHasNoEffectWhenAlreadyAbsolute() {
- $url = new SimpleUrl('https://test:secret@www.lastcraft.com:321/stuff/?a=1#f');
- $absolute = $url->makeAbsolute('http://host.com/here/');
- $this->assertEqual($absolute->getScheme(), 'https');
- $this->assertEqual($absolute->getUsername(), 'test');
- $this->assertEqual($absolute->getPassword(), 'secret');
- $this->assertEqual($absolute->getHost(), 'www.lastcraft.com');
- $this->assertEqual($absolute->getPort(), 321);
- $this->assertEqual($absolute->getPath(), '/stuff/');
- $this->assertEqual($absolute->getEncodedRequest(), '?a=1');
- $this->assertEqual($absolute->getFragment(), 'f');
- }
-
- function testMakingAbsoluteCarriesAuthenticationWhenAlreadyAbsolute() {
- $url = new SimpleUrl('https://www.lastcraft.com');
- $absolute = $url->makeAbsolute('http://test:secret@host.com/here/');
- $this->assertEqual($absolute->getHost(), 'www.lastcraft.com');
- $this->assertEqual($absolute->getUsername(), 'test');
- $this->assertEqual($absolute->getPassword(), 'secret');
- }
-
- function testMakingHostOnlyAbsoluteDoesNotCarryAnyOtherInformation() {
- $url = new SimpleUrl('http://www.lastcraft.com');
- $absolute = $url->makeAbsolute('https://host.com:81/here/');
- $this->assertEqual($absolute->getScheme(), 'http');
- $this->assertEqual($absolute->getHost(), 'www.lastcraft.com');
- $this->assertIdentical($absolute->getPort(), false);
- $this->assertEqual($absolute->getPath(), '/');
- }
-}
-
-class TestOfFrameUrl extends UnitTestCase {
-
- function testTargetAttachment() {
- $url = new SimpleUrl('http://www.site.com/home.html');
- $this->assertIdentical($url->getTarget(), false);
- $url->setTarget('A frame');
- $this->assertIdentical($url->getTarget(), 'A frame');
- }
-}
-
-/**
- * @note Based off of http://www.mozilla.org/quality/networking/testing/filetests.html
- */
-class TestOfFileUrl extends UnitTestCase {
-
- function testMinimalUrl() {
- $url = new SimpleUrl('file:///');
- $this->assertEqual($url->getScheme(), 'file');
- $this->assertIdentical($url->getHost(), false);
- $this->assertEqual($url->getPath(), '/');
- }
-
- function testUnixUrl() {
- $url = new SimpleUrl('file:///fileInRoot');
- $this->assertEqual($url->getScheme(), 'file');
- $this->assertIdentical($url->getHost(), false);
- $this->assertEqual($url->getPath(), '/fileInRoot');
- }
-
- function testDOSVolumeUrl() {
- $url = new SimpleUrl('file:///C:/config.sys');
- $this->assertEqual($url->getScheme(), 'file');
- $this->assertIdentical($url->getHost(), false);
- $this->assertEqual($url->getPath(), '/C:/config.sys');
- }
-
- function testDOSVolumePromotion() {
- $url = new SimpleUrl('file://C:/config.sys');
- $this->assertEqual($url->getScheme(), 'file');
- $this->assertIdentical($url->getHost(), false);
- $this->assertEqual($url->getPath(), '/C:/config.sys');
- }
-
- function testDOSBackslashes() {
- $url = new SimpleUrl('file:///C:\config.sys');
- $this->assertEqual($url->getScheme(), 'file');
- $this->assertIdentical($url->getHost(), false);
- $this->assertEqual($url->getPath(), '/C:/config.sys');
- }
-
- function testDOSDirnameAfterFile() {
- $url = new SimpleUrl('file://C:\config.sys');
- $this->assertEqual($url->getScheme(), 'file');
- $this->assertIdentical($url->getHost(), false);
- $this->assertEqual($url->getPath(), '/C:/config.sys');
- }
-
-}
-
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/user_agent_test.php b/core/vendors/simpletest/test/user_agent_test.php
deleted file mode 100755
index 030abeb..0000000
--- a/core/vendors/simpletest/test/user_agent_test.php
+++ /dev/null
@@ -1,348 +0,0 @@
-headers = new MockSimpleHttpHeaders();
- $this->response = new MockSimpleHttpResponse();
- $this->response->setReturnValue('isError', false);
- $this->response->returns('getHeaders', new MockSimpleHttpHeaders());
- $this->request = new MockSimpleHttpRequest();
- $this->request->returns('fetch', $this->response);
- }
-
- function testGetRequestWithoutIncidentGivesNoErrors() {
- $url = new SimpleUrl('http://test:secret@this.com/page.html');
- $url->addRequestParameters(array('a' => 'A', 'b' => 'B'));
-
- $agent = new MockRequestUserAgent();
- $agent->returns('createHttpRequest', $this->request);
- $agent->__construct();
-
- $response = $agent->fetchResponse(
- new SimpleUrl('http://test:secret@this.com/page.html'),
- new SimpleGetEncoding(array('a' => 'A', 'b' => 'B')));
- $this->assertFalse($response->isError());
- }
-}
-
-class TestOfAdditionalHeaders extends UnitTestCase {
-
- function testAdditionalHeaderAddedToRequest() {
- $response = new MockSimpleHttpResponse();
- $response->setReturnReference('getHeaders', new MockSimpleHttpHeaders());
-
- $request = new MockSimpleHttpRequest();
- $request->setReturnReference('fetch', $response);
- $request->expectOnce(
- 'addHeaderLine',
- array('User-Agent: SimpleTest'));
-
- $agent = new MockRequestUserAgent();
- $agent->setReturnReference('createHttpRequest', $request);
- $agent->__construct();
- $agent->addHeader('User-Agent: SimpleTest');
- $response = $agent->fetchResponse(new SimpleUrl('http://this.host/'), new SimpleGetEncoding());
- }
-}
-
-class TestOfBrowserCookies extends UnitTestCase {
-
- private function createStandardResponse() {
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue("isError", false);
- $response->setReturnValue("getContent", "stuff");
- $response->setReturnReference("getHeaders", new MockSimpleHttpHeaders());
- return $response;
- }
-
- private function createCookieSite($header_lines) {
- $headers = new SimpleHttpHeaders($header_lines);
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue("isError", false);
- $response->setReturnReference("getHeaders", $headers);
- $response->setReturnValue("getContent", "stuff");
- $request = new MockSimpleHttpRequest();
- $request->setReturnReference("fetch", $response);
- return $request;
- }
-
- private function createMockedRequestUserAgent(&$request) {
- $agent = new MockRequestUserAgent();
- $agent->setReturnReference('createHttpRequest', $request);
- $agent->__construct();
- return $agent;
- }
-
- function testCookieJarIsSentToRequest() {
- $jar = new SimpleCookieJar();
- $jar->setCookie('a', 'A');
-
- $request = new MockSimpleHttpRequest();
- $request->returns('fetch', $this->createStandardResponse());
- $request->expectOnce('readCookiesFromJar', array($jar, '*'));
-
- $agent = $this->createMockedRequestUserAgent($request);
- $agent->setCookie('a', 'A');
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- }
-
- function testNoCookieJarIsSentToRequestWhenCookiesAreDisabled() {
- $request = new MockSimpleHttpRequest();
- $request->returns('fetch', $this->createStandardResponse());
- $request->expectNever('readCookiesFromJar');
-
- $agent = $this->createMockedRequestUserAgent($request);
- $agent->setCookie('a', 'A');
- $agent->ignoreCookies();
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- }
-
- function testReadingNewCookie() {
- $request = $this->createCookieSite('Set-cookie: a=AAAA');
- $agent = $this->createMockedRequestUserAgent($request);
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- $this->assertEqual($agent->getCookieValue("this.com", "this/path/", "a"), "AAAA");
- }
-
- function testIgnoringNewCookieWhenCookiesDisabled() {
- $request = $this->createCookieSite('Set-cookie: a=AAAA');
- $agent = $this->createMockedRequestUserAgent($request);
- $agent->ignoreCookies();
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- $this->assertIdentical($agent->getCookieValue("this.com", "this/path/", "a"), false);
- }
-
- function testOverwriteCookieThatAlreadyExists() {
- $request = $this->createCookieSite('Set-cookie: a=AAAA');
- $agent = $this->createMockedRequestUserAgent($request);
- $agent->setCookie('a', 'A');
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- $this->assertEqual($agent->getCookieValue("this.com", "this/path/", "a"), "AAAA");
- }
-
- function testClearCookieBySettingExpiry() {
- $request = $this->createCookieSite('Set-cookie: a=b');
- $agent = $this->createMockedRequestUserAgent($request);
-
- $agent->setCookie("a", "A", "this/path/", "Wed, 25-Dec-02 04:24:21 GMT");
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- $this->assertIdentical(
- $agent->getCookieValue("this.com", "this/path/", "a"),
- "b");
- $agent->restart("Wed, 25-Dec-02 04:24:20 GMT");
- $this->assertIdentical(
- $agent->getCookieValue("this.com", "this/path/", "a"),
- false);
- }
-
- function testAgeingAndClearing() {
- $request = $this->createCookieSite('Set-cookie: a=A; expires=Wed, 25-Dec-02 04:24:21 GMT; path=/this/path');
- $agent = $this->createMockedRequestUserAgent($request);
-
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- $agent->restart("Wed, 25-Dec-02 04:24:20 GMT");
- $this->assertIdentical(
- $agent->getCookieValue("this.com", "this/path/", "a"),
- "A");
- $agent->ageCookies(2);
- $agent->restart("Wed, 25-Dec-02 04:24:20 GMT");
- $this->assertIdentical(
- $agent->getCookieValue("this.com", "this/path/", "a"),
- false);
- }
-
- function testReadingIncomingAndSettingNewCookies() {
- $request = $this->createCookieSite('Set-cookie: a=AAA');
- $agent = $this->createMockedRequestUserAgent($request);
-
- $this->assertNull($agent->getBaseCookieValue("a", false));
- $agent->fetchResponse(
- new SimpleUrl('http://this.com/this/path/page.html'),
- new SimpleGetEncoding());
- $agent->setCookie("b", "BBB", "this.com", "this/path/");
- $this->assertEqual(
- $agent->getBaseCookieValue("a", new SimpleUrl('http://this.com/this/path/page.html')),
- "AAA");
- $this->assertEqual(
- $agent->getBaseCookieValue("b", new SimpleUrl('http://this.com/this/path/page.html')),
- "BBB");
- }
-}
-
-class TestOfHttpRedirects extends UnitTestCase {
-
- function createRedirect($content, $redirect) {
- $headers = new MockSimpleHttpHeaders();
- $headers->setReturnValue('isRedirect', (boolean)$redirect);
- $headers->setReturnValue('getLocation', $redirect);
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('getContent', $content);
- $response->setReturnReference('getHeaders', $headers);
- $request = new MockSimpleHttpRequest();
- $request->setReturnReference('fetch', $response);
- return $request;
- }
-
- function testDisabledRedirects() {
- $agent = new MockRequestUserAgent();
- $agent->returns(
- 'createHttpRequest',
- $this->createRedirect('stuff', 'there.html'));
- $agent->expectOnce('createHttpRequest');
- $agent->__construct();
- $agent->setMaximumRedirects(0);
- $response = $agent->fetchResponse(new SimpleUrl('here.html'), new SimpleGetEncoding());
- $this->assertEqual($response->getContent(), 'stuff');
- }
-
- function testSingleRedirect() {
- $agent = new MockRequestUserAgent();
- $agent->returnsAt(
- 0,
- 'createHttpRequest',
- $this->createRedirect('first', 'two.html'));
- $agent->returnsAt(
- 1,
- 'createHttpRequest',
- $this->createRedirect('second', 'three.html'));
- $agent->expectCallCount('createHttpRequest', 2);
- $agent->__construct();
-
- $agent->setMaximumRedirects(1);
- $response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimpleGetEncoding());
- $this->assertEqual($response->getContent(), 'second');
- }
-
- function testDoubleRedirect() {
- $agent = new MockRequestUserAgent();
- $agent->returnsAt(
- 0,
- 'createHttpRequest',
- $this->createRedirect('first', 'two.html'));
- $agent->returnsAt(
- 1,
- 'createHttpRequest',
- $this->createRedirect('second', 'three.html'));
- $agent->returnsAt(
- 2,
- 'createHttpRequest',
- $this->createRedirect('third', 'four.html'));
- $agent->expectCallCount('createHttpRequest', 3);
- $agent->__construct();
-
- $agent->setMaximumRedirects(2);
- $response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimpleGetEncoding());
- $this->assertEqual($response->getContent(), 'third');
- }
-
- function testSuccessAfterRedirect() {
- $agent = new MockRequestUserAgent();
- $agent->returnsAt(
- 0,
- 'createHttpRequest',
- $this->createRedirect('first', 'two.html'));
- $agent->returnsAt(
- 1,
- 'createHttpRequest',
- $this->createRedirect('second', false));
- $agent->returnsAt(
- 2,
- 'createHttpRequest',
- $this->createRedirect('third', 'four.html'));
- $agent->expectCallCount('createHttpRequest', 2);
- $agent->__construct();
-
- $agent->setMaximumRedirects(2);
- $response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimpleGetEncoding());
- $this->assertEqual($response->getContent(), 'second');
- }
-
- function testRedirectChangesPostToGet() {
- $agent = new MockRequestUserAgent();
- $agent->returnsAt(
- 0,
- 'createHttpRequest',
- $this->createRedirect('first', 'two.html'));
- $agent->expectAt(0, 'createHttpRequest', array('*', new IsAExpectation('SimplePostEncoding')));
- $agent->returnsAt(
- 1,
- 'createHttpRequest',
- $this->createRedirect('second', 'three.html'));
- $agent->expectAt(1, 'createHttpRequest', array('*', new IsAExpectation('SimpleGetEncoding')));
- $agent->expectCallCount('createHttpRequest', 2);
- $agent->__construct();
- $agent->setMaximumRedirects(1);
- $response = $agent->fetchResponse(new SimpleUrl('one.html'), new SimplePostEncoding());
- }
-}
-
-class TestOfBadHosts extends UnitTestCase {
-
- private function createSimulatedBadHost() {
- $response = new MockSimpleHttpResponse();
- $response->setReturnValue('isError', true);
- $response->setReturnValue('getError', 'Bad socket');
- $response->setReturnValue('getContent', false);
- $request = new MockSimpleHttpRequest();
- $request->setReturnReference('fetch', $response);
- return $request;
- }
-
- function testUntestedHost() {
- $request = $this->createSimulatedBadHost();
- $agent = new MockRequestUserAgent();
- $agent->setReturnReference('createHttpRequest', $request);
- $agent->__construct();
- $response = $agent->fetchResponse(
- new SimpleUrl('http://this.host/this/path/page.html'),
- new SimpleGetEncoding());
- $this->assertTrue($response->isError());
- }
-}
-
-class TestOfAuthorisation extends UnitTestCase {
-
- function testAuthenticateHeaderAdded() {
- $response = new MockSimpleHttpResponse();
- $response->setReturnReference('getHeaders', new MockSimpleHttpHeaders());
-
- $request = new MockSimpleHttpRequest();
- $request->returns('fetch', $response);
- $request->expectOnce(
- 'addHeaderLine',
- array('Authorization: Basic ' . base64_encode('test:secret')));
-
- $agent = new MockRequestUserAgent();
- $agent->returns('createHttpRequest', $request);
- $agent->__construct();
- $response = $agent->fetchResponse(
- new SimpleUrl('http://test:secret@this.host'),
- new SimpleGetEncoding());
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/visual_test.php b/core/vendors/simpletest/test/visual_test.php
deleted file mode 100755
index 6b9d085..0000000
--- a/core/vendors/simpletest/test/visual_test.php
+++ /dev/null
@@ -1,495 +0,0 @@
-a = $a;
- }
-}
-
-class PassingUnitTestCaseOutput extends UnitTestCase {
-
- function testOfResults() {
- $this->pass('Pass');
- }
-
- function testTrue() {
- $this->assertTrue(true);
- }
-
- function testFalse() {
- $this->assertFalse(false);
- }
-
- function testExpectation() {
- $expectation = &new EqualExpectation(25, 'My expectation message: %s');
- $this->assert($expectation, 25, 'My assert message : %s');
- }
-
- function testNull() {
- $this->assertNull(null, "%s -> Pass");
- $this->assertNotNull(false, "%s -> Pass");
- }
-
- function testType() {
- $this->assertIsA("hello", "string", "%s -> Pass");
- $this->assertIsA($this, "PassingUnitTestCaseOutput", "%s -> Pass");
- $this->assertIsA($this, "UnitTestCase", "%s -> Pass");
- }
-
- function testTypeEquality() {
- $this->assertEqual("0", 0, "%s -> Pass");
- }
-
- function testNullEquality() {
- $this->assertNotEqual(null, 1, "%s -> Pass");
- $this->assertNotEqual(1, null, "%s -> Pass");
- }
-
- function testIntegerEquality() {
- $this->assertNotEqual(1, 2, "%s -> Pass");
- }
-
- function testStringEquality() {
- $this->assertEqual("a", "a", "%s -> Pass");
- $this->assertNotEqual("aa", "ab", "%s -> Pass");
- }
-
- function testHashEquality() {
- $this->assertEqual(array("a" => "A", "b" => "B"), array("b" => "B", "a" => "A"), "%s -> Pass");
- }
-
- function testWithin() {
- $this->assertWithinMargin(5, 5.4, 0.5, "%s -> Pass");
- }
-
- function testOutside() {
- $this->assertOutsideMargin(5, 5.6, 0.5, "%s -> Pass");
- }
-
- function testStringIdentity() {
- $a = "fred";
- $b = $a;
- $this->assertIdentical($a, $b, "%s -> Pass");
- }
-
- function testTypeIdentity() {
- $a = "0";
- $b = 0;
- $this->assertNotIdentical($a, $b, "%s -> Pass");
- }
-
- function testNullIdentity() {
- $this->assertNotIdentical(null, 1, "%s -> Pass");
- $this->assertNotIdentical(1, null, "%s -> Pass");
- }
-
- function testHashIdentity() {
- }
-
- function testObjectEquality() {
- $this->assertEqual(new TestDisplayClass(4), new TestDisplayClass(4), "%s -> Pass");
- $this->assertNotEqual(new TestDisplayClass(4), new TestDisplayClass(5), "%s -> Pass");
- }
-
- function testObjectIndentity() {
- $this->assertIdentical(new TestDisplayClass(false), new TestDisplayClass(false), "%s -> Pass");
- $this->assertNotIdentical(new TestDisplayClass(false), new TestDisplayClass(0), "%s -> Pass");
- }
-
- function testReference() {
- $a = "fred";
- $b = &$a;
- $this->assertReference($a, $b, "%s -> Pass");
- }
-
- function testCloneOnDifferentObjects() {
- $a = "fred";
- $b = $a;
- $c = "Hello";
- $this->assertClone($a, $b, "%s -> Pass");
- }
-
- function testPatterns() {
- $this->assertPattern('/hello/i', "Hello there", "%s -> Pass");
- $this->assertNoPattern('/hello/', "Hello there", "%s -> Pass");
- }
-
- function testLongStrings() {
- $text = "";
- for ($i = 0; $i < 10; $i++) {
- $text .= "0123456789";
- }
- $this->assertEqual($text, $text);
- }
-}
-
-class FailingUnitTestCaseOutput extends UnitTestCase {
-
- function testOfResults() {
- $this->fail('Fail'); // Fail.
- }
-
- function testTrue() {
- $this->assertTrue(false); // Fail.
- }
-
- function testFalse() {
- $this->assertFalse(true); // Fail.
- }
-
- function testExpectation() {
- $expectation = &new EqualExpectation(25, 'My expectation message: %s');
- $this->assert($expectation, 24, 'My assert message : %s'); // Fail.
- }
-
- function testNull() {
- $this->assertNull(false, "%s -> Fail"); // Fail.
- $this->assertNotNull(null, "%s -> Fail"); // Fail.
- }
-
- function testType() {
- $this->assertIsA(14, "string", "%s -> Fail"); // Fail.
- $this->assertIsA(14, "TestOfUnitTestCaseOutput", "%s -> Fail"); // Fail.
- $this->assertIsA($this, "TestReporter", "%s -> Fail"); // Fail.
- }
-
- function testTypeEquality() {
- $this->assertNotEqual("0", 0, "%s -> Fail"); // Fail.
- }
-
- function testNullEquality() {
- $this->assertEqual(null, 1, "%s -> Fail"); // Fail.
- $this->assertEqual(1, null, "%s -> Fail"); // Fail.
- }
-
- function testIntegerEquality() {
- $this->assertEqual(1, 2, "%s -> Fail"); // Fail.
- }
-
- function testStringEquality() {
- $this->assertNotEqual("a", "a", "%s -> Fail"); // Fail.
- $this->assertEqual("aa", "ab", "%s -> Fail"); // Fail.
- }
-
- function testHashEquality() {
- $this->assertEqual(array("a" => "A", "b" => "B"), array("b" => "B", "a" => "Z"), "%s -> Fail");
- }
-
- function testWithin() {
- $this->assertWithinMargin(5, 5.6, 0.5, "%s -> Fail"); // Fail.
- }
-
- function testOutside() {
- $this->assertOutsideMargin(5, 5.4, 0.5, "%s -> Fail"); // Fail.
- }
-
- function testStringIdentity() {
- $a = "fred";
- $b = $a;
- $this->assertNotIdentical($a, $b, "%s -> Fail"); // Fail.
- }
-
- function testTypeIdentity() {
- $a = "0";
- $b = 0;
- $this->assertIdentical($a, $b, "%s -> Fail"); // Fail.
- }
-
- function testNullIdentity() {
- $this->assertIdentical(null, 1, "%s -> Fail"); // Fail.
- $this->assertIdentical(1, null, "%s -> Fail"); // Fail.
- }
-
- function testHashIdentity() {
- $this->assertIdentical(array("a" => "A", "b" => "B"), array("b" => "B", "a" => "A"), "%s -> fail"); // Fail.
- }
-
- function testObjectEquality() {
- $this->assertNotEqual(new TestDisplayClass(4), new TestDisplayClass(4), "%s -> Fail"); // Fail.
- $this->assertEqual(new TestDisplayClass(4), new TestDisplayClass(5), "%s -> Fail"); // Fail.
- }
-
- function testObjectIndentity() {
- $this->assertNotIdentical(new TestDisplayClass(false), new TestDisplayClass(false), "%s -> Fail"); // Fail.
- $this->assertIdentical(new TestDisplayClass(false), new TestDisplayClass(0), "%s -> Fail"); // Fail.
- }
-
- function testReference() {
- $a = "fred";
- $b = &$a;
- $this->assertClone($a, $b, "%s -> Fail"); // Fail.
- }
-
- function testCloneOnDifferentObjects() {
- $a = "fred";
- $b = $a;
- $c = "Hello";
- $this->assertClone($a, $c, "%s -> Fail"); // Fail.
- }
-
- function testPatterns() {
- $this->assertPattern('/hello/', "Hello there", "%s -> Fail"); // Fail.
- $this->assertNoPattern('/hello/i', "Hello there", "%s -> Fail"); // Fail.
- }
-
- function testLongStrings() {
- $text = "";
- for ($i = 0; $i < 10; $i++) {
- $text .= "0123456789";
- }
- $this->assertEqual($text . $text, $text . "a" . $text); // Fail.
- }
-}
-
-class Dummy {
- function Dummy() {
- }
-
- function a() {
- }
-}
-Mock::generate('Dummy');
-
-class TestOfMockObjectsOutput extends UnitTestCase {
-
- function testCallCounts() {
- $dummy = &new MockDummy();
- $dummy->expectCallCount('a', 1, 'My message: %s');
- $dummy->a();
- $dummy->a();
- }
-
- function testMinimumCallCounts() {
- $dummy = &new MockDummy();
- $dummy->expectMinimumCallCount('a', 2, 'My message: %s');
- $dummy->a();
- $dummy->a();
- }
-
- function testEmptyMatching() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array());
- $dummy->a();
- $dummy->a(null); // Fail.
- }
-
- function testEmptyMatchingWithCustomMessage() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array(), 'My expectation message: %s');
- $dummy->a();
- $dummy->a(null); // Fail.
- }
-
- function testNullMatching() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array(null));
- $dummy->a(null);
- $dummy->a(); // Fail.
- }
-
- function testBooleanMatching() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array(true, false));
- $dummy->a(true, false);
- $dummy->a(true, true); // Fail.
- }
-
- function testIntegerMatching() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array(32, 33));
- $dummy->a(32, 33);
- $dummy->a(32, 34); // Fail.
- }
-
- function testFloatMatching() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array(3.2, 3.3));
- $dummy->a(3.2, 3.3);
- $dummy->a(3.2, 3.4); // Fail.
- }
-
- function testStringMatching() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array('32', '33'));
- $dummy->a('32', '33');
- $dummy->a('32', '34'); // Fail.
- }
-
- function testEmptyMatchingWithCustomExpectationMessage() {
- $dummy = &new MockDummy();
- $dummy->expect(
- 'a',
- array(new EqualExpectation('A', 'My part expectation message: %s')),
- 'My expectation message: %s');
- $dummy->a('A');
- $dummy->a('B'); // Fail.
- }
-
- function testArrayMatching() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array(array(32), array(33)));
- $dummy->a(array(32), array(33));
- $dummy->a(array(32), array('33')); // Fail.
- }
-
- function testObjectMatching() {
- $a = new Dummy();
- $a->a = 'a';
- $b = new Dummy();
- $b->b = 'b';
- $dummy = &new MockDummy();
- $dummy->expect('a', array($a, $b));
- $dummy->a($a, $b);
- $dummy->a($a, $a); // Fail.
- }
-
- function testBigList() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array(false, 0, 1, 1.0));
- $dummy->a(false, 0, 1, 1.0);
- $dummy->a(true, false, 2, 2.0); // Fail.
- }
-}
-
-class TestOfPastBugs extends UnitTestCase {
-
- function testMixedTypes() {
- $this->assertEqual(array(), null, "%s -> Pass");
- $this->assertIdentical(array(), null, "%s -> Fail"); // Fail.
- }
-
- function testMockWildcards() {
- $dummy = &new MockDummy();
- $dummy->expect('a', array('*', array(33)));
- $dummy->a(array(32), array(33));
- $dummy->a(array(32), array('33')); // Fail.
- }
-}
-
-class TestOfVisualShell extends ShellTestCase {
-
- function testDump() {
- $this->execute('ls');
- $this->dumpOutput();
- $this->execute('dir');
- $this->dumpOutput();
- }
-
- function testDumpOfList() {
- $this->execute('ls');
- $this->dump($this->getOutputAsList());
- }
-}
-
-class PassesAsWellReporter extends HtmlReporter {
-
- protected function getCss() {
- return parent::getCss() . ' .pass { color: darkgreen; }';
- }
-
- function paintPass($message) {
- parent::paintPass($message);
- print "Pass : ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> " . htmlentities($message) . " \n";
- }
-
- function paintSignal($type, &$payload) {
- print "$type : ";
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- print implode(" -> ", $breadcrumb);
- print " -> " . htmlentities(serialize($payload)) . " \n";
- }
-}
-
-class TestOfSkippingNoMatterWhat extends UnitTestCase {
- function skip() {
- $this->skipIf(true, 'Always skipped -> %s');
- }
-
- function testFail() {
- $this->fail('This really shouldn\'t have happened');
- }
-}
-
-class TestOfSkippingOrElse extends UnitTestCase {
- function skip() {
- $this->skipUnless(false, 'Always skipped -> %s');
- }
-
- function testFail() {
- $this->fail('This really shouldn\'t have happened');
- }
-}
-
-class TestOfSkippingTwiceOver extends UnitTestCase {
- function skip() {
- $this->skipIf(true, 'First reason -> %s');
- $this->skipIf(true, 'Second reason -> %s');
- }
-
- function testFail() {
- $this->fail('This really shouldn\'t have happened');
- }
-}
-
-class TestThatShouldNotBeSkipped extends UnitTestCase {
- function skip() {
- $this->skipIf(false);
- $this->skipUnless(true);
- }
-
- function testFail() {
- $this->fail('We should see this message');
- }
-
- function testPass() {
- $this->pass('We should see this message');
- }
-}
-
-$test = &new TestSuite('Visual test with 46 passes, 47 fails and 0 exceptions');
-$test->add(new PassingUnitTestCaseOutput());
-$test->add(new FailingUnitTestCaseOutput());
-$test->add(new TestOfMockObjectsOutput());
-$test->add(new TestOfPastBugs());
-$test->add(new TestOfVisualShell());
-$test->add(new TestOfSkippingNoMatterWhat());
-$test->add(new TestOfSkippingOrElse());
-$test->add(new TestOfSkippingTwiceOver());
-$test->add(new TestThatShouldNotBeSkipped());
-
-if (isset($_GET['xml']) || in_array('xml', (isset($argv) ? $argv : array()))) {
- $reporter = new XmlReporter();
-} elseif (TextReporter::inCli()) {
- $reporter = new TextReporter();
-} else {
- $reporter = new PassesAsWellReporter();
-}
-if (isset($_GET['dry']) || in_array('dry', (isset($argv) ? $argv : array()))) {
- $reporter->makeDry();
-}
-exit ($test->run($reporter) ? 0 : 1);
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/web_tester_test.php b/core/vendors/simpletest/test/web_tester_test.php
deleted file mode 100755
index 8c3bf1a..0000000
--- a/core/vendors/simpletest/test/web_tester_test.php
+++ /dev/null
@@ -1,155 +0,0 @@
-assertTrue($expectation->test('a'));
- $this->assertTrue($expectation->test(array('a')));
- $this->assertFalse($expectation->test('A'));
- }
-
- function testMatchesInteger() {
- $expectation = new FieldExpectation('1');
- $this->assertTrue($expectation->test('1'));
- $this->assertTrue($expectation->test(1));
- $this->assertTrue($expectation->test(array('1')));
- $this->assertTrue($expectation->test(array(1)));
- }
-
- function testNonStringFailsExpectation() {
- $expectation = new FieldExpectation('a');
- $this->assertFalse($expectation->test(null));
- }
-
- function testUnsetFieldCanBeTestedFor() {
- $expectation = new FieldExpectation(false);
- $this->assertTrue($expectation->test(false));
- }
-
- function testMultipleValuesCanBeInAnyOrder() {
- $expectation = new FieldExpectation(array('a', 'b'));
- $this->assertTrue($expectation->test(array('a', 'b')));
- $this->assertTrue($expectation->test(array('b', 'a')));
- $this->assertFalse($expectation->test(array('a', 'a')));
- $this->assertFalse($expectation->test('a'));
- }
-
- function testSingleItemCanBeArrayOrString() {
- $expectation = new FieldExpectation(array('a'));
- $this->assertTrue($expectation->test(array('a')));
- $this->assertTrue($expectation->test('a'));
- }
-}
-
-class TestOfHeaderExpectations extends UnitTestCase {
-
- function testExpectingOnlyTheHeaderName() {
- $expectation = new HttpHeaderExpectation('a');
- $this->assertIdentical($expectation->test(false), false);
- $this->assertIdentical($expectation->test('a: A'), true);
- $this->assertIdentical($expectation->test('A: A'), true);
- $this->assertIdentical($expectation->test('a: B'), true);
- $this->assertIdentical($expectation->test(' a : A '), true);
- }
-
- function testHeaderValueAsWell() {
- $expectation = new HttpHeaderExpectation('a', 'A');
- $this->assertIdentical($expectation->test(false), false);
- $this->assertIdentical($expectation->test('a: A'), true);
- $this->assertIdentical($expectation->test('A: A'), true);
- $this->assertIdentical($expectation->test('A: a'), false);
- $this->assertIdentical($expectation->test('a: B'), false);
- $this->assertIdentical($expectation->test(' a : A '), true);
- $this->assertIdentical($expectation->test(' a : AB '), false);
- }
-
- function testHeaderValueWithColons() {
- $expectation = new HttpHeaderExpectation('a', 'A:B:C');
- $this->assertIdentical($expectation->test('a: A'), false);
- $this->assertIdentical($expectation->test('a: A:B'), false);
- $this->assertIdentical($expectation->test('a: A:B:C'), true);
- $this->assertIdentical($expectation->test('a: A:B:C:D'), false);
- }
-
- function testMultilineSearch() {
- $expectation = new HttpHeaderExpectation('a', 'A');
- $this->assertIdentical($expectation->test("aa: A\r\nb: B\r\nc: C"), false);
- $this->assertIdentical($expectation->test("aa: A\r\na: A\r\nb: B"), true);
- }
-
- function testMultilineSearchWithPadding() {
- $expectation = new HttpHeaderExpectation('a', ' A ');
- $this->assertIdentical($expectation->test("aa:A\r\nb:B\r\nc:C"), false);
- $this->assertIdentical($expectation->test("aa:A\r\na:A\r\nb:B"), true);
- }
-
- function testPatternMatching() {
- $expectation = new HttpHeaderExpectation('a', new PatternExpectation('/A/'));
- $this->assertIdentical($expectation->test('a: A'), true);
- $this->assertIdentical($expectation->test('A: A'), true);
- $this->assertIdentical($expectation->test('A: a'), false);
- $this->assertIdentical($expectation->test('a: B'), false);
- $this->assertIdentical($expectation->test(' a : A '), true);
- $this->assertIdentical($expectation->test(' a : AB '), true);
- }
-
- function testCaseInsensitivePatternMatching() {
- $expectation = new HttpHeaderExpectation('a', new PatternExpectation('/A/i'));
- $this->assertIdentical($expectation->test('a: a'), true);
- $this->assertIdentical($expectation->test('a: B'), false);
- $this->assertIdentical($expectation->test(' a : A '), true);
- $this->assertIdentical($expectation->test(' a : BAB '), true);
- $this->assertIdentical($expectation->test(' a : bab '), true);
- }
-
- function testUnwantedHeader() {
- $expectation = new NoHttpHeaderExpectation('a');
- $this->assertIdentical($expectation->test(''), true);
- $this->assertIdentical($expectation->test('stuff'), true);
- $this->assertIdentical($expectation->test('b: B'), true);
- $this->assertIdentical($expectation->test('a: A'), false);
- $this->assertIdentical($expectation->test('A: A'), false);
- }
-
- function testMultilineUnwantedSearch() {
- $expectation = new NoHttpHeaderExpectation('a');
- $this->assertIdentical($expectation->test("aa:A\r\nb:B\r\nc:C"), true);
- $this->assertIdentical($expectation->test("aa:A\r\na:A\r\nb:B"), false);
- }
-
- function testLocationHeaderSplitsCorrectly() {
- $expectation = new HttpHeaderExpectation('Location', 'http://here/');
- $this->assertIdentical($expectation->test('Location: http://here/'), true);
- }
-}
-
-class TestOfTextExpectations extends UnitTestCase {
-
- function testMatchingSubString() {
- $expectation = new TextExpectation('wanted');
- $this->assertIdentical($expectation->test(''), false);
- $this->assertIdentical($expectation->test('Wanted'), false);
- $this->assertIdentical($expectation->test('wanted'), true);
- $this->assertIdentical($expectation->test('the wanted text is here'), true);
- }
-
- function testNotMatchingSubString() {
- $expectation = new NoTextExpectation('wanted');
- $this->assertIdentical($expectation->test(''), true);
- $this->assertIdentical($expectation->test('Wanted'), true);
- $this->assertIdentical($expectation->test('wanted'), false);
- $this->assertIdentical($expectation->test('the wanted text is here'), false);
- }
-}
-
-class TestOfGenericAssertionsInWebTester extends WebTestCase {
- function testEquality() {
- $this->assertEqual('a', 'a');
- $this->assertNotEqual('a', 'A');
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test/xml_test.php b/core/vendors/simpletest/test/xml_test.php
deleted file mode 100755
index f99e0dc..0000000
--- a/core/vendors/simpletest/test/xml_test.php
+++ /dev/null
@@ -1,187 +0,0 @@
- 2));
- $this->assertEqual($nesting->getSize(), 2);
- }
-}
-
-class TestOfXmlStructureParsing extends UnitTestCase {
- function testValidXml() {
- $listener = new MockSimpleScorer();
- $listener->expectNever('paintGroupStart');
- $listener->expectNever('paintGroupEnd');
- $listener->expectNever('paintCaseStart');
- $listener->expectNever('paintCaseEnd');
- $parser = new SimpleTestXmlParser($listener);
- $this->assertTrue($parser->parse("\n"));
- $this->assertTrue($parser->parse("\n"));
- $this->assertTrue($parser->parse(" \n"));
- }
-
- function testEmptyGroup() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintGroupStart', array('a_group', 7));
- $listener->expectOnce('paintGroupEnd', array('a_group'));
- $parser = new SimpleTestXmlParser($listener);
- $parser->parse("\n");
- $parser->parse("\n");
- $this->assertTrue($parser->parse("\n"));
- $this->assertTrue($parser->parse("a_group \n"));
- $this->assertTrue($parser->parse(" \n"));
- $parser->parse(" \n");
- }
-
- function testEmptyCase() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintCaseStart', array('a_case'));
- $listener->expectOnce('paintCaseEnd', array('a_case'));
- $parser = new SimpleTestXmlParser($listener);
- $parser->parse("\n");
- $parser->parse("\n");
- $this->assertTrue($parser->parse("\n"));
- $this->assertTrue($parser->parse("a_case \n"));
- $this->assertTrue($parser->parse(" \n"));
- $parser->parse(" \n");
- }
-
- function testEmptyMethod() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintCaseStart', array('a_case'));
- $listener->expectOnce('paintCaseEnd', array('a_case'));
- $listener->expectOnce('paintMethodStart', array('a_method'));
- $listener->expectOnce('paintMethodEnd', array('a_method'));
- $parser = new SimpleTestXmlParser($listener);
- $parser->parse("\n");
- $parser->parse("\n");
- $parser->parse("\n");
- $parser->parse("a_case \n");
- $this->assertTrue($parser->parse("\n"));
- $this->assertTrue($parser->parse("a_method \n"));
- $this->assertTrue($parser->parse(" \n"));
- $parser->parse(" \n");
- $parser->parse(" \n");
- }
-
- function testNestedGroup() {
- $listener = new MockSimpleScorer();
- $listener->expectAt(0, 'paintGroupStart', array('a_group', 7));
- $listener->expectAt(1, 'paintGroupStart', array('b_group', 3));
- $listener->expectCallCount('paintGroupStart', 2);
- $listener->expectAt(0, 'paintGroupEnd', array('b_group'));
- $listener->expectAt(1, 'paintGroupEnd', array('a_group'));
- $listener->expectCallCount('paintGroupEnd', 2);
-
- $parser = new SimpleTestXmlParser($listener);
- $parser->parse("\n");
- $parser->parse("\n");
-
- $this->assertTrue($parser->parse("\n"));
- $this->assertTrue($parser->parse("a_group \n"));
- $this->assertTrue($parser->parse("\n"));
- $this->assertTrue($parser->parse("b_group \n"));
- $this->assertTrue($parser->parse(" \n"));
- $this->assertTrue($parser->parse(" \n"));
- $parser->parse(" \n");
- }
-}
-
-class AnyOldSignal {
- public $stuff = true;
-}
-
-class TestOfXmlResultsParsing extends UnitTestCase {
-
- function sendValidStart(&$parser) {
- $parser->parse("\n");
- $parser->parse("\n");
- $parser->parse("\n");
- $parser->parse("a_case \n");
- $parser->parse("\n");
- $parser->parse("a_method \n");
- }
-
- function sendValidEnd(&$parser) {
- $parser->parse(" \n");
- $parser->parse(" \n");
- $parser->parse(" \n");
- }
-
- function testPass() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintPass', array('a_message'));
- $parser = new SimpleTestXmlParser($listener);
- $this->sendValidStart($parser);
- $this->assertTrue($parser->parse("a_message \n"));
- $this->sendValidEnd($parser);
- }
-
- function testFail() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintFail', array('a_message'));
- $parser = new SimpleTestXmlParser($listener);
- $this->sendValidStart($parser);
- $this->assertTrue($parser->parse("a_message \n"));
- $this->sendValidEnd($parser);
- }
-
- function testException() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintError', array('a_message'));
- $parser = new SimpleTestXmlParser($listener);
- $this->sendValidStart($parser);
- $this->assertTrue($parser->parse("a_message \n"));
- $this->sendValidEnd($parser);
- }
-
- function testSkip() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintSkip', array('a_message'));
- $parser = new SimpleTestXmlParser($listener);
- $this->sendValidStart($parser);
- $this->assertTrue($parser->parse("a_message \n"));
- $this->sendValidEnd($parser);
- }
-
- function testSignal() {
- $signal = new AnyOldSignal();
- $signal->stuff = "Hello";
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintSignal', array('a_signal', $signal));
- $parser = new SimpleTestXmlParser($listener);
- $this->sendValidStart($parser);
- $this->assertTrue($parser->parse(
- " \n"));
- $this->sendValidEnd($parser);
- }
-
- function testMessage() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintMessage', array('a_message'));
- $parser = new SimpleTestXmlParser($listener);
- $this->sendValidStart($parser);
- $this->assertTrue($parser->parse("a_message \n"));
- $this->sendValidEnd($parser);
- }
-
- function testFormattedMessage() {
- $listener = new MockSimpleScorer();
- $listener->expectOnce('paintFormattedMessage', array("\na\tmessage\n"));
- $parser = new SimpleTestXmlParser($listener);
- $this->sendValidStart($parser);
- $this->assertTrue($parser->parse(" \n"));
- $this->sendValidEnd($parser);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/test_case.php b/core/vendors/simpletest/test_case.php
deleted file mode 100755
index ba023c3..0000000
--- a/core/vendors/simpletest/test_case.php
+++ /dev/null
@@ -1,658 +0,0 @@
-label = $label;
- }
- }
-
- /**
- * Accessor for the test name for subclasses.
- * @return string Name of the test.
- * @access public
- */
- function getLabel() {
- return $this->label ? $this->label : get_class($this);
- }
-
- /**
- * This is a placeholder for skipping tests. In this
- * method you place skipIf() and skipUnless() calls to
- * set the skipping state.
- * @access public
- */
- function skip() {
- }
-
- /**
- * Will issue a message to the reporter and tell the test
- * case to skip if the incoming flag is true.
- * @param string $should_skip Condition causing the tests to be skipped.
- * @param string $message Text of skip condition.
- * @access public
- */
- function skipIf($should_skip, $message = '%s') {
- if ($should_skip && ! $this->should_skip) {
- $this->should_skip = true;
- $message = sprintf($message, 'Skipping [' . get_class($this) . ']');
- $this->reporter->paintSkip($message . $this->getAssertionLine());
- }
- }
-
- /**
- * Accessor for the private variable $_shoud_skip
- * @access public
- */
- function shouldSkip() {
- return $this->should_skip;
- }
-
- /**
- * Will issue a message to the reporter and tell the test
- * case to skip if the incoming flag is false.
- * @param string $shouldnt_skip Condition causing the tests to be run.
- * @param string $message Text of skip condition.
- * @access public
- */
- function skipUnless($shouldnt_skip, $message = false) {
- $this->skipIf(! $shouldnt_skip, $message);
- }
-
- /**
- * Used to invoke the single tests.
- * @return SimpleInvoker Individual test runner.
- * @access public
- */
- function createInvoker() {
- return new SimpleErrorTrappingInvoker(
- new SimpleExceptionTrappingInvoker(new SimpleInvoker($this)));
- }
-
- /**
- * Uses reflection to run every method within itself
- * starting with the string "test" unless a method
- * is specified.
- * @param SimpleReporter $reporter Current test reporter.
- * @return boolean True if all tests passed.
- * @access public
- */
- function run($reporter) {
- $context = SimpleTest::getContext();
- $context->setTest($this);
- $context->setReporter($reporter);
- $this->reporter = $reporter;
- $started = false;
- foreach ($this->getTests() as $method) {
- if ($reporter->shouldInvoke($this->getLabel(), $method)) {
- $this->skip();
- if ($this->should_skip) {
- break;
- }
- if (! $started) {
- $reporter->paintCaseStart($this->getLabel());
- $started = true;
- }
- $invoker = $this->reporter->createInvoker($this->createInvoker());
- $invoker->before($method);
- $invoker->invoke($method);
- $invoker->after($method);
- }
- }
- if ($started) {
- $reporter->paintCaseEnd($this->getLabel());
- }
- unset($this->reporter);
- $context->setTest(null);
- return $reporter->getStatus();
- }
-
- /**
- * Gets a list of test names. Normally that will
- * be all internal methods that start with the
- * name "test". This method should be overridden
- * if you want a different rule.
- * @return array List of test names.
- * @access public
- */
- function getTests() {
- $methods = array();
- foreach (get_class_methods(get_class($this)) as $method) {
- if ($this->isTest($method)) {
- $methods[] = $method;
- }
- }
- return $methods;
- }
-
- /**
- * Tests to see if the method is a test that should
- * be run. Currently any method that starts with 'test'
- * is a candidate unless it is the constructor.
- * @param string $method Method name to try.
- * @return boolean True if test method.
- * @access protected
- */
- protected function isTest($method) {
- if (strtolower(substr($method, 0, 4)) == 'test') {
- return ! SimpleTestCompatibility::isA($this, strtolower($method));
- }
- return false;
- }
-
- /**
- * Announces the start of the test.
- * @param string $method Test method just started.
- * @access public
- */
- function before($method) {
- $this->reporter->paintMethodStart($method);
- $this->observers = array();
- }
-
- /**
- * Sets up unit test wide variables at the start
- * of each test method. To be overridden in
- * actual user test cases.
- * @access public
- */
- function setUp() {
- }
-
- /**
- * Clears the data set in the setUp() method call.
- * To be overridden by the user in actual user test cases.
- * @access public
- */
- function tearDown() {
- }
-
- /**
- * Announces the end of the test. Includes private clean up.
- * @param string $method Test method just finished.
- * @access public
- */
- function after($method) {
- for ($i = 0; $i < count($this->observers); $i++) {
- $this->observers[$i]->atTestEnd($method, $this);
- }
- $this->reporter->paintMethodEnd($method);
- }
-
- /**
- * Sets up an observer for the test end.
- * @param object $observer Must have atTestEnd()
- * method.
- * @access public
- */
- function tell($observer) {
- $this->observers[] = &$observer;
- }
-
- /**
- * @deprecated
- */
- function pass($message = "Pass") {
- if (! isset($this->reporter)) {
- trigger_error('Can only make assertions within test methods');
- }
- $this->reporter->paintPass(
- $message . $this->getAssertionLine());
- return true;
- }
-
- /**
- * Sends a fail event with a message.
- * @param string $message Message to send.
- * @access public
- */
- function fail($message = "Fail") {
- if (! isset($this->reporter)) {
- trigger_error('Can only make assertions within test methods');
- }
- $this->reporter->paintFail(
- $message . $this->getAssertionLine());
- return false;
- }
-
- /**
- * Formats a PHP error and dispatches it to the
- * reporter.
- * @param integer $severity PHP error code.
- * @param string $message Text of error.
- * @param string $file File error occoured in.
- * @param integer $line Line number of error.
- * @access public
- */
- function error($severity, $message, $file, $line) {
- if (! isset($this->reporter)) {
- trigger_error('Can only make assertions within test methods');
- }
- $this->reporter->paintError(
- "Unexpected PHP error [$message] severity [$severity] in [$file line $line]");
- }
-
- /**
- * Formats an exception and dispatches it to the
- * reporter.
- * @param Exception $exception Object thrown.
- * @access public
- */
- function exception($exception) {
- $this->reporter->paintException($exception);
- }
-
- /**
- * For user defined expansion of the available messages.
- * @param string $type Tag for sorting the signals.
- * @param mixed $payload Extra user specific information.
- */
- function signal($type, $payload) {
- if (! isset($this->reporter)) {
- trigger_error('Can only make assertions within test methods');
- }
- $this->reporter->paintSignal($type, $payload);
- }
-
- /**
- * Runs an expectation directly, for extending the
- * tests with new expectation classes.
- * @param SimpleExpectation $expectation Expectation subclass.
- * @param mixed $compare Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assert($expectation, $compare, $message = '%s') {
- if ($expectation->test($compare)) {
- return $this->pass(sprintf(
- $message,
- $expectation->overlayMessage($compare, $this->reporter->getDumper())));
- } else {
- return $this->fail(sprintf(
- $message,
- $expectation->overlayMessage($compare, $this->reporter->getDumper())));
- }
- }
-
- /**
- * Uses a stack trace to find the line of an assertion.
- * @return string Line number of first assert*
- * method embedded in format string.
- * @access public
- */
- function getAssertionLine() {
- $trace = new SimpleStackTrace(array('assert', 'expect', 'pass', 'fail', 'skip'));
- return $trace->traceMethod();
- }
-
- /**
- * Sends a formatted dump of a variable to the
- * test suite for those emergency debugging
- * situations.
- * @param mixed $variable Variable to display.
- * @param string $message Message to display.
- * @return mixed The original variable.
- * @access public
- */
- function dump($variable, $message = false) {
- $dumper = $this->reporter->getDumper();
- $formatted = $dumper->dump($variable);
- if ($message) {
- $formatted = $message . "\n" . $formatted;
- }
- $this->reporter->paintFormattedMessage($formatted);
- return $variable;
- }
-
- /**
- * Accessor for the number of subtests including myelf.
- * @return integer Number of test cases.
- * @access public
- */
- function getSize() {
- return 1;
- }
-}
-
-/**
- * Helps to extract test cases automatically from a file.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class SimpleFileLoader {
-
- /**
- * Builds a test suite from a library of test cases.
- * The new suite is composed into this one.
- * @param string $test_file File name of library with
- * test case classes.
- * @return TestSuite The new test suite.
- * @access public
- */
- function load($test_file) {
- $existing_classes = get_declared_classes();
- $existing_globals = get_defined_vars();
- include_once($test_file);
- $new_globals = get_defined_vars();
- $this->makeFileVariablesGlobal($existing_globals, $new_globals);
- $new_classes = array_diff(get_declared_classes(), $existing_classes);
- if (empty($new_classes)) {
- $new_classes = $this->scrapeClassesFromFile($test_file);
- }
- $classes = $this->selectRunnableTests($new_classes);
- return $this->createSuiteFromClasses($test_file, $classes);
- }
-
- /**
- * Imports new variables into the global namespace.
- * @param hash $existing Variables before the file was loaded.
- * @param hash $new Variables after the file was loaded.
- * @access private
- */
- protected function makeFileVariablesGlobal($existing, $new) {
- $globals = array_diff(array_keys($new), array_keys($existing));
- foreach ($globals as $global) {
- $GLOBALS[$global] = $new[$global];
- }
- }
-
- /**
- * Lookup classnames from file contents, in case the
- * file may have been included before.
- * Note: This is probably too clever by half. Figuring this
- * out after a failed test case is going to be tricky for us,
- * never mind the user. A test case should not be included
- * twice anyway.
- * @param string $test_file File name with classes.
- * @access private
- */
- protected function scrapeClassesFromFile($test_file) {
- preg_match_all('~^\s*class\s+(\w+)(\s+(extends|implements)\s+\w+)*\s*\{~mi',
- file_get_contents($test_file),
- $matches );
- return $matches[1];
- }
-
- /**
- * Calculates the incoming test cases. Skips abstract
- * and ignored classes.
- * @param array $candidates Candidate classes.
- * @return array New classes which are test
- * cases that shouldn't be ignored.
- * @access public
- */
- function selectRunnableTests($candidates) {
- $classes = array();
- foreach ($candidates as $class) {
- if (TestSuite::getBaseTestCase($class)) {
- $reflection = new SimpleReflection($class);
- if ($reflection->isAbstract()) {
- SimpleTest::ignore($class);
- } else {
- $classes[] = $class;
- }
- }
- }
- return $classes;
- }
-
- /**
- * Builds a test suite from a class list.
- * @param string $title Title of new group.
- * @param array $classes Test classes.
- * @return TestSuite Group loaded with the new
- * test cases.
- * @access public
- */
- function createSuiteFromClasses($title, $classes) {
- if (count($classes) == 0) {
- $suite = new BadTestSuite($title, "No runnable test cases in [$title]");
- return $suite;
- }
- SimpleTest::ignoreParentsIfIgnored($classes);
- $suite = new TestSuite($title);
- foreach ($classes as $class) {
- if (! SimpleTest::isIgnored($class)) {
- $suite->add($class);
- }
- }
- return $suite;
- }
-}
-
-/**
- * This is a composite test class for combining
- * test cases and other RunnableTest classes into
- * a group test.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class TestSuite {
- private $label;
- private $test_cases;
-
- /**
- * Sets the name of the test suite.
- * @param string $label Name sent at the start and end
- * of the test.
- * @access public
- */
- function TestSuite($label = false) {
- $this->label = $label;
- $this->test_cases = array();
- }
-
- /**
- * Accessor for the test name for subclasses. If the suite
- * wraps a single test case the label defaults to the name of that test.
- * @return string Name of the test.
- * @access public
- */
- function getLabel() {
- if (! $this->label) {
- return ($this->getSize() == 1) ?
- get_class($this->test_cases[0]) : get_class($this);
- } else {
- return $this->label;
- }
- }
-
- /**
- * Adds a test into the suite by instance or class. The class will
- * be instantiated if it's a test suite.
- * @param SimpleTestCase $test_case Suite or individual test
- * case implementing the
- * runnable test interface.
- * @access public
- */
- function add($test_case) {
- if (! is_string($test_case)) {
- $this->test_cases[] = $test_case;
- } elseif (TestSuite::getBaseTestCase($test_case) == 'testsuite') {
- $this->test_cases[] = new $test_case();
- } else {
- $this->test_cases[] = $test_case;
- }
- }
-
- /**
- * Builds a test suite from a library of test cases.
- * The new suite is composed into this one.
- * @param string $test_file File name of library with
- * test case classes.
- * @access public
- */
- function addFile($test_file) {
- $extractor = new SimpleFileLoader();
- $this->add($extractor->load($test_file));
- }
-
- /**
- * Delegates to a visiting collector to add test
- * files.
- * @param string $path Path to scan from.
- * @param SimpleCollector $collector Directory scanner.
- * @access public
- */
- function collect($path, $collector) {
- $collector->collect($this, $path);
- }
-
- /**
- * Invokes run() on all of the held test cases, instantiating
- * them if necessary.
- * @param SimpleReporter $reporter Current test reporter.
- * @access public
- */
- function run($reporter) {
- $reporter->paintGroupStart($this->getLabel(), $this->getSize());
- for ($i = 0, $count = count($this->test_cases); $i < $count; $i++) {
- if (is_string($this->test_cases[$i])) {
- $class = $this->test_cases[$i];
- $test = new $class();
- $test->run($reporter);
- unset($test);
- } else {
- $this->test_cases[$i]->run($reporter);
- }
- }
- $reporter->paintGroupEnd($this->getLabel());
- return $reporter->getStatus();
- }
-
- /**
- * Number of contained test cases.
- * @return integer Total count of cases in the group.
- * @access public
- */
- function getSize() {
- $count = 0;
- foreach ($this->test_cases as $case) {
- if (is_string($case)) {
- if (! SimpleTest::isIgnored($case)) {
- $count++;
- }
- } else {
- $count += $case->getSize();
- }
- }
- return $count;
- }
-
- /**
- * Test to see if a class is derived from the
- * SimpleTestCase class.
- * @param string $class Class name.
- * @access public
- */
- static function getBaseTestCase($class) {
- while ($class = get_parent_class($class)) {
- $class = strtolower($class);
- if ($class == 'simpletestcase' || $class == 'testsuite') {
- return $class;
- }
- }
- return false;
- }
-}
-
-/**
- * This is a failing group test for when a test suite hasn't
- * loaded properly.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class BadTestSuite {
- private $label;
- private $error;
-
- /**
- * Sets the name of the test suite and error message.
- * @param string $label Name sent at the start and end
- * of the test.
- * @access public
- */
- function BadTestSuite($label, $error) {
- $this->label = $label;
- $this->error = $error;
- }
-
- /**
- * Accessor for the test name for subclasses.
- * @return string Name of the test.
- * @access public
- */
- function getLabel() {
- return $this->label;
- }
-
- /**
- * Sends a single error to the reporter.
- * @param SimpleReporter $reporter Current test reporter.
- * @access public
- */
- function run($reporter) {
- $reporter->paintGroupStart($this->getLabel(), $this->getSize());
- $reporter->paintFail('Bad TestSuite [' . $this->getLabel() .
- '] with error [' . $this->error . ']');
- $reporter->paintGroupEnd($this->getLabel());
- return $reporter->getStatus();
- }
-
- /**
- * Number of contained test cases. Always zero.
- * @return integer Total count of cases in the group.
- * @access public
- */
- function getSize() {
- return 0;
- }
-}
-?>
diff --git a/core/vendors/simpletest/tidy_parser.php b/core/vendors/simpletest/tidy_parser.php
deleted file mode 100755
index 3d8b4b2..0000000
--- a/core/vendors/simpletest/tidy_parser.php
+++ /dev/null
@@ -1,382 +0,0 @@
-free();
- }
-
- /**
- * Frees up any references so as to allow the PHP garbage
- * collection from unset() to work.
- */
- private function free() {
- unset($this->page);
- $this->forms = array();
- $this->labels = array();
- }
-
- /**
- * This builder is only available if the 'tidy' extension is loaded.
- * @return boolean True if available.
- */
- function can() {
- return extension_loaded('tidy');
- }
-
- /**
- * Reads the raw content the page using HTML Tidy.
- * @param $response SimpleHttpResponse Fetched response.
- * @return SimplePage Newly parsed page.
- */
- function parse($response) {
- $this->page = new SimplePage($response);
- $tidied = tidy_parse_string($input = $this->insertGuards($response->getContent()),
- array('output-xml' => false, 'wrap' => '0', 'indent' => 'no'),
- 'latin1');
- $this->walkTree($tidied->html());
- $this->attachLabels($this->widgets_by_id, $this->labels);
- $this->page->setForms($this->forms);
- $page = $this->page;
- $this->free();
- return $page;
- }
-
- /**
- * Stops HTMLTidy stripping content that we wish to preserve.
- * @param string The raw html.
- * @return string The html with guard tags inserted.
- */
- private function insertGuards($html) {
- return $this->insertEmptyTagGuards($this->insertTextareaSimpleWhitespaceGuards($html));
- }
-
- /**
- * Removes the extra content added during the parse stage
- * in order to preserve content we don't want stripped
- * out by HTMLTidy.
- * @param string The raw html.
- * @return string The html with guard tags removed.
- */
- private function stripGuards($html) {
- return $this->stripTextareaWhitespaceGuards($this->stripEmptyTagGuards($html));
- }
-
- /**
- * HTML tidy strips out empty tags such as which we
- * need to preserve. This method inserts an additional marker.
- * @param string The raw html.
- * @return string The html with guards inserted.
- */
- private function insertEmptyTagGuards($html) {
- return preg_replace('#<(option|textarea)([^>]*)>(\s*)(option|textarea)>#is',
- '<\1\2>___EMPTY___\3\4>',
- $html);
- }
-
- /**
- * HTML tidy strips out empty tags such as which we
- * need to preserve. This method strips additional markers
- * inserted by SimpleTest to the tidy output used to make the
- * tags non-empty. This ensures their preservation.
- * @param string The raw html.
- * @return string The html with guards removed.
- */
- private function stripEmptyTagGuards($html) {
- return preg_replace('#(^|>)(\s*)___EMPTY___(\s*)(|$)#i', '\2\3', $html);
- }
-
- /**
- * By parsing the XML output of tidy, we lose some whitespace
- * information in textarea tags. We temporarily recode this
- * data ourselves so as not to lose it.
- * @param string The raw html.
- * @return string The html with guards inserted.
- */
- private function insertTextareaSimpleWhitespaceGuards($html) {
- return preg_replace_callback('#]*)>(.*?) #is',
- array($this, 'insertWhitespaceGuards'),
- $html);
- }
-
- /**
- * Callback for insertTextareaSimpleWhitespaceGuards().
- * @param array $matches Result of preg_replace_callback().
- * @return string Guard tags now replace whitespace.
- */
- private function insertWhitespaceGuards($matches) {
- return '' .
- str_replace(array("\n", "\r", "\t", ' '),
- array('___NEWLINE___', '___CR___', '___TAB___', '___SPACE___'),
- $matches[2]) .
- ' ';
- }
-
- /**
- * Removes the whitespace preserving guards we added
- * before parsing.
- * @param string The raw html.
- * @return string The html with guards removed.
- */
- private function stripTextareaWhitespaceGuards($html) {
- return str_replace(array('___NEWLINE___', '___CR___', '___TAB___', '___SPACE___'),
- array("\n", "\r", "\t", ' '),
- $html);
- }
-
- /**
- * Visits the given node and all children
- * @param object $node Tidy XML node.
- */
- private function walkTree($node) {
- if ($node->name == 'a') {
- $this->page->addLink($this->tags()->createTag($node->name, (array)$node->attribute)
- ->addContent($this->innerHtml($node)));
- } elseif ($node->name == 'base' and isset($node->attribute['href'])) {
- $this->page->setBase($node->attribute['href']);
- } elseif ($node->name == 'title') {
- $this->page->setTitle($this->tags()->createTag($node->name, (array)$node->attribute)
- ->addContent($this->innerHtml($node)));
- } elseif ($node->name == 'frameset') {
- $this->page->setFrames($this->collectFrames($node));
- } elseif ($node->name == 'form') {
- $this->forms[] = $this->walkForm($node, $this->createEmptyForm($node));
- } elseif ($node->name == 'label') {
- $this->labels[] = $this->tags()->createTag($node->name, (array)$node->attribute)
- ->addContent($this->innerHtml($node));
- } else {
- $this->walkChildren($node);
- }
- }
-
- /**
- * Helper method for traversing the XML tree.
- * @param object $node Tidy XML node.
- */
- private function walkChildren($node) {
- if ($node->hasChildren()) {
- foreach ($node->child as $child) {
- $this->walkTree($child);
- }
- }
- }
-
- /**
- * Facade for forms containing preparsed widgets.
- * @param object $node Tidy XML node.
- * @return SimpleForm Facade for SimpleBrowser.
- */
- private function createEmptyForm($node) {
- return new SimpleForm($this->tags()->createTag($node->name, (array)$node->attribute), $this->page);
- }
-
- /**
- * Visits the given node and all children
- * @param object $node Tidy XML node.
- */
- private function walkForm($node, $form, $enclosing_label = '') {
- if ($node->name == 'a') {
- $this->page->addLink($this->tags()->createTag($node->name, (array)$node->attribute)
- ->addContent($this->innerHtml($node)));
- } elseif (in_array($node->name, array('input', 'button', 'textarea', 'select'))) {
- $this->addWidgetToForm($node, $form, $enclosing_label);
- } elseif ($node->name == 'label') {
- $this->labels[] = $this->tags()->createTag($node->name, (array)$node->attribute)
- ->addContent($this->innerHtml($node));
- if ($node->hasChildren()) {
- foreach ($node->child as $child) {
- $this->walkForm($child, $form, SimplePage::normalise($this->innerHtml($node)));
- }
- }
- } elseif ($node->hasChildren()) {
- foreach ($node->child as $child) {
- $this->walkForm($child, $form);
- }
- }
- return $form;
- }
-
- /**
- * Tests a node for a "for" atribute. Used for
- * attaching labels.
- * @param object $node Tidy XML node.
- * @return boolean True if the "for" attribute exists.
- */
- private function hasFor($node) {
- return isset($node->attribute) and $node->attribute['for'];
- }
-
- /**
- * Adds the widget into the form container.
- * @param object $node Tidy XML node of widget.
- * @param SimpleForm $form Form to add it to.
- * @param string $enclosing_label The label of any label
- * tag we might be in.
- */
- private function addWidgetToForm($node, $form, $enclosing_label) {
- $widget = $this->tags()->createTag($node->name, $this->attributes($node));
- if (! $widget) {
- return;
- }
- $widget->setLabel($enclosing_label)
- ->addContent($this->innerHtml($node));
- if ($node->name == 'select') {
- $widget->addTags($this->collectSelectOptions($node));
- }
- $form->addWidget($widget);
- $this->indexWidgetById($widget);
- }
-
- /**
- * Fills the widget cache to speed up searching.
- * @param SimpleTag $widget Parsed widget to cache.
- */
- private function indexWidgetById($widget) {
- $id = $widget->getAttribute('id');
- if (! $id) {
- return;
- }
- if (! isset($this->widgets_by_id[$id])) {
- $this->widgets_by_id[$id] = array();
- }
- $this->widgets_by_id[$id][] = $widget;
- }
-
- /**
- * Parses the options from inside an XML select node.
- * @param object $node Tidy XML node.
- * @return array List of SimpleTag options.
- */
- private function collectSelectOptions($node) {
- $options = array();
- if ($node->name == 'option') {
- $options[] = $this->tags()->createTag($node->name, $this->attributes($node))
- ->addContent($this->innerHtml($node));
- }
- if ($node->hasChildren()) {
- foreach ($node->child as $child) {
- $options = array_merge($options, $this->collectSelectOptions($child));
- }
- }
- return $options;
- }
-
- /**
- * Convenience method for collecting all the attributes
- * of a tag. Not sure why Tidy does not have this.
- * @param object $node Tidy XML node.
- * @return array Hash of attribute strings.
- */
- private function attributes($node) {
- if (! preg_match('|<[^ ]+\s(.*?)/?>|s', $node->value, $first_tag_contents)) {
- return array();
- }
- $attributes = array();
- preg_match_all('/\S+\s*=\s*\'[^\']*\'|(\S+\s*=\s*"[^"]*")|([^ =]+\s*=\s*[^ "\']+?)|[^ "\']+/', $first_tag_contents[1], $matches);
- foreach($matches[0] as $unparsed) {
- $attributes = $this->mergeAttribute($attributes, $unparsed);
- }
- return $attributes;
- }
-
- /**
- * Overlay an attribute into the attributes hash.
- * @param array $attributes Current attribute list.
- * @param string $raw Raw attribute string with
- * both key and value.
- * @return array New attribute hash.
- */
- private function mergeAttribute($attributes, $raw) {
- $parts = explode('=', $raw);
- list($name, $value) = count($parts) == 1 ? array($parts[0], $parts[0]) : $parts;
- $attributes[trim($name)] = html_entity_decode($this->dequote(trim($value)), ENT_QUOTES);
- return $attributes;
- }
-
- /**
- * Remove start and end quotes.
- * @param string $quoted A quoted string.
- * @return string Quotes are gone.
- */
- private function dequote($quoted) {
- if (preg_match('/^(\'([^\']*)\'|"([^"]*)")$/', $quoted, $matches)) {
- return isset($matches[3]) ? $matches[3] : $matches[2];
- }
- return $quoted;
- }
-
- /**
- * Collects frame information inside a frameset tag.
- * @param object $node Tidy XML node.
- * @return array List of SimpleTag frame descriptions.
- */
- private function collectFrames($node) {
- $frames = array();
- if ($node->name == 'frame') {
- $frames = array($this->tags()->createTag($node->name, (array)$node->attribute));
- } else if ($node->hasChildren()) {
- $frames = array();
- foreach ($node->child as $child) {
- $frames = array_merge($frames, $this->collectFrames($child));
- }
- }
- return $frames;
- }
-
- /**
- * Extracts the XML node text.
- * @param object $node Tidy XML node.
- * @return string The text only.
- */
- private function innerHtml($node) {
- $raw = '';
- if ($node->hasChildren()) {
- foreach ($node->child as $child) {
- $raw .= $child->value;
- }
- }
- return $this->stripGuards($raw);
- }
-
- /**
- * Factory for parsed content holders.
- * @return SimpleTagBuilder Factory.
- */
- private function tags() {
- return new SimpleTagBuilder();
- }
-
- /**
- * Called at the end of a parse run. Attaches any
- * non-wrapping labels to their form elements.
- * @param array $widgets_by_id Cached SimpleTag hash.
- * @param array $labels SimpleTag label elements.
- */
- private function attachLabels($widgets_by_id, $labels) {
- foreach ($labels as $label) {
- $for = $label->getFor();
- if ($for and isset($widgets_by_id[$for])) {
- $text = $label->getText();
- foreach ($widgets_by_id[$for] as $widget) {
- $widget->setLabel($text);
- }
- }
- }
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/unit_tester.php b/core/vendors/simpletest/unit_tester.php
deleted file mode 100755
index ce82660..0000000
--- a/core/vendors/simpletest/unit_tester.php
+++ /dev/null
@@ -1,413 +0,0 @@
-assert(new TrueExpectation(), $result, $message);
- }
-
- /**
- * Will be true on false and vice versa. False
- * is the PHP definition of false, so that null,
- * empty strings, zero and an empty array all count
- * as false.
- * @param boolean $result Pass on false.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertFalse($result, $message = '%s') {
- return $this->assert(new FalseExpectation(), $result, $message);
- }
-
- /**
- * Will be true if the value is null.
- * @param null $value Supposedly null value.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertNull($value, $message = '%s') {
- $dumper = new SimpleDumper();
- $message = sprintf(
- $message,
- '[' . $dumper->describeValue($value) . '] should be null');
- return $this->assertTrue(! isset($value), $message);
- }
-
- /**
- * Will be true if the value is set.
- * @param mixed $value Supposedly set value.
- * @param string $message Message to display.
- * @return boolean True on pass.
- * @access public
- */
- function assertNotNull($value, $message = '%s') {
- $dumper = new SimpleDumper();
- $message = sprintf(
- $message,
- '[' . $dumper->describeValue($value) . '] should not be null');
- return $this->assertTrue(isset($value), $message);
- }
-
- /**
- * Type and class test. Will pass if class
- * matches the type name or is a subclass or
- * if not an object, but the type is correct.
- * @param mixed $object Object to test.
- * @param string $type Type name as string.
- * @param string $message Message to display.
- * @return boolean True on pass.
- * @access public
- */
- function assertIsA($object, $type, $message = '%s') {
- return $this->assert(
- new IsAExpectation($type),
- $object,
- $message);
- }
-
- /**
- * Type and class mismatch test. Will pass if class
- * name or underling type does not match the one
- * specified.
- * @param mixed $object Object to test.
- * @param string $type Type name as string.
- * @param string $message Message to display.
- * @return boolean True on pass.
- * @access public
- */
- function assertNotA($object, $type, $message = '%s') {
- return $this->assert(
- new NotAExpectation($type),
- $object,
- $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * the same value only. Otherwise a fail.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertEqual($first, $second, $message = '%s') {
- return $this->assert(
- new EqualExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * a different value. Otherwise a fail.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertNotEqual($first, $second, $message = '%s') {
- return $this->assert(
- new NotEqualExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if the if the first parameter
- * is near enough to the second by the margin.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param mixed $margin Fuzziness of match.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertWithinMargin($first, $second, $margin, $message = '%s') {
- return $this->assert(
- new WithinMarginExpectation($first, $margin),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if the two parameters differ
- * by more than the margin.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param mixed $margin Fuzziness of match.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertOutsideMargin($first, $second, $margin, $message = '%s') {
- return $this->assert(
- new OutsideMarginExpectation($first, $margin),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * the same value and same type. Otherwise a fail.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertIdentical($first, $second, $message = '%s') {
- return $this->assert(
- new IdenticalExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * the different value or different type.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertNotIdentical($first, $second, $message = '%s') {
- return $this->assert(
- new NotIdenticalExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if both parameters refer
- * to the same object or value. Fail otherwise.
- * This will cause problems testing objects under
- * E_STRICT.
- * TODO: Replace with expectation.
- * @param mixed $first Reference to check.
- * @param mixed $second Hopefully the same variable.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertReference(&$first, &$second, $message = '%s') {
- $dumper = new SimpleDumper();
- $message = sprintf(
- $message,
- '[' . $dumper->describeValue($first) .
- '] and [' . $dumper->describeValue($second) .
- '] should reference the same object');
- return $this->assertTrue(
- SimpleTestCompatibility::isReference($first, $second),
- $message);
- }
-
- /**
- * Will trigger a pass if both parameters refer
- * to the same object. Fail otherwise. This has
- * the same semantics at the PHPUnit assertSame.
- * That is, if values are passed in it has roughly
- * the same affect as assertIdentical.
- * TODO: Replace with expectation.
- * @param mixed $first Object reference to check.
- * @param mixed $second Hopefully the same object.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertSame($first, $second, $message = '%s') {
- $dumper = new SimpleDumper();
- $message = sprintf(
- $message,
- '[' . $dumper->describeValue($first) .
- '] and [' . $dumper->describeValue($second) .
- '] should reference the same object');
- return $this->assertTrue($first === $second, $message);
- }
-
- /**
- * Will trigger a pass if both parameters refer
- * to different objects. Fail otherwise. The objects
- * have to be identical though.
- * @param mixed $first Object reference to check.
- * @param mixed $second Hopefully not the same object.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertClone($first, $second, $message = '%s') {
- $dumper = new SimpleDumper();
- $message = sprintf(
- $message,
- '[' . $dumper->describeValue($first) .
- '] and [' . $dumper->describeValue($second) .
- '] should not be the same object');
- $identical = new IdenticalExpectation($first);
- return $this->assertTrue(
- $identical->test($second) && ! ($first === $second),
- $message);
- }
-
- /**
- * Will trigger a pass if both parameters refer
- * to different variables. Fail otherwise. The objects
- * have to be identical references though.
- * This will fail under E_STRICT with objects. Use
- * assertClone() for this.
- * @param mixed $first Object reference to check.
- * @param mixed $second Hopefully not the same object.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertCopy(&$first, &$second, $message = "%s") {
- $dumper = new SimpleDumper();
- $message = sprintf(
- $message,
- "[" . $dumper->describeValue($first) .
- "] and [" . $dumper->describeValue($second) .
- "] should not be the same object");
- return $this->assertFalse(
- SimpleTestCompatibility::isReference($first, $second),
- $message);
- }
-
- /**
- * Will trigger a pass if the Perl regex pattern
- * is found in the subject. Fail otherwise.
- * @param string $pattern Perl regex to look for including
- * the regex delimiters.
- * @param string $subject String to search in.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertPattern($pattern, $subject, $message = '%s') {
- return $this->assert(
- new PatternExpectation($pattern),
- $subject,
- $message);
- }
-
- /**
- * Will trigger a pass if the perl regex pattern
- * is not present in subject. Fail if found.
- * @param string $pattern Perl regex to look for including
- * the regex delimiters.
- * @param string $subject String to search in.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertNoPattern($pattern, $subject, $message = '%s') {
- return $this->assert(
- new NoPatternExpectation($pattern),
- $subject,
- $message);
- }
-
- /**
- * Prepares for an error. If the error mismatches it
- * passes through, otherwise it is swallowed. Any
- * left over errors trigger failures.
- * @param SimpleExpectation/string $expected The error to match.
- * @param string $message Message on failure.
- * @access public
- */
- function expectError($expected = false, $message = '%s') {
- $queue = SimpleTest::getContext()->get('SimpleErrorQueue');
- $queue->expectError($this->coerceExpectation($expected), $message);
- }
-
- /**
- * Prepares for an exception. If the error mismatches it
- * passes through, otherwise it is swallowed. Any
- * left over errors trigger failures.
- * @param SimpleExpectation/Exception $expected The error to match.
- * @param string $message Message on failure.
- * @access public
- */
- function expectException($expected = false, $message = '%s') {
- $queue = SimpleTest::getContext()->get('SimpleExceptionTrap');
- $line = $this->getAssertionLine();
- $queue->expectException($expected, $message . $line);
- }
-
- /**
- * Tells SimpleTest to ignore an upcoming exception as not relevant
- * to the current test. It doesn't affect the test, whether thrown or
- * not.
- * @param SimpleExpectation/Exception $ignored The error to ignore.
- * @access public
- */
- function ignoreException($ignored = false) {
- SimpleTest::getContext()->get('SimpleExceptionTrap')->ignoreException($ignored);
- }
-
- /**
- * Creates an equality expectation if the
- * object/value is not already some type
- * of expectation.
- * @param mixed $expected Expected value.
- * @return SimpleExpectation Expectation object.
- * @access private
- */
- protected function coerceExpectation($expected) {
- if ($expected == false) {
- return new TrueExpectation();
- }
- if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) {
- return $expected;
- }
- return new EqualExpectation(
- is_string($expected) ? str_replace('%', '%%', $expected) : $expected);
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/url.php b/core/vendors/simpletest/url.php
deleted file mode 100755
index 11d70e7..0000000
--- a/core/vendors/simpletest/url.php
+++ /dev/null
@@ -1,550 +0,0 @@
-chompCoordinates($url);
- $this->setCoordinates($x, $y);
- $this->scheme = $this->chompScheme($url);
- if ($this->scheme === 'file') {
- // Unescaped backslashes not used in directory separator context
- // will get caught by this, but they should have been urlencoded
- // anyway so we don't care. If this ends up being a problem, the
- // host regexp must be modified to match for backslashes when
- // the scheme is file.
- $url = str_replace('\\', '/', $url);
- }
- list($this->username, $this->password) = $this->chompLogin($url);
- $this->host = $this->chompHost($url);
- $this->port = false;
- if (preg_match('/(.*?):(.*)/', $this->host, $host_parts)) {
- if ($this->scheme === 'file' && strlen($this->host) === 2) {
- // DOS drive was placed in authority; promote it to path.
- $url = '/' . $this->host . $url;
- $this->host = false;
- } else {
- $this->host = $host_parts[1];
- $this->port = (integer)$host_parts[2];
- }
- }
- $this->path = $this->chompPath($url);
- $this->request = $this->parseRequest($this->chompRequest($url));
- $this->fragment = (strncmp($url, "#", 1) == 0 ? substr($url, 1) : false);
- $this->target = false;
- }
-
- /**
- * Extracts the X, Y coordinate pair from an image map.
- * @param string $url URL so far. The coordinates will be
- * removed.
- * @return array X, Y as a pair of integers.
- * @access private
- */
- protected function chompCoordinates(&$url) {
- if (preg_match('/(.*)\?(\d+),(\d+)$/', $url, $matches)) {
- $url = $matches[1];
- return array((integer)$matches[2], (integer)$matches[3]);
- }
- return array(false, false);
- }
-
- /**
- * Extracts the scheme part of an incoming URL.
- * @param string $url URL so far. The scheme will be
- * removed.
- * @return string Scheme part or false.
- * @access private
- */
- protected function chompScheme(&$url) {
- if (preg_match('#^([^/:]*):(//)(.*)#', $url, $matches)) {
- $url = $matches[2] . $matches[3];
- return $matches[1];
- }
- return false;
- }
-
- /**
- * Extracts the username and password from the
- * incoming URL. The // prefix will be reattached
- * to the URL after the doublet is extracted.
- * @param string $url URL so far. The username and
- * password are removed.
- * @return array Two item list of username and
- * password. Will urldecode() them.
- * @access private
- */
- protected function chompLogin(&$url) {
- $prefix = '';
- if (preg_match('#^(//)(.*)#', $url, $matches)) {
- $prefix = $matches[1];
- $url = $matches[2];
- }
- if (preg_match('#^([^/]*)@(.*)#', $url, $matches)) {
- $url = $prefix . $matches[2];
- $parts = explode(":", $matches[1]);
- return array(
- urldecode($parts[0]),
- isset($parts[1]) ? urldecode($parts[1]) : false);
- }
- $url = $prefix . $url;
- return array(false, false);
- }
-
- /**
- * Extracts the host part of an incoming URL.
- * Includes the port number part. Will extract
- * the host if it starts with // or it has
- * a top level domain or it has at least two
- * dots.
- * @param string $url URL so far. The host will be
- * removed.
- * @return string Host part guess or false.
- * @access private
- */
- protected function chompHost(&$url) {
- if (preg_match('!^(//)(.*?)(/.*|\?.*|#.*|$)!', $url, $matches)) {
- $url = $matches[3];
- return $matches[2];
- }
- if (preg_match('!(.*?)(\.\./|\./|/|\?|#|$)(.*)!', $url, $matches)) {
- $tlds = SimpleUrl::getAllTopLevelDomains();
- if (preg_match('/[a-z0-9\-]+\.(' . $tlds . ')/i', $matches[1])) {
- $url = $matches[2] . $matches[3];
- return $matches[1];
- } elseif (preg_match('/[a-z0-9\-]+\.[a-z0-9\-]+\.[a-z0-9\-]+/i', $matches[1])) {
- $url = $matches[2] . $matches[3];
- return $matches[1];
- }
- }
- return false;
- }
-
- /**
- * Extracts the path information from the incoming
- * URL. Strips this path from the URL.
- * @param string $url URL so far. The host will be
- * removed.
- * @return string Path part or '/'.
- * @access private
- */
- protected function chompPath(&$url) {
- if (preg_match('/(.*?)(\?|#|$)(.*)/', $url, $matches)) {
- $url = $matches[2] . $matches[3];
- return ($matches[1] ? $matches[1] : '');
- }
- return '';
- }
-
- /**
- * Strips off the request data.
- * @param string $url URL so far. The request will be
- * removed.
- * @return string Raw request part.
- * @access private
- */
- protected function chompRequest(&$url) {
- if (preg_match('/\?(.*?)(#|$)(.*)/', $url, $matches)) {
- $url = $matches[2] . $matches[3];
- return $matches[1];
- }
- return '';
- }
-
- /**
- * Breaks the request down into an object.
- * @param string $raw Raw request.
- * @return SimpleFormEncoding Parsed data.
- * @access private
- */
- protected function parseRequest($raw) {
- $this->raw = $raw;
- $request = new SimpleGetEncoding();
- foreach (explode("&", $raw) as $pair) {
- if (preg_match('/(.*?)=(.*)/', $pair, $matches)) {
- $request->add(urldecode($matches[1]), urldecode($matches[2]));
- } elseif ($pair) {
- $request->add(urldecode($pair), '');
- }
- }
- return $request;
- }
-
- /**
- * Accessor for protocol part.
- * @param string $default Value to use if not present.
- * @return string Scheme name, e.g "http".
- * @access public
- */
- function getScheme($default = false) {
- return $this->scheme ? $this->scheme : $default;
- }
-
- /**
- * Accessor for user name.
- * @return string Username preceding host.
- * @access public
- */
- function getUsername() {
- return $this->username;
- }
-
- /**
- * Accessor for password.
- * @return string Password preceding host.
- * @access public
- */
- function getPassword() {
- return $this->password;
- }
-
- /**
- * Accessor for hostname and port.
- * @param string $default Value to use if not present.
- * @return string Hostname only.
- * @access public
- */
- function getHost($default = false) {
- return $this->host ? $this->host : $default;
- }
-
- /**
- * Accessor for top level domain.
- * @return string Last part of host.
- * @access public
- */
- function getTld() {
- $path_parts = pathinfo($this->getHost());
- return (isset($path_parts['extension']) ? $path_parts['extension'] : false);
- }
-
- /**
- * Accessor for port number.
- * @return integer TCP/IP port number.
- * @access public
- */
- function getPort() {
- return $this->port;
- }
-
- /**
- * Accessor for path.
- * @return string Full path including leading slash if implied.
- * @access public
- */
- function getPath() {
- if (! $this->path && $this->host) {
- return '/';
- }
- return $this->path;
- }
-
- /**
- * Accessor for page if any. This may be a
- * directory name if ambiguious.
- * @return Page name.
- * @access public
- */
- function getPage() {
- if (! preg_match('/([^\/]*?)$/', $this->getPath(), $matches)) {
- return false;
- }
- return $matches[1];
- }
-
- /**
- * Gets the path to the page.
- * @return string Path less the page.
- * @access public
- */
- function getBasePath() {
- if (! preg_match('/(.*\/)[^\/]*?$/', $this->getPath(), $matches)) {
- return false;
- }
- return $matches[1];
- }
-
- /**
- * Accessor for fragment at end of URL after the "#".
- * @return string Part after "#".
- * @access public
- */
- function getFragment() {
- return $this->fragment;
- }
-
- /**
- * Sets image coordinates. Set to false to clear
- * them.
- * @param integer $x Horizontal position.
- * @param integer $y Vertical position.
- * @access public
- */
- function setCoordinates($x = false, $y = false) {
- if (($x === false) || ($y === false)) {
- $this->x = $this->y = false;
- return;
- }
- $this->x = (integer)$x;
- $this->y = (integer)$y;
- }
-
- /**
- * Accessor for horizontal image coordinate.
- * @return integer X value.
- * @access public
- */
- function getX() {
- return $this->x;
- }
-
- /**
- * Accessor for vertical image coordinate.
- * @return integer Y value.
- * @access public
- */
- function getY() {
- return $this->y;
- }
-
- /**
- * Accessor for current request parameters
- * in URL string form. Will return teh original request
- * if at all possible even if it doesn't make much
- * sense.
- * @return string Form is string "?a=1&b=2", etc.
- * @access public
- */
- function getEncodedRequest() {
- if ($this->raw) {
- $encoded = $this->raw;
- } else {
- $encoded = $this->request->asUrlRequest();
- }
- if ($encoded) {
- return '?' . preg_replace('/^\?/', '', $encoded);
- }
- return '';
- }
-
- /**
- * Adds an additional parameter to the request.
- * @param string $key Name of parameter.
- * @param string $value Value as string.
- * @access public
- */
- function addRequestParameter($key, $value) {
- $this->raw = false;
- $this->request->add($key, $value);
- }
-
- /**
- * Adds additional parameters to the request.
- * @param hash/SimpleFormEncoding $parameters Additional
- * parameters.
- * @access public
- */
- function addRequestParameters($parameters) {
- $this->raw = false;
- $this->request->merge($parameters);
- }
-
- /**
- * Clears down all parameters.
- * @access public
- */
- function clearRequest() {
- $this->raw = false;
- $this->request = new SimpleGetEncoding();
- }
-
- /**
- * Gets the frame target if present. Although
- * not strictly part of the URL specification it
- * acts as similarily to the browser.
- * @return boolean/string Frame name or false if none.
- * @access public
- */
- function getTarget() {
- return $this->target;
- }
-
- /**
- * Attaches a frame target.
- * @param string $frame Name of frame.
- * @access public
- */
- function setTarget($frame) {
- $this->raw = false;
- $this->target = $frame;
- }
-
- /**
- * Renders the URL back into a string.
- * @return string URL in canonical form.
- * @access public
- */
- function asString() {
- $path = $this->path;
- $scheme = $identity = $host = $port = $encoded = $fragment = '';
- if ($this->username && $this->password) {
- $identity = $this->username . ':' . $this->password . '@';
- }
- if ($this->getHost()) {
- $scheme = $this->getScheme() ? $this->getScheme() : 'http';
- $scheme .= '://';
- $host = $this->getHost();
- } elseif ($this->getScheme() === 'file') {
- // Safest way; otherwise, file URLs on Windows have an extra
- // leading slash. It might be possible to convert file://
- // URIs to local file paths, but that requires more research.
- $scheme = 'file://';
- }
- if ($this->getPort() && $this->getPort() != 80 ) {
- $port = ':'.$this->getPort();
- }
-
- if (substr($this->path, 0, 1) == '/') {
- $path = $this->normalisePath($this->path);
- }
- $encoded = $this->getEncodedRequest();
- $fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
- $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
- return "$scheme$identity$host$port$path$encoded$fragment$coords";
- }
-
- /**
- * Replaces unknown sections to turn a relative
- * URL into an absolute one. The base URL can
- * be either a string or a SimpleUrl object.
- * @param string/SimpleUrl $base Base URL.
- * @access public
- */
- function makeAbsolute($base) {
- if (! is_object($base)) {
- $base = new SimpleUrl($base);
- }
- if ($this->getHost()) {
- $scheme = $this->getScheme();
- $host = $this->getHost();
- $port = $this->getPort() ? ':' . $this->getPort() : '';
- $identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
- if (! $identity) {
- $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
- }
- } else {
- $scheme = $base->getScheme();
- $host = $base->getHost();
- $port = $base->getPort() ? ':' . $base->getPort() : '';
- $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
- }
- $path = $this->normalisePath($this->extractAbsolutePath($base));
- $encoded = $this->getEncodedRequest();
- $fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
- $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
- return new SimpleUrl("$scheme://$identity$host$port$path$encoded$fragment$coords");
- }
-
- /**
- * Replaces unknown sections of the path with base parts
- * to return a complete absolute one.
- * @param string/SimpleUrl $base Base URL.
- * @param string Absolute path.
- * @access private
- */
- protected function extractAbsolutePath($base) {
- if ($this->getHost()) {
- return $this->path;
- }
- if (! $this->isRelativePath($this->path)) {
- return $this->path;
- }
- if ($this->path) {
- return $base->getBasePath() . $this->path;
- }
- return $base->getPath();
- }
-
- /**
- * Simple test to see if a path part is relative.
- * @param string $path Path to test.
- * @return boolean True if starts with a "/".
- * @access private
- */
- protected function isRelativePath($path) {
- return (substr($path, 0, 1) != '/');
- }
-
- /**
- * Extracts the username and password for use in rendering
- * a URL.
- * @return string/boolean Form of username:password or false.
- * @access public
- */
- function getIdentity() {
- if ($this->username && $this->password) {
- return $this->username . ':' . $this->password;
- }
- return false;
- }
-
- /**
- * Replaces . and .. sections of the path.
- * @param string $path Unoptimised path.
- * @return string Path with dots removed if possible.
- * @access public
- */
- function normalisePath($path) {
- $path = preg_replace('|/\./|', '/', $path);
- return preg_replace('|/[^/]+/\.\./|', '/', $path);
- }
-
- /**
- * A pipe seperated list of all TLDs that result in two part
- * domain names.
- * @return string Pipe separated list.
- * @access public
- */
- static function getAllTopLevelDomains() {
- return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum';
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/user_agent.php b/core/vendors/simpletest/user_agent.php
deleted file mode 100755
index ea53602..0000000
--- a/core/vendors/simpletest/user_agent.php
+++ /dev/null
@@ -1,328 +0,0 @@
-cookie_jar = new SimpleCookieJar();
- $this->authenticator = new SimpleAuthenticator();
- }
-
- /**
- * Removes expired and temporary cookies as if
- * the browser was closed and re-opened. Authorisation
- * has to be obtained again as well.
- * @param string/integer $date Time when session restarted.
- * If omitted then all persistent
- * cookies are kept.
- * @access public
- */
- function restart($date = false) {
- $this->cookie_jar->restartSession($date);
- $this->authenticator->restartSession();
- }
-
- /**
- * Adds a header to every fetch.
- * @param string $header Header line to add to every
- * request until cleared.
- * @access public
- */
- function addHeader($header) {
- $this->additional_headers[] = $header;
- }
-
- /**
- * Ages the cookies by the specified time.
- * @param integer $interval Amount in seconds.
- * @access public
- */
- function ageCookies($interval) {
- $this->cookie_jar->agePrematurely($interval);
- }
-
- /**
- * Sets an additional cookie. If a cookie has
- * the same name and path it is replaced.
- * @param string $name Cookie key.
- * @param string $value Value of cookie.
- * @param string $host Host upon which the cookie is valid.
- * @param string $path Cookie path if not host wide.
- * @param string $expiry Expiry date.
- * @access public
- */
- function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
- $this->cookie_jar->setCookie($name, $value, $host, $path, $expiry);
- }
-
- /**
- * Reads the most specific cookie value from the
- * browser cookies.
- * @param string $host Host to search.
- * @param string $path Applicable path.
- * @param string $name Name of cookie to read.
- * @return string False if not present, else the
- * value as a string.
- * @access public
- */
- function getCookieValue($host, $path, $name) {
- return $this->cookie_jar->getCookieValue($host, $path, $name);
- }
-
- /**
- * Reads the current cookies within the base URL.
- * @param string $name Key of cookie to find.
- * @param SimpleUrl $base Base URL to search from.
- * @return string/boolean Null if there is no base URL, false
- * if the cookie is not set.
- * @access public
- */
- function getBaseCookieValue($name, $base) {
- if (! $base) {
- return null;
- }
- return $this->getCookieValue($base->getHost(), $base->getPath(), $name);
- }
-
- /**
- * Switches off cookie sending and recieving.
- * @access public
- */
- function ignoreCookies() {
- $this->cookies_enabled = false;
- }
-
- /**
- * Switches back on the cookie sending and recieving.
- * @access public
- */
- function useCookies() {
- $this->cookies_enabled = true;
- }
-
- /**
- * Sets the socket timeout for opening a connection.
- * @param integer $timeout Maximum time in seconds.
- * @access public
- */
- function setConnectionTimeout($timeout) {
- $this->connection_timeout = $timeout;
- }
-
- /**
- * Sets the maximum number of redirects before
- * a page will be loaded anyway.
- * @param integer $max Most hops allowed.
- * @access public
- */
- function setMaximumRedirects($max) {
- $this->max_redirects = $max;
- }
-
- /**
- * Sets proxy to use on all requests for when
- * testing from behind a firewall. Set URL
- * to false to disable.
- * @param string $proxy Proxy URL.
- * @param string $username Proxy username for authentication.
- * @param string $password Proxy password for authentication.
- * @access public
- */
- function useProxy($proxy, $username, $password) {
- if (! $proxy) {
- $this->proxy = false;
- return;
- }
- if ((strncmp($proxy, 'http://', 7) != 0) && (strncmp($proxy, 'https://', 8) != 0)) {
- $proxy = 'http://'. $proxy;
- }
- $this->proxy = new SimpleUrl($proxy);
- $this->proxy_username = $username;
- $this->proxy_password = $password;
- }
-
- /**
- * Test to see if the redirect limit is passed.
- * @param integer $redirects Count so far.
- * @return boolean True if over.
- * @access private
- */
- protected function isTooManyRedirects($redirects) {
- return ($redirects > $this->max_redirects);
- }
-
- /**
- * Sets the identity for the current realm.
- * @param string $host Host to which realm applies.
- * @param string $realm Full name of realm.
- * @param string $username Username for realm.
- * @param string $password Password for realm.
- * @access public
- */
- function setIdentity($host, $realm, $username, $password) {
- $this->authenticator->setIdentityForRealm($host, $realm, $username, $password);
- }
-
- /**
- * Fetches a URL as a response object. Will keep trying if redirected.
- * It will also collect authentication realm information.
- * @param string/SimpleUrl $url Target to fetch.
- * @param SimpleEncoding $encoding Additional parameters for request.
- * @return SimpleHttpResponse Hopefully the target page.
- * @access public
- */
- function fetchResponse($url, $encoding) {
- if ($encoding->getMethod() != 'POST') {
- $url->addRequestParameters($encoding);
- $encoding->clear();
- }
- $response = $this->fetchWhileRedirected($url, $encoding);
- if ($headers = $response->getHeaders()) {
- if ($headers->isChallenge()) {
- $this->authenticator->addRealm(
- $url,
- $headers->getAuthentication(),
- $headers->getRealm());
- }
- }
- return $response;
- }
-
- /**
- * Fetches the page until no longer redirected or
- * until the redirect limit runs out.
- * @param SimpleUrl $url Target to fetch.
- * @param SimpelFormEncoding $encoding Additional parameters for request.
- * @return SimpleHttpResponse Hopefully the target page.
- * @access private
- */
- protected function fetchWhileRedirected($url, $encoding) {
- $redirects = 0;
- do {
- $response = $this->fetch($url, $encoding);
- if ($response->isError()) {
- return $response;
- }
- $headers = $response->getHeaders();
- if ($this->cookies_enabled) {
- $headers->writeCookiesToJar($this->cookie_jar, $url);
- }
- if (! $headers->isRedirect()) {
- break;
- }
- $location = new SimpleUrl($headers->getLocation());
- $url = $location->makeAbsolute($url);
- $encoding = new SimpleGetEncoding();
- } while (! $this->isTooManyRedirects(++$redirects));
- return $response;
- }
-
- /**
- * Actually make the web request.
- * @param SimpleUrl $url Target to fetch.
- * @param SimpleFormEncoding $encoding Additional parameters for request.
- * @return SimpleHttpResponse Headers and hopefully content.
- * @access protected
- */
- protected function fetch($url, $encoding) {
- $request = $this->createRequest($url, $encoding);
- return $request->fetch($this->connection_timeout);
- }
-
- /**
- * Creates a full page request.
- * @param SimpleUrl $url Target to fetch as url object.
- * @param SimpleFormEncoding $encoding POST/GET parameters.
- * @return SimpleHttpRequest New request.
- * @access private
- */
- protected function createRequest($url, $encoding) {
- $request = $this->createHttpRequest($url, $encoding);
- $this->addAdditionalHeaders($request);
- if ($this->cookies_enabled) {
- $request->readCookiesFromJar($this->cookie_jar, $url);
- }
- $this->authenticator->addHeaders($request, $url);
- return $request;
- }
-
- /**
- * Builds the appropriate HTTP request object.
- * @param SimpleUrl $url Target to fetch as url object.
- * @param SimpleFormEncoding $parameters POST/GET parameters.
- * @return SimpleHttpRequest New request object.
- * @access protected
- */
- protected function createHttpRequest($url, $encoding) {
- return new SimpleHttpRequest($this->createRoute($url), $encoding);
- }
-
- /**
- * Sets up either a direct route or via a proxy.
- * @param SimpleUrl $url Target to fetch as url object.
- * @return SimpleRoute Route to take to fetch URL.
- * @access protected
- */
- protected function createRoute($url) {
- if ($this->proxy) {
- return new SimpleProxyRoute(
- $url,
- $this->proxy,
- $this->proxy_username,
- $this->proxy_password);
- }
- return new SimpleRoute($url);
- }
-
- /**
- * Adds additional manual headers.
- * @param SimpleHttpRequest $request Outgoing request.
- * @access private
- */
- protected function addAdditionalHeaders(&$request) {
- foreach ($this->additional_headers as $header) {
- $request->addHeaderLine($header);
- }
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/web_tester.php b/core/vendors/simpletest/web_tester.php
deleted file mode 100755
index a17230e..0000000
--- a/core/vendors/simpletest/web_tester.php
+++ /dev/null
@@ -1,1532 +0,0 @@
-value = $value;
- }
-
- /**
- * Tests the expectation. True if it matches
- * a string value or an array value in any order.
- * @param mixed $compare Comparison value. False for
- * an unset field.
- * @return boolean True if correct.
- * @access public
- */
- function test($compare) {
- if ($this->value === false) {
- return ($compare === false);
- }
- if ($this->isSingle($this->value)) {
- return $this->testSingle($compare);
- }
- if (is_array($this->value)) {
- return $this->testMultiple($compare);
- }
- return false;
- }
-
- /**
- * Tests for valid field comparisons with a single option.
- * @param mixed $value Value to type check.
- * @return boolean True if integer, string or float.
- * @access private
- */
- protected function isSingle($value) {
- return is_string($value) || is_integer($value) || is_float($value);
- }
-
- /**
- * String comparison for simple field with a single option.
- * @param mixed $compare String to test against.
- * @returns boolean True if matching.
- * @access private
- */
- protected function testSingle($compare) {
- if (is_array($compare) && count($compare) == 1) {
- $compare = $compare[0];
- }
- if (! $this->isSingle($compare)) {
- return false;
- }
- return ($this->value == $compare);
- }
-
- /**
- * List comparison for multivalue field.
- * @param mixed $compare List in any order to test against.
- * @returns boolean True if matching.
- * @access private
- */
- protected function testMultiple($compare) {
- if (is_string($compare)) {
- $compare = array($compare);
- }
- if (! is_array($compare)) {
- return false;
- }
- sort($compare);
- return ($this->value === $compare);
- }
-
- /**
- * Returns a human readable test message.
- * @param mixed $compare Comparison value.
- * @return string Description of success
- * or failure.
- * @access public
- */
- function testMessage($compare) {
- $dumper = $this->getDumper();
- if (is_array($compare)) {
- sort($compare);
- }
- if ($this->test($compare)) {
- return "Field expectation [" . $dumper->describeValue($this->value) . "]";
- } else {
- return "Field expectation [" . $dumper->describeValue($this->value) .
- "] fails with [" .
- $dumper->describeValue($compare) . "] " .
- $dumper->describeDifference($this->value, $compare);
- }
- }
-}
-
-/**
- * Test for a specific HTTP header within a header block.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class HttpHeaderExpectation extends SimpleExpectation {
- private $expected_header;
- private $expected_value;
-
- /**
- * Sets the field and value to compare against.
- * @param string $header Case insenstive trimmed header name.
- * @param mixed $value Optional value to compare. If not
- * given then any value will match. If
- * an expectation object then that will
- * be used instead.
- * @param string $message Optiona message override. Can use %s as
- * a placeholder for the original message.
- */
- function __construct($header, $value = false, $message = '%s') {
- parent::__construct($message);
- $this->expected_header = $this->normaliseHeader($header);
- $this->expected_value = $value;
- }
-
- /**
- * Accessor for aggregated object.
- * @return mixed Expectation set in constructor.
- * @access protected
- */
- protected function getExpectation() {
- return $this->expected_value;
- }
-
- /**
- * Removes whitespace at ends and case variations.
- * @param string $header Name of header.
- * @param string Trimmed and lowecased header
- * name.
- * @access private
- */
- protected function normaliseHeader($header) {
- return strtolower(trim($header));
- }
-
- /**
- * Tests the expectation. True if it matches
- * a string value or an array value in any order.
- * @param mixed $compare Raw header block to search.
- * @return boolean True if header present.
- * @access public
- */
- function test($compare) {
- return is_string($this->findHeader($compare));
- }
-
- /**
- * Searches the incoming result. Will extract the matching
- * line as text.
- * @param mixed $compare Raw header block to search.
- * @return string Matching header line.
- * @access protected
- */
- protected function findHeader($compare) {
- $lines = explode("\r\n", $compare);
- foreach ($lines as $line) {
- if ($this->testHeaderLine($line)) {
- return $line;
- }
- }
- return false;
- }
-
- /**
- * Compares a single header line against the expectation.
- * @param string $line A single line to compare.
- * @return boolean True if matched.
- * @access private
- */
- protected function testHeaderLine($line) {
- if (count($parsed = explode(':', $line, 2)) < 2) {
- return false;
- }
- list($header, $value) = $parsed;
- if ($this->normaliseHeader($header) != $this->expected_header) {
- return false;
- }
- return $this->testHeaderValue($value, $this->expected_value);
- }
-
- /**
- * Tests the value part of the header.
- * @param string $value Value to test.
- * @param mixed $expected Value to test against.
- * @return boolean True if matched.
- * @access protected
- */
- protected function testHeaderValue($value, $expected) {
- if ($expected === false) {
- return true;
- }
- if (SimpleExpectation::isExpectation($expected)) {
- return $expected->test(trim($value));
- }
- return (trim($value) == trim($expected));
- }
-
- /**
- * Returns a human readable test message.
- * @param mixed $compare Raw header block to search.
- * @return string Description of success
- * or failure.
- * @access public
- */
- function testMessage($compare) {
- if (SimpleExpectation::isExpectation($this->expected_value)) {
- $message = $this->expected_value->overlayMessage($compare, $this->getDumper());
- } else {
- $message = $this->expected_header .
- ($this->expected_value ? ': ' . $this->expected_value : '');
- }
- if (is_string($line = $this->findHeader($compare))) {
- return "Searching for header [$message] found [$line]";
- } else {
- return "Failed to find header [$message]";
- }
- }
-}
-
-/**
- * Test for a specific HTTP header within a header block that
- * should not be found.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class NoHttpHeaderExpectation extends HttpHeaderExpectation {
- private $expected_header;
- private $expected_value;
-
- /**
- * Sets the field and value to compare against.
- * @param string $unwanted Case insenstive trimmed header name.
- * @param string $message Optiona message override. Can use %s as
- * a placeholder for the original message.
- */
- function __construct($unwanted, $message = '%s') {
- parent::__construct($unwanted, false, $message);
- }
-
- /**
- * Tests that the unwanted header is not found.
- * @param mixed $compare Raw header block to search.
- * @return boolean True if header present.
- * @access public
- */
- function test($compare) {
- return ($this->findHeader($compare) === false);
- }
-
- /**
- * Returns a human readable test message.
- * @param mixed $compare Raw header block to search.
- * @return string Description of success
- * or failure.
- * @access public
- */
- function testMessage($compare) {
- $expectation = $this->getExpectation();
- if (is_string($line = $this->findHeader($compare))) {
- return "Found unwanted header [$expectation] with [$line]";
- } else {
- return "Did not find unwanted header [$expectation]";
- }
- }
-}
-
-/**
- * Test for a text substring.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class TextExpectation extends SimpleExpectation {
- private $substring;
-
- /**
- * Sets the value to compare against.
- * @param string $substring Text to search for.
- * @param string $message Customised message on failure.
- * @access public
- */
- function __construct($substring, $message = '%s') {
- parent::__construct($message);
- $this->substring = $substring;
- }
-
- /**
- * Accessor for the substring.
- * @return string Text to match.
- * @access protected
- */
- protected function getSubstring() {
- return $this->substring;
- }
-
- /**
- * Tests the expectation. True if the text contains the
- * substring.
- * @param string $compare Comparison value.
- * @return boolean True if correct.
- * @access public
- */
- function test($compare) {
- return (strpos($compare, $this->substring) !== false);
- }
-
- /**
- * Returns a human readable test message.
- * @param mixed $compare Comparison value.
- * @return string Description of success
- * or failure.
- * @access public
- */
- function testMessage($compare) {
- if ($this->test($compare)) {
- return $this->describeTextMatch($this->getSubstring(), $compare);
- } else {
- $dumper = $this->getDumper();
- return "Text [" . $this->getSubstring() .
- "] not detected in [" .
- $dumper->describeValue($compare) . "]";
- }
- }
-
- /**
- * Describes a pattern match including the string
- * found and it's position.
- * @param string $substring Text to search for.
- * @param string $subject Subject to search.
- * @access protected
- */
- protected function describeTextMatch($substring, $subject) {
- $position = strpos($subject, $substring);
- $dumper = $this->getDumper();
- return "Text [$substring] detected at character [$position] in [" .
- $dumper->describeValue($subject) . "] in region [" .
- $dumper->clipString($subject, 100, $position) . "]";
- }
-}
-
-/**
- * Fail if a substring is detected within the
- * comparison text.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class NoTextExpectation extends TextExpectation {
-
- /**
- * Sets the reject pattern
- * @param string $substring Text to search for.
- * @param string $message Customised message on failure.
- * @access public
- */
- function __construct($substring, $message = '%s') {
- parent::__construct($substring, $message);
- }
-
- /**
- * Tests the expectation. False if the substring appears
- * in the text.
- * @param string $compare Comparison value.
- * @return boolean True if correct.
- * @access public
- */
- function test($compare) {
- return ! parent::test($compare);
- }
-
- /**
- * Returns a human readable test message.
- * @param string $compare Comparison value.
- * @return string Description of success
- * or failure.
- * @access public
- */
- function testMessage($compare) {
- if ($this->test($compare)) {
- $dumper = $this->getDumper();
- return "Text [" . $this->getSubstring() .
- "] not detected in [" .
- $dumper->describeValue($compare) . "]";
- } else {
- return $this->describeTextMatch($this->getSubstring(), $compare);
- }
- }
-}
-
-/**
- * Test case for testing of web pages. Allows
- * fetching of pages, parsing of HTML and
- * submitting forms.
- * @package SimpleTest
- * @subpackage WebTester
- */
-class WebTestCase extends SimpleTestCase {
- private $browser;
- private $ignore_errors = false;
-
- /**
- * Creates an empty test case. Should be subclassed
- * with test methods for a functional test case.
- * @param string $label Name of test case. Will use
- * the class name if none specified.
- * @access public
- */
- function __construct($label = false) {
- parent::__construct($label);
- }
-
- /**
- * Announces the start of the test.
- * @param string $method Test method just started.
- * @access public
- */
- function before($method) {
- parent::before($method);
- $this->setBrowser($this->createBrowser());
- }
-
- /**
- * Announces the end of the test. Includes private clean up.
- * @param string $method Test method just finished.
- * @access public
- */
- function after($method) {
- $this->unsetBrowser();
- parent::after($method);
- }
-
- /**
- * Gets a current browser reference for setting
- * special expectations or for detailed
- * examination of page fetches.
- * @return SimpleBrowser Current test browser object.
- * @access public
- */
- function getBrowser() {
- return $this->browser;
- }
-
- /**
- * Gets a current browser reference for setting
- * special expectations or for detailed
- * examination of page fetches.
- * @param SimpleBrowser $browser New test browser object.
- * @access public
- */
- function setBrowser($browser) {
- return $this->browser = $browser;
- }
-
- /**
- * Sets the HTML parser to use within this browser.
- * @param object The parser, one of SimplePHPPageBuilder or
- * SimpleTidyPageBuilder.
- */
- function setParser($parser) {
- $this->browser->setParser($parser);
- }
-
- /**
- * Clears the current browser reference to help the
- * PHP garbage collector.
- * @access public
- */
- function unsetBrowser() {
- unset($this->browser);
- }
-
- /**
- * Creates a new default web browser object.
- * Will be cleared at the end of the test method.
- * @return TestBrowser New browser.
- * @access public
- */
- function createBrowser() {
- return new SimpleBrowser();
- }
-
- /**
- * Gets the last response error.
- * @return string Last low level HTTP error.
- * @access public
- */
- function getTransportError() {
- return $this->browser->getTransportError();
- }
-
- /**
- * Accessor for the currently selected URL.
- * @return string Current location or false if
- * no page yet fetched.
- * @access public
- */
- function getUrl() {
- return $this->browser->getUrl();
- }
-
- /**
- * Dumps the current request for debugging.
- * @access public
- */
- function showRequest() {
- $this->dump($this->browser->getRequest());
- }
-
- /**
- * Dumps the current HTTP headers for debugging.
- * @access public
- */
- function showHeaders() {
- $this->dump($this->browser->getHeaders());
- }
-
- /**
- * Dumps the current HTML source for debugging.
- * @access public
- */
- function showSource() {
- $this->dump($this->browser->getContent());
- }
-
- /**
- * Dumps the visible text only for debugging.
- * @access public
- */
- function showText() {
- $this->dump(wordwrap($this->browser->getContentAsText(), 80));
- }
-
- /**
- * Simulates the closing and reopening of the browser.
- * Temporary cookies will be discarded and timed
- * cookies will be expired if later than the
- * specified time.
- * @param string/integer $date Time when session restarted.
- * If ommitted then all persistent
- * cookies are kept. Time is either
- * Cookie format string or timestamp.
- * @access public
- */
- function restart($date = false) {
- if ($date === false) {
- $date = time();
- }
- $this->browser->restart($date);
- }
-
- /**
- * Moves cookie expiry times back into the past.
- * Useful for testing timeouts and expiries.
- * @param integer $interval Amount to age in seconds.
- * @access public
- */
- function ageCookies($interval) {
- $this->browser->ageCookies($interval);
- }
-
- /**
- * Disables frames support. Frames will not be fetched
- * and the frameset page will be used instead.
- * @access public
- */
- function ignoreFrames() {
- $this->browser->ignoreFrames();
- }
-
- /**
- * Switches off cookie sending and recieving.
- * @access public
- */
- function ignoreCookies() {
- $this->browser->ignoreCookies();
- }
-
- /**
- * Skips errors for the next request only. You might
- * want to confirm that a page is unreachable for
- * example.
- * @access public
- */
- function ignoreErrors() {
- $this->ignore_errors = true;
- }
-
- /**
- * Issues a fail if there is a transport error anywhere
- * in the current frameset. Only one such error is
- * reported.
- * @param string/boolean $result HTML or failure.
- * @return string/boolean $result Passes through result.
- * @access private
- */
- protected function failOnError($result) {
- if (! $this->ignore_errors) {
- if ($error = $this->browser->getTransportError()) {
- $this->fail($error);
- }
- }
- $this->ignore_errors = false;
- return $result;
- }
-
- /**
- * Adds a header to every fetch.
- * @param string $header Header line to add to every
- * request until cleared.
- * @access public
- */
- function addHeader($header) {
- $this->browser->addHeader($header);
- }
-
- /**
- * Sets the maximum number of redirects before
- * the web page is loaded regardless.
- * @param integer $max Maximum hops.
- * @access public
- */
- function setMaximumRedirects($max) {
- if (! $this->browser) {
- trigger_error(
- 'Can only set maximum redirects in a test method, setUp() or tearDown()');
- }
- $this->browser->setMaximumRedirects($max);
- }
-
- /**
- * Sets the socket timeout for opening a connection and
- * receiving at least one byte of information.
- * @param integer $timeout Maximum time in seconds.
- * @access public
- */
- function setConnectionTimeout($timeout) {
- $this->browser->setConnectionTimeout($timeout);
- }
-
- /**
- * Sets proxy to use on all requests for when
- * testing from behind a firewall. Set URL
- * to false to disable.
- * @param string $proxy Proxy URL.
- * @param string $username Proxy username for authentication.
- * @param string $password Proxy password for authentication.
- * @access public
- */
- function useProxy($proxy, $username = false, $password = false) {
- $this->browser->useProxy($proxy, $username, $password);
- }
-
- /**
- * Fetches a page into the page buffer. If
- * there is no base for the URL then the
- * current base URL is used. After the fetch
- * the base URL reflects the new location.
- * @param string $url URL to fetch.
- * @param hash $parameters Optional additional GET data.
- * @return boolean/string Raw page on success.
- * @access public
- */
- function get($url, $parameters = false) {
- return $this->failOnError($this->browser->get($url, $parameters));
- }
-
- /**
- * Fetches a page by POST into the page buffer.
- * If there is no base for the URL then the
- * current base URL is used. After the fetch
- * the base URL reflects the new location.
- * @param string $url URL to fetch.
- * @param mixed $parameters Optional POST parameters or content body to send
- * @param string $content_type Content type of provided body
- * @return boolean/string Raw page on success.
- * @access public
- */
- function post($url, $parameters = false, $content_type = false) {
- return $this->failOnError($this->browser->post($url, $parameters, $content_type));
- }
-
- /**
- * Fetches a page by PUT into the page buffer.
- * If there is no base for the URL then the
- * current base URL is used. After the fetch
- * the base URL reflects the new location.
- * @param string $url URL to fetch.
- * @param mixed $body Optional content body to send
- * @param string $content_type Content type of provided body
- * @return boolean/string Raw page on success.
- * @access public
- */
- function put($url, $body = false, $content_type = false) {
- return $this->failOnError($this->browser->put($url, $body, $content_type));
- }
-
- /**
- * Fetches a page by a DELETE request
- * @param string $url URL to fetch.
- * @param hash $parameters Optional additional parameters.
- * @return boolean/string Raw page on success.
- * @access public
- */
- function delete($url, $parameters = false) {
- return $this->failOnError($this->browser->delete($url, $parameters));
- }
-
-
- /**
- * Does a HTTP HEAD fetch, fetching only the page
- * headers. The current base URL is unchanged by this.
- * @param string $url URL to fetch.
- * @param hash $parameters Optional additional GET data.
- * @return boolean True on success.
- * @access public
- */
- function head($url, $parameters = false) {
- return $this->failOnError($this->browser->head($url, $parameters));
- }
-
- /**
- * Equivalent to hitting the retry button on the
- * browser. Will attempt to repeat the page fetch.
- * @return boolean True if fetch succeeded.
- * @access public
- */
- function retry() {
- return $this->failOnError($this->browser->retry());
- }
-
- /**
- * Equivalent to hitting the back button on the
- * browser.
- * @return boolean True if history entry and
- * fetch succeeded.
- * @access public
- */
- function back() {
- return $this->failOnError($this->browser->back());
- }
-
- /**
- * Equivalent to hitting the forward button on the
- * browser.
- * @return boolean True if history entry and
- * fetch succeeded.
- * @access public
- */
- function forward() {
- return $this->failOnError($this->browser->forward());
- }
-
- /**
- * Retries a request after setting the authentication
- * for the current realm.
- * @param string $username Username for realm.
- * @param string $password Password for realm.
- * @return boolean/string HTML on successful fetch. Note
- * that authentication may still have
- * failed.
- * @access public
- */
- function authenticate($username, $password) {
- return $this->failOnError(
- $this->browser->authenticate($username, $password));
- }
-
- /**
- * Gets the cookie value for the current browser context.
- * @param string $name Name of cookie.
- * @return string Value of cookie or false if unset.
- * @access public
- */
- function getCookie($name) {
- return $this->browser->getCurrentCookieValue($name);
- }
-
- /**
- * Sets a cookie in the current browser.
- * @param string $name Name of cookie.
- * @param string $value Cookie value.
- * @param string $host Host upon which the cookie is valid.
- * @param string $path Cookie path if not host wide.
- * @param string $expiry Expiry date.
- * @access public
- */
- function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
- $this->browser->setCookie($name, $value, $host, $path, $expiry);
- }
-
- /**
- * Accessor for current frame focus. Will be
- * false if no frame has focus.
- * @return integer/string/boolean Label if any, otherwise
- * the position in the frameset
- * or false if none.
- * @access public
- */
- function getFrameFocus() {
- return $this->browser->getFrameFocus();
- }
-
- /**
- * Sets the focus by index. The integer index starts from 1.
- * @param integer $choice Chosen frame.
- * @return boolean True if frame exists.
- * @access public
- */
- function setFrameFocusByIndex($choice) {
- return $this->browser->setFrameFocusByIndex($choice);
- }
-
- /**
- * Sets the focus by name.
- * @param string $name Chosen frame.
- * @return boolean True if frame exists.
- * @access public
- */
- function setFrameFocus($name) {
- return $this->browser->setFrameFocus($name);
- }
-
- /**
- * Clears the frame focus. All frames will be searched
- * for content.
- * @access public
- */
- function clearFrameFocus() {
- return $this->browser->clearFrameFocus();
- }
-
- /**
- * Clicks a visible text item. Will first try buttons,
- * then links and then images.
- * @param string $label Visible text or alt text.
- * @return string/boolean Raw page or false.
- * @access public
- */
- function click($label) {
- return $this->failOnError($this->browser->click($label));
- }
-
- /**
- * Checks for a click target.
- * @param string $label Visible text or alt text.
- * @return boolean True if click target.
- * @access public
- */
- function assertClickable($label, $message = '%s') {
- return $this->assertTrue(
- $this->browser->isClickable($label),
- sprintf($message, "Click target [$label] should exist"));
- }
-
- /**
- * Clicks the submit button by label. The owning
- * form will be submitted by this.
- * @param string $label Button label. An unlabeled
- * button can be triggered by 'Submit'.
- * @param hash $additional Additional form values.
- * @return boolean/string Page on success, else false.
- * @access public
- */
- function clickSubmit($label = 'Submit', $additional = false) {
- return $this->failOnError(
- $this->browser->clickSubmit($label, $additional));
- }
-
- /**
- * Clicks the submit button by name attribute. The owning
- * form will be submitted by this.
- * @param string $name Name attribute of button.
- * @param hash $additional Additional form values.
- * @return boolean/string Page on success.
- * @access public
- */
- function clickSubmitByName($name, $additional = false) {
- return $this->failOnError(
- $this->browser->clickSubmitByName($name, $additional));
- }
-
- /**
- * Clicks the submit button by ID attribute. The owning
- * form will be submitted by this.
- * @param string $id ID attribute of button.
- * @param hash $additional Additional form values.
- * @return boolean/string Page on success.
- * @access public
- */
- function clickSubmitById($id, $additional = false) {
- return $this->failOnError(
- $this->browser->clickSubmitById($id, $additional));
- }
-
- /**
- * Checks for a valid button label.
- * @param string $label Visible text.
- * @return boolean True if click target.
- * @access public
- */
- function assertSubmit($label, $message = '%s') {
- return $this->assertTrue(
- $this->browser->isSubmit($label),
- sprintf($message, "Submit button [$label] should exist"));
- }
-
- /**
- * Clicks the submit image by some kind of label. Usually
- * the alt tag or the nearest equivalent. The owning
- * form will be submitted by this. Clicking outside of
- * the boundary of the coordinates will result in
- * a failure.
- * @param string $label Alt attribute of button.
- * @param integer $x X-coordinate of imaginary click.
- * @param integer $y Y-coordinate of imaginary click.
- * @param hash $additional Additional form values.
- * @return boolean/string Page on success.
- * @access public
- */
- function clickImage($label, $x = 1, $y = 1, $additional = false) {
- return $this->failOnError(
- $this->browser->clickImage($label, $x, $y, $additional));
- }
-
- /**
- * Clicks the submit image by the name. Usually
- * the alt tag or the nearest equivalent. The owning
- * form will be submitted by this. Clicking outside of
- * the boundary of the coordinates will result in
- * a failure.
- * @param string $name Name attribute of button.
- * @param integer $x X-coordinate of imaginary click.
- * @param integer $y Y-coordinate of imaginary click.
- * @param hash $additional Additional form values.
- * @return boolean/string Page on success.
- * @access public
- */
- function clickImageByName($name, $x = 1, $y = 1, $additional = false) {
- return $this->failOnError(
- $this->browser->clickImageByName($name, $x, $y, $additional));
- }
-
- /**
- * Clicks the submit image by ID attribute. The owning
- * form will be submitted by this. Clicking outside of
- * the boundary of the coordinates will result in
- * a failure.
- * @param integer/string $id ID attribute of button.
- * @param integer $x X-coordinate of imaginary click.
- * @param integer $y Y-coordinate of imaginary click.
- * @param hash $additional Additional form values.
- * @return boolean/string Page on success.
- * @access public
- */
- function clickImageById($id, $x = 1, $y = 1, $additional = false) {
- return $this->failOnError(
- $this->browser->clickImageById($id, $x, $y, $additional));
- }
-
- /**
- * Checks for a valid image with atht alt text or title.
- * @param string $label Visible text.
- * @return boolean True if click target.
- * @access public
- */
- function assertImage($label, $message = '%s') {
- return $this->assertTrue(
- $this->browser->isImage($label),
- sprintf($message, "Image with text [$label] should exist"));
- }
-
- /**
- * Submits a form by the ID.
- * @param string $id Form ID. No button information
- * is submitted this way.
- * @return boolean/string Page on success.
- * @access public
- */
- function submitFormById($id, $additional = false) {
- return $this->failOnError($this->browser->submitFormById($id, $additional));
- }
-
- /**
- * Follows a link by name. Will click the first link
- * found with this link text by default, or a later
- * one if an index is given. Match is case insensitive
- * with normalised space.
- * @param string $label Text between the anchor tags.
- * @param integer $index Link position counting from zero.
- * @return boolean/string Page on success.
- * @access public
- */
- function clickLink($label, $index = 0) {
- return $this->failOnError($this->browser->clickLink($label, $index));
- }
-
- /**
- * Follows a link by id attribute.
- * @param string $id ID attribute value.
- * @return boolean/string Page on success.
- * @access public
- */
- function clickLinkById($id) {
- return $this->failOnError($this->browser->clickLinkById($id));
- }
-
- /**
- * Tests for the presence of a link label. Match is
- * case insensitive with normalised space.
- * @param string $label Text between the anchor tags.
- * @param mixed $expected Expected URL or expectation object.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if link present.
- * @access public
- */
- function assertLink($label, $expected = true, $message = '%s') {
- $url = $this->browser->getLink($label);
- if ($expected === true || ($expected !== true && $url === false)) {
- return $this->assertTrue($url !== false, sprintf($message, "Link [$label] should exist"));
- }
- if (! SimpleExpectation::isExpectation($expected)) {
- $expected = new IdenticalExpectation($expected);
- }
- return $this->assert($expected, $url->asString(), sprintf($message, "Link [$label] should match"));
- }
-
- /**
- * Tests for the non-presence of a link label. Match is
- * case insensitive with normalised space.
- * @param string/integer $label Text between the anchor tags
- * or ID attribute.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if link missing.
- * @access public
- */
- function assertNoLink($label, $message = '%s') {
- return $this->assertTrue(
- $this->browser->getLink($label) === false,
- sprintf($message, "Link [$label] should not exist"));
- }
-
- /**
- * Tests for the presence of a link id attribute.
- * @param string $id Id attribute value.
- * @param mixed $expected Expected URL or expectation object.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if link present.
- * @access public
- */
- function assertLinkById($id, $expected = true, $message = '%s') {
- $url = $this->browser->getLinkById($id);
- if ($expected === true) {
- return $this->assertTrue($url !== false, sprintf($message, "Link ID [$id] should exist"));
- }
- if (! SimpleExpectation::isExpectation($expected)) {
- $expected = new IdenticalExpectation($expected);
- }
- return $this->assert($expected, $url->asString(), sprintf($message, "Link ID [$id] should match"));
- }
-
- /**
- * Tests for the non-presence of a link label. Match is
- * case insensitive with normalised space.
- * @param string $id Id attribute value.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if link missing.
- * @access public
- */
- function assertNoLinkById($id, $message = '%s') {
- return $this->assertTrue(
- $this->browser->getLinkById($id) === false,
- sprintf($message, "Link ID [$id] should not exist"));
- }
-
- /**
- * Sets all form fields with that label, or name if there
- * is no label attached.
- * @param string $name Name of field in forms.
- * @param string $value New value of field.
- * @return boolean True if field exists, otherwise false.
- * @access public
- */
- function setField($label, $value, $position=false) {
- return $this->browser->setField($label, $value, $position);
- }
-
- /**
- * Sets all form fields with that name.
- * @param string $name Name of field in forms.
- * @param string $value New value of field.
- * @return boolean True if field exists, otherwise false.
- * @access public
- */
- function setFieldByName($name, $value, $position=false) {
- return $this->browser->setFieldByName($name, $value, $position);
- }
-
- /**
- * Sets all form fields with that id.
- * @param string/integer $id Id of field in forms.
- * @param string $value New value of field.
- * @return boolean True if field exists, otherwise false.
- * @access public
- */
- function setFieldById($id, $value) {
- return $this->browser->setFieldById($id, $value);
- }
-
- /**
- * Confirms that the form element is currently set
- * to the expected value. A missing form will always
- * fail. If no value is given then only the existence
- * of the field is checked.
- * @param string $name Name of field in forms.
- * @param mixed $expected Expected string/array value or
- * false for unset fields.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if pass.
- * @access public
- */
- function assertField($label, $expected = true, $message = '%s') {
- $value = $this->browser->getField($label);
- return $this->assertFieldValue($label, $value, $expected, $message);
- }
-
- /**
- * Confirms that the form element is currently set
- * to the expected value. A missing form element will always
- * fail. If no value is given then only the existence
- * of the field is checked.
- * @param string $name Name of field in forms.
- * @param mixed $expected Expected string/array value or
- * false for unset fields.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if pass.
- * @access public
- */
- function assertFieldByName($name, $expected = true, $message = '%s') {
- $value = $this->browser->getFieldByName($name);
- return $this->assertFieldValue($name, $value, $expected, $message);
- }
-
- /**
- * Confirms that the form element is currently set
- * to the expected value. A missing form will always
- * fail. If no ID is given then only the existence
- * of the field is checked.
- * @param string/integer $id Name of field in forms.
- * @param mixed $expected Expected string/array value or
- * false for unset fields.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if pass.
- * @access public
- */
- function assertFieldById($id, $expected = true, $message = '%s') {
- $value = $this->browser->getFieldById($id);
- return $this->assertFieldValue($id, $value, $expected, $message);
- }
-
- /**
- * Tests the field value against the expectation.
- * @param string $identifier Name, ID or label.
- * @param mixed $value Current field value.
- * @param mixed $expected Expected value to match.
- * @param string $message Failure message.
- * @return boolean True if pass
- * @access protected
- */
- protected function assertFieldValue($identifier, $value, $expected, $message) {
- if ($expected === true) {
- return $this->assertTrue(
- isset($value),
- sprintf($message, "Field [$identifier] should exist"));
- }
- if (! SimpleExpectation::isExpectation($expected)) {
- $identifier = str_replace('%', '%%', $identifier);
- $expected = new FieldExpectation(
- $expected,
- "Field [$identifier] should match with [%s]");
- }
- return $this->assert($expected, $value, $message);
- }
-
- /**
- * Checks the response code against a list
- * of possible values.
- * @param array $responses Possible responses for a pass.
- * @param string $message Message to display. Default
- * can be embedded with %s.
- * @return boolean True if pass.
- * @access public
- */
- function assertResponse($responses, $message = '%s') {
- $responses = (is_array($responses) ? $responses : array($responses));
- $code = $this->browser->getResponseCode();
- $message = sprintf($message, "Expecting response in [" .
- implode(", ", $responses) . "] got [$code]");
- return $this->assertTrue(in_array($code, $responses), $message);
- }
-
- /**
- * Checks the mime type against a list
- * of possible values.
- * @param array $types Possible mime types for a pass.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertMime($types, $message = '%s') {
- $types = (is_array($types) ? $types : array($types));
- $type = $this->browser->getMimeType();
- $message = sprintf($message, "Expecting mime type in [" .
- implode(", ", $types) . "] got [$type]");
- return $this->assertTrue(in_array($type, $types), $message);
- }
-
- /**
- * Attempt to match the authentication type within
- * the security realm we are currently matching.
- * @param string $authentication Usually basic.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertAuthentication($authentication = false, $message = '%s') {
- if (! $authentication) {
- $message = sprintf($message, "Expected any authentication type, got [" .
- $this->browser->getAuthentication() . "]");
- return $this->assertTrue(
- $this->browser->getAuthentication(),
- $message);
- } else {
- $message = sprintf($message, "Expected authentication [$authentication] got [" .
- $this->browser->getAuthentication() . "]");
- return $this->assertTrue(
- strtolower($this->browser->getAuthentication()) == strtolower($authentication),
- $message);
- }
- }
-
- /**
- * Checks that no authentication is necessary to view
- * the desired page.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertNoAuthentication($message = '%s') {
- $message = sprintf($message, "Expected no authentication type, got [" .
- $this->browser->getAuthentication() . "]");
- return $this->assertFalse($this->browser->getAuthentication(), $message);
- }
-
- /**
- * Attempts to match the current security realm.
- * @param string $realm Name of security realm.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertRealm($realm, $message = '%s') {
- if (! SimpleExpectation::isExpectation($realm)) {
- $realm = new EqualExpectation($realm);
- }
- return $this->assert(
- $realm,
- $this->browser->getRealm(),
- "Expected realm -> $message");
- }
-
- /**
- * Checks each header line for the required value. If no
- * value is given then only an existence check is made.
- * @param string $header Case insensitive header name.
- * @param mixed $value Case sensitive trimmed string to
- * match against. An expectation object
- * can be used for pattern matching.
- * @return boolean True if pass.
- * @access public
- */
- function assertHeader($header, $value = false, $message = '%s') {
- return $this->assert(
- new HttpHeaderExpectation($header, $value),
- $this->browser->getHeaders(),
- $message);
- }
-
- /**
- * Confirms that the header type has not been received.
- * Only the landing page is checked. If you want to check
- * redirect pages, then you should limit redirects so
- * as to capture the page you want.
- * @param string $header Case insensitive header name.
- * @return boolean True if pass.
- * @access public
- */
- function assertNoHeader($header, $message = '%s') {
- return $this->assert(
- new NoHttpHeaderExpectation($header),
- $this->browser->getHeaders(),
- $message);
- }
-
- /**
- * Tests the text between the title tags.
- * @param string/SimpleExpectation $title Expected title.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertTitle($title = false, $message = '%s') {
- if (! SimpleExpectation::isExpectation($title)) {
- $title = new EqualExpectation($title);
- }
- return $this->assert($title, $this->browser->getTitle(), $message);
- }
-
- /**
- * Will trigger a pass if the text is found in the plain
- * text form of the page.
- * @param string $text Text to look for.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertText($text, $message = '%s') {
- return $this->assert(
- new TextExpectation($text),
- $this->browser->getContentAsText(),
- $message);
- }
-
- /**
- * Will trigger a pass if the text is not found in the plain
- * text form of the page.
- * @param string $text Text to look for.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertNoText($text, $message = '%s') {
- return $this->assert(
- new NoTextExpectation($text),
- $this->browser->getContentAsText(),
- $message);
- }
-
- /**
- * Will trigger a pass if the Perl regex pattern
- * is found in the raw content.
- * @param string $pattern Perl regex to look for including
- * the regex delimiters.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertPattern($pattern, $message = '%s') {
- return $this->assert(
- new PatternExpectation($pattern),
- $this->browser->getContent(),
- $message);
- }
-
- /**
- * Will trigger a pass if the perl regex pattern
- * is not present in raw content.
- * @param string $pattern Perl regex to look for including
- * the regex delimiters.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertNoPattern($pattern, $message = '%s') {
- return $this->assert(
- new NoPatternExpectation($pattern),
- $this->browser->getContent(),
- $message);
- }
-
- /**
- * Checks that a cookie is set for the current page
- * and optionally checks the value.
- * @param string $name Name of cookie to test.
- * @param string $expected Expected value as a string or
- * false if any value will do.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertCookie($name, $expected = false, $message = '%s') {
- $value = $this->getCookie($name);
- if (! $expected) {
- return $this->assertTrue(
- $value,
- sprintf($message, "Expecting cookie [$name]"));
- }
- if (! SimpleExpectation::isExpectation($expected)) {
- $expected = new EqualExpectation($expected);
- }
- return $this->assert($expected, $value, "Expecting cookie [$name] -> $message");
- }
-
- /**
- * Checks that no cookie is present or that it has
- * been successfully cleared.
- * @param string $name Name of cookie to test.
- * @param string $message Message to display.
- * @return boolean True if pass.
- * @access public
- */
- function assertNoCookie($name, $message = '%s') {
- return $this->assertTrue(
- $this->getCookie($name) === null or $this->getCookie($name) === false,
- sprintf($message, "Not expecting cookie [$name]"));
- }
-
- /**
- * Called from within the test methods to register
- * passes and failures.
- * @param boolean $result Pass on true.
- * @param string $message Message to display describing
- * the test state.
- * @return boolean True on pass
- * @access public
- */
- function assertTrue($result, $message = '%s') {
- return $this->assert(new TrueExpectation(), $result, $message);
- }
-
- /**
- * Will be true on false and vice versa. False
- * is the PHP definition of false, so that null,
- * empty strings, zero and an empty array all count
- * as false.
- * @param boolean $result Pass on false.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertFalse($result, $message = '%s') {
- return $this->assert(new FalseExpectation(), $result, $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * the same value only. Otherwise a fail. This
- * is for testing hand extracted text, etc.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertEqual($first, $second, $message = '%s') {
- return $this->assert(
- new EqualExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Will trigger a pass if the two parameters have
- * a different value. Otherwise a fail. This
- * is for testing hand extracted text, etc.
- * @param mixed $first Value to compare.
- * @param mixed $second Value to compare.
- * @param string $message Message to display.
- * @return boolean True on pass
- * @access public
- */
- function assertNotEqual($first, $second, $message = '%s') {
- return $this->assert(
- new NotEqualExpectation($first),
- $second,
- $message);
- }
-
- /**
- * Uses a stack trace to find the line of an assertion.
- * @return string Line number of first assert*
- * method embedded in format string.
- * @access public
- */
- function getAssertionLine() {
- $trace = new SimpleStackTrace(array('assert', 'click', 'pass', 'fail'));
- return $trace->traceMethod();
- }
-}
-?>
\ No newline at end of file
diff --git a/core/vendors/simpletest/xml.php b/core/vendors/simpletest/xml.php
deleted file mode 100755
index 54fb6f5..0000000
--- a/core/vendors/simpletest/xml.php
+++ /dev/null
@@ -1,647 +0,0 @@
-namespace = ($namespace ? $namespace . ':' : '');
- $this->indent = $indent;
- }
-
- /**
- * Calculates the pretty printing indent level
- * from the current level of nesting.
- * @param integer $offset Extra indenting level.
- * @return string Leading space.
- * @access protected
- */
- protected function getIndent($offset = 0) {
- return str_repeat(
- $this->indent,
- count($this->getTestList()) + $offset);
- }
-
- /**
- * Converts character string to parsed XML
- * entities string.
- * @param string text Unparsed character data.
- * @return string Parsed character data.
- * @access public
- */
- function toParsedXml($text) {
- return str_replace(
- array('&', '<', '>', '"', '\''),
- array('&', '<', '>', '"', '''),
- $text);
- }
-
- /**
- * Paints the start of a group test.
- * @param string $test_name Name of test that is starting.
- * @param integer $size Number of test cases starting.
- * @access public
- */
- function paintGroupStart($test_name, $size) {
- parent::paintGroupStart($test_name, $size);
- print $this->getIndent();
- print "<" . $this->namespace . "group size=\"$size\">\n";
- print $this->getIndent(1);
- print "<" . $this->namespace . "name>" .
- $this->toParsedXml($test_name) .
- "" . $this->namespace . "name>\n";
- }
-
- /**
- * Paints the end of a group test.
- * @param string $test_name Name of test that is ending.
- * @access public
- */
- function paintGroupEnd($test_name) {
- print $this->getIndent();
- print "" . $this->namespace . "group>\n";
- parent::paintGroupEnd($test_name);
- }
-
- /**
- * Paints the start of a test case.
- * @param string $test_name Name of test that is starting.
- * @access public
- */
- function paintCaseStart($test_name) {
- parent::paintCaseStart($test_name);
- print $this->getIndent();
- print "<" . $this->namespace . "case>\n";
- print $this->getIndent(1);
- print "<" . $this->namespace . "name>" .
- $this->toParsedXml($test_name) .
- "" . $this->namespace . "name>\n";
- }
-
- /**
- * Paints the end of a test case.
- * @param string $test_name Name of test that is ending.
- * @access public
- */
- function paintCaseEnd($test_name) {
- print $this->getIndent();
- print "" . $this->namespace . "case>\n";
- parent::paintCaseEnd($test_name);
- }
-
- /**
- * Paints the start of a test method.
- * @param string $test_name Name of test that is starting.
- * @access public
- */
- function paintMethodStart($test_name) {
- parent::paintMethodStart($test_name);
- print $this->getIndent();
- print "<" . $this->namespace . "test>\n";
- print $this->getIndent(1);
- print "<" . $this->namespace . "name>" .
- $this->toParsedXml($test_name) .
- "" . $this->namespace . "name>\n";
- }
-
- /**
- * Paints the end of a test method.
- * @param string $test_name Name of test that is ending.
- * @param integer $progress Number of test cases ending.
- * @access public
- */
- function paintMethodEnd($test_name) {
- print $this->getIndent();
- print "" . $this->namespace . "test>\n";
- parent::paintMethodEnd($test_name);
- }
-
- /**
- * Paints pass as XML.
- * @param string $message Message to encode.
- * @access public
- */
- function paintPass($message) {
- parent::paintPass($message);
- print $this->getIndent(1);
- print "<" . $this->namespace . "pass>";
- print $this->toParsedXml($message);
- print "" . $this->namespace . "pass>\n";
- }
-
- /**
- * Paints failure as XML.
- * @param string $message Message to encode.
- * @access public
- */
- function paintFail($message) {
- parent::paintFail($message);
- print $this->getIndent(1);
- print "<" . $this->namespace . "fail>";
- print $this->toParsedXml($message);
- print "" . $this->namespace . "fail>\n";
- }
-
- /**
- * Paints error as XML.
- * @param string $message Message to encode.
- * @access public
- */
- function paintError($message) {
- parent::paintError($message);
- print $this->getIndent(1);
- print "<" . $this->namespace . "exception>";
- print $this->toParsedXml($message);
- print "" . $this->namespace . "exception>\n";
- }
-
- /**
- * Paints exception as XML.
- * @param Exception $exception Exception to encode.
- * @access public
- */
- function paintException($exception) {
- parent::paintException($exception);
- print $this->getIndent(1);
- print "<" . $this->namespace . "exception>";
- $message = 'Unexpected exception of type [' . get_class($exception) .
- '] with message ['. $exception->getMessage() .
- '] in ['. $exception->getFile() .
- ' line ' . $exception->getLine() . ']';
- print $this->toParsedXml($message);
- print "" . $this->namespace . "exception>\n";
- }
-
- /**
- * Paints the skipping message and tag.
- * @param string $message Text to display in skip tag.
- * @access public
- */
- function paintSkip($message) {
- parent::paintSkip($message);
- print $this->getIndent(1);
- print "<" . $this->namespace . "skip>";
- print $this->toParsedXml($message);
- print "" . $this->namespace . "skip>\n";
- }
-
- /**
- * Paints a simple supplementary message.
- * @param string $message Text to display.
- * @access public
- */
- function paintMessage($message) {
- parent::paintMessage($message);
- print $this->getIndent(1);
- print "<" . $this->namespace . "message>";
- print $this->toParsedXml($message);
- print "" . $this->namespace . "message>\n";
- }
-
- /**
- * Paints a formatted ASCII message such as a
- * privateiable dump.
- * @param string $message Text to display.
- * @access public
- */
- function paintFormattedMessage($message) {
- parent::paintFormattedMessage($message);
- print $this->getIndent(1);
- print "<" . $this->namespace . "formatted>";
- print "";
- print "" . $this->namespace . "formatted>\n";
- }
-
- /**
- * Serialises the event object.
- * @param string $type Event type as text.
- * @param mixed $payload Message or object.
- * @access public
- */
- function paintSignal($type, $payload) {
- parent::paintSignal($type, $payload);
- print $this->getIndent(1);
- print "<" . $this->namespace . "signal type=\"$type\">";
- print "";
- print "" . $this->namespace . "signal>\n";
- }
-
- /**
- * Paints the test document header.
- * @param string $test_name First test top level
- * to start.
- * @access public
- * @abstract
- */
- function paintHeader($test_name) {
- if (! SimpleReporter::inCli()) {
- header('Content-type: text/xml');
- }
- print "namespace) {
- print " xmlns:" . $this->namespace .
- "=\"www.lastcraft.com/SimpleTest/Beta3/Report\"";
- }
- print "?>\n";
- print "<" . $this->namespace . "run>\n";
- }
-
- /**
- * Paints the test document footer.
- * @param string $test_name The top level test.
- * @access public
- * @abstract
- */
- function paintFooter($test_name) {
- print "" . $this->namespace . "run>\n";
- }
-}
-
-/**
- * Accumulator for incoming tag. Holds the
- * incoming test structure information for
- * later dispatch to the reporter.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class NestingXmlTag {
- private $name;
- private $attributes;
-
- /**
- * Sets the basic test information except
- * the name.
- * @param hash $attributes Name value pairs.
- * @access public
- */
- function NestingXmlTag($attributes) {
- $this->name = false;
- $this->attributes = $attributes;
- }
-
- /**
- * Sets the test case/method name.
- * @param string $name Name of test.
- * @access public
- */
- function setName($name) {
- $this->name = $name;
- }
-
- /**
- * Accessor for name.
- * @return string Name of test.
- * @access public
- */
- function getName() {
- return $this->name;
- }
-
- /**
- * Accessor for attributes.
- * @return hash All attributes.
- * @access protected
- */
- protected function getAttributes() {
- return $this->attributes;
- }
-}
-
-/**
- * Accumulator for incoming method tag. Holds the
- * incoming test structure information for
- * later dispatch to the reporter.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class NestingMethodTag extends NestingXmlTag {
-
- /**
- * Sets the basic test information except
- * the name.
- * @param hash $attributes Name value pairs.
- * @access public
- */
- function NestingMethodTag($attributes) {
- $this->NestingXmlTag($attributes);
- }
-
- /**
- * Signals the appropriate start event on the
- * listener.
- * @param SimpleReporter $listener Target for events.
- * @access public
- */
- function paintStart(&$listener) {
- $listener->paintMethodStart($this->getName());
- }
-
- /**
- * Signals the appropriate end event on the
- * listener.
- * @param SimpleReporter $listener Target for events.
- * @access public
- */
- function paintEnd(&$listener) {
- $listener->paintMethodEnd($this->getName());
- }
-}
-
-/**
- * Accumulator for incoming case tag. Holds the
- * incoming test structure information for
- * later dispatch to the reporter.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class NestingCaseTag extends NestingXmlTag {
-
- /**
- * Sets the basic test information except
- * the name.
- * @param hash $attributes Name value pairs.
- * @access public
- */
- function NestingCaseTag($attributes) {
- $this->NestingXmlTag($attributes);
- }
-
- /**
- * Signals the appropriate start event on the
- * listener.
- * @param SimpleReporter $listener Target for events.
- * @access public
- */
- function paintStart(&$listener) {
- $listener->paintCaseStart($this->getName());
- }
-
- /**
- * Signals the appropriate end event on the
- * listener.
- * @param SimpleReporter $listener Target for events.
- * @access public
- */
- function paintEnd(&$listener) {
- $listener->paintCaseEnd($this->getName());
- }
-}
-
-/**
- * Accumulator for incoming group tag. Holds the
- * incoming test structure information for
- * later dispatch to the reporter.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class NestingGroupTag extends NestingXmlTag {
-
- /**
- * Sets the basic test information except
- * the name.
- * @param hash $attributes Name value pairs.
- * @access public
- */
- function NestingGroupTag($attributes) {
- $this->NestingXmlTag($attributes);
- }
-
- /**
- * Signals the appropriate start event on the
- * listener.
- * @param SimpleReporter $listener Target for events.
- * @access public
- */
- function paintStart(&$listener) {
- $listener->paintGroupStart($this->getName(), $this->getSize());
- }
-
- /**
- * Signals the appropriate end event on the
- * listener.
- * @param SimpleReporter $listener Target for events.
- * @access public
- */
- function paintEnd(&$listener) {
- $listener->paintGroupEnd($this->getName());
- }
-
- /**
- * The size in the attributes.
- * @return integer Value of size attribute or zero.
- * @access public
- */
- function getSize() {
- $attributes = $this->getAttributes();
- if (isset($attributes['SIZE'])) {
- return (integer)$attributes['SIZE'];
- }
- return 0;
- }
-}
-
-/**
- * Parser for importing the output of the XmlReporter.
- * Dispatches that output to another reporter.
- * @package SimpleTest
- * @subpackage UnitTester
- */
-class SimpleTestXmlParser {
- private $listener;
- private $expat;
- private $tag_stack;
- private $in_content_tag;
- private $content;
- private $attributes;
-
- /**
- * Loads a listener with the SimpleReporter
- * interface.
- * @param SimpleReporter $listener Listener of tag events.
- * @access public
- */
- function SimpleTestXmlParser(&$listener) {
- $this->listener = &$listener;
- $this->expat = &$this->createParser();
- $this->tag_stack = array();
- $this->in_content_tag = false;
- $this->content = '';
- $this->attributes = array();
- }
-
- /**
- * Parses a block of XML sending the results to
- * the listener.
- * @param string $chunk Block of text to read.
- * @return boolean True if valid XML.
- * @access public
- */
- function parse($chunk) {
- if (! xml_parse($this->expat, $chunk)) {
- trigger_error('XML parse error with ' .
- xml_error_string(xml_get_error_code($this->expat)));
- return false;
- }
- return true;
- }
-
- /**
- * Sets up expat as the XML parser.
- * @return resource Expat handle.
- * @access protected
- */
- protected function &createParser() {
- $expat = xml_parser_create();
- xml_set_object($expat, $this);
- xml_set_element_handler($expat, 'startElement', 'endElement');
- xml_set_character_data_handler($expat, 'addContent');
- xml_set_default_handler($expat, 'defaultContent');
- return $expat;
- }
-
- /**
- * Opens a new test nesting level.
- * @return NestedXmlTag The group, case or method tag
- * to start.
- * @access private
- */
- protected function pushNestingTag($nested) {
- array_unshift($this->tag_stack, $nested);
- }
-
- /**
- * Accessor for current test structure tag.
- * @return NestedXmlTag The group, case or method tag
- * being parsed.
- * @access private
- */
- protected function &getCurrentNestingTag() {
- return $this->tag_stack[0];
- }
-
- /**
- * Ends a nesting tag.
- * @return NestedXmlTag The group, case or method tag
- * just finished.
- * @access private
- */
- protected function popNestingTag() {
- return array_shift($this->tag_stack);
- }
-
- /**
- * Test if tag is a leaf node with only text content.
- * @param string $tag XML tag name.
- * @return @boolean True if leaf, false if nesting.
- * @private
- */
- protected function isLeaf($tag) {
- return in_array($tag, array(
- 'NAME', 'PASS', 'FAIL', 'EXCEPTION', 'SKIP', 'MESSAGE', 'FORMATTED', 'SIGNAL'));
- }
-
- /**
- * Handler for start of event element.
- * @param resource $expat Parser handle.
- * @param string $tag Element name.
- * @param hash $attributes Name value pairs.
- * Attributes without content
- * are marked as true.
- * @access protected
- */
- protected function startElement($expat, $tag, $attributes) {
- $this->attributes = $attributes;
- if ($tag == 'GROUP') {
- $this->pushNestingTag(new NestingGroupTag($attributes));
- } elseif ($tag == 'CASE') {
- $this->pushNestingTag(new NestingCaseTag($attributes));
- } elseif ($tag == 'TEST') {
- $this->pushNestingTag(new NestingMethodTag($attributes));
- } elseif ($this->isLeaf($tag)) {
- $this->in_content_tag = true;
- $this->content = '';
- }
- }
-
- /**
- * End of element event.
- * @param resource $expat Parser handle.
- * @param string $tag Element name.
- * @access protected
- */
- protected function endElement($expat, $tag) {
- $this->in_content_tag = false;
- if (in_array($tag, array('GROUP', 'CASE', 'TEST'))) {
- $nesting_tag = $this->popNestingTag();
- $nesting_tag->paintEnd($this->listener);
- } elseif ($tag == 'NAME') {
- $nesting_tag = &$this->getCurrentNestingTag();
- $nesting_tag->setName($this->content);
- $nesting_tag->paintStart($this->listener);
- } elseif ($tag == 'PASS') {
- $this->listener->paintPass($this->content);
- } elseif ($tag == 'FAIL') {
- $this->listener->paintFail($this->content);
- } elseif ($tag == 'EXCEPTION') {
- $this->listener->paintError($this->content);
- } elseif ($tag == 'SKIP') {
- $this->listener->paintSkip($this->content);
- } elseif ($tag == 'SIGNAL') {
- $this->listener->paintSignal(
- $this->attributes['TYPE'],
- unserialize($this->content));
- } elseif ($tag == 'MESSAGE') {
- $this->listener->paintMessage($this->content);
- } elseif ($tag == 'FORMATTED') {
- $this->listener->paintFormattedMessage($this->content);
- }
- }
-
- /**
- * Content between start and end elements.
- * @param resource $expat Parser handle.
- * @param string $text Usually output messages.
- * @access protected
- */
- protected function addContent($expat, $text) {
- if ($this->in_content_tag) {
- $this->content .= $text;
- }
- return true;
- }
-
- /**
- * XML and Doctype handler. Discards all such content.
- * @param resource $expat Parser handle.
- * @param string $default Text of default content.
- * @access protected
- */
- protected function defaultContent($expat, $default) {
- }
-}
-?>
diff --git a/core/views/_v_email.php b/core/views/_v_email.php
deleted file mode 100755
index 7b8ecaa..0000000
--- a/core/views/_v_email.php
+++ /dev/null
@@ -1,3 +0,0 @@
-
- =$content?>
-
\ No newline at end of file
diff --git a/core/views/_v_template.php b/core/views/_v_template.php
deleted file mode 100755
index 0e8815f..0000000
--- a/core/views/_v_template.php
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- =@$title; ?>
-
-
-
-
-
-
-
-
-
-
-
-
- echo $content;?>
-
-
-
-
-
\ No newline at end of file
diff --git a/core/views/v_message.php b/core/views/v_message.php
deleted file mode 100755
index 65fe43a..0000000
--- a/core/views/v_message.php
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
=$message?>
-
- if($type == 'error'): ?>
-
=APP_EMAIL?>
- endif; ?>
-
-
\ No newline at end of file
diff --git a/environment.php b/environment.php
deleted file mode 100755
index 6260827..0000000
--- a/environment.php
+++ /dev/null
@@ -1,36 +0,0 @@
-