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);
 }
Пример #2
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;
 }
Пример #3
0
 /**
  * Adds all US states as provinces to given country.
  *
  * @param CountryInterface $country
  */
 protected function addUsStates(CountryInterface $country)
 {
     $provinceRepository = $this->getProvinceRepository();
     foreach ($this->states as $isoName => $name) {
         $province = $provinceRepository->createNew()->setName($name)->setIsoName($isoName);
         $country->addProvince($province);
         $this->setReference('Sylius.Province.' . $isoName, $province);
     }
 }
Пример #4
0
 /**
  * Adds all US states as provinces to given country.
  *
  * @param CountryInterface $country
  */
 protected function addUsStates(CountryInterface $country)
 {
     $provinceFactory = $this->getProvinceFactory();
     foreach ($this->states as $provinceCode => $name) {
         $province = $provinceFactory->createNew();
         $province->setName($name);
         $province->setCode($provinceCode);
         $country->addProvince($province);
         $this->setReference('Sylius.Province.' . $provinceCode, $province);
     }
 }
 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);
 }
Пример #6
0
 /**
  * @When /^I want to create a new province in (country "([^"]*)")$/
  */
 public function iWantToCreateANewProvinceInCountry(CountryInterface $country)
 {
     $this->updatePage->open(['id' => $country->getId()]);
     $this->updatePage->clickAddProvinceButton();
 }
Пример #7
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()));
         }
     }
 }
Пример #8
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);
 }
Пример #9
0
 /**
  * @Given /^(this country)(?:| also) has the "([^"]+)" province with "([^"]+)" code$/
  * @Given /^(?:|the )(country "[^"]+") has the "([^"]+)" province with "([^"]+)" code$/
  */
 public function theCountryHasProvinceWithCode(CountryInterface $country, $name, $code)
 {
     /** @var ProvinceInterface $province */
     $province = $this->provinceFactory->createNew();
     $province->setName($name);
     $province->setCode($code);
     $country->addProvince($province);
     $this->sharedStorage->set('province', $province);
     $this->countryManager->flush();
 }
Пример #10
0
 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(NotEqualException::class)->during('countryWithNameShouldAppearInTheStore', [$country]);
 }
Пример #11
0
 /**
  * @Given /^(country "([^"]*)") should appear in the store$/
  */
 public function countryWithNameShouldAppearInTheStore(CountryInterface $country)
 {
     expect($this->countryIndexPage->isResourceOnPage(['code' => $country->getCode()]))->toBe(true);
 }
Пример #12
0
 function it_throws_if_trying_to_define_province_which_does_not_belong_to_country(CountryInterface $country, ProvinceInterface $province)
 {
     $country->hasProvince($province)->willReturn(false);
     $this->setCountry($country);
     $country->getName()->willReturn('United States');
     $province->getName()->willReturn('Quebec');
     $expectedExceptionMessage = 'Cannot set province "Quebec", because it does not belong to country "United States"';
     $this->shouldThrow(new \InvalidArgumentException($expectedExceptionMessage))->duringSetProvince($province);
 }
Пример #13
0
 /**
  * @Then /^(country "[^"]+") should appear in the store$/
  */
 public function countryShouldAppearInTheStore(CountryInterface $country)
 {
     Assert::true($this->countryIndexPage->isResourceOnPage(['code' => $country->getCode()]), sprintf('Country %s should exist but it does not', $country->getCode()));
 }
Пример #14
0
 function it_has_fluent_interface(CountryInterface $country, ProvinceInterface $province)
 {
     $this->setFirstName('John')->shouldReturn($this);
     $this->setLastName('Doe')->shouldReturn($this);
     $this->setStreet('Foo Street 3-44')->shouldReturn($this);
     $this->setCity('Nashville')->shouldReturn($this);
     $this->setPostcode('53562')->shouldReturn($this);
     $country->hasProvince($province)->willReturn(true);
     $this->setCountry($country)->shouldReturn($this);
     $this->setProvince($province)->shouldReturn($this);
 }
Пример #15
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();
 }
Пример #16
0
 function it_translates_country_into_name(CountryInterface $country)
 {
     $country->getCode()->willReturn('IE');
     $this->translateCountryIsoCode($country)->shouldReturn('Ireland');
 }
 function it_opens_country_update_page(UpdatePageInterface $countryUpdatePage, CountryInterface $country)
 {
     $country->getId()->willReturn(10);
     $countryUpdatePage->open(['id' => 10])->shouldBeCalled();
     $this->iWantToEditThisCountry($country);
 }
Пример #18
0
 function it_returns_country_name(CountryInterface $country)
 {
     $country->getName()->willReturn('Serbia');
     $this->setCountry($country);
     $this->getName()->shouldReturn('Serbia');
 }
Пример #19
0
 /**
  * @param array $provinces
  * @param CountryInterface $country
  */
 private function loadProvincesForCountry(array $provinces, CountryInterface $country)
 {
     foreach ($provinces as $provinceCode => $provinceName) {
         /** @var ProvinceInterface $province */
         $province = $this->provinceFactory->createNew();
         $province->setCode($provinceCode);
         $province->setName($provinceName);
         $country->addProvince($province);
         $this->provinceManager->persist($province);
     }
 }