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();
 }
示例#2
2
 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_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);
 }
 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]);
 }
示例#5
1
 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', '', []);
 }
示例#6
1
 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']);
 }
 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());
 }
 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 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;');
 }
 /**
  * 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(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_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');
 }
 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);
 }
 /**
  * @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/'));
 }
示例#15
0
 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);
 }
 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);
 }
示例#17
0
 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, []);
 }
 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);
 }
 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);
 }
 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;
     });
 }
示例#21
0
 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);
 }
示例#22
0
 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);
 }
 public function TODO_it_can_generate_spec_source_from_class_source($factory, ImprovedClassSource $classSource, ClassType $classType, ImprovedClassSource $specSource)
 {
     $classSource->getClassType()->willReturn($classType);
     $classType->getFullName()->willReturn('Namespace\\Class');
     $factory->create(Argument::type(ClassType::class))->willReturn($specSource);
     $this->generate($classSource)->shouldReturn($specSource);
 }
 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);
 }
示例#25
0
 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_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_validates_that_a_job_instance_has_a_known_type($jobRegistry, $context, Constraint $constraint, JobInstance $jobInstance, JobInterface $job)
 {
     $jobInstance->getJobName()->willReturn('my_job_name');
     $jobRegistry->get('my_job_name')->willReturn($job);
     $context->buildViolation(Argument::cetera())->shouldNotBeCalled();
     $this->validate($jobInstance, $constraint);
 }
 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_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 let(ManagerRegistry $managerRegistry, TranslatableListener $translatableListener, ObjectManager $manager, ClassMetadata $translatableMetadata)
 {
     $managerRegistry->getManagerForClass(Argument::type('string'))->willReturn($manager);
     $translatableListener->getExtendedMetadata($manager, Argument::type('string'))->willReturn($translatableMetadata);
     $translatableListener->getLocale()->willReturn('en');
     $this->beConstructedWith($managerRegistry, $translatableListener, new PropertyAccessor());
 }