本文整理匯總了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;
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}