/** * @param ProductAttributeInterface $productAttribute * * @return mixed */ private function getRandomValueForProductAttribute(ProductAttributeInterface $productAttribute) { switch ($productAttribute->getStorageType()) { case ProductAttributeValueInterface::STORAGE_BOOLEAN: return $this->faker->boolean; case ProductAttributeValueInterface::STORAGE_INTEGER: return $this->faker->numberBetween(0, 10000); case ProductAttributeValueInterface::STORAGE_FLOAT: return $this->faker->randomFloat(4, 0, 10000); case ProductAttributeValueInterface::STORAGE_TEXT: return $this->faker->sentence; case ProductAttributeValueInterface::STORAGE_DATE: case ProductAttributeValueInterface::STORAGE_DATETIME: return $this->faker->dateTimeThisCentury; default: throw new \BadMethodCallException(); } }
public function createExpense(AcceptanceTester $I) { $I->wantTo('Create an expense'); $vendorName = $this->faker->name; $clientEmail = $this->faker->safeEmail; $amount = $this->faker->numberBetween(10, 20); // create vendor $I->amOnPage('/vendors/create'); $I->fillField(['name' => 'name'], $vendorName); $I->click('Save'); $I->see($vendorName); $vendorId = $I->grabFromDatabase('vendors', 'id', ['name' => $vendorName]); // create client $I->amOnPage('/clients/create'); $I->fillField(['name' => 'contacts[0][email]'], $clientEmail); $I->click('Save'); $I->see($clientEmail); // create expense $I->amOnPage('/expenses/create'); $I->fillField(['name' => 'amount'], $amount); $I->selectDropdown($I, $vendorName, '.vendor-select .dropdown-toggle'); $I->selectDropdown($I, $clientEmail, '.client-select .dropdown-toggle'); $I->click('Save'); $I->seeInDatabase('expenses', ['vendor_id' => $vendorId]); // invoice expense $I->executeJS('submitAction(\'invoice\')'); $I->click('Save'); $I->wait(1); $I->see($clientEmail); $I->see($amount); }
/** * Run the database seeds. * * @return void */ public function run() { $users = $this->userRepository->findAll(); $tags = Tag::get(['id'])->pluck('id')->toArray(); for ($i = 0; $i < 20; $i++) { $user = $users->random(); $count = mt_rand(1, 2); $post = Post::instantiate($user, ['title' => $user->name . '的好贴'], $this->faker->randomElements($tags, $count)); Comment::instantiate($user, $post, ['body' => $this->faker->text, 'views' => $this->faker->numberBetween(0, 1000)]); } Post::inRandomOrder()->first()->makeSticky(); }
/** * {@inheritdoc} */ public function load(array $options) { $options = $this->optionsResolver->resolve($options); $this->taxonFixture->load(['custom' => [['code' => 'category', 'name' => 'Category', 'children' => [['code' => 'books', 'name' => 'Books']]]]]); $this->productAttributeFixture->load(['custom' => [['name' => 'Book author', 'code' => 'book_author', 'type' => TextAttributeType::TYPE], ['name' => 'Book ISBN', 'code' => 'book_isbn', 'type' => TextAttributeType::TYPE], ['name' => 'Book pages', 'code' => 'book_pages', 'type' => IntegerAttributeType::TYPE]]]); $products = []; $productsNames = $this->getUniqueNames($options['amount']); for ($i = 0; $i < $options['amount']; ++$i) { $authorName = $this->faker->name; $products[] = ['name' => sprintf('Book "%s" by %s', $productsNames[$i], $authorName), 'code' => $this->faker->uuid, 'main_taxon' => 'books', 'taxons' => ['books'], 'product_attributes' => ['book_author' => $authorName, 'book_isbn' => $this->faker->isbn13, 'book_pages' => $this->faker->numberBetween(42, 1024)], 'images' => ['main' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 'books.jpg'), 'thumbnail' => sprintf('%s/../Resources/fixtures/%s', __DIR__, 'books.jpg')]]; } $this->productFixture->load(['custom' => $products]); }
/** * @param PDO $db * @return void */ public function seed(PDO $db) { $db->exec('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER, gender TEXT)'); $stmt = $db->prepare('INSERT INTO users (name, age, gender) VALUES (:name, :age, :gender)'); $names = []; for ($i = 0; $i < $this->faker->numberBetween(5, 15); $i++) { $name = $this->faker->name; $age = rand(18, 90); $gender = rand(0, 100) % 2 ? 'male' : 'female'; $stmt->execute([':name' => $name, ':age' => $age, ':gender' => $gender]); $id = $db->lastInsertId(); $names[$id] = $name; } $randomId = array_rand($names); $this->randomRecord = ['id' => $randomId, 'name' => $names[$randomId]]; }
/** * {@inheritdoc} */ public function generate(array $config, $outputDir, ProgressHelper $progress, array $options = null) { $this->attributeGroupsFile = $outputDir . '/' . static::ATTRIBUTE_GROUP_FILENAME; $count = (int) $config['count']; $this->faker = Faker\Factory::create(); $this->attributeGroups = []; for ($i = 0; $i < $count; $i++) { $attributeGroup = []; $attributeGroup['sortOrder'] = $this->faker->numberBetween(1, 10); $attributeGroup['labels'] = $this->getLocalizedRandomLabels(); $this->attributeGroups[self::ATTR_GROUP_CODE_PREFIX . $i] = $attributeGroup; $progress->advance(); } $this->writeYamlFile(['attribute_groups' => $this->attributeGroups], $this->attributeGroupsFile); return $this; }
public function generate($databaseName, $size, $batchSize = 1000) { $this->getConnection()->query(sprintf('USE %s', $databaseName)); $this->reset(); $scopes = array_keys($this->scopeFaker); $numberOfScopes = count($scopes); $currentBatch = 0; $createdRecords = 0; while ($size > $createdRecords) { if ($currentBatch >= $batchSize) { $this->flush(); $currentBatch = 0; } $createdRecords++; $currentBatch++; $code = $this->faker->uuid; $this->batch['entity'][$code] = ['code' => $code]; $this->generateAttributes($this->faker, $this->attribute->getAll(), $code, 0); if ($this->faker->boolean(66)) { $currentScopes = $this->faker->randomElements($scopes, $this->faker->numberBetween(1, $numberOfScopes)); foreach ($currentScopes as $scopeCode) { $this->generateAttributes($this->scopeFaker[$scopeCode], $this->attribute->getAllScopeAware(), $code, $this->scope->getId($scopeCode)); } } } if ($currentBatch > 0) { $this->flush(); } return $this; }
/** * {@inheritdoc} */ protected function configureOptions(OptionsResolver $resolver) { $resolver->setDefault('title', function (Options $options) { return $this->faker->words(3, true); })->setDefault('rating', function (Options $options) { return $this->faker->numberBetween(1, 5); })->setDefault('comment', function (Options $options) { return $this->faker->sentences(3, true); })->setDefault('author', LazyOption::randomOne($this->customerRepository))->setNormalizer('author', LazyOption::findOneBy($this->customerRepository, 'email'))->setDefault('product', LazyOption::randomOne($this->productRepository))->setNormalizer('product', LazyOption::findOneBy($this->productRepository, 'code'))->setDefault('status', null); }
/** * {@inheritdoc} */ public function generate(array $config, $outputDir, ProgressHelper $progress, array $options = null) { $countPerAttribute = (int) $config['count_per_attribute']; $this->delimiter = $config['delimiter']; $this->attributeOptionsFile = $outputDir . '/' . static::ATTRIBUTE_OPTIONS_FILENAME; foreach ($this->getSelectAttributes() as $attribute) { for ($i = 0; $i < $countPerAttribute; $i++) { $attributeOption = []; $attributeOption['attribute'] = $attribute->getCode(); $attributeOption['code'] = static::ATTRIBUTE_OPTION_CODE_PREFIX . $attribute->getCode() . $i; $attributeOption['sort_order'] = $this->faker->numberBetween(1, $countPerAttribute); foreach ($this->getLocalizedRandomLabels() as $localeCode => $label) { $attributeOption['label-' . $localeCode] = $label; } $this->attributeOptions[$attributeOption['code']] = $attributeOption; } } $headers = $this->getAllKeys($this->attributeOptions); $this->writeCsvFile($this->attributeOptions, $headers); return $this; }
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()); } } }
/** * {@inheritdoc} */ public function load(array $options) { $options = $this->optionsResolver->resolve($options); $this->taxonFixture->load(['custom' => [['code' => 'category', 'name' => 'Category', 'children' => [['code' => 'books', 'name' => 'Books']]]]]); $this->productAttributeFixture->load(['custom' => [['name' => 'Book author', 'code' => 'BOOK-AUTHOR', 'type' => TextAttributeType::TYPE], ['name' => 'Book ISBN', 'code' => 'BOOK-ISBN', 'type' => TextAttributeType::TYPE], ['name' => 'Book pages', 'code' => 'BOOK-PAGES', 'type' => IntegerAttributeType::TYPE]]]); $this->productArchetypeFixture->load(['custom' => [['name' => 'Book', 'code' => 'BOOK', 'product_attributes' => ['BOOK-AUTHOR', 'BOOK-ISBN', 'BOOK-PAGES'], 'product_options' => []]]]); $products = []; for ($i = 0; $i < $options['amount']; ++$i) { $name = $this->faker->name; $products[] = ['name' => sprintf('Book "%s" by %s', $this->faker->word, $name), 'code' => $this->faker->uuid, 'main_taxon' => 'books', 'product_archetype' => 'BOOK', 'taxons' => ['books'], 'product_attributes' => ['BOOK-AUTHOR' => $name, 'BOOK-ISBN' => $this->faker->isbn13, 'BOOK-PAGES' => $this->faker->numberBetween(42, 1024)], 'images' => [sprintf('%s/../Resources/fixtures/%s', __DIR__, 'books.jpg')]]; } $this->productFixture->load(['custom' => $products]); }
public function createQuote(AcceptanceTester $I) { $clientEmail = $this->faker->safeEmail; $productKey = $this->faker->text(10); $I->wantTo('create a quote'); // create client $I->amOnPage('/clients/create'); $I->fillField(['name' => 'contacts[0][email]'], $clientEmail); $I->click('Save'); $I->see($clientEmail); // create product $I->amOnPage('/products/create'); $I->fillField(['name' => 'product_key'], $productKey); $I->fillField(['name' => 'notes'], $this->faker->text(80)); $I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20)); $I->click('Save'); $I->wait(1); //$I->see($productKey); // create quote $I->amOnPage('/quotes/create'); $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); $I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey); $I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable'); $I->click('Save'); $I->see($clientEmail); // enter payment $clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]); $invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId]); $invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]); $clientSession = $I->haveFriend('client'); $clientSession->does(function (AcceptanceTester $I) use($invitationKey) { $I->amOnPage('/view/' . $invitationKey); $I->click('Approve'); $I->see('This quote is approved'); }); }
private function distributeRubrics() { print_r("Distribute rubrics for company..."); $companies = Company::find()->all(); $rubrics = Rubric::findRecursive(array(), 'down', true); $rubrics_ids = ArrayHelper::getColumn($rubrics, 'id'); $rubrics_ids_count = count($rubrics_ids); foreach ($companies as $company) { $this->faker->unique(true); $rubric_for_company_count = $this->faker->numberBetween(self::MIN_RUBRIC_FOR_COMPANY, self::MAX_RUBRIC_FOR_COMPANY); for ($i = 1; $i <= $rubric_for_company_count; $i++) { $company_rubric = new CompanyRubric(); $company_rubric->company_id = $company->id; $company_rubric->rubric_id = $rubrics_ids[$this->faker->unique()->numberBetween(0, $rubrics_ids_count - 1)]; $company_rubric->save(); } } print_r("DONE" . PHP_EOL); }
/** * {@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' => 'Books', 'code' => 'BOOKS', 'parent' => 'CATEGORY'], ['name' => 'BookMania', 'code' => 'BOOKMANIA', 'parent' => 'BRAND']])]); $this->productAttributeFixture->load(['custom' => [['name' => 'Book author', 'code' => 'BOOK-AUTHOR', 'type' => TextAttributeType::TYPE], ['name' => 'Book ISBN', 'code' => 'BOOK-ISBN', 'type' => TextAttributeType::TYPE], ['name' => 'Book pages', 'code' => 'BOOK-PAGES', 'type' => IntegerAttributeType::TYPE]]]); $this->productArchetypeFixture->load(['custom' => [['name' => 'Book', 'code' => 'BOOK', 'product_attributes' => ['BOOK-AUTHOR', 'BOOK-ISBN', 'BOOK-PAGES'], 'product_options' => []]]]); $products = []; for ($i = 0; $i < $options['amount']; ++$i) { $name = $this->faker->name; $products[] = ['name' => sprintf('Book "%s" by %s', $this->faker->word, $name), 'code' => $this->faker->uuid, 'main_taxon' => 'BOOKS', 'product_archetype' => 'BOOK', 'taxons' => ['BOOKS', 'BOOKMANIA'], 'product_attributes' => ['BOOK-AUTHOR' => $name, 'BOOK-ISBN' => $this->faker->isbn13, 'BOOK-PAGES' => $this->faker->numberBetween(42, 1024)], 'images' => [sprintf('%s/../Resources/fixtures/%s', __DIR__, 'books.jpg')]]; } $this->productFixture->load(['custom' => $products]); }
/** * Get a random number, float or integer * * @param stdClass $schema * @param bool $float * @return float|int * @throws InvalidArgumentException */ private function getRandomNumber(stdClass $schema, $float = false) { $multipleOf = $this->provider->getProperty($schema, 'multipleOf', $this->config->getMultipleOf()); $maximum = $this->provider->getProperty($schema, 'maximum', $this->config->getMaximum()); $minimum = $this->provider->getProperty($schema, 'minimum', $this->config->getMinimum()); $exclusiveMaximum = $this->provider->getProperty($schema, 'exclusiveMaximum', false); $exclusiveMinimum = $this->provider->getProperty($schema, 'exclusiveMinimum', false); if (true === $exclusiveMaximum) { $maximum--; } if (true === $exclusiveMinimum) { $maximum++; } $decimals = $float ? $this->generator->numberBetween(0, 4) : 0; $modifier = 1 / pow(10, $decimals); $number = $float ? $this->generator->randomFloat($decimals, $minimum, $maximum) : $this->generator->numberBetween($minimum, $maximum); while ($number % $multipleOf !== 0) { $number += $modifier; } return $number; }
/** * Only seed shops. * * @param Shop $owner */ private function seedAttributes($owner) { if (!$owner instanceof Shop) { return; } if ($this->faker->boolean(20)) { return; } $attributeGroups = $owner->attributeGroups()->saveMany(factory(AttributeGroup::class, $this->faker->numberBetween(2, 4))->make()); $attributeGroups->each(function (AttributeGroup $attributeGroup) { $attributeGroup->attributeOptions()->saveMany(factory(AttributeOption::class, $this->faker->numberBetween(2, 4))->make()); }); $variantManager = app(\App\Modules\ProductModule\Managers\VariantManager::class); /** @var Product[] $products */ $products = $owner->products()->get(); foreach ($products as $product) { if ($this->faker->boolean(20)) { continue; } $options = $attributeGroups->random(2)->pluck('attributeOptions')->flatten(1); $product->attributeOptions()->sync($options->pluck('id')->toArray()); $variantManager->refreshVariants($product); } }
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]; }
/** * {@inheritdoc} */ public function generate(array $config, $outputDir, ProgressHelper $progress, array $options = null) { $this->tmpFile = tempnam(sys_get_temp_dir(), 'data-gene'); if (!empty($config['filename'])) { $this->outputFile = $outputDir . '/' . trim($config['filename']); } else { $this->outputFile = $outputDir . '/' . self::DEFAULT_FILENAME; } $count = (int) $config['count']; $nbAttrBase = (int) $config['filled_attributes_count']; $nbAttrDeviation = (int) $config['filled_attributes_standard_deviation']; $startIndex = (int) $config['start_index']; $categoriesCount = (int) $config['categories_count']; $mandatoryAttributes = $config['mandatory_attributes']; if (!is_array($mandatoryAttributes)) { $mandatoryAttributes = []; } $delimiter = $config['delimiter']; $this->delimiter = $delimiter != null ? $delimiter : self::DEFAULT_DELIMITER; if (isset($config['force_values'])) { $this->forcedValues = $config['force_values']; } else { $this->forcedValues = []; } $this->identifierCode = $this->attributeRepository->getIdentifierCode(); $this->faker = Faker\Factory::create(); for ($i = $startIndex; $i < $startIndex + $count; $i++) { $product = []; $product[$this->identifierCode] = self::IDENTIFIER_PREFIX . $i; $family = $this->getRandomFamily($this->faker); $product['family'] = $family->getCode(); if ($nbAttrBase > 0) { if ($nbAttrDeviation > 0) { $nbAttr = $this->faker->numberBetween($nbAttrBase - round($nbAttrDeviation / 2), $nbAttrBase + round($nbAttrDeviation / 2)); } else { $nbAttr = $nbAttrBase; } } $familyAttrCount = count($this->getAttributesFromFamily($family)); if (!isset($nbAttr) || $nbAttr > $familyAttrCount) { $nbAttr = $familyAttrCount; } $attributes = $this->getRandomAttributesFromFamily($family, $nbAttr); foreach ($attributes as $attribute) { $valueData = $this->generateValue($attribute); $product = array_merge($product, $valueData); } foreach ($mandatoryAttributes as $mandatoryAttribute) { if (isset($this->attributesByFamily[$family->getCode()][$mandatoryAttribute])) { $attribute = $this->attributesByFamily[$family->getCode()][$mandatoryAttribute]; $valueData = $this->generateValue($attribute); $product = array_merge($product, $valueData); } } $categories = $this->getRandomCategoryCodes($categoriesCount); $product[self::CATEGORY_FIELD] = implode(',', $categories); $this->bufferizeProduct($product); $progress->advance(); } $this->writeCsvFile(); unlink($this->tmpFile); return $this; }
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)]; }
/** * Create a random CompanyProfile field. * * @param VisualAppeal\Connect\Company $company (Default: null, newly created) * @param VisualAppeal\Connect\User $user (Default: null, newly created) * * @return VisualAppeal\Connect\CompanyProfile */ protected function createCompanyProfile($company = null, $user = null) { $user = $user ?: $this->createUser(); $company = $company ?: $this->createCompany($user); return \VisualAppeal\Connect\CompanyProfile::create(['company_id' => $company->id, 'title' => strtolower($this->faker->word), 'value' => $this->faker->sentence($this->faker->numberBetween(1, 2)), 'translatable' => false]); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $faker = new Generator(); $faker->addProvider(new Person($faker)); $faker->addProvider(new Internet($faker)); $faker->addProvider(new PhoneNumber($faker)); $faker->addProvider(new Lorem($faker)); // Generate default admin $admin = new User(); $admin->setPlainPassword('123456'); $admin->setEmail('*****@*****.**'); $admin->setEnabled(true); $admin->setType(User::ROLE_ADMIN); $admin->setFirstName($faker->firstName); $admin->setLastName($faker->lastName); $manager->persist($admin); // Generate default student $student = new User(); $student->setPlainPassword('123456'); $student->setEmail('*****@*****.**'); $student->setEnabled(true); $student->setType(User::ROLE_STUDENT); $student->setStudentProfileVisibility(User::VISIBILITY_VISIBLE); $student->setFirstName($faker->firstName); $student->setLastName($faker->lastName); $faker->seed(rand(1, 10)); $studentProfile = new StudentProfile(); $studentProfile->setContactEmail($student->getEmail()); $studentProfile->setHeadline($faker->sentence); $student->setStudentProfile($studentProfile); $manager->persist($student); // Generate stat for student for ($i = 0; $i < 30; $i++) { $numProfileView = rand(0, 15); $numShortlist = rand(0, round($numProfileView / 2)); for ($y = 0; $y < $numProfileView; $y++) { $time = (new \DateTime('now'))->modify('-' . $i . ' days'); $time->setTime(rand(1, 11), rand(1, 30), 0); $statProfileView = new StatProfileView(); $statProfileView->setCreated($time); $statProfileView->setStudent($studentProfile); $manager->persist($statProfileView); } for ($z = 0; $z < $numShortlist; $z++) { $time = (new \DateTime('now'))->modify('-' . $i . ' days'); $time->setTime(rand(1, 11), rand(1, 30), 0); $statShortlist = new StatShortlist(); $statShortlist->setCreated($time); $statShortlist->setStudent($studentProfile); $manager->persist($statShortlist); } } // Generate default member $member = new User(); $member->setPlainPassword('123456'); $member->setEmail('*****@*****.**'); $member->setEnabled(true); $member->setType(User::ROLE_GS1_MEMBER); $member->setFirstName($faker->firstName); $member->setLastName($faker->lastName); $manager->persist($member); // Generate 20 more accounts of students and members for ($i = 0; $i < 20; $i++) { $faker->seed(rand(($i + 1) * 10, ($i + 2) * 10)); $user = new User(); $user->setPlainPassword('123456'); $user->setEmail($faker->email); $user->setEnabled(true); $user->setFirstName($faker->firstName); $user->setLastName($faker->lastName); $shouldBeAMember = $faker->numberBetween(0, 2) == 0; if ($shouldBeAMember) { $user->setType(User::ROLE_GS1_MEMBER); } else { $user->setType(User::ROLE_STUDENT); // disable few students $shouldEnableStudent = $faker->numberBetween(0, 2) != 0; $user->setStudentProfileVisibility($shouldEnableStudent ? User::VISIBILITY_VISIBLE : User::VISIBILITY_HIDDEN); $studentProfile = new StudentProfile(); $studentProfile->setContactEmail($user->getEmail()); $studentProfile->setHeadline($faker->sentence); $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance(); try { $studentProfile->setContactNumber($phoneUtil->parse($faker->mobileNumber, "AU")); } catch (\libphonenumber\NumberParseException $e) { } $user->setStudentProfile($studentProfile); } $manager->persist($user); } $manager->flush(); }
protected function itemAttributes() { return ["article_id" => uniqid(), "article_type" => TestArticle::class, "name" => $this->faker->word, "price" => $this->faker->numberBetween(100, 10000), "quantity" => $this->faker->numberBetween(1, 10), "details" => $this->faker->sentence]; }
/** * @return array */ protected function generateJoinMeetingParams() { return ['meetingId' => $this->faker->uuid, 'userName' => $this->faker->name, 'password' => $this->faker->password, 'userId' => $this->faker->numberBetween(1, 1000), 'webVoiceConf' => $this->faker->word, 'creationTime' => $this->faker->unixTime]; }