Ejemplo n.º 1
0
 /**
  * @param CountryInterface $country
  * @param string $status
  *
  * @return bool
  */
 private function checkCountryStatus(CountryInterface $country, $status)
 {
     $tableAccessor = $this->getTableAccessor();
     $table = $this->getElement('table');
     $row = $tableAccessor->getRowWithFields($table, ['code' => $country->getCode()]);
     $enabledField = $tableAccessor->getFieldFromRow($table, $row, 'Enabled');
     return $enabledField->getText() === $status;
 }
 function it_should_recognize_subject_as_eligible_if_country_match(OrderInterface $subject, AddressInterface $address, CountryInterface $country, RepositoryInterface $countryRepository)
 {
     $country->getCode()->willReturn('IE');
     $address->getCountryCode()->willReturn('IE');
     $subject->getShippingAddress()->willReturn($address);
     $countryRepository->findOneBy(['code' => 'IE'])->willReturn($country);
     $this->isEligible($subject, ['country' => 'IE'])->shouldReturn(true);
 }
 function it_adds_or_removes_provinces_on_pre_set_data(FormFactoryInterface $formFactory, FormEvent $event, FormInterface $form, FormInterface $provinceForm, AddressInterface $address, CountryInterface $country, ProvinceInterface $province)
 {
     $event->getForm()->willReturn($form);
     $event->getData()->willReturn($address);
     $country->getCode()->willReturn('IE');
     $address->getCountryCode()->willReturn('IE');
     $country->hasProvinces()->willReturn(true);
     $province->getCode()->willReturn('province');
     $address->getProvinceCode()->willReturn('province');
     $formFactory->createNamed('provinceCode', 'sylius_province_code_choice', 'province', Argument::withKey('country'))->willReturn($provinceForm);
     $this->preSetData($event);
 }
Ejemplo n.º 4
0
 /**
  * Adds all US states as provinces to given country.
  *
  * @param CountryInterface $country
  */
 protected function addUsStates(CountryInterface $country)
 {
     $provinceFactory = $this->getProvinceFactory();
     $countryCode = $country->getCode();
     foreach ($this->states as $baseProvinceCode => $name) {
         $province = $provinceFactory->createNew();
         $province->setName($name);
         $newProvinceCode = sprintf('%s-%s', $countryCode, $baseProvinceCode);
         $province->setCode($newProvinceCode);
         $country->addProvince($province);
         $this->setReference('Sylius.Province.' . $newProvinceCode, $province);
     }
 }
Ejemplo n.º 5
0
 function it_translates_country_into_name(CountryInterface $country)
 {
     $country->getCode()->willReturn('IE');
     $this->translateCountryIsoCode($country)->shouldReturn('Ireland');
 }
Ejemplo n.º 6
0
 /**
  * @When /^I proceed as guest "([^"]*)" with ("[^"]+" as shipping country)$/
  */
 public function iProceedLoggingAsGuestWithAsShippingCountry($email, CountryInterface $shippingCountry = null)
 {
     $this->addressPage->open();
     $this->addressPage->specifyEmail($email);
     $shippingAddress = $this->createDefaultAddress();
     if (null !== $shippingCountry) {
         $shippingAddress->setCountryCode($shippingCountry->getCode());
     }
     $this->addressPage->specifyShippingAddress($shippingAddress);
     $this->addressPage->nextStep();
 }
Ejemplo n.º 7
0
 /**
  * @Then /^the (country "([^"]+)") should appear in the store$/
  */
 public function countryShouldAppearInTheStore(CountryInterface $country)
 {
     $this->indexPage->open();
     Assert::true($this->indexPage->isSingleResourceOnPage(['code' => $country->getCode()]), sprintf('Country %s should exist but it does not', $country->getCode()));
 }
Ejemplo n.º 8
0
 /**
  * @param CountryInterface $country
  * @param TableNode|array $provinces
  */
 private function addProvincesToCountry($country, $provinces)
 {
     if (null !== $provinces) {
         $provinces = $provinces instanceof TableNode ? $provinces->getHash() : $provinces;
         foreach ($provinces as $provinceName) {
             $country->addProvince($this->thereisProvince($provinceName, $country->getCode()));
         }
     }
 }
Ejemplo n.º 9
0
 function it_matches_address_from_province_when_many_are_found(RepositoryInterface $repository, CountryInterface $country, ProvinceInterface $province, AddressInterface $address, ZoneMemberInterface $memberCountry, ZoneMemberInterface $memberProvince, ZoneInterface $zoneCountry, ZoneInterface $zoneProvince)
 {
     $province->getCode()->willReturn('DU');
     $country->getCode()->willReturn('IE');
     $address->getCountryCode()->willReturn('IE');
     $address->getProvinceCode()->willReturn('DU');
     $memberCountry->getCode()->willReturn('IE');
     $memberProvince->getCode()->willReturn('DU');
     $zoneProvince->getMembers()->willReturn([$memberProvince]);
     $zoneProvince->getType()->willReturn(ZoneInterface::TYPE_PROVINCE);
     $zoneCountry->getMembers()->willReturn([$memberCountry]);
     $zoneCountry->getType()->willReturn(ZoneInterface::TYPE_COUNTRY);
     $repository->findAll()->willReturn([$zoneCountry, $zoneProvince]);
     $memberProvince->getBelongsTo()->willReturn($zoneProvince);
     $memberCountry->getBelongsTo()->willReturn($zoneCountry);
     $this->match($address)->shouldReturn($zoneProvince);
 }
 function it_throws_not_equal_exception_if_country_does_not_appear_in_the_store(IndexPageInterface $countryIndexPage, CountryInterface $country)
 {
     $country->getCode()->willReturn('FR');
     $countryIndexPage->isResourceOnPage(['code' => 'FR'])->willReturn(false);
     $this->shouldThrow(\InvalidArgumentException::class)->during('countryShouldAppearInTheStore', [$country]);
 }
Ejemplo n.º 11
0
 /**
  * @Given /^(country "([^"]*)") should appear in the store$/
  */
 public function countryWithNameShouldAppearInTheStore(CountryInterface $country)
 {
     expect($this->countryIndexPage->isResourceOnPage(['code' => $country->getCode()]))->toBe(true);
 }