예제 #1
1
 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);
 }
예제 #2
0
 /**
  * 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;
 }
 /**
  * {@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;
     });
 }
 /**
  * @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)]];
     });
 }
 /**
  * {@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;
     });
 }
예제 #6
0
 /**
  * {@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;
 }
 /**
  * {@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();
 }
 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());
         }
     }
 }
예제 #9
0
 /**
  * @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;
     }
 }
예제 #10
0
 /**
  * {@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'));
 }
예제 #11
0
 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];
 }
예제 #12
0
 /**
  * @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];
 }
예제 #13
0
 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];
 }
예제 #14
0
 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'])];
 }
예제 #15
0
 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];
 }
예제 #16
0
 public function getDummyData(Generator $faker, array $valoresPersonalizados = array())
 {
     return ['nombres' => $faker->firstName, 'apellidos' => $faker->lastName, 'telefono' => '5' . $faker->randomNumber($nbDigits = 6), 'celular' => '9' . $faker->randomNumber($nbDigits = 8), 'direccion' => $faker->streetAddress, 'year' => $faker->randomDigit($nbDigits = 6), 'orden_merito' => $faker->numberBetween($min = 2, $max = 10), 'usuario_id' => $this->getRandom('Usuario')->id];
 }
예제 #17
0
 public function __construct(Generator $generator, $offset, $quantity)
 {
     for ($i = 0; $i < $quantity; $i++) {
         $this->products[] = new Product($offset++, $generator->catchPhrase, $generator->randomNumber(50, 500));
     }
 }
예제 #18
0
 /**
  * @param Generator $faker
  *
  * @return array
  */
 public function fakeProduct($faker)
 {
     return array('id' => $faker->uuid, 'name' => $faker->name, 'weight' => $faker->randomNumber(), 'ean13' => $faker->ean13);
 }
예제 #19
0
 /**
  * @param ProductVariantInterface $productVariant
  * @param ChannelInterface $channel
  */
 private function createChannelPricings(ProductVariantInterface $productVariant, ChannelInterface $channel)
 {
     /** @var ChannelPricingInterface $channelPricing */
     $channelPricing = $this->channelPricingFactory->createNew();
     $channelPricing->setChannel($channel);
     $channelPricing->setPrice($this->faker->randomNumber(3));
     $productVariant->addChannelPricing($channelPricing);
 }
 /**
  * Gets a random integer
  *
  * @param Faker\Generator
  * @return int
  */
 public function getFakeData(Generator $faker)
 {
     return $faker->randomNumber();
 }
 public function getDummyData(Generator $faker, array $customValues = [])
 {
     return ['reference' => $faker->randomNumber(4), 'name' => $faker->sentence(2), 'description' => $faker->paragraph(1)];
 }
 public function getDummyData(Generator $faker, array $customValues = [])
 {
     return ['reference' => $faker->unique()->bothify('????###'), 'central' => $faker->randomNumber(4), 'cc_cd' => $faker->numerify('CC-###'), 'capacity_asap' => $faker->randomNumber(6), 'capacity_adp' => $faker->randomNumber(6)];
 }
 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['fecha_inicio' => $faker->dateTimeBetween($startDate = '-1 years', $endDate = 'now'), 'cliente_id' => $this->getRandom('Cliente')->id, 'tipo' => $faker->randomElement(['Local', 'Local', 'Nacional']), 'tiempo' => $faker->randomElement(['24 horas', '48 horas', '2 dias']), 'nro_orden' => $faker->randomNumber(6), 'estado' => $faker->randomElement(['En proceso', 'Despachado'])];
 }