Skip to content

Commit

Permalink
Fixtures load console command (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
misantron committed May 25, 2023
1 parent 1016461 commit afdfa49
Show file tree
Hide file tree
Showing 13 changed files with 820 additions and 240 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ declare(strict_types=1);
namespace Fixtures;

use Dynamite\AbstractTable;
use Dynamite\Attribute\Groups;
use Dynamite\Enum\KeyTypeEnum;
use Dynamite\Enum\ProjectionTypeEnum;
use Dynamite\Enum\ScalarAttributeTypeEnum;
use Dynamite\TableInterface;
use Dynamite\Schema\Attribute;

#[Groups(['group1'])] // groups can be used optionally with console command
final class UsersTable extends AbstractTable implements TableInterface
{
protected function configure(): void
Expand Down Expand Up @@ -71,10 +73,12 @@ declare(strict_types=1);
namespace Fixtures;

use Dynamite\AbstractFixture;
use Dynamite\Attribute\Groups;
use Dynamite\FixtureInterface;
use Dynamite\Schema\Record;
use Dynamite\Schema\Value;

#[Groups(['group1'])] // groups can be used optionally with console command
final class UserFixtures extends AbstractFixture implements FixtureInterface
{
protected function configure(): void
Expand Down Expand Up @@ -150,6 +154,7 @@ declare(strict_types=1);

use Dynamite\Client;
use Dynamite\Executor;
use Dynamite\Loader;
use Dynamite\Serializer\PropertyNameConverter;
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
Expand All @@ -170,12 +175,20 @@ $clientFactory = new ClientFactory($serializer);
$loader = new Loader($validator, $serializer);
$loader->loadFromDirectory('/path/to/YourFixtures');

$groups = ['group1']; // loading fixtures belong to the selected group only

$executor = new Executor($clientFactory->createAsyncAwsClient());
$executor->execute($loader->getFixtures(), $loader->getTables());
$executor->execute($loader->getFixtures($groups), $loader->getTables($groups));
```

**Important!** Each executor class comes with a purger class which executed before, drop tables and truncate data.

### Load fixtures via console command

```shell
bin/console dynamite:fixtures:load --path path/to/fixtures
```

### Debug logger

Execution process debug logs can be enabled by passing PSR-3 logger into executor:
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"require": {
"php": "^8.1",
"psr/log": "^2.0 || ^3.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/property-access": "^5.4 || ^6.0",
"symfony/serializer": "^5.4 || ^6.0",
"symfony/validator": "^5.4 || ^6.0",
Expand Down
Loading

0 comments on commit afdfa49

Please sign in to comment.