php Prophecy-Argument类(方法)实例源码

下面列出了php Prophecy-Argument 类(方法)源码代码实例,从而了解它的用法。

作者:jacdobr    项目:teryt-database-bundl   
function let(ObjectManager $om, ObjectRepository $or)
 {
     // It is not possible to mock internal classes with final constructor
     $this->beConstructedWith(new \SimpleXMLElement('<row></row>'), $om);
     $om->getRepository(Argument::type('string'))->willReturn($or);
     $or->findOneBy(Argument::type('array'))->willReturn();
 }

作者:ReissClothin    项目:Syliu   
function it_builds_form_with_proper_fields(FormBuilder $builder)
 {
     $builder->add('name', 'text', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('abbreviation', 'text', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }

作者:alexisfroge    项目:pim-community-de   
function it_lists_user_notifications_linked_to_the_current_user(UserInterface $user, UserNotification $userNotification, Request $request, $manager, $context, $templating)
 {
     $context->getUser()->willReturn($user);
     $manager->getUserNotifications($user, Argument::cetera())->willReturn([$userNotification]);
     $templating->renderResponse('PimNotificationBundle:Notification:list.json.twig', ['userNotifications' => [$userNotification]], Argument::type('Symfony\\Component\\HttpFoundation\\JsonResponse'))->shouldBeCalled();
     $this->listAction($request);
 }

作者:abdeldaye    项目:pim-community-de   
function it_marks_a_variant_group_as_updated_when_its_attributes_are_removed_or_updated($registry, EntityManager $em, ProductTemplateInterface $productTemplate, GroupInterface $group, GroupRepositoryInterface $groupRepo)
 {
     $productTemplate->getId()->willReturn(956);
     $registry->getRepository(Argument::type('string'))->willReturn($groupRepo);
     $groupRepo->getVariantGroupByProductTemplate($productTemplate)->willReturn($group);
     $this->guessUpdates($em, $productTemplate, UpdateGuesserInterface::ACTION_UPDATE_ENTITY)->shouldReturn([$group]);
 }

作者:NeverRespons    项目:Syliu   
function it_does_not_filters_when_data_id_is_not_defined(DataSourceInterface $dataSource, ExpressionBuilderInterface $expressionBuilder)
 {
     $dataSource->getExpressionBuilder()->willReturn($expressionBuilder);
     $expressionBuilder->equals('entity', Argument::any())->shouldNotBeCalled();
     $dataSource->restrict(Argument::any())->shouldNotBeCalled();
     $this->apply($dataSource, 'entity', '', []);
 }

作者:ahmadrabi    项目:Syliu   
function it_builds_form(FormBuilder $builder, FormFactoryInterface $factory)
 {
     $builder->add('type', 'sylius_promotion_rule_choice', Argument::type('array'))->willReturn($builder);
     $builder->getFormFactory()->willReturn($factory);
     $builder->addEventSubscriber(Argument::type(BuildRuleFormSubscriber::class))->shouldBeCalled();
     $this->buildForm($builder, ['configuration_type' => 'configuration_form_type']);
 }

作者:Silweret    项目:Syliu   
function it_builds_a_form(FormBuilderInterface $builder)
 {
     $builder->add('first_item_cost', 'sylius_money', Argument::withKey('constraints'))->shouldBeCalled()->willReturn($builder);
     $builder->add('additional_item_cost', 'sylius_money', Argument::withKey('constraints'))->shouldBeCalled()->willReturn($builder);
     $builder->add('additional_item_limit', 'integer', Argument::withKey('constraints'))->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, array());
 }

作者:sidibe    项目:Syliu   
function let(MetadataRendererInterface $universalRenderer, OptionsResolver $optionsResolver, PropertyAccessorInterface $propertyAccessor)
 {
     $this->beConstructedWith($universalRenderer, $optionsResolver, $propertyAccessor);
     $optionsResolver->setDefaults(Argument::type('array'))->willReturn($optionsResolver);
     $optionsResolver->setAllowedValues(Argument::any(), Argument::type('array'))->willReturn($optionsResolver);
     $optionsResolver->setAllowedTypes(Argument::any(), Argument::any())->willReturn($optionsResolver);
 }

作者:qrz-i    项目:pim-community-de   
function it_processes_homogeneous_items($serializer, $localeRepository)
 {
     $items = [['item1' => ['attr10']], ['item2' => 'attr20'], ['item3' => ['attr30']]];
     $localeRepository->getActivatedLocaleCodes()->willReturn(['code1', 'code2']);
     $serializer->serialize(Argument::cetera())->willReturn('those;items;in;csv;format;');
     $this->process($items)->shouldReturn('those;items;in;csv;format;');
 }

作者:IRlyDontKno    项目:elcod   
/**
  * Get variant image resolver mock.
  *
  * @param ImageInterface|false $image Image
  *
  * @return VariantImageResolver
  */
 protected function getVariantImageMock($image)
 {
     $variantImageResolver = $this->prophesize('Elcodi\\Component\\Product\\ImageResolver\\VariantImageResolver');
     $variantImageResolver->getValidImage(Argument::any())->willReturn($image);
     $variantImageResolver->getPurchasableNamespace()->willReturn('Elcodi\\Component\\Product\\Entity\\Interfaces\\VariantInterface');
     return $variantImageResolver->reveal();
 }

作者:ashutosh-srija    项目:findit_akene   
function let(GroupRepositoryInterface $groupRepository, DenormalizerInterface $denormalizer, ValidatorInterface $validator, ObjectDetacherInterface $detacher, StepExecution $stepExecution)
 {
     $groupClass = 'Pim\\Bundle\\CatalogBundle\\Entity\\Group';
     $this->beConstructedWith($groupRepository, $denormalizer, $validator, $detacher, $groupClass, 'csv');
     $this->setStepExecution($stepExecution);
     $validator->validate(Argument::any())->willReturn(new ConstraintViolationList());
 }

作者:ashutosh-srija    项目:findit_akene   
function it_hydrates_a_result_record(Builder $builder, Query $query, ProductInterface $product, Association $association, AssociationType $associationType, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, DocumentManager $documentManager, \Doctrine\ODM\MongoDB\Mapping\ClassMetadata $metadata, Collection $collection, ArrayIterator $arrayIterator)
 {
     $options = ['locale_code' => 'en_US', 'scope_code' => 'print', 'current_group_id' => null, 'attributes_configuration' => [], 'association_type_id' => 1, 'current_product' => $product];
     $builder->getQuery()->willReturn($query);
     $builder->hydrate(false)->willReturn($builder);
     $associatedProduct1->getId()->willReturn('550ae6b98ead0ed7778b46bb');
     $associatedProduct2->getId()->willReturn('550ae6b98abd0ec8778b46bb');
     $product->getAssociations()->willReturn([$association]);
     $association->getAssociationType()->willReturn($associationType);
     $associationType->getId()->willReturn(1);
     $association->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]);
     $queryDefinition = ['type' => 1, 'sort' => ['normalizedData.is_associated' => -1, '_id' => 1], 'limit' => 10, 'skip' => 0, 'query' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb'])]], 'newObj' => []];
     $query->getQuery()->willReturn($queryDefinition);
     $query->getDocumentManager()->willReturn($documentManager);
     $documentManager->getDocumentCollection(Argument::any())->willReturn($collection);
     $documentManager->getClassMetadata(Argument::any())->willReturn($metadata);
     $metadata->getFieldNames()->willReturn(['id', 'created', 'updated', 'locale', 'scope', 'values', 'indexedValues', 'indexedValuesOutdated', 'family', 'familyId', 'categories', 'categoryIds', 'enabled', 'groups', 'groupIds', 'associations', 'completenesses', 'normalizedData']);
     $pipeline = [['$match' => ['_id' => ['$ne' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb'])]]], ['$project' => ['id' => 1, 'created' => 1, 'updated' => 1, 'locale' => 1, 'scope' => 1, 'values' => 1, 'indexedValues' => 1, 'indexedValuesOutdated' => 1, 'family' => 1, 'familyId' => 1, 'categories' => 1, 'categoryIds' => 1, 'enabled' => 1, 'groups' => 1, 'groupIds' => 1, 'associations' => 1, 'completenesses' => 1, 'normalizedData' => 1, 'is_associated' => ['$cond' => [['$or' => [['$eq' => ['$_id', \MongoId::__set_state(['$id' => '550ae6b98ead0ed7778b46bb'])]], ['$eq' => ['$_id', \MongoId::__set_state(['$id' => '550ae6b98abd0ec8778b46bb'])]]]], 1, 0]]]], ['$sort' => ['is_associated' => -1]], ['$skip' => 0], ['$limit' => 10]];
     $collection->aggregate($pipeline)->willReturn($arrayIterator);
     $fixture = ['_id' => \MongoId::__set_state(['$id' => '550ae6b98ead0ee8778b46bb']), 'normalizedData' => [], 'sku' => ['attribute' => ['code' => 'sku', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => null, 'scope' => null, 'value' => 'mysku'], 'name' => ['attribute' => ['code' => 'name', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => null], 'desc' => ['attribute' => ['code' => 'desc', 'attributeType' => 'text', 'backendType' => 'text'], 'locale' => 'fr_FR', 'scope' => 'print'], 'is_associated' => 1];
     $arrayIterator->toArray()->willReturn([$fixture]);
     $rows = $this->hydrate($builder, $options);
     $rows->shouldHaveCount(1);
     $firstResult = $rows[0];
     $firstResult->shouldBeAnInstanceOf('\\Oro\\Bundle\\DataGridBundle\\Datasource\\ResultRecord');
 }

作者:phpguar    项目:phpguar   
function it_should_pre_load_configuration_properly(GenericEvent $event, ContainerInterface $container, PhpGuard $guard, InputInterface $input)
 {
     $input->hasParameterOption(Argument::cetera())->willReturn(false);
     $container->get('phpguard')->willReturn($guard);
     $guard->setOptions(array())->shouldBeCalled();
     $this->preLoad($event);
 }

作者:scaytras    项目:json-rpc-clien   
/**
  * @param mixed $params
  * @param bool $isArray
  * @return JsonRpcClient
  */
 private function getProphetClient($params, $isArray)
 {
     $guzzle = $this->prophesize(ClientInterface::class);
     $self = $this;
     $guzzle->sendAsync(Argument::type(RequestInterface::class))->will(function ($args) use($self, $params, $isArray) {
         /** @var RequestInterface $request */
         $request = $args[0];
         $content = $request->getBody()->getContents();
         $data = json_decode($content);
         if ($isArray) {
             $self::assertTrue(is_array($data));
             $self::assertNotEmpty($data);
             $data = array_shift($data);
         }
         $self::assertEquals(JSON_ERROR_NONE, json_last_error());
         $self::assertObjectHasAttribute('id', $data);
         $self::assertObjectHasAttribute('method', $data);
         $self::assertObjectHasAttribute('params', $data);
         $self::assertObjectHasAttribute('jsonrpc', $data);
         $self::assertEquals('test', $data->id);
         $self::assertEquals('2.0', $data->jsonrpc);
         $self::assertEquals('test', $data->method);
         $self::assertEquals($params, $data->params);
         return new Promise(function () {
         }, function () {
         });
     });
     return new JsonRpcClient($guzzle->reveal(), new Uri('http://localhost/'));
 }

作者:okwinz    项目:Syliu   
function it_has_options(OptionsResolver $resolver)
 {
     $resolver->setDefaults(Argument::withKey('choice_list'))->shouldBeCalled()->willReturn($resolver);
     $resolver->setRequired(['variable'])->shouldBeCalled()->willReturn($resolver);
     $resolver->setAllowedTypes('variable', VariableInterface::class)->shouldBeCalled()->willReturn($resolver);
     $this->configureOptions($resolver);
 }

作者:ashutosh-srija    项目:findit_akene   
function it_does_not_notify_if_job_execution_has_no_user($event, $jobExecution, $manager)
 {
     $jobExecution->getUser()->willReturn(null);
     $jobExecution->getStatus()->shouldNotBeCalled();
     $manager->notify(Argument::cetera())->shouldNotBeCalled();
     $this->afterJobExecution($event);
 }

作者:loic42    项目:Syliu   
function it_builds_form_with_proper_fields(FormBuilderInterface $builder)
 {
     $builder->add('exchangeRate', 'number', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->add('enabled', 'checkbox', Argument::any())->shouldBeCalled()->willReturn($builder);
     $builder->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))->shouldBeCalled()->willReturn($builder);
     $this->buildForm($builder, []);
 }

作者:abdeldaye    项目:pim-community-de   
function it_supports_denormalization_in_csv_of_a_family()
 {
     $this->supportsDenormalization([], self::ENTITY_CLASS, self::FORMAT_CSV)->shouldBe(true);
     $this->supportsDenormalization([], Argument::not(self::ENTITY_CLASS), self::FORMAT_CSV)->shouldBe(false);
     $this->supportsDenormalization([], self::ENTITY_CLASS, Argument::not(self::FORMAT_CSV))->shouldBe(false);
     $this->supportsDenormalization([], Argument::not(self::ENTITY_CLASS), Argument::not(self::FORMAT_CSV))->shouldBe(false);
 }

作者:nmarmo    项目:Syliu   
function it_creates_query_builder_for_all_status($em, QueryBuilder $builder)
 {
     $em->createQueryBuilder()->shouldBeCalled()->willReturn($builder);
     $builder->select('method')->shouldBeCalled()->willReturn($builder);
     $builder->from(Argument::any(), 'method')->shouldBeCalled()->willReturn($builder);
     $this->getQueryBuidlerForChoiceType(array('disabled' => true))->shouldReturn($builder);
 }

作者:jackbzn    项目:spreadsheet-parse   
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;
     });
 }


问题


面经


文章

微信
公众号

扫码关注公众号