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


PHP ParamFetcher::setContainer方法代码示例

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


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

示例1: testEmptyValidator

 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage The ParamFetcher requirements feature requires the symfony/validator component.
  */
 public function testEmptyValidator()
 {
     $param = $this->createMockedParam('none', null, array(), false, null, array('constraint'));
     $this->setParams([$param]);
     $fetcher = new ParamFetcher($this->paramReader, $this->requestStack, $this->violationFormatter, null);
     $fetcher->setContainer($this->container);
     $fetcher->setController($this->controller);
     $fetcher->get('none', '42');
 }
开发者ID:AAstakhov,项目名称:FOSRestBundle,代码行数:13,代码来源:ParamFetcherTest.php

示例2: testCustomErrorMessage

 public function testCustomErrorMessage()
 {
     $param = new QueryParam();
     $param->name = 'fero';
     $errorMessage = "variable must be an integer";
     $param->requirements = array('rule' => '\\d+', 'error_message' => $errorMessage);
     $param->description = 'integer value';
     $param->strict = true;
     $request = new Request(array('fero' => 'foobar'), array(), array('_controller' => __CLASS__ . '::stubAction'));
     $reader = $this->getMockBuilder('FOS\\RestBundle\\Request\\ParamReader')->disableOriginalConstructor()->getMock();
     $reader->expects($this->any())->method('read')->will($this->returnValue(array('fero' => $param)));
     $constraint = new Regex(array('pattern' => '#^(?:\\d+)$#xsu', 'message' => $errorMessage));
     $errors = new ConstraintViolationList(array(new ConstraintViolation($errorMessage, null, array(), null, null, null)));
     $this->validator->expects($this->once())->method('validateValue')->with('foobar', $constraint)->will($this->returnValue($errors));
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $queryFetcher = new ParamFetcher($reader, $requestStack, $this->violationFormatter, $this->validator);
     $queryFetcher->setContainer($this->container);
     $queryFetcher->setController($this->controller);
     try {
         $queryFetcher->get('fero');
         $this->fail('Fetching get() in strict mode with no default value did not throw an exception');
     } catch (HttpException $httpException) {
         $this->assertEquals($errorMessage, $httpException->getMessage());
     }
 }
开发者ID:ktounet,项目名称:FOSRestBundle,代码行数:26,代码来源:ParamFetcherTest.php


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