Add environment variables for data creation for testing

This commit is contained in:
Ryan Prather 2024-12-25 02:48:32 +00:00
parent 12199b6152
commit 2655848d96
7 changed files with 27 additions and 12 deletions

View File

@ -16,13 +16,15 @@ class MemberCaseFixture extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
if(!$_ENV['CREATE_CASES']) {
return;
}
$sources = $manager->getRepository(ReferralSource::class)->findAll();
$users = $manager->getRepository(User::class)->findAll();
$gen = \Faker\Factory::create();
for ($x = 0; $x < 50; $x++) {
for ($x = 0; $x < $_ENV['CREATE_CASES']; $x++) {
$case = new MemberCase();
$case->setCaseNumber($gen->numberBetween(1000000, 9999999))
->setDcsCaseId($gen->numberBetween(1000000, 9999999))

View File

@ -16,7 +16,9 @@ class MemberFixture extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
if (!$_ENV['CREATE_MEMBERS']) {
return;
}
$gen = \Faker\Factory::create();
$cases = $manager->getRepository(MemberCase::class)->findAll();
@ -24,7 +26,7 @@ class MemberFixture extends Fixture implements DependentFixtureInterface
/** @var MemberCase $case */
$caseLastName = $case->getLastName();
print "Adding members for case {$case->getCaseName()}".PHP_EOL;
$memCount = $gen->numberBetween(0, 5);
$memCount = $gen->numberBetween(0, $_ENV['CREATE_MEMBERS']);
for ($x = 0; $x < $memCount; $x++) {
$isChild = $gen->boolean();
$isParent = ($isChild ? false : $gen->boolean());

View File

@ -19,14 +19,16 @@ class NoteFixture extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
if(!$_ENV['CREATE_NOTES']) {
return;
}
$gen = \Faker\Factory::create();
$refs = $manager->getRepository(Referral::class)->findAll();
foreach ($refs as $ref) {
/** @var Referral $ref */
print "Adding notes for referral {$ref->getReferralId()}".PHP_EOL;
$noteCount = $gen->numberBetween(0, 10);
$noteCount = $gen->numberBetween(0, $_ENV['CREATE_NOTES']);
$case = $ref->getMemberCase();
$caseMembers = $case->getMembers();

View File

@ -13,13 +13,15 @@ class ReferralFixture extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
if(!$_ENV['CREATE_REFERRALS']) {
return;
}
$gen = \Faker\Factory::create();
$cases = $manager->getRepository(MemberCase::class)->findAll();
foreach ($cases as $case) {
print "Adding referrals for case {$case->getCaseNumber()}".PHP_EOL;
$refCount = $gen->numberBetween(0, 2);
$refCount = $gen->numberBetween(0, $_ENV['CREATE_REFERRALS']);
for ($x = 0; $x < $refCount; $x++) {
$ref = new Referral();
$ref->setReferralId($gen->numberBetween(1000000, 9999999))

View File

@ -12,10 +12,12 @@ class ReferralSourceFixture extends Fixture
{
public function load(ObjectManager $manager): void
{
if(!$_ENV['CREATE_SOURCES']) {
return;
}
$gen = Factory::create();
for ($x = 0; $x < 20; $x++) {
for ($x = 0; $x < $_ENV['CREATE_REFERRALS']; $x++) {
$src = new ReferralSource();
$name = "{$gen->firstName()} {$gen->lastName()}";
$username = strtolower(str_replace(' ', '.', $name));

View File

@ -14,6 +14,9 @@ class StaffNoteFixture extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
if(!$_ENV['CREATE_STAFF_NOTES']) {
return;
}
$cases = $manager->getRepository(MemberCase::class)->findAll();
$gen = \Faker\Factory::create();

View File

@ -20,10 +20,12 @@ class UserFixture extends Fixture
public function load(ObjectManager $manager): void
{
if(!$_ENV['CREATE_USERS']) {
return;
}
$comp = $manager->getRepository(Company::class)->findOneBy(['name' => 'Counseling Partners, LLC']);
$gen = \Faker\Factory::create();
for ($x = 0; $x < 20; $x++) {
for ($x = 0; $x < $_ENV['CREATE_USERS']; $x++) {
$user = new User();
$name = $gen->firstName().' '.$gen->lastName();
$username = strtolower(str_replace(' ', '.', $name));