當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。