/** * @param ProductInterface $product * @param array $taxons * * @return bool */ private function hasProductValidTaxon(ProductInterface $product, array $taxons) { foreach ($product->getProductTaxons() as $productTaxon) { if (in_array($productTaxon->getTaxon()->getCode(), $taxons)) { return true; } } return false; }
function it_recognizes_a_subject_as_not_eligible_if_a_product_taxon_is_not_matched(OrderInterface $subject, OrderItemInterface $item, ProductInterface $reflexBow, ProductTaxonInterface $reflexBowProductTaxon, TaxonInterface $bows) { $configuration = ['taxons' => ['swords', 'axes']]; $bows->getCode()->willReturn('bows'); $reflexBow->getProductTaxons()->willReturn([$reflexBowProductTaxon]); $reflexBowProductTaxon->getTaxon()->willReturn($bows); $item->getProduct()->willReturn($reflexBow); $subject->getItems()->willReturn([$item]); $this->isEligible($subject, $configuration)->shouldReturn(false); }