コード例 #1
0
 /**
  * @covers ApiRawMessage
  */
 public function testApiRawMessage()
 {
     $msg = new RawMessage('foo', array('baz'));
     $msg->inLanguage('de')->title(Title::newMainPage());
     $msg2 = new ApiRawMessage($msg, 'code', array('data'));
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg2 = unserialize(serialize($msg2));
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg = new RawMessage('foo', array('baz'));
     $msg2 = new ApiRawMessage(array('foo', 'baz'), 'code', array('data'));
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg = new RawMessage('foo');
     $msg2 = new ApiRawMessage('foo', 'code', array('data'));
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg2->setApiCode('code', array('data'));
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg2->setApiCode(null);
     $this->assertEquals('foo', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg2->setApiData(array('data2'));
     $this->assertEquals(array('data2'), $msg2->getApiData());
 }
コード例 #2
0
 /**
  * @covers Message::bitrateParams
  */
 public function testMessageBitrateParams()
 {
     $lang = Language::factory('en');
     $msg = new RawMessage('$1');
     $this->assertEquals($lang->formatBitrate(123456), $msg->inLanguage($lang)->bitrateParams(123456)->plain(), 'bitrateParams is handled correctly');
 }
コード例 #3
0
ファイル: MessageTest.php プロジェクト: paladox/mediawiki
 /**
  * @covers Message::text
  * @covers Message::parse
  * @covers Message::parseAsBlock
  * @covers Message::toString
  * @covers Message::transformText
  * @covers Message::parseText
  * @dataProvider provideParser
  */
 public function testParser($expect, $format)
 {
     $msg = new RawMessage("''&'' <x><!-- x -->");
     $this->assertEquals($expect, $msg->inLanguage('en')->{$format}());
 }
コード例 #4
0
ファイル: MessageTest.php プロジェクト: biribogos/wikihow-src
 /**
  * FIXME: This should not need database, but Language#formatExpiry does (bug 55912)
  * @group Database
  * @todo this should be split up into multiple test methods
  * @covers Message::numParams
  * @covers Message::durationParams
  * @covers Message::expiryParams
  * @covers Message::timeperiodParams
  * @covers Message::sizeParams
  * @covers Message::bitrateParams
  */
 public function testMessageParamTypes()
 {
     $lang = Language::factory('en');
     $msg = new RawMessage('$1');
     $this->assertEquals($lang->formatNum(123456.789), $msg->inLanguage($lang)->numParams(123456.789)->plain(), 'numParams is handled correctly');
     $msg = new RawMessage('$1');
     $this->assertEquals($lang->formatDuration(1234), $msg->inLanguage($lang)->durationParams(1234)->plain(), 'durationParams is handled correctly');
     $msg = new RawMessage('$1');
     $this->assertEquals($lang->formatExpiry(wfTimestampNow()), $msg->inLanguage($lang)->expiryParams(wfTimestampNow())->plain(), 'expiryParams is handled correctly');
     $msg = new RawMessage('$1');
     $this->assertEquals($lang->formatTimePeriod(1234), $msg->inLanguage($lang)->timeperiodParams(1234)->plain(), 'timeperiodParams is handled correctly');
     $msg = new RawMessage('$1');
     $this->assertEquals($lang->formatSize(123456), $msg->inLanguage($lang)->sizeParams(123456)->plain(), 'sizeParams is handled correctly');
     $msg = new RawMessage('$1');
     $this->assertEquals($lang->formatBitrate(123456), $msg->inLanguage($lang)->bitrateParams(123456)->plain(), 'bitrateParams is handled correctly');
 }