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


PHP Argument::that方法代码示例

本文整理汇总了PHP中Prophecy\Argument::that方法的典型用法代码示例。如果您正苦于以下问题:PHP Argument::that方法的具体用法?PHP Argument::that怎么用?PHP Argument::that使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Prophecy\Argument的用法示例。


在下文中一共展示了Argument::that方法的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);
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:30,代码来源:AdminAnnotatedElementPassSpec.php

示例2: foreach

 function it_should_have_fields(FormBuilderInterface $builder, FormBuilderInterface $costBuilder, FormBuilderInterface $emailBuilder)
 {
     // Cost field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->create('cost', 'money', Argument::cetera())->shouldBeCalled()->willReturn($costBuilder);
     /** @noinspection PhpParamsInspection */
     /** @noinspection PhpUndefinedMethodInspection */
     $costBuilder->addViewTransformer(Argument::type(MoneyTransformer::class), true)->willReturn($costBuilder);
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add($costBuilder)->shouldBeCalled()->willReturn($builder);
     // Stripe field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add('stripe_form', 'cm_stripe', Argument::that(function (array $options) {
         $expectedOptions = ['inherit_data' => true, 'label' => false];
         foreach ($expectedOptions as $option => $value) {
             if (!isset($options[$option]) || $options[$option] !== $value) {
                 return false;
             }
         }
         return true;
     }))->shouldBeCalled()->willReturn($builder);
     // Description field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add('description', Argument::cetera())->shouldBeCalled()->willReturn($builder);
     // User email field
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->create('userEmail', Argument::cetera())->shouldBeCalled()->willReturn($emailBuilder);
     /** @noinspection PhpParamsInspection */
     /** @noinspection PhpUndefinedMethodInspection */
     $emailBuilder->addViewTransformer(Argument::type(EmailTransformer::class), true)->willReturn($emailBuilder);
     /** @noinspection PhpUndefinedMethodInspection */
     $builder->add($emailBuilder)->shouldBeCalled()->willReturn($builder);
     /** @noinspection PhpUndefinedMethodInspection */
     $this->buildForm($builder, []);
 }
开发者ID:cubicmushroom,项目名称:stripe-bundle,代码行数:35,代码来源:TakePaymentTypeSpec.php

示例3: testHtmlResponse

 /**
  * @covers ::processAttachments
  *
  * @dataProvider attachmentsProvider
  */
 public function testHtmlResponse(array $attachments)
 {
     $big_pipe_response = new BigPipeResponse('original');
     $big_pipe_response->setAttachments($attachments);
     // This mock is the main expectation of this test: verify that the decorated
     // service (that is this mock) never receives BigPipe placeholder
     // attachments, because it doesn't know (nor should it) how to handle them.
     $html_response_attachments_processor = $this->prophesize(AttachmentsResponseProcessorInterface::class);
     $html_response_attachments_processor->processAttachments(Argument::that(function ($response) {
         return $response instanceof HtmlResponse && empty(array_intersect(['big_pipe_placeholders', 'big_pipe_nojs_placeholders'], array_keys($response->getAttachments())));
     }))->will(function ($args) {
         /** @var \Symfony\Component\HttpFoundation\Response|\Drupal\Core\Render\AttachmentsInterface $response */
         $response = $args[0];
         // Simulate its actual behavior.
         $attachments = array_diff_key($response->getAttachments(), ['html_response_attachment_placeholders' => TRUE]);
         $response->setContent('processed');
         $response->setAttachments($attachments);
         return $response;
     })->shouldBeCalled();
     $big_pipe_response_attachments_processor = $this->createBigPipeResponseAttachmentsProcessor($html_response_attachments_processor);
     $processed_big_pipe_response = $big_pipe_response_attachments_processor->processAttachments($big_pipe_response);
     // The secondary expectation of this test: the original (passed in) response
     // object remains unchanged, the processed (returned) response object has
     // the expected values.
     $this->assertSame($attachments, $big_pipe_response->getAttachments(), 'Attachments of original response object MUST NOT be changed.');
     $this->assertEquals('original', $big_pipe_response->getContent(), 'Content of original response object MUST NOT be changed.');
     $this->assertEquals(array_diff_key($attachments, ['html_response_attachment_placeholders' => TRUE]), $processed_big_pipe_response->getAttachments(), 'Attachments of returned (processed) response object MUST be changed.');
     $this->assertEquals('processed', $processed_big_pipe_response->getContent(), 'Content of returned (processed) response object MUST be changed.');
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:34,代码来源:BigPipeResponseAttachmentsProcessorTest.php

示例4: it_loads_the_configuration

 /**
  * @param Symfony\Component\DependencyInjection\ContainerBuilder $container
  * @param Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag
  * @param Symfony\Component\DependencyInjection\Definition $libraryDefinition
  * @param Symfony\Component\DependencyInjection\Definition $parserDefinition
  */
 public function it_loads_the_configuration($container, $parameterBag, $libraryDefinition, $parserDefinition)
 {
     $container->getParameterBag()->shouldBeCalled()->willReturn($parameterBag);
     $container->hasExtension(Argument::any())->shouldBeCalled()->willReturn(false);
     $container->addResource(Argument::any())->shouldBeCalled()->willReturn($container);
     foreach (array('dispatcher', 'metadata.driver', 'metadata.factory', 'metadata.reader', 'parser', 'library', 'parser', 'formatter', 'formatter.markdown', 'formatter.textile', 'validator', 'validator.constraint_validator_factory') as $service) {
         $container->setDefinition('fabricius.' . $service, Argument::any())->shouldBeCalled();
     }
     $container->setAlias('fabricius', Argument::any())->shouldBeCalled();
     $container->getDefinition('fabricius.library')->shouldBeCalled()->willReturn($libraryDefinition);
     $libraryDefinition->addMethodCall('registerRepository', Argument::that(function ($args) {
         if ($args[0] !== 'Fabricius\\FabriciusBundle\\ContentItem') {
             return false;
         } elseif ($args[1]->getClass() !== 'Fabricius\\Loader\\FileLoader') {
             return false;
         } elseif ($args[2]->getClass() !== 'Fabricius\\Storage\\ArrayStorage') {
             return false;
         }
         return true;
     }))->shouldBeCalled();
     $container->getDefinition('fabricius.parser')->shouldBeCalled()->willReturn($parserDefinition);
     $parserDefinition->addMethodCall('setExcerptDelimiter', array('[MORE]'))->shouldBeCalled();
     $config = array('excerpt_delimiter' => '[MORE]', 'formatter' => array('markdown' => array('enabled' => true), 'textile' => array('enabled' => true)), 'repositories' => array('Fabricius\\FabriciusBundle\\ContentItem' => array('loader' => array('file' => array('dir' => __DIR__)), 'storage' => array('array' => array('enabled' => true)))));
     $this->load(array('fabricius' => $config), $container)->shouldReturn(null);
 }
开发者ID:fabricius,项目名称:fabricius-bundle,代码行数:31,代码来源:FabriciusExtensionSpec.php

示例5: pathArgument

 private function pathArgument($expected)
 {
     $regex = $this->pathRegex($expected);
     return Argument::that(function ($path) use($regex) {
         return preg_match($regex, $path);
     });
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:7,代码来源:ConfigurationFileSpec.php

示例6: it_registers_columns

 /** @test */
 public function it_registers_columns()
 {
     /** @var CompoundColumn $compoundColumn */
     $compoundColumn = null;
     $datagridBuilder = $this->prophesize(DatagridBuilderInterface::class);
     $datagridBuilder->set(Argument::that(function ($column) use(&$compoundColumn) {
         self::assertInstanceOf(CompoundColumn::class, $column);
         $compoundColumn = $column;
         return true;
     }))->shouldBeCalledTimes(1);
     $builder = new CompoundColumnBuilder($this->factory, $datagridBuilder->reveal(), 'actions', ['label' => 'act']);
     $builder->add('id', NumberType::class);
     $builder->add('name', TextType::class, ['format' => '%s']);
     self::assertTrue($builder->has('id'));
     self::assertTrue($builder->has('name'));
     self::assertFalse($builder->has('date'));
     // Register it.
     $builder->end();
     if (!$compoundColumn) {
         self::fail('$compoundColumn was not set. So set() was not called internally.');
     }
     self::assertEquals('actions', $compoundColumn->getName());
     self::assertEquals(['label' => 'act', 'data_provider' => null], $compoundColumn->getOptions());
     $columns = $compoundColumn->getColumns();
     self::assertArrayHasKey('id', $columns);
     self::assertArrayHasKey('name', $columns);
     self::assertArrayNotHasKey('date', $columns);
     self::assertColumnEquals($columns['id'], 'id', NumberType::class, ['parent_column' => $compoundColumn, 'data_provider' => null]);
     self::assertColumnEquals($columns['name'], 'name', TextType::class, ['format' => '%s', 'parent_column' => $compoundColumn, 'data_provider' => null]);
 }
开发者ID:rollerworks,项目名称:datagrid,代码行数:31,代码来源:CompoundColumnBuilderTest.php

示例7: let

 function let(FileSourceRegistry $fileSourceRegistry, ArchiveFactory $archiveFactory, ArchiveRepository $archiveRepository, FileSource $fileSource, Archive $archive, Archive $existingArchive, ArchiveRepository $archiveRepository, File $file)
 {
     $fileSourceRegistry->get('dummy')->willReturn($fileSource);
     $fileSource->getFiles('path')->willReturn([$file]);
     $archiveFactory->create('name', Argument::that(function ($archiveFiles) {
         foreach ($archiveFiles as $archiveFile) {
             if (!$archiveFile instanceof ArchiveFile) {
                 return false;
             }
         }
         return true;
     }))->willReturn($archive);
     $archiveFactory->create('existingName', Argument::that(function ($archiveFiles) {
         foreach ($archiveFiles as $archiveFile) {
             if (!$archiveFile instanceof ArchiveFile) {
                 return false;
             }
         }
         return true;
     }))->willReturn($existingArchive);
     $archive->getName()->willReturn('name');
     $existingArchive->getName()->willReturn('existingName');
     $archiveRepository->findByName("name")->willReturn(null);
     $archiveRepository->findByName("existingName")->willReturn($existingArchive);
     $this->beConstructedWith($fileSourceRegistry, $archiveFactory, $archiveRepository);
 }
开发者ID:partikus,项目名称:FileArchive,代码行数:26,代码来源:CreateArchiveUseCaseSpec.php

示例8: let

 public function let(RowBuilderFactory $rowBuilderFactory, ColumnIndexTransformer $columnIndexTransformer, ValueTransformer $valueTransformer, RowBuilder $rowBuilder)
 {
     $startWith = function ($startString) {
         return function ($string) use($startString) {
             return $startString === substr($string, 0, strlen($startString));
         };
     };
     $columnIndexTransformer->transform(Argument::that($startWith('A')))->willReturn(0);
     $columnIndexTransformer->transform(Argument::that($startWith('B')))->willReturn(1);
     $columnIndexTransformer->transform(Argument::that($startWith('C')))->willReturn(2);
     $columnIndexTransformer->transform(Argument::that($startWith('D')))->willReturn(3);
     $row = null;
     $rowBuilderFactory->create()->will(function () use($rowBuilder, &$row) {
         $row = [];
         return $rowBuilder;
     });
     $rowBuilder->addValue(Argument::type('int'), Argument::type('array'))->will(function ($args) use(&$row) {
         $row[$args[0]] = $args[1];
     });
     $rowBuilder->getData()->will(function () use(&$row) {
         return $row;
     });
     $this->beConstructedWith($rowBuilderFactory, $columnIndexTransformer, $valueTransformer, __DIR__ . '/fixtures/sheet.xml', []);
     $valueTransformer->transform(Argument::type('string'), Argument::type('string'), Argument::type('string'))->will(function ($args) {
         return $args;
     });
 }
开发者ID:jackbzne,项目名称:spreadsheet-parser,代码行数:27,代码来源:RowIteratorSpec.php

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

示例10: testRender

 public function testRender()
 {
     $request = new Request(['test' => 1], ['test' => 2], [], ['test' => 3]);
     $activeTheme = $this->prophesize(ActiveTheme::class);
     $controllerResolver = $this->prophesize(ControllerResolver::class);
     $webspaceManager = $this->prophesize(WebspaceManager::class);
     $requestStack = $this->prophesize(RequestStack::class);
     $structure = $this->prophesize(PageBridge::class);
     $translator = $this->prophesize(TranslatorInterface::class);
     $webspaceManager->findWebspaceByKey('sulu_io')->willReturn($this->getWebspace());
     $structure->getController()->willReturn('TestController:test');
     $structure->getLanguageCode()->willReturn('de_at');
     $structure->getWebspaceKey()->willReturn('sulu_io');
     $controllerResolver->getController(Argument::type(Request::class))->will(function () {
         return [new TestController(), 'testAction'];
     });
     $requestStack->getCurrentRequest()->willReturn($request);
     $requestStack->push(Argument::that(function (Request $newRequest) use($request) {
         $this->assertEquals($request->query->all(), $newRequest->query->all());
         $this->assertEquals($request->request->all(), $newRequest->request->all());
         $this->assertEquals($request->cookies->all(), $newRequest->cookies->all());
         return true;
     }))->shouldBeCalledTimes(1);
     $requestStack->pop()->shouldBeCalled();
     $translator->getLocale()->willReturn('de');
     $translator->setLocale('de_at')->shouldBeCalled();
     $translator->setLocale('de')->shouldBeCalled();
     $renderer = new PreviewRenderer($activeTheme->reveal(), $controllerResolver->reveal(), $webspaceManager->reveal(), $requestStack->reveal(), $translator->reveal());
     $result = $renderer->render($structure->reveal());
     $this->assertEquals('TEST', $result);
 }
开发者ID:ollietb,项目名称:sulu,代码行数:31,代码来源:PreviewRendererTest.php

示例11: array

 function it_accepts_nested_tasks(TaskStack $stack)
 {
     $stack->push(Argument::that(function ($task) {
         return $task->getName() === 'build' && $task->getDependencies() === array('test', 'minify', 'cleanup');
     }));
     $this->task('build', array('test', 'minify', 'cleanup'));
 }
开发者ID:wouterj,项目名称:fred,代码行数:7,代码来源:FredSpec.php

示例12: testOnPageContext

 /**
  * @covers ::onPageContext
  */
 public function testOnPageContext()
 {
     $collection = new RouteCollection();
     $route_provider = $this->prophesize(RouteProviderInterface::class);
     $route_provider->getRoutesByPattern('/test_route')->willReturn($collection);
     $request = new Request();
     $request_stack = new RequestStack();
     $request_stack->push($request);
     $data_definition = new DataDefinition(['type' => 'entity:user']);
     $typed_data = $this->prophesize(TypedDataInterface::class);
     $this->typedDataManager->getDefaultConstraints($data_definition)->willReturn([]);
     $this->typedDataManager->create($data_definition, 'banana')->willReturn($typed_data->reveal());
     $this->typedDataManager->createDataDefinition('bar')->will(function () use($data_definition) {
         return $data_definition;
     });
     $this->page->getPath()->willReturn('/test_route');
     $this->page->getParameter('foo')->willReturn(['machine_name' => 'foo', 'type' => 'integer', 'label' => 'Foo']);
     $this->page->getParameter('baz')->willReturn(['machine_name' => 'baz', 'type' => 'integer', 'label' => '']);
     $this->page->getParameter('page')->willReturn(['machine_name' => 'page', 'type' => 'entity:page', 'label' => '']);
     $this->page->addContext('foo', Argument::that(function ($context) {
         return $context instanceof Context && $context->getContextDefinition()->getLabel() == 'Foo';
     }))->shouldBeCalled();
     $this->page->addContext('baz', Argument::that(function ($context) {
         return $context instanceof Context && $context->getContextDefinition()->getLabel() == '{baz} from route';
     }))->shouldBeCalled();
     $this->page->addContext('page', Argument::that(function ($context) {
         return $context instanceof Context && $context->getContextDefinition()->getLabel() == '{page} from route';
     }))->shouldBeCalled();
     $collection->add('test_route', new Route('/test_route', [], [], ['parameters' => ['foo' => ['type' => 'bar'], 'baz' => ['type' => 'bop'], 'page' => ['type' => 'entity:page']]]));
     // Set up a request with one of the expected parameters as an attribute.
     $request->attributes->add(['foo' => 'banana']);
     $route_param_context = new RouteParamContext($route_provider->reveal(), $request_stack);
     $route_param_context->onPageContext($this->event);
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:37,代码来源:RouteParamContextTest.php

示例13: it_should_trigger_events_during_form_configuration

 /**
  * @param \Zend\EventManager\EventManager $eventManager
  * @param \Zend\Form\FormInterface $form
  * @param \ArrayAccess $spec
  */
 public function it_should_trigger_events_during_form_configuration($eventManager, $form, $spec)
 {
     $this->configureForm($form, $spec);
     $triggeredEvents = array(FormEvent::EVENT_CONFIGURE_ELEMENT_PRE, FormEvent::EVENT_CONFIGURE_ELEMENT_POST);
     $eventManager->trigger(Argument::that(function ($event) use($form, $spec, $triggeredEvents) {
         return $event instanceof FormEvent && in_array($event->getName(), $triggeredEvents) && $event->getTarget() == $form->getWrappedObject() && $event->getParam('spec') == $spec->getWrappedObject();
     }))->shouldBeCalledTimes(count($triggeredEvents));
 }
开发者ID:phpro,项目名称:zf-annotated-forms,代码行数:13,代码来源:FactorySpec.php

示例14: use

 function it_request_provided_time_apod(Client $httpClient, ResponseInterface $response)
 {
     $today = new \DateTime('today');
     $httpClient->request('GET', Argument::any(), Argument::that(function ($argument) use($today) {
         return $argument['query']['date'] === $today->format('Y-m-d');
     }))->shouldBeCalled()->willReturn($response);
     $this->get('today');
 }
开发者ID:rodrigodiez,项目名称:how-i-code-php,代码行数:8,代码来源:ClientSpec.php

示例15: pack

 function it_should_not_validate_group_membership_when_going_to_ldap_if_the_op_type_is_not_modification($connection)
 {
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == '(&(objectClass=group)(cn=Domain Users)(groupType:1.2.840.113556.1.4.803:=2147483648))' && $operation->getAttributes() == ['objectSid'];
     }))->willReturn(['count' => 1, ["objectSid" => ["count" => 1, 0 => pack('H*', str_replace('\\', '', $this->groupSidHex))], 0 => "objectSid", "count" => 1, "dn" => "CN=Domain Users,CN=Users,dc=example,dc=local"]]);
     $this->setOperationType(AttributeConverterInterface::TYPE_SEARCH_TO);
     $this->toLdap('Domain Users')->shouldBeEqualTo('513');
 }
开发者ID:ldaptools,项目名称:ldaptools,代码行数:8,代码来源:ConvertPrimaryGroupSpec.php


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