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


PHP ParameterBag::expects方法代码示例

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


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

示例1: getRequestAttributesMock

 /**
  * @return ParameterBag|PHPUnit_Framework_MockObject_MockObject
  */
 protected function getRequestAttributesMock()
 {
     if (!isset($this->requestAttributesMock)) {
         $this->requestAttributesMock = $this->getMock('Symfony\\Component\\HttpFoundation\\ParameterBag');
         $this->requestAttributesMock->expects($this->once())->method('get')->with('is_rest_request')->will($this->returnValue($this->isRestRequest));
     }
     return $this->requestAttributesMock;
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:11,代码来源:EventListenerTest.php

示例2: testMultipleBreadcrumbs

 /**
  * Test the generation of multiple breadcrumbs
  */
 public function testMultipleBreadcrumbs()
 {
     $label1 = 'foo';
     $route1 = 'bar';
     $label2 = 'baz';
     $route2 = 'qux';
     $this->requestAttributes->expects($this->any())->method('get')->will($this->returnValue(array(array('label' => $label1, 'route' => $route1), array('label' => $label2, 'route' => $route2))));
     $this->provider->onKernelRequest($this->responseEvent);
     $result = $this->provider->getBreadcrumbs();
     $this->assertCount(2, $result->getAll());
     $this->assertEquals($label1, $result->getAll()[0]->getLabel());
     $this->assertEquals($route1, $result->getAll()[0]->getRoute());
     $this->assertEquals($label2, $result->getAll()[1]->getLabel());
     $this->assertEquals($route2, $result->getAll()[1]->getRoute());
 }
开发者ID:pasblin,项目名称:breadcrumb-bundle,代码行数:18,代码来源:BreadcrumbProviderTest.php

示例3: testAccessSubscriberDoesNotAlterRequestIfAccessManagerGrantsAccess

 /**
  * Tests that if access is granted, AccessSubscriber will not throw an exception.
  */
 public function testAccessSubscriberDoesNotAlterRequestIfAccessManagerGrantsAccess()
 {
     $this->parameterBag->expects($this->once())->method('has')->with(RouteObjectInterface::ROUTE_OBJECT)->will($this->returnValue(TRUE));
     $this->parameterBag->expects($this->once())->method('get')->with(RouteObjectInterface::ROUTE_OBJECT)->will($this->returnValue($this->route));
     $this->accessManager->expects($this->once())->method('check')->with($this->equalTo($this->route))->will($this->returnValue(TRUE));
     $subscriber = new AccessSubscriber($this->accessManager, $this->currentUser);
     // We're testing that no exception is thrown in this case. There is no
     // return.
     $subscriber->onKernelRequestAccessCheck($this->event);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:13,代码来源:AccessSubscriberTest.php

示例4: testOnVisitNodeWithContext

 /**
  * Test FieldNameSearchListener::onVisitNode() with context
  *
  * @return void
  */
 public function testOnVisitNodeWithContext()
 {
     $fieldMapping = ['route.id' => ['array' => '$array', 'array.0' => '$array.0', 'array.0.field' => '$array.0.$field', 'array.0.field.ref' => '$array.0.$field.$ref']];
     $fieldValue = 'field-value';
     $this->requestAttrs->expects($this->once())->method('get')->with('_route')->willReturn('route.id');
     $node = new EqNode('$field.$ref', $fieldValue);
     $context = new \SplStack();
     $context->push(new ElemMatchNode('$array', $node));
     $builder = $this->getMockBuilder(Builder::class)->disableOriginalConstructor()->getMock();
     $event = new VisitNodeEvent($node, $builder, $context);
     $listener = $this->createListener($fieldMapping);
     $listener->onVisitNode($event);
     $this->assertNotSame($node, $event->getNode());
     $this->assertSame($builder, $event->getBuilder());
     $this->assertEquals(new EqNode('field.ref', $fieldValue), $event->getNode());
 }
开发者ID:alebon,项目名称:graviton,代码行数:21,代码来源:FieldNameSearchListenerTest.php

示例5: testOnVisitNodeWithContext

 /**
  * Test ExtReferenceSearchListener::onVisitNode() with context
  *
  * @return void
  */
 public function testOnVisitNodeWithContext()
 {
     $extrefMapping = ['route.id' => ['array.0.field.$ref']];
     $extrefUrl = 'extref.url';
     $extrefValue = ExtReference::create('Ref', 'id');
     $dbRefValue = \MongoDBRef::create($extrefValue->getRef(), $extrefValue->getId());
     $this->requestAttrs->expects($this->once())->method('get')->with('_route')->willReturn('route.id');
     $this->converter->expects($this->once())->method('getExtReference')->with($extrefUrl)->willReturn($extrefValue);
     $node = new EqNode('field.$ref', $extrefUrl);
     $context = new \SplStack();
     $context->push(new ElemMatchNode('array', $node));
     $builder = $this->getMockBuilder('Doctrine\\ODM\\MongoDB\\Query\\Builder')->disableOriginalConstructor()->getMock();
     $event = new VisitNodeEvent($node, $builder, $context);
     $listener = $this->createListener($extrefMapping);
     $listener->onVisitNode($event);
     $this->assertNotSame($node, $event->getNode());
     $this->assertSame($builder, $event->getBuilder());
     $this->assertEquals(new EqNode('field.$ref', $dbRefValue), $event->getNode());
 }
开发者ID:alebon,项目名称:graviton,代码行数:24,代码来源:ExtReferenceSearchListenerTest.php


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