Index: trunk/phase3/maintenance/parserTests.inc |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | /** |
43 | 43 | * boolean $useTemporaryTables Use temporary tables for the temporary database |
44 | 44 | */ |
45 | | - private $useTemporaryTables = true; |
| 45 | + private $useTemporaryTables = false; |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * boolean $databaseSetupDone True if the database has been set up |
— | — | @@ -145,6 +145,7 @@ |
146 | 146 | * Draw input from a set of test files |
147 | 147 | */ |
148 | 148 | function fuzzTest( $filenames ) { |
| 149 | + $GLOBALS['wgContLang'] = Language::factory( 'en' ); |
149 | 150 | $dict = $this->getFuzzInput( $filenames ); |
150 | 151 | $dictSize = strlen( $dict ); |
151 | 152 | $logMaxLength = log( $this->maxFuzzTestLength ); |
— | — | @@ -265,6 +266,7 @@ |
266 | 267 | * @return Boolean: true if passed all tests, false if any tests failed. |
267 | 268 | */ |
268 | 269 | public function runTestsFromFiles( $filenames ) { |
| 270 | + $GLOBALS['wgContLang'] = Language::factory( 'en' ); |
269 | 271 | $this->recorder->start(); |
270 | 272 | $this->setupDatabase(); |
271 | 273 | $ok = true; |
— | — | @@ -486,9 +488,6 @@ |
487 | 489 | */ |
488 | 490 | private function setupGlobals( $opts = '', $config = '' ) { |
489 | 491 | global $wgDBtype; |
490 | | - if ( !isset( $this->uploadDir ) ) { |
491 | | - $this->uploadDir = $this->setupUploadDir(); |
492 | | - } |
493 | 492 | |
494 | 493 | # Find out values for some special options. |
495 | 494 | $lang = |
— | — | @@ -711,53 +710,14 @@ |
712 | 711 | |
713 | 712 | |
714 | 713 | if ( $wgDBtype == 'oracle' ) { |
715 | | - # Insert 0 and 1 user_ids to prevent FK violations |
| 714 | + # Insert 0 user to prevent FK violations |
716 | 715 | |
717 | 716 | # Anonymous user |
718 | 717 | $db->insert( 'user', array( |
719 | 718 | 'user_id' => 0, |
720 | 719 | 'user_name' => 'Anonymous' ) ); |
721 | | - |
722 | | - # Hack-on-Hack: Insert a test user to be able to insert an image |
723 | | - $db->insert( 'user', array( |
724 | | - 'user_id' => 1, |
725 | | - 'user_name' => 'Tester' ) ); |
726 | 720 | } |
727 | 721 | |
728 | | - # Hack: Insert an image to work with |
729 | | - $db->insert( 'image', array( |
730 | | - 'img_name' => 'Foobar.jpg', |
731 | | - 'img_size' => 12345, |
732 | | - 'img_description' => 'Some lame file', |
733 | | - 'img_user' => 1, |
734 | | - 'img_user_text' => 'WikiSysop', |
735 | | - 'img_timestamp' => $db->timestamp( '20010115123500' ), |
736 | | - 'img_width' => 1941, |
737 | | - 'img_height' => 220, |
738 | | - 'img_bits' => 24, |
739 | | - 'img_media_type' => MEDIATYPE_BITMAP, |
740 | | - 'img_major_mime' => "image", |
741 | | - 'img_minor_mime' => "jpeg", |
742 | | - 'img_metadata' => serialize( array() ), |
743 | | - ) ); |
744 | | - |
745 | | - # This image will be blacklisted in [[MediaWiki:Bad image list]] |
746 | | - $db->insert( 'image', array( |
747 | | - 'img_name' => 'Bad.jpg', |
748 | | - 'img_size' => 12345, |
749 | | - 'img_description' => 'zomgnotcensored', |
750 | | - 'img_user' => 1, |
751 | | - 'img_user_text' => 'WikiSysop', |
752 | | - 'img_timestamp' => $db->timestamp( '20010115123500' ), |
753 | | - 'img_width' => 320, |
754 | | - 'img_height' => 240, |
755 | | - 'img_bits' => 24, |
756 | | - 'img_media_type' => MEDIATYPE_BITMAP, |
757 | | - 'img_major_mime' => "image", |
758 | | - 'img_minor_mime' => "jpeg", |
759 | | - 'img_metadata' => serialize( array() ), |
760 | | - ) ); |
761 | | - |
762 | 722 | # Update certain things in site_stats |
763 | 723 | $db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) ); |
764 | 724 | |
— | — | @@ -767,6 +727,31 @@ |
768 | 728 | # Make a new message cache |
769 | 729 | global $wgMessageCache, $wgMemc; |
770 | 730 | $wgMessageCache = new MessageCache( $wgMemc, true, 3600 ); |
| 731 | + |
| 732 | + $this->uploadDir = $this->setupUploadDir(); |
| 733 | + $user = User::createNew( 'WikiSysop' ); |
| 734 | + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) ); |
| 735 | + $image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array( |
| 736 | + 'width' => 1941, |
| 737 | + 'height' => 220, |
| 738 | + 'bits' => 24, |
| 739 | + 'media_type' => MEDIATYPE_BITMAP, |
| 740 | + 'mime' => 'image/jpeg', |
| 741 | + 'metadata' => serialize( array() ), |
| 742 | + 'fileExists' => true |
| 743 | + ), $db->timestamp( '20010115123500' ), $user ); |
| 744 | + |
| 745 | + # This image will be blacklisted in [[MediaWiki:Bad image list]] |
| 746 | + $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) ); |
| 747 | + $image->recordUpload2( '', 'zomgnotcensored', 'Borderline image', array( |
| 748 | + 'width' => 320, |
| 749 | + 'height' => 240, |
| 750 | + 'bits' => 24, |
| 751 | + 'media_type' => MEDIATYPE_BITMAP, |
| 752 | + 'mime' => 'image/jpeg', |
| 753 | + 'metadata' => serialize( array() ), |
| 754 | + 'fileExists' => true |
| 755 | + ), $db->timestamp( '20010115123500' ), $user ); |
771 | 756 | } |
772 | 757 | |
773 | 758 | /** |
— | — | @@ -791,6 +776,8 @@ |
792 | 777 | if ( !$this->databaseSetupDone ) { |
793 | 778 | return; |
794 | 779 | } |
| 780 | + $this->teardownUploadDir( $this->uploadDir ); |
| 781 | + |
795 | 782 | $this->changePrefix( $this->oldTablePrefix ); |
796 | 783 | $this->databaseSetupDone = false; |
797 | 784 | if ( $this->useTemporaryTables ) { |
— | — | @@ -825,14 +812,13 @@ |
826 | 813 | $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images"; |
827 | 814 | } |
828 | 815 | |
829 | | - wfDebug( "Creating upload directory $dir\n" ); |
| 816 | + //wfDebug( "Creating upload directory $dir\n" ); |
830 | 817 | if ( file_exists( $dir ) ) { |
831 | 818 | wfDebug( "Already exists!\n" ); |
832 | 819 | return $dir; |
833 | 820 | } |
834 | 821 | wfMkdirParents( $dir . '/3/3a' ); |
835 | 822 | copy( "$IP/skins/monobook/headbg.jpg", "$dir/3/3a/Foobar.jpg" ); |
836 | | - |
837 | 823 | wfMkdirParents( $dir . '/0/09' ); |
838 | 824 | copy( "$IP/skins/monobook/headbg.jpg", "$dir/0/09/Bad.jpg" ); |
839 | 825 | return $dir; |
— | — | @@ -848,10 +834,6 @@ |
849 | 835 | foreach ( $this->savedGlobals as $var => $val ) { |
850 | 836 | $GLOBALS[$var] = $val; |
851 | 837 | } |
852 | | - if ( isset( $this->uploadDir ) ) { |
853 | | - $this->teardownUploadDir( $this->uploadDir ); |
854 | | - unset( $this->uploadDir ); |
855 | | - } |
856 | 838 | } |
857 | 839 | |
858 | 840 | /** |
— | — | @@ -1045,7 +1027,6 @@ |
1046 | 1028 | * @param $line Integer: the input line number, for reporting errors |
1047 | 1029 | */ |
1048 | 1030 | public function addArticle( $name, $text, $line ) { |
1049 | | - $this->setupGlobals(); |
1050 | 1031 | $title = Title::newFromText( $name ); |
1051 | 1032 | if ( is_null( $title ) ) { |
1052 | 1033 | wfDie( "invalid title at line $line\n" ); |
— | — | @@ -1058,8 +1039,6 @@ |
1059 | 1040 | |
1060 | 1041 | $art = new Article( $title ); |
1061 | 1042 | $art->insertNewArticle( $text, '', false, false ); |
1062 | | - |
1063 | | - $this->teardownGlobals(); |
1064 | 1043 | } |
1065 | 1044 | |
1066 | 1045 | /** |
— | — | @@ -1728,8 +1707,9 @@ |
1729 | 1708 | $section = null; |
1730 | 1709 | continue; |
1731 | 1710 | } |
| 1711 | + global $wgUseTeX; |
1732 | 1712 | if ( $this->parser && |
1733 | | - preg_match( '/\\bmath\\b/i', $data['options'] ) && !$this->parser->savedGlobals['wgUseTeX'] ) { |
| 1713 | + preg_match( '/\\bmath\\b/i', $data['options'] ) && !$wgUseTeX ) { |
1734 | 1714 | # don't run math tests if $wgUseTeX is set to false in LocalSettings |
1735 | 1715 | $data = array(); |
1736 | 1716 | $section = null; |
Index: trunk/phase3/maintenance/tests/MediaWikiParserTest.php |
— | — | @@ -17,7 +17,8 @@ |
18 | 18 | public function run( PHPUnit_Framework_TestResult $result = null, $filter = false, |
19 | 19 | array $groups = array(), array $excludeGroups = array(), $processIsolation = false |
20 | 20 | ) { |
21 | | - global $IP; |
| 21 | + global $IP, $wgContLang; |
| 22 | + $wgContLang = Language::factory( 'en' ); |
22 | 23 | $this->backend->setupDatabase(); |
23 | 24 | |
24 | 25 | $iter = new TestFileIterator( "$IP/maintenance/parserTests.txt" ); |