summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2007-09-14 13:18:58 +0200
committerPierre Schmitz <pierre@archlinux.de>2007-09-14 13:18:58 +0200
commit8f416baead93a48e5799e44b8bd2e2c4859f4e04 (patch)
treecd47ac55eb80a39e3225e8b4f3161b88ea16c2cf /t
parentd7d08bd1a17618c7d77a6b9b2989e9f7293d6ed6 (diff)
auf Version 1.11 aktualisiert; Login-Bug behoben
Diffstat (limited to 't')
-rw-r--r--t/00-test.t2
-rw-r--r--t/inc/IP.t1
-rw-r--r--t/inc/Language.t62
-rw-r--r--t/inc/Licenses.t6
-rw-r--r--t/inc/Sanitizer.t3
-rw-r--r--t/inc/Title.t2
-rw-r--r--t/inc/Xml.t3
-rw-r--r--t/maint/bom.t38
-rw-r--r--t/maint/eol-style.t6
-rw-r--r--t/maint/php-lint.t4
-rw-r--r--t/maint/php-tag.t6
-rw-r--r--t/maint/unix-newlines.t23
12 files changed, 133 insertions, 23 deletions
diff --git a/t/00-test.t b/t/00-test.t
index c3defa40..b9ed2038 100644
--- a/t/00-test.t
+++ b/t/00-test.t
@@ -5,4 +5,6 @@ require 'Test.php';
plan(1);
ok(0 == 0);
+
+/* vim: set filetype=php: */
?>
diff --git a/t/inc/IP.t b/t/inc/IP.t
index eb4978b9..82a61fe1 100644
--- a/t/inc/IP.t
+++ b/t/inc/IP.t
@@ -57,4 +57,5 @@ foreach ( $private as $p ) {
ok( ! IP::isPublic( $p ), "$p is not a public IP address" );
}
+/* vim: set filetype=php: */
?>
diff --git a/t/inc/Language.t b/t/inc/Language.t
new file mode 100644
index 00000000..df5e491d
--- /dev/null
+++ b/t/inc/Language.t
@@ -0,0 +1,62 @@
+#!/usr/bin/env php
+<?php
+
+require 'Test.php';
+
+# Test offset usage for a given language::userAdjust
+function test_userAdjust( $langObj, $date, $offset, $expected ) {
+ global $wgLocalTZoffset;
+ $wgLocalTZoffset = $offset;
+
+ cmp_ok(
+ $langObj->userAdjust( $date, '' ),
+ '==',
+ $expected,
+ "User adjust $date by $offset minutes should give $expected"
+ );
+}
+
+# Collection of parameters for Language_t_Offset.
+# Format: date to be formatted, localTZoffset value, expected date
+$userAdjust_tests = array(
+ array( 20061231235959, 0, 20061231235959 ),
+ array( 20061231235959, 5, 20070101000459 ),
+ array( 20061231235959, 15, 20070101001459 ),
+ array( 20061231235959, 60, 20070101005959 ),
+ array( 20061231235959, 90, 20070101012959 ),
+ array( 20061231235959, 120, 20070101015959 ),
+ array( 20061231235959, 540, 20070101085959 ),
+ array( 20061231235959, -5, 20061231235459 ),
+ array( 20061231235959, -30, 20061231232959 ),
+ array( 20061231235959, -60, 20061231225959 ),
+);
+
+plan( 7 + count($userAdjust_tests) );
+
+require_ok( 'includes/Defines.php' );
+
+# require_ok() doesn't work for these, find out why
+define( 'MEDIAWIKI', 1 );
+require 'LocalSettings.php';
+require 'includes/DefaultSettings.php';
+
+# Create a language object
+require_ok( 'languages/Language.php' );
+require_ok( 'includes/Title.php' );
+$wgContLang = $en = Language::factory( 'en' );
+
+# We need an user to test the lang
+require_ok( 'includes/GlobalFunctions.php' );
+require_ok( 'includes/ProfilerStub.php' );
+require_ok( 'includes/Exception.php' );
+require_ok( 'includes/User.php' );
+global $wgUser;
+$wgUser = new User();
+
+# Launch tests for language::userAdjust
+foreach( $userAdjust_tests as $data ) {
+ test_userAdjust( $en, $data[0], $data[1], $data[2] );
+}
+
+/* vim: set filetype=php: */
+?>
diff --git a/t/inc/Licenses.t b/t/inc/Licenses.t
index 86202bd6..7e9f67c8 100644
--- a/t/inc/Licenses.t
+++ b/t/inc/Licenses.t
@@ -23,7 +23,5 @@ $str = "
#echo $lc->html;
-
-
-
-?> \ No newline at end of file
+/* vim: set filetype=php: */
+?>
diff --git a/t/inc/Sanitizer.t b/t/inc/Sanitizer.t
index e3b11b6f..601f8a88 100644
--- a/t/inc/Sanitizer.t
+++ b/t/inc/Sanitizer.t
@@ -60,3 +60,6 @@ cmp_ok(
'<div>Hello world</div>',
'Self-closing closing div'
);
+
+/* vim: set filetype=php: */
+?>
diff --git a/t/inc/Title.t b/t/inc/Title.t
index 51157197..53ebfcd8 100644
--- a/t/inc/Title.t
+++ b/t/inc/Title.t
@@ -29,5 +29,5 @@ foreach ( range( 1, 255 ) as $num ) {
}
}
-
+/* vim: set filetype=php: */
?>
diff --git a/t/inc/Xml.t b/t/inc/Xml.t
index bf95cce2..527cd7f5 100644
--- a/t/inc/Xml.t
+++ b/t/inc/Xml.t
@@ -53,4 +53,5 @@ cmp_ok(
cmp_ok( Xml::closeElement( 'element' ), '==', '</element>', 'closeElement() shortcut' );
-?> \ No newline at end of file
+/* vim: set filetype=php: */
+?>
diff --git a/t/maint/bom.t b/t/maint/bom.t
new file mode 100644
index 00000000..b5e6ae98
--- /dev/null
+++ b/t/maint/bom.t
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+#
+# This test detect Byte Order Mark (BOM). The char is sometime included at the
+# top of files by some text editors to mark them as being UTF-8 encoded.
+# They are not stripped by php 5.x and appear at the beginning of our content,
+# You want them removed!
+# See:
+# http://www.fileformat.info/info/unicode/char/feff/index.htm
+# http://bugzilla.wikimedia.org/show_bug.cgi?id=9954
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use File::Find;
+
+# Files for wich we want to check the BOM char ( 0xFE 0XFF )
+my $ext = qr/(?:php|inc)/x ;
+
+my $bomchar = qr/\xef\xbb\xbf/ ;
+
+my @files;
+
+find( sub{ push @files, $File::Find::name if -f && /\.$ext$/ }, '.' );
+
+# Register our files with the test system
+plan tests => scalar @files ;
+
+for my $file (@files) {
+ open my $fh, "<", $file or die "Couln't open $file: $!";
+ my $line = <$fh>;
+ if( $line =~ /$bomchar/ ) {
+ fail "$file has a Byte Order Mark at line $.";
+ } else {
+ pass "$file has no Byte Order Mark!";
+ }
+}
diff --git a/t/maint/eol-style.t b/t/maint/eol-style.t
index d877a264..2e281dc4 100644
--- a/t/maint/eol-style.t
+++ b/t/maint/eol-style.t
@@ -26,10 +26,10 @@ for my $file (@files) {
waitpid $pid, 0;
if ( $? != 0 ) {
- ok 1 => "svn propget failed, $file probably not under version control";
+ pass "svn propget failed, $file probably not under version control";
} elsif ( $res eq 'native' ) {
- ok 1 => "$file svn:eol-style is 'native'";
+ pass "$file svn:eol-style is 'native'";
} else {
- ok 0 => "$file svn:eol-style is '$res', should be 'native'";
+ fail "$file svn:eol-style is '$res', should be 'native'";
}
}
diff --git a/t/maint/php-lint.t b/t/maint/php-lint.t
index e65d6895..6687a089 100644
--- a/t/maint/php-lint.t
+++ b/t/maint/php-lint.t
@@ -26,8 +26,8 @@ for my $file (@files) {
waitpid $pid, 0;
if ( $? == 0 ) {
- ok 1 => "Looks fine";
+ pass($file);
} else {
- ok 0 => "$file does not pass php linter. Error was: $res";
+ fail("$file does not pass php -l. Error was: $res");
}
}
diff --git a/t/maint/php-tag.t b/t/maint/php-tag.t
index 80b870b7..5093ca7f 100644
--- a/t/maint/php-tag.t
+++ b/t/maint/php-tag.t
@@ -17,11 +17,11 @@ plan tests => scalar @files;
for my $file (@files) {
my $cont = slurp $file;
if ( $cont =~ m<<\?php .* \?>>xs ) {
- ok 1 => "$file has <?php ?>";
+ pass "$file has <?php ?>";
} elsif ( $cont =~ m<<\? .* \?>>xs ) {
- ok 0 => "$file does not use <? ?>";
+ fail "$file does not use <? ?>";
} else {
- ok 1 => "$file has neither <?php ?> nor <? ?>, check it";
+ pass "$file has neither <?php ?> nor <? ?>, check it";
}
}
diff --git a/t/maint/unix-newlines.t b/t/maint/unix-newlines.t
index 91a24ad7..c47dd17c 100644
--- a/t/maint/unix-newlines.t
+++ b/t/maint/unix-newlines.t
@@ -5,23 +5,28 @@ use warnings;
use Test::More;;
use File::Find;
-use File::Slurp qw< slurp >;
-use Socket qw< $CRLF $LF >;
+use Socket '$CRLF';
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;
+plan 'no_plan';
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";
- }
+ open my $fh, "<", $file or die "Can't open $file: $!";
+ binmode $fh;
+
+ my $ok = 1;
+ while (<$fh>) {
+ if (/$CRLF/) {
+ fail "$file has \\r\\n on line $.";
+ $ok = 0;
+ }
+ }
+
+ pass "$file has only unix newlines" if $ok;
}