本文整理汇总了PHP中Prophecy\Argument::allOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Argument::allOf方法的具体用法?PHP Argument::allOf怎么用?PHP Argument::allOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prophecy\Argument
的用法示例。
在下文中一共展示了Argument::allOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: realpath
/**
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param \Doctrine\Common\Annotations\AnnotationReader $annotationReader
* @param \FSi\Bundle\AdminBundle\Finder\AdminClassFinder $adminClassFinder
*/
function it_registers_annotated_admin_classes_as_services($container, $annotationReader, $adminClassFinder)
{
$container->getParameter('kernel.bundles')->willReturn(array('FSi\\Bundle\\AdminBundle\\spec\\fixtures\\MyBundle', 'FSi\\Bundle\\AdminBundle\\FSiAdminBundle', 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'));
$baseDir = __DIR__ . '/../../../../../..';
$adminClassFinder->findClasses(array(realpath($baseDir . '/spec/fixtures/Admin'), realpath($baseDir . '/Admin')))->willReturn(array('FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\CRUDElement'));
$annotationReader->getClassAnnotation(Argument::allOf(Argument::type('ReflectionClass'), Argument::which('getName', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\CRUDElement')), 'FSi\\Bundle\\AdminBundle\\Annotation\\Element')->willReturn(null);
$annotationReader->getClassAnnotation(Argument::allOf(Argument::type('ReflectionClass'), Argument::which('getName', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement')), 'FSi\\Bundle\\AdminBundle\\Annotation\\Element')->willReturn(new Element(array()));
$container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\DirectoryResource'), Argument::which('getResource', realpath($baseDir . '/spec/fixtures/Admin')), Argument::which('getPattern', '/\\.php$/')))->shouldBeCalled();
$container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\DirectoryResource'), Argument::which('getResource', realpath($baseDir . '/Admin')), Argument::which('getPattern', '/\\.php$/')))->shouldBeCalled();
$container->addDefinitions(Argument::that(function ($definitions) {
if (count($definitions) !== 1) {
return false;
}
/** @var \Symfony\Component\DependencyInjection\Definition $definition */
$definition = $definitions[0];
if ($definition->getClass() !== 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement') {
return false;
}
if (!$definition->hasTag('admin.element')) {
return false;
}
return true;
}))->shouldBeCalled();
$this->process($container);
}
示例2:
function it_render_template_with_paginator(EngineInterface $templating, Response $response, GalleryManagerInterface $galleryManager, AdapterInterface $adapter)
{
$galleryManager->createPagerfantaAdapter()->willReturn($adapter);
$adapter->getNbResults()->willReturn(5);
$templating->renderResponse('FSiGalleryBundle:Gallery:list.html.twig', Argument::allOf(Argument::withEntry('galleries', Argument::type('Pagerfanta\\Pagerfanta')), Argument::withEntry('preview_photos_count', 4)))->willReturn($response);
$this->listAction(2)->shouldReturn($response);
}
示例3: testShouldDispatchEvents
public function testShouldDispatchEvents()
{
$notification = Email::create();
$notifyArg = Argument::allOf(Argument::type(Email::class), Argument::that(function ($arg) use($notification) {
return $arg !== $notification;
}));
$handler = $this->prophesize(NotificationHandlerInterface::class);
$handler->getName()->willReturn('default');
$handler->supports(Argument::any())->willReturn(true);
$handler->notify($notifyArg)->willReturn();
$handler2 = $this->prophesize(NotificationHandlerInterface::class);
$handler2->getName()->willReturn('default');
$handler2->supports(Argument::any())->willReturn(true);
$handler2->notify($notifyArg)->willReturn();
$this->dispatcher->dispatch('notifire.pre_notify', Argument::type(PreNotifyEvent::class))->shouldBeCalled();
$this->dispatcher->dispatch('notifire.notify', Argument::that(function ($arg) use($notification) {
if (!$arg instanceof NotifyEvent) {
return false;
}
$not = $arg->getNotification();
return $not !== $notification;
}))->shouldBeCalledTimes(2);
$this->dispatcher->dispatch('notifire.post_notify', Argument::type(PostNotifyEvent::class))->shouldBeCalled();
$this->manager->addHandler($handler->reveal());
$this->manager->addHandler($handler2->reveal());
$this->manager->notify($notification);
}
示例4: it_set_controller_if_init_return_response
public function it_set_controller_if_init_return_response(FilterControllerEvent $event, Request $request, SampleInitController $controller)
{
$event->getRequest()->willReturn($request);
$event->getController()->willReturn(array($controller));
$controller->init($request)->willReturn(new Response('http://example.com/'));
$event->setController(Argument::allOf(Argument::withEntry('0', Argument::type('Yavin\\Symfony\\Controller\\InitControllerSubscriber')), Argument::withEntry('1', 'responseAction')))->shouldBeCalled();
$this->onKernelController($event);
}
示例5:
function it_adds_new_entity_with_field_set(MapBuilder $builder, ResourceRepository $repository, TextType $resource)
{
$resource->getName()->willReturn('resources_group.resource_a.en');
$repository->get('resources_group.resource_a.en')->willReturn(null);
$builder->getResource(Argument::type('string'))->willReturn($resource);
$resource->getResourceProperty()->willReturn('textValue');
$repository->add(Argument::allOf(Argument::type('spec\\FSi\\Bundle\\ResourceRepositoryBundle\\Repository\\ResourceEntity'), Argument::which('getTextValue', 'text')))->shouldBeCalled();
$this->set('resources_group.resource_a', 'text');
}
示例6: testUseNameAsAttributeIfServiceAndIdentIsGiven
public function testUseNameAsAttributeIfServiceAndIdentIsGiven()
{
$serviceName = 'some-service';
$identAttribute = 'source';
$client = $this->getRiemannClient();
$logger = new Logger($client->reveal(), $serviceName, $identAttribute);
$logger->log(['service' => 'foo']);
$client->sendEvent(Argument::allOf(Argument::withEntry('service', 'foo'), Argument::withEntry('attributes', [['key' => $identAttribute, 'value' => $serviceName]])))->shouldHaveBeenCalled();
}
示例7: it_loads_resources_config_only_if_resource_repository_extension_exists
/**
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @param \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $bag
*/
public function it_loads_resources_config_only_if_resource_repository_extension_exists($container, $bag)
{
$container->hasExtension(Argument::type('string'))->willReturn(false);
$container->hasExtension('fsi_resource_repository')->willReturn(true);
$container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\FileResource'), Argument::that(function ($value) {
return $value instanceof FileResource && preg_match('/context\\/resource\\.xml$/', $value->getResource());
})))->shouldBeCalled();
$container->getParameterBag()->willReturn($bag);
$container->setDefinition(Argument::type('string'), Argument::type('Symfony\\Component\\DependencyInjection\\Definition'))->shouldBeCalled();
$this->process($container);
}
示例8: testTagging
public function testTagging()
{
$definitionObserver = $this->prophesize('\\Symfony\\Component\\DependencyInjection\\Definition');
$definitionObserver->addMethodCall("addHelper", Argument::allOf(Argument::containing('test'), Argument::containing(new Reference('handlebars.helper.test'))))->shouldBeCalled();
$containerObserver = $this->prophesize('\\Symfony\\Component\\DependencyInjection\\ContainerBuilder');
$containerObserver->has('handlebars.helper')->willReturn(true)->shouldBeCalled();
$containerObserver->findDefinition('handlebars.helper')->willReturn($definitionObserver->reveal())->shouldBeCalled();
$taggedServices = ['handlebars.helper.test' => [['id' => 'test']]];
$containerObserver->findTaggedServiceIds('handlebars.helper')->willReturn($taggedServices)->shouldBeCalled();
$helperPass = new HelperPass();
$helperPass->process($containerObserver->reveal());
}
示例9: Request
/**
* @param \FSi\Bundle\AdminSecurityBundle\Model\UserPasswordResetInterface $user
* @param \Twig_Environment $twig
* @param \Twig_Template $template
* @param \Swift_Mailer $mailer
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
*/
function it_should_render_template($user, $twig, $template, $mailer, $requestStack)
{
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_USER_AGENT' => 'user agent', 'REMOTE_ADDR' => '192.168.99.99'));
$requestStack->getMasterRequest()->willReturn($request);
$templateParameters = array('user' => $user, 'ip' => '192.168.99.99', 'user_agent' => 'user agent');
$twig->mergeGlobals($templateParameters)->willReturn($templateParameters);
$twig->loadTemplate('mailer-template.html.twig')->willReturn($template);
$template->renderBlock('subject', $templateParameters)->willReturn('subject string');
$template->renderBlock('body_html', $templateParameters)->willReturn('body string');
$user->getEmail()->willReturn('user@example.com');
$mailer->send(Argument::allOf(Argument::type('\\Swift_Message'), Argument::which('getSubject', 'subject string'), Argument::which('getTo', array('user@example.com' => null)), Argument::which('getFrom', array('from@fsi.pl' => null)), Argument::which('getReplyTo', array('replay-to@fsi.pl' => null)), Argument::which('getBody', 'body string')))->willReturn(1);
$this->sendPasswordResetMail($user)->shouldReturn(1);
}
示例10: preConsume_should_log_debug_message
/**
* @test
*/
public function preConsume_should_log_debug_message()
{
$body = 'payload-body';
$messageName = 'message-name';
$methodName = 'MyClass::myMethod';
/** @var ConsumerContainer $consumerContainer */
$consumerContainer = $this->prophesize(ConsumerContainer::class);
$consumerContainer->getRoutingKey()->willReturn($messageName);
$consumerContainer->getMethodName()->willReturn($methodName);
$event = new ConsumerEvent(new AMQPMessage($body), $consumerContainer->reveal());
$this->subscriber->preConsume($event);
$this->logger->debug(Argument::allOf(Argument::containingString($messageName), Argument::containingString($methodName), Argument::containingString($body)))->shouldHaveBeenCalled();
}
示例11: handle_should_log_message_with_payload
/**
* @test
*/
public function handle_should_log_message_with_payload()
{
$exceptionMessage = "Fatal error";
$baseException = new Exception($exceptionMessage);
$payloadMessage = $this->prophesize(MessageInterface::class);
$exception = new ConsumerContainerException($this->consumerContainer->reveal(), new AMQPMessage(), $payloadMessage->reveal(), $baseException);
$this->handler->handle($exception);
$this->logger->warning(Argument::allOf(Argument::containingString(self::MESSAGE_CLASS), Argument::containingString($exceptionMessage)), Argument::that(function ($context) use($baseException) {
verify($context['exception'])->isInstanceOf(ConsumerContainerException::class);
verify($context['exception']->getPrevious())->equals($baseException);
return $context;
}))->shouldHaveBeenCalled();
}
示例12: testLoadTemplateAndCompileWithoutAutoReload
public function testLoadTemplateAndCompileWithoutAutoReload()
{
$loader = $this->prophesize('JaySDe\\HandlebarsBundle\\Loader\\FilesystemLoader');
$loader->getCacheKey('test')->willReturn(__DIR__ . '/Fixtures/Resources/views/main.hbs');
$loader->getSource('test')->willReturn(__DIR__ . '/Fixtures/Resources/views/main.hbs');
$helper = $this->prophesize('JaySDe\\HandlebarsBundle\\HandlebarsHelperService');
$profiler = $this->prophesize('JaySDe\\HandlebarsBundle\\HandlebarsProfileExtension');
$cache = $this->prophesize('JaySDe\\HandlebarsBundle\\Cache\\Filesystem');
$cache->generateKey('test')->willReturn('test');
$cache->write('test', Argument::type('string'), Argument::allOf(Argument::containing(new FileResource(__DIR__ . '/Fixtures/Resources/views/main.hbs'))))->shouldBeCalled();
$cache->load('test')->shouldBeCalled();
$environment = new HandlebarsEnvironment($loader->reveal(), $helper->reveal(), ['auto_reload' => false], $cache->reveal(), $profiler->reveal());
$environment->loadTemplate('test');
}
示例13: let
function let(RouterInterface $router, IdentityResolver $identityResolver, DefinitionInterface $definition, \stdClass $object)
{
$this->beConstructedWith($router, $identityResolver);
$router->generate('bravesheep_crudify.index', Argument::withKey('mapping'))->will(function ($args) {
return '/' . $args[1]['mapping'] . '/index';
});
$router->generate('bravesheep_crudify.new', Argument::withKey('mapping'))->will(function ($args) {
return '/' . $args[1]['mapping'] . '/new';
});
$router->generate('bravesheep_crudify.create', Argument::withKey('mapping'))->will(function ($args) {
return '/' . $args[1]['mapping'] . '/create';
});
$router->generate('bravesheep_crudify.edit', Argument::allOf(Argument::withKey('mapping'), Argument::withKey('id')))->will(function ($args) {
return '/' . $args[1]['mapping'] . '/edit/' . $args[1]['id'];
});
$router->generate('bravesheep_crudify.update', Argument::allOf(Argument::withKey('mapping'), Argument::withKey('id')))->will(function ($args) {
return '/' . $args[1]['mapping'] . '/update/' . $args[1]['id'];
});
$router->generate('bravesheep_crudify.delete', Argument::allOf(Argument::withKey('mapping'), Argument::withKey('id')))->will(function ($args) {
return '/' . $args[1]['mapping'] . '/delete/' . $args[1]['id'];
});
$definition->getName()->willReturn('test');
$identityResolver->getId($definition, $object)->willReturn(42);
}
示例14:
/**
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
*/
function it_should_set_default_options($resolver)
{
$resolver->setDefaults(Argument::allOf(Argument::withEntry('data_class', 'FSi\\DoctrineExtensions\\Uploadable\\File'), Argument::withEntry('constraints', Argument::withEntry(0, Argument::type('\\FSi\\Bundle\\DoctrineExtensionsBundle\\Validator\\Constraints\\File')))))->shouldBeCalled();
$this->setDefaultOptions($resolver);
}
示例15: isAnArrayContainingAReferenceAndAPriority
private function isAnArrayContainingAReferenceAndAPriority($service, $priority)
{
return Argument::allOf(Argument::withEntry(0, Argument::allOf(Argument::type('Symfony\\Component\\DependencyInjection\\Reference'), Argument::which('__toString', $service))));
}