summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2010-10-27 11:13:08 +0300
committerTheo Chatzimichos <tampakrap@gentoo.org>2010-10-27 11:13:08 +0300
commite7fac954e7932db9a62c717ba0acf078401fbe96 (patch)
tree9ef7cb9a42ea18a659b5d8857e6a7a282d0c9463 /plugins/wp-syntax/test
parentsmall fixes in update script (diff)
downloadblogs-gentoo-e7fac954e7932db9a62c717ba0acf078401fbe96.tar.gz
blogs-gentoo-e7fac954e7932db9a62c717ba0acf078401fbe96.tar.bz2
blogs-gentoo-e7fac954e7932db9a62c717ba0acf078401fbe96.zip
Add the following plugins:
- aksimet - clean archives reloaded - google intergration toolkit - openid - smart youtube - wp stats - wp-syntax - wp-security scan
Diffstat (limited to 'plugins/wp-syntax/test')
-rw-r--r--plugins/wp-syntax/test/code.php101
-rw-r--r--plugins/wp-syntax/test/index.php203
2 files changed, 304 insertions, 0 deletions
diff --git a/plugins/wp-syntax/test/code.php b/plugins/wp-syntax/test/code.php
new file mode 100644
index 00000000..ed314446
--- /dev/null
+++ b/plugins/wp-syntax/test/code.php
@@ -0,0 +1,101 @@
+<?php
+
+$code = array();
+$code['php'] = <<<EOF
+<div id="foo">
+<?php
+ function foo() {
+ echo "Hello World!\\n";
+ }
+ for (\$i = 0; \$i < 10 $i++) {
+ foo();
+ }
+?>
+</div>
+EOF;
+
+$code['lisp'] = <<<EOF
+(defun foo
+ "bleh *bleh* bleh"
+ (interactive))
+EOF;
+
+$code['java'] = <<<EOF
+public class Hello {
+ public static void main(String[] args) {
+ System.out.println("Hello World!");
+ }
+}
+EOF;
+
+$code['xml'] = <<<EOF
+<xml>
+ <foo>
+ <bar id="howdy">&quot;Hello World!&quot;</bar>
+ </foo>
+</xml>
+EOF;
+
+$code['html'] = <<<EOF
+<html><head><title>Hello World</title></head>
+ <body>
+ <h1>Hello World!</h1>
+ <p><strong>howdy</strong></p>
+ </body>
+</html>
+EOF;
+
+$code['ruby'] = <<<EOF
+class Example
+ def example(arg1)
+ return "Hello: " + arg1.to_s
+ end
+end
+EOF;
+
+$code['rails'] = <<<EOF
+ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action', :action => 'index', :requirements => { :action => /(?:[a-z](?:[-_]?[a-z]+)*)/ }
+ map.connect ':controller/:id', :action => 'show', :requirements => { :id => /\d+/ }
+ map.connect ':controller/:id/:action',
+end
+EOF;
+
+$code['ocaml'] = <<<EOF
+let square x = x * x;;
+val square : int -> int =
+let rec fact x =
+ if x < = 1 then 1 else x * fact (x - 1);;
+val fact : int -> int =
+fact 5;; - : int = 120
+square 120;; - : int = 14400
+EOF;
+
+$code['python'] = <<<EOF
+from itertools import islice
+
+def fib():
+ x, y = 1, 1
+ while True:
+ yield x
+ x, y = y, x + y
+
+for num in islice(fib(), 20):
+ print num
+EOF;
+
+$code['c'] = <<<EOF
+_tcsncat_s(CurrentFileName, MAX_PATH, TEXT("\\\\"), MAX_PATH);
+_tcsncat_s(CurrentFileName, MAX_PATH, FileInformation.cFileName, MAX_PATH);
+
+if(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+{
+ RecurseFileSystem(CurrentFileName);
+}
+else
+{
+ /* Do action on file here! */
+}
+EOF;
+
+?>
diff --git a/plugins/wp-syntax/test/index.php b/plugins/wp-syntax/test/index.php
new file mode 100644
index 00000000..e6199708
--- /dev/null
+++ b/plugins/wp-syntax/test/index.php
@@ -0,0 +1,203 @@
+<?php
+
+include("code.php");
+
+function test_lang($lang, $language = null, $line = null, $escaped = null)
+{
+ global $code;
+ if (!isset($language)) $language = $lang;
+ else $as = "as $language";
+
+ if (isset($escaped)) $c = htmlspecialchars($code[$lang]);
+ else { $c = $code[$lang]; $escaped = "false"; }
+
+ $snippet = <<<EOF
+<h2>$lang $as</h2>
+<p>This *is* what some <code>$lang</code> code looks like (escaped:$escaped):</p>
+<pre lang='$language' line="$line" escaped="$escaped"> \t \r
+$c
+</pre>
+EOF;
+
+ return $snippet;
+}
+
+function gather_content()
+{
+ $content = '';
+ $content .= test_lang('php');
+ $content .= test_lang('lisp', null, 1);
+ $content .= test_lang('java', null, 1);
+ $content .= test_lang('xml');
+ $content .= test_lang('xml', null, null, "true");
+ $content .= test_lang('html', 'html4strict');
+ $content .= test_lang('html', 'xml', 18);
+ $content .= test_lang('html', 'xml', 18, "true");
+ $content .= test_lang('ocaml');
+ $content .= test_lang('python');
+ $content .= test_lang('ruby', null, 18);
+ $content .= test_lang('ruby');
+ $content .= test_lang('rails');
+ $content .= test_lang('c');
+ return $content;
+}
+
+function test_head()
+{
+ echo apply_filters("wp_head", "");
+}
+
+function test_all()
+{
+ echo apply_filters("the_content", gather_content());
+}
+
+function test_all_with_other_filters()
+{
+ add_filter('the_content', 'pre_killer'); // bad if run before GeSHi
+ add_filter('the_content', 'amp_exposer'); // bad if run after GeSHi
+
+ if (file_exists("filters/filters.php"))
+ {
+ include("filters/filters.php");
+ }
+
+ echo apply_filters("the_content", gather_content());
+}
+
+include("../wp-syntax.php");
+?>
+
+<html>
+<head>
+<title>WP-Syntax Test Page</title>
+<link rel="stylesheet" href="../wp-syntax.css" type="text/css" media="screen" />
+<?php
+test_head();
+define("TEMPLATEPATH", "../");
+test_head();
+?>
+<style type="text/css" media="screen">
+.wp_syntax td div, .wp_syntax div div {
+ padding: 0;
+}
+</style>
+</head>
+
+<body>
+<div style="width:50%;">
+ <h1>Vanilla, without other filters</h1>
+<?php
+test_all();
+?>
+
+ <h1>Modified, with other filters</h1>
+<?php
+test_all_with_other_filters();
+?>
+</div>
+</body>
+</html>
+
+
+<?php
+
+function amp_exposer($content)
+{
+ return str_replace("&", "&amp;", $content);
+}
+
+function pre_killer($content)
+{
+ return preg_replace("/<(\/)?pre([^>]*)>/", "[$1pre$2]", $content);
+}
+
+/*
+ * === WORDPRESS STUBS ===
+ */
+function get_bloginfo($arg) {
+ return "http://yourblog.com/blog";
+}
+
+function get_option($arg) {
+ return "http://yourblog.com/blog";
+}
+
+function remove_filter($tag, $function_to_remove, $priority = 10)
+{
+ return true;
+}
+
+function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1)
+{
+ global $test_filter;
+
+ $test_filter[$tag][$priority][] = $function_to_add;
+ $test_filter[$tag][$priority] = array_unique($test_filter[$tag][$priority]);
+
+ return true;
+}
+
+function apply_filters($tag, $string)
+{
+ global $test_filter;
+
+ if (!isset($test_filter[$tag])) return $string;
+
+ uksort($test_filter[$tag], "strnatcasecmp");
+
+ foreach ($test_filter[$tag] as $priority => $functions)
+ {
+ if (is_null($functions)) continue;
+
+ foreach($functions as $function)
+ {
+ $string = call_user_func_array($function, array($string));
+ }
+ }
+ return $string;
+}
+
+function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1)
+{
+ add_filter($tag, $function_to_add, $priority, $accepted_args);
+}
+
+function do_action($tag, $arg = '') {
+ global $test_filter;
+
+ if (!isset($test_filter[$tag])) return;
+
+ uksort($test_filter[$tag], "strnatcasecmp");
+
+ foreach ($test_filter[$tag] as $priority => $functions)
+ {
+ if (is_null($functions)) continue;
+
+ foreach($functions as $function)
+ {
+ call_user_func_array($function, array($arg));
+ }
+ }
+}
+
+function do_action_ref_array($tag, $args) {
+ global $test_filter;
+
+ if (!isset($test_filter[$tag])) return;
+
+ uksort($test_filter[$tag], "strnatcasecmp");
+
+ foreach ($test_filter[$tag] as $priority => $functions)
+ {
+ if (is_null($functions)) continue;
+
+ foreach($functions as $function)
+ {
+ call_user_func_array($function, $args);
+ }
+ }
+}
+
+?>
+