コード例 #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);
 }
コード例 #2
0
 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']);
 }
コード例 #3
0
ファイル: IndexPage.php プロジェクト: gabiudrescu/Sylius
 /**
  * @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;
 }
コード例 #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']);
 }
コード例 #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);
 }
コード例 #6
0
ファイル: SetupCommand.php プロジェクト: starspire/Sylius
 /**
  * @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.');
 }
コード例 #7
0
ファイル: SetupCommand.php プロジェクト: Niiko/Sylius
 /**
  * @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.');
 }
コード例 #8
0
 /**
  * @Given /^I want to edit (this locale)$/
  */
 public function iWantToEditThisLocale(LocaleInterface $locale)
 {
     $this->updatePage->open(['id' => $locale->getId()]);
 }
コード例 #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']);
 }
コード例 #10
0
 function it_opens_locale_update_page(UpdatePageInterface $updatePage, LocaleInterface $locale)
 {
     $locale->getId()->willReturn(1);
     $updatePage->open(['id' => 1])->shouldBeCalled();
     $this->iWantToEditThisLocale($locale);
 }
コード例 #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']);
 }