本文整理汇总了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());
}