当前位置: 首页>>代码示例>>PHP>>正文


PHP Generator::randomNumber方法代码示例

本文整理汇总了PHP中Faker\Generator::randomNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::randomNumber方法的具体用法?PHP Generator::randomNumber怎么用?PHP Generator::randomNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Faker\Generator的用法示例。


在下文中一共展示了Generator::randomNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     $this->faker = Factory::create();
     $this->id = TwitterMessageId::create($this->faker->uuid);
     $this->lang = $this->faker->countryISOAlpha3;
     $this->userName = $this->faker->userName;
     $this->hashtagText = $this->faker->word;
     $this->text = $this->faker->text();
     $this->complexText = '@' . $this->userName . ' ' . $this->text . ' #' . $this->hashtagText;
     $this->date = new \DateTimeImmutable();
     $this->coordinates = \Mockery::mock(TwitterCoordinates::class);
     $this->place = \Mockery::mock(TwitterPlace::class);
     $this->inReplyToStatusId = $this->faker->randomNumber();
     $this->inReplyToUserId = $this->faker->randomNumber();
     $this->inReplyToScreenName = $this->faker->userName;
     $this->retweeted = $this->faker->boolean();
     $this->retweetCount = $this->faker->randomNumber();
     $this->favorited = $this->faker->boolean();
     $this->favoriteCount = $this->faker->randomNumber();
     $this->truncated = $this->faker->boolean();
     $this->source = null;
     $this->retweetedStatus = \Mockery::mock(Tweet::class);
     $this->hashtag = \Mockery::mock(TwitterHashtag::class);
     $this->userMention = \Mockery::mock(TwitterUserMention::class);
     $this->sender = \Mockery::mock(TwitterUser::class);
     $this->recipient = \Mockery::mock(TwitterUser::class);
     $this->entities = \Mockery::mock(TwitterEntities::class);
 }
开发者ID:remi-san,项目名称:twitter,代码行数:28,代码来源:TweetTest.php

示例2: getDefaultFields

 /**
  * Returns default values by given fields
  *
  * @param array $fields
  * @return array
  */
 protected function getDefaultFields(array $fields)
 {
     $defaults = array('oxid' => $this->generator->md5, 'oxparentid' => '', 'oxactive' => '1', 'oxtimestamp' => $this->generator->dateTime, 'oxshopid' => 'oxbaseshop', 'oxsort' => $this->generator->randomNumber(), 'oxactivefrom' => '0000-00-00 00:00:00', 'oxactiveto' => '0000-00-00 00:00:00', 'oxdesc' => $this->generator->text(255), 'oxshortdesc' => $this->generator->text(50));
     foreach ($defaults as $key => $value) {
         if (false === in_array($key, $fields)) {
             unset($defaults[$key]);
         }
     }
     return $defaults;
 }
开发者ID:edvinaskrucas,项目名称:srunit,代码行数:16,代码来源:AbstractProvisioner.php

示例3: configureOptions

 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('type', CartQuantityRuleChecker::TYPE)->setAllowedTypes('type', 'string')->setDefault('configuration', ['count' => $this->faker->randomNumber(1)])->setNormalizer('configuration', function (Options $options, $configuration) {
         foreach ($configuration as $channelCode => $channelConfiguration) {
             if (isset($channelConfiguration['amount'])) {
                 $configuration[$channelCode]['amount'] *= 100;
             }
         }
         return $configuration;
     });
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:14,代码来源:PromotionRuleExampleFactory.php

示例4: __construct

 /**
  * @param FactoryInterface $shippingMethodFactory
  * @param RepositoryInterface $zoneRepository
  * @param RepositoryInterface $shippingCategoryRepository
  * @param RepositoryInterface $localeRepository
  */
 public function __construct(FactoryInterface $shippingMethodFactory, RepositoryInterface $zoneRepository, RepositoryInterface $shippingCategoryRepository, RepositoryInterface $localeRepository)
 {
     $this->shippingMethodFactory = $shippingMethodFactory;
     $this->localeRepository = $localeRepository;
     $this->faker = \Faker\Factory::create();
     $this->optionsResolver = (new OptionsResolver())->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('description', function (Options $options) {
         return $this->faker->sentence();
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('zone', LazyOption::randomOne($zoneRepository))->setAllowedTypes('zone', ['null', 'string', ZoneInterface::class])->setNormalizer('zone', LazyOption::findOneBy($zoneRepository, 'code'))->setDefined('shipping_category')->setAllowedTypes('shipping_category', ['null', 'string', ShippingCategoryInterface::class])->setNormalizer('shipping_category', LazyOption::findOneBy($shippingCategoryRepository, 'code'))->setDefault('calculator', function (Options $options) {
         return ['type' => DefaultCalculators::FLAT_RATE, 'configuration' => ['amount' => $this->faker->randomNumber(4)]];
     });
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:23,代码来源:ShippingMethodExampleFactory.php

示例5: configureOptions

 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('type', PercentageDiscountPromotionActionCommand::TYPE)->setAllowedTypes('type', 'string')->setDefault('configuration', ['percentage' => $this->faker->randomNumber(2)])->setNormalizer('configuration', function (Options $options, $configuration) {
         foreach ($configuration as $channelCode => $channelConfiguration) {
             if (isset($channelConfiguration['amount'])) {
                 $configuration[$channelCode]['amount'] *= 100;
             }
             if (isset($channelConfiguration['percentage'])) {
                 $configuration[$channelCode]['percentage'] /= 100;
             }
         }
         if (isset($configuration['percentage'])) {
             $configuration['percentage'] /= 100;
         }
         return $configuration;
     });
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:20,代码来源:PromotionActionExampleFactory.php

示例6: create

 /**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ProductInterface $product */
     $product = $this->productFactory->createNew();
     $product->setVariantSelectionMethod(ProductInterface::VARIANT_SELECTION_MATCH);
     $product->setCode($options['code']);
     $product->setEnabled($options['enabled']);
     $product->setMainTaxon($options['main_taxon']);
     $product->setCreatedAt($this->faker->dateTimeBetween('-1 week', 'now'));
     foreach ($this->getLocales() as $localeCode) {
         $product->setCurrentLocale($localeCode);
         $product->setFallbackLocale($localeCode);
         $product->setName($options['name']);
         $product->setShortDescription($options['short_description']);
         $product->setDescription($options['description']);
     }
     foreach ($options['taxons'] as $taxon) {
         $product->addTaxon($taxon);
     }
     foreach ($options['channels'] as $channel) {
         $product->addChannel($channel);
     }
     foreach ($options['product_options'] as $option) {
         $product->addOption($option);
     }
     foreach ($options['product_attributes'] as $attribute) {
         $product->addAttribute($attribute);
     }
     try {
         $this->variantGenerator->generate($product);
     } catch (\InvalidArgumentException $exception) {
         /** @var ProductVariantInterface $productVariant */
         $productVariant = $this->productVariantFactory->createNew();
         $product->addVariant($productVariant);
     }
     $i = 0;
     /** @var ProductVariantInterface $productVariant */
     foreach ($product->getVariants() as $productVariant) {
         $productVariant->setAvailableOn($this->faker->dateTimeThisYear);
         $productVariant->setPrice($this->faker->randomNumber(4));
         $productVariant->setCode(sprintf('%s-variant#%d', $options['code'], $i));
         $productVariant->setOnHand($this->faker->randomNumber(1));
         ++$i;
     }
     foreach ($options['images'] as $imageCode => $imagePath) {
         /** @var ImageInterface $productImage */
         $productImage = $this->productImageFactory->createNew();
         $productImage->setCode($imageCode);
         $productImage->setFile(new UploadedFile($imagePath, basename($imagePath)));
         $this->imageUploader->upload($productImage);
         $product->addImage($productImage);
     }
     return $product;
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:58,代码来源:ProductExampleFactory.php

示例7: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     // Generate 20 access codes
     $faker = new Generator();
     $faker->addProvider(new Base($faker));
     for ($i = 0; $i < 20; $i++) {
         $code = new StudentAccessCode();
         $code->setCode($faker->randomNumber(8));
         $manager->persist($code);
     }
     $manager->flush();
 }
开发者ID:hoangnd25,项目名称:IndustryProject,代码行数:15,代码来源:StudentAccessCodeFixture.php

示例8: testResponse

 public function testResponse()
 {
     foreach (array(PaymentStatus::SUCCESS, PaymentStatus::DECLINED, PaymentStatus::INCOMPLETE) as $status) {
         $response = array('orderID' => $this->faker->randomNumber('####'), 'currency' => 'CHF', 'amount' => $this->faker->randomFloat(2, 1, 100), 'PM' => $this->faker->randomElement(array(PaymentMethod::POSTFINANCE_EFINANCE, PaymentMethod::CREDITCARD, PaymentMethod::POSTFINANCE_CARD)), 'ACCEPTANCE' => 'test123', 'STATUS' => $status, 'CARDNO' => 'XXXXXXXXXXXX' . $this->faker->randomNumber('####'), 'ED' => $this->faker->numberBetween(10, 12) . $this->faker->numberBetween(10, 99), 'CN' => $this->faker->name, 'TRXDATE' => $this->faker->date('m/d/Y'), 'PAYID' => $this->faker->randomNumber('########'), 'IPCTY' => $this->faker->countryCode, 'CCCTY' => $this->faker->countryCode, 'ECI' => '5', 'CVCCheck' => 'NO', 'AAVCheck' => 'NO', 'VC' => 'NO', 'IP' => $this->faker->ipv4, 'NCERROR' => '0');
         if ($response['PM'] === PaymentMethod::CREDITCARD) {
             $response['BRAND'] = $this->faker->randomElement(array(Brand::MASTERCARD, Brand::VISA));
         } elseif ($response['PM'] === PaymentMethod::POSTFINANCE_CARD) {
             $response['BRAND'] = PaymentMethod::POSTFINANCE_CARD;
         } elseif ($response['PM'] === PaymentMethod::POSTFINANCE_EFINANCE) {
             $response['BRAND'] = PaymentMethod::POSTFINANCE_EFINANCE;
         }
         $response['SHASIGN'] = $this->createHash($response, $this->environment->getShaOut(), $this->environment->getHashAlgorithm());
         $ePayment = new PostFinanceEPayment($this->environment);
         $response = $ePayment->getResponse($response);
         $this->assertTrue($response instanceof Response);
         if ($status === PaymentStatus::SUCCESS) {
             $this->assertFalse($response->hasError());
         } else {
             $this->assertTrue($response->hasError());
         }
     }
 }
开发者ID:whatwedo,项目名称:postfinance-e-payment,代码行数:22,代码来源:PostFinanceEPaymentTest.php

示例9: createVariants

 /**
  * @param ProductInterface $product
  * @param array $options
  */
 private function createVariants(ProductInterface $product, array $options)
 {
     try {
         $this->variantGenerator->generate($product);
     } catch (\InvalidArgumentException $exception) {
         /** @var ProductVariantInterface $productVariant */
         $productVariant = $this->productVariantFactory->createNew();
         $product->addVariant($productVariant);
     }
     $i = 0;
     /** @var ProductVariantInterface $productVariant */
     foreach ($product->getVariants() as $productVariant) {
         $productVariant->setAvailableOn($this->faker->dateTimeThisYear);
         $productVariant->setPrice($this->faker->randomNumber(4));
         $productVariant->setCode(sprintf('%s-variant#%d', $options['code'], $i));
         $productVariant->setOnHand($this->faker->randomNumber(1));
         ++$i;
     }
 }
开发者ID:loic425,项目名称:Sylius,代码行数:23,代码来源:ProductExampleFactory.php

示例10: configureOptions

 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('description', function (Options $options) {
         return $this->faker->sentence();
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('zone', LazyOption::randomOne($this->zoneRepository))->setAllowedTypes('zone', ['null', 'string', ZoneInterface::class])->setNormalizer('zone', LazyOption::findOneBy($this->zoneRepository, 'code'))->setDefined('shipping_category')->setAllowedTypes('shipping_category', ['null', 'string', ShippingCategoryInterface::class])->setNormalizer('shipping_category', LazyOption::findOneBy($this->shippingCategoryRepository, 'code'))->setDefault('calculator', function (Options $options) {
         $configuration = [];
         /** @var ChannelInterface $channel */
         foreach ($options['channels'] as $channel) {
             $configuration[$channel->getCode()] = ['amount' => $this->faker->randomNumber(4)];
         }
         return ['type' => DefaultCalculators::FLAT_RATE, 'configuration' => $configuration];
     })->setDefault('channels', LazyOption::all($this->channelRepository))->setAllowedTypes('channels', 'array')->setNormalizer('channels', LazyOption::findBy($this->channelRepository, 'code'));
 }
开发者ID:sylius,项目名称:sylius,代码行数:22,代码来源:ShippingMethodExampleFactory.php

示例11: getDummyData

 public function getDummyData(Generator $faker, array $custom = [])
 {
     return ['number_document' => $faker->randomNumber($nbDigits = 5), 'description' => $faker->text, 'expiration' => $faker->date($format = 'Y-m-d', $max = 'now'), 'estatus' => $faker->randomElement($array = array('Received', 'Review', 'Correction', 'Signature', 'Sent')), 'responsable_id' => $this->random('User')->id, 'user_id' => $this->random('User')->id];
 }
开发者ID:aguila302,项目名称:oficios,代码行数:4,代码来源:DocumentTableSeeder.php

示例12: generateCreateParams

 /**
  * @return array
  */
 protected function generateCreateParams()
 {
     return ['meetingName' => $this->faker->name, 'meetingId' => $this->faker->uuid, 'attendeePassword' => $this->faker->password, 'moderatorPassword' => $this->faker->password, 'autoStartRecording' => $this->faker->boolean(50), 'dialNumber' => $this->faker->phoneNumber, 'voiceBridge' => $this->faker->randomNumber(5), 'webVoice' => $this->faker->word, 'logoutUrl' => $this->faker->url, 'maxParticipants' => $this->faker->numberBetween(2, 100), 'record' => $this->faker->boolean(50), 'duration' => $this->faker->numberBetween(0, 6000), 'welcomeMessage' => $this->faker->sentence, 'allowStartStopRecording' => $this->faker->boolean(50), 'moderatorOnlyMessage' => $this->faker->sentence, 'meta_presenter' => $this->faker->name];
 }
开发者ID:riadvice,项目名称:bigbluebutton-api-php,代码行数:7,代码来源:TestCase.php

示例13: getDummyData

 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['cantidad' => $faker->randomNumber($nbDigits = 1), 'peso' => $faker->randomNumber($nbDigits = 2), 'envio' => $faker->word, 'descripcion' => $faker->sentence($nbWords = 6), 'entrega_id' => $this->getRandom('Entrega')->id];
 }
开发者ID:jkrlos2791,项目名称:Courier,代码行数:4,代码来源:ItemEntregaTableSeeder.php

示例14: getDummyData

 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['nombre' => $faker->name, 'direccion' => $faker->address, 'ruc' => $faker->randomNumber(8), 'banco' => $faker->randomElement(['BCP', 'Continental', 'Interbank'])];
 }
开发者ID:jkrlos2791,项目名称:Courier,代码行数:4,代码来源:ClienteTableSeeder.php

示例15: getDummyData

 public function getDummyData(Generator $faker, array $valoresPersonalizados = array())
 {
     return ['nombre' => $faker->firstName, 'apellido' => $faker->lastName, 'email' => $faker->unique()->email, 'telefono' => '5' . $faker->randomNumber($nbDigits = 6), 'celular' => '9' . $faker->randomNumber($nbDigits = 8), 'activo' => 1];
 }
开发者ID:dsalazar37,项目名称:electivos,代码行数:4,代码来源:TutorTableSeeder.php


注:本文中的Faker\Generator::randomNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。