/**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('type', function (Options $options) {
         return $this->faker->randomElement(array_keys($this->attributeTypes));
     })->setAllowedValues('type', array_keys($this->attributeTypes));
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function load(array $options)
 {
     $options = $this->optionsResolver->resolve($options);
     $this->taxonFixture->load(['custom' => [['code' => 'category', 'name' => 'Category', 'children' => [['code' => 'mugs', 'name' => 'Mugs']]]]]);
     $this->productAttributeFixture->load(['custom' => [['name' => 'Mug material', 'code' => 'mug_material', 'type' => TextAttributeType::TYPE]]]);
     $this->productOptionFixture->load(['custom' => [['name' => 'Mug type', 'code' => 'mug_type', 'values' => ['mug_type_medium' => 'Medium mug', 'mug_type_double' => 'Double mug', 'mug_type_monster' => 'Monster mug']]]]);
     $products = [];
     for ($i = 0; $i < $options['amount']; ++$i) {
         $products[] = ['name' => sprintf('Mug "%s"', $this->faker->word), 'code' => $this->faker->uuid, 'main_taxon' => 'mugs', 'taxons' => ['mugs'], 'product_attributes' => ['mug_material' => $this->faker->randomElement(['Invisible porcelain', 'Banana skin', 'Porcelain', 'Centipede'])], 'images' => [sprintf('%s/../Resources/fixtures/%s', __DIR__, 'mugs.jpg')]];
     }
     $this->productFixture->load(['custom' => $products]);
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function load(array $options)
 {
     $options = $this->optionsResolver->resolve($options);
     $this->taxonFixture->load(['custom' => [['code' => 'category', 'name' => 'Category', 'children' => [['code' => 'stickers', 'name' => 'Stickers']]]]]);
     $this->productAttributeFixture->load(['custom' => [['name' => 'Sticker paper', 'code' => 'sticker_paper', 'type' => TextAttributeType::TYPE], ['name' => 'Sticker resolution', 'code' => 'sticker_resolution', 'type' => TextAttributeType::TYPE]]]);
     $this->productOptionFixture->load(['custom' => [['name' => 'Sticker size', 'code' => 'sticker_size', 'values' => ['sticker_size-3' => '3"', 'sticker_size_5' => '5"', 'sticker_size_7' => '7"']]]]);
     $products = [];
     for ($i = 0; $i < $options['amount']; ++$i) {
         $products[] = ['name' => sprintf('Sticker "%s"', $this->faker->word), 'code' => $this->faker->uuid, 'main_taxon' => 'stickers', 'taxons' => ['stickers'], 'product_attributes' => ['sticker_paper' => sprintf('Paper from tree %s', $this->faker->randomElement(['Wung', 'Tanajno', 'Lemon-San', 'Me-Gusta'])), 'sticker_resolution' => $this->faker->randomElement(['JKM XD', '476DPI', 'FULL HD', '200DPI'])], 'images' => ['main' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 'stickers.jpg'), 'thumbnail' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 'stickers.jpg')]];
     }
     $this->productFixture->load(['custom' => $products]);
 }
 /**
  * @param AttributeFactoryInterface $productAttributeFactory
  * @param RepositoryInterface $localeRepository
  * @param array $attributeTypes
  */
 public function __construct(AttributeFactoryInterface $productAttributeFactory, RepositoryInterface $localeRepository, array $attributeTypes)
 {
     $this->productAttributeFactory = $productAttributeFactory;
     $this->localeRepository = $localeRepository;
     $this->faker = \Faker\Factory::create();
     $this->optionsResolver = (new OptionsResolver())->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('type', function (Options $options) use($attributeTypes) {
         return $this->faker->randomElement(array_keys($attributeTypes));
     })->setAllowedValues('type', array_keys($attributeTypes));
 }
예제 #5
0
 /**
  * @param Player|null $not
  * @return Player
  */
 private function randomPlayer(Player $not = null)
 {
     while (true) {
         $random = $this->faker->randomElement($this->players);
         if ($not === null) {
             return $random;
         }
         if ($random->getName() !== $not->getName()) {
             return $random;
         }
     }
     return null;
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function load(array $options)
 {
     $options = $this->optionsResolver->resolve($options);
     $this->taxonFixture->load(['custom' => [['code' => 'category', 'name' => 'Category', 'children' => [['code' => 't_shirts', 'name' => 'T-Shirts', 'children' => [['code' => 'mens_t_shirts', 'name' => 'Men'], ['code' => 'womens_t_shirts', 'name' => 'Women']]]]]]]);
     $this->productAttributeFixture->load(['custom' => [['name' => 'T-Shirt brand', 'code' => 't_shirt_brand', 'type' => TextAttributeType::TYPE], ['name' => 'T-Shirt collection', 'code' => 't_shirt_collection', 'type' => TextAttributeType::TYPE], ['name' => 'T-Shirt material', 'code' => 't_shirt_material', 'type' => TextAttributeType::TYPE]]]);
     $this->productOptionFixture->load(['custom' => [['name' => 'T-Shirt color', 'code' => 't_shirt_color', 'values' => ['t_shirt_color_red' => 'Red', 't_shirt_color_black' => 'Black', 't_shirt_color_white' => 'White']], ['name' => 'T-Shirt size', 'code' => 't_shirt_size', 'values' => ['t_shirt_size_s' => 'S', 't_shirt_size_m' => 'M', 't_shirt_size_l' => 'L', 't_shirt_size_xl' => 'XL', 't_shirt_size_xxl' => 'XXL']]]]);
     $products = [];
     for ($i = 0; $i < $options['amount']; ++$i) {
         $categoryTaxonCode = $this->faker->randomElement(['mens_t_shirts', 'womens_t_shirts']);
         $products[] = ['name' => sprintf('T-Shirt "%s"', $this->faker->word), 'code' => $this->faker->uuid, 'main_taxon' => $categoryTaxonCode, 'taxons' => [$categoryTaxonCode], 'product_attributes' => ['t_shirt_brand' => $this->faker->randomElement(['Nike', 'Adidas', 'JKM-476 Streetwear', 'Potato', 'Centipede Wear']), 't_shirt_collection' => sprintf('Sylius %s %s', $this->faker->randomElement(['Summer', 'Winter', 'Spring', 'Autumn']), mt_rand(1995, 2012)), 't_shirt_material' => $this->faker->randomElement(['Centipede', 'Wool', 'Centipede 10% / Wool 90%', 'Potato 100%'])], 'product_options' => ['t_shirt_color', 't_shirt_size'], 'images' => ['main' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 't-shirts.jpg'), 'thumbnail' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 't-shirts.jpg')]];
     }
     $this->productFixture->load(['custom' => $products]);
 }
 public function test(TestCase $test, Generator $faker)
 {
     $value = $faker->randomElement(array_filter(array_keys($this->items)), function ($value) {
         return !!$value;
     });
     return $test->select($value, $this->name);
 }
예제 #8
0
 /**
  * @param RepositoryContainer $orm
  * @param Subject[] $subjects
  * @param Video[] $videos
  */
 protected function createSchemasAndBlocks($orm, $subjects, $videos)
 {
     $author = $orm->users->getById(1);
     foreach ($subjects as $subject) {
         for ($i = 0; $i < 3; ++$i) {
             $schema = new Schema();
             $schema->name = $this->faker->name;
             $schema->subject = $subject;
             $schema->author = $author;
             $orm->schemas->attach($schema);
             for ($k = 0; $k < 10; ++$k) {
                 $block = new Block();
                 $block->name = $this->faker->name;
                 $block->author = $author;
                 $orm->blocks->attach($block);
                 $bridge = new BlockSchemaBridge();
                 $bridge->position = $k;
                 $bridge->block = $block;
                 $bridge->schema = $schema;
                 $orm->blockSchemaBridges->attach($bridge);
                 for ($l = 0; $l < 7; ++$l) {
                     $bridge = new ContentBlockBridge();
                     $bridge->block = $block;
                     $bridge->content = $this->faker->randomElement($videos);
                     $bridge->position = $l;
                     $orm->contentBlockBridges->attach($bridge);
                 }
             }
         }
     }
 }
예제 #9
0
 /**
  * @param OrderInterface $order
  */
 private function selectPayment(OrderInterface $order)
 {
     $paymentMethod = $this->faker->randomElement($this->paymentMethodRepository->findEnabledForChannel($order->getChannel()));
     Assert::notNull($paymentMethod, 'Payment method should not be null.');
     foreach ($order->getPayments() as $payment) {
         $payment->setMethod($paymentMethod);
     }
     $this->applyCheckoutStateTransition($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
 }
예제 #10
0
 /**
  * @param OrderInterface $order
  */
 private function selectPayment(OrderInterface $order)
 {
     $paymentMethod = $this->faker->randomElement($order->getChannel()->getPaymentMethods()->toArray());
     Assert::notNull($paymentMethod);
     foreach ($order->getPayments() as $payment) {
         $payment->setMethod($paymentMethod);
     }
     $this->applyCheckoutStateTransition($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
 }
 /**
  * Generate value content based on backend type
  *
  * @param AbstractAttribute $attribute
  * @param string            $key
  *
  * @return string
  */
 protected function generateValueData(AbstractAttribute $attribute, $key)
 {
     $data = "";
     if (isset($this->forcedValues[$attribute->getCode()])) {
         return $this->forcedValues[$attribute->getCode()];
     }
     switch ($attribute->getBackendType()) {
         case "varchar":
             $validationRule = $attribute->getValidationRule();
             switch ($validationRule) {
                 case 'url':
                     $data = $this->faker->url();
                     break;
                 default:
                     $data = $this->faker->sentence();
                     break;
             }
             break;
         case "text":
             $data = $this->faker->sentence();
             break;
         case "date":
             $data = $this->faker->dateTimeBetween($attribute->getDateMin(), $attribute->getDateMax());
             $data = $data->format('Y-m-d');
             break;
         case "metric":
         case "decimal":
         case "prices":
             if ($attribute->getBackendType() && preg_match('/-' . self::METRIC_UNIT . '$/', $key)) {
                 $data = $attribute->getDefaultMetricUnit();
             } else {
                 $min = $attribute->getNumberMin() != null ? $attribute->getNumberMin() : self::DEFAULT_NUMBER_MIN;
                 $max = $attribute->getNumberMax() != null ? $attribute->getNumberMax() : self::DEFAULT_NUMBER_MAX;
                 $decimals = $attribute->isDecimalsAllowed() ? self::DEFAULT_NB_DECIMALS : 0;
                 $data = $this->faker->randomFloat($decimals, $min, $max);
             }
             break;
         case "boolean":
             $data = $this->faker->boolean() ? "1" : "0";
             break;
         case "option":
         case "options":
             $options = [];
             foreach ($attribute->getOptions() as $option) {
                 $options[] = $option;
             }
             $option = $this->faker->randomElement($options);
             if (is_object($option)) {
                 $data = $option->getCode();
             }
             break;
         default:
             $data = '';
             break;
     }
     return (string) $data;
 }
예제 #12
0
 /**
  * @param ChannelFactoryInterface $channelFactory
  * @param RepositoryInterface $localeRepository
  * @param RepositoryInterface $currencyRepository
  * @param RepositoryInterface $paymentMethodRepository
  * @param RepositoryInterface $shippingMethodRepository
  */
 public function __construct(ChannelFactoryInterface $channelFactory, RepositoryInterface $localeRepository, RepositoryInterface $currencyRepository, RepositoryInterface $paymentMethodRepository, RepositoryInterface $shippingMethodRepository)
 {
     $this->channelFactory = $channelFactory;
     $this->faker = \Faker\Factory::create();
     $this->optionsResolver = (new OptionsResolver())->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('hostname', function (Options $options) {
         return $options['code'] . '.localhost';
     })->setDefault('color', function (Options $options) {
         return $this->faker->colorName;
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('tax_calculation_strategy', 'order_items_based')->setAllowedTypes('tax_calculation_strategy', 'string')->setDefault('default_locale', function (Options $options) {
         return $this->faker->randomElement($options['locales']);
     })->setAllowedTypes('default_locale', LocaleInterface::class)->setNormalizer('default_locale', LazyOption::findOneBy($localeRepository, 'code'))->setDefault('locales', LazyOption::all($localeRepository))->setAllowedTypes('locales', 'array')->setNormalizer('locales', LazyOption::findBy($localeRepository, 'code'))->setDefault('default_currency', function (Options $options) {
         return $this->faker->randomElement($options['currencies']);
     })->setAllowedTypes('default_currency', CurrencyInterface::class)->setNormalizer('default_currency', LazyOption::findOneBy($currencyRepository, 'code'))->setDefault('currencies', LazyOption::all($currencyRepository))->setAllowedTypes('currencies', 'array')->setNormalizer('currencies', LazyOption::findBy($currencyRepository, 'code'))->setDefault('payment_methods', LazyOption::all($paymentMethodRepository))->setAllowedTypes('payment_methods', 'array')->setNormalizer('payment_methods', LazyOption::findBy($paymentMethodRepository, 'code'))->setDefault('shipping_methods', LazyOption::all($shippingMethodRepository))->setAllowedTypes('shipping_methods', 'array')->setNormalizer('shipping_methods', LazyOption::findBy($shippingMethodRepository, 'code'))->setDefault('theme_name', null);
 }
예제 #13
0
 /**
  * @return AddressInterface
  */
 protected function createAddress()
 {
     /* @var $address AddressInterface */
     $address = $this->getAddressRepository()->createNew();
     $address->setFirstname($this->faker->firstName);
     $address->setLastname($this->faker->lastName);
     $address->setCity($this->faker->city);
     $address->setStreet($this->faker->streetAddress);
     $address->setPostcode($this->faker->postcode);
     do {
         $isoName = $this->faker->countryCode;
     } while ('UK' === $isoName);
     $country = $this->getReference('Sylius.Country.' . $isoName);
     $province = $country->hasProvinces() ? $this->faker->randomElement($country->getProvinces()->toArray()) : null;
     $address->setCountry($country);
     $address->setProvince($province);
     return $address;
 }
예제 #14
0
 /**
  * @return AddressInterface
  */
 protected function createAddress()
 {
     /* @var $address AddressInterface */
     $address = $this->getAddressFactory()->createNew();
     $address->setFirstname($this->faker->firstName);
     $address->setLastname($this->faker->lastName);
     $address->setCity($this->faker->city);
     $address->setStreet($this->faker->streetAddress);
     $address->setPostcode($this->faker->postcode);
     /** @var CountryInterface $country */
     $countries = Intl::getRegionBundle()->getCountryNames($this->defaultLocale);
     $isoName = array_rand($countries);
     $country = $this->getReference("Sylius.Country." . $isoName);
     $province = $country->hasProvinces() ? $this->faker->randomElement($country->getProvinces()->toArray()) : null;
     $address->setCountry($country);
     $address->setProvince($province);
     return $address;
 }
예제 #15
0
 /**
  * {@inheritdoc}
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefault('name', function (Options $options) {
         return $this->faker->words(3, true);
     })->setDefault('code', function (Options $options) {
         return StringInflector::nameToCode($options['name']);
     })->setDefault('hostname', function (Options $options) {
         return $options['code'] . '.localhost';
     })->setDefault('color', function (Options $options) {
         return $this->faker->colorName;
     })->setDefault('enabled', function (Options $options) {
         return $this->faker->boolean(90);
     })->setAllowedTypes('enabled', 'bool')->setDefault('tax_calculation_strategy', 'order_items_based')->setAllowedTypes('tax_calculation_strategy', 'string')->setDefault('default_locale', function (Options $options) {
         return $this->faker->randomElement($options['locales']);
     })->setAllowedTypes('default_locale', ['string', LocaleInterface::class])->setNormalizer('default_locale', LazyOption::findOneBy($this->localeRepository, 'code'))->setDefault('locales', LazyOption::all($this->localeRepository))->setAllowedTypes('locales', 'array')->setNormalizer('locales', LazyOption::findBy($this->localeRepository, 'code'))->setDefault('base_currency', function (Options $options) {
         return $this->faker->randomElement($options['currencies']);
     })->setAllowedTypes('base_currency', ['string', CurrencyInterface::class])->setNormalizer('base_currency', LazyOption::findOneBy($this->currencyRepository, 'code'))->setDefault('currencies', LazyOption::all($this->currencyRepository))->setAllowedTypes('currencies', 'array')->setNormalizer('currencies', LazyOption::findBy($this->currencyRepository, 'code'))->setDefault('theme_name', null);
 }
예제 #16
0
 /**
  * {@inheritdoc}
  */
 public function load(array $options)
 {
     $options = $this->optionsResolver->resolve($options);
     $taxons = [];
     if (null === $this->taxonRepository->findOneBy(['code' => 'CATEGORY'])) {
         $taxons[] = ['name' => 'Category', 'code' => 'CATEGORY', 'parent' => null];
     }
     if (null === $this->taxonRepository->findOneBy(['code' => 'BRAND'])) {
         $taxons[] = ['name' => 'Brand', 'code' => 'BRAND', 'parent' => null];
     }
     $this->taxonFixture->load(['custom' => array_merge($taxons, [['name' => 'Stickers', 'code' => 'STICKERS', 'parent' => 'CATEGORY'], ['name' => 'StickyPicky', 'code' => 'STICKYPICKY', 'parent' => 'BRAND']])]);
     $this->productAttributeFixture->load(['custom' => [['name' => 'Sticker paper', 'code' => 'STICKER-PAPER', 'type' => TextAttributeType::TYPE], ['name' => 'Sticker resolution', 'code' => 'STICKER-RESOLUTION', 'type' => TextAttributeType::TYPE]]]);
     $this->productOptionFixture->load(['custom' => [['name' => 'Sticker SIZE', 'code' => 'STICKER-SIZE', 'values' => ['STICKER-SIZE-3' => '3"', 'STICKER-SIZE-5' => '5"', 'STICKER-SIZE-7' => '7"']]]]);
     $this->productArchetypeFixture->load(['custom' => [['name' => 'Sticker', 'code' => 'STICKER', 'product_attributes' => ['STICKER-PAPER', 'STICKER-RESOLUTION'], 'product_options' => ['STICKER-SIZE']]]]);
     $products = [];
     for ($i = 0; $i < $options['amount']; ++$i) {
         $products[] = ['name' => sprintf('Sticker "%s"', $this->faker->word), 'code' => $this->faker->uuid, 'main_taxon' => 'STICKERS', 'product_archetype' => 'STICKER', 'taxons' => ['STICKERS', 'STICKYPICKY'], 'product_attributes' => ['STICKER-PAPER' => sprintf('Paper from tree %s', $this->faker->randomElement(['Wung', 'Tanajno', 'Lemon-San', 'Me-Gusta'])), 'STICKER-RESOLUTION' => $this->faker->randomElement(['JKM XD', '476DPI', 'FULL HD', '200DPI'])], 'images' => [sprintf('%s/../Resources/fixtures/%s', __DIR__, 'stickers.jpg')]];
     }
     $this->productFixture->load(['custom' => $products]);
 }
예제 #17
0
 /**
  * {@inheritdoc}
  */
 public function load(array $options)
 {
     $options = $this->optionsResolver->resolve($options);
     $taxons = [];
     if (null === $this->taxonRepository->findOneBy(['code' => 'CATEGORY'])) {
         $taxons[] = ['name' => 'Category', 'code' => 'CATEGORY', 'parent' => null];
     }
     if (null === $this->taxonRepository->findOneBy(['code' => 'BRAND'])) {
         $taxons[] = ['name' => 'Brand', 'code' => 'BRAND', 'parent' => null];
     }
     $this->taxonFixture->load(['custom' => array_merge($taxons, [['name' => 'T-Shirts', 'code' => 'TSHIRTS', 'parent' => 'CATEGORY'], ['name' => 'Super Tees', 'code' => 'SUPER-TEES', 'parent' => 'BRAND']])]);
     $this->productAttributeFixture->load(['custom' => [['name' => 'T-Shirt brand', 'code' => 'TSHIRT-BRAND', 'type' => TextAttributeType::TYPE], ['name' => 'T-Shirt collection', 'code' => 'TSHIRT-COLLECTION', 'type' => TextAttributeType::TYPE], ['name' => 'T-Shirt material', 'code' => 'TSHIRT-MATERIAL', 'type' => TextAttributeType::TYPE]]]);
     $this->productOptionFixture->load(['custom' => [['name' => 'T-Shirt color', 'code' => 'TSHIRT-COLOR', 'values' => ['TSHIRT-COLOR-RED' => 'Red', 'TSHIRT-COLOR-BLACK' => 'Black', 'TSHIRT-COLOR-WHITE' => 'White']], ['name' => 'T-Shirt size', 'code' => 'TSHIRT-SIZE', 'values' => ['TSHIRT-SIZE-S' => 'S', 'TSHIRT-SIZE-M' => 'M', 'TSHIRT-SIZE-L' => 'L', 'TSHIRT-SIZE-XL' => 'XL', 'TSHIRT-SIZE-XXL' => 'XXL']]]]);
     $this->productArchetypeFixture->load(['custom' => [['name' => 'T-Shirt', 'code' => 'TSHIRT', 'product_attributes' => ['TSHIRT-BRAND', 'TSHIRT-COLLECTION', 'TSHIRT-MATERIAL'], 'product_options' => ['TSHIRT-COLOR', 'TSHIRT-SIZE']]]]);
     $products = [];
     for ($i = 0; $i < $options['amount']; ++$i) {
         $products[] = ['name' => sprintf('T-Shirt "%s"', $this->faker->word), 'code' => $this->faker->uuid, 'main_taxon' => 'TSHIRTS', 'product_archetype' => 'TSHIRT', 'taxons' => ['TSHIRTS', 'SUPER-TEES'], 'product_attributes' => ['TSHIRT-BRAND' => $this->faker->randomElement(['Nike', 'Adidas', 'JKM-476 Streetwear', 'Potato', 'Centipede Wear']), 'TSHIRT-COLLECTION' => sprintf('Sylius %s %s', $this->faker->randomElement(['Summer', 'Winter', 'Spring', 'Autumn']), mt_rand(1995, 2012)), 'TSHIRT-MATERIAL' => $this->faker->randomElement(['Centipede', 'Wool', 'Centipede 10% / Wool 90%', 'Potato 100%'])], 'images' => [sprintf('%s/../Resources/fixtures/%s', __DIR__, 't-shirts.jpg')]];
     }
     $this->productFixture->load(['custom' => $products]);
 }
예제 #18
0
 /**
  * {@inheritdoc}
  */
 public function load(array $options)
 {
     $options = $this->optionsResolver->resolve($options);
     $taxons = [];
     if (null === $this->taxonRepository->findOneBy(['code' => 'CATEGORY'])) {
         $taxons[] = ['name' => 'Category', 'code' => 'CATEGORY', 'parent' => null];
     }
     if (null === $this->taxonRepository->findOneBy(['code' => 'BRAND'])) {
         $taxons[] = ['name' => 'Brand', 'code' => 'BRAND', 'parent' => null];
     }
     $this->taxonFixture->load(['custom' => array_merge($taxons, [['name' => 'Mugs', 'code' => 'MUGS', 'parent' => 'CATEGORY'], ['name' => 'Mugland', 'code' => 'MUGLAND', 'parent' => 'BRAND']])]);
     $this->productAttributeFixture->load(['custom' => [['name' => 'Mug material', 'code' => 'MUG-MATERIAL', 'type' => TextAttributeType::TYPE]]]);
     $this->productOptionFixture->load(['custom' => [['name' => 'Mug type', 'code' => 'MUG-TYPE', 'values' => ['MUG-TYPE-MEDIUM' => 'Medium mug', 'MUG-TYPE-DOUBLE' => 'Double mug', 'MUG-TYPE-MONSTER' => 'Monster mug']]]]);
     $this->productArchetypeFixture->load(['custom' => [['name' => 'Mug', 'code' => 'MUG', 'product_attributes' => ['MUG-MATERIAL'], 'product_options' => ['MUG-TYPE']]]]);
     $products = [];
     for ($i = 0; $i < $options['amount']; ++$i) {
         $products[] = ['name' => sprintf('Mug "%s"', $this->faker->word), 'code' => $this->faker->uuid, 'main_taxon' => 'MUGS', 'product_archetype' => 'MUG', 'taxons' => ['MUGS', 'MUGLAND'], 'product_attributes' => ['MUG-MATERIAL' => $this->faker->randomElement(['Invisible porcelain', 'Banana skin', 'Porcelain', 'Centipede'])], 'images' => [sprintf('%s/../Resources/fixtures/%s', __DIR__, 'mugs.jpg')]];
     }
     $this->productFixture->load(['custom' => $products]);
 }
예제 #19
0
 public function getDummyData(Generator $faker)
 {
     return ['status' => $faker->randomElement(['open', 'delete', 'block', 'close']), 'ore_id' => $faker->numberBetween(0, 500), 'date_in' => $faker->date('Y-m-d', 'now'), 'type' => $faker->randomElement(['letter', 'suitcase', 'other']), 'sender_ref' => $faker->phoneNumber, 'sender_id' => rand(1, 10), 'sender_details' => $faker->company, 'issue' => $faker->paragraph(2), 'user_id' => $this->getRandom('User')->id, 'dependence_id' => rand(1, 16)];
 }
예제 #20
0
 public function getDummyData(Generator $faker, array $customValues = [])
 {
     $firs_name = $faker->firstName;
     $last_name = $faker->lastName;
     return ['identification' => $faker->unique()->numberBetween(5000000, 39999999), 'first_name' => $firs_name, 'last_name' => $last_name, 'full_name' => $firs_name . ' ' . $last_name, 'avatar' => 'vendor/AdminTheme/images/avatar/default.png', 'type' => $faker->randomElement(['moderator', 'user']), 'email' => $faker->unique()->email, 'password' => '123456'];
 }
예제 #21
0
 /**
  * @param \Faker\Generator $generator
  * @return array
  */
 public function guessModifiers(\Faker\Generator $generator)
 {
     $modifiers = array();
     $class = $this->class;
     $peerClass = $class::PEER;
     $tableMap = $peerClass::getTableMap();
     foreach ($tableMap->getBehaviors() as $name => $params) {
         switch ($name) {
             case 'nested_set':
                 $modifiers['nested_set'] = function ($obj, $inserted) use($class, $generator) {
                     if (isset($inserted[$class])) {
                         $queryClass = $class . 'Query';
                         $parent = $queryClass::create()->findPk($generator->randomElement($inserted[$class]));
                         $obj->insertAsLastChildOf($parent);
                     } else {
                         $obj->makeRoot();
                     }
                 };
                 break;
             case 'sortable':
                 $modifiers['sortable'] = function ($obj, $inserted) use($class) {
                     $maxRank = isset($inserted[$class]) ? count($inserted[$class]) : 0;
                     $obj->insertAtRank(mt_rand(1, $maxRank + 1));
                 };
                 break;
         }
     }
     return $modifiers;
 }
예제 #22
0
 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['name' => $faker->firstName, 'email' => $faker->email, 'password' => 'secret', 'role' => $faker->randomElement(['admin', 'member', 'member']), 'provider_id' => null, 'active' => $faker->randomElement([1, 0, 1, 1]), 'confirmation_token' => null];
 }
예제 #23
0
 public function getDummyData(Generator $faker)
 {
     return ["title" => $faker->sentence(), "status" => $faker->randomElement(["open", "closed"]), "user_id" => $this->getRandomId("User")];
 }
예제 #24
0
 public function getDummyData(Generator $faker, array $custom = [])
 {
     return ['title' => $faker->title, 'favicon_path' => $faker->imageUrl(), 'url' => $faker->url, 'visibility' => $faker->randomElement([1, 1, 1, 0]), 'user_id' => $this->random('User')->id];
 }
예제 #25
0
 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['title' => $faker->sentence(), 'status' => $faker->randomElement(['open', 'open', 'closed']), 'user_id' => $this->getRandom('User')->id];
 }
 public function getDummyData(Generator $faker, array $valoresPersonalizados = array())
 {
     return ['titulo' => $faker->sentence(), 'estado' => $faker->randomElement(['abierto', 'cerrado']), 'user_id' => $this->getRandom('User')->id];
 }
 /**
  * Get a random item from a repo
  *
  * @param Faker\Generator  $faker
  * @param ObjectRepository $repo
  * @param array            &$items
  *
  * @return mixed
  */
 protected function getRandomItem(Faker\Generator $faker, ObjectRepository $repo, array &$items = null)
 {
     if (null === $items) {
         $items = [];
         $loadedItems = $repo->findAll();
         foreach ($loadedItems as $item) {
             $items[$item->getCode()] = $item;
         }
     }
     return $faker->randomElement($items);
 }
예제 #28
0
 public function getDummyData(\Faker\Generator $faker, array $customValues = array())
 {
     return ['name' => $faker->sentence(2), 'type' => $faker->randomElement(['DIG', 'DIG', 'CRE']), 'description' => $faker->paragraph(3), 'objectives' => $faker->paragraph(6), 'status' => $faker->randomElement([false, false, true]), 'customer_id' => $this->getRandom('Customer')->id];
 }
예제 #29
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];
 }
 /**
  * Get a random attribute group code
  *
  * @return string
  */
 protected function getRandomAttributeGroupCode()
 {
     return $this->faker->randomElement($this->getAttributeGroupCodes());
 }