From cecb985bee3bdd252e1b8dc0bd500b37cd52be01 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 16 May 2007 20:58:53 +0000 Subject: Aktualisierung auf MediaWiki 1.10.0 Plugins angepasst und verbessert kleine Korrekturen am Design --- t/00-test.t | 8 +++++++ t/README | 54 ++++++++++++++++++++++++++++++++++++++++++ t/inc/IP.t | 60 +++++++++++++++++++++++++++++++++++++++++++++++ t/inc/Licenses.t | 29 +++++++++++++++++++++++ t/inc/Sanitizer.t | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ t/inc/Title.t | 33 ++++++++++++++++++++++++++ t/inc/Xml.t | 56 ++++++++++++++++++++++++++++++++++++++++++++ t/maint/eol-style.t | 35 ++++++++++++++++++++++++++++ t/maint/php-lint.t | 33 ++++++++++++++++++++++++++ t/maint/php-tag.t | 29 +++++++++++++++++++++++ t/maint/unix-newlines.t | 28 ++++++++++++++++++++++ 11 files changed, 427 insertions(+) create mode 100644 t/00-test.t create mode 100644 t/README create mode 100644 t/inc/IP.t create mode 100644 t/inc/Licenses.t create mode 100644 t/inc/Sanitizer.t create mode 100644 t/inc/Title.t create mode 100644 t/inc/Xml.t create mode 100644 t/maint/eol-style.t create mode 100644 t/maint/php-lint.t create mode 100644 t/maint/php-tag.t create mode 100644 t/maint/unix-newlines.t (limited to 't') diff --git a/t/00-test.t b/t/00-test.t new file mode 100644 index 00000000..c3defa40 --- /dev/null +++ b/t/00-test.t @@ -0,0 +1,8 @@ +#!/usr/bin/env php + diff --git a/t/README b/t/README new file mode 100644 index 00000000..2bf42aba --- /dev/null +++ b/t/README @@ -0,0 +1,54 @@ +=head1 NAME + +F - MediaWiki test tree + +=head1 DESCRIPTION + +This is the MediaWiki test tree (well, one of them), tests in this +directory are self-contained programs that produce TAP output via the +F module (/trunk/Test/Test.php) (see +http://search.cpan.org/~petdance/TAP-1.00/TAP.pm#THE_TAP_FORMAT for +information on the TAP format). + +=head1 Running the tests + +You'll need F to run the tests, it lives in the +F directory and can be copied or linked to the F +directory. + + ln -s ../Test/Test.php . + +Since the tests are self-contained PHP programs you can run them +(Xml.t here) as: + + php t/inc/Xml.t + +That'll give you the raw TAP output, but what you probably want is to +use a TAP formatter such as L: + + prove t/inc/Xml.t # add -v for the verbose version + +or to run all the tests: + + prove -r t + +=head1 TODO + +=over + +=item * + +Rewrite the rest of the F stuff to use L and move it +here + +=item * + +Make the parsertests use TAP? + +=item * + +Write unit tests for the entire codebase:) + +=back + +=cut diff --git a/t/inc/IP.t b/t/inc/IP.t new file mode 100644 index 00000000..eb4978b9 --- /dev/null +++ b/t/inc/IP.t @@ -0,0 +1,60 @@ +#!/usr/bin/env php + diff --git a/t/inc/Licenses.t b/t/inc/Licenses.t new file mode 100644 index 00000000..86202bd6 --- /dev/null +++ b/t/inc/Licenses.t @@ -0,0 +1,29 @@ +#!/usr/bin/env php +html; + + + + +?> \ No newline at end of file diff --git a/t/inc/Sanitizer.t b/t/inc/Sanitizer.t new file mode 100644 index 00000000..e3b11b6f --- /dev/null +++ b/t/inc/Sanitizer.t @@ -0,0 +1,62 @@ +#!/usr/bin/env php +Hello world' ), + '==', + '
Hello world
', + 'Self-closing closing div' +); diff --git a/t/inc/Title.t b/t/inc/Title.t new file mode 100644 index 00000000..51157197 --- /dev/null +++ b/t/inc/Title.t @@ -0,0 +1,33 @@ +#!/usr/bin/env php +|", $chr ) !== false || preg_match( "/[\\x00-\\x1f\\x7f]/", $chr ) ) { + unlike( $chr, "/[$titlechars]/", "chr($num) = $chr is not a valid titlechar" ); + } else { + like( $chr, "/[$titlechars]/", "chr($num) = $chr is a valid titlechar" ); + } +} + + +?> diff --git a/t/inc/Xml.t b/t/inc/Xml.t new file mode 100644 index 00000000..bf95cce2 --- /dev/null +++ b/t/inc/Xml.t @@ -0,0 +1,56 @@ +#!/usr/bin/env php +', + 'Opening element with no attributes' +); + +cmp_ok( + Xml::element( 'element', null, '' ), + '==', + '', + 'Terminated empty element' +); + +cmp_ok( + Xml::element( 'element', null, 'hello you & you' ), + '==', + 'hello <there> you & you', + 'Element with no attributes and content that needs escaping' +); + +cmp_ok( + Xml::element( 'element', array( 'key' => 'value', '<>' => '<>' ), null ), + '==', + '="<>">', + 'Element attributes, keys are not escaped' +); + +# +# open/close element +# + +cmp_ok( + Xml::openElement( 'element', array( 'k' => 'v' ) ), + '==', + '', + 'openElement() shortcut' +); + +cmp_ok( Xml::closeElement( 'element' ), '==', '', 'closeElement() shortcut' ); + +?> \ No newline at end of file diff --git a/t/maint/eol-style.t b/t/maint/eol-style.t new file mode 100644 index 00000000..d877a264 --- /dev/null +++ b/t/maint/eol-style.t @@ -0,0 +1,35 @@ +#!/usr/bin/env perl +# +# Based on php-tag.t +# +use strict; +use warnings; + +use Test::More; +use File::Find; +use IPC::Open3; +use File::Spec; +use Symbol qw(gensym); + +my $ext = qr/(?: php | inc | txt | sql | t)/x; +my @files; + +find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' ); + +plan tests => scalar @files ; + +for my $file (@files) { + open NULL, '+>', File::Spec->devnull and \*NULL or die; + my $pid = open3('<&NULL', \*P, '>&NULL', qw'svn propget svn:eol-style', $file); + my $res = do { local $/;

. "" }; + chomp $res; + waitpid $pid, 0; + + if ( $? != 0 ) { + ok 1 => "svn propget failed, $file probably not under version control"; + } elsif ( $res eq 'native' ) { + ok 1 => "$file svn:eol-style is 'native'"; + } else { + ok 0 => "$file svn:eol-style is '$res', should be 'native'"; + } +} diff --git a/t/maint/php-lint.t b/t/maint/php-lint.t new file mode 100644 index 00000000..e65d6895 --- /dev/null +++ b/t/maint/php-lint.t @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +# +# Based on php-tag.t and eol-style +# +use strict; +use warnings; + +use Test::More; +use File::Find; +use IPC::Open3; +use File::Spec; +use Symbol qw(gensym); + +my $ext = qr/(?: php | inc )/x; +my @files; + +find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' ); + +plan tests => scalar @files ; + +for my $file (@files) { + open NULL, '+>', File::Spec->devnull and \*NULL or die; + my $pid = open3('<&NULL', \*P, '>&NULL', qw'php -l', $file); + my $res = do { local $/;

. "" }; + chomp $res; + waitpid $pid, 0; + + if ( $? == 0 ) { + ok 1 => "Looks fine"; + } else { + ok 0 => "$file does not pass php linter. Error was: $res"; + } +} diff --git a/t/maint/php-tag.t b/t/maint/php-tag.t new file mode 100644 index 00000000..80b870b7 --- /dev/null +++ b/t/maint/php-tag.t @@ -0,0 +1,29 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Test::More;; + +use File::Find; +use File::Slurp qw< slurp >; + +my $ext = qr/(?: php | inc )/x; + +my @files; +find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' ); + +plan tests => scalar @files; + +for my $file (@files) { + my $cont = slurp $file; + if ( $cont =~ m<<\?php .* \?>>xs ) { + ok 1 => "$file has "; + } elsif ( $cont =~ m<<\? .* \?>>xs ) { + ok 0 => "$file does not use "; + } else { + ok 1 => "$file has neither nor , check it"; + } +} + + + diff --git a/t/maint/unix-newlines.t b/t/maint/unix-newlines.t new file mode 100644 index 00000000..91a24ad7 --- /dev/null +++ b/t/maint/unix-newlines.t @@ -0,0 +1,28 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Test::More;; + +use File::Find; +use File::Slurp qw< slurp >; +use Socket qw< $CRLF $LF >; + +my $ext = qr/(?: t | pm | sql | js | php | inc | xml )/x; + +my @files; +find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' ); + +plan tests => scalar @files; + +for my $file (@files) { + my $cont = slurp $file; + if ( $cont and $cont =~ $CRLF ) { + ok 0 => "$file contains windows newlines"; + } else { + ok 1 => "$file is made of unix newlines and win"; + } +} + + + -- cgit v1.2.3-54-g00ecf