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_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(); }