当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiResult::addParsedLimit方法代码示例

本文整理汇总了PHP中ApiResult::addParsedLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiResult::addParsedLimit方法的具体用法?PHP ApiResult::addParsedLimit怎么用?PHP ApiResult::addParsedLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiResult的用法示例。


在下文中一共展示了ApiResult::addParsedLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testInstanceDataMethods


//.........这里部分代码省略.........
     try {
         $result->addValue(null, 'file', $fh);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add resource(stream) to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     try {
         $result->addValue(null, null, $fh);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add resource(stream) to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     try {
         $obj->file = $fh;
         $result->addValue(null, 'sub', $obj);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add resource(stream) to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     try {
         $obj->file = $fh;
         $result->addValue(null, null, $obj);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add resource(stream) to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     fclose($fh);
     try {
         $result->addValue(null, 'inf', INF);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add non-finite floats to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     try {
         $result->addValue(null, null, INF);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add non-finite floats to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     try {
         $result->addValue(null, 'nan', NAN);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add non-finite floats to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     try {
         $result->addValue(null, null, NAN);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add non-finite floats to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     $result->addValue(null, null, NAN, ApiResult::NO_VALIDATE);
     try {
         $result->addValue(null, null, NAN, ApiResult::NO_SIZE_CHECK);
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Cannot add non-finite floats to ApiResult', $ex->getMessage(), 'Expected exception');
     }
     $result->reset();
     $result->addParsedLimit('foo', 12);
     $this->assertSame(array('limits' => array('foo' => 12), ApiResult::META_TYPE => 'assoc'), $result->getResultData());
     $result->addParsedLimit('foo', 13);
     $this->assertSame(array('limits' => array('foo' => 13), ApiResult::META_TYPE => 'assoc'), $result->getResultData());
     $this->assertSame(null, $result->getResultData(array('foo', 'bar', 'baz')));
     $this->assertSame(13, $result->getResultData(array('limits', 'foo')));
     try {
         $result->getResultData(array('limits', 'foo', 'bar'));
         $this->fail('Expected exception not thrown');
     } catch (InvalidArgumentException $ex) {
         $this->assertSame('Path limits.foo is not an array', $ex->getMessage(), 'Expected exception');
     }
     $result = new ApiResult(10);
     $formatter = new ApiErrorFormatter($result, Language::factory('en'), 'none', false);
     $result->setErrorFormatter($formatter);
     $this->assertFalse($result->addValue(null, 'foo', '12345678901'));
     $this->assertTrue($result->addValue(null, 'foo', '12345678901', ApiResult::NO_SIZE_CHECK));
     $this->assertSame(0, $result->getSize());
     $result->reset();
     $this->assertTrue($result->addValue(null, 'foo', '1234567890'));
     $this->assertFalse($result->addValue(null, 'foo', '1'));
     $result->removeValue(null, 'foo');
     $this->assertTrue($result->addValue(null, 'foo', '1'));
     $result = new ApiResult(10);
     $obj = new ApiResultTestSerializableObject('ok');
     $obj->foobar = 'foobaz';
     $this->assertTrue($result->addValue(null, 'foo', $obj));
     $this->assertSame(2, $result->getSize());
     $result = new ApiResult(8388608);
     $result2 = new ApiResult(8388608);
     $result2->addValue(null, 'foo', 'bar');
     $result->addValue(null, 'baz', $result2);
     $this->assertSame(array('baz' => array('foo' => 'bar', ApiResult::META_TYPE => 'assoc'), ApiResult::META_TYPE => 'assoc'), $result->getResultData());
     $result = new ApiResult(8388608);
     $result->addValue(null, 'foo', "foo�bar");
     $result->addValue(null, 'bar', "á");
     $result->addValue(null, 'baz', 74);
     $result->addValue(null, null, "foo�bar");
     $result->addValue(null, null, "á");
     $this->assertSame(array('foo' => "foo�bar", 'bar' => "á", 'baz' => 74, 0 => "foo�bar", 1 => "á", ApiResult::META_TYPE => 'assoc'), $result->getResultData());
 }
开发者ID:ucfengzhun,项目名称:mediawiki,代码行数:101,代码来源:ApiResultTest.php


注:本文中的ApiResult::addParsedLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。