Skip to content

Commit

Permalink
Fix use of internal seeder within open-source modules
Browse files Browse the repository at this point in the history
(cherry picked from commit a946827aae2eca67cb34b8491d7d1485d4d75875)
  • Loading branch information
rootpd committed Aug 12, 2024
1 parent 2c84ac4 commit bc058c1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Seeders/AddressTypesTestSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Crm\UsersModule\Seeders;

use Crm\ApplicationModule\Seeders\ISeeder;
use Crm\UsersModule\Repositories\AddressTypesRepository;
use Symfony\Component\Console\Output\OutputInterface;

class AddressTypesTestSeeder implements ISeeder
{
public const ADDRESS_TYPE = 'crm_test';

public function __construct(private AddressTypesRepository $addressTypesRepository)
{
}

public function seed(OutputInterface $output)
{
$types = [
self::ADDRESS_TYPE => 'Dummy address type for tests',
];

foreach ($types as $type => $title) {
if ($this->addressTypesRepository->findBy('type', $type)) {
$output->writeln(" * address type <info>{$type}</info> exists");
} else {
$this->addressTypesRepository->insert([
'type' => $type,
'title' => $title,
]);
$output->writeln(" <comment>* address type <info>{$type}</info> created</comment>");
}
}
}
}
1 change: 1 addition & 0 deletions src/config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ services:
- Crm\UsersModule\Seeders\UsersSeeder
- Crm\UsersModule\Seeders\SnippetsSeeder
- Crm\UsersModule\Seeders\MeasurementsSeeder
- Crm\UsersModule\Seeders\AddressTypesTestSeeder
- Crm\UsersModule\Components\UserSourceAccesses\UserSourceAccesses
- Crm\UsersModule\Components\UserTokens\UserTokens
- Crm\UsersModule\Models\Auth\Rate\WrongPasswordRateLimit
Expand Down

0 comments on commit bc058c1

Please sign in to comment.