r101049 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101048‎ | r101049 | r101050 >
Date:20:54, 27 October 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
FU r100915: split out GlobalWithDBTest (tests which need the DB)
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/GlobalFunctions/GlobalTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/GlobalFunctions/GlobalTest.php
@@ -934,29 +934,6 @@
935935 "Called eval.php --help --test with wrapper and php option" ),
936936 );
937937 }
938 -
939 - /**
940 - * @dataProvider provideWfIsBadImageList
941 - */
942 - function testWfIsBadImage( $name, $title, $blacklist, $expected, $desc ) {
943 - $this->assertEquals( $expected, wfIsBadImage( $name, $title, $blacklist ), $desc );
944 - }
945 -
946 - function provideWfIsBadImageList() {
947 - $blacklist = '* [[File:Bad.jpg]] except [[Nasty page]]';
948 - return array(
949 - array( 'Bad.jpg', false, $blacklist, true,
950 - 'Called on a bad image' ),
951 - array( 'Bad.jpg', Title::makeTitle( NS_MAIN, 'A page' ), $blacklist, true,
952 - 'Called on a bad image' ),
953 - array( 'NotBad.jpg', false, $blacklist, false,
954 - 'Called on a non-bad image' ),
955 - array( 'Bad.jpg', Title::makeTitle( NS_MAIN, 'Nasty page' ), $blacklist, false,
956 - 'Called on a bad image but is on a whitelisted page' ),
957 - array( 'File:Bad.jpg', false, $blacklist, false,
958 - 'Called on a bad image with File:' ),
959 - );
960 - }
961938 /* TODO: many more! */
962939 }
963940
Index: trunk/phase3/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
@@ -0,0 +1,29 @@
 2+<?php
 3+
 4+/**
 5+ * @group Database
 6+ */
 7+class GlobalWithDBTest extends MediaWikiTestCase {
 8+ /**
 9+ * @dataProvider provideWfIsBadImageList
 10+ */
 11+ function testWfIsBadImage( $name, $title, $blacklist, $expected, $desc ) {
 12+ $this->assertEquals( $expected, wfIsBadImage( $name, $title, $blacklist ), $desc );
 13+ }
 14+
 15+ function provideWfIsBadImageList() {
 16+ $blacklist = '* [[File:Bad.jpg]] except [[Nasty page]]';
 17+ return array(
 18+ array( 'Bad.jpg', false, $blacklist, true,
 19+ 'Called on a bad image' ),
 20+ array( 'Bad.jpg', Title::makeTitle( NS_MAIN, 'A page' ), $blacklist, true,
 21+ 'Called on a bad image' ),
 22+ array( 'NotBad.jpg', false, $blacklist, false,
 23+ 'Called on a non-bad image' ),
 24+ array( 'Bad.jpg', Title::makeTitle( NS_MAIN, 'Nasty page' ), $blacklist, false,
 25+ 'Called on a bad image but is on a whitelisted page' ),
 26+ array( 'File:Bad.jpg', false, $blacklist, false,
 27+ 'Called on a bad image with File:' ),
 28+ );
 29+ }
 30+}
Property changes on: trunk/phase3/tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php
___________________________________________________________________
Added: svn:eol-style
131 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100915* Allow passing in a blacklist into wfIsBadImage()...aaron00:23, 27 October 2011

Comments

#Comment by Hashar (talk | contribs)   15:41, 30 October 2011

Can we really apply the " @group Database" statement to a class? I am wondering if PHPUnit really support that.

#Comment by Platonides (talk | contribs)   15:44, 30 October 2011

Yes, that's how we have been using it since the beginning (what surprised me was that it seems to also be possible to apply it toi just one method).

#Comment by Hashar (talk | contribs)   20:46, 30 October 2011

To me, the @group statement was only to be applied to methods :d

#Comment by Aaron Schulz (talk | contribs)   20:49, 30 October 2011

Didn't know you could do that :)

Status & tagging log