function it_dumps_reference_data_filter($repository, $registry, OutputInterface $output, HelperSet $helperSet, TableHelper $table, AttributeFilterInterface $refDataFilter, AttributeInterface $refDataAttribute) { $output->writeln(Argument::any())->shouldBeCalled(); $repository->findAll()->willReturn([$refDataAttribute]); $registry->getAttributeFilters()->willReturn([$refDataFilter]); $refDataFilter->getAttributeTypes()->willReturn([]); $operators = ['IN', 'EMPTY']; $refDataFilter->getOperators()->willReturn($operators); $refDataFilter->supportsAttribute($refDataAttribute)->willReturn(true); $refDataAttribute->getCode()->willReturn('ref_data'); $refDataAttribute->getAttributeType()->willReturn(AttributeTypes::REFERENCE_DATA_MULTI_SELECT); $refDataAttribute->isScopable()->willReturn(false); $refDataAttribute->isLocalizable()->willReturn(false); $refDataAttribute->isBackendTypeReferenceData()->willReturn(true); $helperSet->get('table')->willReturn($table); $headers = ['attribute', 'localizable', 'scopable', 'attribute type', 'operators', 'filter_class']; $table->setHeaders($headers)->shouldBeCalled()->willReturn($table); $table->setRows(Argument::that(function ($param) { return 'ref_data' === $param[0][0] && 'no' === $param[0][1] && 'no' === $param[0][2] && AttributeTypes::REFERENCE_DATA_MULTI_SELECT === $param[0][3] && 'IN, EMPTY' === $param[0][4] && false !== strpos($param[0][5], 'AttributeFilterInterface'); }))->shouldBeCalled(); $table->render(Argument::any())->shouldBeCalled(); $this->dump($output, $helperSet); }
/** * Add a filter condition on an attribute * * @param AttributeFilterInterface $filter the filter * @param AttributeInterface $attribute the attribute * @param string $operator the operator * @param mixed $value the value to filter * @param array $context the filter context * * @return ProductQueryBuilderInterface */ protected function addAttributeFilter(AttributeFilterInterface $filter, AttributeInterface $attribute, $operator, $value, array $context) { $locale = $attribute->isLocalizable() ? $context['locale'] : null; $scope = $attribute->isScopable() ? $context['scope'] : null; $filter->setQueryBuilder($this->getQueryBuilder()); $filter->addAttributeFilter($attribute, $operator, $value, $locale, $scope, $context); return $this; }