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


PHP PropertyAccessorInterface::expects方法代码示例

本文整理汇总了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]);
 }
开发者ID:blazarecki,项目名称:lug,代码行数:11,代码来源:NumberTypeTest.php

示例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);
 }
开发者ID:nicmart,项目名称:treebuilder,代码行数:9,代码来源:PropertyAccessResolverTest.php

示例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]));
 }
开发者ID:php-lug,项目名称:lug,代码行数:11,代码来源:LinkSecureTypeTest.php

示例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);
 }
开发者ID:blazarecki,项目名称:lug,代码行数:16,代码来源:MessageListenerTest.php

示例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);
 }
开发者ID:php-lug,项目名称:lug,代码行数:17,代码来源:LocaleDomainSubscriberTest.php

示例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;
     }
 }
开发者ID:php-lug,项目名称:lug,代码行数:22,代码来源:JsonTypeTest.php

示例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));
 }
开发者ID:php-lug,项目名称:lug,代码行数:11,代码来源:ParameterResolverTest.php

示例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]));
 }
开发者ID:php-lug,项目名称:lug,代码行数:6,代码来源:ResourceTypeTest.php

示例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]));
 }
开发者ID:php-lug,项目名称:lug,代码行数:6,代码来源:TwigTypeTest.php

示例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]));
 }
开发者ID:php-lug,项目名称:lug,代码行数:6,代码来源:LinkTypeTest.php


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