function it_applies_a_filter_by_unclassified_products($utility, $categoryRepo, FilterDatasourceAdapterInterface $datasource, CategoryInterface $tree)
 {
     $tree->getId()->willReturn(1);
     $categoryRepo->find(1)->willReturn($tree);
     $categoryRepo->getAllChildrenIds($tree)->willReturn([2, 3]);
     $utility->applyFilter($datasource, 'categories.id', 'NOT IN', [2, 3])->shouldBeCalled();
     $this->apply($datasource, ['value' => ['categoryId' => -1, 'treeId' => 1]]);
 }
 function it_provides_formatted_batch_config_for_the_job(CategoryInterface $officeCategory, CategoryInterface $bedroomCategory)
 {
     $officeCategory->getCode()->willReturn('office_room');
     $bedroomCategory->getCode()->willReturn('bedroom');
     $this->setCategories([$officeCategory, $bedroomCategory]);
     $this->setFilters([['id', 'IN', ['49', '2']]]);
     $this->getBatchConfig()->shouldReturn('{\\"filters\\":[[\\"id\\",\\"IN\\",[\\"49\\",\\"2\\"]]],\\"actions\\":[{\\"field\\":\\"categories\\",\\"value\\":[\\"office_room\\",\\"bedroom\\"]}]}');
 }
 function it_provides_formatted_batch_config_for_the_job(CategoryInterface $officeCategory, CategoryInterface $bedroomCategory)
 {
     $officeCategory->getCode()->willReturn('office_room');
     $bedroomCategory->getCode()->willReturn('bedroom');
     $this->setCategories([$officeCategory, $bedroomCategory]);
     $this->setFilters([['id', 'IN', ['49', '2']]]);
     $this->getBatchConfig()->shouldReturn(['filters' => [['id', 'IN', ['49', '2']]], 'actions' => [['field' => 'categories', 'value' => ['office_room', 'bedroom']]]]);
 }
 function it_massively_insert_and_update_objects($bulkSaver, $bulkDetacher, $stepExecution, CategoryInterface $object1, CategoryInterface $object2)
 {
     $bulkSaver->saveAll([$object1, $object2]);
     $bulkDetacher->detachAll([$object1, $object2]);
     $object1->getId()->willReturn(null);
     $stepExecution->incrementSummaryInfo('create')->shouldBeCalled();
     $object2->getId()->willReturn(42);
     $stepExecution->incrementSummaryInfo('process')->shouldBeCalled();
     $this->write([$object1, $object2]);
 }
 function it_normalizes_an_existing_product_without_family_into_mongodb_document($mongoFactory, $serializer, ProductInterface $product, \MongoId $mongoId, \MongoDate $mongoDate, Association $assoc1, Association $assoc2, CategoryInterface $category1, CategoryInterface $category2, GroupInterface $group1, GroupInterface $group2, ProductValueInterface $value1, ProductValueInterface $value2)
 {
     $mongoFactory->createMongoId('product1')->willReturn($mongoId);
     $mongoFactory->createMongoDate()->willReturn($mongoDate);
     $category1->getId()->willReturn(12);
     $category2->getId()->willReturn(34);
     $group1->getId()->willReturn(56);
     $group2->getId()->willReturn(78);
     $product->getId()->willReturn('product1');
     $product->getCreated()->willReturn(null);
     $product->getFamily()->willReturn(null);
     $product->isEnabled()->willReturn(true);
     $product->getGroups()->willReturn([$group1, $group2]);
     $product->getCategories()->willReturn([$category1, $category2]);
     $product->getAssociations()->willReturn([$assoc1, $assoc2]);
     $product->getValues()->willReturn([$value1, $value2]);
     $context = ['_id' => $mongoId];
     $serializer->normalize($product, 'mongodb_json')->willReturn(['data' => 'data', 'completenesses' => 'completenesses']);
     $serializer->normalize($value1, 'mongodb_document', $context)->willReturn('my_value_1');
     $serializer->normalize($value2, 'mongodb_document', $context)->willReturn('my_value_2');
     $serializer->normalize($assoc1, 'mongodb_document', $context)->willReturn('my_assoc_1');
     $serializer->normalize($assoc2, 'mongodb_document', $context)->willReturn('my_assoc_2');
     $this->normalize($product, 'mongodb_document')->shouldReturn(['_id' => $mongoId, 'created' => $mongoDate, 'updated' => $mongoDate, 'enabled' => true, 'groupIds' => [56, 78], 'categoryIds' => [12, 34], 'associations' => ['my_assoc_1', 'my_assoc_2'], 'values' => ['my_value_1', 'my_value_2'], 'normalizedData' => ['data' => 'data'], 'completenesses' => []]);
 }
 /**
  * {@inheritdoc}
  */
 public function findAllForCategory(CategoryInterface $category)
 {
     $qb = $this->createQueryBuilder('p');
     $qb->field('categoryIds')->in([$category->getId()]);
     return $qb->getQuery()->execute();
 }
 /**
  * Update default tree of users using a tree that will be removed
  *
  * @param CategoryInterface $category
  */
 protected function onTreeRemoved(CategoryInterface $category)
 {
     $users = $this->findUsersBy(['defaultTree' => $category]);
     $trees = $this->container->get('pim_catalog.repository.category')->getTrees();
     $defaultTree = current(array_filter($trees, function ($tree) use($category) {
         return $tree->getCode() !== $category->getCode();
     }));
     foreach ($users as $user) {
         $user->setDefaultTree($defaultTree);
         $this->computeChangeset($user);
     }
 }
 function it_does_not_mark_products_as_updated_when_a_category_is_updated(EntityManager $em, ProductInterface $foo, ProductInterface $bar, CategoryInterface $category)
 {
     $category->getProducts()->willReturn([$foo, $bar]);
     $this->guessUpdates($em, $category, UpdateGuesserInterface::ACTION_UPDATE_ENTITY)->shouldReturn([]);
 }