本文整理汇总了PHP中Symfony\Component\PropertyAccess\PropertyAccessorInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP PropertyAccessorInterface::expects方法的具体用法?PHP PropertyAccessorInterface::expects怎么用?PHP PropertyAccessorInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\PropertyAccess\PropertyAccessorInterface
的用法示例。
在下文中一共展示了PropertyAccessorInterface::expects方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRenderWithoutScalar
/**
* @expectedException \Lug\Component\Grid\Exception\InvalidTypeException
* @expectedExceptionMessage The "name" number column type expects a numeric value, got "stdClass".
*/
public function testRenderWithoutScalar()
{
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($path = 'path_value'))->will($this->returnValue(new \stdClass()));
$column = $this->createColumnMock();
$column->expects($this->once())->method('getName')->will($this->returnValue('name'));
$this->type->render($data, ['column' => $column, 'path' => $path]);
}
示例2: setUp
public function setUp()
{
$this->accessor = $this->getMockBuilder('Symfony\\Component\\PropertyAccess\\PropertyAccessorInterface')->getMock();
$this->accessor->expects($this->any())->method('getValue')->will($this->returnCallback(function ($item, $path) {
static $i = 0;
return array($item, $path, $i++);
}));
$this->resolver = new PropertyAccessResolver($this->accessor);
}
示例3: testRender
public function testRender()
{
$this->urlGenerator->expects($this->once())->method('generate')->with($this->identicalTo($route = 'route_value'), $this->identicalTo([$routeParameter = 'route_parameter' => $routeParameterValue = 'route_parameter_value']), $this->identicalTo($routeReferenceType = UrlGeneratorInterface::ABSOLUTE_PATH))->will($this->returnValue($url = 'url_value'));
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($routeParameter))->will($this->returnValue($routeParameterValue));
$action = $this->createActionMock();
$action->expects($this->once())->method('getLabel')->will($this->returnValue($actionLabel = 'action_label'));
$action->expects($this->once())->method('getOption')->with($this->identicalTo('trans_domain'))->will($this->returnValue($actionTransDomain = 'action_trans_domain'));
$this->formFactory->expects($this->once())->method('create')->with($this->identicalTo(CsrfProtectionType::class), $this->isNull(), $this->identicalTo(['method' => $method = Request::METHOD_DELETE, 'action' => $url, 'label' => $actionLabel, 'translation_domain' => $actionTransDomain]))->will($this->returnValue($form = $this->createFormMock()));
$form->expects($this->once())->method('createView')->will($this->returnValue($view = $this->createFormViewMock()));
$this->assertSame($view, $this->type->render($data, ['action' => $action, 'method' => strtolower($method), 'route' => $route, 'route_parameters' => [$routeParameter], 'route_reference_type' => $routeReferenceType]));
}
示例4: testMessageWithLabelPropertyPath
public function testMessageWithLabelPropertyPath()
{
$event = $this->createDomainEventMock();
$event->expects($this->once())->method('getMessageType')->will($this->returnValue($messageType = 'message_type'));
$event->expects($this->once())->method('setMessageType')->with($this->identicalTo($messageType));
$event->expects($this->once())->method('getMessage')->will($this->returnValue(null));
$event->expects($this->once())->method('getAction')->will($this->returnValue($action = 'action'));
$event->expects($this->once())->method('getObject')->will($this->returnValue($object = new \stdClass()));
$event->expects($this->once())->method('getResource')->will($this->returnValue($resource = $this->createResourceMock()));
$resource->expects($this->once())->method('getName')->will($this->returnValue($name = 'name'));
$resource->expects($this->once())->method('getLabelPropertyPath')->will($this->returnValue($labelPropertyPath = 'property_path'));
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($object), $this->identicalTo($labelPropertyPath))->will($this->returnValue($property = 'property'));
$this->translator->expects($this->once())->method('trans')->with($this->identicalTo('lug.' . $name . '.' . $action . '.' . $messageType), $this->identicalTo(['%' . $name . '%' => $property]))->will($this->returnValue($translation = 'translation'));
$event->expects($this->once())->method('setMessage')->with($this->identicalTo($translation));
$this->messageListener->addMessage($event);
}
示例5: testValidateDefaultLocale
public function testValidateDefaultLocale()
{
$this->localeProvider->expects($this->once())->method('getDefaultLocale')->will($this->returnValue($locale = $this->createLocaleMock()));
$domainEvent = $this->createDomainEventMock();
$domainEvent->expects($this->once())->method('getData')->will($this->returnValue($locale));
$domainEvent->expects($this->once())->method('getResource')->will($this->returnValue($resource = $this->createResourceMock()));
$resource->expects($this->exactly(2))->method('getName')->will($this->returnValue($resourceName = 'resource'));
$resource->expects($this->once())->method('getLabelPropertyPath')->will($this->returnValue($labelPropertyPath = 'code'));
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($locale), $this->identicalTo($labelPropertyPath))->will($this->returnValue($localeCode = 'code'));
$domainEvent->expects($this->once())->method('setStopped')->with($this->identicalTo(true));
$domainEvent->expects($this->once())->method('setStatusCode')->with($this->identicalTo(409));
$domainEvent->expects($this->once())->method('setMessageType')->with($this->identicalTo('error'));
$domainEvent->expects($this->once())->method('getAction')->will($this->returnValue('action'));
$this->translator->expects($this->once())->method('trans')->with($this->identicalTo('lug.resource.action.default'), $this->identicalTo(['%resource%' => $localeCode]), $this->identicalTo('flashes'))->will($this->returnValue($translation = 'translation'));
$domainEvent->expects($this->once())->method('setMessage')->with($this->identicalTo($translation));
$this->localeDomainSubscriber->validateDefaultLocale($domainEvent);
}
示例6: testRenderWithResource
/**
* @expectedException \Lug\Component\Grid\Exception\InvalidTypeException
* @expectedExceptionMessage The "name" json column type expects anything except a resource.
*/
public function testRenderWithResource()
{
$resource = fopen('php://temp', 'r');
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($path = 'path_value'))->will($this->returnValue($resource));
$column = $this->createColumnMock();
$column->expects($this->once())->method('getName')->will($this->returnValue('name'));
try {
$this->type->render($data, ['column' => $column, 'path' => $path, 'options' => 0, 'depth' => 512]);
$this->fail();
} catch (InvalidTypeException $e) {
}
if (is_resource($resource)) {
fclose($resource);
}
if (isset($e)) {
throw $e;
}
}
示例7: testResolveRedirectRouteParametersForwardParameters
public function testResolveRedirectRouteParametersForwardParameters()
{
$this->requestStack->expects($this->exactly(2))->method('getMasterRequest')->will($this->returnValue($request = $this->createRequestMock()));
$request->attributes->expects($this->once())->method('get')->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))->will($this->returnValue([$parameter = 'id']));
$request->query = $this->createParameterBagMock();
$request->query->expects($this->once())->method('all')->will($this->returnValue($query = ['foo' => 'bar']));
$object = new \stdClass();
$object->{$parameter} = $value = 1;
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($object), $this->identicalTo($parameter))->will($this->returnValue($value));
$this->assertSame(array_merge($query, [$parameter => $value]), $this->parameterResolver->resolveRedirectRouteParameters($object, true));
}
示例8: testRenderWithNull
public function testRenderWithNull()
{
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($path = 'path_value'))->will($this->returnValue(null));
$this->renderer->expects($this->never())->method('render');
$this->assertNull($this->type->render($data, ['path' => $path]));
}
示例9: testRender
public function testRender()
{
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($path = 'path_value'))->will($this->returnValue($twigData = 'twig_data'));
$this->twig->expects($this->once())->method('render')->with($this->identicalTo($template = 'template'), $this->identicalTo(array_merge($context = ['foo' => 'bar'], ['column' => $column = $this->createColumnMock(), 'data' => $twigData])))->will($this->returnValue($result = 'result'));
$this->assertSame($result, $this->type->render($data, ['column' => $column, 'path' => $path, 'template' => $template, 'context' => $context]));
}
示例10: testRender
public function testRender()
{
$this->urlGenerator->expects($this->once())->method('generate')->with($this->identicalTo($route = 'route_value'), $this->identicalTo([$routeParameter = 'route_parameter' => $routeParameterValue = 'route_parameter_value']), $this->identicalTo($routeReferenceType = UrlGeneratorInterface::ABSOLUTE_PATH))->will($this->returnValue($url = 'url_value'));
$this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($routeParameter))->will($this->returnValue($routeParameterValue));
$this->assertSame($url, $this->type->render($data, ['route' => $route, 'route_parameters' => [$routeParameter], 'route_reference_type' => $routeReferenceType]));
}