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, []); }
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'); }
/** * 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(); }
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); }
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()); }
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', '', []); }
function it_normalizes_families(Family $family, Webservice $webservice, $familyNormalizer) { $familyNormalizer->normalize($family, AbstractNormalizer::MAGENTO_FORMAT, Argument::any())->willReturn(['attributeSetName' => 'family_code']); $webservice->getAttributeSetList()->willReturn([]); $webservice->getStoreViewsList()->willReturn([]); $this->process($family)->shouldReturn(['family_object' => $family, 'attributes_in_family' => null, 'families_to_create' => ['attributeSetName' => 'family_code']]); }
function it_builds_form_with_proper_fields(FormBuilderInterface $builder) { $builder->add('type', 'text', Argument::any())->willReturn($builder); $builder->add('description', 'text', Argument::any())->willReturn($builder); $builder->add('amount', 'sylius_money', Argument::any())->willReturn($builder); $this->buildForm($builder, array()); }
function it_supports_metric_attribute(AttributeInterface $metric) { $metric->getAttributeType()->willReturn('pim_catalog_metric'); $this->supportsAttribute($metric)->shouldReturn(true); $metric->getAttributeType()->willReturn(Argument::any()); $this->supportsAttribute($metric)->shouldReturn(false); }
private function _initMockClientFactory() { $prophet = new \Prophecy\Prophet(); $client = $prophet->prophesize("Bxav\\Bundle\\ServiceHandlerClientBundle\\Model\\SoapClient"); $client->getFunctions()->willReturn([]); $this->clientFactory->get(Argument::any())->willReturn($client); }
function it_does_not_add_violation_product_price_with_no_data($context, ProductPriceInterface $productPrice, IsNumeric $numericConstraint) { $productPrice->getData()->willReturn(null); $context->buildViolation(Argument::cetera())->shouldNotBeCalled(); $context->buildViolation(Argument::any())->shouldNotBeCalled(); $this->validate($productPrice, $numericConstraint); }
function its_runAll_should_returns_only_failed_or_broken_tests(Runner $runner) { Filesystem::create()->serialize($this->cacheFile, array('succeed' => ResultEvent::createSucceed('Success'), 'failed' => ResultEvent::createFailed('Failed'), 'broken' => ResultEvent::createBroken('Broken'))); $runner->run(Argument::any())->shouldBeCalled(); $results = $this->runAll(); $results->getResults()->shouldHaveCount(2); }
function it_does_not_add_a_many_to_one_mapping_if_the_class_is_not_a_configured_attribute_value_model(LoadClassMetadataEventArgs $eventArgs, ClassMetadataInfo $metadata) { $eventArgs->getClassMetadata()->willReturn($metadata); $metadata->getName()->willReturn('KeepMoving\\ThisClass\\DoesNot\\Concern\\You'); $metadata->mapManyToOne(Argument::any())->shouldNotBeCalled(); $this->loadClassMetadata($eventArgs); }
function it_should_add_rule_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory) { $builder->getFormFactory()->willReturn($factory); $builder->add(Argument::any(), Argument::cetera())->willReturn($builder); $builder->addEventSubscriber(Argument::type(BuildRuleFormSubscriber::class))->willReturn($builder); $this->buildForm($builder, array()); }
public function it_should_return_a_previously_registered_similar_aggregate_root_if_available(AggregateRoot $aggregateRoot, $aggregateRoot1, $eventBus, $saveAggregateCallback) { $aggregateRoot1->sameIdentityAs($aggregateRoot)->willReturn(true); $aggregateRoot->addEventRegistrationCallback(Argument::any())->shouldNotBeCalled(); $this->add($aggregateRoot, $eventBus, $saveAggregateCallback)->shouldReturn($aggregateRoot1); $this->all()->shouldHaveCount(2); }
function it_does_nothing_if_request_is_not_master(GetResponseEvent $event, Request $request, LocaleManager $localeManager) { $event->getRequest()->willReturn($request); $request->get('locale')->willReturn(null); $localeManager->setLocale(Argument::any())->shouldNotBeCalled(); $this->onKernelRequest($event); }
function it_should_build_form_with_proper_fields(FormBuilder $builder) { $builder->add('description', 'textarea', Argument::any())->shouldBeCalled()->willReturn($builder); $builder->addEventSubscriber(Argument::type(AddCodeFormSubscriber::class))->shouldBeCalled()->willReturn($builder); $builder->addEventSubscriber(Argument::type(AddParentFormSubscriber::class))->shouldBeCalled()->willReturn($builder); $this->buildForm($builder, []); }
/** * @return CacheItemPoolInterface * @throws \LogicException * * @link https://gist.github.com/scaytrase/3cf9c5ece4218280669c */ private function createCache() { static $items = []; $cache = $this->prophesize(CacheItemPoolInterface::class); $that = $this; $cache->getItem(Argument::type('string'))->will(function ($args) use(&$items, $that) { $key = $args[0]; if (!array_key_exists($key, $items)) { $item = $that->prophesize(CacheItemInterface::class); $item->getKey()->willReturn($key); $item->isHit()->willReturn(false); $item->get()->willReturn(null); $item->set(Argument::any())->will(function ($args) use($item) { $item->get()->willReturn($args[0]); }); $item->expiresAfter(Argument::type('int'))->willReturn($item); $item->expiresAfter(Argument::exact(null))->willReturn($item); $item->expiresAfter(Argument::type(\DateInterval::class))->willReturn($item); $item->expiresAt(Argument::type(\DateTimeInterface::class))->willReturn($item); $items[$key] = $item; } return $items[$key]->reveal(); }); $cache->save(Argument::type(CacheItemInterface::class))->will(function ($args) use(&$items) { $item = $args[0]; $items[$item->getKey()]->isHit()->willReturn(true); }); return $cache->reveal(); }
/** * @param \Prophecy\Doubler\Generator\Node\ClassNode $node */ function it_adds_a_method_to_node_if_not_exists($node) { $node->hasMethod('__construct')->willReturn(false); $node->addMethod(Argument::any())->shouldBeCalled(); $node->getParentClass()->shouldBeCalled(); $this->apply($node); }
protected function getQueryBuilderSpec(Collaborator $manager, Collaborator $queryBuilder) { $manager->createQueryBuilder()->shouldBeCalled()->willReturn($queryBuilder); $queryBuilder->select('kreta')->shouldBeCalled()->willReturn($queryBuilder); $queryBuilder->from(Argument::any(), 'kreta', null)->shouldBeCalled()->willReturn($queryBuilder); return $queryBuilder; }
function it_does_not_log_user_in_if_customer_does_not_have_assigned_user($loginManager, GenericEvent $event, CustomerInterface $customer) { $event->getSubject()->willReturn($customer); $customer->getUser()->willReturn(null); $loginManager->login(Argument::any())->shouldNotBeCalled(); $this->login($event); }
function it_can_calculate_with_one_result(Client $client, PrecoPrazoResult $result) { $response = new FakePrecoPrazoResponse('preco'); $client->get('http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?nCdEmpresa=&sDsSenha=&nCdServico=40010%2C41106&sCepOrigem=&sCepDestino=&nVlPeso=&nCdFormato=1&nVlComprimento=&nVlAltura=&nVlLargura=&nVlDiametro=&sCdMaoPropria=N&nVlValorDeclarado=0&sCdAvisoRecebimento=N&StrRetorno=xml')->willReturn($response); $result->fill(Argument::any())->shouldBeCalled(); $this->calculate()->shouldBeAnInstanceOf('EscapeWork\\Frete\\Correios\\PrecoPrazoResult'); }
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, []); }
public function let(Container $container, Translator $translator, Session $session, TopicRepository $topicRepository, EntityRepository $repository, EntityManager $entityManager, Request $request, FormFactory $formFactory, FormBuilder $formBuilder, Form $form, FormView $formView, Topic $topic, CsrfTokenManagerAdapter $csrfTokenManagerAdapter, AbstractQuery $query, AbstractQuery $query2, ParameterBag $parameterBag, ArticleTopicRepository $articleTopicrepository, UserService $userService, User $user, TopicService $topicService, Article $article, QueryBuilder $queryBuilder, CacheService $cacheService, EventDispatcher $dispatcher) { $container->get('em')->willReturn($entityManager); $container->get('session')->willReturn($session); $container->get('request')->willReturn($request); $container->get('translator')->willReturn($translator); $container->get('form.factory')->willReturn($formFactory); $container->get('form.csrf_provider')->willReturn($csrfTokenManagerAdapter); $container->get('newscoop.cache')->willReturn($cacheService); $container->get('user')->willReturn($userService); $container->get('dispatcher')->willReturn($dispatcher); $userService->getCurrentUser()->willReturn($user); $container->get('newscoop_newscoop.topic_service')->willReturn($topicService); $formBuilder->getForm(Argument::cetera())->willReturn($form); $formFactory->create(Argument::cetera())->willReturn($form); $form->createView()->willReturn($formView); $form->handleRequest(Argument::cetera())->willReturn(true); $form->isValid()->willReturn(true); $entityManager->persist(Argument::any())->willReturn(true); $entityManager->flush(Argument::any())->willReturn(true); $entityManager->remove(Argument::any())->willReturn(true); $entityManager->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic')->willReturn($repository); $entityManager->getRepository('Newscoop\\Entity\\ArticleTopic')->willReturn($articleTopicrepository); $this->setContainer($container); $this->token = 'uTxRiEkont4XxRpTcSADPCowge7TgNONE7Y5HWd4pmY'; $request->get('_csrf_token')->willReturn($this->token); $request->get('_code')->willReturn('en'); $request->get('_articleNumber')->willReturn('64'); $request->getLocale()->willReturn('en'); $request->get('_code', 'en')->willReturn('en'); $request->request = $parameterBag; }
function it_should_configure_the_resolver(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('format' => Argument::any(), 'language' => \Locale::getDefault(), 'leading_zero' => false))->shouldBeCalled(); $resolver->setOptional(array('placeholder', 'language', 'leading_zero'))->shouldBeCalled(); $resolver->setAllowedTypes(array('placeholder' => array('string'), 'language' => array('string'), 'leading_zero' => array('bool')))->shouldBeCalled(); $this->setDefaultOptions($resolver); }
function let(Listener $listener) { MFS::mkdir(MFS::$tmpDir); $listener->hasPath(Argument::any())->willReturn(true); $listener->getPatterns()->willReturn(array()); $listener->getIgnores()->willReturn(array()); }
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); }
private function getAccessTokenWhenExpirationIs($isExpired) { $this->givenOAuthClient($this->config); $this->cache->setClient(Argument::any())->willReturn(null); $this->cache->isExpired()->willReturn($isExpired); return $this->auth->getAccessToken(); }
function it_throws_handle_exception_if_cart_was_not_found(CartContextInterface $cartContext, ObjectManager $cartManager) { $cartContext->getCart()->willThrow(CartNotFoundException::class); $cartManager->persist(Argument::any())->shouldNotBeCalled(); $cartManager->flush()->shouldNotBeCalled(); $this->shouldThrow(HandleException::class)->during('handle', ['en_GB']); }
function it_send_password_reset_pin_mail($sender, GenericEvent $event, UserInterface $user) { $event->getSubject()->willReturn($user); $user->getEmail()->willReturn('*****@*****.**'); $sender->send('reset_password_pin', ['*****@*****.**'], Argument::any())->shouldBeCalled(); $this->sendResetPasswordPinEmail($event); }