elythyr / prooph-fixtures
首次尝试用Prooph实现类似DoctrineFixtures的功能
v1.1
2019-02-03 12:17 UTC
Requires
- prooph/event-store: ^7.5
- psr/container: ^1.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.1
- phpunit/php-invoker: ^2.0
- phpunit/phpunit: ^7.5
- prooph/php-cs-fixer-config: ^0.3.0
This package is auto-updated.
Last update: 2024-09-29 04:14:43 UTC
README
在我对ES的实验过程中,我发现自己缺少Doctrine数据固定工具。
因此,我决定尝试为Prooph重现类似的功能。
安装
哦,甜蜜的Composer!
composer require --dev elythyr/prooph-fixtures
版本管理
由于这是一个练习项目,我并不关心BC中断。我只尝试不破坏小版本,这意味着
- 从
1.0.0
更新到1.0.9
不应该破坏任何东西 - 从
1.0.0
更新到1.1.0
可能会破坏很多东西
配置
实际上没有配置。所有配置都应该已经完成,更多信息请参见Prooph EventStore。
使用方法
如何配置各个部分的示例
// /test.php // Configure your system: // Replace it by your own container or create everything manually :'( $container = new class() implements ContainerInterface { public function has($id) { return false; } public function get($id) { return null; } }; // Retrieve your event store $eventStore = $container->get('event_store'); // Create a provider for your fixtures $fixturesProvider = new InMemoryFixturesProvider([ $youContainer->get('a_fixture'), $youContainer->get('another_fixture'), // ... ]); // Retrieve the cleaning projection strategy // No implementations are provided since it depends on your EventStore implementation $cleaningProjectionStrategy = $container->get('cleaning_projection_strategy'); // Retrieve the names of all your projections $projectionsNames = $container->get('projections_names'); // Create the cleaner you want to use, here we will clean both event streams and projections $cleaner = new ChainCleaner([ new EventStreamsCleaner($eventStore), new ProjectionsCleaner( $cleaningProjectionStrategy, $projectionsNames ), ]); // Create the fixtures manager, just a front to regroup everything in one place $fixturesManager = new FixturesManager($fixturesProvider, $cleaner); // Lets do some cleaning ! $fixturesManager->cleanUp(); // Loading is so easy, you can do it yourself :) // Under the hood the manager do all the heavy lifting by ordering the fixtures foreach ($fixturesManager->getFixtures() as $fixture) { $fixture->load(); }
待办事项
- 添加Travis CI
- 添加测试覆盖率
- 发布第一个版本
- 发布到Packagist
- (如有需要)添加不清理数据库的可能性
- (如有需要)添加加载固定件的过滤功能