r93511 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93510‎ | r93511 | r93512 >
Date:01:58, 30 July 2011
Author:kaldari
Status:ok
Tags:
Comment:
more phpUnit tests
Modified paths:
  • /trunk/extensions/CentralNotice/tests/CentralNoticeTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/tests/CentralNoticeTest.php
@@ -5,7 +5,8 @@
66 */
77 class CentralNoticeTest extends PHPUnit_Framework_TestCase {
88
9 - protected static $centralNotice;
 9+ protected static $centralNotice, $centralNoticeDB, $noticeTemplate;
 10+ var $campaignId;
1011
1112 protected function setUp() {
1213 parent::setUp();
@@ -13,11 +14,11 @@
1415 $noticeName = 'PHPUnitTestCampaign';
1516 $enabled = 0;
1617 $start = array(
17 - "month" => 07,
18 - "day" => 18,
19 - "year" => 2011,
20 - "hour" => 23,
21 - "min" => 55,
 18+ "month" => '07',
 19+ "day" => '18',
 20+ "year" => '2011',
 21+ "hour" => '23',
 22+ "min" => '55',
2223 );
2324 $projects = array( 'wikipedia', 'wikibooks' );
2425 $project_languages = array( 'en', 'de' );
@@ -25,11 +26,27 @@
2627 $geo_countries = array( 'US', 'AF' );
2728 self::$centralNotice->addCampaign( $noticeName, $enabled, $start, $projects,
2829 $project_languages, $geotargeted, $geo_countries );
 30+ $this->campaignId = CentralNotice::getNoticeId( 'PHPUnitTestCampaign' );
 31+
 32+ self::$noticeTemplate = new SpecialNoticeTemplate;
 33+ $bannerName = 'PHPUnitTestBanner';
 34+ $body = 'testing';
 35+ $displayAnon = 1;
 36+ $displayAccount = 1;
 37+ $fundaising = 1;
 38+ $landingPages = 'JA1, JA2';
 39+ self::$noticeTemplate->addTemplate( $bannerName, $body, $displayAnon, $displayAccount,
 40+ $fundaising, $landingPages );
 41+ self::$centralNotice->addTemplateTo( 'PHPUnitTestCampaign', 'PHPUnitTestBanner', '25' );
 42+
 43+ self::$centralNoticeDB = new CentralNoticeDB;
2944 }
3045
3146 protected function tearDown() {
3247 parent::tearDown();
3348 self::$centralNotice->removeCampaign( 'PHPUnitTestCampaign' );
 49+ self::$centralNotice->removeTemplateFor( 'PHPUnitTestCampaign', 'PHPUnitTestBanner' );
 50+ self::$noticeTemplate->removeTemplate ( 'PHPUnitTestBanner' );
3451 }
3552
3653 public function testDropDownList() {
@@ -60,5 +77,28 @@
6178 CentralNotice::getNoticeCountries( 'PHPUnitTestCampaign' )
6279 );
6380 }
 81+
 82+ public function testGetCampaignBanners() {
 83+ $campaignId = CentralNotice::getNoticeId( 'PHPUnitTestCampaign' );
 84+ $this->assertEquals(
 85+ '[{"name":"PHPUnitTestBanner","weight":25,"display_anon":1,"display_account":1,"fundraising":1,"landing_pages":"JA1, JA2","campaign":"PHPUnitTestCampaign"}]',
 86+ json_encode( CentralNoticeDB::getCampaignBanners( $campaignId ) )
 87+ );
 88+ }
 89+
 90+ public function testGetCampaignSettings() {
 91+ $campaignArray = array(
 92+ 'enabled' => 0,
 93+ 'end' => 20110818235500,
 94+ 'geo' => 1,
 95+ 'locked' => 0,
 96+ 'preferred' => 0,
 97+ 'start' => 20110718235500
 98+ );
 99+ $this->assertEquals(
 100+ $campaignArray,
 101+ CentralNoticeDB::getCampaignSettings( 'PHPUnitTestCampaign', false )
 102+ );
 103+ }
64104
65105 }

Status & tagging log