/** * @param AddressInterface $address * @param ZoneInterface $zone * * @return bool */ protected function addressBelongsToZone(AddressInterface $address, ZoneInterface $zone) { foreach ($zone->getMembers() as $member) { if ($this->addressBelongsToZoneMember($address, $member)) { return true; } } return false; }
function it_matches_all_zones_by_scope_when_one_zone_for_address_is_defined(RepositoryInterface $repository, AddressInterface $address, ZoneMemberInterface $memberCountry, ZoneInterface $zoneCountry) { $repository->findBy(['scope' => 'shipping'])->willReturn([$zoneCountry]); $address->getCountryCode()->willReturn('US'); $memberCountry->getCode()->willReturn('US'); $zoneCountry->getType()->willReturn(ZoneInterface::TYPE_COUNTRY); $zoneCountry->getMembers()->willReturn([$memberCountry]); $memberCountry->getBelongsTo()->willReturn($zoneCountry); $this->matchAll($address, 'shipping')->shouldReturn([$zoneCountry]); }
function it_should_match_all_zones_by_scope_when_one_zone_for_address_is_defined($repository, CountryInterface $country, AddressInterface $address, ZoneMemberCountry $memberCountry, ZoneInterface $zoneCountry) { $repository->findBy(array('scope' => 'shipping'))->shouldBeCalled()->willReturn(array($zoneCountry)); $address->getCountry()->shouldBeCalled()->willReturn($country); $memberCountry->getCountry()->shouldBeCalled()->willReturn($country); $zoneCountry->getType()->shouldBeCalled()->willReturn(ZoneInterface::TYPE_COUNTRY); $zoneCountry->getMembers()->shouldBeCalled()->willReturn(array($memberCountry)); $memberCountry->getBelongsTo()->willReturn($zoneCountry); $this->matchAll($address, 'shipping')->shouldReturn(array($zoneCountry)); }