Ejemplo n.º 1
0
 function it_checks_if_the_locale_is_available(RepositoryInterface $repository, LocaleInterface $locale)
 {
     $repository->findBy(Argument::any())->willReturn(array($locale));
     $locale->getCode()->willReturn('en');
     $this->isLocaleAvailable('en')->shouldReturn(true);
     $this->isLocaleAvailable('fr')->shouldReturn(false);
 }
 function it_provides_available_locales($localeRepository, LocaleInterface $firstLocale, LocaleInterface $secondLocale)
 {
     $locales = [$firstLocale, $secondLocale];
     $localeRepository->findBy(['enabled' => true])->willReturn($locales);
     $firstLocale->getCode()->willReturn('en_US');
     $secondLocale->getCode()->willReturn('pl_PL');
     $this->getAvailableLocales()->shouldReturn(['en_US', 'pl_PL']);
 }
Ejemplo n.º 3
0
 /**
  * @param LocaleInterface $locale
  * @param string $status
  *
  * @return bool
  */
 private function checkLocaleStatus(LocaleInterface $locale, $status)
 {
     $tableAccessor = $this->getTableAccessor();
     $table = $this->getElement('table');
     $row = $tableAccessor->getRowWithFields($table, ['code' => $locale->getCode()]);
     $enabledField = $tableAccessor->getFieldFromRow($table, $row, 'enabled');
     return $enabledField->getText() === $status;
 }
Ejemplo n.º 4
0
 function it_returns_only_channels_enabled_locales_as_available_ones(ChannelContextInterface $channelContext, ChannelInterface $channel, LocaleInterface $enabledLocale, LocaleInterface $disabledLocale)
 {
     $channelContext->getChannel()->willReturn($channel);
     $channel->getLocales()->willReturn(new ArrayCollection([$enabledLocale->getWrappedObject(), $disabledLocale->getWrappedObject()]));
     $enabledLocale->isEnabled()->willReturn(true);
     $disabledLocale->isEnabled()->willReturn(false);
     $enabledLocale->getCode()->willReturn('en_US');
     $this->getAvailableLocalesCodes()->shouldReturn(['en_US']);
 }
Ejemplo n.º 5
0
 function it_checks_if_the_locale_code_is_available(RepositoryInterface $localeRepository, LocaleInterface $firstLocale, LocaleInterface $secondLocale)
 {
     $locales = array($firstLocale, $secondLocale);
     $localeRepository->findBy(array('enabled' => true))->willReturn($locales);
     $firstLocale->getCode()->willReturn('en_US');
     $secondLocale->getCode()->willReturn('pl_PL');
     $this->isLocaleAvailable('en_US')->shouldReturn(true);
     $this->isLocaleAvailable('de_DE')->shouldReturn(false);
 }
Ejemplo n.º 6
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function setupAdministratorUser(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Create your administrator account.');
     $userManager = $this->get('sylius.manager.admin_user');
     $userRepository = $this->get('sylius.repository.admin_user');
     $userFactory = $this->get('sylius.factory.admin_user');
     /** @var AdminUserInterface $user */
     $user = $userFactory->createNew();
     if ($input->getOption('no-interaction')) {
         $exists = null !== $userRepository->findOneByEmail('*****@*****.**');
         if ($exists) {
             return 0;
         }
         $user->setEmail('*****@*****.**');
         $user->setPlainPassword('sylius');
     } else {
         do {
             $email = $this->ask($output, 'E-Mail:', [new NotBlank(), new Email()]);
             $exists = null !== $userRepository->findOneByEmail($email);
             if ($exists) {
                 $output->writeln('<error>E-Mail is already in use!</error>');
             }
         } while ($exists);
         $user->setEmail($email);
         $user->setPlainPassword($this->getAdministratorPassword($output));
     }
     $user->setEnabled(true);
     $user->setLocaleCode($this->locale->getCode());
     $userManager->persist($user);
     $userManager->flush();
     $output->writeln('Administrator account successfully registered.');
 }
Ejemplo n.º 7
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function setupAdministratorUser(InputInterface $input, OutputInterface $output)
 {
     /** @var QuestionHelper $questionHelper */
     $questionHelper = $this->getHelper('question');
     $output->writeln('Create your administrator account.');
     $userManager = $this->get('sylius.manager.admin_user');
     $userRepository = $this->get('sylius.repository.admin_user');
     $userFactory = $this->get('sylius.factory.admin_user');
     /** @var AdminUserInterface $user */
     $user = $userFactory->createNew();
     if ($input->getOption('no-interaction')) {
         $exists = null !== $userRepository->findOneByEmail('*****@*****.**');
         if ($exists) {
             return 0;
         }
         $user->setEmail('*****@*****.**');
         $user->setPlainPassword('sylius');
     } else {
         do {
             $question = new Question('E-mail:');
             $question->setValidator(function ($value) use($output) {
                 /** @var ConstraintViolationListInterface $errors */
                 $errors = $this->get('validator')->validate((string) $value, [new Email(), new NotBlank()]);
                 foreach ($errors as $error) {
                     throw new \DomainException($error->getMessage());
                 }
                 return $value;
             });
             $question->setMaxAttempts(3);
             $email = $questionHelper->ask($input, $output, $question);
             $exists = null !== $userRepository->findOneByEmail($email);
             if ($exists) {
                 $output->writeln('<error>E-Mail is already in use!</error>');
             }
         } while ($exists);
         $user->setEmail($email);
         $user->setPlainPassword($this->getAdministratorPassword($input, $output));
     }
     $user->setEnabled(true);
     $user->setLocaleCode($this->locale->getCode());
     $userManager->persist($user);
     $userManager->flush();
     $output->writeln('Administrator account successfully registered.');
 }
 /**
  * @Given /^I want to edit (this locale)$/
  */
 public function iWantToEditThisLocale(LocaleInterface $locale)
 {
     $this->updatePage->open(['id' => $locale->getId()]);
 }
Ejemplo n.º 9
0
 function it_returns_all_defined_locales(RepositoryInterface $localeRepository, LocaleInterface $locale)
 {
     $localeRepository->findAll()->willReturn([$locale]);
     $locale->getCode()->willReturn('en_US');
     $this->getDefinedLocalesCodes()->shouldReturn(['en_US']);
 }
 function it_opens_locale_update_page(UpdatePageInterface $updatePage, LocaleInterface $locale)
 {
     $locale->getId()->willReturn(1);
     $updatePage->open(['id' => 1])->shouldBeCalled();
     $this->iWantToEditThisLocale($locale);
 }
Ejemplo n.º 11
0
 function it_returns_all_enabled_locales(RepositoryInterface $localeRepository, LocaleInterface $locale)
 {
     $localeRepository->findBy(['enabled' => true])->willReturn([$locale]);
     $locale->getCode()->willReturn('en_US');
     $this->getAvailableLocalesCodes()->shouldReturn(['en_US']);
 }